decocms 4.174.1 → 4.175.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/dist/client/assets/{AlertCircle-B4EXMryE.js → AlertCircle-gBgC-IDj.js} +1 -1
  2. package/dist/client/assets/{AreaChart-BW_1EjBM.js → AreaChart-DF037x7j.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-CE-yCN3S.js → ArrowUp-v9chKyHK.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-CDC0lOOc.js → ArrowUpRight-DQ-en6iJ.js} +1 -1
  5. package/dist/client/assets/{Check--awAyRiE.js → Check-Cm0N5Xp1.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-BTsHwKjD.js → CheckCircle-DNkhRFtL.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-DKFpNRQV.js → ChevronDown-CGpzF5Tp.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-oqk6atiG.js → ChevronRight-uYqx7PHp.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-B1iChrb_.js → ChevronUp-BbYR_cV6.js} +1 -1
  10. package/dist/client/assets/{Copy01-ChjW-25q.js → Copy01-B9wS1vC-.js} +1 -1
  11. package/dist/client/assets/{CpuChip01-CTWqWAa1.js → CpuChip01-AWVpXsY4.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-CEVcKsGC.js → DotsVertical-D_I0FzwU.js} +1 -1
  13. package/dist/client/assets/{Eye-BYcnMHWS.js → Eye-Dg_Cwp5s.js} +1 -1
  14. package/dist/client/assets/{FilterLines-zBYCQkr6.js → FilterLines-BaP3cCYD.js} +1 -1
  15. package/dist/client/assets/{HardDrive-DLU9CuiI.js → HardDrive-BpCOR94X.js} +1 -1
  16. package/dist/client/assets/{Key01-Dsj6C6J4.js → Key01-DeHkxCcX.js} +1 -1
  17. package/dist/client/assets/{LayoutLeft-rZo4YFaS.js → LayoutLeft-wIcrY_QM.js} +1 -1
  18. package/dist/client/assets/{LinkExternal01-DvgyySBY.js → LinkExternal01-BKiT6Lg5.js} +1 -1
  19. package/dist/client/assets/{LogOut01-BqjYwQ-L.js → LogOut01-THqSoWGX.js} +1 -1
  20. package/dist/client/assets/{Monitor01-BDyk0CCy.js → Monitor01-CaaXe9Ty.js} +1 -1
  21. package/dist/client/assets/{Palette-BHqZm1BB.js → Palette-BFT2IxVH.js} +1 -1
  22. package/dist/client/assets/{Play-UYeserO3.js → Play-D6dqRBBL.js} +1 -1
  23. package/dist/client/assets/{Plus-DvOe1im7.js → Plus-CzX8ksPj.js} +1 -1
  24. package/dist/client/assets/{SearchLg-CALh2CD9.js → SearchLg-ClRKcOmG.js} +1 -1
  25. package/dist/client/assets/{SearchMd-D-mNON36.js → SearchMd-CChGc0qj.js} +1 -1
  26. package/dist/client/assets/{Settings02-tIAH8kc5.js → Settings02-Cndba0CR.js} +1 -1
  27. package/dist/client/assets/{Shield01-NeMGEmcP.js → Shield01-BcYc_LI3.js} +1 -1
  28. package/dist/client/assets/{Star01-DZY7bO--.js → Star01-DrbVBTPI.js} +1 -1
  29. package/dist/client/assets/{Stars01-CnoqJq4o.js → Stars01-2HJFeMi3.js} +1 -1
  30. package/dist/client/assets/{Stars02-KR5W7Tx-.js → Stars02-BBw_PSwc.js} +1 -1
  31. package/dist/client/assets/{Sun-CuSypPJ3.js → Sun-CMRBSsx9.js} +1 -1
  32. package/dist/client/assets/{SwitchHorizontal01-DPkmWInI.js → SwitchHorizontal01-jLNSp4oB.js} +1 -1
  33. package/dist/client/assets/{Tool01-DoJO-7ts.js → Tool01-EzL5AMRE.js} +1 -1
  34. package/dist/client/assets/{Tool02-DVf19DQg.js → Tool02-7CeN_eX3.js} +1 -1
  35. package/dist/client/assets/{Trash01-CJyWVEey.js → Trash01-DI04PDkF.js} +1 -1
  36. package/dist/client/assets/{TrendUp01-VQoprwQR.js → TrendUp01-rmhNgtoT.js} +1 -1
  37. package/dist/client/assets/{Upload01-D8tavvhY.js → Upload01-BfNUVrdU.js} +1 -1
  38. package/dist/client/assets/{User01-bpOKqEwm.js → User01-BpfKnMCd.js} +1 -1
  39. package/dist/client/assets/{Users01-DXQ-IFKV.js → Users01-Biz3dQtc.js} +1 -1
  40. package/dist/client/assets/{Users03-DinXE2Wu.js → Users03-B7VhAJ6s.js} +1 -1
  41. package/dist/client/assets/{X-5tNp0CwX.js → X-BeHJXMOX.js} +1 -1
  42. package/dist/client/assets/{XCircle-DIvFZUMd.js → XCircle-DsfZK6Fi.js} +1 -1
  43. package/dist/client/assets/{XClose-DpesLh8g.js → XClose-yEy6wJCH.js} +1 -1
  44. package/dist/client/assets/{Zap-D7pCF_wi.js → Zap-B_be8ugm.js} +1 -1
  45. package/dist/client/assets/{ZapSquare-C-8aSQkC.js → ZapSquare-0UHU2E1-.js} +1 -1
  46. package/dist/client/assets/{access-gate-JTL9F01y.js → access-gate-arSA2CqL.js} +1 -1
  47. package/dist/client/assets/{add-section-modal-CVGOibAu.js → add-section-modal-Dyf6Zk_Q.js} +1 -1
  48. package/dist/client/assets/{agent-icon-CwxJJE2K.js → agent-icon-BB8mzMQ9.js} +1 -1
  49. package/dist/client/assets/{agents-list-DRL99wiP.js → agents-list-Dpi4dokW.js} +1 -1
  50. package/dist/client/assets/{ai-providers-DUPX2I1x.js → ai-providers-ouqrsg4Y.js} +1 -1
  51. package/dist/client/assets/{alert-Bv2pabsO.js → alert-CNw5Haa7.js} +1 -1
  52. package/dist/client/assets/{alert-dialog-CKs9ou3V.js → alert-dialog-C2Nzx1YE.js} +1 -1
  53. package/dist/client/assets/{app-editor-C1RTaban.js → app-editor-DoKHzAzj.js} +1 -1
  54. package/dist/client/assets/{auth-BtpL_i8R.js → auth-B48EtwHB.js} +1 -1
  55. package/dist/client/assets/{auth-catchall-DkC6fqCv.js → auth-catchall-fbg8isTq.js} +1 -1
  56. package/dist/client/assets/{auth-entry-MRnremUf.js → auth-entry-jx5uMJTi.js} +1 -1
  57. package/dist/client/assets/{auth-split-layout-Bk4paAz2.js → auth-split-layout-eaae3FHA.js} +1 -1
  58. package/dist/client/assets/{authenticate-and-persist-oauth-DutNqAro.js → authenticate-and-persist-oauth-Di8-syFQ.js} +1 -1
  59. package/dist/client/assets/{automation-list-row-BbAxqhi2.js → automation-list-row-VQ5g6Dhp.js} +1 -1
  60. package/dist/client/assets/{automation-runs-qxx1Thgk.js → automation-runs-T-6LDbI3.js} +1 -1
  61. package/dist/client/assets/{automations-jRrVlG9H.js → automations-5RUzkP69.js} +1 -1
  62. package/dist/client/assets/{avatar-BXJjsQ__.js → avatar-JHFTWNp7.js} +1 -1
  63. package/dist/client/assets/{badge-B05N3Qt9.js → badge-CttcUU9Z.js} +1 -1
  64. package/dist/client/assets/{block-document-lt-cvXZW.js → block-document-DF1N1JC6.js} +1 -1
  65. package/dist/client/assets/{brand-context-Yy3jNeuV.js → brand-context-49-nr2gz.js} +1 -1
  66. package/dist/client/assets/{buckets-BRkkTtrs.js → buckets-DD20ONF1.js} +1 -1
  67. package/dist/client/assets/{bulk-category-panel-BjWnDJg5.js → bulk-category-panel-Bxz1yeRr.js} +1 -1
  68. package/dist/client/assets/{calendar-ClYFx9c2.js → calendar-Bi3Ui_zb.js} +1 -1
  69. package/dist/client/assets/{capability-load-error-DLF7zw4o.js → capability-load-error-C36707hz.js} +1 -1
  70. package/dist/client/assets/{card-CjfWSaTo.js → card-CkiEgOp1.js} +1 -1
  71. package/dist/client/assets/{category-editor-Chof72Vs.js → category-editor-7Es3bqJO.js} +1 -1
  72. package/dist/client/assets/{chat-context-CD_qCtCt.js → chat-context-ZANxeYW1.js} +1 -1
  73. package/dist/client/assets/{checkbox-CpgxDNSJ.js → checkbox-oXBpggwR.js} +1 -1
  74. package/dist/client/assets/{cli-auth-success-BOS2WhZl.js → cli-auth-success-DA5i-h2V.js} +1 -1
  75. package/dist/client/assets/{collection-detail-Be8hGbYN.js → collection-detail-DjjIpN3b.js} +1 -1
  76. package/dist/client/assets/{collection-display-button-DjW_4xIE.js → collection-display-button-CzlQ3-Ru.js} +1 -1
  77. package/dist/client/assets/{collection-search-B3ZqBcL8.js → collection-search-BECJRGvb.js} +1 -1
  78. package/dist/client/assets/{collection-table-wrapper-D623qF5a.js → collection-table-wrapper-Dqudguu6.js} +1 -1
  79. package/dist/client/assets/{collection-tabs-PzOPdepY.js → collection-tabs-DLgcQ9vN.js} +1 -1
  80. package/dist/client/assets/{command-C5d3qMjy.js → command-BwpPSuEK.js} +1 -1
  81. package/dist/client/assets/{commerce-onboarding-gDONlvlM.js → commerce-onboarding-CpUDWDPF.js} +1 -1
  82. package/dist/client/assets/{companions-core-x_QAOzgo.js → companions-core-CZj6AdLP.js} +1 -1
  83. package/dist/client/assets/{connect-CD6rJ5oE.js → connect-pkqfGkBp.js} +1 -1
  84. package/dist/client/assets/{connection-BpgZwkjC.js → connection-Cp9yA2cA.js} +1 -1
  85. package/dist/client/assets/{connection-card-C4EvbBvT.js → connection-card-CHCG5YLX.js} +1 -1
  86. package/dist/client/assets/{connection-detail-DmtwNo81.js → connection-detail-BgdGMvJ-.js} +1 -1
  87. package/dist/client/assets/{connection-form-helpers-Dl-r3-ed.js → connection-form-helpers-BTPKH1hE.js} +1 -1
  88. package/dist/client/assets/{connections-DA6fP2xs.js → connections-VPa6zhqx.js} +1 -1
  89. package/dist/client/assets/{decopilot-sse-pool-BJgHi1AV.js → decopilot-sse-pool-CdUwcdgN.js} +1 -1
  90. package/dist/client/assets/{dialog-Bmcw4MC1.js → dialog-3W-8IScJ.js} +1 -1
  91. package/dist/client/assets/{domain-settings-B9pg0e8h.js → domain-settings-DFOMNmtP.js} +1 -1
  92. package/dist/client/assets/{drawer-iuNGEK9E.js → drawer-BfyjUlUf.js} +1 -1
  93. package/dist/client/assets/{dropdown-menu-C57Z0WbH.js → dropdown-menu-D6c-yNXN.js} +1 -1
  94. package/dist/client/assets/{empty-state-oynOKM_3.js → empty-state-DSeXLvMa.js} +1 -1
  95. package/dist/client/assets/{extract-connection-data-BgVQcpwU.js → extract-connection-data-916x9paw.js} +1 -1
  96. package/dist/client/assets/{file-explorer-DSfni5rf.js → file-explorer-DKbMJMdh.js} +1 -1
  97. package/dist/client/assets/{form-CmD9PvlR.js → form-DN_EVxGu.js} +1 -1
  98. package/dist/client/assets/{general-DGFk_kQL.js → general-DDGPXHK7.js} +1 -1
  99. package/dist/client/assets/{github-repo-picker-DEmqqmkZ.js → github-repo-picker-BMroiuBR.js} +1 -1
  100. package/dist/client/assets/{hooks-cLtEcBwH.js → hooks-BzCUuOns.js} +2 -2
  101. package/dist/client/assets/{index-CWWq105T.js → index-B9SJSEs8.js} +3 -3
  102. package/dist/client/assets/{index-C6yF4S4F.js → index-B9Sd5SNY.js} +1 -1
  103. package/dist/client/assets/{index-zCik4qTM.js → index-BmfagrE5.js} +1 -1
  104. package/dist/client/assets/{index-wVkH9Hey.js → index-Ci2-WeDM.js} +3 -3
  105. package/dist/client/assets/{index-DtOslnK_.js → index-Ck3OddUp.js} +1 -1
  106. package/dist/client/assets/{index-CDjXqP5m.js → index-CxLtShDr.js} +1 -1
  107. package/dist/client/assets/{index-C8G3xJVT.js → index-D1Wg8_dp.js} +5 -5
  108. package/dist/client/assets/{index-BF_ESf7y.js → index-DHH-tyXp.js} +1 -1
  109. package/dist/client/assets/{index-DNv5bquW.js → index-DiTRDbD6.js} +1 -1
  110. package/dist/client/assets/{index-rXqZaKsD.js → index-DyLXmCq2.js} +1 -1
  111. package/dist/client/assets/{index-BdcvDJP6.js → index-cyN-8TNg.js} +1 -1
  112. package/dist/client/assets/{index-redirect-DPK1g0Bw.js → index-redirect-BAIh-u-t.js} +1 -1
  113. package/dist/client/assets/{input-By24O0su.js → input-CSbRtiVQ.js} +1 -1
  114. package/dist/client/assets/{integration-icon-Bfc2y9D6.js → integration-icon-CUPPNkWn.js} +1 -1
  115. package/dist/client/assets/{invite-member-dialog-gjw9HVtr.js → invite-member-dialog-DxNsaS30.js} +1 -1
  116. package/dist/client/assets/{label-D2_SLZN8.js → label-DGvaEu-Z.js} +1 -1
  117. package/dist/client/assets/{layout-DFvZMlXD.js → layout-BhCe4UGa.js} +1 -1
  118. package/dist/client/assets/{login-Ce2mVkRp.js → login-CytzYVev.js} +1 -1
  119. package/dist/client/assets/{mcp-oauth-DcAWH2Cr.js → mcp-oauth-BDiXNpWl.js} +1 -1
  120. package/dist/client/assets/{members-C9uzckYa.js → members-N9Lk_KYA.js} +1 -1
  121. package/dist/client/assets/{monaco-editor-XCUu8nXj.js → monaco-editor-CppjdLmN.js} +1 -1
  122. package/dist/client/assets/{monitoring-stats-row-CnMpV0Yu.js → monitoring-stats-row-CDiSTj0B.js} +1 -1
  123. package/dist/client/assets/{multi-select-DWvdNdae.js → multi-select-DPkl-fQc.js} +1 -1
  124. package/dist/client/assets/{oauth-callback-ai-provider-By9YPAnH.js → oauth-callback-ai-provider-D4vEiIZK.js} +1 -1
  125. package/dist/client/assets/{oauth-callback-BPdfuWbk.js → oauth-callback-urJEesdj.js} +1 -1
  126. package/dist/client/assets/{onboarding-9fJgJ59j.js → onboarding-NMD7Rgsh.js} +1 -1
  127. package/dist/client/assets/{org-layout-C2yB6PrL.js → org-layout-3FbPnKCH.js} +1 -1
  128. package/dist/client/assets/{organization-choice-BC2h8c4u.js → organization-choice-DRlimkmR.js} +1 -1
  129. package/dist/client/assets/{orgs-upIvvu6k.js → orgs-BS-I92U-.js} +1 -1
  130. package/dist/client/assets/{page-seo-form-Dwd-qW30.js → page-seo-form--knIJHxX.js} +1 -1
  131. package/dist/client/assets/{popover-C0CdM3s5.js → popover-C5IHpjj7.js} +1 -1
  132. package/dist/client/assets/{post-editor-DMNEDYTW.js → post-editor-Cyb7CBZu.js} +1 -1
  133. package/dist/client/assets/{primitives-DeELRq7p.js → primitives-eKxr__L-.js} +1 -1
  134. package/dist/client/assets/{profile-Dh1EdV6q.js → profile-BLo-8uaY.js} +1 -1
  135. package/dist/client/assets/project-app-view-DI33Uf1W.js +1 -0
  136. package/dist/client/assets/record-editor-DASq4Mkh.js +1 -0
  137. package/dist/client/assets/{redirect-editor-CZ9vkr1g.js → redirect-editor-pTxMMIka.js} +1 -1
  138. package/dist/client/assets/registry-BC2bizEu.js +2 -0
  139. package/dist/client/assets/{registry-layout-BWuOh9p-.js → registry-layout-CCN-tAs-.js} +1 -1
  140. package/dist/client/assets/{reports-CTE3zjw4.js → reports-N2zbxBuL.js} +1 -1
  141. package/dist/client/assets/{require-capability-BjImA_Z3.js → require-capability-C0gWEvXs.js} +1 -1
  142. package/dist/client/assets/{required-auth-layout-CHjKRNNN.js → required-auth-layout-Cadc6LjF.js} +1 -1
  143. package/dist/client/assets/{reset-password-CBJFQYdF.js → reset-password-BwyQEavx.js} +1 -1
  144. package/dist/client/assets/{roles-BZPr68Tm.js → roles-CnA68_xi.js} +1 -1
  145. package/dist/client/assets/{search-input-iGzq6vPG.js → search-input-DwPTNKRK.js} +1 -1
  146. package/dist/client/assets/{secrets-D261TPKi.js → secrets-C4eJ6A5S.js} +1 -1
  147. package/dist/client/assets/{sections-editor-BxWRIXWO.js → sections-editor-BK545TXJ.js} +1 -1
  148. package/dist/client/assets/{select-model-BwxjW1D6.js → select-model-DF2yexj8.js} +1 -1
  149. package/dist/client/assets/{select-DT8NSv1e.js → select-ntnc0DeD.js} +1 -1
  150. package/dist/client/assets/{self-tool-result-3InEPzBn.js → self-tool-result-CUYnn309.js} +1 -1
  151. package/dist/client/assets/{seo-editor-BfTPuUjv.js → seo-editor-D8ISmwI0.js} +1 -1
  152. package/dist/client/assets/{settings-layout-7laZ5_jX.js → settings-layout-BuncGk0j.js} +1 -1
  153. package/dist/client/assets/{settings-section-CqFnLq2j.js → settings-section-DLpWTC0i.js} +1 -1
  154. package/dist/client/assets/{shell-controls-BB4-pRNT.js → shell-controls-DXy1fqcy.js} +1 -1
  155. package/dist/client/assets/{shell-layout-B2_a9w8c.js → shell-layout-C8vXpdx8.js} +1 -1
  156. package/dist/client/assets/{sidebar-BOvgK9ES.js → sidebar-gTBPMKXv.js} +1 -1
  157. package/dist/client/assets/{skeleton-DBuazYGk.js → skeleton-DB9zRkhz.js} +1 -1
  158. package/dist/client/assets/{spinner-DbYXU-jD.js → spinner-CoHgFrQQ.js} +1 -1
  159. package/dist/client/assets/{sso-BPe1qHc5.js → sso-RvH9UTzx.js} +1 -1
  160. package/dist/client/assets/{store-Byk8t8es.js → store-DMSKzAh9.js} +1 -1
  161. package/dist/client/assets/store-registry-tM2ZixeZ.js +2 -0
  162. package/dist/client/assets/{studio-tools-C7ofaafW.js → studio-tools-CMu0zejY.js} +1 -1
  163. package/dist/client/assets/{switch-DdnpQ1IG.js → switch-D3xcu-F2.js} +1 -1
  164. package/dist/client/assets/{tab-id-CbsMWzCZ.js → tab-id-zqDmuOai.js} +1 -1
  165. package/dist/client/assets/{table-CAXMh-Gw.js → table-0P2Wc2TK.js} +1 -1
  166. package/dist/client/assets/{tabs-BS-FUGEp.js → tabs-Bx87nE6V.js} +1 -1
  167. package/dist/client/assets/{textarea-CgQMTjfl.js → textarea-DZs2CdHW.js} +1 -1
  168. package/dist/client/assets/{toggle-group-Dqfq2Zgx.js → toggle-group-skqXoHrg.js} +1 -1
  169. package/dist/client/assets/{toolbar-D0JRORj9.js → toolbar-MZ2ylwjL.js} +1 -1
  170. package/dist/client/assets/{tooltip-CuruP4hv.js → tooltip-C5kLfH4m.js} +1 -1
  171. package/dist/client/assets/{use-ai-providers-0iGJhTPy.js → use-ai-providers-5zLZx5j1.js} +1 -1
  172. package/dist/client/assets/{use-automations-B73p3VIh.js → use-automations-4THjPRL2.js} +1 -1
  173. package/dist/client/assets/{use-autosave-CPplNQe8.js → use-autosave-CFwkwQtT.js} +1 -1
  174. package/dist/client/assets/{use-capability-CW01fCtS.js → use-capability-Bk-mxsYF.js} +1 -1
  175. package/dist/client/assets/{use-clock-tick-FfcOO8sN.js → use-clock-tick-DiU5xSPA.js} +1 -1
  176. package/dist/client/assets/{use-connection-ByXmZyC6.js → use-connection-VGJh4zjw.js} +1 -1
  177. package/dist/client/assets/{use-copy-Eo3h7Fu7.js → use-copy-ugNCdSAD.js} +1 -1
  178. package/dist/client/assets/{use-create-virtual-mcp-Bpsav4jR.js → use-create-virtual-mcp-D5NOiXHC.js} +1 -1
  179. package/dist/client/assets/{use-debounced-autosave-DN5kkEbU.js → use-debounced-autosave-BmApGYN6.js} +1 -1
  180. package/dist/client/assets/{use-debounced-value-DQW5NZnQ.js → use-debounced-value-CfDM0Jhq.js} +1 -1
  181. package/dist/client/assets/{use-deco-credits-DxNlIYxY.js → use-deco-credits-B4UjorXb.js} +1 -1
  182. package/dist/client/assets/{use-decopilot-events-Bm2XYdS-.js → use-decopilot-events-D5dgQ5AI.js} +1 -1
  183. package/dist/client/assets/{use-delete-connection-D-cgjBTx.js → use-delete-connection-CUR9j-BP.js} +1 -1
  184. package/dist/client/assets/{use-deployment-admin-CGdQY9U3.js → use-deployment-admin-BixrzrZ5.js} +1 -1
  185. package/dist/client/assets/{use-file-configs-DwQyBTH3.js → use-file-configs-CHUmsqsc.js} +1 -1
  186. package/dist/client/assets/{use-infinite-scroll-CEdNmWZK.js → use-infinite-scroll-BthWIatn.js} +1 -1
  187. package/dist/client/assets/{use-join-requests-B8nZzlAV.js → use-join-requests-BTozyIE4.js} +1 -1
  188. package/dist/client/assets/{use-mcp-auth-status-DszggueQ.js → use-mcp-auth-status-B6ROc3dd.js} +1 -1
  189. package/dist/client/assets/{use-mcp-client-WCmcRc0D.js → use-mcp-client-CaVVZEYW.js} +1 -1
  190. package/dist/client/assets/{use-mcp-tools-CsS3rGzl.js → use-mcp-tools-DvuJ8P5F.js} +1 -1
  191. package/dist/client/assets/{use-members-BYonxqoz.js → use-members-Csv5Hp9l.js} +1 -1
  192. package/dist/client/assets/{use-mobile-BzaYWdHG.js → use-mobile-CsZZ5Bco.js} +1 -1
  193. package/dist/client/assets/{use-navigate-to-agent-B4o6F9Ux.js → use-navigate-to-agent-D3FDvvrd.js} +1 -1
  194. package/dist/client/assets/{use-org-auth-client-COTYDmMf.js → use-org-auth-client-DJ5wJM3W.js} +1 -1
  195. package/dist/client/assets/{use-org-sso-CwSQr68v.js → use-org-sso-aOrIhTdJ.js} +1 -1
  196. package/dist/client/assets/{use-organization-roles-BjFNJXJ2.js → use-organization-roles-Bl34Q4rS.js} +1 -1
  197. package/dist/client/assets/{use-organization-settings-DByF75VD.js → use-organization-settings-Teu3tLzq.js} +1 -1
  198. package/dist/client/assets/{use-registry-connections-Bsaeevnu.js → use-registry-connections-Y3AY23BD.js} +1 -1
  199. package/dist/client/assets/{use-secrets-BRk1ecVp.js → use-secrets-BPoLBbik.js} +1 -1
  200. package/dist/client/assets/{use-status-sounds-CN8wTS-A.js → use-status-sounds-BhdAWgIR.js} +1 -1
  201. package/dist/client/assets/{use-tags-BBmiQbRw.js → use-tags-DaZQsGJQ.js} +1 -1
  202. package/dist/client/assets/{use-view-mode-C5Wmyb5Q.js → use-view-mode-Dm0_QE6W.js} +1 -1
  203. package/dist/client/assets/{use-virtual-mcp-Cc8Hqm89.js → use-virtual-mcp-6nLwy6c-.js} +1 -1
  204. package/dist/client/assets/useInfiniteQuery-BsbZizup.js +1 -0
  205. package/dist/client/assets/{useQueries-BZJwkoPb.js → useQueries-DEhpvmrD.js} +1 -1
  206. package/dist/client/assets/{useRouterState-CoxPriSc.js → useRouterState-DHCxiPwV.js} +1 -1
  207. package/dist/client/assets/useSuspenseInfiniteQuery-__xFXx7Y.js +1 -0
  208. package/dist/client/assets/{users-2MehsVpR.js → users-CzCIQeS6.js} +1 -1
  209. package/dist/client/assets/{variant-calendar-s56AwaM0.js → variant-calendar-Ct0BNjVX.js} +1 -1
  210. package/dist/client/assets/{view-mode-toggle-B1kMmEuC.js → view-mode-toggle-CA1P05si.js} +1 -1
  211. package/dist/client/index.html +1 -1
  212. package/dist/server/cli.js +462 -458
  213. package/dist/server/migrate.js +88 -84
  214. package/dist/server/server.js +380 -380
  215. package/package.json +1 -1
  216. package/dist/client/assets/project-app-view-BtReYMtz.js +0 -1
  217. package/dist/client/assets/record-editor-6lnacVYh.js +0 -1
  218. package/dist/client/assets/registry-BjpUg1iD.js +0 -2
  219. package/dist/client/assets/store-registry-Eotj-n1q.js +0 -2
  220. package/dist/client/assets/useInfiniteQuery-CXubmdVt.js +0 -1
  221. package/dist/client/assets/useSuspenseInfiniteQuery-BMu2Dtrs.js +0 -1
@@ -1 +1 @@
1
- import{c as M,j as t,F as de,a as ye,o as me,r as $,a0 as le,b as ee,k as Z,e as ge,t as te,d$ as Ne,K as se,G as ke,n as ve,m as ae,B as re,x as Ce,y as Re}from"./index-wVkH9Hey.js";import{a as we,b as Pe,d as Se,e as Ie}from"./dialog-Bmcw4MC1.js";import{C as Te}from"./collection-search-B3ZqBcL8.js";import{u as _e}from"./use-debounced-value-DQW5NZnQ.js";import{b as he,u as Ee}from"./use-connection-ByXmZyC6.js";import{W as Ae,u as ne,S as pe}from"./use-mcp-client-WCmcRc0D.js";import{a as be}from"./authenticate-and-persist-oauth-DutNqAro.js";import{b as ue}from"./Settings02-tIAH8kc5.js";import{n as ze}from"./LinkExternal01-DvgyySBY.js";import{T as Le}from"./agent-icon-CwxJJE2K.js";import{u as Ge}from"./use-mcp-tools-CsS3rGzl.js";import{e as Oe}from"./extract-connection-data-BgVQcpwU.js";import{c as Fe}from"./use-navigate-to-agent-B4o6F9Ux.js";import{g as Ue,p as fe,f as $e,G as xe}from"./provision-repo-scoped-github-connection-B2s3ApVy.js";function D(C){const e=M.c(4),{size:n,className:l}=C;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z"}),e[0]=p):p=e[0];let o;return e[1]!==l||e[2]!==n?(o=t.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:l,children:p}),e[1]=l,e[2]=n,e[3]=o):o=e[3],o}function He(C,e){const n=M.c(12),{org:l}=de();let p;n[0]!==l.id?(p=Ae.REGISTRY(l.id),n[0]=l.id,n[1]=p):p=n[1];const o=p;let a;n[2]!==l.id||n[3]!==l.slug||n[4]!==o?(a={connectionId:o,orgId:l.id,orgSlug:l.slug},n[2]=l.id,n[3]=l.slug,n[4]=o,n[5]=a):a=n[5];const r=ne(a);let s;n[6]!==C?(s={name:C},n[6]=C,n[7]=s):s=n[7];const u=e?.enabled??!0;let N;return n[8]!==r||n[9]!==s||n[10]!==u?(N={client:r,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:s,enabled:u,staleTime:3e5,select:De},n[8]=r,n[9]=s,n[10]=u,n[11]=N):N=n[11],Ge(N)}function De(C){return C.structuredContent?.item??null}const Me="deco/mcp-github";function Be(C){const{org:e}=de(),{data:n}=ye.useSession(),l=he(),p=me(),[o,a]=$.useState("idle"),[r,s]=$.useState(null),[u,N]=$.useState(null),{data:k,isLoading:P}=He(Me,{enabled:C.enabled}),f=$.useRef(!1);C.enabled&&k&&!P&&!f.current&&n?.user?.id&&o==="idle"&&(f.current=!0,d());async function d(){if(!(!k||!n?.user?.id||!e))try{a("installing"),s(null);const c=Oe(k,e.id,n.user.id,{remoteIndex:0});if(!c.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:g}=await l.create.mutateAsync(c);a("authenticating");const j=await be({connectionId:g,orgId:e.id,orgSlug:e.slug,persistFallback:x=>l.update.mutateAsync({id:g,data:{connection_token:x}}).then(()=>{})});if(j.ran&&!j.ok){try{await l.delete.mutateAsync(g)}catch{}throw new Error(j.error&&j.error!=="no token received"?j.error:"No token received from GitHub")}le(p,e.id),N(c),a("ready")}catch(c){s(c instanceof Error?c.message:String(c)),a("error")}}function m(){a("idle"),s(null),N(null),f.current=!1}return C.enabled&&P&&o==="idle"?{status:"installing",error:null,connection:null,retry:m}:{status:o,error:r,connection:u,retry:m}}function dt(C){const e=M.c(27),{open:n,onOpenChange:l,title:p,onImportComplete:o,mode:a}=C,r=a===void 0?"agent":a,s=ee();let u;e[0]!==r||e[1]!==s||e[2]!==p?(u=p??s(r==="connection"?"common.githubRepoPicker.addRepo":"common.githubRepoPicker.importFromGitHub"),e[0]=r,e[1]=s,e[2]=p,e[3]=u):u=e[3];const N=u,[k,P]=$.useState(null);let f;e[4]!==N?(f=t.jsx(we,{className:"sr-only",children:t.jsx(Pe,{children:N})}),e[4]=N,e[5]=f):f=e[5];let d;e[6]!==N||e[7]!==k||e[8]!==s?(d=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:k?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>P(null),className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors shrink-0","aria-label":s("common.githubRepoPicker.backToAccounts"),children:t.jsx(ue,{size:16})}),t.jsx("img",{src:k.avatarUrl,alt:k.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:k.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:N})]})}),e[6]=N,e[7]=k,e[8]=s,e[9]=d):d=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Z,{size:18,className:"animate-spin text-muted-foreground"})}),e[10]=m):m=e[10];let c;e[11]!==l?(c=()=>l(!1),e[11]=l,e[12]=c):c=e[12];let b;e[13]!==r||e[14]!==o||e[15]!==n||e[16]!==k||e[17]!==c?(b=t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:t.jsx($.Suspense,{fallback:m,children:t.jsx(qe,{open:n,onComplete:c,selectedInstallation:k,onSelectInstallation:P,onImportComplete:o,mode:r})})}),e[13]=r,e[14]=o,e[15]=n,e[16]=k,e[17]=c,e[18]=b):b=e[18];let g;e[19]!==f||e[20]!==d||e[21]!==b?(g=t.jsxs(Se,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[f,d,b]}),e[19]=f,e[20]=d,e[21]=b,e[22]=g):g=e[22];let j;return e[23]!==l||e[24]!==n||e[25]!==g?(j=t.jsx(Ie,{open:n,onOpenChange:l,children:g}),e[23]=l,e[24]=n,e[25]=g,e[26]=j):j=e[26],j}function qe({open:C,onComplete:e,selectedInstallation:n,onSelectInstallation:l,onImportComplete:p,mode:o="agent"}){const a=ee(),{org:r}=de(),s=me(),u=Fe(),[N,k]=$.useState(null),P=Ee({slug:"mcp-github"}),f=Ue(P),d=Be({enabled:C&&f.length===0}),m=f.length===1?f[0]??null:N,c=ne({connectionId:m?.id??"",orgId:r.id,orgSlug:r.slug}),b=ne({connectionId:pe,orgId:r.id,orgSlug:r.slug}),g=async(i,y)=>{try{const I=await c.callTool({name:"get_file_contents",arguments:{owner:i.owner,repo:i.name,path:y}});if(I.isError)return null;const R=I.content?.find(w=>w.type==="resource")?.resource?.text;if(!R)return null;try{const w=JSON.parse(R);return typeof w=="string"?w:JSON.stringify(w)}catch{return R}}catch{return null}},j=(i,y)=>{Promise.all([g(y,"AGENTS.md"),g(y,"CLAUDE.md")]).then(async([v,I])=>{const T=v??I??null;T&&(await b.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:i,data:{metadata:{instructions:T}}}}),le(s,r.id))}).catch(v=>{console.error("GitHub instructions fetch failed:",v)})},x=ge({mutationFn:async i=>{if(!m||!n)throw new Error("No GitHub connection or installation");const y=n.installationId;if(o==="connection"){const{childConnectionId:R}=await fe({orgSlug:r.slug,sourceConnection:m,installationId:y,owner:i.owner,repo:i.name,githubCallTool:w=>c.callTool(w),selfCallTool:w=>b.callTool(w),orgShared:!0});return{virtualMcpId:null,repo:i,connectionId:R,item:null}}const{childConnectionId:v,reused:I}=await fe({orgSlug:r.slug,sourceConnection:m,installationId:y,owner:i.owner,repo:i.name,githubCallTool:R=>c.callTool(R),selfCallTool:R=>b.callTool(R)});let T=null;try{const R=await b.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:i.name,description:i.description||"Imported from GitHub",pinned:!1,icon:null,metadata:{githubRepo:{owner:i.owner,name:i.name,url:i.url,installationId:y,connectionId:v},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"},chatDefaultOpen:!0}}},connections:[{connection_id:v}]}}}),w=R.structuredContent??R,_=w.item?.id;if(!w.item||!_)throw new Error("Failed to create the imported agent");return T=_,{virtualMcpId:_,repo:i,connectionId:v,item:w.item}}catch(R){throw T&&await b.callTool({name:"COLLECTION_VIRTUAL_MCP_DELETE",arguments:{id:T}}).catch(()=>{}),I||await b.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:v,force:!0}}).catch(()=>{}),R}},onSuccess:({virtualMcpId:i,repo:y,connectionId:v,item:I})=>{if(o==="connection"||!i||!I){le(s,r.id),Ne(s,r.id),te.success(a("common.githubRepoPicker.addedRepo",{name:y.name})),e();return}if(s.setQueryData(se.collectionItem(b,r.id,"","VIRTUAL_MCP",i),{item:I}),le(s,r.id),j(i,y),p){p({virtualMcpId:i,repo:y,connectionId:v});return}te.success(a("common.githubRepoPicker.importedRepo",{name:y.name})),e(),localStorage.setItem(ke.sidebarOpen(),JSON.stringify(!1)),u(i)},onError:(i,y)=>{console.error("GitHub import failed:",i);const v=i instanceof Error?i.message:a("common.githubRepoPicker.unknownError");if(y.fork&&v.toLowerCase().includes("mint")){te.error(a("common.githubRepoPicker.failedImportFork",{name:y.name}));return}te.error(a("common.githubRepoPicker.failedImport",{error:v}))}});return d.status==="installing"||d.status==="authenticating"?t.jsx(ce,{status:d.status,error:null,retry:d.retry}):d.status==="error"?t.jsx(ce,{status:"error",error:d.error,retry:d.retry}):f.length===0&&d.status==="idle"?t.jsx(ce,{status:"installing",error:null,retry:d.retry}):f.length>1&&!m?t.jsxs("div",{className:"flex flex-col py-2",children:[t.jsx("div",{className:"px-4 py-2",children:t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:a("common.githubRepoPicker.selectConnection")})}),f.map(i=>t.jsxs("button",{type:"button",onClick:()=>k(i),className:"flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left",children:[i.icon?t.jsx("img",{src:i.icon,alt:i.title,className:"size-7 rounded-full shrink-0"}):t.jsx("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center shrink-0",children:t.jsx(D,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:i.title})]},i.id))]}):m?n?t.jsx(Ke,{connectionId:m.id,orgId:r.id,orgSlug:r.slug,installation:n,onSelectRepo:i=>x.mutate(i),isSaving:x.isPending}):t.jsx(Qe,{connectionId:m.id,orgId:r.id,orgSlug:r.slug,onSelect:l,showBackButton:f.length>1,onBack:()=>k(null)}):null}function Qe(C){const e=M.c(124),{connectionId:n,orgId:l,orgSlug:p,onSelect:o,showBackButton:a,onBack:r}=C,s=ee();let u;e[0]!==l||e[1]!==p?(u={connectionId:pe,orgId:l,orgSlug:p},e[0]=l,e[1]=p,e[2]=u):u=e[2];const N=ne(u),k=me(),P=he();let f;e[3]!==n||e[4]!==l?(f=se.githubUserOrgs(l,n),e[3]=n,e[4]=l,e[5]=f):f=e[5];let d;e[6]!==n||e[7]!==N?(d=()=>$e(h=>N.callTool(h),n),e[6]=n,e[7]=N,e[8]=d):d=e[8];let m;e[9]!==f||e[10]!==d?(m={queryKey:f,queryFn:d},e[9]=f,e[10]=d,e[11]=m):m=e[11];const c=ve(m);let b;e[12]!==P||e[13]!==n||e[14]!==c||e[15]!==l||e[16]!==p||e[17]!==k?(b=async()=>{const h=await be({connectionId:n,orgId:l,orgSlug:p,persistFallback:E=>P.update.mutateAsync({id:n,data:{connection_token:E}}).then(Ve)});if(h.ran&&!h.ok)throw new Error(h.error??"no token received");const S=new URL(`/api/${p}/mcp/${n}`,window.location.origin);await k.invalidateQueries({queryKey:se.isMCPAuthenticated(S.href,null)}),await k.invalidateQueries({queryKey:se.mcpClientPrefix()}),await c.refetch()},e[12]=P,e[13]=n,e[14]=c,e[15]=l,e[16]=p,e[17]=k,e[18]=b):b=e[18];let g;e[19]!==s?(g=h=>{te.error(s("common.githubRepoPicker.failedReconnect",{error:h instanceof Error?h.message:s("common.githubRepoPicker.unknownError")}))},e[19]=s,e[20]=g):g=e[20];let j;e[21]!==b||e[22]!==g?(j={mutationFn:b,onError:g},e[21]=b,e[22]=g,e[23]=j):j=e[23];const x=ge(j);if(c.isLoading){let h;return e[24]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Z,{size:18,className:"animate-spin text-muted-foreground"})}),e[24]=h):h=e[24],h}if(c.isError){let h;e[25]!==s?(h=s("common.githubRepoPicker.failedLoadAccounts"),e[25]=s,e[26]=h):h=e[26];let S;e[27]!==h?(S=t.jsx("p",{className:"text-sm text-destructive",children:h}),e[27]=h,e[28]=S):S=e[28];let E;e[29]!==s?(E=s("common.githubRepoPicker.connectionExpiredMessage"),e[29]=s,e[30]=E):E=e[30];let A;e[31]!==E?(A=t.jsx("p",{className:"text-xs text-muted-foreground max-w-[280px] leading-relaxed",children:E}),e[31]=E,e[32]=A):A=e[32];let z;e[33]!==x?(z=()=>x.mutate(),e[33]=x,e[34]=z):z=e[34];const H=x.isPending;let L;e[35]!==x.isPending?(L=x.isPending?t.jsx(Z,{size:14,className:"animate-spin"}):t.jsx(D,{className:"size-3.5"}),e[35]=x.isPending,e[36]=L):L=e[36];let G;e[37]!==s?(G=s("common.githubRepoPicker.reconnectGitHub"),e[37]=s,e[38]=G):G=e[38];let O;e[39]!==x.isPending||e[40]!==z||e[41]!==L||e[42]!==G?(O=t.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:z,disabled:H,children:[L,G]}),e[39]=x.isPending,e[40]=z,e[41]=L,e[42]=G,e[43]=O):O=e[43];let U;return e[44]!==A||e[45]!==O||e[46]!==S?(U=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[S,A,O]}),e[44]=A,e[45]=O,e[46]=S,e[47]=U):U=e[47],U}const i=c.data;if(!i)return null;if(i.installations.length===0){let h;e[48]!==r||e[49]!==a||e[50]!==s?(h=a&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(ue,{size:12}),s("common.githubRepoPicker.changeConnection")]})}),e[48]=r,e[49]=a,e[50]=s,e[51]=h):h=e[51];let S;e[52]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx("div",{className:"size-16 rounded-2xl bg-muted flex items-center justify-center",children:t.jsx(D,{className:"size-8 text-foreground"})}),e[52]=S):S=e[52];let E;e[53]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("span",{className:"size-1.5 rounded-full bg-success"}),e[53]=E):E=e[53];let A;e[54]!==s?(A=s("common.githubRepoPicker.githubConnected"),e[54]=s,e[55]=A):A=e[55];let z;e[56]!==A?(z=t.jsxs("div",{className:"mt-4 flex items-center gap-1.5 text-xs font-medium text-success",children:[E,A]}),e[56]=A,e[57]=z):z=e[57];let H;e[58]!==s?(H=s("common.githubRepoPicker.setupRepositoriesTitle"),e[58]=s,e[59]=H):H=e[59];let L;e[60]!==H?(L=t.jsx("h2",{className:"mt-2 text-base font-semibold text-foreground",children:H}),e[60]=H,e[61]=L):L=e[61];let G;e[62]!==s?(G=s("common.githubRepoPicker.noRepositoriesShared"),e[62]=s,e[63]=G):G=e[63];let O;e[64]!==G?(O=t.jsx("p",{className:"mt-1.5 max-w-[360px] text-xs leading-relaxed text-muted-foreground",children:G}),e[64]=G,e[65]=O):O=e[65];let U;e[66]!==s?(U=s("common.githubRepoPicker.chooseRepositories"),e[66]=s,e[67]=U):U=e[67];let ie;e[68]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx(ze,{size:14}),e[68]=ie):ie=e[68];let B;e[69]!==U?(B=t.jsx(re,{asChild:!0,size:"sm",children:t.jsxs("a",{href:xe,target:"_blank",rel:"noopener noreferrer",children:[U,ie]})}),e[69]=U,e[70]=B):B=e[70];let q;e[71]!==c?(q=()=>{c.refetch()},e[71]=c,e[72]=q):q=e[72];const je=c.isFetching;let Q;e[73]!==c.isFetching?(Q=c.isFetching&&t.jsx(Z,{size:14,className:"animate-spin"}),e[73]=c.isFetching,e[74]=Q):Q=e[74];let V;e[75]!==s?(V=s("common.githubRepoPicker.checkAgain"),e[75]=s,e[76]=V):V=e[76];let K;e[77]!==c.isFetching||e[78]!==q||e[79]!==Q||e[80]!==V?(K=t.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:q,disabled:je,children:[Q,V]}),e[77]=c.isFetching,e[78]=q,e[79]=Q,e[80]=V,e[81]=K):K=e[81];let J;e[82]!==B||e[83]!==K?(J=t.jsxs("div",{className:"mt-5 flex items-center gap-2",children:[B,K]}),e[82]=B,e[83]=K,e[84]=J):J=e[84];let W;e[85]!==s?(W=s("common.githubRepoPicker.repositoryAccessNote"),e[85]=s,e[86]=W):W=e[86];let Y;e[87]!==W?(Y=t.jsx("p",{className:"mt-4 max-w-[360px] rounded-lg bg-muted/50 px-3 py-2 text-xs leading-relaxed text-muted-foreground",children:W}),e[87]=W,e[88]=Y):Y=e[88];let X;e[89]!==z||e[90]!==L||e[91]!==O||e[92]!==J||e[93]!==Y?(X=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-8 py-6 text-center",children:[S,z,L,O,J,Y]}),e[89]=z,e[90]=L,e[91]=O,e[92]=J,e[93]=Y,e[94]=X):X=e[94];let oe;return e[95]!==X||e[96]!==h?(oe=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[h,X]}),e[95]=X,e[96]=h,e[97]=oe):oe=e[97],oe}let y;e[98]!==r||e[99]!==a||e[100]!==s?(y=a&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(ue,{size:12}),s("common.githubRepoPicker.changeConnection")]})}),e[98]=r,e[99]=a,e[100]=s,e[101]=y):y=e[101];let v;if(e[102]!==i.installations||e[103]!==o||e[104]!==s){let h;e[106]!==o||e[107]!==s?(h=S=>t.jsxs("button",{type:"button",onClick:()=>o(S),className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left group",children:[t.jsx("img",{src:S.avatarUrl,alt:S.login,className:"size-7 rounded-full shrink-0 ring-1 ring-border"}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium leading-none",children:S.login}),S.type==="User"&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:s("common.githubRepoPicker.personalAccount")})]}),t.jsxs("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[s("common.githubRepoPicker.select")," →"]})]},S.installationId),e[106]=o,e[107]=s,e[108]=h):h=e[108],v=i.installations.map(h),e[102]=i.installations,e[103]=o,e[104]=s,e[105]=v}else v=e[105];let I;e[109]!==v?(I=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:v}),e[109]=v,e[110]=I):I=e[110];let T;e[111]!==s?(T=s("common.githubRepoPicker.accountNotListed"),e[111]=s,e[112]=T):T=e[112];let R;e[113]!==s?(R=s("common.githubRepoPicker.installGitHubApp"),e[113]=s,e[114]=R):R=e[114];let w;e[115]!==R?(w=t.jsx("span",{className:"underline underline-offset-2",children:R}),e[115]=R,e[116]=w):w=e[116];let _;e[117]!==T||e[118]!==w?(_=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:xe,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:[T," ",w]})}),e[117]=T,e[118]=w,e[119]=_):_=e[119];let F;return e[120]!==I||e[121]!==_||e[122]!==y?(F=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[y,I,_]}),e[120]=I,e[121]=_,e[122]=y,e[123]=F):F=e[123],F}function Ve(){}function Ke(C){const e=M.c(23),{connectionId:n,orgId:l,orgSlug:p,installation:o,onSelectRepo:a,isSaving:r}=C,s=ee(),[u,N]=$.useState(""),k=_e(u,300),P=$.useDeferredValue(k),f=u!==P;let d;e[0]!==s?(d=s("common.githubRepoPicker.searchRepositories"),e[0]=s,e[1]=d):d=e[1];let m;e[2]!==f||e[3]!==u||e[4]!==d?(m=t.jsx(Te,{placeholder:d,value:u,onChange:N,isSearching:f}),e[2]=f,e[3]=u,e[4]=d,e[5]=m):m=e[5];const c=f?"opacity-40":"opacity-100";let b;e[6]!==c?(b=ae("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",c),e[6]=c,e[7]=b):b=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Z,{size:18,className:"animate-spin text-muted-foreground"})}),e[8]=g):g=e[8];let j;e[9]!==n||e[10]!==P||e[11]!==o||e[12]!==r||e[13]!==a||e[14]!==l||e[15]!==p?(j=t.jsx($.Suspense,{fallback:g,children:t.jsx(Je,{connectionId:n,orgId:l,orgSlug:p,installation:o,query:P,onSelectRepo:a,isSaving:r})}),e[9]=n,e[10]=P,e[11]=o,e[12]=r,e[13]=a,e[14]=l,e[15]=p,e[16]=j):j=e[16];let x;e[17]!==b||e[18]!==j?(x=t.jsx("div",{className:b,children:j}),e[17]=b,e[18]=j,e[19]=x):x=e[19];let i;return e[20]!==m||e[21]!==x?(i=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m,x]}),e[20]=m,e[21]=x,e[22]=i):i=e[22],i}function Je(C){const e=M.c(36),{connectionId:n,orgId:l,orgSlug:p,installation:o,query:a,onSelectRepo:r,isSaving:s}=C,u=ee();let N;e[0]!==n||e[1]!==l||e[2]!==p?(N={connectionId:n,orgId:l,orgSlug:p},e[0]=n,e[1]=l,e[2]=p,e[3]=N):N=e[3];const k=ne(N),P=o.type==="User"?"user":"org",f=a?`${P}:${o.login} ${a} in:name fork:true`:`${P}:${o.login} fork:true`;let d;e[4]!==n||e[5]!==o.login||e[6]!==l||e[7]!==a?(d=se.githubOrgRepos(l,n,o.login,a),e[4]=n,e[5]=o.login,e[6]=l,e[7]=a,e[8]=d):d=e[8];let m;e[9]!==k||e[10]!==f?(m=async x=>{const{signal:i}=x,v=(await k.callTool({name:"search_repositories",arguments:{query:f,page:1,perPage:30}},void 0,{signal:i})).content?.[0]?.text;if(!v)throw new Error("No response from search_repositories");return(JSON.parse(v).items??[]).map(We)},e[9]=k,e[10]=f,e[11]=m):m=e[11];let c;e[12]!==d||e[13]!==m?(c={queryKey:d,queryFn:m},e[12]=d,e[13]=m,e[14]=c):c=e[14];const{data:b}=Ce(c);if(b.length===0){let x;e[15]!==u?(x=u("common.githubRepoPicker.noRepositoriesFound"),e[15]=u,e[16]=x):x=e[16];let i;e[17]!==x?(i=t.jsx("p",{className:"text-sm text-muted-foreground",children:x}),e[17]=x,e[18]=i):i=e[18];let y;e[19]!==a||e[20]!==u?(y=a&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:u("common.githubRepoPicker.tryDifferentSearchTerm")}),e[19]=a,e[20]=u,e[21]=y):y=e[21];let v;return e[22]!==i||e[23]!==y?(v=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[i,y]}),e[22]=i,e[23]=y,e[24]=v):v=e[24],v}let g;if(e[25]!==s||e[26]!==r||e[27]!==b||e[28]!==u){let x;e[30]!==s||e[31]!==r||e[32]!==u?(x=i=>t.jsxs("button",{type:"button",onClick:()=>r(i),disabled:s,className:"flex items-start gap-3 px-4 py-3 hover:bg-accent transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(D,{className:"size-4 text-muted-foreground mt-0.5 shrink-0"}),t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium truncate",children:i.name}),i.fork&&t.jsx("span",{className:"text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:u("common.githubRepoPicker.forkBadge")})]}),t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:[i.private?t.jsx(Re,{size:10}):t.jsx(Le,{size:10}),i.private?u("common.githubRepoPicker.private"):u("common.githubRepoPicker.public")]})]},i.fullName),e[30]=s,e[31]=r,e[32]=u,e[33]=x):x=e[33],g=b.map(x),e[25]=s,e[26]=r,e[27]=b,e[28]=u,e[29]=g}else g=e[29];let j;return e[34]!==g?(j=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:g}),e[34]=g,e[35]=j):j=e[35],j}function We(C){return{name:C.name,fullName:C.full_name,owner:C.full_name.split("/")[0]??"",url:C.html_url,private:C.private,description:C.description,updatedAt:C.updated_at,fork:C.fork??!1}}function ce(C){const e=M.c(51),{status:n,error:l,retry:p}=C,o=ee();if(n==="error"){let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("div",{className:"size-10 rounded-full bg-destructive/10 flex items-center justify-center",children:t.jsx(D,{className:"size-5 text-destructive"})}),e[0]=v):v=e[0];let I;e[1]!==o?(I=o("common.githubRepoPicker.connectionFailed"),e[1]=o,e[2]=I):I=e[2];let T;e[3]!==I?(T=t.jsx("p",{className:"text-sm font-medium",children:I}),e[3]=I,e[4]=T):T=e[4];let R;e[5]!==l||e[6]!==o?(R=l??o("common.githubRepoPicker.somethingWentWrong"),e[5]=l,e[6]=o,e[7]=R):R=e[7];let w;e[8]!==R?(w=t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:R}),e[8]=R,e[9]=w):w=e[9];let _;e[10]!==T||e[11]!==w?(_=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[T,w]}),e[10]=T,e[11]=w,e[12]=_):_=e[12];let F;e[13]!==o?(F=o("common.githubRepoPicker.tryAgain"),e[13]=o,e[14]=F):F=e[14];let h;e[15]!==p||e[16]!==F?(h=t.jsx("button",{type:"button",onClick:p,className:"text-xs font-medium text-foreground border border-border rounded-md px-3 py-1.5 hover:bg-accent transition-colors",children:F}),e[15]=p,e[16]=F,e[17]=h):h=e[17];let S;return e[18]!==_||e[19]!==h?(S=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[v,_,h]}),e[18]=_,e[19]=h,e[20]=S):S=e[20],S}const a=n==="authenticating";let r;e[21]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(D,{className:"size-5 text-foreground"})}),e[21]=r):r=e[21];let s;e[22]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("div",{className:"relative size-10",children:[r,t.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-background flex items-center justify-center",children:t.jsx(Z,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[22]=s):s=e[22];let u;e[23]!==a||e[24]!==o?(u=o(a?"common.githubRepoPicker.authenticatingGitHub":"common.githubRepoPicker.settingUpGitHub"),e[23]=a,e[24]=o,e[25]=u):u=e[25];let N;e[26]!==u?(N=t.jsx("p",{className:"text-sm font-medium",children:u}),e[26]=u,e[27]=N):N=e[27];let k;e[28]!==a||e[29]!==o?(k=o(a?"common.githubRepoPicker.completeOAuthFlow":"common.githubRepoPicker.installingGitHubConnection"),e[28]=a,e[29]=o,e[30]=k):k=e[30];let P;e[31]!==k?(P=t.jsx("p",{className:"text-xs text-muted-foreground",children:k}),e[31]=k,e[32]=P):P=e[32];let f;e[33]!==N||e[34]!==P?(f=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[N,P]}),e[33]=N,e[34]=P,e[35]=f):f=e[35];const d=a?"bg-muted-foreground/30":"bg-foreground animate-pulse";let m;e[36]!==d?(m=ae("size-1.5 rounded-full",d),e[36]=d,e[37]=m):m=e[37];let c;e[38]!==m?(c=t.jsx("span",{className:m}),e[38]=m,e[39]=c):c=e[39];const b=a?"bg-foreground animate-pulse":"bg-muted-foreground/30";let g;e[40]!==b?(g=ae("size-1.5 rounded-full",b),e[40]=b,e[41]=g):g=e[41];let j;e[42]!==g?(j=t.jsx("span",{className:g}),e[42]=g,e[43]=j):j=e[43];let x;e[44]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[44]=x):x=e[44];let i;e[45]!==c||e[46]!==j?(i=t.jsxs("div",{className:"flex items-center gap-1.5",children:[c,j,x]}),e[45]=c,e[46]=j,e[47]=i):i=e[47];let y;return e[48]!==i||e[49]!==f?(y=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[s,f,i]}),e[48]=i,e[49]=f,e[50]=y):y=e[50],y}export{D as G,dt as a,Be as b,He as u};
1
+ import{c as M,j as t,F as de,a as ye,o as me,r as $,a0 as le,b as ee,k as Z,e as ge,t as te,d$ as Ne,K as se,G as ke,n as ve,m as ae,B as re,x as Ce,y as Re}from"./index-Ci2-WeDM.js";import{a as we,b as Pe,d as Se,e as Ie}from"./dialog-3W-8IScJ.js";import{C as Te}from"./collection-search-BECJRGvb.js";import{u as _e}from"./use-debounced-value-CfDM0Jhq.js";import{b as he,u as Ee}from"./use-connection-VGJh4zjw.js";import{W as Ae,u as ne,S as pe}from"./use-mcp-client-CaVVZEYW.js";import{a as be}from"./authenticate-and-persist-oauth-Di8-syFQ.js";import{b as ue}from"./Settings02-Cndba0CR.js";import{n as ze}from"./LinkExternal01-BKiT6Lg5.js";import{T as Le}from"./agent-icon-BB8mzMQ9.js";import{u as Ge}from"./use-mcp-tools-DvuJ8P5F.js";import{e as Oe}from"./extract-connection-data-916x9paw.js";import{c as Fe}from"./use-navigate-to-agent-D3FDvvrd.js";import{g as Ue,p as fe,f as $e,G as xe}from"./provision-repo-scoped-github-connection-B2s3ApVy.js";function D(C){const e=M.c(4),{size:n,className:l}=C;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z"}),e[0]=p):p=e[0];let o;return e[1]!==l||e[2]!==n?(o=t.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:l,children:p}),e[1]=l,e[2]=n,e[3]=o):o=e[3],o}function He(C,e){const n=M.c(12),{org:l}=de();let p;n[0]!==l.id?(p=Ae.REGISTRY(l.id),n[0]=l.id,n[1]=p):p=n[1];const o=p;let a;n[2]!==l.id||n[3]!==l.slug||n[4]!==o?(a={connectionId:o,orgId:l.id,orgSlug:l.slug},n[2]=l.id,n[3]=l.slug,n[4]=o,n[5]=a):a=n[5];const r=ne(a);let s;n[6]!==C?(s={name:C},n[6]=C,n[7]=s):s=n[7];const u=e?.enabled??!0;let N;return n[8]!==r||n[9]!==s||n[10]!==u?(N={client:r,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:s,enabled:u,staleTime:3e5,select:De},n[8]=r,n[9]=s,n[10]=u,n[11]=N):N=n[11],Ge(N)}function De(C){return C.structuredContent?.item??null}const Me="deco/mcp-github";function Be(C){const{org:e}=de(),{data:n}=ye.useSession(),l=he(),p=me(),[o,a]=$.useState("idle"),[r,s]=$.useState(null),[u,N]=$.useState(null),{data:k,isLoading:P}=He(Me,{enabled:C.enabled}),f=$.useRef(!1);C.enabled&&k&&!P&&!f.current&&n?.user?.id&&o==="idle"&&(f.current=!0,d());async function d(){if(!(!k||!n?.user?.id||!e))try{a("installing"),s(null);const c=Oe(k,e.id,n.user.id,{remoteIndex:0});if(!c.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:g}=await l.create.mutateAsync(c);a("authenticating");const j=await be({connectionId:g,orgId:e.id,orgSlug:e.slug,persistFallback:x=>l.update.mutateAsync({id:g,data:{connection_token:x}}).then(()=>{})});if(j.ran&&!j.ok){try{await l.delete.mutateAsync(g)}catch{}throw new Error(j.error&&j.error!=="no token received"?j.error:"No token received from GitHub")}le(p,e.id),N(c),a("ready")}catch(c){s(c instanceof Error?c.message:String(c)),a("error")}}function m(){a("idle"),s(null),N(null),f.current=!1}return C.enabled&&P&&o==="idle"?{status:"installing",error:null,connection:null,retry:m}:{status:o,error:r,connection:u,retry:m}}function dt(C){const e=M.c(27),{open:n,onOpenChange:l,title:p,onImportComplete:o,mode:a}=C,r=a===void 0?"agent":a,s=ee();let u;e[0]!==r||e[1]!==s||e[2]!==p?(u=p??s(r==="connection"?"common.githubRepoPicker.addRepo":"common.githubRepoPicker.importFromGitHub"),e[0]=r,e[1]=s,e[2]=p,e[3]=u):u=e[3];const N=u,[k,P]=$.useState(null);let f;e[4]!==N?(f=t.jsx(we,{className:"sr-only",children:t.jsx(Pe,{children:N})}),e[4]=N,e[5]=f):f=e[5];let d;e[6]!==N||e[7]!==k||e[8]!==s?(d=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:k?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>P(null),className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors shrink-0","aria-label":s("common.githubRepoPicker.backToAccounts"),children:t.jsx(ue,{size:16})}),t.jsx("img",{src:k.avatarUrl,alt:k.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:k.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:N})]})}),e[6]=N,e[7]=k,e[8]=s,e[9]=d):d=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Z,{size:18,className:"animate-spin text-muted-foreground"})}),e[10]=m):m=e[10];let c;e[11]!==l?(c=()=>l(!1),e[11]=l,e[12]=c):c=e[12];let b;e[13]!==r||e[14]!==o||e[15]!==n||e[16]!==k||e[17]!==c?(b=t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:t.jsx($.Suspense,{fallback:m,children:t.jsx(qe,{open:n,onComplete:c,selectedInstallation:k,onSelectInstallation:P,onImportComplete:o,mode:r})})}),e[13]=r,e[14]=o,e[15]=n,e[16]=k,e[17]=c,e[18]=b):b=e[18];let g;e[19]!==f||e[20]!==d||e[21]!==b?(g=t.jsxs(Se,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[f,d,b]}),e[19]=f,e[20]=d,e[21]=b,e[22]=g):g=e[22];let j;return e[23]!==l||e[24]!==n||e[25]!==g?(j=t.jsx(Ie,{open:n,onOpenChange:l,children:g}),e[23]=l,e[24]=n,e[25]=g,e[26]=j):j=e[26],j}function qe({open:C,onComplete:e,selectedInstallation:n,onSelectInstallation:l,onImportComplete:p,mode:o="agent"}){const a=ee(),{org:r}=de(),s=me(),u=Fe(),[N,k]=$.useState(null),P=Ee({slug:"mcp-github"}),f=Ue(P),d=Be({enabled:C&&f.length===0}),m=f.length===1?f[0]??null:N,c=ne({connectionId:m?.id??"",orgId:r.id,orgSlug:r.slug}),b=ne({connectionId:pe,orgId:r.id,orgSlug:r.slug}),g=async(i,y)=>{try{const I=await c.callTool({name:"get_file_contents",arguments:{owner:i.owner,repo:i.name,path:y}});if(I.isError)return null;const R=I.content?.find(w=>w.type==="resource")?.resource?.text;if(!R)return null;try{const w=JSON.parse(R);return typeof w=="string"?w:JSON.stringify(w)}catch{return R}}catch{return null}},j=(i,y)=>{Promise.all([g(y,"AGENTS.md"),g(y,"CLAUDE.md")]).then(async([v,I])=>{const T=v??I??null;T&&(await b.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:i,data:{metadata:{instructions:T}}}}),le(s,r.id))}).catch(v=>{console.error("GitHub instructions fetch failed:",v)})},x=ge({mutationFn:async i=>{if(!m||!n)throw new Error("No GitHub connection or installation");const y=n.installationId;if(o==="connection"){const{childConnectionId:R}=await fe({orgSlug:r.slug,sourceConnection:m,installationId:y,owner:i.owner,repo:i.name,githubCallTool:w=>c.callTool(w),selfCallTool:w=>b.callTool(w),orgShared:!0});return{virtualMcpId:null,repo:i,connectionId:R,item:null}}const{childConnectionId:v,reused:I}=await fe({orgSlug:r.slug,sourceConnection:m,installationId:y,owner:i.owner,repo:i.name,githubCallTool:R=>c.callTool(R),selfCallTool:R=>b.callTool(R)});let T=null;try{const R=await b.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:i.name,description:i.description||"Imported from GitHub",pinned:!1,icon:null,metadata:{githubRepo:{owner:i.owner,name:i.name,url:i.url,installationId:y,connectionId:v},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"},chatDefaultOpen:!0}}},connections:[{connection_id:v}]}}}),w=R.structuredContent??R,_=w.item?.id;if(!w.item||!_)throw new Error("Failed to create the imported agent");return T=_,{virtualMcpId:_,repo:i,connectionId:v,item:w.item}}catch(R){throw T&&await b.callTool({name:"COLLECTION_VIRTUAL_MCP_DELETE",arguments:{id:T}}).catch(()=>{}),I||await b.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:v,force:!0}}).catch(()=>{}),R}},onSuccess:({virtualMcpId:i,repo:y,connectionId:v,item:I})=>{if(o==="connection"||!i||!I){le(s,r.id),Ne(s,r.id),te.success(a("common.githubRepoPicker.addedRepo",{name:y.name})),e();return}if(s.setQueryData(se.collectionItem(b,r.id,"","VIRTUAL_MCP",i),{item:I}),le(s,r.id),j(i,y),p){p({virtualMcpId:i,repo:y,connectionId:v});return}te.success(a("common.githubRepoPicker.importedRepo",{name:y.name})),e(),localStorage.setItem(ke.sidebarOpen(),JSON.stringify(!1)),u(i)},onError:(i,y)=>{console.error("GitHub import failed:",i);const v=i instanceof Error?i.message:a("common.githubRepoPicker.unknownError");if(y.fork&&v.toLowerCase().includes("mint")){te.error(a("common.githubRepoPicker.failedImportFork",{name:y.name}));return}te.error(a("common.githubRepoPicker.failedImport",{error:v}))}});return d.status==="installing"||d.status==="authenticating"?t.jsx(ce,{status:d.status,error:null,retry:d.retry}):d.status==="error"?t.jsx(ce,{status:"error",error:d.error,retry:d.retry}):f.length===0&&d.status==="idle"?t.jsx(ce,{status:"installing",error:null,retry:d.retry}):f.length>1&&!m?t.jsxs("div",{className:"flex flex-col py-2",children:[t.jsx("div",{className:"px-4 py-2",children:t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:a("common.githubRepoPicker.selectConnection")})}),f.map(i=>t.jsxs("button",{type:"button",onClick:()=>k(i),className:"flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left",children:[i.icon?t.jsx("img",{src:i.icon,alt:i.title,className:"size-7 rounded-full shrink-0"}):t.jsx("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center shrink-0",children:t.jsx(D,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:i.title})]},i.id))]}):m?n?t.jsx(Ke,{connectionId:m.id,orgId:r.id,orgSlug:r.slug,installation:n,onSelectRepo:i=>x.mutate(i),isSaving:x.isPending}):t.jsx(Qe,{connectionId:m.id,orgId:r.id,orgSlug:r.slug,onSelect:l,showBackButton:f.length>1,onBack:()=>k(null)}):null}function Qe(C){const e=M.c(124),{connectionId:n,orgId:l,orgSlug:p,onSelect:o,showBackButton:a,onBack:r}=C,s=ee();let u;e[0]!==l||e[1]!==p?(u={connectionId:pe,orgId:l,orgSlug:p},e[0]=l,e[1]=p,e[2]=u):u=e[2];const N=ne(u),k=me(),P=he();let f;e[3]!==n||e[4]!==l?(f=se.githubUserOrgs(l,n),e[3]=n,e[4]=l,e[5]=f):f=e[5];let d;e[6]!==n||e[7]!==N?(d=()=>$e(h=>N.callTool(h),n),e[6]=n,e[7]=N,e[8]=d):d=e[8];let m;e[9]!==f||e[10]!==d?(m={queryKey:f,queryFn:d},e[9]=f,e[10]=d,e[11]=m):m=e[11];const c=ve(m);let b;e[12]!==P||e[13]!==n||e[14]!==c||e[15]!==l||e[16]!==p||e[17]!==k?(b=async()=>{const h=await be({connectionId:n,orgId:l,orgSlug:p,persistFallback:E=>P.update.mutateAsync({id:n,data:{connection_token:E}}).then(Ve)});if(h.ran&&!h.ok)throw new Error(h.error??"no token received");const S=new URL(`/api/${p}/mcp/${n}`,window.location.origin);await k.invalidateQueries({queryKey:se.isMCPAuthenticated(S.href,null)}),await k.invalidateQueries({queryKey:se.mcpClientPrefix()}),await c.refetch()},e[12]=P,e[13]=n,e[14]=c,e[15]=l,e[16]=p,e[17]=k,e[18]=b):b=e[18];let g;e[19]!==s?(g=h=>{te.error(s("common.githubRepoPicker.failedReconnect",{error:h instanceof Error?h.message:s("common.githubRepoPicker.unknownError")}))},e[19]=s,e[20]=g):g=e[20];let j;e[21]!==b||e[22]!==g?(j={mutationFn:b,onError:g},e[21]=b,e[22]=g,e[23]=j):j=e[23];const x=ge(j);if(c.isLoading){let h;return e[24]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Z,{size:18,className:"animate-spin text-muted-foreground"})}),e[24]=h):h=e[24],h}if(c.isError){let h;e[25]!==s?(h=s("common.githubRepoPicker.failedLoadAccounts"),e[25]=s,e[26]=h):h=e[26];let S;e[27]!==h?(S=t.jsx("p",{className:"text-sm text-destructive",children:h}),e[27]=h,e[28]=S):S=e[28];let E;e[29]!==s?(E=s("common.githubRepoPicker.connectionExpiredMessage"),e[29]=s,e[30]=E):E=e[30];let A;e[31]!==E?(A=t.jsx("p",{className:"text-xs text-muted-foreground max-w-[280px] leading-relaxed",children:E}),e[31]=E,e[32]=A):A=e[32];let z;e[33]!==x?(z=()=>x.mutate(),e[33]=x,e[34]=z):z=e[34];const H=x.isPending;let L;e[35]!==x.isPending?(L=x.isPending?t.jsx(Z,{size:14,className:"animate-spin"}):t.jsx(D,{className:"size-3.5"}),e[35]=x.isPending,e[36]=L):L=e[36];let G;e[37]!==s?(G=s("common.githubRepoPicker.reconnectGitHub"),e[37]=s,e[38]=G):G=e[38];let O;e[39]!==x.isPending||e[40]!==z||e[41]!==L||e[42]!==G?(O=t.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:z,disabled:H,children:[L,G]}),e[39]=x.isPending,e[40]=z,e[41]=L,e[42]=G,e[43]=O):O=e[43];let U;return e[44]!==A||e[45]!==O||e[46]!==S?(U=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[S,A,O]}),e[44]=A,e[45]=O,e[46]=S,e[47]=U):U=e[47],U}const i=c.data;if(!i)return null;if(i.installations.length===0){let h;e[48]!==r||e[49]!==a||e[50]!==s?(h=a&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(ue,{size:12}),s("common.githubRepoPicker.changeConnection")]})}),e[48]=r,e[49]=a,e[50]=s,e[51]=h):h=e[51];let S;e[52]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx("div",{className:"size-16 rounded-2xl bg-muted flex items-center justify-center",children:t.jsx(D,{className:"size-8 text-foreground"})}),e[52]=S):S=e[52];let E;e[53]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("span",{className:"size-1.5 rounded-full bg-success"}),e[53]=E):E=e[53];let A;e[54]!==s?(A=s("common.githubRepoPicker.githubConnected"),e[54]=s,e[55]=A):A=e[55];let z;e[56]!==A?(z=t.jsxs("div",{className:"mt-4 flex items-center gap-1.5 text-xs font-medium text-success",children:[E,A]}),e[56]=A,e[57]=z):z=e[57];let H;e[58]!==s?(H=s("common.githubRepoPicker.setupRepositoriesTitle"),e[58]=s,e[59]=H):H=e[59];let L;e[60]!==H?(L=t.jsx("h2",{className:"mt-2 text-base font-semibold text-foreground",children:H}),e[60]=H,e[61]=L):L=e[61];let G;e[62]!==s?(G=s("common.githubRepoPicker.noRepositoriesShared"),e[62]=s,e[63]=G):G=e[63];let O;e[64]!==G?(O=t.jsx("p",{className:"mt-1.5 max-w-[360px] text-xs leading-relaxed text-muted-foreground",children:G}),e[64]=G,e[65]=O):O=e[65];let U;e[66]!==s?(U=s("common.githubRepoPicker.chooseRepositories"),e[66]=s,e[67]=U):U=e[67];let ie;e[68]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx(ze,{size:14}),e[68]=ie):ie=e[68];let B;e[69]!==U?(B=t.jsx(re,{asChild:!0,size:"sm",children:t.jsxs("a",{href:xe,target:"_blank",rel:"noopener noreferrer",children:[U,ie]})}),e[69]=U,e[70]=B):B=e[70];let q;e[71]!==c?(q=()=>{c.refetch()},e[71]=c,e[72]=q):q=e[72];const je=c.isFetching;let Q;e[73]!==c.isFetching?(Q=c.isFetching&&t.jsx(Z,{size:14,className:"animate-spin"}),e[73]=c.isFetching,e[74]=Q):Q=e[74];let V;e[75]!==s?(V=s("common.githubRepoPicker.checkAgain"),e[75]=s,e[76]=V):V=e[76];let K;e[77]!==c.isFetching||e[78]!==q||e[79]!==Q||e[80]!==V?(K=t.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:q,disabled:je,children:[Q,V]}),e[77]=c.isFetching,e[78]=q,e[79]=Q,e[80]=V,e[81]=K):K=e[81];let J;e[82]!==B||e[83]!==K?(J=t.jsxs("div",{className:"mt-5 flex items-center gap-2",children:[B,K]}),e[82]=B,e[83]=K,e[84]=J):J=e[84];let W;e[85]!==s?(W=s("common.githubRepoPicker.repositoryAccessNote"),e[85]=s,e[86]=W):W=e[86];let Y;e[87]!==W?(Y=t.jsx("p",{className:"mt-4 max-w-[360px] rounded-lg bg-muted/50 px-3 py-2 text-xs leading-relaxed text-muted-foreground",children:W}),e[87]=W,e[88]=Y):Y=e[88];let X;e[89]!==z||e[90]!==L||e[91]!==O||e[92]!==J||e[93]!==Y?(X=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-8 py-6 text-center",children:[S,z,L,O,J,Y]}),e[89]=z,e[90]=L,e[91]=O,e[92]=J,e[93]=Y,e[94]=X):X=e[94];let oe;return e[95]!==X||e[96]!==h?(oe=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[h,X]}),e[95]=X,e[96]=h,e[97]=oe):oe=e[97],oe}let y;e[98]!==r||e[99]!==a||e[100]!==s?(y=a&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(ue,{size:12}),s("common.githubRepoPicker.changeConnection")]})}),e[98]=r,e[99]=a,e[100]=s,e[101]=y):y=e[101];let v;if(e[102]!==i.installations||e[103]!==o||e[104]!==s){let h;e[106]!==o||e[107]!==s?(h=S=>t.jsxs("button",{type:"button",onClick:()=>o(S),className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left group",children:[t.jsx("img",{src:S.avatarUrl,alt:S.login,className:"size-7 rounded-full shrink-0 ring-1 ring-border"}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium leading-none",children:S.login}),S.type==="User"&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:s("common.githubRepoPicker.personalAccount")})]}),t.jsxs("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[s("common.githubRepoPicker.select")," →"]})]},S.installationId),e[106]=o,e[107]=s,e[108]=h):h=e[108],v=i.installations.map(h),e[102]=i.installations,e[103]=o,e[104]=s,e[105]=v}else v=e[105];let I;e[109]!==v?(I=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:v}),e[109]=v,e[110]=I):I=e[110];let T;e[111]!==s?(T=s("common.githubRepoPicker.accountNotListed"),e[111]=s,e[112]=T):T=e[112];let R;e[113]!==s?(R=s("common.githubRepoPicker.installGitHubApp"),e[113]=s,e[114]=R):R=e[114];let w;e[115]!==R?(w=t.jsx("span",{className:"underline underline-offset-2",children:R}),e[115]=R,e[116]=w):w=e[116];let _;e[117]!==T||e[118]!==w?(_=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:xe,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:[T," ",w]})}),e[117]=T,e[118]=w,e[119]=_):_=e[119];let F;return e[120]!==I||e[121]!==_||e[122]!==y?(F=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[y,I,_]}),e[120]=I,e[121]=_,e[122]=y,e[123]=F):F=e[123],F}function Ve(){}function Ke(C){const e=M.c(23),{connectionId:n,orgId:l,orgSlug:p,installation:o,onSelectRepo:a,isSaving:r}=C,s=ee(),[u,N]=$.useState(""),k=_e(u,300),P=$.useDeferredValue(k),f=u!==P;let d;e[0]!==s?(d=s("common.githubRepoPicker.searchRepositories"),e[0]=s,e[1]=d):d=e[1];let m;e[2]!==f||e[3]!==u||e[4]!==d?(m=t.jsx(Te,{placeholder:d,value:u,onChange:N,isSearching:f}),e[2]=f,e[3]=u,e[4]=d,e[5]=m):m=e[5];const c=f?"opacity-40":"opacity-100";let b;e[6]!==c?(b=ae("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",c),e[6]=c,e[7]=b):b=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Z,{size:18,className:"animate-spin text-muted-foreground"})}),e[8]=g):g=e[8];let j;e[9]!==n||e[10]!==P||e[11]!==o||e[12]!==r||e[13]!==a||e[14]!==l||e[15]!==p?(j=t.jsx($.Suspense,{fallback:g,children:t.jsx(Je,{connectionId:n,orgId:l,orgSlug:p,installation:o,query:P,onSelectRepo:a,isSaving:r})}),e[9]=n,e[10]=P,e[11]=o,e[12]=r,e[13]=a,e[14]=l,e[15]=p,e[16]=j):j=e[16];let x;e[17]!==b||e[18]!==j?(x=t.jsx("div",{className:b,children:j}),e[17]=b,e[18]=j,e[19]=x):x=e[19];let i;return e[20]!==m||e[21]!==x?(i=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m,x]}),e[20]=m,e[21]=x,e[22]=i):i=e[22],i}function Je(C){const e=M.c(36),{connectionId:n,orgId:l,orgSlug:p,installation:o,query:a,onSelectRepo:r,isSaving:s}=C,u=ee();let N;e[0]!==n||e[1]!==l||e[2]!==p?(N={connectionId:n,orgId:l,orgSlug:p},e[0]=n,e[1]=l,e[2]=p,e[3]=N):N=e[3];const k=ne(N),P=o.type==="User"?"user":"org",f=a?`${P}:${o.login} ${a} in:name fork:true`:`${P}:${o.login} fork:true`;let d;e[4]!==n||e[5]!==o.login||e[6]!==l||e[7]!==a?(d=se.githubOrgRepos(l,n,o.login,a),e[4]=n,e[5]=o.login,e[6]=l,e[7]=a,e[8]=d):d=e[8];let m;e[9]!==k||e[10]!==f?(m=async x=>{const{signal:i}=x,v=(await k.callTool({name:"search_repositories",arguments:{query:f,page:1,perPage:30}},void 0,{signal:i})).content?.[0]?.text;if(!v)throw new Error("No response from search_repositories");return(JSON.parse(v).items??[]).map(We)},e[9]=k,e[10]=f,e[11]=m):m=e[11];let c;e[12]!==d||e[13]!==m?(c={queryKey:d,queryFn:m},e[12]=d,e[13]=m,e[14]=c):c=e[14];const{data:b}=Ce(c);if(b.length===0){let x;e[15]!==u?(x=u("common.githubRepoPicker.noRepositoriesFound"),e[15]=u,e[16]=x):x=e[16];let i;e[17]!==x?(i=t.jsx("p",{className:"text-sm text-muted-foreground",children:x}),e[17]=x,e[18]=i):i=e[18];let y;e[19]!==a||e[20]!==u?(y=a&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:u("common.githubRepoPicker.tryDifferentSearchTerm")}),e[19]=a,e[20]=u,e[21]=y):y=e[21];let v;return e[22]!==i||e[23]!==y?(v=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[i,y]}),e[22]=i,e[23]=y,e[24]=v):v=e[24],v}let g;if(e[25]!==s||e[26]!==r||e[27]!==b||e[28]!==u){let x;e[30]!==s||e[31]!==r||e[32]!==u?(x=i=>t.jsxs("button",{type:"button",onClick:()=>r(i),disabled:s,className:"flex items-start gap-3 px-4 py-3 hover:bg-accent transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(D,{className:"size-4 text-muted-foreground mt-0.5 shrink-0"}),t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium truncate",children:i.name}),i.fork&&t.jsx("span",{className:"text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:u("common.githubRepoPicker.forkBadge")})]}),t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:[i.private?t.jsx(Re,{size:10}):t.jsx(Le,{size:10}),i.private?u("common.githubRepoPicker.private"):u("common.githubRepoPicker.public")]})]},i.fullName),e[30]=s,e[31]=r,e[32]=u,e[33]=x):x=e[33],g=b.map(x),e[25]=s,e[26]=r,e[27]=b,e[28]=u,e[29]=g}else g=e[29];let j;return e[34]!==g?(j=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:g}),e[34]=g,e[35]=j):j=e[35],j}function We(C){return{name:C.name,fullName:C.full_name,owner:C.full_name.split("/")[0]??"",url:C.html_url,private:C.private,description:C.description,updatedAt:C.updated_at,fork:C.fork??!1}}function ce(C){const e=M.c(51),{status:n,error:l,retry:p}=C,o=ee();if(n==="error"){let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("div",{className:"size-10 rounded-full bg-destructive/10 flex items-center justify-center",children:t.jsx(D,{className:"size-5 text-destructive"})}),e[0]=v):v=e[0];let I;e[1]!==o?(I=o("common.githubRepoPicker.connectionFailed"),e[1]=o,e[2]=I):I=e[2];let T;e[3]!==I?(T=t.jsx("p",{className:"text-sm font-medium",children:I}),e[3]=I,e[4]=T):T=e[4];let R;e[5]!==l||e[6]!==o?(R=l??o("common.githubRepoPicker.somethingWentWrong"),e[5]=l,e[6]=o,e[7]=R):R=e[7];let w;e[8]!==R?(w=t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:R}),e[8]=R,e[9]=w):w=e[9];let _;e[10]!==T||e[11]!==w?(_=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[T,w]}),e[10]=T,e[11]=w,e[12]=_):_=e[12];let F;e[13]!==o?(F=o("common.githubRepoPicker.tryAgain"),e[13]=o,e[14]=F):F=e[14];let h;e[15]!==p||e[16]!==F?(h=t.jsx("button",{type:"button",onClick:p,className:"text-xs font-medium text-foreground border border-border rounded-md px-3 py-1.5 hover:bg-accent transition-colors",children:F}),e[15]=p,e[16]=F,e[17]=h):h=e[17];let S;return e[18]!==_||e[19]!==h?(S=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[v,_,h]}),e[18]=_,e[19]=h,e[20]=S):S=e[20],S}const a=n==="authenticating";let r;e[21]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(D,{className:"size-5 text-foreground"})}),e[21]=r):r=e[21];let s;e[22]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("div",{className:"relative size-10",children:[r,t.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-background flex items-center justify-center",children:t.jsx(Z,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[22]=s):s=e[22];let u;e[23]!==a||e[24]!==o?(u=o(a?"common.githubRepoPicker.authenticatingGitHub":"common.githubRepoPicker.settingUpGitHub"),e[23]=a,e[24]=o,e[25]=u):u=e[25];let N;e[26]!==u?(N=t.jsx("p",{className:"text-sm font-medium",children:u}),e[26]=u,e[27]=N):N=e[27];let k;e[28]!==a||e[29]!==o?(k=o(a?"common.githubRepoPicker.completeOAuthFlow":"common.githubRepoPicker.installingGitHubConnection"),e[28]=a,e[29]=o,e[30]=k):k=e[30];let P;e[31]!==k?(P=t.jsx("p",{className:"text-xs text-muted-foreground",children:k}),e[31]=k,e[32]=P):P=e[32];let f;e[33]!==N||e[34]!==P?(f=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[N,P]}),e[33]=N,e[34]=P,e[35]=f):f=e[35];const d=a?"bg-muted-foreground/30":"bg-foreground animate-pulse";let m;e[36]!==d?(m=ae("size-1.5 rounded-full",d),e[36]=d,e[37]=m):m=e[37];let c;e[38]!==m?(c=t.jsx("span",{className:m}),e[38]=m,e[39]=c):c=e[39];const b=a?"bg-foreground animate-pulse":"bg-muted-foreground/30";let g;e[40]!==b?(g=ae("size-1.5 rounded-full",b),e[40]=b,e[41]=g):g=e[41];let j;e[42]!==g?(j=t.jsx("span",{className:g}),e[42]=g,e[43]=j):j=e[43];let x;e[44]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[44]=x):x=e[44];let i;e[45]!==c||e[46]!==j?(i=t.jsxs("div",{className:"flex items-center gap-1.5",children:[c,j,x]}),e[45]=c,e[46]=j,e[47]=i):i=e[47];let y;return e[48]!==i||e[49]!==f?(y=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[s,f,i]}),e[48]=i,e[49]=f,e[50]=y):y=e[50],y}export{D as G,dt as a,Be as b,He as u};
@@ -1,4 +1,4 @@
1
- import{dH as It,dI as Tt,bi as R,Z as c,dJ as de,bo as Je,dK as wt,bh as At,aH as Mt,a6 as O,a5 as Y,a3 as oe,Y as S,bj as h,b8 as F,cw as Ot,dL as E,a4 as Ct,t as ge,c as Te,r as W,F as Rt,j as Nt}from"./index-wVkH9Hey.js";import{S as xt,u as Pt}from"./use-mcp-client-WCmcRc0D.js";import{d as He,D as ve}from"./decopilot-sse-pool-BJgHi1AV.js";import{d as Dt}from"./delay-CnY5UFtP.js";import{e as Lt}from"./backoff-CrEUbyZT.js";var re;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function a(s){throw new Error}t.assertNever=a,t.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},t.getValidEnumValues=s=>{const o=t.objectKeys(s).filter(n=>typeof s[s[n]]!="number"),i={};for(const n of o)i[n]=s[n];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(const i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(re||(re={}));var Oe;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(Oe||(Oe={}));re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ce extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(o){return o.message},r={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(a(i));else{let n=r,p=0;for(;p<i.path.length;){const u=i.path[p];p===i.path.length-1?(n[u]=n[u]||{_errors:[]},n[u]._errors.push(a(i))):n[u]=n[u]||{_errors:[]},n=n[u],p++}}};return s(this),r}static assert(e){if(!(e instanceof ce))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),r=[];for(const s of this.issues)if(s.path.length>0){const o=s.path[0];a[o]=a[o]||[],a[o].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:a}}get formErrors(){return this.flatten()}}ce.create=t=>new ce(t);var Ce;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Ce||(Ce={}));var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));var We="vercel.ai.error",kt=Symbol.for(We),Re,Ne,Z=class Ye extends(Ne=Error,Re=kt,Ne){constructor({name:e,message:a,cause:r}){super(a),this[Re]=!0,this.name=e,this.cause=r}static isInstance(e){return Ye.hasMarker(e,We)}static hasMarker(e,a){const r=Symbol.for(a);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Ge(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var qe="AI_InvalidArgumentError",Xe=`vercel.ai.error.${qe}`,jt=Symbol.for(Xe),xe,Pe,Zt=class extends(Pe=Z,xe=jt,Pe){constructor({message:t,cause:e,argument:a}){super({name:qe,message:t,cause:e}),this[xe]=!0,this.argument=a}static isInstance(t){return Z.hasMarker(t,Xe)}},Qe="AI_JSONParseError",Ke=`vercel.ai.error.${Qe}`,$t=Symbol.for(Ke),De,Le,ke=class extends(Le=Z,De=$t,Le){constructor({text:t,cause:e}){super({name:Qe,message:`JSON parsing failed: Text: ${t}.
1
+ import{dH as It,dI as Tt,bi as R,Z as c,dJ as de,bo as Je,dK as wt,bh as At,aH as Mt,a6 as O,a5 as Y,a3 as oe,Y as S,bj as h,b8 as F,cw as Ot,dL as E,a4 as Ct,t as ge,c as Te,r as W,F as Rt,j as Nt}from"./index-Ci2-WeDM.js";import{S as xt,u as Pt}from"./use-mcp-client-CaVVZEYW.js";import{d as He,D as ve}from"./decopilot-sse-pool-CdUwcdgN.js";import{d as Dt}from"./delay-CnY5UFtP.js";import{e as Lt}from"./backoff-CrEUbyZT.js";var re;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function a(s){throw new Error}t.assertNever=a,t.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},t.getValidEnumValues=s=>{const o=t.objectKeys(s).filter(n=>typeof s[s[n]]!="number"),i={};for(const n of o)i[n]=s[n];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(const i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(re||(re={}));var Oe;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(Oe||(Oe={}));re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ce extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(o){return o.message},r={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(a(i));else{let n=r,p=0;for(;p<i.path.length;){const u=i.path[p];p===i.path.length-1?(n[u]=n[u]||{_errors:[]},n[u]._errors.push(a(i))):n[u]=n[u]||{_errors:[]},n=n[u],p++}}};return s(this),r}static assert(e){if(!(e instanceof ce))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),r=[];for(const s of this.issues)if(s.path.length>0){const o=s.path[0];a[o]=a[o]||[],a[o].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:a}}get formErrors(){return this.flatten()}}ce.create=t=>new ce(t);var Ce;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Ce||(Ce={}));var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));var We="vercel.ai.error",kt=Symbol.for(We),Re,Ne,Z=class Ye extends(Ne=Error,Re=kt,Ne){constructor({name:e,message:a,cause:r}){super(a),this[Re]=!0,this.name=e,this.cause=r}static isInstance(e){return Ye.hasMarker(e,We)}static hasMarker(e,a){const r=Symbol.for(a);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Ge(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var qe="AI_InvalidArgumentError",Xe=`vercel.ai.error.${qe}`,jt=Symbol.for(Xe),xe,Pe,Zt=class extends(Pe=Z,xe=jt,Pe){constructor({message:t,cause:e,argument:a}){super({name:qe,message:t,cause:e}),this[xe]=!0,this.argument=a}static isInstance(t){return Z.hasMarker(t,Xe)}},Qe="AI_JSONParseError",Ke=`vercel.ai.error.${Qe}`,$t=Symbol.for(Ke),De,Le,ke=class extends(Le=Z,De=$t,Le){constructor({text:t,cause:e}){super({name:Qe,message:`JSON parsing failed: Text: ${t}.
2
2
  Error message: ${Ge(e)}`,cause:e}),this[De]=!0,this.text=t}static isInstance(t){return Z.hasMarker(t,Ke)}},et="AI_TypeValidationError",tt=`vercel.ai.error.${et}`,Ut=Symbol.for(tt),je,Ze,X=class ye extends(Ze=Z,je=Ut,Ze){constructor({value:e,cause:a,context:r}){let s="Type validation failed";if(r?.field&&(s+=` for ${r.field}`),r?.entityName||r?.entityId){s+=" (";const o=[];r.entityName&&o.push(r.entityName),r.entityId&&o.push(`id: "${r.entityId}"`),s+=o.join(", "),s+=")"}super({name:et,message:`${s}: Value: ${JSON.stringify(e)}.
3
3
  Error message: ${Ge(a)}`,cause:a}),this[je]=!0,this.value=e,this.context=r}static isInstance(e){return Z.hasMarker(e,tt)}static wrap({value:e,cause:a,context:r}){var s,o,i;return ye.isInstance(a)&&a.value===e&&((s=a.context)==null?void 0:s.field)===r?.field&&((o=a.context)==null?void 0:o.entityName)===r?.entityName&&((i=a.context)==null?void 0:i.entityId)===r?.entityId?a:new ye({value:e,cause:a,context:r})}},ie=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const s=()=>{const o=a.length,i=new Array(e);for(let n=0;n<e;n++)i[n]=a[Math.random()*o|0];return i.join("")};if(t==null)return s;if(a.includes(r))throw new Zt({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${a}".`});return()=>`${t}${r}${s()}`};ie();var Ft=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Bt=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function $e(t){const e=JSON.parse(t);return e===null||typeof e!="object"||Ft.test(t)===!1&&Bt.test(t)===!1?e:Vt(e)}function Vt(t){let e=[t];for(;e.length;){const a=e;e=[];for(const r of a){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&r.constructor!==null&&typeof r.constructor=="object"&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const s in r){const o=r[s];o&&typeof o=="object"&&e.push(o)}}}return t}function zt(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return $e(t)}try{return $e(t)}finally{Error.stackTraceLimit=e}}function we(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const r of Object.keys(a))a[r]=z(a[r])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(z):z(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(z)),t.allOf!=null&&(t.allOf=t.allOf.map(z)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(z));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=z(e[a]);return t}function z(t){return typeof t=="boolean"?t:we(t)}var Jt=Symbol("Let zodToJsonSchema decide on which parser to use"),Ue={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Ht=t=>typeof t=="string"?{...Ue,name:t}:{...Ue,...t};function N(){return{}}function Wt(t,e){var a,r,s;const o={type:"array"};return(a=t.type)!=null&&a._def&&((s=(r=t.type)==null?void 0:r._def)==null?void 0:s.typeName)!==m.ZodAny&&(o.items=b(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(o.minItems=t.minLength.value),t.maxLength&&(o.maxItems=t.maxLength.value),t.exactLength&&(o.minItems=t.exactLength.value,o.maxItems=t.exactLength.value),o}function Yt(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function Gt(){return{type:"boolean"}}function at(t,e){return b(t.type._def,e)}var qt=(t,e)=>b(t.innerType._def,e);function rt(t,e,a){const r=a??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((s,o)=>rt(t,e,s))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Xt(t)}}var Xt=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function Qt(t,e){return{...b(t.innerType._def,e),default:t.defaultValue()}}function Kt(t,e){return e.effectStrategy==="input"?b(t.schema._def,e):N()}function ea(t){return{type:"string",enum:Array.from(t.values)}}var ta=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function aa(t,e){const a=[b(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),b(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),r=[];return a.forEach(s=>{if(ta(s))r.push(...s.allOf);else{let o=s;if("additionalProperties"in s&&s.additionalProperties===!1){const{additionalProperties:i,...n}=s;o=n}r.push(o)}}),r.length?{allOf:r}:void 0}function ra(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var he=void 0,P={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(he===void 0&&(he=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),he),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function st(t,e){const a={type:"string"};if(t.checks)for(const r of t.checks)switch(r.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,r.value):r.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,r.value):r.value;break;case"email":switch(e.emailStrategy){case"format:email":D(a,"email",r.message,e);break;case"format:idn-email":D(a,"idn-email",r.message,e);break;case"pattern:zod":M(a,P.email,r.message,e);break}break;case"url":D(a,"uri",r.message,e);break;case"uuid":D(a,"uuid",r.message,e);break;case"regex":M(a,r.regex,r.message,e);break;case"cuid":M(a,P.cuid,r.message,e);break;case"cuid2":M(a,P.cuid2,r.message,e);break;case"startsWith":M(a,RegExp(`^${me(r.value,e)}`),r.message,e);break;case"endsWith":M(a,RegExp(`${me(r.value,e)}$`),r.message,e);break;case"datetime":D(a,"date-time",r.message,e);break;case"date":D(a,"date",r.message,e);break;case"time":D(a,"time",r.message,e);break;case"duration":D(a,"duration",r.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,r.value):r.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,r.value):r.value;break;case"includes":{M(a,RegExp(me(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&&D(a,"ipv4",r.message,e),r.version!=="v4"&&D(a,"ipv6",r.message,e);break}case"base64url":M(a,P.base64url,r.message,e);break;case"jwt":M(a,P.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&M(a,P.ipv4Cidr,r.message,e),r.version!=="v4"&&M(a,P.ipv6Cidr,r.message,e);break}case"emoji":M(a,P.emoji(),r.message,e);break;case"ulid":{M(a,P.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{D(a,"binary",r.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{M(a,P.base64,r.message,e);break}}break}case"nanoid":M(a,P.nanoid,r.message,e)}return a}function me(t,e){return e.patternStrategy==="escape"?na(t):t}var sa=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function na(t){let e="";for(let a=0;a<t.length;a++)sa.has(t[a])||(e+="\\"),e+=t[a];return e}function D(t,e,a,r){var s;t.format||(s=t.anyOf)!=null&&s.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&r.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function M(t,e,a,r){var s;t.pattern||(s=t.allOf)!=null&&s.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Fe(e,r),...a&&r.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=Fe(e,r)}function Fe(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},s=r.i?t.source.toLowerCase():t.source;let o="",i=!1,n=!1,p=!1;for(let u=0;u<s.length;u++){if(i){o+=s[u],i=!1;continue}if(r.i){if(n){if(s[u].match(/[a-z]/)){p?(o+=s[u],o+=`${s[u-2]}-${s[u]}`.toUpperCase(),p=!1):s[u+1]==="-"&&((a=s[u+2])!=null&&a.match(/[a-z]/))?(o+=s[u],p=!0):o+=`${s[u]}${s[u].toUpperCase()}`;continue}}else if(s[u].match(/[a-z]/)){o+=`[${s[u]}${s[u].toUpperCase()}]`;continue}}if(r.m){if(s[u]==="^"){o+=`(^|(?<=[\r
4
4
  ]))`;continue}else if(s[u]==="$"){o+=`($|(?=[\r
@@ -12,4 +12,4 @@ Error message: ${Ge(a)}`,cause:a}),this[je]=!0,this.value=e,this.context=r}stati
12
12
 
13
13
  `))!==-1;){const p=s.slice(0,n);if(s=s.slice(n+2),await this.handleStreamFrame(p),this.status.get().kind==="error")return!1}}}async handleStreamFrame(e){const a=e.split(`
14
14
  `);let r="message";const s=[];for(const n of a)n.startsWith("event:")?r=n.slice(6).trim():n.startsWith("data:")&&s.push(n.slice(5).trim());if(s.length===0)return;const o=s.join(`
15
- `);if(r!=="message")return;let i;try{i=JSON.parse(o)}catch(n){this.failTo(n instanceof Error?n:new Error(String(n)));return}await this.validateAndHandleChunk(i)}async validateAndHandleChunk(e){try{const a=sr(),r=a.validate?await a.validate(e):{success:!0,value:e};if(!r.success){this.failTo(r.error instanceof Error?r.error:new Error(String(r.error)));return}this.handleChunk(r.value)}catch(a){this.failTo(a instanceof Error?a:new Error(String(a)))}}drainChunkBuffer(){const e=this.chunkBuffer??[];this.chunkBuffer=null;for(const a of e)this.handleChunk(a)}setRunStatusStage(e){this.runStatusStage.update(a=>wr(a,e))}clearRunStatusStage(){this.runStatusStage.get()!==null&&this.runStatusStage.set(null)}handleChunk(e){if(this.chunkBuffer!==null){this.chunkBuffer.push(e);return}if(e.type==="data-user-message"){const o=e.data;o&&this.applyLocalMessage(o);return}const a=Tr(e),r=Ir(e);if(this.waitingForNewRun){if(a){this.acceptPreStartRunStatus&&r&&(this.setRunStatusStage(r),this.observer?.onData?.(e));return}if(e.type!=="start")return;this.waitingForNewRun=!1,this.acceptPreStartRunStatus=!0}if(a){r&&(this.setRunStatusStage(r),this.observer?.onData?.(e));return}if(e.type!=="start"&&e.type!=="finish"&&!e.type.startsWith("data-")&&e.type!=="start-step"&&this.clearRunStatusStage(),e.type.startsWith("data-")&&this.observer?.onData?.(e),e.type==="tool-input-available"){const o=e;this.observer?.onToolCall?.({toolCall:{toolCallId:o.toolCallId,toolName:o.toolName,input:o.input}})}e.type==="start"&&(this.freshRunSubstream=!0);const s=this.ensureSubStream();if(s.enqueue(e),e.type==="finish"){const o=e;this.pendingFinishReason=o.finishReason,this.clearRunStatusStage(),this.subController=null,s.close()}}forceCloseSubStream(e=!1){const a=this.subController;if(a){this.discardOnClose=e,this.subController=null;try{a.close()}catch{}}}ensureSubStream(){if(this.subController)return this.subController;this.pendingFinishReason=void 0;let e;const a=new ReadableStream({start(r){e=r}});return this.subController=e,this.foldSubStream(a),e}async foldSubStream(e){const a=this.messages.get(),r=a.at(-1),s=this.freshRunSubstream&&r?.role==="assistant"&&(r.parts??[]).some(T=>"state"in T&&(T.state==="approval-requested"||T.state==="approval-responded")),o=s?structuredClone(r):!this.freshRunSubstream&&a.length>0&&r?.role==="assistant"?r:void 0,i=s?r?.id:void 0;this.freshRunSubstream=!1;const n=cr({message:o,stream:br(e,o),onError:T=>{const k=T instanceof Error?T:new Error(String(T));this.failTo(k)}});let p=null,u=null,d=null;const f=()=>{if(d=null,!u)return;const T=i&&u.id!==i?{...u,id:i}:u;u=null,this.messages.update(k=>H(St(jr(k,Ur(k,T))),[]))};for await(const T of n)p=T,u=T,d===null&&(d=Rr(f)),this.status.get().kind!=="streaming"&&this.status.set({kind:"streaming"});d!==null&&(Nr(d),d=null),u&&f();const _=this.pendingFinishReason,C=this.discardOnClose;if(this.subController=null,this.pendingFinishReason=void 0,this.discardOnClose=!1,C||(this.finishReason.set(_??null),this.status.set({kind:"ready"})),p&&!C){const T=i??p.id;this.messages.update(x=>{const j=x.findIndex(v=>v.id===T);if(j===-1)return x;const V=x[j];if(V.created_at!=null)return x;const l=V.metadata?.created_at,w=l!=null?new Date(l).toISOString():new Date().toISOString(),I=[...x];return I[j]={...V,created_at:w},I}),this.observer?.onFinish?.(p,this.messages.get(),_),p.metadata?.resumedFromBackground&&this.refetchLatestPage()}}failTo(e){this.abort.signal.aborted||(this.clearRunStatusStage(),this.status.set({kind:"error",error:e}),this.observer?.onError?.(e))}}function kr(t,e){const a=new Map;for(const r of t.parts)r&&typeof r=="object"&&"toolCallId"in r&&"created_at"in r&&typeof r.toolCallId=="string"&&a.set(r.toolCallId,r.created_at);return a.size===0?e.parts:e.parts.map(r=>{if(r&&typeof r=="object"&&"toolCallId"in r&&!("created_at"in r)&&typeof r.toolCallId=="string"){const s=a.get(r.toolCallId);if(s!=null)return{...r,created_at:s}}return r})}function bt(t,e){if(!t)return e;const a=t.created_at,r=e.created_at,s=kr(t,e);let o=s===e.parts?e:{...e,parts:s};return r==null&&a!=null&&(o={...o,created_at:a}),o}function jr(t,e){const a=t.findIndex(s=>s.id===e.id);if(a===-1)return[...t,e];const r=[...t];return r[a]=bt(r[a],e),r}const ue="msg_async_stub_";function St(t){let e=!1;for(const r of t)if(r.id.startsWith(ue)){e=!0;break}if(!e)return t;const a=new Set;for(const r of t)if(r.role==="assistant"&&!r.id.startsWith(ue))for(const s of r.parts)s&&typeof s=="object"&&"type"in s&&s.type==="tool-web_search"&&"toolCallId"in s&&a.add(s.toolCallId);return a.size===0?t:t.filter(r=>{if(!r.id.startsWith(ue))return!0;const s=Zr(r)??r.id.slice(ue.length);return!a.has(s)})}function Zr(t){for(const e of t.parts)if(e&&typeof e=="object"&&"type"in e&&e.type==="tool-web_search"&&"toolCallId"in e&&typeof e.toolCallId=="string")return e.toolCallId}function H(t,e){const a=new Map(t.map(s=>[s.id,s]));for(const s of e)a.set(s.id,bt(a.get(s.id),s));const r=[...a.values()];return r.sort((s,o)=>{const i=ne(s),n=ne(o);if(i!==n)return i-n;const p=f=>f.role==="user"?0:f.role==="assistant"?1:2,u=p(s),d=p(o);return u!==d?u-d:s.id<o.id?-1:s.id>o.id?1:0}),St(r)}function $r(t,e){if(e.length===0)return t;const a=new Set(e.map(o=>o.id));let r=Number.POSITIVE_INFINITY;for(const o of e){const i=ne(o);i<r&&(r=i)}const s=t.filter(o=>{if(o.role!=="assistant"||a.has(o.id))return!0;const i=ne(o);return Number.isFinite(i)&&i<=r});return H(s,e)}function Ur(t,e){if(e.created_at!=null||t.find(s=>s.id===e.id)?.created_at!=null)return e;let r=0;for(const s of t){const o=ne(s);Number.isFinite(o)&&o>r&&(r=o)}return r===0?e:{...e,created_at:new Date(r+1).toISOString()}}function ne(t){const e=t;if(e.created_at!=null)return new Date(e.created_at).getTime();const a=t.metadata;return a?.created_at!=null?new Date(a.created_at).getTime():Number.POSITIVE_INFINITY}let J=null;function Fr(t,e,a={}){const r=`${t}::${e}`;return J?.key===r?(a.batch&&J.enableBatch(),J):(J?.dispose(),J=new Lr(t,e,a),typeof window<"u"&&(window.__conn=J),J)}const Br=new Set(["decopilot","claude-code"]);function Vr(t){return t==="claude-code"}function ts({isDesktopApp:t,harnessId:e,sandboxProviderKind:a}){return e!=null&&!Br.has(e)?!0:a==null||a==="agent-sandbox"?!1:!(e==="decopilot"&&a==="user-desktop")}const zr=6e4;function ee(t,e){const a=t.findIndex(n=>n.id===e.id);if(a===-1){const n=new Date().toISOString();return[{created_at:e.created_at??e.updated_at??n,updated_at:e.updated_at??n,...e,title:e.title??"New chat",branch:e.branch??null},...t]}const r=[...t],s=r[a],o=s.updated_at?new Date(s.updated_at).getTime():Number.NEGATIVE_INFINITY;return(e.updated_at?new Date(e.updated_at).getTime():Number.POSITIVE_INFINITY)<o?t:(r[a]={...r[a],...e},r)}function Jr(t,e){const a=t.findIndex(s=>s.id===e.id);if(a===-1)return[e,...t];const r=[...t];return r[a]={...r[a],...e},r}class Hr{constructor(e,a,r={}){this.orgSlug=e,this.locator=a,this.key=`${e}::${a}`,this.client=r.client??null;const s=r.sse??He;this.watchUnsubscribe=s.subscribe(this.orgSlug,o=>this.handleWatchEvent(o),()=>this.onWatchReconnect()),this.loadInitialPage()}orgSlug;locator;threads=new L([]);threadsStatus=new L({kind:"loading"});active=new L(null);key;hasMore=new L(!1);isFetchingMore=new L(!1);pendingOptimistic=new Set;archivedTombstones=new Map;client;nextOffset=0;pageSize=10;scopeWhere={created_by:"me"};scopeKey=JSON.stringify({created_by:"me"});loadGeneration=0;eventBuffer=[];watchUnsubscribe=null;dispose(){this.watchUnsubscribe?.(),this.watchUnsubscribe=null,this.active.set(null)}setActive(e){const a=Fr(this.orgSlug,e,{client:this.client,batch:Vr(this.threads.get().find(r=>r.id===e)?.harness_id)});return this.active.get()!==a&&this.active.set(a),a}closeActive(){this.active.get()!==null&&this.active.set(null)}async create(e){try{if(!this.client)throw new Error("ThreadManagerStore: no MCP client");const a=await this.client.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:e}});if(a.isError)throw new Error(ae(a,"COLLECTION_THREADS_CREATE failed"));const r=a.structuredContent?.item;if(!r)throw new Error("create: no item returned");return this.threads.update(s=>s.some(o=>o.id===r.id)?s:[r,...s]),r}catch(a){const r=a instanceof Error?a.message:String(a);throw ge.error(`Could not create chat: ${r}`),a}}rename(e,a){return this.optimisticUpdate(e,{title:a})}hide(e){return this.optimisticHide(e)}setStatus(e,a){return this.optimisticUpdate(e,{status:a})}setBranch(e,a){return this.optimisticUpdate(e,{branch:a})}setAgent(e,a){return this.optimisticUpdate(e,{virtual_mcp_id:a})}patchThread(e){this.isTombstoned(e.id)||this.threads.update(a=>ee(a,e))}mergeThreads(e){e.length!==0&&this.threads.update(a=>e.reduce((r,s)=>this.isTombstoned(s.id)?r:ee(r,s),a))}async optimisticUpdate(e,a){if(!this.client)throw new Error("ThreadManagerStore: no MCP client");const r=this.threads.get();this.pendingOptimistic.add(e),this.threads.update(s=>ee(s,{...a,id:e,updated_at:new Date().toISOString()}));try{if((await this.client.callTool({name:"COLLECTION_THREADS_UPDATE",arguments:{id:e,data:a}})).isError)throw new Error("COLLECTION_THREADS_UPDATE failed")}catch(s){throw this.threads.set(r),s}finally{this.pendingOptimistic.delete(e)}}async optimisticHide(e){if(!this.client)throw new Error("ThreadManagerStore: no MCP client");const a=this.threads.get();this.pendingOptimistic.add(e),this.archivedTombstones.set(e,Date.now()),this.threads.update(r=>r.filter(s=>s.id!==e));try{if((await this.client.callTool({name:"COLLECTION_THREADS_UPDATE",arguments:{id:e,data:{hidden:!0}}})).isError)throw new Error("COLLECTION_THREADS_UPDATE failed")}catch(r){throw this.threads.set(a),this.archivedTombstones.delete(e),r}finally{this.pendingOptimistic.delete(e)}}pruneArchivedTombstones(){if(this.archivedTombstones.size===0)return;const e=Date.now()-zr;for(const[a,r]of this.archivedTombstones)r<e&&this.archivedTombstones.delete(a)}isTombstoned(e){return this.pruneArchivedTombstones(),this.archivedTombstones.has(e)}async loadInitialPage(){const e=++this.loadGeneration;if(!this.client){this.drainEventBuffer();return}try{const a=await this.client.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:this.pageSize,offset:0,orderBy:[{field:["updated_at"],direction:"desc"}],where:{hidden:!1,...this.scopeWhere}}});if(e!==this.loadGeneration)return;if(a.isError)throw new Error(ae(a,"COLLECTION_THREADS_LIST failed"));const r=a.structuredContent??a,s=r.items??[];this.threads.set(s),this.hasMore.set(r.hasMore??!1),this.nextOffset=s.length,this.threadsStatus.set({kind:"ready"}),this.drainEventBuffer()}catch(a){if(e!==this.loadGeneration)return;this.threadsStatus.set({kind:"error",error:a instanceof Error?a:new Error(String(a))}),this.drainEventBuffer()}}setScope(e){const a=JSON.stringify(e);a!==this.scopeKey&&(this.scopeKey=a,this.scopeWhere=e,this.nextOffset=0,this.loadInitialPage())}drainEventBuffer(){const e=this.eventBuffer??[];this.eventBuffer=null;for(const a of e)this.isTombstoned(a.id)||this.threads.update(r=>ee(r,a))}async fetchNextPage(){if(!this.client||!this.hasMore.get()||this.isFetchingMore.get())return;this.isFetchingMore.set(!0);const e=this.loadGeneration;try{const a=await this.client.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:this.pageSize,offset:this.nextOffset,orderBy:[{field:["updated_at"],direction:"desc"}],where:{hidden:!1,...this.scopeWhere}}});if(e!==this.loadGeneration)return;if(a.isError)throw new Error(ae(a,"COLLECTION_THREADS_LIST failed"));const r=a.structuredContent??a,s=r.items??[];this.threads.update(o=>{const i=new Set(o.map(n=>n.id));return[...o,...s.filter(n=>!i.has(n.id))]}),this.hasMore.set(r.hasMore??!1),this.nextOffset+=s.length}catch(a){const r=a instanceof Error?a.message:String(a);ge.error(`Could not load more chats: ${r}`)}finally{this.isFetchingMore.set(!1)}}async fetchThread(e){if(!e)return null;const a=this.threads.get().find(r=>r.id===e);return a||this.getThreadRemote(e)}async getThreadRemote(e){if(!e||!this.client)return null;try{const a=await this.client.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:e}});return a.isError?null:(a.structuredContent??a).item??null}catch{return null}}async refreshThreadMetadata(e){if(!(!e||!this.client)&&this.threads.get().some(a=>a.id===e))try{const a=await this.client.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:e}});if(a.isError)return;const s=(a.structuredContent??a).item;if(!s)return;this.patchThread({id:s.id,metadata:s.metadata,virtual_mcp_id:s.virtual_mcp_id,branch:s.branch,updated_at:s.updated_at})}catch{}}async fetchThreadIntoSlot(e){const a=await this.getThreadRemote(e);return a&&!a.hidden&&!this.isTombstoned(a.id)&&this.threads.update(r=>Jr(r,a)),a??this.threads.get().find(r=>r.id===e)??null}handleWatchEvent(e){if(e.type!==ve.THREAD_STATUS)return;let a;try{a=JSON.parse(e.data)}catch{return}if(this.isTombstoned(a.subject))return;const r={id:a.subject,updated_at:a.data.updated_at??a.time,...a.data.status!==void 0&&{status:a.data.status},...a.data.created_by!==void 0&&{created_by:a.data.created_by},...a.data.trigger_id!==void 0&&{trigger_id:a.data.trigger_id},...a.data.virtual_mcp_id!==void 0&&{virtual_mcp_id:a.data.virtual_mcp_id},...a.data.title!==void 0&&{title:a.data.title},...a.data.branch!==void 0&&{branch:a.data.branch},...a.data.harness_id!==void 0&&{harness_id:a.data.harness_id},...a.data.created_at!==void 0&&{created_at:a.data.created_at},...a.data.metadata!==void 0&&{metadata:a.data.metadata}};if(this.eventBuffer!==null){this.eventBuffer.push(r);return}this.threads.update(s=>ee(s,r))}onWatchReconnect(){this.eventBuffer=[],this.loadInitialPage()}}let $=null;function Wr(t,e,a={}){const r=`${t}::${e}`;return $&&$.key===r||($?.dispose(),$=new Hr(t,e,a)),$}function as(t,e){const a=`${t}::${e}`;return $&&$.key===a?$:null}const Me=W.createContext(null);function rs(t){const e=Te.c(10),{children:a}=t,{org:r,locator:s}=Rt();let o;e[0]!==r.id||e[1]!==r.slug?(o={connectionId:xt,orgId:r.id,orgSlug:r.slug},e[0]=r.id,e[1]=r.slug,e[2]=o):o=e[2];const i=Pt(o);let n;e[3]!==i||e[4]!==s||e[5]!==r.slug?(n=Wr(r.slug,s,{client:i}),e[3]=i,e[4]=s,e[5]=r.slug,e[6]=n):n=e[6];const p=n;let u;return e[7]!==a||e[8]!==p?(u=Nt.jsx(Me.Provider,{value:p,children:a}),e[7]=a,e[8]=p,e[9]=u):u=e[9],u}function _t(){const t=W.useContext(Me);if(!t)throw new Error("useThreadManager: missing ThreadManagerProvider");return t}function ss(){return W.useContext(Me)}function ns(){const t=Te.c(8),e=_t(),a=W.useSyncExternalStore(e.threads.subscribe,e.threads.get),r=W.useSyncExternalStore(e.threadsStatus.subscribe,e.threadsStatus.get),s=W.useSyncExternalStore(e.hasMore.subscribe,e.hasMore.get),o=W.useSyncExternalStore(e.isFetchingMore.subscribe,e.isFetchingMore.get);let i;t[0]!==e?(i=e.fetchNextPage.bind(e),t[0]=e,t[1]=i):i=t[1];let n;return t[2]!==s||t[3]!==o||t[4]!==r||t[5]!==i||t[6]!==a?(n={threads:a,status:r,hasMore:s,isFetchingMore:o,fetchNextPage:i},t[2]=s,t[3]=o,t[4]=r,t[5]=i,t[6]=a,t[7]=n):n=t[7],n}function os(){const t=Te.c(28),e=_t();let a;t[0]!==e?(a=e.create.bind(e),t[0]=e,t[1]=a):a=t[1];let r;t[2]!==e?(r=e.rename.bind(e),t[2]=e,t[3]=r):r=t[3];let s;t[4]!==e?(s=e.hide.bind(e),t[4]=e,t[5]=s):s=t[5];let o;t[6]!==e?(o=e.setStatus.bind(e),t[6]=e,t[7]=o):o=t[7];let i;t[8]!==e?(i=e.setBranch.bind(e),t[8]=e,t[9]=i):i=t[9];let n;t[10]!==e?(n=e.setAgent.bind(e),t[10]=e,t[11]=n):n=t[11];let p;t[12]!==e?(p=e.setScope.bind(e),t[12]=e,t[13]=p):p=t[13];let u;t[14]!==e?(u=e.setActive.bind(e),t[14]=e,t[15]=u):u=t[15];let d;t[16]!==e?(d=e.closeActive.bind(e),t[16]=e,t[17]=d):d=t[17];let f;return t[18]!==a||t[19]!==r||t[20]!==s||t[21]!==o||t[22]!==i||t[23]!==n||t[24]!==p||t[25]!==u||t[26]!==d?(f={create:a,rename:r,hide:s,setStatus:o,setBranch:i,setAgent:n,setScope:p,setActive:u,closeActive:d},t[18]=a,t[19]=r,t[20]=s,t[21]=o,t[22]=i,t[23]=n,t[24]=p,t[25]=u,t[26]=d,t[27]=f):f=t[27],f}export{L as S,rs as T,ns as a,os as b,ss as c,es as d,br as e,Fr as f,as as g,Vr as i,cr as r,ts as s,Kr as t,_t as u,ot as z};
15
+ `);if(r!=="message")return;let i;try{i=JSON.parse(o)}catch(n){this.failTo(n instanceof Error?n:new Error(String(n)));return}await this.validateAndHandleChunk(i)}async validateAndHandleChunk(e){try{const a=sr(),r=a.validate?await a.validate(e):{success:!0,value:e};if(!r.success){this.failTo(r.error instanceof Error?r.error:new Error(String(r.error)));return}this.handleChunk(r.value)}catch(a){this.failTo(a instanceof Error?a:new Error(String(a)))}}drainChunkBuffer(){const e=this.chunkBuffer??[];this.chunkBuffer=null;for(const a of e)this.handleChunk(a)}setRunStatusStage(e){this.runStatusStage.update(a=>wr(a,e))}clearRunStatusStage(){this.runStatusStage.get()!==null&&this.runStatusStage.set(null)}handleChunk(e){if(this.chunkBuffer!==null){this.chunkBuffer.push(e);return}if(e.type==="data-user-message"){const o=e.data;o&&this.applyLocalMessage(o);return}const a=Tr(e),r=Ir(e);if(this.waitingForNewRun){if(a){this.acceptPreStartRunStatus&&r&&(this.setRunStatusStage(r),this.observer?.onData?.(e));return}if(e.type!=="start")return;this.waitingForNewRun=!1,this.acceptPreStartRunStatus=!0}if(a){r&&(this.setRunStatusStage(r),this.observer?.onData?.(e));return}if(e.type!=="start"&&e.type!=="finish"&&!e.type.startsWith("data-")&&e.type!=="start-step"&&this.clearRunStatusStage(),e.type.startsWith("data-")&&this.observer?.onData?.(e),e.type==="tool-input-available"){const o=e;this.observer?.onToolCall?.({toolCall:{toolCallId:o.toolCallId,toolName:o.toolName,input:o.input}})}e.type==="start"&&(this.freshRunSubstream=!0);const s=this.ensureSubStream();if(s.enqueue(e),e.type==="finish"){const o=e;this.pendingFinishReason=o.finishReason,this.clearRunStatusStage(),this.subController=null,s.close()}}forceCloseSubStream(e=!1){const a=this.subController;if(a){this.discardOnClose=e,this.subController=null;try{a.close()}catch{}}}ensureSubStream(){if(this.subController)return this.subController;this.pendingFinishReason=void 0;let e;const a=new ReadableStream({start(r){e=r}});return this.subController=e,this.foldSubStream(a),e}async foldSubStream(e){const a=this.messages.get(),r=a.at(-1),s=this.freshRunSubstream&&r?.role==="assistant"&&(r.parts??[]).some(T=>"state"in T&&(T.state==="approval-requested"||T.state==="approval-responded")),o=s?structuredClone(r):!this.freshRunSubstream&&a.length>0&&r?.role==="assistant"?r:void 0,i=s?r?.id:void 0;this.freshRunSubstream=!1;const n=cr({message:o,stream:br(e,o),onError:T=>{const k=T instanceof Error?T:new Error(String(T));this.failTo(k)}});let p=null,u=null,d=null;const f=()=>{if(d=null,!u)return;const T=i&&u.id!==i?{...u,id:i}:u;u=null,this.messages.update(k=>H(St(jr(k,Ur(k,T))),[]))};for await(const T of n)p=T,u=T,d===null&&(d=Rr(f)),this.status.get().kind!=="streaming"&&this.status.set({kind:"streaming"});d!==null&&(Nr(d),d=null),u&&f();const _=this.pendingFinishReason,C=this.discardOnClose;if(this.subController=null,this.pendingFinishReason=void 0,this.discardOnClose=!1,C||(this.finishReason.set(_??null),this.status.set({kind:"ready"})),p&&!C){const T=i??p.id;this.messages.update(x=>{const j=x.findIndex(v=>v.id===T);if(j===-1)return x;const V=x[j];if(V.created_at!=null)return x;const l=V.metadata?.created_at,w=l!=null?new Date(l).toISOString():new Date().toISOString(),I=[...x];return I[j]={...V,created_at:w},I}),this.observer?.onFinish?.(p,this.messages.get(),_),p.metadata?.resumedFromBackground&&this.refetchLatestPage()}}failTo(e){this.abort.signal.aborted||(this.clearRunStatusStage(),this.status.set({kind:"error",error:e}),this.observer?.onError?.(e))}}function kr(t,e){const a=new Map;for(const r of t.parts)r&&typeof r=="object"&&"toolCallId"in r&&"created_at"in r&&typeof r.toolCallId=="string"&&a.set(r.toolCallId,r.created_at);return a.size===0?e.parts:e.parts.map(r=>{if(r&&typeof r=="object"&&"toolCallId"in r&&!("created_at"in r)&&typeof r.toolCallId=="string"){const s=a.get(r.toolCallId);if(s!=null)return{...r,created_at:s}}return r})}function bt(t,e){if(!t)return e;const a=t.created_at,r=e.created_at,s=kr(t,e);let o=s===e.parts?e:{...e,parts:s};return r==null&&a!=null&&(o={...o,created_at:a}),o}function jr(t,e){const a=t.findIndex(s=>s.id===e.id);if(a===-1)return[...t,e];const r=[...t];return r[a]=bt(r[a],e),r}const ue="msg_async_stub_";function St(t){let e=!1;for(const r of t)if(r.id.startsWith(ue)){e=!0;break}if(!e)return t;const a=new Set;for(const r of t)if(r.role==="assistant"&&!r.id.startsWith(ue))for(const s of r.parts)s&&typeof s=="object"&&"type"in s&&s.type==="tool-web_search"&&"toolCallId"in s&&a.add(s.toolCallId);return a.size===0?t:t.filter(r=>{if(!r.id.startsWith(ue))return!0;const s=Zr(r)??r.id.slice(ue.length);return!a.has(s)})}function Zr(t){for(const e of t.parts)if(e&&typeof e=="object"&&"type"in e&&e.type==="tool-web_search"&&"toolCallId"in e&&typeof e.toolCallId=="string")return e.toolCallId}function H(t,e){const a=new Map(t.map(s=>[s.id,s]));for(const s of e)a.set(s.id,bt(a.get(s.id),s));const r=[...a.values()];return r.sort((s,o)=>{const i=ne(s),n=ne(o);if(i!==n)return i-n;const p=f=>f.role==="user"?0:f.role==="assistant"?1:2,u=p(s),d=p(o);return u!==d?u-d:s.id<o.id?-1:s.id>o.id?1:0}),St(r)}function $r(t,e){if(e.length===0)return t;const a=new Set(e.map(o=>o.id));let r=Number.POSITIVE_INFINITY;for(const o of e){const i=ne(o);i<r&&(r=i)}const s=t.filter(o=>{if(o.role!=="assistant"||a.has(o.id))return!0;const i=ne(o);return Number.isFinite(i)&&i<=r});return H(s,e)}function Ur(t,e){if(e.created_at!=null||t.find(s=>s.id===e.id)?.created_at!=null)return e;let r=0;for(const s of t){const o=ne(s);Number.isFinite(o)&&o>r&&(r=o)}return r===0?e:{...e,created_at:new Date(r+1).toISOString()}}function ne(t){const e=t;if(e.created_at!=null)return new Date(e.created_at).getTime();const a=t.metadata;return a?.created_at!=null?new Date(a.created_at).getTime():Number.POSITIVE_INFINITY}let J=null;function Fr(t,e,a={}){const r=`${t}::${e}`;return J?.key===r?(a.batch&&J.enableBatch(),J):(J?.dispose(),J=new Lr(t,e,a),typeof window<"u"&&(window.__conn=J),J)}const Br=new Set(["decopilot","claude-code"]);function Vr(t){return t==="claude-code"}function ts({isDesktopApp:t,harnessId:e,sandboxProviderKind:a}){return e!=null&&!Br.has(e)?!0:a==null||a==="agent-sandbox"?!1:!(e==="decopilot"&&a==="user-desktop")}const zr=6e4;function ee(t,e){const a=t.findIndex(n=>n.id===e.id);if(a===-1){const n=new Date().toISOString();return[{created_at:e.created_at??e.updated_at??n,updated_at:e.updated_at??n,...e,title:e.title??"New chat",branch:e.branch??null},...t]}const r=[...t],s=r[a],o=s.updated_at?new Date(s.updated_at).getTime():Number.NEGATIVE_INFINITY;return(e.updated_at?new Date(e.updated_at).getTime():Number.POSITIVE_INFINITY)<o?t:(r[a]={...r[a],...e},r)}function Jr(t,e){const a=t.findIndex(s=>s.id===e.id);if(a===-1)return[e,...t];const r=[...t];return r[a]={...r[a],...e},r}class Hr{constructor(e,a,r={}){this.orgSlug=e,this.locator=a,this.key=`${e}::${a}`,this.client=r.client??null;const s=r.sse??He;this.watchUnsubscribe=s.subscribe(this.orgSlug,o=>this.handleWatchEvent(o),()=>this.onWatchReconnect()),this.loadInitialPage()}orgSlug;locator;threads=new L([]);threadsStatus=new L({kind:"loading"});active=new L(null);key;hasMore=new L(!1);isFetchingMore=new L(!1);archivedTombstones=new Map;client;nextOffset=0;pageSize=10;scopeWhere={created_by:"me"};scopeKey=JSON.stringify({created_by:"me"});loadGeneration=0;eventBuffer=[];watchUnsubscribe=null;dispose(){this.watchUnsubscribe?.(),this.watchUnsubscribe=null,this.active.set(null)}setActive(e){const a=Fr(this.orgSlug,e,{client:this.client,batch:Vr(this.threads.get().find(r=>r.id===e)?.harness_id)});return this.active.get()!==a&&this.active.set(a),a}closeActive(){this.active.get()!==null&&this.active.set(null)}async create(e){try{if(!this.client)throw new Error("ThreadManagerStore: no MCP client");const a=await this.client.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:e}});if(a.isError)throw new Error(ae(a,"COLLECTION_THREADS_CREATE failed"));const r=a.structuredContent?.item;if(!r)throw new Error("create: no item returned");return this.threads.update(s=>s.some(o=>o.id===r.id)?s:[r,...s]),r}catch(a){const r=a instanceof Error?a.message:String(a);throw ge.error(`Could not create chat: ${r}`),a}}rename(e,a){return this.optimisticUpdate(e,{title:a})}hide(e){return this.optimisticHide(e)}setStatus(e,a){return this.optimisticUpdate(e,{status:a})}setBranch(e,a){return this.optimisticUpdate(e,{branch:a})}setAgent(e,a){return this.optimisticUpdate(e,{virtual_mcp_id:a})}patchThread(e){this.isTombstoned(e.id)||this.threads.update(a=>ee(a,e))}mergeThreads(e){e.length!==0&&this.threads.update(a=>e.reduce((r,s)=>this.isTombstoned(s.id)?r:ee(r,s),a))}async optimisticUpdate(e,a){if(!this.client)throw new Error("ThreadManagerStore: no MCP client");const r=this.threads.get();this.threads.update(s=>ee(s,{...a,id:e,updated_at:new Date().toISOString()}));try{if((await this.client.callTool({name:"COLLECTION_THREADS_UPDATE",arguments:{id:e,data:a}})).isError)throw new Error("COLLECTION_THREADS_UPDATE failed")}catch(s){throw this.threads.set(r),s}}async optimisticHide(e){if(!this.client)throw new Error("ThreadManagerStore: no MCP client");const a=this.threads.get();this.archivedTombstones.set(e,Date.now()),this.threads.update(r=>r.filter(s=>s.id!==e));try{if((await this.client.callTool({name:"COLLECTION_THREADS_UPDATE",arguments:{id:e,data:{hidden:!0}}})).isError)throw new Error("COLLECTION_THREADS_UPDATE failed")}catch(r){throw this.threads.set(a),this.archivedTombstones.delete(e),r}}pruneArchivedTombstones(){if(this.archivedTombstones.size===0)return;const e=Date.now()-zr;for(const[a,r]of this.archivedTombstones)r<e&&this.archivedTombstones.delete(a)}isTombstoned(e){return this.pruneArchivedTombstones(),this.archivedTombstones.has(e)}async loadInitialPage(){const e=++this.loadGeneration;if(!this.client){this.drainEventBuffer();return}try{const a=await this.client.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:this.pageSize,offset:0,orderBy:[{field:["updated_at"],direction:"desc"}],where:{hidden:!1,...this.scopeWhere}}});if(e!==this.loadGeneration)return;if(a.isError)throw new Error(ae(a,"COLLECTION_THREADS_LIST failed"));const r=a.structuredContent??a,s=r.items??[];this.threads.set(s),this.hasMore.set(r.hasMore??!1),this.nextOffset=s.length,this.threadsStatus.set({kind:"ready"}),this.drainEventBuffer()}catch(a){if(e!==this.loadGeneration)return;this.threadsStatus.set({kind:"error",error:a instanceof Error?a:new Error(String(a))}),this.drainEventBuffer()}}setScope(e){const a=JSON.stringify(e);a!==this.scopeKey&&(this.scopeKey=a,this.scopeWhere=e,this.nextOffset=0,this.loadInitialPage())}drainEventBuffer(){const e=this.eventBuffer??[];this.eventBuffer=null;for(const a of e)this.isTombstoned(a.id)||this.threads.update(r=>ee(r,a))}async fetchNextPage(){if(!this.client||!this.hasMore.get()||this.isFetchingMore.get())return;this.isFetchingMore.set(!0);const e=this.loadGeneration;try{const a=await this.client.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:this.pageSize,offset:this.nextOffset,orderBy:[{field:["updated_at"],direction:"desc"}],where:{hidden:!1,...this.scopeWhere}}});if(e!==this.loadGeneration)return;if(a.isError)throw new Error(ae(a,"COLLECTION_THREADS_LIST failed"));const r=a.structuredContent??a,s=r.items??[];this.threads.update(o=>{const i=new Set(o.map(n=>n.id));return[...o,...s.filter(n=>!i.has(n.id))]}),this.hasMore.set(r.hasMore??!1),this.nextOffset+=s.length}catch(a){const r=a instanceof Error?a.message:String(a);ge.error(`Could not load more chats: ${r}`)}finally{this.isFetchingMore.set(!1)}}async fetchThread(e){if(!e)return null;const a=this.threads.get().find(r=>r.id===e);return a||this.getThreadRemote(e)}async getThreadRemote(e){if(!e||!this.client)return null;try{const a=await this.client.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:e}});return a.isError?null:(a.structuredContent??a).item??null}catch{return null}}async refreshThreadMetadata(e){if(!(!e||!this.client)&&this.threads.get().some(a=>a.id===e))try{const a=await this.client.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:e}});if(a.isError)return;const s=(a.structuredContent??a).item;if(!s)return;this.patchThread({id:s.id,metadata:s.metadata,virtual_mcp_id:s.virtual_mcp_id,branch:s.branch,updated_at:s.updated_at})}catch{}}async fetchThreadIntoSlot(e){const a=await this.getThreadRemote(e);return a&&!a.hidden&&!this.isTombstoned(a.id)&&this.threads.update(r=>Jr(r,a)),a??this.threads.get().find(r=>r.id===e)??null}handleWatchEvent(e){if(e.type!==ve.THREAD_STATUS)return;let a;try{a=JSON.parse(e.data)}catch{return}if(this.isTombstoned(a.subject))return;const r={id:a.subject,updated_at:a.data.updated_at??a.time,...a.data.status!==void 0&&{status:a.data.status},...a.data.created_by!==void 0&&{created_by:a.data.created_by},...a.data.trigger_id!==void 0&&{trigger_id:a.data.trigger_id},...a.data.virtual_mcp_id!==void 0&&{virtual_mcp_id:a.data.virtual_mcp_id},...a.data.title!==void 0&&{title:a.data.title},...a.data.branch!==void 0&&{branch:a.data.branch},...a.data.harness_id!==void 0&&{harness_id:a.data.harness_id},...a.data.created_at!==void 0&&{created_at:a.data.created_at},...a.data.metadata!==void 0&&{metadata:a.data.metadata}};if(this.eventBuffer!==null){this.eventBuffer.push(r);return}this.threads.update(s=>ee(s,r))}onWatchReconnect(){this.eventBuffer=[],this.loadInitialPage()}}let $=null;function Wr(t,e,a={}){const r=`${t}::${e}`;return $&&$.key===r||($?.dispose(),$=new Hr(t,e,a)),$}function as(t,e){const a=`${t}::${e}`;return $&&$.key===a?$:null}const Me=W.createContext(null);function rs(t){const e=Te.c(10),{children:a}=t,{org:r,locator:s}=Rt();let o;e[0]!==r.id||e[1]!==r.slug?(o={connectionId:xt,orgId:r.id,orgSlug:r.slug},e[0]=r.id,e[1]=r.slug,e[2]=o):o=e[2];const i=Pt(o);let n;e[3]!==i||e[4]!==s||e[5]!==r.slug?(n=Wr(r.slug,s,{client:i}),e[3]=i,e[4]=s,e[5]=r.slug,e[6]=n):n=e[6];const p=n;let u;return e[7]!==a||e[8]!==p?(u=Nt.jsx(Me.Provider,{value:p,children:a}),e[7]=a,e[8]=p,e[9]=u):u=e[9],u}function _t(){const t=W.useContext(Me);if(!t)throw new Error("useThreadManager: missing ThreadManagerProvider");return t}function ss(){return W.useContext(Me)}function ns(){const t=Te.c(8),e=_t(),a=W.useSyncExternalStore(e.threads.subscribe,e.threads.get),r=W.useSyncExternalStore(e.threadsStatus.subscribe,e.threadsStatus.get),s=W.useSyncExternalStore(e.hasMore.subscribe,e.hasMore.get),o=W.useSyncExternalStore(e.isFetchingMore.subscribe,e.isFetchingMore.get);let i;t[0]!==e?(i=e.fetchNextPage.bind(e),t[0]=e,t[1]=i):i=t[1];let n;return t[2]!==s||t[3]!==o||t[4]!==r||t[5]!==i||t[6]!==a?(n={threads:a,status:r,hasMore:s,isFetchingMore:o,fetchNextPage:i},t[2]=s,t[3]=o,t[4]=r,t[5]=i,t[6]=a,t[7]=n):n=t[7],n}function os(){const t=Te.c(28),e=_t();let a;t[0]!==e?(a=e.create.bind(e),t[0]=e,t[1]=a):a=t[1];let r;t[2]!==e?(r=e.rename.bind(e),t[2]=e,t[3]=r):r=t[3];let s;t[4]!==e?(s=e.hide.bind(e),t[4]=e,t[5]=s):s=t[5];let o;t[6]!==e?(o=e.setStatus.bind(e),t[6]=e,t[7]=o):o=t[7];let i;t[8]!==e?(i=e.setBranch.bind(e),t[8]=e,t[9]=i):i=t[9];let n;t[10]!==e?(n=e.setAgent.bind(e),t[10]=e,t[11]=n):n=t[11];let p;t[12]!==e?(p=e.setScope.bind(e),t[12]=e,t[13]=p):p=t[13];let u;t[14]!==e?(u=e.setActive.bind(e),t[14]=e,t[15]=u):u=t[15];let d;t[16]!==e?(d=e.closeActive.bind(e),t[16]=e,t[17]=d):d=t[17];let f;return t[18]!==a||t[19]!==r||t[20]!==s||t[21]!==o||t[22]!==i||t[23]!==n||t[24]!==p||t[25]!==u||t[26]!==d?(f={create:a,rename:r,hide:s,setStatus:o,setBranch:i,setAgent:n,setScope:p,setActive:u,closeActive:d},t[18]=a,t[19]=r,t[20]=s,t[21]=o,t[22]=i,t[23]=n,t[24]=p,t[25]=u,t[26]=d,t[27]=f):f=t[27],f}export{L as S,rs as T,ns as a,os as b,ss as c,es as d,br as e,Fr as f,as as g,Vr as i,cr as r,ts as s,Kr as t,_t as u,ot as z};