decocms 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/dist/client/assets/{AlertCircle-HztvGgEK.js → AlertCircle-DC-zDzV-.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-CD45Pqa3.js → ArrowUpRight-OJZisFPQ.js} +1 -1
  3. package/dist/client/assets/{CheckCircle-B93tZkib.js → CheckCircle-Cgnheu-R.js} +1 -1
  4. package/dist/client/assets/{ChevronDown-BHp2n33E.js → ChevronDown-DyHvxYlc.js} +1 -1
  5. package/dist/client/assets/{ChevronLeft-CkLGnzyI.js → ChevronLeft-dyRjFCmp.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-HkVZWjVD.js → ChevronRight-Cpfh3gza.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-DLoyITzq.js → ChevronUp-DBpw6M-L.js} +1 -1
  8. package/dist/client/assets/{DotsVertical-DBVnta3o.js → DotsVertical-5jSu3d1f.js} +1 -1
  9. package/dist/client/assets/{Eye-BuXBYPNx.js → Eye-bojNLUjA.js} +1 -1
  10. package/dist/client/assets/{FilterLines-JdWf41nd.js → FilterLines-CFl65nng.js} +1 -1
  11. package/dist/client/assets/{Globe01-DbyYsbkQ.js → Globe01-CyfpzbeQ.js} +1 -1
  12. package/dist/client/assets/{Globe04-ht6-fzwU.js → Globe04-DFpdKSRI.js} +1 -1
  13. package/dist/client/assets/{HardDrive-QsbiOkra.js → HardDrive-B1mtnaeA.js} +1 -1
  14. package/dist/client/assets/{Key01-B-rzooWI.js → Key01-CwrJlZo0.js} +1 -1
  15. package/dist/client/assets/{LayoutLeft-CvZZnjM_.js → LayoutLeft-fsm0LcB8.js} +1 -1
  16. package/dist/client/assets/{LinkExternal01-C75h4nTA.js → LinkExternal01-BHwVyDja.js} +1 -1
  17. package/dist/client/assets/{Monitor01-C751a6VH.js → Monitor01-ChA6ov2I.js} +1 -1
  18. package/dist/client/assets/{Palette-Cw4TmFXF.js → Palette-DusYqL0W.js} +1 -1
  19. package/dist/client/assets/{Play-BaPiITj6.js → Play-CnXG8qqP.js} +1 -1
  20. package/dist/client/assets/{Plus-cqzweyhV.js → Plus-eGxBB1d8.js} +1 -1
  21. package/dist/client/assets/{SearchLg-BgcbIGrG.js → SearchLg-CDpA_lbT.js} +1 -1
  22. package/dist/client/assets/{SearchMd-B_E38g9S.js → SearchMd-ujiTPCmg.js} +1 -1
  23. package/dist/client/assets/{Settings02-HJQMPAnK.js → Settings02-BcAnTzm5.js} +1 -1
  24. package/dist/client/assets/{Shield01-CYOeouzJ.js → Shield01-ZxmFmrvL.js} +1 -1
  25. package/dist/client/assets/{Star01-BLuwEqBm.js → Star01-DHEkWySe.js} +1 -1
  26. package/dist/client/assets/{Stars01-bmKEIBXR.js → Stars01-BdCaKqhF.js} +1 -1
  27. package/dist/client/assets/{Stars02-CO1akjaP.js → Stars02-qnq-_X9g.js} +1 -1
  28. package/dist/client/assets/{Sun-DGf33qzc.js → Sun-lTiqxOzH.js} +1 -1
  29. package/dist/client/assets/{SwitchHorizontal01-CtPAye2M.js → SwitchHorizontal01-DAZXInW8.js} +1 -1
  30. package/dist/client/assets/{Tool01-Dc5WA1H4.js → Tool01-CvnpFI53.js} +1 -1
  31. package/dist/client/assets/{Trash01-Dn19EDIc.js → Trash01-ByxlxTiZ.js} +1 -1
  32. package/dist/client/assets/{Upload01-AmIm4zQN.js → Upload01-Z77n1bV8.js} +1 -1
  33. package/dist/client/assets/{User01-CYnD1B0h.js → User01-COQtf360.js} +1 -1
  34. package/dist/client/assets/{Users01-B3f8K1I8.js → Users01-wtRJYQKX.js} +1 -1
  35. package/dist/client/assets/{Users03-B7auzTEh.js → Users03-DknrDMtT.js} +1 -1
  36. package/dist/client/assets/{X-BJ5AK9_B.js → X-DrMVHLcw.js} +1 -1
  37. package/dist/client/assets/{XCircle-BEhXc7sQ.js → XCircle-Ct0eqqsw.js} +1 -1
  38. package/dist/client/assets/{XClose-BaODJMh0.js → XClose-BaZ908gw.js} +1 -1
  39. package/dist/client/assets/{Zap-CDSogr5w.js → Zap-wRIFSWIq.js} +1 -1
  40. package/dist/client/assets/{ZapSquare-CmmJkOPb.js → ZapSquare-PMiGcZpW.js} +1 -1
  41. package/dist/client/assets/{ZoomOut-9WiOjKDc.js → ZoomOut-6ix2H92j.js} +1 -1
  42. package/dist/client/assets/{access-gate-Bwf2CoM1.js → access-gate-D6dGDGRI.js} +1 -1
  43. package/dist/client/assets/{add-section-modal-CmQEBOgZ.js → add-section-modal-DOhGqRCL.js} +1 -1
  44. package/dist/client/assets/{agent-icon-Ba-0ZYgG.js → agent-icon-oDx9Z_Be.js} +1 -1
  45. package/dist/client/assets/{agents-list-D5VkOHIG.js → agents-list-BgSM_QG_.js} +1 -1
  46. package/dist/client/assets/{ai-providers-CZ5SMOKO.js → ai-providers-Crp7kidL.js} +1 -1
  47. package/dist/client/assets/{alert-nxT5lZho.js → alert-CKj_5smu.js} +1 -1
  48. package/dist/client/assets/{alert-dialog-Bqe6OAIL.js → alert-dialog-CYizItFp.js} +2 -2
  49. package/dist/client/assets/app-editor-Xoia35dq.js +1 -0
  50. package/dist/client/assets/{auth-CqOhN4mO.js → auth-Bej0Tx2Y.js} +1 -1
  51. package/dist/client/assets/{auth-catchall-CNFrjBAq.js → auth-catchall-CmNVpp-8.js} +1 -1
  52. package/dist/client/assets/{auth-entry-DPV3aDXY.js → auth-entry-PwLVm-jX.js} +1 -1
  53. package/dist/client/assets/{auth-split-layout-Dp0-2xO6.js → auth-split-layout-5YwPgbAb.js} +1 -1
  54. package/dist/client/assets/{authenticate-and-persist-oauth-BkWGH7gY.js → authenticate-and-persist-oauth-DoPUB_Bh.js} +1 -1
  55. package/dist/client/assets/{automation-list-row-CjVzmIPj.js → automation-list-row-CsTyBm4M.js} +1 -1
  56. package/dist/client/assets/{automation-runs-DIDLqvYF.js → automation-runs-B-dNDEWH.js} +1 -1
  57. package/dist/client/assets/{automations-DEtrS6hH.js → automations-D395202A.js} +1 -1
  58. package/dist/client/assets/{avatar-DUFWGs9Z.js → avatar-CJP1BOq4.js} +1 -1
  59. package/dist/client/assets/{badge-ULvYE549.js → badge-DhpSM7g_.js} +1 -1
  60. package/dist/client/assets/{block-document-Cl3urvMb.js → block-document-B2vhG8Ii.js} +1 -1
  61. package/dist/client/assets/{brand-context-DU7I0d5o.js → brand-context-BRpHgxfT.js} +1 -1
  62. package/dist/client/assets/{buckets-4u7bKclV.js → buckets-DDR0G33f.js} +1 -1
  63. package/dist/client/assets/{bulk-category-panel-Bqpqm_Qj.js → bulk-category-panel-CM1bMunr.js} +1 -1
  64. package/dist/client/assets/{capability-load-error-Xikv63T6.js → capability-load-error-CCgNL5xi.js} +1 -1
  65. package/dist/client/assets/{card-DuZccs_2.js → card-BFb5m83e.js} +1 -1
  66. package/dist/client/assets/category-editor-2T4Y_ABL.js +1 -0
  67. package/dist/client/assets/{chat-context-Ba1J4Wbr.js → chat-context-n9syhvq-.js} +4 -4
  68. package/dist/client/assets/{checkbox-CZumSc8B.js → checkbox-DmOzmKLP.js} +1 -1
  69. package/dist/client/assets/{cli-auth-success-Ca86Sm5z.js → cli-auth-success-BVPtMYcv.js} +1 -1
  70. package/dist/client/assets/{collection-detail-2DizOat2.js → collection-detail-BQKV3UU7.js} +1 -1
  71. package/dist/client/assets/{collection-display-button-DTaFqStv.js → collection-display-button-Bf9dlJRy.js} +1 -1
  72. package/dist/client/assets/{collection-search-D2jsOcE8.js → collection-search-8iNXnGlM.js} +1 -1
  73. package/dist/client/assets/{collection-tabs-BlI5WHJs.js → collection-tabs-KA2be3wH.js} +1 -1
  74. package/dist/client/assets/{command-ClUS1KMM.js → command-C34397s2.js} +1 -1
  75. package/dist/client/assets/{commerce-onboarding-C9kK24Mf.js → commerce-onboarding-D2H83R0U.js} +1 -1
  76. package/dist/client/assets/{connect-desktop-dialog-DPJKYCn-.js → connect-desktop-dialog-Brra3cMC.js} +1 -1
  77. package/dist/client/assets/{connection-card-CEtBve6r.js → connection-card-C6NYo4Gp.js} +1 -1
  78. package/dist/client/assets/{connection-detail-dUoqAHFY.js → connection-detail-gJ5ITUXe.js} +1 -1
  79. package/dist/client/assets/{connection-form-helpers-DtWH2w6r.js → connection-form-helpers-CwZx7WkC.js} +1 -1
  80. package/dist/client/assets/{connections-SZjaegFI.js → connections-CicrEJbU.js} +1 -1
  81. package/dist/client/assets/{context-menu-VSlW1NY7.js → context-menu-BW_OZBmV.js} +1 -1
  82. package/dist/client/assets/{decopilot-Y0nnLngo.js → decopilot-BItqS11w.js} +1 -1
  83. package/dist/client/assets/{decopilot-sse-pool-BR9ewfWR.js → decopilot-sse-pool-CvYk1hkc.js} +1 -1
  84. package/dist/client/assets/{dialog-onqVrhoh.js → dialog-BAqFyO8a.js} +1 -1
  85. package/dist/client/assets/{domain-settings-D6CfPi24.js → domain-settings-r_E3rHsG.js} +1 -1
  86. package/dist/client/assets/{drawer-D6-83PZ_.js → drawer-CFkqEC3w.js} +1 -1
  87. package/dist/client/assets/{dropdown-menu-D9g8Sl4X.js → dropdown-menu-C62KNjwK.js} +1 -1
  88. package/dist/client/assets/{empty-state-0bsCiepl.js → empty-state-Sh_DuDcy.js} +1 -1
  89. package/dist/client/assets/{extract-connection-data-Dk45baha.js → extract-connection-data-D6bQrejT.js} +1 -1
  90. package/dist/client/assets/file-explorer-C8pgfKCz.js +2 -0
  91. package/dist/client/assets/{file-type-icon-B1XEm_9k.js → file-type-icon-DPWxBpNL.js} +1 -1
  92. package/dist/client/assets/{files-BvKHt3eY.js → files-B9ekmQa_.js} +1 -1
  93. package/dist/client/assets/{form-Dvd73W2C.js → form-DGE2mWLL.js} +1 -1
  94. package/dist/client/assets/{general-DrBGUycq.js → general-BMDKtyZB.js} +1 -1
  95. package/dist/client/assets/{github-repo-picker-CB-ypGEp.js → github-repo-picker-B5tZucJa.js} +1 -1
  96. package/dist/client/assets/{hooks-tDbCB3C5.js → hooks-CUSV6Enf.js} +1 -1
  97. package/dist/client/assets/{import-from-deco-dialog-wTIFbH1Y.js → import-from-deco-dialog-M3CP3Gmn.js} +1 -1
  98. package/dist/client/assets/index-B2yJy2sB.js +1 -0
  99. package/dist/client/assets/{index-1nPke5TY.js → index-B6hcksS9.js} +1 -1
  100. package/dist/client/assets/{index-DrUwfEHA.js → index-Bb-tYGNK.js} +1 -1
  101. package/dist/client/assets/index-BqKQnks_.css +1 -0
  102. package/dist/client/assets/{index-DmjWDqcd.js → index-CFiyU0D9.js} +3 -3
  103. package/dist/client/assets/index-CRxAjd1d.js +513 -0
  104. package/dist/client/assets/{index-DkjetCaY.js → index-CkTyYAY1.js} +1 -1
  105. package/dist/client/assets/{index-BFlpjafk.js → index-DGzNvPy2.js} +1 -1
  106. package/dist/client/assets/{index-D3WaYPH4.js → index-DIBoN36v.js} +1 -1
  107. package/dist/client/assets/{index-BTZwvNmT.js → index-DQnTjiix.js} +1 -1
  108. package/dist/client/assets/{index-DeiWC-uz.js → index-D_S_Rq8A.js} +1 -1
  109. package/dist/client/assets/{index-Ftnw_1Xy.js → index-Dj7TxcSd.js} +1 -1
  110. package/dist/client/assets/{index-B_kMLuGG.js → index-hmJjUPum.js} +1 -1
  111. package/dist/client/assets/{index--njjOK24.js → index-jBUpmiBg.js} +1 -1
  112. package/dist/client/assets/{index-D3mRtkEB.js → index-mEtg0zTM.js} +1 -1
  113. package/dist/client/assets/{index-redirect-B6SIDrdt.js → index-redirect-C9Kkmz45.js} +1 -1
  114. package/dist/client/assets/{input-BlaLo4Ee.js → input-BwRH-Gsz.js} +1 -1
  115. package/dist/client/assets/{integration-icon-BF4ETuj8.js → integration-icon-LQhkkaLl.js} +1 -1
  116. package/dist/client/assets/{label-GEC2UjFS.js → label-CdBSUJpf.js} +1 -1
  117. package/dist/client/assets/{login-DiR83Uim.js → login-d0UWtw9N.js} +1 -1
  118. package/dist/client/assets/{mcp-oauth-sGspCuYg.js → mcp-oauth-IblqU9XT.js} +1 -1
  119. package/dist/client/assets/{members-BDtCBiR9.js → members-Bpdrl2e9.js} +1 -1
  120. package/dist/client/assets/{monaco-editor-BKh1966p.js → monaco-editor-5JIc-lnc.js} +1 -1
  121. package/dist/client/assets/{monitoring-stats-row-Bdo8nd6T.js → monitoring-stats-row-DPsQ-OAn.js} +1 -1
  122. package/dist/client/assets/{oauth-callback-BexQI-2W.js → oauth-callback-B1AvYYRn.js} +1 -1
  123. package/dist/client/assets/{oauth-callback-ai-provider-1VSCaYAB.js → oauth-callback-ai-provider-BtGHmjpp.js} +1 -1
  124. package/dist/client/assets/{onboarding-CZfsqsuP.js → onboarding-DfUmI7F5.js} +1 -1
  125. package/dist/client/assets/{org-install-BCHSGKR9.js → org-install-CpJAFt1s.js} +1 -1
  126. package/dist/client/assets/{org-layout-D5zV7CtT.js → org-layout-BsuFzdH_.js} +1 -1
  127. package/dist/client/assets/{organization-choice-B_qzGE3r.js → organization-choice-DrxWffZp.js} +1 -1
  128. package/dist/client/assets/{page-seo-form-Cg3EP0Kg.js → page-seo-form-BLqpZnj6.js} +1 -1
  129. package/dist/client/assets/page-seo-sheet-C7jjKuEW.js +1 -0
  130. package/dist/client/assets/{popover-BxWSrnHV.js → popover-BXFiEQtN.js} +1 -1
  131. package/dist/client/assets/post-editor-Tve7DmSa.js +1 -0
  132. package/dist/client/assets/{preview-dialog-B6mTIXuI.js → preview-dialog-CQgf0QcR.js} +2 -2
  133. package/dist/client/assets/{primitives-DikyHxBV.js → primitives-BF1opf4F.js} +1 -1
  134. package/dist/client/assets/{profile-CR2pTbhO.js → profile-C8meo3ry.js} +1 -1
  135. package/dist/client/assets/project-app-view-BR2-hR46.js +1 -0
  136. package/dist/client/assets/record-editor-DbXO7U7E.js +1 -0
  137. package/dist/client/assets/registry-jjhvqeDq.js +2 -0
  138. package/dist/client/assets/{registry-layout-BQTxWcaj.js → registry-layout-C4UMhzml.js} +1 -1
  139. package/dist/client/assets/{require-capability-B1UdIHXr.js → require-capability--mIKExbX.js} +1 -1
  140. package/dist/client/assets/{required-auth-layout-CykGSzYq.js → required-auth-layout-DDJmFi3U.js} +1 -1
  141. package/dist/client/assets/{reset-password-BKTSF6vw.js → reset-password-CuNa1ife.js} +1 -1
  142. package/dist/client/assets/{roles-tVsESxlL.js → roles-BMhGnq_F.js} +1 -1
  143. package/dist/client/assets/{scroll-area-B8CDvPWi.js → scroll-area-BM-54tW1.js} +1 -1
  144. package/dist/client/assets/{search-input-L82tU3Bd.js → search-input-M7ubuBMG.js} +1 -1
  145. package/dist/client/assets/{secrets-BPwXng2k.js → secrets-BN1JMG5V.js} +1 -1
  146. package/dist/client/assets/{sections-editor-CuKTooG7.js → sections-editor-Buouhx1S.js} +2 -2
  147. package/dist/client/assets/{select-ySr8WoR1.js → select-C6v8Xcth.js} +1 -1
  148. package/dist/client/assets/{select-model-DdjL4UVJ.js → select-model-Cz9R_UN3.js} +1 -1
  149. package/dist/client/assets/seo-editor-D9o3utSQ.js +1 -0
  150. package/dist/client/assets/{settings-layout-BBsWbAB4.js → settings-layout-CSaUQUXv.js} +1 -1
  151. package/dist/client/assets/{settings-section-ysOtzM09.js → settings-section-MeT61nuY.js} +1 -1
  152. package/dist/client/assets/{sheet-X3VztLnq.js → sheet-DyU03ddw.js} +1 -1
  153. package/dist/client/assets/{shell-controls-DTY4r0Sw.js → shell-controls-DtGb6E4l.js} +1 -1
  154. package/dist/client/assets/{shell-layout-CdseotG7.js → shell-layout-Nyz7GHu7.js} +1 -1
  155. package/dist/client/assets/{shell-route-loading-DNSXVK6N.js → shell-route-loading-BRcTX0VT.js} +1 -1
  156. package/dist/client/assets/{sidebar-H8VlLCcE.js → sidebar-BNrafefE.js} +1 -1
  157. package/dist/client/assets/{skeleton-DknPHMRJ.js → skeleton-B0I93PJP.js} +1 -1
  158. package/dist/client/assets/{sortable.esm-Ctxa79RM.js → sortable.esm-MymOIPKk.js} +1 -1
  159. package/dist/client/assets/{sso-WkG_Ya3-.js → sso-CfyYgWAs.js} +1 -1
  160. package/dist/client/assets/{store-BisoAFLO.js → store-T7GJ1SPI.js} +1 -1
  161. package/dist/client/assets/store-registry-B-YJeGRV.js +2 -0
  162. package/dist/client/assets/{studio-tools-BWRE75AX.js → studio-tools-CNO5iCKk.js} +1 -1
  163. package/dist/client/assets/{switch-DR4CkZQD.js → switch-CCMIMmOF.js} +1 -1
  164. package/dist/client/assets/{table-C4Cy5HHY.js → table-DeNuxLMl.js} +1 -1
  165. package/dist/client/assets/{tabs-C77-FnFK.js → tabs-Ca0vDJqc.js} +1 -1
  166. package/dist/client/assets/{task-status-DIimAguz.js → task-status-B3nPzwP7.js} +1 -1
  167. package/dist/client/assets/{textarea-DzC7ppsf.js → textarea-BYT525JZ.js} +1 -1
  168. package/dist/client/assets/{toggle-group-DUz2fIQy.js → toggle-group-9TrYMc69.js} +1 -1
  169. package/dist/client/assets/toolbar-p8VcpV1N.js +1 -0
  170. package/dist/client/assets/{tools-list-CTCIGteU.js → tools-list-uWC3Ij6C.js} +1 -1
  171. package/dist/client/assets/{tooltip-Cr9AJTu1.js → tooltip-DrpiSbRG.js} +1 -1
  172. package/dist/client/assets/{types-DIYYFrZY.js → types-C7syjwde.js} +4 -4
  173. package/dist/client/assets/{use-ai-providers-DnoPML_E.js → use-ai-providers-C7KmiuqP.js} +1 -1
  174. package/dist/client/assets/{use-automations-B4dRXrYb.js → use-automations-RMjkwkxX.js} +1 -1
  175. package/dist/client/assets/{use-capability-CDOjpxJe.js → use-capability-C6Dwri-U.js} +1 -1
  176. package/dist/client/assets/{use-clock-tick-DfB4yM8e.js → use-clock-tick-BcxdOJLx.js} +1 -1
  177. package/dist/client/assets/{use-collections-C6o5d0Mn.js → use-collections-B4atckEK.js} +1 -1
  178. package/dist/client/assets/{use-connection-RPVug9uL.js → use-connection-Dz29RF9P.js} +1 -1
  179. package/dist/client/assets/{use-copy-DByELpSB.js → use-copy-Xy0buIqd.js} +1 -1
  180. package/dist/client/assets/{use-create-virtual-mcp-DYyOoMN3.js → use-create-virtual-mcp-DVmI--_C.js} +1 -1
  181. package/dist/client/assets/{use-debounced-autosave-D9laFBFB.js → use-debounced-autosave-B4mbwJnu.js} +1 -1
  182. package/dist/client/assets/{use-debounced-value-Bs78etny.js → use-debounced-value-C6U3mliE.js} +1 -1
  183. package/dist/client/assets/{use-decopilot-events-DavYF-aF.js → use-decopilot-events-CpQNzv3e.js} +1 -1
  184. package/dist/client/assets/{use-delete-connection-9x3-oXog.js → use-delete-connection-CqeuxO_6.js} +1 -1
  185. package/dist/client/assets/{use-file-configs-YQp2GWKp.js → use-file-configs-CFCmr--W.js} +1 -1
  186. package/dist/client/assets/{use-infinite-scroll-BmnUwDlC.js → use-infinite-scroll-BX1nHHVY.js} +1 -1
  187. package/dist/client/assets/{use-join-requests-wdTUrAXP.js → use-join-requests-j9WpmFq7.js} +1 -1
  188. package/dist/client/assets/{use-mcp-client-NDJy9UEP.js → use-mcp-client-xOK-OF8p.js} +2 -2
  189. package/dist/client/assets/{use-mcp-prompts-ziW0oQXD.js → use-mcp-prompts-Crr3H7P7.js} +1 -1
  190. package/dist/client/assets/{use-mcp-tools-ByN1fg_5.js → use-mcp-tools-C8tMWwG9.js} +1 -1
  191. package/dist/client/assets/{use-members-CqCv95kS.js → use-members-BMNjJExY.js} +1 -1
  192. package/dist/client/assets/{use-mobile-C1ok2Oda.js → use-mobile-NlF-3RoP.js} +1 -1
  193. package/dist/client/assets/{use-navigate-to-agent-GB89TSmS.js → use-navigate-to-agent-DZubxUSm.js} +1 -1
  194. package/dist/client/assets/{use-org-auth-client-a0tV0I4a.js → use-org-auth-client-C_UJ3Vg_.js} +1 -1
  195. package/dist/client/assets/{use-org-fs-C4An_fXX.js → use-org-fs-DyK8omii.js} +1 -1
  196. package/dist/client/assets/{use-org-sso-DXOaOrbn.js → use-org-sso-DkqH8Zpz.js} +1 -1
  197. package/dist/client/assets/{use-organization-roles-CsUVzen8.js → use-organization-roles-Cu69Rnex.js} +1 -1
  198. package/dist/client/assets/{use-organization-settings-rqcqUUeR.js → use-organization-settings-DksiQdGc.js} +1 -1
  199. package/dist/client/assets/{use-registry-connections-BHtQ89zr.js → use-registry-connections-BOZLpkM5.js} +1 -1
  200. package/dist/client/assets/{use-secrets-CQoqzufN.js → use-secrets-CLmhH-Rb.js} +1 -1
  201. package/dist/client/assets/{use-status-sounds-yeVUNOcg.js → use-status-sounds-DxV7deix.js} +1 -1
  202. package/dist/client/assets/{use-view-mode-D7GDuIV9.js → use-view-mode-C2dllj6L.js} +1 -1
  203. package/dist/client/assets/{use-virtual-mcp-DQxIBquV.js → use-virtual-mcp-2U_MnYnK.js} +1 -1
  204. package/dist/client/assets/useInfiniteQuery-RUqqRph1.js +1 -0
  205. package/dist/client/assets/useSuspenseInfiniteQuery-fRYRtDkY.js +1 -0
  206. package/dist/client/assets/{useSuspenseQueries-DM2UC-1d.js → useSuspenseQueries-Cysvk68n.js} +1 -1
  207. package/dist/client/assets/{variant-calendar-Dkf9XIru.js → variant-calendar-mZn_D1Zo.js} +1 -1
  208. package/dist/client/assets/{view-mode-toggle-1VKSbXaL.js → view-mode-toggle-4CQodGfa.js} +1 -1
  209. package/dist/client/index.html +2 -2
  210. package/dist/server/cli.js +1 -1
  211. package/package.json +1 -1
  212. package/dist/client/assets/app-editor-Cfln2sHr.js +0 -1
  213. package/dist/client/assets/category-editor-BT4Cxoo3.js +0 -1
  214. package/dist/client/assets/file-explorer-BtYpNmrX.js +0 -2
  215. package/dist/client/assets/index-1MQY-aKx.css +0 -1
  216. package/dist/client/assets/index-DL5xoOQh.js +0 -513
  217. package/dist/client/assets/index-PHpiDror.js +0 -1
  218. package/dist/client/assets/page-seo-sheet-fP6EiExR.js +0 -1
  219. package/dist/client/assets/post-editor-CpIwB3m_.js +0 -1
  220. package/dist/client/assets/project-app-view-AkqKN49v.js +0 -1
  221. package/dist/client/assets/record-editor-Dm0nCNn9.js +0 -1
  222. package/dist/client/assets/registry-DhcyXlrd.js +0 -2
  223. package/dist/client/assets/seo-editor-BXwxtymi.js +0 -1
  224. package/dist/client/assets/store-registry-DKSrdFtG.js +0 -2
  225. package/dist/client/assets/toolbar-1nBak56S.js +0 -1
  226. package/dist/client/assets/useInfiniteQuery-BiSAb_zK.js +0 -1
  227. package/dist/client/assets/useSuspenseInfiniteQuery-9J-jWStM.js +0 -1
@@ -1,4 +1,4 @@
1
- import{cZ as de,c_ as he,c$ as fe,ce as pe,d0 as me,bV as m,bW as w,d1 as _e,d2 as ge,d3 as we,d4 as $,d5 as Te,d6 as j,d7 as ye,d8 as q,d9 as ve,da as F,db as ke,dc as Se,dd as Ce,de as Q,bA as Re,bC as be,bh as Ie,c9 as te,cl as Ee,cr as qe,cp as Pe,cN as Ae,df as $e,dg as Me,dh as M,di as Oe,dj as He,cq as Ne,cm as xe,cn as De,co as Ue,bx as je,dk as Fe,dl as Le,dm as Ve,cg as We,dn as ze,dp as Qe,dq as Ge,bw as x,c as se,q as re,aK as V}from"./index-DmjWDqcd.js";import{U as P,a as O,e as G}from"./auth-CqOhN4mO.js";function N(o){return!!o._zod}function R(o,e){return N(o)?de(o,e):o.safeParse(e)}function oe(o){if(!o)return;let e;if(N(o)?e=o._zod?.def?.shape:e=o.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Je(o){if(N(o)){const a=o._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const t=o._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=o.value;if(s!==void 0)return s}function b(o){return o==="completed"||o==="failed"||o==="cancelled"}function J(o){const t=oe(o)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=Je(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function K(o,e){const t=R(o,e);if(!t.success)throw t.error;return t.data}const Ke=6e4;class Ye{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(he,t=>{this._oncancel(t)}),this.setNotificationHandler(fe,t=>{this._onprogress(t)}),this.setRequestHandler(pe,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(me,async(t,s)=>{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new m(w.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(_e,async(t,s)=>{const r=async()=>{const a=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(a,s.sessionId);){if(i.type==="response"||i.type==="error"){const u=i.message,p=u.id,l=this._requestResolvers.get(p);if(l)if(this._requestResolvers.delete(p),i.type==="response")l(u);else{const h=u,f=new m(h.error.code,h.error.message,h.error.data);l(f)}else{const h=i.type==="response"?"Response":"Error";this._onerror(new Error(`${h} handler missing for request ${p}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(a,s.sessionId);if(!n)throw new m(w.InvalidParams,`Task not found: ${a}`);if(!b(n.status))return await this._waitForTaskUpdate(a,s.signal),await r();if(b(n.status)){const i=await this._taskStore.getTaskResult(a,s.sessionId);return this._clearTaskQueue(a),{...i,_meta:{...i._meta,[q]:{taskId:a}}}}return await r()};return await r()}),this.setRequestHandler(ge,async(t,s)=>{try{const{tasks:r,nextCursor:a}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:r,nextCursor:a,_meta:{}}}catch(r){throw new m(w.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(we,async(t,s)=>{try{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new m(w.InvalidParams,`Task not found: ${t.params.taskId}`);if(b(r.status))throw new m(w.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const a=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!a)throw new m(w.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...a}}catch(r){throw r instanceof m?r:new m(w.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,r,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:a,onTimeout:r})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),m.fromError(w.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=a=>{s?.(a),this._onerror(a)};const r=this._transport?.onmessage;this._transport.onmessage=(a,n)=>{r?.(a,n),$(a)||Te(a)?this._onresponse(a):j(a)?this._onrequest(a,n):ye(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=m.fromError(w.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,a=e.params?._meta?.[q]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:w.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):r?.send(l).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=ve(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,p={signal:n.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const h={relatedRequestId:e.id};a&&(h.relatedTask={taskId:a}),await this.notification(l,h)},sendRequest:async(l,h,f)=>{if(n.signal.aborted)throw new m(w.ConnectionClosed,"Request was cancelled");const g={...f,relatedRequestId:e.id};a&&!g.relatedTask&&(g.relatedTask={taskId:a});const y=g.relatedTask?.taskId??a;return y&&u&&await u.updateTaskStatus(y,"input_required"),await this.request(l,h,g)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:a,taskStore:u,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,p)).then(async l=>{if(n.signal.aborted)return;const h={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:h,timestamp:Date.now()},r?.sessionId):await r?.send(h)},async l=>{if(n.signal.aborted)return;const h={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:w.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:h,timestamp:Date.now()},r?.sessionId):await r?.send(h)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===n&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,r=Number(t),a=this._progressHandlers.get(r);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(u);return}a(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),$(e))s(e);else{const n=new m(e.error.code,e.error.message,e.error.data);s(n)}return}const r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let a=!1;if($(e)&&e.result&&typeof e.result=="object"){const n=e.result;if(n.task&&typeof n.task=="object"){const i=n.task;typeof i.taskId=="string"&&(a=!0,this._taskProgressTokens.set(i.taskId,t))}}if(a||this._progressHandlers.delete(t),$(e))r(e);else{const n=m.fromError(e.error.code,e.error.message,e.error.data);r(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:r}=s??{};if(!r){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof m?n:new m(w.InternalError,String(n))}}return}let a;try{const n=await this.request(e,F,s);if(n.task)a=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new m(w.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:a},s);if(yield{type:"taskStatus",task:i},b(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)}:i.status==="failed"?yield{type:"error",error:new m(w.InternalError,`Task ${a} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new m(w.InternalError,`Task ${a} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)};return}const u=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(p=>setTimeout(p,u)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof m?n:new m(w.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:r,resumptionToken:a,onresumptiontoken:n,task:i,relatedTask:u}=s??{};return new Promise((p,l)=>{const h=c=>{l(c)};if(!this._transport){h(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(c){h(c);return}s?.signal?.throwIfAborted();const f=this._requestMessageId++,g={...e,jsonrpc:"2.0",id:f};s?.onprogress&&(this._progressHandlers.set(f,s.onprogress),g.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),i&&(g.params={...g.params,task:i}),u&&(g.params={...g.params,_meta:{...g.params?._meta||{},[q]:u}});const y=c=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(c)}},{relatedRequestId:r,resumptionToken:a,onresumptiontoken:n}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));const _=c instanceof m?c:new m(w.RequestTimeout,String(c));l(_)};this._responseHandlers.set(f,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return l(c);try{const _=R(t,c.result);_.success?p(_.data):l(_.error)}catch(_){l(_)}}}),s?.signal?.addEventListener("abort",()=>{y(s?.signal?.reason)});const T=s?.timeout??Ke,v=()=>y(m.fromError(w.RequestTimeout,"Request timed out",{timeout:T}));this._setupTimeout(f,T,s?.maxTotalTimeout,v,s?.resetTimeoutOnProgress??!1);const d=u?.taskId;if(d){const c=_=>{const k=this._responseHandlers.get(f);k?k(_):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,c),this._enqueueTaskMessage(d,{type:"request",message:g,timestamp:Date.now()}).catch(_=>{this._cleanupTimeout(f),l(_)})}else this._transport.send(g,{relatedRequestId:r,resumptionToken:a,onresumptiontoken:n}).catch(c=>{this._cleanupTimeout(f),l(c)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ke,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Se,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Ce,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=t?.relatedTask?.taskId;if(s){const i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[q]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:i,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let i={...e,jsonrpc:"2.0"};t?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[q]:t.relatedTask}}}),this._transport?.send(i,t).catch(u=>this._onerror(u))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[q]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=J(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,a)=>{const n=K(e,r);return Promise.resolve(t(n,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=J(e);this._notificationHandlers.set(s,r=>{const a=K(e,r);return Promise.resolve(t(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const r of s)if(r.type==="request"&&j(r.message)){const a=r.message.id,n=this._requestResolvers.get(a);n?(n(new m(w.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(e);r?.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,a)=>{if(t.aborted){a(new m(w.InvalidRequest,"Request cancelled"));return}const n=setTimeout(r,s);t.addEventListener("abort",()=>{clearTimeout(n),a(new m(w.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async r=>{if(!e)throw new Error("No request provided");return await s.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async r=>{const a=await s.getTask(r,t);if(!a)throw new m(w.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(r,a,n)=>{await s.storeTaskResult(r,a,n,t);const i=await s.getTask(r,t);if(i){const u=Q.parse({method:"notifications/tasks/status",params:i});await this.notification(u),b(i.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>s.getTaskResult(r,t),updateTaskStatus:async(r,a,n)=>{const i=await s.getTask(r,t);if(!i)throw new m(w.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(b(i.status))throw new m(w.InvalidParams,`Cannot update task "${r}" from terminal status "${i.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(r,a,n,t);const u=await s.getTask(r,t);if(u){const p=Q.parse({method:"notifications/tasks/status",params:u});await this.notification(p),b(u.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>s.listTasks(r,t)}}}function Y(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function Be(o,e){const t={...o};for(const s in e){const r=s,a=e[r];if(a===void 0)continue;const n=t[r];Y(n)&&Y(a)?t[r]={...n,...a}:t[r]=a}return t}var Ze=be();const Xe=Re(Ze);function et(){const o=new Xe({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Ie(o),o}class tt{constructor(e){this._ajv=e??et()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class st{constructor(e){this._client=e}async*callToolStream(e,t=te,s){const r=this._client,a={...s,task:s?.task??(r.isToolTask(e.name)?{}:void 0)},n=r.requestStream({method:"tools/call",params:e},t,a),i=r.getToolOutputValidator(e.name);for await(const u of n){if(u.type==="result"&&i){const p=u.result;if(!p.structuredContent&&!p.isError){yield{type:"error",error:new m(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(p.structuredContent)try{const l=i(p.structuredContent);if(!l.valid){yield{type:"error",error:new m(w.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof m){yield{type:"error",error:l};return}yield{type:"error",error:new m(w.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield u}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function rt(o,e,t){if(!o)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!o.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function ot(o,e,t){if(!o)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!o.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!o.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function H(o,e){if(!(!o||e===null||typeof e!="object")){if(o.type==="object"&&o.properties&&typeof o.properties=="object"){const t=e,s=o.properties;for(const r of Object.keys(s)){const a=s[r];t[r]===void 0&&Object.prototype.hasOwnProperty.call(a,"default")&&(t[r]=a.default),t[r]!==void 0&&H(a,t[r])}}if(Array.isArray(o.anyOf))for(const t of o.anyOf)typeof t!="boolean"&&H(t,e);if(Array.isArray(o.oneOf))for(const t of o.oneOf)typeof t!="boolean"&&H(t,e)}}function at(o){if(!o)return{supportsFormMode:!1,supportsUrlMode:!1};const e=o.form!==void 0,t=o.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let nt=class extends Ye{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new tt,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Ee,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",qe,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Pe,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new st(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Be(this._capabilities,e)}setRequestHandler(e,t){const r=oe(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let a;if(N(r)){const i=r;a=i._zod?.def?.value??i.value}else{const i=r;a=i._def?.value??i.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const n=a;if(n==="elicitation/create"){const i=async(u,p)=>{const l=R(Le,u);if(!l.success){const c=l.error instanceof Error?l.error.message:String(l.error);throw new m(w.InvalidParams,`Invalid elicitation request: ${c}`)}const{params:h}=l.data;h.mode=h.mode??"form";const{supportsFormMode:f,supportsUrlMode:g}=at(this._capabilities.elicitation);if(h.mode==="form"&&!f)throw new m(w.InvalidParams,"Client does not support form-mode elicitation requests");if(h.mode==="url"&&!g)throw new m(w.InvalidParams,"Client does not support URL-mode elicitation requests");const y=await Promise.resolve(t(u,p));if(h.task){const c=R(F,y);if(!c.success){const _=c.error instanceof Error?c.error.message:String(c.error);throw new m(w.InvalidParams,`Invalid task creation result: ${_}`)}return c.data}const T=R(Ve,y);if(!T.success){const c=T.error instanceof Error?T.error.message:String(T.error);throw new m(w.InvalidParams,`Invalid elicitation result: ${c}`)}const v=T.data,d=h.mode==="form"?h.requestedSchema:void 0;if(h.mode==="form"&&v.action==="accept"&&v.content&&d&&this._capabilities.elicitation?.form?.applyDefaults)try{H(d,v.content)}catch{}return v};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(u,p)=>{const l=R(We,u);if(!l.success){const v=l.error instanceof Error?l.error.message:String(l.error);throw new m(w.InvalidParams,`Invalid sampling request: ${v}`)}const{params:h}=l.data,f=await Promise.resolve(t(u,p));if(h.task){const v=R(F,f);if(!v.success){const d=v.error instanceof Error?v.error.message:String(v.error);throw new m(w.InvalidParams,`Invalid task creation result: ${d}`)}return v.data}const y=h.tools||h.toolChoice?ze:Qe,T=R(y,f);if(!T.success){const v=T.error instanceof Error?T.error.message:String(T.error);throw new m(w.InvalidParams,`Invalid sampling result: ${v}`)}return T.data};return super.setRequestHandler(e,i)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:Ae,capabilities:this._capabilities,clientInfo:this._clientInfo}},$e,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Me.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){rt(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&ot(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},M,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Oe,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},M,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},He,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Ne,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},xe,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},De,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Ue,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},M,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},M,t)}async callTool(e,t=te,s){if(this.isToolTaskRequired(e.name))throw new m(w.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const r=await this.request({method:"tools/call",params:e},t,s),a=this.getToolOutputValidator(e.name);if(a){if(!r.structuredContent&&!r.isError)throw new m(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{const n=a(r.structuredContent);if(!n.valid)throw new m(w.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof m?n:new m(w.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const r=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,r)}const s=t.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(t.name),s==="required"&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},je,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,r){const a=Fe.safeParse(s);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=a.data,{onChanged:u}=s,p=async()=>{if(!n){u(null,null);return}try{const h=await r();u(null,h)}catch(h){const f=h instanceof Error?h:new Error(String(h));u(f,null)}},l=()=>{if(i){const h=this._listChangedDebounceTimers.get(e);h&&clearTimeout(h);const f=setTimeout(p,i);this._listChangedDebounceTimers.set(e,f)}else p()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const bt={SELF:o=>`${o}_self`,REGISTRY:o=>`${o}_registry`,COMMUNITY_REGISTRY:o=>`${o}_community-registry`,DEV_ASSETS:o=>`${o}_dev-assets`,SITE_DIAGNOSTICS:o=>`site-diagnostics_${o}`,COMMERCE_DISCOVERY:o=>`${o}_commerce-discovery`},It="get_my_diagnostic",it="self";function W(o){return{is(e){return!e||!e.startsWith(o)?null:e.slice(o.length)||null},get(e){return`${o}${e}`}}}function ct(o){return{id:o.id,organization_id:o.organizationId,title:o.title,description:o.description,icon:o.icon,status:"active",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:"system",updated_by:void 0,metadata:{instructions:o.instructions??null},pinned:!1,connections:[]}}const ae=W("decopilot_"),Et=ae.is,lt=ae.get,ne=W("dev_"),qt=ne.get,Pt=ne.is;function At(o){return ct({id:lt(o),organizationId:o,title:"Decopilot",description:"Default agent that aggregates all organization connections",icon:"https://assets.decocache.com/decocms/fd07a578-6b1c-40f1-bc05-88a3b981695d/f7fc4ffa81aec04e37ae670c3cd4936643a7b269.png"})}const ut=W("commerce-discovery_"),$t=ut.get,Mt={AGENT_MANAGER:o=>`studio-agent-manager_${o}`,AUTOMATION_MANAGER:o=>`studio-automation-manager_${o}`,CONNECTION_MANAGER:o=>`studio-connection-manager_${o}`,STORE_MANAGER:o=>`studio-store-manager_${o}`,BRAND_MANAGER:o=>`studio-brand-manager_${o}`,USAGE_MANAGER:o=>`studio-usage-manager_${o}`};function Ot(o){return o?o.startsWith("studio-agent-manager_")||o.startsWith("studio-automation-manager_")||o.startsWith("studio-connection-manager_")||o.startsWith("studio-store-manager_")||o.startsWith("studio-brand-manager_")||o.startsWith("studio-usage-manager_"):!1}const D=o=>[{type:"text",text:o}];function dt(o){const e=o.meshUrl??(typeof window<"u"?window.location.origin:void 0);if(!e)throw new Error("RestSelfClient requires either meshUrl or a browser environment.");const t={"Content-Type":"application/json",Accept:"application/json",...o.token?{Authorization:`Bearer ${o.token}`}:{}},s=u=>new URL(`/api/${encodeURIComponent(o.orgSlug)}${u}`,e).href,r=async u=>{let p;try{p=await fetch(s(`/tools/${encodeURIComponent(u.name)}`),{method:"POST",headers:t,credentials:"include",body:JSON.stringify(u.arguments??{})})}catch(h){const f=h instanceof Error?h.message:"Network error";return{content:D(f),isError:!0}}if(!p.ok){let h=`${u.name} failed (${p.status})`;try{const f=await p.json();f?.error&&(h=f.error)}catch{}return{content:D(h),isError:!0}}const l=await p.json().catch(()=>({}));return{content:D(typeof l=="string"?l:JSON.stringify(l)),structuredContent:l}},a=async()=>{const u=await fetch(s("/tools"),{method:"GET",headers:t,credentials:"include"});return u.ok?await u.json():{tools:[]}},n=u=>()=>Promise.reject(new Error(`RestSelfClient: ${u} is not supported over REST for the self connection`));return{callTool:r,listTools:a,listPrompts:n("listPrompts"),getPrompt:n("getPrompt"),listResources:n("listResources"),readResource:n("readResource"),listResourceTemplates:n("listResourceTemplates"),close:()=>Promise.resolve(),toJSON:()=>o.toJSONString}}function L(o){return o?o instanceof Headers?Object.fromEntries(o.entries()):Array.isArray(o)?Object.fromEntries(o):{...o}:{}}function ht(o=fetch,e){return e?async(t,s)=>{const r={...e,...s,headers:s?.headers?{...L(e.headers),...L(s.headers)}:e.headers};return o(t,r)}:o}class B extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const Z=10,ft=13,I=32;function U(o){}function pt(o){if(typeof o=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=U,onError:t=U,onRetry:s=U,onComment:r}=o,a=[];let n=!0,i,u="",p=0,l;function h(d){if(n&&(n=!1,d.charCodeAt(0)===239&&d.charCodeAt(1)===187&&d.charCodeAt(2)===191&&(d=d.slice(3))),a.length===0){const k=f(d);k!==""&&a.push(k);return}if(d.indexOf(`
1
+ import{c_ as de,c$ as he,d0 as fe,cf as pe,d1 as me,bW as m,bX as w,d2 as _e,d3 as ge,d4 as we,d5 as A,d6 as Te,d7 as j,d8 as ye,d9 as q,da as ve,db as F,dc as ke,dd as Se,de as Ce,df as Q,bB as Re,bD as be,bi as Ie,ca as te,cm as Ee,cs as qe,cq as Pe,cO as $e,dg as Ae,dh as Me,di as M,dj as Oe,dk as He,cr as Ne,cn as xe,co as De,cp as Ue,by as je,dl as Fe,dm as Le,dn as Ve,ch as We,dp as ze,dq as Qe,dr as Ge,bx as x,c as se,q as re,aL as V}from"./index-CFiyU0D9.js";import{U as P,a as O,e as G}from"./auth-Bej0Tx2Y.js";function N(o){return!!o._zod}function R(o,e){return N(o)?de(o,e):o.safeParse(e)}function oe(o){if(!o)return;let e;if(N(o)?e=o._zod?.def?.shape:e=o.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Je(o){if(N(o)){const a=o._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const t=o._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=o.value;if(s!==void 0)return s}function b(o){return o==="completed"||o==="failed"||o==="cancelled"}function J(o){const t=oe(o)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=Je(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function K(o,e){const t=R(o,e);if(!t.success)throw t.error;return t.data}const Ke=6e4;class Be{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(he,t=>{this._oncancel(t)}),this.setNotificationHandler(fe,t=>{this._onprogress(t)}),this.setRequestHandler(pe,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(me,async(t,s)=>{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new m(w.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(_e,async(t,s)=>{const r=async()=>{const a=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(a,s.sessionId);){if(i.type==="response"||i.type==="error"){const u=i.message,p=u.id,l=this._requestResolvers.get(p);if(l)if(this._requestResolvers.delete(p),i.type==="response")l(u);else{const h=u,f=new m(h.error.code,h.error.message,h.error.data);l(f)}else{const h=i.type==="response"?"Response":"Error";this._onerror(new Error(`${h} handler missing for request ${p}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(a,s.sessionId);if(!n)throw new m(w.InvalidParams,`Task not found: ${a}`);if(!b(n.status))return await this._waitForTaskUpdate(a,s.signal),await r();if(b(n.status)){const i=await this._taskStore.getTaskResult(a,s.sessionId);return this._clearTaskQueue(a),{...i,_meta:{...i._meta,[q]:{taskId:a}}}}return await r()};return await r()}),this.setRequestHandler(ge,async(t,s)=>{try{const{tasks:r,nextCursor:a}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:r,nextCursor:a,_meta:{}}}catch(r){throw new m(w.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(we,async(t,s)=>{try{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new m(w.InvalidParams,`Task not found: ${t.params.taskId}`);if(b(r.status))throw new m(w.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const a=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!a)throw new m(w.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...a}}catch(r){throw r instanceof m?r:new m(w.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,r,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:a,onTimeout:r})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),m.fromError(w.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=a=>{s?.(a),this._onerror(a)};const r=this._transport?.onmessage;this._transport.onmessage=(a,n)=>{r?.(a,n),A(a)||Te(a)?this._onresponse(a):j(a)?this._onrequest(a,n):ye(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=m.fromError(w.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,a=e.params?._meta?.[q]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:w.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):r?.send(l).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=ve(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,p={signal:n.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const h={relatedRequestId:e.id};a&&(h.relatedTask={taskId:a}),await this.notification(l,h)},sendRequest:async(l,h,f)=>{if(n.signal.aborted)throw new m(w.ConnectionClosed,"Request was cancelled");const g={...f,relatedRequestId:e.id};a&&!g.relatedTask&&(g.relatedTask={taskId:a});const y=g.relatedTask?.taskId??a;return y&&u&&await u.updateTaskStatus(y,"input_required"),await this.request(l,h,g)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:a,taskStore:u,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,p)).then(async l=>{if(n.signal.aborted)return;const h={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:h,timestamp:Date.now()},r?.sessionId):await r?.send(h)},async l=>{if(n.signal.aborted)return;const h={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:w.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:h,timestamp:Date.now()},r?.sessionId):await r?.send(h)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===n&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,r=Number(t),a=this._progressHandlers.get(r);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(u);return}a(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),A(e))s(e);else{const n=new m(e.error.code,e.error.message,e.error.data);s(n)}return}const r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let a=!1;if(A(e)&&e.result&&typeof e.result=="object"){const n=e.result;if(n.task&&typeof n.task=="object"){const i=n.task;typeof i.taskId=="string"&&(a=!0,this._taskProgressTokens.set(i.taskId,t))}}if(a||this._progressHandlers.delete(t),A(e))r(e);else{const n=m.fromError(e.error.code,e.error.message,e.error.data);r(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:r}=s??{};if(!r){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof m?n:new m(w.InternalError,String(n))}}return}let a;try{const n=await this.request(e,F,s);if(n.task)a=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new m(w.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:a},s);if(yield{type:"taskStatus",task:i},b(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)}:i.status==="failed"?yield{type:"error",error:new m(w.InternalError,`Task ${a} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new m(w.InternalError,`Task ${a} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)};return}const u=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(p=>setTimeout(p,u)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof m?n:new m(w.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:r,resumptionToken:a,onresumptiontoken:n,task:i,relatedTask:u}=s??{};return new Promise((p,l)=>{const h=c=>{l(c)};if(!this._transport){h(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(c){h(c);return}s?.signal?.throwIfAborted();const f=this._requestMessageId++,g={...e,jsonrpc:"2.0",id:f};s?.onprogress&&(this._progressHandlers.set(f,s.onprogress),g.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),i&&(g.params={...g.params,task:i}),u&&(g.params={...g.params,_meta:{...g.params?._meta||{},[q]:u}});const y=c=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(c)}},{relatedRequestId:r,resumptionToken:a,onresumptiontoken:n}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));const _=c instanceof m?c:new m(w.RequestTimeout,String(c));l(_)};this._responseHandlers.set(f,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return l(c);try{const _=R(t,c.result);_.success?p(_.data):l(_.error)}catch(_){l(_)}}}),s?.signal?.addEventListener("abort",()=>{y(s?.signal?.reason)});const T=s?.timeout??Ke,v=()=>y(m.fromError(w.RequestTimeout,"Request timed out",{timeout:T}));this._setupTimeout(f,T,s?.maxTotalTimeout,v,s?.resetTimeoutOnProgress??!1);const d=u?.taskId;if(d){const c=_=>{const k=this._responseHandlers.get(f);k?k(_):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,c),this._enqueueTaskMessage(d,{type:"request",message:g,timestamp:Date.now()}).catch(_=>{this._cleanupTimeout(f),l(_)})}else this._transport.send(g,{relatedRequestId:r,resumptionToken:a,onresumptiontoken:n}).catch(c=>{this._cleanupTimeout(f),l(c)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ke,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Se,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Ce,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=t?.relatedTask?.taskId;if(s){const i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[q]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:i,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let i={...e,jsonrpc:"2.0"};t?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[q]:t.relatedTask}}}),this._transport?.send(i,t).catch(u=>this._onerror(u))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[q]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=J(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,a)=>{const n=K(e,r);return Promise.resolve(t(n,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=J(e);this._notificationHandlers.set(s,r=>{const a=K(e,r);return Promise.resolve(t(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const r of s)if(r.type==="request"&&j(r.message)){const a=r.message.id,n=this._requestResolvers.get(a);n?(n(new m(w.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(e);r?.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,a)=>{if(t.aborted){a(new m(w.InvalidRequest,"Request cancelled"));return}const n=setTimeout(r,s);t.addEventListener("abort",()=>{clearTimeout(n),a(new m(w.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async r=>{if(!e)throw new Error("No request provided");return await s.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async r=>{const a=await s.getTask(r,t);if(!a)throw new m(w.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(r,a,n)=>{await s.storeTaskResult(r,a,n,t);const i=await s.getTask(r,t);if(i){const u=Q.parse({method:"notifications/tasks/status",params:i});await this.notification(u),b(i.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>s.getTaskResult(r,t),updateTaskStatus:async(r,a,n)=>{const i=await s.getTask(r,t);if(!i)throw new m(w.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(b(i.status))throw new m(w.InvalidParams,`Cannot update task "${r}" from terminal status "${i.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(r,a,n,t);const u=await s.getTask(r,t);if(u){const p=Q.parse({method:"notifications/tasks/status",params:u});await this.notification(p),b(u.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>s.listTasks(r,t)}}}function B(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function Ye(o,e){const t={...o};for(const s in e){const r=s,a=e[r];if(a===void 0)continue;const n=t[r];B(n)&&B(a)?t[r]={...n,...a}:t[r]=a}return t}var Ze=be();const Xe=Re(Ze);function et(){const o=new Xe({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Ie(o),o}class tt{constructor(e){this._ajv=e??et()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class st{constructor(e){this._client=e}async*callToolStream(e,t=te,s){const r=this._client,a={...s,task:s?.task??(r.isToolTask(e.name)?{}:void 0)},n=r.requestStream({method:"tools/call",params:e},t,a),i=r.getToolOutputValidator(e.name);for await(const u of n){if(u.type==="result"&&i){const p=u.result;if(!p.structuredContent&&!p.isError){yield{type:"error",error:new m(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(p.structuredContent)try{const l=i(p.structuredContent);if(!l.valid){yield{type:"error",error:new m(w.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof m){yield{type:"error",error:l};return}yield{type:"error",error:new m(w.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield u}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function rt(o,e,t){if(!o)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!o.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function ot(o,e,t){if(!o)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!o.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!o.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function H(o,e){if(!(!o||e===null||typeof e!="object")){if(o.type==="object"&&o.properties&&typeof o.properties=="object"){const t=e,s=o.properties;for(const r of Object.keys(s)){const a=s[r];t[r]===void 0&&Object.prototype.hasOwnProperty.call(a,"default")&&(t[r]=a.default),t[r]!==void 0&&H(a,t[r])}}if(Array.isArray(o.anyOf))for(const t of o.anyOf)typeof t!="boolean"&&H(t,e);if(Array.isArray(o.oneOf))for(const t of o.oneOf)typeof t!="boolean"&&H(t,e)}}function at(o){if(!o)return{supportsFormMode:!1,supportsUrlMode:!1};const e=o.form!==void 0,t=o.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let nt=class extends Be{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new tt,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Ee,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",qe,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Pe,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new st(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ye(this._capabilities,e)}setRequestHandler(e,t){const r=oe(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let a;if(N(r)){const i=r;a=i._zod?.def?.value??i.value}else{const i=r;a=i._def?.value??i.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const n=a;if(n==="elicitation/create"){const i=async(u,p)=>{const l=R(Le,u);if(!l.success){const c=l.error instanceof Error?l.error.message:String(l.error);throw new m(w.InvalidParams,`Invalid elicitation request: ${c}`)}const{params:h}=l.data;h.mode=h.mode??"form";const{supportsFormMode:f,supportsUrlMode:g}=at(this._capabilities.elicitation);if(h.mode==="form"&&!f)throw new m(w.InvalidParams,"Client does not support form-mode elicitation requests");if(h.mode==="url"&&!g)throw new m(w.InvalidParams,"Client does not support URL-mode elicitation requests");const y=await Promise.resolve(t(u,p));if(h.task){const c=R(F,y);if(!c.success){const _=c.error instanceof Error?c.error.message:String(c.error);throw new m(w.InvalidParams,`Invalid task creation result: ${_}`)}return c.data}const T=R(Ve,y);if(!T.success){const c=T.error instanceof Error?T.error.message:String(T.error);throw new m(w.InvalidParams,`Invalid elicitation result: ${c}`)}const v=T.data,d=h.mode==="form"?h.requestedSchema:void 0;if(h.mode==="form"&&v.action==="accept"&&v.content&&d&&this._capabilities.elicitation?.form?.applyDefaults)try{H(d,v.content)}catch{}return v};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(u,p)=>{const l=R(We,u);if(!l.success){const v=l.error instanceof Error?l.error.message:String(l.error);throw new m(w.InvalidParams,`Invalid sampling request: ${v}`)}const{params:h}=l.data,f=await Promise.resolve(t(u,p));if(h.task){const v=R(F,f);if(!v.success){const d=v.error instanceof Error?v.error.message:String(v.error);throw new m(w.InvalidParams,`Invalid task creation result: ${d}`)}return v.data}const y=h.tools||h.toolChoice?ze:Qe,T=R(y,f);if(!T.success){const v=T.error instanceof Error?T.error.message:String(T.error);throw new m(w.InvalidParams,`Invalid sampling result: ${v}`)}return T.data};return super.setRequestHandler(e,i)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:$e,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ae,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Me.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){rt(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&ot(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},M,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Oe,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},M,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},He,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Ne,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},xe,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},De,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Ue,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},M,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},M,t)}async callTool(e,t=te,s){if(this.isToolTaskRequired(e.name))throw new m(w.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const r=await this.request({method:"tools/call",params:e},t,s),a=this.getToolOutputValidator(e.name);if(a){if(!r.structuredContent&&!r.isError)throw new m(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{const n=a(r.structuredContent);if(!n.valid)throw new m(w.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof m?n:new m(w.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const r=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,r)}const s=t.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(t.name),s==="required"&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},je,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,r){const a=Fe.safeParse(s);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=a.data,{onChanged:u}=s,p=async()=>{if(!n){u(null,null);return}try{const h=await r();u(null,h)}catch(h){const f=h instanceof Error?h:new Error(String(h));u(f,null)}},l=()=>{if(i){const h=this._listChangedDebounceTimers.get(e);h&&clearTimeout(h);const f=setTimeout(p,i);this._listChangedDebounceTimers.set(e,f)}else p()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const bt={SELF:o=>`${o}_self`,REGISTRY:o=>`${o}_registry`,COMMUNITY_REGISTRY:o=>`${o}_community-registry`,DEV_ASSETS:o=>`${o}_dev-assets`,SITE_DIAGNOSTICS:o=>`site-diagnostics_${o}`,COMMERCE_DISCOVERY:o=>`${o}_commerce-discovery`},It="get_my_diagnostic",it="self";function W(o){return{is(e){return!e||!e.startsWith(o)?null:e.slice(o.length)||null},get(e){return`${o}${e}`}}}function ct(o){return{id:o.id,organization_id:o.organizationId,title:o.title,description:o.description,icon:o.icon,status:"active",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:"system",updated_by:void 0,metadata:{instructions:o.instructions??null},pinned:!1,connections:[]}}const ae=W("decopilot_"),Et=ae.is,lt=ae.get,ne=W("dev_"),qt=ne.get,Pt=ne.is;function $t(o){return ct({id:lt(o),organizationId:o,title:"Decopilot",description:"Default agent that aggregates all organization connections",icon:"https://assets.decocache.com/decocms/fd07a578-6b1c-40f1-bc05-88a3b981695d/f7fc4ffa81aec04e37ae670c3cd4936643a7b269.png"})}const ut=W("commerce-discovery_"),At=ut.get,Mt={AGENT_MANAGER:o=>`studio-agent-manager_${o}`,AUTOMATION_MANAGER:o=>`studio-automation-manager_${o}`,CONNECTION_MANAGER:o=>`studio-connection-manager_${o}`,STORE_MANAGER:o=>`studio-store-manager_${o}`,BRAND_MANAGER:o=>`studio-brand-manager_${o}`,USAGE_MANAGER:o=>`studio-usage-manager_${o}`};function Ot(o){return o?o.startsWith("studio-agent-manager_")||o.startsWith("studio-automation-manager_")||o.startsWith("studio-connection-manager_")||o.startsWith("studio-store-manager_")||o.startsWith("studio-brand-manager_")||o.startsWith("studio-usage-manager_"):!1}const D=o=>[{type:"text",text:o}];function dt(o){const e=o.meshUrl??(typeof window<"u"?window.location.origin:void 0);if(!e)throw new Error("RestSelfClient requires either meshUrl or a browser environment.");const t={"Content-Type":"application/json",Accept:"application/json",...o.token?{Authorization:`Bearer ${o.token}`}:{}},s=u=>new URL(`/api/${encodeURIComponent(o.orgSlug)}${u}`,e).href,r=async u=>{let p;try{p=await fetch(s(`/tools/${encodeURIComponent(u.name)}`),{method:"POST",headers:t,credentials:"include",body:JSON.stringify(u.arguments??{})})}catch(h){const f=h instanceof Error?h.message:"Network error";return{content:D(f),isError:!0}}if(!p.ok){let h=`${u.name} failed (${p.status})`;try{const f=await p.json();f?.error&&(h=f.error)}catch{}return{content:D(h),isError:!0}}const l=await p.json().catch(()=>({}));return{content:D(typeof l=="string"?l:JSON.stringify(l)),structuredContent:l}},a=async()=>{const u=await fetch(s("/tools"),{method:"GET",headers:t,credentials:"include"});return u.ok?await u.json():{tools:[]}},n=u=>()=>Promise.reject(new Error(`RestSelfClient: ${u} is not supported over REST for the self connection`));return{callTool:r,listTools:a,listPrompts:n("listPrompts"),getPrompt:n("getPrompt"),listResources:n("listResources"),readResource:n("readResource"),listResourceTemplates:n("listResourceTemplates"),close:()=>Promise.resolve(),toJSON:()=>o.toJSONString}}function L(o){return o?o instanceof Headers?Object.fromEntries(o.entries()):Array.isArray(o)?Object.fromEntries(o):{...o}:{}}function ht(o=fetch,e){return e?async(t,s)=>{const r={...e,...s,headers:s?.headers?{...L(e.headers),...L(s.headers)}:e.headers};return o(t,r)}:o}class Y extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const Z=10,ft=13,I=32;function U(o){}function pt(o){if(typeof o=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=U,onError:t=U,onRetry:s=U,onComment:r}=o,a=[];let n=!0,i,u="",p=0,l;function h(d){if(n&&(n=!1,d.charCodeAt(0)===239&&d.charCodeAt(1)===187&&d.charCodeAt(2)===191&&(d=d.slice(3))),a.length===0){const k=f(d);k!==""&&a.push(k);return}if(d.indexOf(`
2
2
  `)===-1&&d.indexOf("\r")===-1){a.push(d);return}a.push(d);const c=a.join("");a.length=0;const _=f(c);_!==""&&a.push(_)}function f(d){let c=0;if(d.indexOf("\r")===-1){let _=d.indexOf(`
3
3
  `,c);for(;_!==-1;){if(c===_){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0,c=_+1,_=d.indexOf(`
4
4
  `,c);continue}const k=d.charCodeAt(c);if(X(d,c,k)){const S=d.charCodeAt(c+5)===I?c+6:c+5,C=d.slice(S,_);if(p===0&&d.charCodeAt(_+1)===Z){e({id:i,event:l,data:C}),i=void 0,u="",l=void 0,c=_+2,_=d.indexOf(`
@@ -7,4 +7,4 @@ ${C}`,p++}else ee(d,c,k)?l=d.slice(d.charCodeAt(c+6)===I?c+7:c+6,_)||void 0:g(d,
7
7
  `,c)}return d.slice(c)}for(;c<d.length;){const _=d.indexOf("\r",c),k=d.indexOf(`
8
8
  `,c);let S=-1;if(_!==-1&&k!==-1?S=_<k?_:k:_!==-1?_===d.length-1?S=-1:S=_:k!==-1&&(S=k),S===-1)break;g(d,c,S),c=S+1,d.charCodeAt(c-1)===ft&&d.charCodeAt(c)===Z&&c++}return d.slice(c)}function g(d,c,_){if(c===_){T();return}const k=d.charCodeAt(c);if(X(d,c,k)){const E=d.charCodeAt(c+5)===I?c+6:c+5,z=d.slice(E,_);u=p===0?z:`${u}
9
9
  ${z}`,p++;return}if(ee(d,c,k)){l=d.slice(d.charCodeAt(c+6)===I?c+7:c+6,_)||void 0;return}if(k===105&&d.charCodeAt(c+1)===100&&d.charCodeAt(c+2)===58){const E=d.slice(d.charCodeAt(c+3)===I?c+4:c+3,_);i=E.includes("\0")?void 0:E;return}if(k===58){if(r){const E=d.slice(c,_);r(E.slice(d.charCodeAt(c+1)===I?2:1))}return}const S=d.slice(c,_),C=S.indexOf(":");if(C===-1){y(S,"",S);return}const ce=S.slice(0,C),le=S.charCodeAt(C+1)===I?2:1,ue=S.slice(C+le);y(ce,ue,S)}function y(d,c,_){switch(d){case"event":l=c||void 0;break;case"data":u=p===0?c:`${u}
10
- ${c}`,p++;break;case"id":i=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?s(parseInt(c,10)):t(new B(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:_}));break;default:t(new B(`Unknown field "${d.length>20?`${d.slice(0,20)}…`:d}"`,{type:"unknown-field",field:d,value:c,line:_}));break}}function T(){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0}function v(d={}){if(d.consume&&a.length>0){const c=a.join("");g(c,0,c.length)}n=!0,i=void 0,u="",p=0,l=void 0,a.length=0}return{feed:h,reset:v}}function X(o,e,t){return t===100&&o.charCodeAt(e+1)===97&&o.charCodeAt(e+2)===116&&o.charCodeAt(e+3)===97&&o.charCodeAt(e+4)===58}function ee(o,e,t){return t===101&&o.charCodeAt(e+1)===118&&o.charCodeAt(e+2)===101&&o.charCodeAt(e+3)===110&&o.charCodeAt(e+4)===116&&o.charCodeAt(e+5)===58}class mt extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let r;super({start(a){r=pt({onEvent:n=>{a.enqueue(n)},onError(n){e==="terminate"?a.error(n):typeof e=="function"&&e(n)},onRetry:t,onComment:s})},transform(a){r.feed(a)}})}}const _t={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class A extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}let gt=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=ht(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??_t}async _authThenStart(){if(!this._authProvider)throw new P("No auth provider");let e;try{e=await O(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(t){throw this.onerror?.(t),t}if(e!=="AUTHORIZED")throw new P;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=L(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),t&&s.set("last-event-id",t);const r=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new A(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),r)}_scheduleReconnection(e,t=0){const s=this._reconnectionOptions.maxRetries;if(t>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(a=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,s){if(!e)return;const{onresumptiontoken:r,replayMessageId:a}=t;let n,i=!1,u=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new mt({onRetry:g=>{this._serverRetryMs=g}})).getReader();for(;;){const{value:g,done:y}=await l.read();if(y)break;if(g.id&&(n=g.id,i=!0,r?.(g.id)),!!g.data&&(!g.event||g.event==="message"))try{const T=x.parse(JSON.parse(g.data));$(T)&&(u=!0,a!==void 0&&(T.id=a)),this.onmessage?.(T)}catch(T){this.onerror?.(T)}}(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:a},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:a},0)}catch(g){this.onerror?.(new Error(`Failed to reconnect: ${g instanceof Error?g.message:String(g)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new P("No auth provider");if(await O(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:s,onresumptiontoken:r}=t||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:j(e)?e.id:void 0}).catch(f=>this.onerror?.(f));return}const a=await this._commonHeaders();a.set("content-type","application/json"),a.set("accept","application/json, text/event-stream");const n={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,n),u=i.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!i.ok){const f=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new A(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:g,scope:y}=G(i);if(this._resourceMetadataUrl=g,this._scope=y,await O(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P;return this._hasCompletedAuthFlow=!0,this.send(e)}if(i.status===403&&this._authProvider){const{resourceMetadataUrl:g,scope:y,error:T}=G(i);if(T==="insufficient_scope"){const v=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===v)throw new A(403,"Server returned 403 after trying upscoping");if(y&&(this._scope=y),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=v??void 0,await O(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new P;return this.send(e)}}throw new A(i.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,i.status===202){await i.body?.cancel(),Ge(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}const l=(Array.isArray(e)?e:[e]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,h=i.headers.get("content-type");if(l)if(h?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:r},!1);else if(h?.includes("application/json")){const f=await i.json(),g=Array.isArray(f)?f.map(y=>x.parse(y)):[x.parse(f)];for(const y of g)this.onmessage?.(y)}else throw await i.body?.cancel(),new A(-1,`Unexpected content type: ${h}`);else await i.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,t);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new A(s.status,`Failed to terminate session: ${s.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};class wt extends gt{constructor(e,t){super(e,t)}send(e,t){const s=Tt(e);return s?.type==="emit"?(this.onmessage?.(s.message),Promise.resolve()):s?.type==="suppress"?Promise.resolve():super.send(e,t)}}function Tt(o){const e=o;if(!e||typeof e!="object"||!("method"in e))return null;switch(e.method){case"initialize":{const t=e?.params?.protocolVersion;return t?{type:"emit",message:{result:{protocolVersion:t,capabilities:{tools:{},resources:{},prompts:{},tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}},serverInfo:{name:"mesh-virtual-mcp",version:"1.0.0"}},jsonrpc:e.jsonrpc??"2.0",id:e.id}}:null}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}const yt={name:"mesh-sdk",version:"1.0.0"};function vt(o,e,t){const s=t??(typeof window<"u"?window.location.origin:void 0);if(!s)throw new Error("MCP client requires either meshUrl option or a browser environment.");const r=`/api/${encodeURIComponent(e)}`,a=o?`${r}/mcp/${o}`:`${r}/mcp`;return new URL(a,s).href}async function ie({connectionId:o,orgId:e,orgSlug:t,token:s,meshUrl:r,mcpUrl:a}){const n=V.mcpClient(e,o??"self",s??"",a??r??"");if(!a&&(!o||o===it))return dt({orgSlug:t,token:s,meshUrl:r,toJSONString:`mcp-client:${n.join(":")}`});const i=a??vt(o,t,r),u=new nt(yt,{capabilities:{tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}}}),p=new wt(new URL(i),{requestInit:{headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream",...s?{Authorization:`Bearer ${s}`}:{}}}});return await u.connect(p),u.toJSON=()=>`mcp-client:${n.join(":")}`,u}function kt(o){const{connectionId:e,token:t,meshUrl:s,mcpUrl:r,orgId:a}=o;return{queryKey:V.mcpClient(a,e??"self",t??"",r??s??""),queryFn:()=>ie(o),staleTime:1/0,gcTime:6e4}}function Nt(o){const e=se.c(2);let t;e[0]!==o?(t=kt(o),e[0]=o,e[1]=t):t=e[1];const{data:s}=re(t);return s}function xt(o){const e=se.c(16),{connectionId:t,orgId:s,orgSlug:r,token:a,meshUrl:n,mcpUrl:i}=o;let u;e[0]!==t||e[1]!==i||e[2]!==n||e[3]!==s||e[4]!==a?(u=t!==void 0?V.mcpClient(s,t??"self",a??"",i??n??""):["mcp","client","skip",s],e[0]=t,e[1]=i,e[2]=n,e[3]=s,e[4]=a,e[5]=u):u=e[5];const p=u;let l;e[6]!==t||e[7]!==i||e[8]!==n||e[9]!==s||e[10]!==r||e[11]!==a?(l=async()=>t===void 0?null:ie({connectionId:t,orgId:s,orgSlug:r,token:a,meshUrl:n,mcpUrl:i}),e[6]=t,e[7]=i,e[8]=n,e[9]=s,e[10]=r,e[11]=a,e[12]=l):l=e[12];let h;e[13]!==p||e[14]!==l?(h={queryKey:p,queryFn:l,staleTime:1/0,gcTime:6e4},e[13]=p,e[14]=l,e[15]=h):h=e[15];const{data:f}=re(h);return f??null}export{Xe as A,It as C,Ye as P,it as S,bt as W,At as a,qt as b,xt as c,Mt as d,ie as e,pt as f,$t as g,ht as h,Et as i,gt as j,nt as k,Ot as l,kt as m,L as n,lt as o,Pt as p,Nt as u};
10
+ ${c}`,p++;break;case"id":i=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?s(parseInt(c,10)):t(new Y(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:_}));break;default:t(new Y(`Unknown field "${d.length>20?`${d.slice(0,20)}…`:d}"`,{type:"unknown-field",field:d,value:c,line:_}));break}}function T(){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0}function v(d={}){if(d.consume&&a.length>0){const c=a.join("");g(c,0,c.length)}n=!0,i=void 0,u="",p=0,l=void 0,a.length=0}return{feed:h,reset:v}}function X(o,e,t){return t===100&&o.charCodeAt(e+1)===97&&o.charCodeAt(e+2)===116&&o.charCodeAt(e+3)===97&&o.charCodeAt(e+4)===58}function ee(o,e,t){return t===101&&o.charCodeAt(e+1)===118&&o.charCodeAt(e+2)===101&&o.charCodeAt(e+3)===110&&o.charCodeAt(e+4)===116&&o.charCodeAt(e+5)===58}class mt extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let r;super({start(a){r=pt({onEvent:n=>{a.enqueue(n)},onError(n){e==="terminate"?a.error(n):typeof e=="function"&&e(n)},onRetry:t,onComment:s})},transform(a){r.feed(a)}})}}const _t={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class $ extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}let gt=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=ht(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??_t}async _authThenStart(){if(!this._authProvider)throw new P("No auth provider");let e;try{e=await O(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(t){throw this.onerror?.(t),t}if(e!=="AUTHORIZED")throw new P;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=L(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),t&&s.set("last-event-id",t);const r=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new $(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),r)}_scheduleReconnection(e,t=0){const s=this._reconnectionOptions.maxRetries;if(t>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(a=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,s){if(!e)return;const{onresumptiontoken:r,replayMessageId:a}=t;let n,i=!1,u=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new mt({onRetry:g=>{this._serverRetryMs=g}})).getReader();for(;;){const{value:g,done:y}=await l.read();if(y)break;if(g.id&&(n=g.id,i=!0,r?.(g.id)),!!g.data&&(!g.event||g.event==="message"))try{const T=x.parse(JSON.parse(g.data));A(T)&&(u=!0,a!==void 0&&(T.id=a)),this.onmessage?.(T)}catch(T){this.onerror?.(T)}}(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:a},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:a},0)}catch(g){this.onerror?.(new Error(`Failed to reconnect: ${g instanceof Error?g.message:String(g)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new P("No auth provider");if(await O(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:s,onresumptiontoken:r}=t||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:j(e)?e.id:void 0}).catch(f=>this.onerror?.(f));return}const a=await this._commonHeaders();a.set("content-type","application/json"),a.set("accept","application/json, text/event-stream");const n={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,n),u=i.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!i.ok){const f=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new $(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:g,scope:y}=G(i);if(this._resourceMetadataUrl=g,this._scope=y,await O(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P;return this._hasCompletedAuthFlow=!0,this.send(e)}if(i.status===403&&this._authProvider){const{resourceMetadataUrl:g,scope:y,error:T}=G(i);if(T==="insufficient_scope"){const v=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===v)throw new $(403,"Server returned 403 after trying upscoping");if(y&&(this._scope=y),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=v??void 0,await O(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new P;return this.send(e)}}throw new $(i.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,i.status===202){await i.body?.cancel(),Ge(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}const l=(Array.isArray(e)?e:[e]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,h=i.headers.get("content-type");if(l)if(h?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:r},!1);else if(h?.includes("application/json")){const f=await i.json(),g=Array.isArray(f)?f.map(y=>x.parse(y)):[x.parse(f)];for(const y of g)this.onmessage?.(y)}else throw await i.body?.cancel(),new $(-1,`Unexpected content type: ${h}`);else await i.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,t);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new $(s.status,`Failed to terminate session: ${s.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};class wt extends gt{constructor(e,t){super(e,t)}send(e,t){const s=Tt(e);return s?.type==="emit"?(this.onmessage?.(s.message),Promise.resolve()):s?.type==="suppress"?Promise.resolve():super.send(e,t)}}function Tt(o){const e=o;if(!e||typeof e!="object"||!("method"in e))return null;switch(e.method){case"initialize":{const t=e?.params?.protocolVersion;return t?{type:"emit",message:{result:{protocolVersion:t,capabilities:{tools:{},resources:{},prompts:{},tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}},serverInfo:{name:"mesh-virtual-mcp",version:"1.0.0"}},jsonrpc:e.jsonrpc??"2.0",id:e.id}}:null}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}const yt={name:"mesh-sdk",version:"1.0.0"};function vt(o,e,t){const s=t??(typeof window<"u"?window.location.origin:void 0);if(!s)throw new Error("MCP client requires either meshUrl option or a browser environment.");const r=`/api/${encodeURIComponent(e)}`,a=o?`${r}/mcp/${o}`:`${r}/mcp`;return new URL(a,s).href}async function ie({connectionId:o,orgId:e,orgSlug:t,token:s,meshUrl:r,mcpUrl:a}){const n=V.mcpClient(e,o??"self",s??"",a??r??"");if(!a&&(!o||o===it))return dt({orgSlug:t,token:s,meshUrl:r,toJSONString:`mcp-client:${n.join(":")}`});const i=a??vt(o,t,r),u=new nt(yt,{capabilities:{tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}}}),p=new wt(new URL(i),{requestInit:{headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream",...s?{Authorization:`Bearer ${s}`}:{}}}});return await u.connect(p),u.toJSON=()=>`mcp-client:${n.join(":")}`,u}function kt(o){const{connectionId:e,token:t,meshUrl:s,mcpUrl:r,orgId:a}=o;return{queryKey:V.mcpClient(a,e??"self",t??"",r??s??""),queryFn:()=>ie(o),staleTime:1/0,gcTime:6e4}}function Nt(o){const e=se.c(2);let t;e[0]!==o?(t=kt(o),e[0]=o,e[1]=t):t=e[1];const{data:s}=re(t);return s}function xt(o){const e=se.c(16),{connectionId:t,orgId:s,orgSlug:r,token:a,meshUrl:n,mcpUrl:i}=o;let u;e[0]!==t||e[1]!==i||e[2]!==n||e[3]!==s||e[4]!==a?(u=t!==void 0?V.mcpClient(s,t??"self",a??"",i??n??""):["mcp","client","skip",s],e[0]=t,e[1]=i,e[2]=n,e[3]=s,e[4]=a,e[5]=u):u=e[5];const p=u;let l;e[6]!==t||e[7]!==i||e[8]!==n||e[9]!==s||e[10]!==r||e[11]!==a?(l=async()=>t===void 0?null:ie({connectionId:t,orgId:s,orgSlug:r,token:a,meshUrl:n,mcpUrl:i}),e[6]=t,e[7]=i,e[8]=n,e[9]=s,e[10]=r,e[11]=a,e[12]=l):l=e[12];let h;e[13]!==p||e[14]!==l?(h={queryKey:p,queryFn:l,staleTime:1/0,gcTime:6e4},e[13]=p,e[14]=l,e[15]=h):h=e[15];const{data:f}=re(h);return f??null}export{Xe as A,It as C,Be as P,it as S,bt as W,$t as a,qt as b,xt as c,Mt as d,ie as e,pt as f,At as g,ht as h,Et as i,gt as j,nt as k,Ot as l,kt as m,L as n,lt as o,Pt as p,Nt as u};
@@ -1 +1 @@
1
- import{c as l,k as c,bV as m,bW as f,q as y,aK as n}from"./index-DmjWDqcd.js";async function u(r){if(!r.getServerCapabilities()?.prompts)return{prompts:[]};try{return await r.listPrompts()}catch(t){if(t instanceof m&&t.code===f.MethodNotFound)return{prompts:[]};throw t}}async function b(r,e,t){if(!r.getServerCapabilities()?.prompts)throw new Error("Prompts capability not supported");return await r.getPrompt({name:e,arguments:t??{}})}function q(r){const e=l.c(12);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let i;e[3]!==t?(i=n.mcpPromptsList(t),e[3]=t,e[4]=i):i=e[4];let o;e[5]!==t?(o=()=>u(t),e[5]=t,e[6]=o):o=e[6];const p=s.staleTime??3e4;let a;return e[7]!==s||e[8]!==i||e[9]!==o||e[10]!==p?(a={...s,queryKey:i,queryFn:o,staleTime:p,retry:!1},e[7]=s,e[8]=i,e[9]=o,e[10]=p,e[11]=a):a=e[11],y(a)}function g(r){const e=l.c(12);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let i;e[3]!==t?(i=n.mcpPromptsList(t),e[3]=t,e[4]=i):i=e[4];let o;e[5]!==t?(o=()=>u(t),e[5]=t,e[6]=o):o=e[6];const p=s.staleTime??3e4;let a;return e[7]!==s||e[8]!==i||e[9]!==o||e[10]!==p?(a={...s,queryKey:i,queryFn:o,staleTime:p,retry:!1},e[7]=s,e[8]=i,e[9]=o,e[10]=p,e[11]=a):a=e[11],c(a)}export{g as a,b as g,u as l,q as u};
1
+ import{c as l,k as c,bW as m,bX as f,q as y,aL as n}from"./index-CFiyU0D9.js";async function u(r){if(!r.getServerCapabilities()?.prompts)return{prompts:[]};try{return await r.listPrompts()}catch(t){if(t instanceof m&&t.code===f.MethodNotFound)return{prompts:[]};throw t}}async function b(r,e,t){if(!r.getServerCapabilities()?.prompts)throw new Error("Prompts capability not supported");return await r.getPrompt({name:e,arguments:t??{}})}function q(r){const e=l.c(12);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let i;e[3]!==t?(i=n.mcpPromptsList(t),e[3]=t,e[4]=i):i=e[4];let o;e[5]!==t?(o=()=>u(t),e[5]=t,e[6]=o):o=e[6];const p=s.staleTime??3e4;let a;return e[7]!==s||e[8]!==i||e[9]!==o||e[10]!==p?(a={...s,queryKey:i,queryFn:o,staleTime:p,retry:!1},e[7]=s,e[8]=i,e[9]=o,e[10]=p,e[11]=a):a=e[11],y(a)}function g(r){const e=l.c(12);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let i;e[3]!==t?(i=n.mcpPromptsList(t),e[3]=t,e[4]=i):i=e[4];let o;e[5]!==t?(o=()=>u(t),e[5]=t,e[6]=o):o=e[6];const p=s.staleTime??3e4;let a;return e[7]!==s||e[8]!==i||e[9]!==o||e[10]!==p?(a={...s,queryKey:i,queryFn:o,staleTime:p,retry:!1},e[7]=s,e[8]=i,e[9]=o,e[10]=p,e[11]=a):a=e[11],c(a)}export{g as a,b as g,u as l,q as u};
@@ -1 +1 @@
1
- import{c as m,k as p,q,aK as T}from"./index-DmjWDqcd.js";function C(n){const e=m.c(12);let t,o;e[0]!==n?({client:t,...o}=n,e[0]=n,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let s;e[5]!==t?(s=async()=>await t.listTools(),e[5]=t,e[6]=s):s=e[6];const r=o.staleTime??3e4;let i;return e[7]!==o||e[8]!==l||e[9]!==s||e[10]!==r?(i={...o,queryKey:l,queryFn:s,staleTime:r,retry:!1},e[7]=o,e[8]=l,e[9]=s,e[10]=r,e[11]=i):i=e[11],q(i)}function K(n){const e=m.c(12);let t,o;e[0]!==n?({client:t,...o}=n,e[0]=n,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let s;e[5]!==t?(s=async()=>await t.listTools(),e[5]=t,e[6]=s):s=e[6];const r=o.staleTime??3e4;let i;return e[7]!==o||e[8]!==l||e[9]!==s||e[10]!==r?(i={...o,queryKey:l,queryFn:s,staleTime:r,retry:!1},e[7]=o,e[8]=l,e[9]=s,e[10]=r,e[11]=i):i=e[11],p(i)}function O(n){const e=m.c(21);let t,o,l,s;e[0]!==n?({client:t,toolName:s,toolArguments:l,...o}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=l,e[4]=s):(t=e[1],o=e[2],l=e[3],s=e[4]);let r,i,u;if(e[5]!==t||e[6]!==o||e[7]!==l||e[8]!==s){const f=JSON.stringify(l??{});u=q,r=o,i=T.mcpToolCall(t,s,f),e[5]=t,e[6]=o,e[7]=l,e[8]=s,e[9]=r,e[10]=i,e[11]=u}else r=e[9],i=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==s?(a=async()=>await t.callTool({name:s,arguments:l}),e[12]=t,e[13]=l,e[14]=s,e[15]=a):a=e[15];const y=o.staleTime??3e4;let c;return e[16]!==r||e[17]!==i||e[18]!==a||e[19]!==y?(c={...r,queryKey:i,queryFn:a,staleTime:y,retry:!1},e[16]=r,e[17]=i,e[18]=a,e[19]=y,e[20]=c):c=e[20],u(c)}function w(n){const e=m.c(21);let t,o,l,s;e[0]!==n?({client:t,toolName:s,toolArguments:l,...o}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=l,e[4]=s):(t=e[1],o=e[2],l=e[3],s=e[4]);let r,i,u;if(e[5]!==t||e[6]!==o||e[7]!==l||e[8]!==s){const f=JSON.stringify(l??{});u=p,r=o,i=T.mcpToolCall(t,s,f),e[5]=t,e[6]=o,e[7]=l,e[8]=s,e[9]=r,e[10]=i,e[11]=u}else r=e[9],i=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==s?(a=async()=>await t.callTool({name:s,arguments:l}),e[12]=t,e[13]=l,e[14]=s,e[15]=a):a=e[15];const y=o.staleTime??3e4;let c;return e[16]!==r||e[17]!==i||e[18]!==a||e[19]!==y?(c={...r,queryKey:i,queryFn:a,staleTime:y,retry:!1},e[16]=r,e[17]=i,e[18]=a,e[19]=y,e[20]=c):c=e[20],u(c)}export{K as a,C as b,O as c,w as u};
1
+ import{c as m,k as p,q,aL as T}from"./index-CFiyU0D9.js";function C(n){const e=m.c(12);let t,o;e[0]!==n?({client:t,...o}=n,e[0]=n,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let s;e[5]!==t?(s=async()=>await t.listTools(),e[5]=t,e[6]=s):s=e[6];const r=o.staleTime??3e4;let i;return e[7]!==o||e[8]!==l||e[9]!==s||e[10]!==r?(i={...o,queryKey:l,queryFn:s,staleTime:r,retry:!1},e[7]=o,e[8]=l,e[9]=s,e[10]=r,e[11]=i):i=e[11],q(i)}function K(n){const e=m.c(12);let t,o;e[0]!==n?({client:t,...o}=n,e[0]=n,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let s;e[5]!==t?(s=async()=>await t.listTools(),e[5]=t,e[6]=s):s=e[6];const r=o.staleTime??3e4;let i;return e[7]!==o||e[8]!==l||e[9]!==s||e[10]!==r?(i={...o,queryKey:l,queryFn:s,staleTime:r,retry:!1},e[7]=o,e[8]=l,e[9]=s,e[10]=r,e[11]=i):i=e[11],p(i)}function O(n){const e=m.c(21);let t,o,l,s;e[0]!==n?({client:t,toolName:s,toolArguments:l,...o}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=l,e[4]=s):(t=e[1],o=e[2],l=e[3],s=e[4]);let r,i,u;if(e[5]!==t||e[6]!==o||e[7]!==l||e[8]!==s){const f=JSON.stringify(l??{});u=q,r=o,i=T.mcpToolCall(t,s,f),e[5]=t,e[6]=o,e[7]=l,e[8]=s,e[9]=r,e[10]=i,e[11]=u}else r=e[9],i=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==s?(a=async()=>await t.callTool({name:s,arguments:l}),e[12]=t,e[13]=l,e[14]=s,e[15]=a):a=e[15];const y=o.staleTime??3e4;let c;return e[16]!==r||e[17]!==i||e[18]!==a||e[19]!==y?(c={...r,queryKey:i,queryFn:a,staleTime:y,retry:!1},e[16]=r,e[17]=i,e[18]=a,e[19]=y,e[20]=c):c=e[20],u(c)}function L(n){const e=m.c(21);let t,o,l,s;e[0]!==n?({client:t,toolName:s,toolArguments:l,...o}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=l,e[4]=s):(t=e[1],o=e[2],l=e[3],s=e[4]);let r,i,u;if(e[5]!==t||e[6]!==o||e[7]!==l||e[8]!==s){const f=JSON.stringify(l??{});u=p,r=o,i=T.mcpToolCall(t,s,f),e[5]=t,e[6]=o,e[7]=l,e[8]=s,e[9]=r,e[10]=i,e[11]=u}else r=e[9],i=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==s?(a=async()=>await t.callTool({name:s,arguments:l}),e[12]=t,e[13]=l,e[14]=s,e[15]=a):a=e[15];const y=o.staleTime??3e4;let c;return e[16]!==r||e[17]!==i||e[18]!==a||e[19]!==y?(c={...r,queryKey:i,queryFn:a,staleTime:y,retry:!1},e[16]=r,e[17]=i,e[18]=a,e[19]=y,e[20]=c):c=e[20],u(c)}export{K as a,C as b,O as c,L as u};
@@ -1 +1 @@
1
- import{c as n,D as i,q as l,K as m}from"./index-DmjWDqcd.js";import{u as a}from"./use-org-auth-client-a0tV0I4a.js";function p(){const e=n.c(7),{locator:o}=i(),u=a();let t;e[0]!==o?(t=m.members(o),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==u?(s=()=>u.organization.listMembers(),e[2]=u,e[3]=s):s=e[3];let r;return e[4]!==t||e[5]!==s?(r={queryKey:t,queryFn:s},e[4]=t,e[5]=s,e[6]=r):r=e[6],l(r)}export{p as u};
1
+ import{c as n,D as i,q as l,K as m}from"./index-CFiyU0D9.js";import{u as a}from"./use-org-auth-client-C_UJ3Vg_.js";function p(){const e=n.c(7),{locator:o}=i(),u=a();let t;e[0]!==o?(t=m.members(o),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==u?(s=()=>u.organization.listMembers(),e[2]=u,e[3]=s):s=e[3];let r;return e[4]!==t||e[5]!==s?(r={queryKey:t,queryFn:s},e[4]=t,e[5]=s,e[6]=r):r=e[6],l(r)}export{p as u};
@@ -1 +1 @@
1
- import{c as m,r}from"./index-DmjWDqcd.js";const a=768,o=()=>globalThis.innerWidth<a;function u(){const e=m.c(2),[l,n]=r.useState(o);let t,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{const i=()=>n(o),c=globalThis.matchMedia(`(max-width: ${a-1}px)`);return c.addEventListener("change",i),n(o),()=>c.removeEventListener("change",i)},s=[],e[0]=t,e[1]=s):(t=e[0],s=e[1]),r.useEffect(t,s),l}export{u};
1
+ import{c as m,r}from"./index-CFiyU0D9.js";const a=768,o=()=>globalThis.innerWidth<a;function u(){const e=m.c(2),[l,n]=r.useState(o);let t,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{const i=()=>n(o),c=globalThis.matchMedia(`(max-width: ${a-1}px)`);return c.addEventListener("change",i),n(o),()=>c.removeEventListener("change",i)},s=[],e[0]=t,e[1]=s):(t=e[0],s=e[1]),r.useEffect(t,s),l}export{u};
@@ -1 +1 @@
1
- import{L as v,r as f,c as C,j as K,b as j,D as M,a as N}from"./index-DmjWDqcd.js";import{u as F}from"./use-virtual-mcp-DQxIBquV.js";const h="__tool_call_runs__",R=["requires_action","in_progress","failed","expired","completed"];function tt(t){const e=new Map(R.map(r=>[r,[]]));for(const r of t){const n=r.status??"completed";(e.get(n)??e.get("completed")).push(r)}return R.map(r=>({status:r,threads:e.get(r)}))}function et(t,e){const r=new Map;for(const a of t){if(a.id.startsWith("thrd_welcome_"))continue;const u=a.virtual_mcp_id??h,d=r.get(u);d?(d.threads.push(a),(a.updated_at??"")>d.latestUpdatedAt&&(d.latestUpdatedAt=a.updated_at??"")):r.set(u,{virtualMcpId:u,threads:[a],latestUpdatedAt:a.updated_at??""})}const n=e!==null?r.get(e):void 0;n&&e&&r.delete(e);const s=r.get(h);s&&r.delete(h);const o=[...r.values()].sort((a,u)=>u.latestUpdatedAt.localeCompare(a.latestUpdatedAt)),i=[];return e&&i.push(n??{virtualMcpId:e,threads:[],latestUpdatedAt:""}),i.push(...o),s&&s.threads.length>0&&i.push(s),i}function rt(t,e){if(e.size===0)return t;const r=[],n=new Map;for(const s of t){const o=e.get(s.virtualMcpId);if(o){const a=n.get(o);if(a)a.threads=[...a.threads,...s.threads],s.latestUpdatedAt>a.latestUpdatedAt&&(a.latestUpdatedAt=s.latestUpdatedAt);else{const u={virtualMcpId:o,threads:[...s.threads],latestUpdatedAt:s.latestUpdatedAt};n.set(o,u),r.push(u)}continue}const i=n.get(s.virtualMcpId);if(i)i.threads=[...s.threads,...i.threads],s.latestUpdatedAt>i.latestUpdatedAt&&(i.latestUpdatedAt=s.latestUpdatedAt);else{const a={...s,threads:[...s.threads]};n.set(s.virtualMcpId,a),r.push(a)}}return r}const x=new Map,I=new Map;function P(t){return`${t.orgId}:${t.userId}`}function E(t){return`sidebar.group-order.${t}`}function O(t){try{const e=localStorage.getItem(t),r=e?JSON.parse(e):[];return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{return[]}}function T(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function L(t){const e=P(t),r=x.get(e);if(r)return r;const n=v.sidebarGroupOrder(t.orgId,t.userId);let s=!1;try{s=localStorage.getItem(n)!==null}catch{}let o=O(n);if(!s&&o.length===0&&t.userId!=="anon"){const i=O(E(t.orgId));i.length>0&&(o=i)}return x.set(e,o),o}function p(t,e){const r=new Set(e);return L(t).filter(n=>!r.has(n))}function g(t,e){x.set(P(t),e),T(v.sidebarGroupOrder(t.orgId,t.userId),e)}function m(t){const e=I.get(t);if(e)return e;const r=O(v.sidebarOrgPinnedOrder(t));return I.set(t,r),r}function S(t,e){I.set(t,e),T(v.sidebarOrgPinnedOrder(t),e)}function nt(t,e){g(t,e)}function st(t,e){S(t,e)}function k(t,e){return t===e||t===h}function w(t,e){return e.includes(t)}function q(t,e){return t.map(r=>r.virtualMcpId).filter(r=>!k(r,e))}function ot(t,e,r,n){const s=new Set(n);return q(t,r).filter(o=>e==="org"?s.has(o):!s.has(o))}function B(t,e){const r=new Set(t),n=e.filter(s=>!r.has(s));return n.length===0?t:[...t,...n]}function at(t,e,r){const n=new Set(r),s=[],o=[];let i,a;for(const u of t){const d=u.virtualMcpId;if(e&&d===e){i=u;continue}if(d===h){a=u;continue}if(n.has(d)){s.push(u);continue}o.push(u)}return{decopilot:i,orgPinned:s,user:o,toolCallRuns:a}}function $(t,e,r,n=[],s=[]){const o=r?t.find(c=>c.virtualMcpId===r):void 0,i=t.find(c=>c.virtualMcpId===h),a=new Set(n),u=n.filter(c=>!k(c,r)),d=B(s,u),l=e.filter(c=>!a.has(c)),b=new Map(t.map(c=>[c.virtualMcpId,c])),A=c=>{const G=b.get(c);return G||{virtualMcpId:c,threads:[],latestUpdatedAt:""}},_=d.filter(c=>a.has(c)).map(A),D=l.map(A),U=[];return o&&U.push(o),U.push(..._,...D),i&&U.push(i),{groups:U,userOrder:l,orgOrder:_.map(c=>c.virtualMcpId)}}function J(t,e){const r=new Set(e);m(t.orgId).length===0&&e.length>0&&S(t.orgId,[...e]);const s=v.sidebarGroupOrder(t.orgId,t.userId);if(O(s).length>0)return;const o=O(E(t.orgId));if(o.length===0)return;const i=o.filter(a=>!r.has(a));g(t,i)}function Y(t,e){const r=new Set(e),n=L(t),s=n.filter(o=>!r.has(o));s.length!==n.length&&g(t,s)}function it(t,e,r,n=[]){J(t,n),Y(t,n);const s=p(t,n),o=m(t.orgId),{userOrder:i,orgOrder:a}=$(e,s,r,n,o);(i.length!==s.length||i.some((u,d)=>u!==s[d]))&&g(t,i),(a.length!==o.length||a.some((u,d)=>u!==o[d]))&&S(t.orgId,a)}function ut(t,e,r,n=[]){const s=p(t,n),o=m(t.orgId);return $(e,s,r,n,o).groups}function dt(t,e,r){if(r){const o=p(t,[e]).filter(a=>a!==e);g(t,o);const i=m(t.orgId);i.includes(e)||S(t.orgId,[...i,e]);return}const n=m(t.orgId).filter(o=>o!==e);S(t.orgId,n);const s=p(t,[]);s.includes(e)||g(t,[...s,e])}function z(t,e,r=[]){if(r.includes(e))return;const n=p(t,r);n.includes(e)||g(t,[e,...n])}function ct(t,e,r=[]){const n=p(t,r),s=n.filter(o=>o!==e);s.length!==n.length&&g(t,s)}function lt(t,e,r){const n=t.indexOf(e),s=t.indexOf(r);if(n===-1||s===-1||n===s)return t;const o=[...t],[i]=o.splice(n,1);return i===void 0?t:(o.splice(s,0,i),o)}function ft(t,e,r,n){if(t==="org")return n;const s=p(e,r),o=new Set(n),i=s.filter(a=>!o.has(a));return[...n,...i]}function gt(t,e,r){const n=w(t,r),s=w(e,r);return n===s}const y=f.createContext(null);function pt(t){const e=C.c(7),{children:r}=t,[n,s]=f.useState(!1),[o,i]=f.useState(0);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>i(W),e[0]=a):a=e[0];const u=a;let d;e[1]!==n||e[2]!==o?(d={empty:n,setEmpty:s,orderRevision:o,bumpOrderRevision:u},e[1]=n,e[2]=o,e[3]=d):d=e[3];let l;return e[4]!==r||e[5]!==d?(l=K.jsx(y.Provider,{value:d,children:r}),e[4]=r,e[5]=d,e[6]=l):l=e[6],l}function W(t){return t+1}function ht(){return f.useContext(y)?.empty??!1}function Ot(){return f.useContext(y)?.orderRevision??0}function H(){return f.useContext(y)?.bumpOrderRevision??Q}function Q(){}function mt(t){const{value:e}=t,r=f.useContext(y),[n,s]=f.useState(null);return r&&n!==e&&(r.setEmpty(e),s(e)),null}function X(t){return(t??[]).filter(e=>!!e.pinned).map(e=>e.id)}function St(){const t=C.c(9),e=j(),{org:r}=M(),n=F(),{data:s}=N.useSession(),o=s?.user?.id??"anon";let i;t[0]!==n?(i=X(n),t[0]=n,t[1]=i):i=t[1];const a=i,u=H();let d;return t[2]!==u||t[3]!==e||t[4]!==r.id||t[5]!==r.slug||t[6]!==a||t[7]!==o?(d=(l,b)=>{z({orgId:r.id,userId:o},l,a),u();const A=crypto.randomUUID();e({to:"/$org/$taskId",params:{org:r.slug,taskId:A},search:{...b?.search??{},virtualmcpid:l}})},t[2]=u,t[3]=e,t[4]=r.id,t[5]=r.slug,t[6]=a,t[7]=o,t[8]=d):d=t[8],d}export{mt as S,h as T,H as a,z as b,gt as c,ft as d,st as e,nt as f,X as g,it as h,ut as i,Ot as j,rt as k,et as l,St as m,tt as n,ct as o,at as p,dt as q,lt as r,ot as s,pt as t,ht as u};
1
+ import{L as v,r as f,c as C,j as K,b as j,D as M,a as N}from"./index-CFiyU0D9.js";import{u as F}from"./use-virtual-mcp-2U_MnYnK.js";const h="__tool_call_runs__",R=["requires_action","in_progress","failed","expired","completed"];function tt(t){const e=new Map(R.map(r=>[r,[]]));for(const r of t){const n=r.status??"completed";(e.get(n)??e.get("completed")).push(r)}return R.map(r=>({status:r,threads:e.get(r)}))}function et(t,e){const r=new Map;for(const a of t){if(a.id.startsWith("thrd_welcome_"))continue;const u=a.virtual_mcp_id??h,d=r.get(u);d?(d.threads.push(a),(a.updated_at??"")>d.latestUpdatedAt&&(d.latestUpdatedAt=a.updated_at??"")):r.set(u,{virtualMcpId:u,threads:[a],latestUpdatedAt:a.updated_at??""})}const n=e!==null?r.get(e):void 0;n&&e&&r.delete(e);const s=r.get(h);s&&r.delete(h);const o=[...r.values()].sort((a,u)=>u.latestUpdatedAt.localeCompare(a.latestUpdatedAt)),i=[];return e&&i.push(n??{virtualMcpId:e,threads:[],latestUpdatedAt:""}),i.push(...o),s&&s.threads.length>0&&i.push(s),i}function rt(t,e){if(e.size===0)return t;const r=[],n=new Map;for(const s of t){const o=e.get(s.virtualMcpId);if(o){const a=n.get(o);if(a)a.threads=[...a.threads,...s.threads],s.latestUpdatedAt>a.latestUpdatedAt&&(a.latestUpdatedAt=s.latestUpdatedAt);else{const u={virtualMcpId:o,threads:[...s.threads],latestUpdatedAt:s.latestUpdatedAt};n.set(o,u),r.push(u)}continue}const i=n.get(s.virtualMcpId);if(i)i.threads=[...s.threads,...i.threads],s.latestUpdatedAt>i.latestUpdatedAt&&(i.latestUpdatedAt=s.latestUpdatedAt);else{const a={...s,threads:[...s.threads]};n.set(s.virtualMcpId,a),r.push(a)}}return r}const x=new Map,I=new Map;function P(t){return`${t.orgId}:${t.userId}`}function E(t){return`sidebar.group-order.${t}`}function O(t){try{const e=localStorage.getItem(t),r=e?JSON.parse(e):[];return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{return[]}}function T(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function L(t){const e=P(t),r=x.get(e);if(r)return r;const n=v.sidebarGroupOrder(t.orgId,t.userId);let s=!1;try{s=localStorage.getItem(n)!==null}catch{}let o=O(n);if(!s&&o.length===0&&t.userId!=="anon"){const i=O(E(t.orgId));i.length>0&&(o=i)}return x.set(e,o),o}function p(t,e){const r=new Set(e);return L(t).filter(n=>!r.has(n))}function g(t,e){x.set(P(t),e),T(v.sidebarGroupOrder(t.orgId,t.userId),e)}function m(t){const e=I.get(t);if(e)return e;const r=O(v.sidebarOrgPinnedOrder(t));return I.set(t,r),r}function S(t,e){I.set(t,e),T(v.sidebarOrgPinnedOrder(t),e)}function nt(t,e){g(t,e)}function st(t,e){S(t,e)}function k(t,e){return t===e||t===h}function w(t,e){return e.includes(t)}function q(t,e){return t.map(r=>r.virtualMcpId).filter(r=>!k(r,e))}function ot(t,e,r,n){const s=new Set(n);return q(t,r).filter(o=>e==="org"?s.has(o):!s.has(o))}function B(t,e){const r=new Set(t),n=e.filter(s=>!r.has(s));return n.length===0?t:[...t,...n]}function at(t,e,r){const n=new Set(r),s=[],o=[];let i,a;for(const u of t){const d=u.virtualMcpId;if(e&&d===e){i=u;continue}if(d===h){a=u;continue}if(n.has(d)){s.push(u);continue}o.push(u)}return{decopilot:i,orgPinned:s,user:o,toolCallRuns:a}}function $(t,e,r,n=[],s=[]){const o=r?t.find(c=>c.virtualMcpId===r):void 0,i=t.find(c=>c.virtualMcpId===h),a=new Set(n),u=n.filter(c=>!k(c,r)),d=B(s,u),l=e.filter(c=>!a.has(c)),b=new Map(t.map(c=>[c.virtualMcpId,c])),A=c=>{const G=b.get(c);return G||{virtualMcpId:c,threads:[],latestUpdatedAt:""}},_=d.filter(c=>a.has(c)).map(A),D=l.map(A),U=[];return o&&U.push(o),U.push(..._,...D),i&&U.push(i),{groups:U,userOrder:l,orgOrder:_.map(c=>c.virtualMcpId)}}function J(t,e){const r=new Set(e);m(t.orgId).length===0&&e.length>0&&S(t.orgId,[...e]);const s=v.sidebarGroupOrder(t.orgId,t.userId);if(O(s).length>0)return;const o=O(E(t.orgId));if(o.length===0)return;const i=o.filter(a=>!r.has(a));g(t,i)}function Y(t,e){const r=new Set(e),n=L(t),s=n.filter(o=>!r.has(o));s.length!==n.length&&g(t,s)}function it(t,e,r,n=[]){J(t,n),Y(t,n);const s=p(t,n),o=m(t.orgId),{userOrder:i,orgOrder:a}=$(e,s,r,n,o);(i.length!==s.length||i.some((u,d)=>u!==s[d]))&&g(t,i),(a.length!==o.length||a.some((u,d)=>u!==o[d]))&&S(t.orgId,a)}function ut(t,e,r,n=[]){const s=p(t,n),o=m(t.orgId);return $(e,s,r,n,o).groups}function dt(t,e,r){if(r){const o=p(t,[e]).filter(a=>a!==e);g(t,o);const i=m(t.orgId);i.includes(e)||S(t.orgId,[...i,e]);return}const n=m(t.orgId).filter(o=>o!==e);S(t.orgId,n);const s=p(t,[]);s.includes(e)||g(t,[...s,e])}function z(t,e,r=[]){if(r.includes(e))return;const n=p(t,r);n.includes(e)||g(t,[e,...n])}function ct(t,e,r=[]){const n=p(t,r),s=n.filter(o=>o!==e);s.length!==n.length&&g(t,s)}function lt(t,e,r){const n=t.indexOf(e),s=t.indexOf(r);if(n===-1||s===-1||n===s)return t;const o=[...t],[i]=o.splice(n,1);return i===void 0?t:(o.splice(s,0,i),o)}function ft(t,e,r,n){if(t==="org")return n;const s=p(e,r),o=new Set(n),i=s.filter(a=>!o.has(a));return[...n,...i]}function gt(t,e,r){const n=w(t,r),s=w(e,r);return n===s}const y=f.createContext(null);function pt(t){const e=C.c(7),{children:r}=t,[n,s]=f.useState(!1),[o,i]=f.useState(0);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>i(W),e[0]=a):a=e[0];const u=a;let d;e[1]!==n||e[2]!==o?(d={empty:n,setEmpty:s,orderRevision:o,bumpOrderRevision:u},e[1]=n,e[2]=o,e[3]=d):d=e[3];let l;return e[4]!==r||e[5]!==d?(l=K.jsx(y.Provider,{value:d,children:r}),e[4]=r,e[5]=d,e[6]=l):l=e[6],l}function W(t){return t+1}function ht(){return f.useContext(y)?.empty??!1}function Ot(){return f.useContext(y)?.orderRevision??0}function H(){return f.useContext(y)?.bumpOrderRevision??Q}function Q(){}function mt(t){const{value:e}=t,r=f.useContext(y),[n,s]=f.useState(null);return r&&n!==e&&(r.setEmpty(e),s(e)),null}function X(t){return(t??[]).filter(e=>!!e.pinned).map(e=>e.id)}function St(){const t=C.c(9),e=j(),{org:r}=M(),n=F(),{data:s}=N.useSession(),o=s?.user?.id??"anon";let i;t[0]!==n?(i=X(n),t[0]=n,t[1]=i):i=t[1];const a=i,u=H();let d;return t[2]!==u||t[3]!==e||t[4]!==r.id||t[5]!==r.slug||t[6]!==a||t[7]!==o?(d=(l,b)=>{z({orgId:r.id,userId:o},l,a),u();const A=crypto.randomUUID();e({to:"/$org/$taskId",params:{org:r.slug,taskId:A},search:{...b?.search??{},virtualmcpid:l}})},t[2]=u,t[3]=e,t[4]=r.id,t[5]=r.slug,t[6]=a,t[7]=o,t[8]=d):d=t[8],d}export{mt as S,h as T,H as a,z as b,gt as c,ft as d,st as e,nt as f,X as g,it as h,ut as i,Ot as j,rt as k,et as l,St as m,tt as n,ct as o,at as p,dt as q,lt as r,ot as s,pt as t,ht as u};
@@ -1 +1 @@
1
- import{c as x,D as j,a as i}from"./index-DmjWDqcd.js";function A(){const e=x.c(32),{org:O}=j(),o=O.id;let z;e[0]!==o?(z=R=>(f=>i.organization[R]({...f??{},organizationId:o})),e[0]=o,e[1]=z):z=e[1];const t=z;let M;e[2]!==o?(M=R=>(f=>{const y={...f??{}},h=y.query??{};return y.query={...h,organizationId:o},i.organization[R](y)}),e[2]=o,e[3]=M):M=e[3];const n=M;let a,r;e[4]!==n?(a=n("listMembers"),r=n("listRoles"),e[4]=n,e[5]=a,e[6]=r):(a=e[5],r=e[6]);let l,s,c,g,u,m,d,v,b;e[7]!==t?(g=t("inviteMember"),u=t("removeMember"),m=t("updateMemberRole"),d=t("addMember"),v=t("createRole"),b=t("updateRole"),l=t("deleteRole"),s=t("cancelInvitation"),c=t("update"),e[7]=t,e[8]=l,e[9]=s,e[10]=c,e[11]=g,e[12]=u,e[13]=m,e[14]=d,e[15]=v,e[16]=b):(l=e[8],s=e[9],c=e[10],g=e[11],u=e[12],m=e[13],d=e[14],v=e[15],b=e[16]);let p;e[17]!==n?(p=n("getActiveMember"),e[17]=n,e[18]=p):p=e[18];let I;return e[19]!==l||e[20]!==s||e[21]!==c||e[22]!==p||e[23]!==a||e[24]!==r||e[25]!==g||e[26]!==u||e[27]!==m||e[28]!==d||e[29]!==v||e[30]!==b?(I={organization:{listMembers:a,listRoles:r,inviteMember:g,removeMember:u,updateMemberRole:m,addMember:d,createRole:v,updateRole:b,deleteRole:l,cancelInvitation:s,update:c,getActiveMember:p,acceptInvitation:i.organization.acceptInvitation,rejectInvitation:i.organization.rejectInvitation,getInvitation:i.organization.getInvitation,list:i.organization.list,create:i.organization.create,getFullOrganization:i.organization.getFullOrganization}},e[19]=l,e[20]=s,e[21]=c,e[22]=p,e[23]=a,e[24]=r,e[25]=g,e[26]=u,e[27]=m,e[28]=d,e[29]=v,e[30]=b,e[31]=I):I=e[31],I}export{A as u};
1
+ import{c as x,D as j,a as i}from"./index-CFiyU0D9.js";function A(){const e=x.c(32),{org:O}=j(),o=O.id;let z;e[0]!==o?(z=R=>(f=>i.organization[R]({...f??{},organizationId:o})),e[0]=o,e[1]=z):z=e[1];const t=z;let M;e[2]!==o?(M=R=>(f=>{const y={...f??{}},h=y.query??{};return y.query={...h,organizationId:o},i.organization[R](y)}),e[2]=o,e[3]=M):M=e[3];const n=M;let a,r;e[4]!==n?(a=n("listMembers"),r=n("listRoles"),e[4]=n,e[5]=a,e[6]=r):(a=e[5],r=e[6]);let l,s,c,g,u,m,d,v,b;e[7]!==t?(g=t("inviteMember"),u=t("removeMember"),m=t("updateMemberRole"),d=t("addMember"),v=t("createRole"),b=t("updateRole"),l=t("deleteRole"),s=t("cancelInvitation"),c=t("update"),e[7]=t,e[8]=l,e[9]=s,e[10]=c,e[11]=g,e[12]=u,e[13]=m,e[14]=d,e[15]=v,e[16]=b):(l=e[8],s=e[9],c=e[10],g=e[11],u=e[12],m=e[13],d=e[14],v=e[15],b=e[16]);let p;e[17]!==n?(p=n("getActiveMember"),e[17]=n,e[18]=p):p=e[18];let I;return e[19]!==l||e[20]!==s||e[21]!==c||e[22]!==p||e[23]!==a||e[24]!==r||e[25]!==g||e[26]!==u||e[27]!==m||e[28]!==d||e[29]!==v||e[30]!==b?(I={organization:{listMembers:a,listRoles:r,inviteMember:g,removeMember:u,updateMemberRole:m,addMember:d,createRole:v,updateRole:b,deleteRole:l,cancelInvitation:s,update:c,getActiveMember:p,acceptInvitation:i.organization.acceptInvitation,rejectInvitation:i.organization.rejectInvitation,getInvitation:i.organization.getInvitation,list:i.organization.list,create:i.organization.create,getFullOrganization:i.organization.getFullOrganization}},e[19]=l,e[20]=s,e[21]=c,e[22]=p,e[23]=a,e[24]=r,e[25]=g,e[26]=u,e[27]=m,e[28]=d,e[29]=v,e[30]=b,e[31]=I):I=e[31],I}export{A as u};
@@ -1 +1 @@
1
- import{c as F,D as w,m as b,d as k,K as h,k as $,b1 as q}from"./index-DmjWDqcd.js";function x(s){return s.contentHash??`${s.size}-${s.updatedAt}`}function p(s,e,t,n){const r=new URLSearchParams(n).toString();return`/api/${encodeURIComponent(s)}/fs/${encodeURIComponent(e)}/${t}${r?`?${r}`:""}`}async function y(s,e){const t=await fetch(s,e);if(!t.ok){let n="";try{n=(await t.json()).error??""}catch{}throw new Error(n||`HTTP ${t.status}`)}return t}function D(s,e){const t=F.c(11),{org:n}=w();let r;t[0]!==n.id||t[1]!==e||t[2]!==s?(r=h.orgFsList(n.id,s,e),t[0]=n.id,t[1]=e,t[2]=s,t[3]=r):r=t[3];let i;t[4]!==n.slug||t[5]!==e||t[6]!==s?(i=async()=>(await(await y(p(n.slug,s,"list",{path:e}))).json()).entries.toSorted(P),t[4]=n.slug,t[5]=e,t[6]=s,t[7]=i):i=t[7];let a;return t[8]!==r||t[9]!==i?(a={queryKey:r,placeholderData:q,queryFn:i},t[8]=r,t[9]=i,t[10]=a):a=t[10],$(a)}function P(s,e){return s.kind!==e.kind?s.kind==="dir"?-1:1:s.path.localeCompare(e.path)}function M(s,e,t){const n=F.c(15),{org:r}=w();let i;n[0]!==r.id||n[1]!==e||n[2]!==s?(i=h.orgFsStat(r.id,s??"",e),n[0]=r.id,n[1]=e,n[2]=s,n[3]=i):i=n[3];const a=s!==null;let o;n[4]!==t?(o=t?.refetchIntervalWhenAbsent?d=>d.state.data?!1:t.refetchIntervalWhenAbsent??!1:void 0,n[4]=t,n[5]=o):o=n[5];let c;n[6]!==r.slug||n[7]!==e||n[8]!==s?(c=async()=>{const d=await fetch(p(r.slug,s??"","stat",{path:e}));if(d.status===404)return null;if(!d.ok)throw new Error(`HTTP ${d.status}`);return(await d.json()).entry},n[6]=r.slug,n[7]=e,n[8]=s,n[9]=c):c=n[9];let u;return n[10]!==i||n[11]!==a||n[12]!==o||n[13]!==c?(u={queryKey:i,enabled:a,refetchInterval:o,queryFn:c},n[10]=i,n[11]=a,n[12]=o,n[13]=c,n[14]=u):u=n[14],$(u)}function A(s){const e=F.c(9),{org:t}=w();let n;e[0]!==t.id||e[1]!==s?(n=h.orgFsUsage(t.id,s),e[0]=t.id,e[1]=s,e[2]=n):n=e[2];let r;e[3]!==t.slug||e[4]!==s?(r=async()=>await(await y(p(t.slug,s,"usage"))).json(),e[3]=t.slug,e[4]=s,e[5]=r):r=e[5];let i;return e[6]!==n||e[7]!==r?(i={queryKey:n,queryFn:r},e[6]=n,e[7]=r,e[8]=i):i=e[8],$(i)}function N(s,e){const t=F.c(9),n=s===void 0?60:s,{org:r}=w();let i;t[0]!==r.id?(i=h.orgFsRecent(r.id),t[0]=r.id,t[1]=i):i=t[1];const a=e?.enabled;let o;t[2]!==n||t[3]!==r.slug?(o=async()=>(await(await y(`/api/${encodeURIComponent(r.slug)}/fs/recent?limit=${n}`)).json()).entries,t[2]=n,t[3]=r.slug,t[4]=o):o=t[4];let c;return t[5]!==i||t[6]!==a||t[7]!==o?(c={queryKey:i,enabled:a,queryFn:o},t[5]=i,t[6]=a,t[7]=o,t[8]=c):c=t[8],$(c)}function X(s,e){const t=F.c(11),n=50,{org:r}=w();let i;t[0]!==r.id||t[1]!==s?(i=h.orgFsSearch(r.id,s),t[0]=r.id,t[1]=s,t[2]=i):i=t[2];const a=s.length>0;let o;t[3]!==n||t[4]!==r.slug||t[5]!==s?(o=async()=>(await(await y(`/api/${encodeURIComponent(r.slug)}/fs/search?q=${encodeURIComponent(s)}&limit=${n}`)).json()).entries,t[3]=n,t[4]=r.slug,t[5]=s,t[6]=o):o=t[6];let c;return t[7]!==i||t[8]!==a||t[9]!==o?(c={queryKey:i,enabled:a,placeholderData:q,queryFn:o},t[7]=i,t[8]=a,t[9]=o,t[10]=c):c=t[10],$(c)}function H(s){const e=F.c(8),{org:t}=w();let n;e[0]!==t.id?(n=h.orgFsSkills(t.id),e[0]=t.id,e[1]=n):n=e[1];const r=s?.enabled;let i;e[2]!==t.slug?(i=async()=>{const o=await y(`/api/${encodeURIComponent(t.slug)}/fs/skills`),{skills:c}=await o.json();return c.map(T)},e[2]=t.slug,e[3]=i):i=e[3];let a;return e[4]!==n||e[5]!==r||e[6]!==i?(a={queryKey:n,enabled:r,queryFn:i},e[4]=n,e[5]=r,e[6]=i,e[7]=a):a=e[7],$(a)}function T(s){return{volume:s.volume,path:s.path}}async function W(s){const e=await y(`/api/${encodeURIComponent(s)}/fs/skills`),{skills:t}=await e.json();return t}async function C(s,e,t){return(await y(p(s,e,"read",{path:t}))).text()}const m=new Set(["md","mdx","markdown","txt","text"]),E=25,_=64*1024,R=256*1024,U=4;function j(s){const e=s.lastIndexOf(".");return e===-1?!1:m.has(s.slice(e+1).toLowerCase())}async function Y(s,e,t){const n=t?`${t}/`:"",r=l=>l.startsWith(n)?l.slice(n.length):l,i=[],a=[],o=[{path:t,depth:0}];for(;o.length>0;){const l=o.shift();if(!l)break;let g;try{g=(await(await y(p(s,e,"list",{path:l.path}))).json()).entries}catch{continue}for(const f of[...g].sort((K,I)=>K.path.localeCompare(I.path))){if(f.kind==="dir"){l.depth<U&&o.push({path:f.path,depth:l.depth+1});continue}j(f.path)&&f.size<=_&&i.length<E?i.push(f.path):a.push(r(f.path))}}const c=await Promise.all(i.map(l=>C(s,e,l).catch(()=>null))),u=[];let d=0;return i.forEach((l,g)=>{const f=c[g];if(f==null||d+f.length>R){a.push(r(l));return}d+=f.length,u.push({relPath:r(l),content:f})}),u.sort((l,g)=>l.relPath==="SKILL.md"?-1:g.relPath==="SKILL.md"?1:l.relPath.localeCompare(g.relPath)),a.sort(),{files:u,omittedPaths:a}}function z(){const s=F.c(7),{org:e}=w();let t;s[0]!==e.id?(t=h.orgFsPublicSets(e.id),s[0]=e.id,s[1]=t):t=s[1];let n;s[2]!==e.slug?(n=async()=>(await(await y(`/api/${encodeURIComponent(e.slug)}/fs/public-sets`)).json()).sets,s[2]=e.slug,s[3]=n):n=s[3];let r;return s[4]!==t||s[5]!==n?(r={queryKey:t,staleTime:3e5,queryFn:n},s[4]=t,s[5]=n,s[6]=r):r=s[6],$(r)}function B(s){const e=F.c(3),{org:t}=w();let n;return e[0]!==t.slug||e[1]!==s?(n=r=>p(t.slug,s,"read",{path:r}),e[0]=t.slug,e[1]=s,e[2]=n):n=e[2],n}function V(){const s=F.c(2),{org:e}=w();let t;return s[0]!==e.slug?(t=(n,r)=>p(e.slug,n,"read",{path:r}),s[0]=e.slug,s[1]=t):t=s[1],t}function J(s){const e=F.c(3),{org:t}=w();let n;return e[0]!==t||e[1]!==s?(n={mutationFn:async r=>(await(await y(p(t.slug,s,"file",{path:r.path}),{method:"PUT",headers:{"content-type":r.contentType??"text/html; charset=utf-8"},body:r.body})).json()).entry},e[0]=t,e[1]=s,e[2]=n):n=e[2],k(n)}function G(s){const e=F.c(18),{org:t}=w(),n=b();let r;e[0]!==t||e[1]!==s?(r=async u=>(await(await y(p(t.slug,s,"public",{path:u.path}),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({mode:u.mode,password:u.password})})).json()).entry,e[0]=t,e[1]=s,e[2]=r):r=e[2];let i;e[3]!==t||e[4]!==n||e[5]!==s?(i=async u=>{const d=h.orgFsStat(t.id,s,u.path);await n.cancelQueries({queryKey:d});const l=n.getQueryData(d),g=u.mode!=="private";return n.setQueryData(d,f=>f&&{...f,readPublic:g,effectivePublic:g,shareMode:u.mode}),{key:d,previous:l}},e[3]=t,e[4]=n,e[5]=s,e[6]=i):i=e[6];let a;e[7]!==n?(a=(u,d,l)=>{l&&n.setQueryData(l.key,l.previous)},e[7]=n,e[8]=a):a=e[8];let o;e[9]!==t||e[10]!==n||e[11]!==s?(o=(u,d,l)=>{n.invalidateQueries({queryKey:h.orgFsStat(t.id,s,l.path)}),n.invalidateQueries({queryKey:h.orgFsVolume(t.id,s)}),n.invalidateQueries({queryKey:h.orgFsRecent(t.id)}),n.invalidateQueries({queryKey:h.orgFsSearchRoot(t.id)})},e[9]=t,e[10]=n,e[11]=s,e[12]=o):o=e[12];let c;return e[13]!==r||e[14]!==i||e[15]!==a||e[16]!==o?(c={mutationFn:r,onMutate:i,onError:a,onSettled:o},e[13]=r,e[14]=i,e[15]=a,e[16]=o,e[17]=c):c=e[17],k(c)}function Z(s){const e=F.c(26),{org:t}=w(),n=b();let r;e[0]!==t||e[1]!==n||e[2]!==s?(r=()=>{n.invalidateQueries({queryKey:h.orgFsVolume(t.id,s)}),n.invalidateQueries({queryKey:h.orgFsRecent(t.id)}),n.invalidateQueries({queryKey:h.orgFsSearchRoot(t.id)})},e[0]=t,e[1]=n,e[2]=s,e[3]=r):r=e[3];const i=r;let a;e[4]!==t||e[5]!==s?(a=async S=>{for(const L of S.files){const O=S.dir?`${S.dir}/${L.name}`:L.name;await y(p(t.slug,s,"file",{path:O}),{method:"PUT",headers:{"content-type":L.type||"application/octet-stream"},body:L})}},e[4]=t,e[5]=s,e[6]=a):a=e[6];let o;e[7]!==i||e[8]!==a?(o={mutationFn:a,onSettled:i},e[7]=i,e[8]=a,e[9]=o):o=e[9];const c=k(o);let u;e[10]!==t||e[11]!==s?(u=async S=>{await y(p(t.slug,s,"dir",{path:S}),{method:"POST"})},e[10]=t,e[11]=s,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==u?(d={mutationFn:u,onSuccess:i},e[13]=i,e[14]=u,e[15]=d):d=e[15];const l=k(d);let g;e[16]!==t||e[17]!==s?(g=async S=>{await y(p(t.slug,s,"file",{path:S}),{method:"DELETE"})},e[16]=t,e[17]=s,e[18]=g):g=e[18];let f;e[19]!==i||e[20]!==g?(f={mutationFn:g,onSuccess:i},e[19]=i,e[20]=g,e[21]=f):f=e[21];const K=k(f);let I;return e[22]!==l||e[23]!==K||e[24]!==c?(I={upload:c,mkdir:l,remove:K},e[22]=l,e[23]=K,e[24]=c,e[25]=I):I=e[25],I}export{V as a,N as b,H as c,M as d,B as e,x as f,Y as g,W as h,J as i,D as j,X as k,z as l,A as m,G as n,Z as u};
1
+ import{c as F,D as w,m as b,d as k,K as h,k as $,b1 as q}from"./index-CFiyU0D9.js";function x(s){return s.contentHash??`${s.size}-${s.updatedAt}`}function p(s,e,t,n){const r=new URLSearchParams(n).toString();return`/api/${encodeURIComponent(s)}/fs/${encodeURIComponent(e)}/${t}${r?`?${r}`:""}`}async function y(s,e){const t=await fetch(s,e);if(!t.ok){let n="";try{n=(await t.json()).error??""}catch{}throw new Error(n||`HTTP ${t.status}`)}return t}function D(s,e){const t=F.c(11),{org:n}=w();let r;t[0]!==n.id||t[1]!==e||t[2]!==s?(r=h.orgFsList(n.id,s,e),t[0]=n.id,t[1]=e,t[2]=s,t[3]=r):r=t[3];let i;t[4]!==n.slug||t[5]!==e||t[6]!==s?(i=async()=>(await(await y(p(n.slug,s,"list",{path:e}))).json()).entries.toSorted(P),t[4]=n.slug,t[5]=e,t[6]=s,t[7]=i):i=t[7];let a;return t[8]!==r||t[9]!==i?(a={queryKey:r,placeholderData:q,queryFn:i},t[8]=r,t[9]=i,t[10]=a):a=t[10],$(a)}function P(s,e){return s.kind!==e.kind?s.kind==="dir"?-1:1:s.path.localeCompare(e.path)}function M(s,e,t){const n=F.c(15),{org:r}=w();let i;n[0]!==r.id||n[1]!==e||n[2]!==s?(i=h.orgFsStat(r.id,s??"",e),n[0]=r.id,n[1]=e,n[2]=s,n[3]=i):i=n[3];const a=s!==null;let o;n[4]!==t?(o=t?.refetchIntervalWhenAbsent?d=>d.state.data?!1:t.refetchIntervalWhenAbsent??!1:void 0,n[4]=t,n[5]=o):o=n[5];let c;n[6]!==r.slug||n[7]!==e||n[8]!==s?(c=async()=>{const d=await fetch(p(r.slug,s??"","stat",{path:e}));if(d.status===404)return null;if(!d.ok)throw new Error(`HTTP ${d.status}`);return(await d.json()).entry},n[6]=r.slug,n[7]=e,n[8]=s,n[9]=c):c=n[9];let u;return n[10]!==i||n[11]!==a||n[12]!==o||n[13]!==c?(u={queryKey:i,enabled:a,refetchInterval:o,queryFn:c},n[10]=i,n[11]=a,n[12]=o,n[13]=c,n[14]=u):u=n[14],$(u)}function A(s){const e=F.c(9),{org:t}=w();let n;e[0]!==t.id||e[1]!==s?(n=h.orgFsUsage(t.id,s),e[0]=t.id,e[1]=s,e[2]=n):n=e[2];let r;e[3]!==t.slug||e[4]!==s?(r=async()=>await(await y(p(t.slug,s,"usage"))).json(),e[3]=t.slug,e[4]=s,e[5]=r):r=e[5];let i;return e[6]!==n||e[7]!==r?(i={queryKey:n,queryFn:r},e[6]=n,e[7]=r,e[8]=i):i=e[8],$(i)}function N(s,e){const t=F.c(9),n=s===void 0?60:s,{org:r}=w();let i;t[0]!==r.id?(i=h.orgFsRecent(r.id),t[0]=r.id,t[1]=i):i=t[1];const a=e?.enabled;let o;t[2]!==n||t[3]!==r.slug?(o=async()=>(await(await y(`/api/${encodeURIComponent(r.slug)}/fs/recent?limit=${n}`)).json()).entries,t[2]=n,t[3]=r.slug,t[4]=o):o=t[4];let c;return t[5]!==i||t[6]!==a||t[7]!==o?(c={queryKey:i,enabled:a,queryFn:o},t[5]=i,t[6]=a,t[7]=o,t[8]=c):c=t[8],$(c)}function X(s,e){const t=F.c(11),n=50,{org:r}=w();let i;t[0]!==r.id||t[1]!==s?(i=h.orgFsSearch(r.id,s),t[0]=r.id,t[1]=s,t[2]=i):i=t[2];const a=s.length>0;let o;t[3]!==n||t[4]!==r.slug||t[5]!==s?(o=async()=>(await(await y(`/api/${encodeURIComponent(r.slug)}/fs/search?q=${encodeURIComponent(s)}&limit=${n}`)).json()).entries,t[3]=n,t[4]=r.slug,t[5]=s,t[6]=o):o=t[6];let c;return t[7]!==i||t[8]!==a||t[9]!==o?(c={queryKey:i,enabled:a,placeholderData:q,queryFn:o},t[7]=i,t[8]=a,t[9]=o,t[10]=c):c=t[10],$(c)}function H(s){const e=F.c(8),{org:t}=w();let n;e[0]!==t.id?(n=h.orgFsSkills(t.id),e[0]=t.id,e[1]=n):n=e[1];const r=s?.enabled;let i;e[2]!==t.slug?(i=async()=>{const o=await y(`/api/${encodeURIComponent(t.slug)}/fs/skills`),{skills:c}=await o.json();return c.map(T)},e[2]=t.slug,e[3]=i):i=e[3];let a;return e[4]!==n||e[5]!==r||e[6]!==i?(a={queryKey:n,enabled:r,queryFn:i},e[4]=n,e[5]=r,e[6]=i,e[7]=a):a=e[7],$(a)}function T(s){return{volume:s.volume,path:s.path}}async function W(s){const e=await y(`/api/${encodeURIComponent(s)}/fs/skills`),{skills:t}=await e.json();return t}async function C(s,e,t){return(await y(p(s,e,"read",{path:t}))).text()}const m=new Set(["md","mdx","markdown","txt","text"]),E=25,_=64*1024,R=256*1024,U=4;function j(s){const e=s.lastIndexOf(".");return e===-1?!1:m.has(s.slice(e+1).toLowerCase())}async function Y(s,e,t){const n=t?`${t}/`:"",r=l=>l.startsWith(n)?l.slice(n.length):l,i=[],a=[],o=[{path:t,depth:0}];for(;o.length>0;){const l=o.shift();if(!l)break;let g;try{g=(await(await y(p(s,e,"list",{path:l.path}))).json()).entries}catch{continue}for(const f of[...g].sort((K,I)=>K.path.localeCompare(I.path))){if(f.kind==="dir"){l.depth<U&&o.push({path:f.path,depth:l.depth+1});continue}j(f.path)&&f.size<=_&&i.length<E?i.push(f.path):a.push(r(f.path))}}const c=await Promise.all(i.map(l=>C(s,e,l).catch(()=>null))),u=[];let d=0;return i.forEach((l,g)=>{const f=c[g];if(f==null||d+f.length>R){a.push(r(l));return}d+=f.length,u.push({relPath:r(l),content:f})}),u.sort((l,g)=>l.relPath==="SKILL.md"?-1:g.relPath==="SKILL.md"?1:l.relPath.localeCompare(g.relPath)),a.sort(),{files:u,omittedPaths:a}}function z(){const s=F.c(7),{org:e}=w();let t;s[0]!==e.id?(t=h.orgFsPublicSets(e.id),s[0]=e.id,s[1]=t):t=s[1];let n;s[2]!==e.slug?(n=async()=>(await(await y(`/api/${encodeURIComponent(e.slug)}/fs/public-sets`)).json()).sets,s[2]=e.slug,s[3]=n):n=s[3];let r;return s[4]!==t||s[5]!==n?(r={queryKey:t,staleTime:3e5,queryFn:n},s[4]=t,s[5]=n,s[6]=r):r=s[6],$(r)}function B(s){const e=F.c(3),{org:t}=w();let n;return e[0]!==t.slug||e[1]!==s?(n=r=>p(t.slug,s,"read",{path:r}),e[0]=t.slug,e[1]=s,e[2]=n):n=e[2],n}function V(){const s=F.c(2),{org:e}=w();let t;return s[0]!==e.slug?(t=(n,r)=>p(e.slug,n,"read",{path:r}),s[0]=e.slug,s[1]=t):t=s[1],t}function J(s){const e=F.c(3),{org:t}=w();let n;return e[0]!==t||e[1]!==s?(n={mutationFn:async r=>(await(await y(p(t.slug,s,"file",{path:r.path}),{method:"PUT",headers:{"content-type":r.contentType??"text/html; charset=utf-8"},body:r.body})).json()).entry},e[0]=t,e[1]=s,e[2]=n):n=e[2],k(n)}function G(s){const e=F.c(18),{org:t}=w(),n=b();let r;e[0]!==t||e[1]!==s?(r=async u=>(await(await y(p(t.slug,s,"public",{path:u.path}),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({mode:u.mode,password:u.password})})).json()).entry,e[0]=t,e[1]=s,e[2]=r):r=e[2];let i;e[3]!==t||e[4]!==n||e[5]!==s?(i=async u=>{const d=h.orgFsStat(t.id,s,u.path);await n.cancelQueries({queryKey:d});const l=n.getQueryData(d),g=u.mode!=="private";return n.setQueryData(d,f=>f&&{...f,readPublic:g,effectivePublic:g,shareMode:u.mode}),{key:d,previous:l}},e[3]=t,e[4]=n,e[5]=s,e[6]=i):i=e[6];let a;e[7]!==n?(a=(u,d,l)=>{l&&n.setQueryData(l.key,l.previous)},e[7]=n,e[8]=a):a=e[8];let o;e[9]!==t||e[10]!==n||e[11]!==s?(o=(u,d,l)=>{n.invalidateQueries({queryKey:h.orgFsStat(t.id,s,l.path)}),n.invalidateQueries({queryKey:h.orgFsVolume(t.id,s)}),n.invalidateQueries({queryKey:h.orgFsRecent(t.id)}),n.invalidateQueries({queryKey:h.orgFsSearchRoot(t.id)})},e[9]=t,e[10]=n,e[11]=s,e[12]=o):o=e[12];let c;return e[13]!==r||e[14]!==i||e[15]!==a||e[16]!==o?(c={mutationFn:r,onMutate:i,onError:a,onSettled:o},e[13]=r,e[14]=i,e[15]=a,e[16]=o,e[17]=c):c=e[17],k(c)}function Z(s){const e=F.c(26),{org:t}=w(),n=b();let r;e[0]!==t||e[1]!==n||e[2]!==s?(r=()=>{n.invalidateQueries({queryKey:h.orgFsVolume(t.id,s)}),n.invalidateQueries({queryKey:h.orgFsRecent(t.id)}),n.invalidateQueries({queryKey:h.orgFsSearchRoot(t.id)})},e[0]=t,e[1]=n,e[2]=s,e[3]=r):r=e[3];const i=r;let a;e[4]!==t||e[5]!==s?(a=async S=>{for(const L of S.files){const O=S.dir?`${S.dir}/${L.name}`:L.name;await y(p(t.slug,s,"file",{path:O}),{method:"PUT",headers:{"content-type":L.type||"application/octet-stream"},body:L})}},e[4]=t,e[5]=s,e[6]=a):a=e[6];let o;e[7]!==i||e[8]!==a?(o={mutationFn:a,onSettled:i},e[7]=i,e[8]=a,e[9]=o):o=e[9];const c=k(o);let u;e[10]!==t||e[11]!==s?(u=async S=>{await y(p(t.slug,s,"dir",{path:S}),{method:"POST"})},e[10]=t,e[11]=s,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==u?(d={mutationFn:u,onSuccess:i},e[13]=i,e[14]=u,e[15]=d):d=e[15];const l=k(d);let g;e[16]!==t||e[17]!==s?(g=async S=>{await y(p(t.slug,s,"file",{path:S}),{method:"DELETE"})},e[16]=t,e[17]=s,e[18]=g):g=e[18];let f;e[19]!==i||e[20]!==g?(f={mutationFn:g,onSuccess:i},e[19]=i,e[20]=g,e[21]=f):f=e[21];const K=k(f);let I;return e[22]!==l||e[23]!==K||e[24]!==c?(I={upload:c,mkdir:l,remove:K},e[22]=l,e[23]=K,e[24]=c,e[25]=I):I=e[25],I}export{V as a,N as b,H as c,M as d,B as e,x as f,Y as g,W as h,J as i,D as j,X as k,z as l,A as m,G as n,Z as u};
@@ -1 +1 @@
1
- import{c as u,k as S,m as l,d as y,K as c}from"./index-DmjWDqcd.js";function w(o,a){const e=u.c(8);let s;e[0]!==o?(s=c.orgSsoStatus(o??""),e[0]=o,e[1]=s):s=e[1];let t;e[2]!==a?(t=async()=>{const r=await fetch(`/api/${a}/sso/status`);if(!r.ok)throw new Error("Failed to check SSO status");return r.json()},e[2]=a,e[3]=t):t=e[3];const n=!!o&&!!a;let i;return e[4]!==s||e[5]!==t||e[6]!==n?(i={queryKey:s,queryFn:t,enabled:n},e[4]=s,e[5]=t,e[6]=n,e[7]=i):i=e[7],S(i)}function m(o,a){const e=u.c(8);let s;e[0]!==o?(s=c.orgSsoConfig(o??""),e[0]=o,e[1]=s):s=e[1];let t;e[2]!==a?(t=async()=>{const r=await fetch(`/api/${a}/sso/config`);if(!r.ok)throw new Error("Failed to fetch SSO config");return r.json()},e[2]=a,e[3]=t):t=e[3];const n=!!o&&!!a;let i;return e[4]!==s||e[5]!==t||e[6]!==n?(i={queryKey:s,queryFn:t,enabled:n},e[4]=s,e[5]=t,e[6]=n,e[7]=i):i=e[7],S(i)}function q(o,a){const e=u.c(8),s=l();let t;e[0]!==a?(t=async r=>{const f=await fetch(`/api/${a}/sso/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!f.ok){const p=await f.json();throw new Error(p.error||"Failed to save SSO config")}return f.json()},e[0]=a,e[1]=t):t=e[1];let n;e[2]!==o||e[3]!==s?(n=()=>{s.invalidateQueries({queryKey:c.orgSsoConfig(o)}),s.invalidateQueries({queryKey:c.orgSsoStatus(o)})},e[2]=o,e[3]=s,e[4]=n):n=e[4];let i;return e[5]!==t||e[6]!==n?(i={mutationFn:t,onSuccess:n},e[5]=t,e[6]=n,e[7]=i):i=e[7],y(i)}function C(o,a){const e=u.c(8),s=l();let t;e[0]!==a?(t=async()=>{const r=await fetch(`/api/${a}/sso/config`,{method:"DELETE"});if(!r.ok)throw new Error("Failed to delete SSO config");return r.json()},e[0]=a,e[1]=t):t=e[1];let n;e[2]!==o||e[3]!==s?(n=()=>{s.invalidateQueries({queryKey:c.orgSsoConfig(o)}),s.invalidateQueries({queryKey:c.orgSsoStatus(o)})},e[2]=o,e[3]=s,e[4]=n):n=e[4];let i;return e[5]!==t||e[6]!==n?(i={mutationFn:t,onSuccess:n},e[5]=t,e[6]=n,e[7]=i):i=e[7],y(i)}function O(o,a){const e=u.c(8),s=l();let t;e[0]!==a?(t=async r=>{const f=await fetch(`/api/${a}/sso/config/enforce`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enforced:r})});if(!f.ok)throw new Error("Failed to toggle SSO enforcement");return f.json()},e[0]=a,e[1]=t):t=e[1];let n;e[2]!==o||e[3]!==s?(n=()=>{s.invalidateQueries({queryKey:c.orgSsoConfig(o)}),s.invalidateQueries({queryKey:c.orgSsoStatus(o)})},e[2]=o,e[3]=s,e[4]=n):n=e[4];let i;return e[5]!==t||e[6]!==n?(i={mutationFn:t,onSuccess:n},e[5]=t,e[6]=n,e[7]=i):i=e[7],y(i)}export{m as a,q as b,C as c,O as d,w as u};
1
+ import{c as u,k as S,m as l,d as y,K as c}from"./index-CFiyU0D9.js";function w(o,a){const e=u.c(8);let s;e[0]!==o?(s=c.orgSsoStatus(o??""),e[0]=o,e[1]=s):s=e[1];let t;e[2]!==a?(t=async()=>{const r=await fetch(`/api/${a}/sso/status`);if(!r.ok)throw new Error("Failed to check SSO status");return r.json()},e[2]=a,e[3]=t):t=e[3];const n=!!o&&!!a;let i;return e[4]!==s||e[5]!==t||e[6]!==n?(i={queryKey:s,queryFn:t,enabled:n},e[4]=s,e[5]=t,e[6]=n,e[7]=i):i=e[7],S(i)}function m(o,a){const e=u.c(8);let s;e[0]!==o?(s=c.orgSsoConfig(o??""),e[0]=o,e[1]=s):s=e[1];let t;e[2]!==a?(t=async()=>{const r=await fetch(`/api/${a}/sso/config`);if(!r.ok)throw new Error("Failed to fetch SSO config");return r.json()},e[2]=a,e[3]=t):t=e[3];const n=!!o&&!!a;let i;return e[4]!==s||e[5]!==t||e[6]!==n?(i={queryKey:s,queryFn:t,enabled:n},e[4]=s,e[5]=t,e[6]=n,e[7]=i):i=e[7],S(i)}function q(o,a){const e=u.c(8),s=l();let t;e[0]!==a?(t=async r=>{const f=await fetch(`/api/${a}/sso/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!f.ok){const p=await f.json();throw new Error(p.error||"Failed to save SSO config")}return f.json()},e[0]=a,e[1]=t):t=e[1];let n;e[2]!==o||e[3]!==s?(n=()=>{s.invalidateQueries({queryKey:c.orgSsoConfig(o)}),s.invalidateQueries({queryKey:c.orgSsoStatus(o)})},e[2]=o,e[3]=s,e[4]=n):n=e[4];let i;return e[5]!==t||e[6]!==n?(i={mutationFn:t,onSuccess:n},e[5]=t,e[6]=n,e[7]=i):i=e[7],y(i)}function C(o,a){const e=u.c(8),s=l();let t;e[0]!==a?(t=async()=>{const r=await fetch(`/api/${a}/sso/config`,{method:"DELETE"});if(!r.ok)throw new Error("Failed to delete SSO config");return r.json()},e[0]=a,e[1]=t):t=e[1];let n;e[2]!==o||e[3]!==s?(n=()=>{s.invalidateQueries({queryKey:c.orgSsoConfig(o)}),s.invalidateQueries({queryKey:c.orgSsoStatus(o)})},e[2]=o,e[3]=s,e[4]=n):n=e[4];let i;return e[5]!==t||e[6]!==n?(i={mutationFn:t,onSuccess:n},e[5]=t,e[6]=n,e[7]=i):i=e[7],y(i)}function O(o,a){const e=u.c(8),s=l();let t;e[0]!==a?(t=async r=>{const f=await fetch(`/api/${a}/sso/config/enforce`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enforced:r})});if(!f.ok)throw new Error("Failed to toggle SSO enforcement");return f.json()},e[0]=a,e[1]=t):t=e[1];let n;e[2]!==o||e[3]!==s?(n=()=>{s.invalidateQueries({queryKey:c.orgSsoConfig(o)}),s.invalidateQueries({queryKey:c.orgSsoStatus(o)})},e[2]=o,e[3]=s,e[4]=n):n=e[4];let i;return e[5]!==t||e[6]!==n?(i={mutationFn:t,onSuccess:n},e[5]=t,e[6]=n,e[7]=i):i=e[7],y(i)}export{m as a,q as b,C as c,O as d,w as u};
@@ -1 +1 @@
1
- import{c as S,j as n,l as v,D as T,k as B,K as P}from"./index-DmjWDqcd.js";import{e as k,d as I,a as A,T as L,b as z,c as O}from"./table-C4Cy5HHY.js";import{a as K,n as D}from"./SwitchHorizontal01-CtPAye2M.js";import{u as E}from"./use-org-auth-client-a0tV0I4a.js";function H(h){const e=S.c(29),{columns:t,data:m,sortKey:p,sortDirection:d,onSort:o,onRowClick:a,rowClassName:s}=h;let l;e[0]!==d?(l=function(r,N){return n.jsx("div",{className:"w-4 flex items-center justify-center",children:N&&d&&(d==="asc"?n.jsx(K,{size:16,className:"text-muted-foreground transition-colors"}):n.jsx(D,{size:16,className:"text-muted-foreground transition-colors"}))})},e[0]=d,e[1]=l):l=e[1];const i=l;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=function(r,N){let y="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider";return r===N-1&&(y="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider w-8"),y},e[2]=c):c=e[2];const u=c;let f;if(e[3]!==t||e[4]!==o||e[5]!==i||e[6]!==p){let x;e[8]!==t.length||e[9]!==o||e[10]!==i||e[11]!==p?(x=(r,N)=>{const y=p===r.id;return n.jsx(k,{className:v(u(N,t.length),"group transition-colors select-none",r.sortable&&"hover:bg-accent cursor-pointer",r.rowClassName,r.cellClassName),onClick:r.sortable&&o?()=>o(r.id):void 0,children:n.jsxs("span",{className:"flex items-center gap-1",children:[r.header,r.sortable&&i(r.id,y)]})},r.id)},e[8]=t.length,e[9]=o,e[10]=i,e[11]=p,e[12]=x):x=e[12],f=t.map(x),e[3]=t,e[4]=o,e[5]=i,e[6]=p,e[7]=f}else f=e[7];let w;e[13]!==f?(w=n.jsx(I,{className:"border-b-0",children:n.jsx(A,{className:"h-9 hover:bg-transparent border-b border-border",children:f})}),e[13]=f,e[14]=w):w=e[14];let g;if(e[15]!==t||e[16]!==m||e[17]!==a||e[18]!==s){let x;e[20]!==t||e[21]!==a||e[22]!==s?(x=(r,N)=>{const y=s?.(r);return n.jsx(A,{"data-row-index":N,className:v("group/data-row transition-colors border-b-0 hover:bg-accent/50",a?"cursor-pointer":"",y),onClick:a?()=>a(r):void 0,children:t.map(b=>n.jsx(L,{className:v("px-5 py-4 h-16 align-middle text-sm text-foreground",b.cellClassName,b.wrap?"whitespace-normal wrap-break-word":""),children:n.jsx("div",{className:v(b.wrap?"w-full":"min-w-0 w-full",!b.wrap&&"truncate overflow-hidden whitespace-nowrap"),children:b.render?b.render(r):b.accessor?b.accessor(r):null})},b.id))},N)},e[20]=t,e[21]=a,e[22]=s,e[23]=x):x=e[23],g=m.map(x),e[15]=t,e[16]=m,e[17]=a,e[18]=s,e[19]=g}else g=e[19];let C;e[24]!==g?(C=n.jsx(z,{children:g}),e[24]=g,e[25]=C):C=e[25];let j;return e[26]!==w||e[27]!==C?(j=n.jsxs(O,{className:"w-full border-collapse",children:[w,C]}),e[26]=w,e[27]=C,e[28]=j):j=e[28],j}function W(h){const e=S.c(12),{columns:t,data:m,isLoading:p,sortKey:d,sortDirection:o,onSort:a,onRowClick:s,emptyState:l}=h;if(p===void 0?!1:p){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}),e[0]=u):u=e[0],u}if(m.length===0){let u;e[1]!==l?(u=l||n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No items found"}),e[1]=l,e[2]=u):u=e[2];let f;return e[3]!==u?(f=n.jsx("div",{className:"flex items-center justify-center h-full",children:u}),e[3]=u,e[4]=f):f=e[4],f}let c;return e[5]!==t||e[6]!==m||e[7]!==s||e[8]!==a||e[9]!==o||e[10]!==d?(c=n.jsx("div",{className:"flex-1",children:n.jsx(H,{columns:t,data:m,sortKey:d,sortDirection:o,onSort:a,onRowClick:s})}),e[5]=t,e[6]=m,e[7]=s,e[8]=a,e[9]=o,e[10]=d,e[11]=c):c=e[11],c}const R=[{value:"owner",label:"Owner",isBuiltin:!0},{value:"admin",label:"Admin",isBuiltin:!0},{value:"user",label:"User",isBuiltin:!0}];function M(h){return h.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function U(h){if(!h)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1,modelCount:0,allowsAllModels:!1};const e=[];let t=!1;const m=[];let p=!1;const d=new Set;let o=!1,a=0,s=!1;for(const[l,i]of Object.entries(h)){if(l==="self"){i.includes("*")?t=!0:e.push(...i);continue}if(l==="models"){i.includes("*:*")?s=!0:a=i.length;continue}if(l==="*"){if(p=!0,i.includes("*"))o=!0;else for(const c of i)d.add(c);continue}if(m.push(l),i.includes("*"))o=!0;else for(const c of i)d.add(c)}return{staticPermissions:e,allowsAllStaticPermissions:t,connectionIds:m,allowsAllConnections:p,toolNames:Array.from(d),allowsAllTools:o,modelCount:a,allowsAllModels:s}}function Y(){const{locator:h}=T(),e=E(),{data:t,isLoading:m,error:p,refetch:d}=B({queryKey:P.organizationRoles(h),queryFn:async()=>{try{const s=await e.organization.listRoles();return s?.error?(console.error("[useOrganizationRoles] API error:",s.error),[]):s?.data??[]}catch(s){return console.error("[useOrganizationRoles] Fetch error:",s),[]}},staleTime:3e4}),o=R.map(s=>({role:s.value,label:s.label,isBuiltin:s.isBuiltin}));if(t&&Array.isArray(t))for(const s of t){const l=s.role;if(!l||R.some(x=>x.value===l))continue;const{staticPermissions:i,allowsAllStaticPermissions:c,connectionIds:u,allowsAllConnections:f,toolNames:w,allowsAllTools:g,modelCount:C,allowsAllModels:j}=U(s.permission);o.push({id:s.id,role:l,label:M(l),isBuiltin:!1,permission:s.permission??void 0,staticPermissionCount:c?-1:i.length,allowsAllStaticPermissions:c,connectionCount:f?-1:u.length,allowsAllConnections:f,toolCount:g?-1:w.length,allowsAllTools:g,modelCount:j?-1:C,allowsAllModels:j})}const a=o.filter(s=>!s.isBuiltin);return{roles:o,customRoles:a,builtinRoles:o.filter(s=>s.isBuiltin),isLoading:m,error:p,refetch:d}}export{W as C,Y as u};
1
+ import{c as S,j as n,l as v,D as T,k as B,K as P}from"./index-CFiyU0D9.js";import{e as k,d as I,a as A,T as L,b as z,c as O}from"./table-DeNuxLMl.js";import{a as K,n as D}from"./SwitchHorizontal01-DAZXInW8.js";import{u as E}from"./use-org-auth-client-C_UJ3Vg_.js";function H(h){const e=S.c(29),{columns:t,data:m,sortKey:p,sortDirection:d,onSort:o,onRowClick:a,rowClassName:s}=h;let l;e[0]!==d?(l=function(r,N){return n.jsx("div",{className:"w-4 flex items-center justify-center",children:N&&d&&(d==="asc"?n.jsx(K,{size:16,className:"text-muted-foreground transition-colors"}):n.jsx(D,{size:16,className:"text-muted-foreground transition-colors"}))})},e[0]=d,e[1]=l):l=e[1];const i=l;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=function(r,N){let y="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider";return r===N-1&&(y="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider w-8"),y},e[2]=c):c=e[2];const u=c;let f;if(e[3]!==t||e[4]!==o||e[5]!==i||e[6]!==p){let x;e[8]!==t.length||e[9]!==o||e[10]!==i||e[11]!==p?(x=(r,N)=>{const y=p===r.id;return n.jsx(k,{className:v(u(N,t.length),"group transition-colors select-none",r.sortable&&"hover:bg-accent cursor-pointer",r.rowClassName,r.cellClassName),onClick:r.sortable&&o?()=>o(r.id):void 0,children:n.jsxs("span",{className:"flex items-center gap-1",children:[r.header,r.sortable&&i(r.id,y)]})},r.id)},e[8]=t.length,e[9]=o,e[10]=i,e[11]=p,e[12]=x):x=e[12],f=t.map(x),e[3]=t,e[4]=o,e[5]=i,e[6]=p,e[7]=f}else f=e[7];let w;e[13]!==f?(w=n.jsx(I,{className:"border-b-0",children:n.jsx(A,{className:"h-9 hover:bg-transparent border-b border-border",children:f})}),e[13]=f,e[14]=w):w=e[14];let g;if(e[15]!==t||e[16]!==m||e[17]!==a||e[18]!==s){let x;e[20]!==t||e[21]!==a||e[22]!==s?(x=(r,N)=>{const y=s?.(r);return n.jsx(A,{"data-row-index":N,className:v("group/data-row transition-colors border-b-0 hover:bg-accent/50",a?"cursor-pointer":"",y),onClick:a?()=>a(r):void 0,children:t.map(b=>n.jsx(L,{className:v("px-5 py-4 h-16 align-middle text-sm text-foreground",b.cellClassName,b.wrap?"whitespace-normal wrap-break-word":""),children:n.jsx("div",{className:v(b.wrap?"w-full":"min-w-0 w-full",!b.wrap&&"truncate overflow-hidden whitespace-nowrap"),children:b.render?b.render(r):b.accessor?b.accessor(r):null})},b.id))},N)},e[20]=t,e[21]=a,e[22]=s,e[23]=x):x=e[23],g=m.map(x),e[15]=t,e[16]=m,e[17]=a,e[18]=s,e[19]=g}else g=e[19];let C;e[24]!==g?(C=n.jsx(z,{children:g}),e[24]=g,e[25]=C):C=e[25];let j;return e[26]!==w||e[27]!==C?(j=n.jsxs(O,{className:"w-full border-collapse",children:[w,C]}),e[26]=w,e[27]=C,e[28]=j):j=e[28],j}function W(h){const e=S.c(12),{columns:t,data:m,isLoading:p,sortKey:d,sortDirection:o,onSort:a,onRowClick:s,emptyState:l}=h;if(p===void 0?!1:p){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}),e[0]=u):u=e[0],u}if(m.length===0){let u;e[1]!==l?(u=l||n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No items found"}),e[1]=l,e[2]=u):u=e[2];let f;return e[3]!==u?(f=n.jsx("div",{className:"flex items-center justify-center h-full",children:u}),e[3]=u,e[4]=f):f=e[4],f}let c;return e[5]!==t||e[6]!==m||e[7]!==s||e[8]!==a||e[9]!==o||e[10]!==d?(c=n.jsx("div",{className:"flex-1",children:n.jsx(H,{columns:t,data:m,sortKey:d,sortDirection:o,onSort:a,onRowClick:s})}),e[5]=t,e[6]=m,e[7]=s,e[8]=a,e[9]=o,e[10]=d,e[11]=c):c=e[11],c}const R=[{value:"owner",label:"Owner",isBuiltin:!0},{value:"admin",label:"Admin",isBuiltin:!0},{value:"user",label:"User",isBuiltin:!0}];function M(h){return h.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function U(h){if(!h)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1,modelCount:0,allowsAllModels:!1};const e=[];let t=!1;const m=[];let p=!1;const d=new Set;let o=!1,a=0,s=!1;for(const[l,i]of Object.entries(h)){if(l==="self"){i.includes("*")?t=!0:e.push(...i);continue}if(l==="models"){i.includes("*:*")?s=!0:a=i.length;continue}if(l==="*"){if(p=!0,i.includes("*"))o=!0;else for(const c of i)d.add(c);continue}if(m.push(l),i.includes("*"))o=!0;else for(const c of i)d.add(c)}return{staticPermissions:e,allowsAllStaticPermissions:t,connectionIds:m,allowsAllConnections:p,toolNames:Array.from(d),allowsAllTools:o,modelCount:a,allowsAllModels:s}}function Y(){const{locator:h}=T(),e=E(),{data:t,isLoading:m,error:p,refetch:d}=B({queryKey:P.organizationRoles(h),queryFn:async()=>{try{const s=await e.organization.listRoles();return s?.error?(console.error("[useOrganizationRoles] API error:",s.error),[]):s?.data??[]}catch(s){return console.error("[useOrganizationRoles] Fetch error:",s),[]}},staleTime:3e4}),o=R.map(s=>({role:s.value,label:s.label,isBuiltin:s.isBuiltin}));if(t&&Array.isArray(t))for(const s of t){const l=s.role;if(!l||R.some(x=>x.value===l))continue;const{staticPermissions:i,allowsAllStaticPermissions:c,connectionIds:u,allowsAllConnections:f,toolNames:w,allowsAllTools:g,modelCount:C,allowsAllModels:j}=U(s.permission);o.push({id:s.id,role:l,label:M(l),isBuiltin:!1,permission:s.permission??void 0,staticPermissionCount:c?-1:i.length,allowsAllStaticPermissions:c,connectionCount:f?-1:u.length,allowsAllConnections:f,toolCount:g?-1:w.length,allowsAllTools:g,modelCount:j?-1:C,allowsAllModels:j})}const a=o.filter(s=>!s.isBuiltin);return{roles:o,customRoles:a,builtinRoles:o.filter(s=>s.isBuiltin),isLoading:m,error:p,refetch:d}}export{W as C,Y as u};
@@ -1 +1 @@
1
- import{K as d,c as l,D as g,k as E,m as I,d as R,r as b}from"./index-DmjWDqcd.js";import{W as G}from"./use-mcp-client-NDJy9UEP.js";import{c as M,u as Q}from"./studio-tools-BWRE75AX.js";const N={organizationId:"",sidebar_items:null,enabled_plugins:null,registry_config:null,simple_mode:null,default_home_agents:null},O={tiers:{fast:null,smart:null,thinking:null,image:null,web_search:null,deep_research:null}};function w(t,e){return{queryKey:d.organizationSettings(e),queryFn:async()=>{try{return await M(t,"ORGANIZATION_SETTINGS_GET",{})}catch{return{...N,organizationId:e}}},staleTime:6e4}}function h(t){const e=l.c(6),{org:s}=g();let n;e[0]!==s.id||e[1]!==s.slug?(n=w(s.slug,s.id),e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=t;let r;return e[3]!==n||e[4]!==i?(r={...n,select:i},e[3]=n,e[4]=i,e[5]=r):r=e[5],E(r)}function W(t,e){const s=l.c(3);let n;s[0]!==t||s[1]!==e?(n=w(e,t),s[0]=t,s[1]=e,s[2]=n):n=s[2];const{data:i}=E(n);return i??null}function S(){const t=l.c(9),{org:e}=g(),s=Q(),n=I();let i;t[0]!==e||t[1]!==s?(i=async u=>{const o=await s.call("ORGANIZATION_SETTINGS_UPDATE",{organizationId:e.id,...u});if(!o)throw new Error("ORGANIZATION_SETTINGS_UPDATE returned no payload");return o},t[0]=e,t[1]=s,t[2]=i):i=t[2];let r;t[3]!==e||t[4]!==n?(r=u=>{n.setQueryData(d.organizationSettings(e.id),o=>({...o??N,...u}))},t[3]=e,t[4]=n,t[5]=r):r=t[5];let a;return t[6]!==i||t[7]!==r?(a={mutationFn:i,onSuccess:r},t[6]=i,t[7]=r,t[8]=a):a=t[8],R(a)}function C(t){return t?.tiers?{tiers:{fast:t.tiers.fast??null,smart:t.tiers.smart??null,thinking:t.tiers.thinking??null,image:t.tiers.image??null,web_search:t.tiers.web_search??null,deep_research:t.tiers.deep_research??null}}:O}function Z(){const{data:t}=h(P);return t??O}function P(t){return C(t.simple_mode)}function F(){const t=l.c(7),e=S();let s,n;t[0]!==e?(s=(r,a)=>e.mutate({simple_mode:r},a),n=(r,a)=>e.mutateAsync({simple_mode:r},a),t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]);let i;return t[3]!==e||t[4]!==s||t[5]!==n?(i={...e,mutate:s,mutateAsync:n},t[3]=e,t[4]=s,t[5]=n,t[6]=i):i=t[6],i}function $(){const{data:t}=h(k);return t??null}function k(t){return t.registry_config}function j(){const t=l.c(7),e=S();let s,n;t[0]!==e?(s=(r,a)=>e.mutate({registry_config:r},a),n=(r,a)=>e.mutateAsync({registry_config:r},a),t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]);let i;return t[3]!==e||t[4]!==s||t[5]!==n?(i={...e,mutate:s,mutateAsync:n},t[3]=e,t[4]=s,t[5]=n,t[6]=i):i=t[6],i}function B(){const{data:t}=h(x);return t??null}function x(t){return t.default_home_agents}function U(){const t=l.c(7),e=S();let s,n;t[0]!==e?(s=(r,a)=>e.mutate({default_home_agents:r},a),n=(r,a)=>e.mutateAsync({default_home_agents:r},a),t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]);let i;return t[3]!==e||t[4]!==s||t[5]!==n?(i={...e,mutate:s,mutateAsync:n},t[3]=e,t[4]=s,t[5]=n,t[6]=i):i=t[6],i}function L(){const t=l.c(14),{org:e}=g(),s=U(),n=I();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Promise.resolve(),t[0]=i):i=t[0];const r=b.useRef(i);let a;t[1]!==e.id?(a=d.organizationSettings(e.id),t[1]=e.id,t[2]=a):a=t[2];const u=a;let o;t[3]!==u||t[4]!==n?(o=()=>n.getQueryData(u)?.default_home_agents?.ids??[],t[3]=u,t[4]=n,t[5]=o):o=t[5];const _=o;let m;t[6]!==u||t[7]!==e.slug||t[8]!==n||t[9]!==s?(m=z=>{const T=r.current.then(async()=>{const A=n.getQueryData(u),p=z(A?.default_home_agents?.ids??[]);if(p!==null){n.setQueryData(u,c=>c&&{...c,default_home_agents:{ids:p}});try{await s.mutateAsync({ids:p}),await n.refetchQueries({queryKey:d.homeNextActions(e.slug),type:"active"})}catch(c){const D=c;throw n.setQueryData(u,A),D}}});return r.current=T.catch(q),T},t[6]=u,t[7]=e.slug,t[8]=n,t[9]=s,t[10]=m):m=t[10];const y=m;let f;return t[11]!==y||t[12]!==_?(f={currentIds:_,apply:y},t[11]=y,t[12]=_,t[13]=f):f=t[13],f}function q(){}function v(){const t=l.c(5),{org:e}=g(),s=$();let n;t[0]!==e.id?(n=G.REGISTRY(e.id),t[0]=e.id,t[1]=n):n=t[1];const i=n;let r;return t[2]!==i||t[3]!==s?(r=a=>{if(!s)return a===i;const u=s.registries[a];return u?u.enabled:a===i},t[2]=i,t[3]=s,t[4]=r):r=t[4],r}export{L as a,v as b,W as c,Z as d,F as e,$ as f,j as g,w as o,B as u};
1
+ import{K as d,c as l,D as g,k as E,m as I,d as R,r as b}from"./index-CFiyU0D9.js";import{W as G}from"./use-mcp-client-xOK-OF8p.js";import{c as M,u as Q}from"./studio-tools-CNO5iCKk.js";const N={organizationId:"",sidebar_items:null,enabled_plugins:null,registry_config:null,simple_mode:null,default_home_agents:null},O={tiers:{fast:null,smart:null,thinking:null,image:null,web_search:null,deep_research:null}};function w(t,e){return{queryKey:d.organizationSettings(e),queryFn:async()=>{try{return await M(t,"ORGANIZATION_SETTINGS_GET",{})}catch{return{...N,organizationId:e}}},staleTime:6e4}}function h(t){const e=l.c(6),{org:s}=g();let n;e[0]!==s.id||e[1]!==s.slug?(n=w(s.slug,s.id),e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=t;let r;return e[3]!==n||e[4]!==i?(r={...n,select:i},e[3]=n,e[4]=i,e[5]=r):r=e[5],E(r)}function W(t,e){const s=l.c(3);let n;s[0]!==t||s[1]!==e?(n=w(e,t),s[0]=t,s[1]=e,s[2]=n):n=s[2];const{data:i}=E(n);return i??null}function S(){const t=l.c(9),{org:e}=g(),s=Q(),n=I();let i;t[0]!==e||t[1]!==s?(i=async u=>{const o=await s.call("ORGANIZATION_SETTINGS_UPDATE",{organizationId:e.id,...u});if(!o)throw new Error("ORGANIZATION_SETTINGS_UPDATE returned no payload");return o},t[0]=e,t[1]=s,t[2]=i):i=t[2];let r;t[3]!==e||t[4]!==n?(r=u=>{n.setQueryData(d.organizationSettings(e.id),o=>({...o??N,...u}))},t[3]=e,t[4]=n,t[5]=r):r=t[5];let a;return t[6]!==i||t[7]!==r?(a={mutationFn:i,onSuccess:r},t[6]=i,t[7]=r,t[8]=a):a=t[8],R(a)}function C(t){return t?.tiers?{tiers:{fast:t.tiers.fast??null,smart:t.tiers.smart??null,thinking:t.tiers.thinking??null,image:t.tiers.image??null,web_search:t.tiers.web_search??null,deep_research:t.tiers.deep_research??null}}:O}function Z(){const{data:t}=h(P);return t??O}function P(t){return C(t.simple_mode)}function F(){const t=l.c(7),e=S();let s,n;t[0]!==e?(s=(r,a)=>e.mutate({simple_mode:r},a),n=(r,a)=>e.mutateAsync({simple_mode:r},a),t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]);let i;return t[3]!==e||t[4]!==s||t[5]!==n?(i={...e,mutate:s,mutateAsync:n},t[3]=e,t[4]=s,t[5]=n,t[6]=i):i=t[6],i}function $(){const{data:t}=h(k);return t??null}function k(t){return t.registry_config}function j(){const t=l.c(7),e=S();let s,n;t[0]!==e?(s=(r,a)=>e.mutate({registry_config:r},a),n=(r,a)=>e.mutateAsync({registry_config:r},a),t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]);let i;return t[3]!==e||t[4]!==s||t[5]!==n?(i={...e,mutate:s,mutateAsync:n},t[3]=e,t[4]=s,t[5]=n,t[6]=i):i=t[6],i}function B(){const{data:t}=h(x);return t??null}function x(t){return t.default_home_agents}function U(){const t=l.c(7),e=S();let s,n;t[0]!==e?(s=(r,a)=>e.mutate({default_home_agents:r},a),n=(r,a)=>e.mutateAsync({default_home_agents:r},a),t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]);let i;return t[3]!==e||t[4]!==s||t[5]!==n?(i={...e,mutate:s,mutateAsync:n},t[3]=e,t[4]=s,t[5]=n,t[6]=i):i=t[6],i}function L(){const t=l.c(14),{org:e}=g(),s=U(),n=I();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Promise.resolve(),t[0]=i):i=t[0];const r=b.useRef(i);let a;t[1]!==e.id?(a=d.organizationSettings(e.id),t[1]=e.id,t[2]=a):a=t[2];const u=a;let o;t[3]!==u||t[4]!==n?(o=()=>n.getQueryData(u)?.default_home_agents?.ids??[],t[3]=u,t[4]=n,t[5]=o):o=t[5];const _=o;let m;t[6]!==u||t[7]!==e.slug||t[8]!==n||t[9]!==s?(m=z=>{const T=r.current.then(async()=>{const A=n.getQueryData(u),p=z(A?.default_home_agents?.ids??[]);if(p!==null){n.setQueryData(u,c=>c&&{...c,default_home_agents:{ids:p}});try{await s.mutateAsync({ids:p}),await n.refetchQueries({queryKey:d.homeNextActions(e.slug),type:"active"})}catch(c){const D=c;throw n.setQueryData(u,A),D}}});return r.current=T.catch(q),T},t[6]=u,t[7]=e.slug,t[8]=n,t[9]=s,t[10]=m):m=t[10];const y=m;let f;return t[11]!==y||t[12]!==_?(f={currentIds:_,apply:y},t[11]=y,t[12]=_,t[13]=f):f=t[13],f}function q(){}function v(){const t=l.c(5),{org:e}=g(),s=$();let n;t[0]!==e.id?(n=G.REGISTRY(e.id),t[0]=e.id,t[1]=n):n=t[1];const i=n;let r;return t[2]!==i||t[3]!==s?(r=a=>{if(!s)return a===i;const u=s.registries[a];return u?u.enabled:a===i},t[2]=i,t[3]=s,t[4]=r):r=t[4],r}export{L as a,v as b,W as c,Z as d,F as e,$ as f,j as g,w as o,B as u};
@@ -1 +1 @@
1
- import{c as C,D as R}from"./index-DmjWDqcd.js";import{u as p}from"./use-connection-RPVug9uL.js";import{W as a}from"./use-mcp-client-NDJy9UEP.js";import{f as y}from"./use-organization-settings-rqcqUUeR.js";function M(){const e=C.c(19),{org:i}=R(),o=y();let l;e[0]!==i.id?(l=a.REGISTRY(i.id),e[0]=i.id,e[1]=l):l=e[1];const d=l;let f;e[2]!==i.id?(f=a.COMMUNITY_REGISTRY(i.id),e[2]=i.id,e[3]=f):f=e[3];const g=f;let r;e[4]!==g||e[5]!==d?(r=[d,g],e[4]=g,e[5]=d,e[6]=r):r=e[6];let t;if(e[7]!==o||e[8]!==r){if(t=new Set(r),o?.registries){let s;e[10]!==o.registries?(s=Object.keys(o.registries),e[10]=o.registries,e[11]=s):s=e[11];for(const u of s)t.add(u)}e[7]=o,e[8]=r,e[9]=t}else t=e[9];const m=p();let n;e[12]!==m?(n=m??[],e[12]=m,e[13]=n):n=e[13];let c;if(e[14]!==t||e[15]!==n){let s;e[17]!==t?(s=u=>t.has(u.id),e[17]=t,e[18]=s):s=e[18],c=n.filter(s),e[14]=t,e[15]=n,e[16]=c}else c=e[16];return c}export{M as u};
1
+ import{c as C,D as R}from"./index-CFiyU0D9.js";import{u as p}from"./use-connection-Dz29RF9P.js";import{W as a}from"./use-mcp-client-xOK-OF8p.js";import{f as y}from"./use-organization-settings-DksiQdGc.js";function M(){const e=C.c(19),{org:i}=R(),o=y();let l;e[0]!==i.id?(l=a.REGISTRY(i.id),e[0]=i.id,e[1]=l):l=e[1];const d=l;let f;e[2]!==i.id?(f=a.COMMUNITY_REGISTRY(i.id),e[2]=i.id,e[3]=f):f=e[3];const g=f;let r;e[4]!==g||e[5]!==d?(r=[d,g],e[4]=g,e[5]=d,e[6]=r):r=e[6];let t;if(e[7]!==o||e[8]!==r){if(t=new Set(r),o?.registries){let s;e[10]!==o.registries?(s=Object.keys(o.registries),e[10]=o.registries,e[11]=s):s=e[11];for(const u of s)t.add(u)}e[7]=o,e[8]=r,e[9]=t}else t=e[9];const m=p();let n;e[12]!==m?(n=m??[],e[12]=m,e[13]=n):n=e[13];let c;if(e[14]!==t||e[15]!==n){let s;e[17]!==t?(s=u=>t.has(u.id),e[17]=t,e[18]=s):s=e[18],c=n.filter(s),e[14]=t,e[15]=n,e[16]=c}else c=e[16];return c}export{M as u};
@@ -1 +1 @@
1
- import{c as r,D as a,K as c,q as f,m as y,d as m}from"./index-DmjWDqcd.js";import{u as l}from"./studio-tools-BWRE75AX.js";function C(){const e=r.c(7),{org:o}=a(),u=l();let i;e[0]!==o.id?(i=c.secrets(o.id),e[0]=o.id,e[1]=i):i=e[1];let t;e[2]!==u?(t=async()=>await u.call("SECRET_LIST",{}),e[2]=u,e[3]=t):t=e[3];let s;e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6];const{data:n}=f(s);return n.secrets}function p(){const e=r.c(8),{org:o}=a(),u=l(),i=y();let t;e[0]!==u?(t=async d=>await u.call("SECRET_CREATE",{...d}),e[0]=u,e[1]=t):t=e[1];let s;e[2]!==o||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:c.secrets(o.id)})},e[2]=o,e[3]=i,e[4]=s):s=e[4];let n;return e[5]!==t||e[6]!==s?(n={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=n):n=e[7],m(n)}export{p as a,C as u};
1
+ import{c as r,D as a,K as c,q as f,m as y,d as m}from"./index-CFiyU0D9.js";import{u as l}from"./studio-tools-CNO5iCKk.js";function C(){const e=r.c(7),{org:o}=a(),u=l();let i;e[0]!==o.id?(i=c.secrets(o.id),e[0]=o.id,e[1]=i):i=e[1];let t;e[2]!==u?(t=async()=>await u.call("SECRET_LIST",{}),e[2]=u,e[3]=t):t=e[3];let s;e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6];const{data:n}=f(s);return n.secrets}function p(){const e=r.c(8),{org:o}=a(),u=l(),i=y();let t;e[0]!==u?(t=async d=>await u.call("SECRET_CREATE",{...d}),e[0]=u,e[1]=t):t=e[1];let s;e[2]!==o||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:c.secrets(o.id)})},e[2]=o,e[3]=i,e[4]=s):s=e[4];let n;return e[5]!==t||e[6]!==s?(n={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=n):n=e[7],m(n)}export{p as a,C as u};
@@ -1 +1 @@
1
- import{c as r,J as u}from"./index-DmjWDqcd.js";import{p as i,q as c}from"./question-004-sINsf4GQ.js";import{u as f}from"./use-decopilot-events-DavYF-aF.js";const p=new Set(["completed","failed","requires_action"]);function q(s){const e=r.c(5),[n]=u();let t;e[0]!==n?(t=o=>{n.enableSounds&&p.has(o.data.status)&&i(c.dataUri).catch(l)},e[0]=n,e[1]=t):t=e[1];let a;e[2]!==s||e[3]!==t?(a={orgSlug:s,onTaskStatus:t},e[2]=s,e[3]=t,e[4]=a):a=e[4],f(a)}function l(s){console.warn("[status-sounds] playback failed:",s)}export{q as u};
1
+ import{c as r,J as u}from"./index-CFiyU0D9.js";import{p as i,q as c}from"./question-004-sINsf4GQ.js";import{u as f}from"./use-decopilot-events-CpQNzv3e.js";const p=new Set(["completed","failed","requires_action"]);function q(s){const e=r.c(5),[n]=u();let t;e[0]!==n?(t=o=>{n.enableSounds&&p.has(o.data.status)&&i(c.dataUri).catch(l)},e[0]=n,e[1]=t):t=e[1];let a;e[2]!==s||e[3]!==t?(a={orgSlug:s,onTaskStatus:t},e[2]=s,e[3]=t,e[4]=a):a=e[4],f(a)}function l(s){console.warn("[status-sounds] playback failed:",s)}export{q as u};
@@ -1 +1 @@
1
- import{c as p,r as f}from"./index-DmjWDqcd.js";import{u as w}from"./use-mobile-C1ok2Oda.js";function S(m,M){const e=p.c(12),u=M===void 0?"cards":M,o=w(),b=f.useRef(o),s=m?`deco-view-mode-${m}`:"deco-view-mode";let i;e[0]!==u||e[1]!==s?(i=()=>{const r=globalThis.localStorage?.getItem(s);return r==="cards"||r==="table"?r:u},e[0]=u,e[1]=s,e[2]=i):i=e[2];const[t,g]=f.useState(i);let l;e[3]!==s?(l=r=>{g(r),globalThis.localStorage?.setItem(s,r)},e[3]=s,e[4]=l):l=e[4];const d=l;let c,a;e[5]!==o||e[6]!==t?(c=()=>{!b.current&&o&&t==="table"&&g("cards"),b.current=o},a=[o,t],e[5]=o,e[6]=t,e[7]=c,e[8]=a):(c=e[7],a=e[8]),f.useEffect(c,a);let n;return e[9]!==d||e[10]!==t?(n=[t,d],e[9]=d,e[10]=t,e[11]=n):n=e[11],n}export{S as u};
1
+ import{c as p,r as f}from"./index-CFiyU0D9.js";import{u as w}from"./use-mobile-NlF-3RoP.js";function S(m,M){const e=p.c(12),u=M===void 0?"cards":M,o=w(),b=f.useRef(o),s=m?`deco-view-mode-${m}`:"deco-view-mode";let i;e[0]!==u||e[1]!==s?(i=()=>{const r=globalThis.localStorage?.getItem(s);return r==="cards"||r==="table"?r:u},e[0]=u,e[1]=s,e[2]=i):i=e[2];const[t,g]=f.useState(i);let l;e[3]!==s?(l=r=>{g(r),globalThis.localStorage?.setItem(s,r)},e[3]=s,e[4]=l):l=e[4];const d=l;let c,a;e[5]!==o||e[6]!==t?(c=()=>{!b.current&&o&&t==="table"&&g("cards"),b.current=o},a=[o,t],e[5]=o,e[6]=t,e[7]=c,e[8]=a):(c=e[7],a=e[8]),f.useEffect(c,a);let n;return e[9]!==d||e[10]!==t?(n=[t,d],e[9]=d,e[10]=t,e[11]=n):n=e[11],n}export{S as u};
@@ -1 +1 @@
1
- import{c as a,D as d,aK as p,k as P}from"./index-DmjWDqcd.js";import{b as L,a as S,u as V,c as _}from"./use-collections-C6o5d0Mn.js";import{S as g,u as I}from"./use-mcp-client-NDJy9UEP.js";function v(s){const t=a.c(5);let e;t[0]!==s?(e=s===void 0?{}:s,t[0]=s,t[1]=e):e=t[1];const n=e,{org:i}=d();let o;t[2]!==i.id||t[3]!==i.slug?(o={connectionId:g,orgId:i.id,orgSlug:i.slug},t[2]=i.id,t[3]=i.slug,t[4]=o):o=t[4];const l=I(o);return L(i.id,"VIRTUAL_MCP",l,n)}function R(s,t,e){return _(s,"VIRTUAL_MCP",t??void 0,e)}function b(s){const t=a.c(3),{org:e}=d();let n;t[0]!==e.id||t[1]!==e.slug?(n={connectionId:g,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=n):n=t[2];const i=I(n);return V(e.id,"VIRTUAL_MCP",s??void 0,i)}function E(s){const t=a.c(15),{org:e}=d();let n;t[0]!==e.id||t[1]!==e.slug?(n={connectionId:g,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=n):n=t[2];const i=I(n);let o,l,c;t[3]!==s||t[4]!==e.id?(o=[...s].sort(),c=P,l=p.virtualMcpLastUsed(e.id,o),t[3]=s,t[4]=e.id,t[5]=o,t[6]=l,t[7]=c):(o=t[5],l=t[6],c=t[7]);const C=o.length>0;let u;t[8]!==i||t[9]!==o?(u=async()=>{const M=(await i.callTool({name:"VIRTUAL_MCP_LAST_USED_LIST",arguments:{ids:o}})).structuredContent??{items:[]},f=new Map;for(const m of M.items)f.set(m.id,m);return f},t[8]=i,t[9]=o,t[10]=u):u=t[10];let r;return t[11]!==l||t[12]!==C||t[13]!==u?(r={queryKey:l,enabled:C,staleTime:3e4,queryFn:u},t[11]=l,t[12]=C,t[13]=u,t[14]=r):r=t[14],c(r)}function $(){const s=a.c(3),{org:t}=d();let e;s[0]!==t.id||s[1]!==t.slug?(e={connectionId:g,orgId:t.id,orgSlug:t.slug},s[0]=t.id,s[1]=t.slug,s[2]=e):e=s[2];const n=I(e);return S(t.id,"VIRTUAL_MCP",n)}export{b as a,$ as b,E as c,v as u,R as v};
1
+ import{c as a,D as d,aL as p,k as P}from"./index-CFiyU0D9.js";import{b as L,a as S,u as V,c as _}from"./use-collections-B4atckEK.js";import{S as g,u as I}from"./use-mcp-client-xOK-OF8p.js";function v(s){const t=a.c(5);let e;t[0]!==s?(e=s===void 0?{}:s,t[0]=s,t[1]=e):e=t[1];const n=e,{org:i}=d();let o;t[2]!==i.id||t[3]!==i.slug?(o={connectionId:g,orgId:i.id,orgSlug:i.slug},t[2]=i.id,t[3]=i.slug,t[4]=o):o=t[4];const l=I(o);return L(i.id,"VIRTUAL_MCP",l,n)}function R(s,t,e){return _(s,"VIRTUAL_MCP",t??void 0,e)}function b(s){const t=a.c(3),{org:e}=d();let n;t[0]!==e.id||t[1]!==e.slug?(n={connectionId:g,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=n):n=t[2];const i=I(n);return V(e.id,"VIRTUAL_MCP",s??void 0,i)}function E(s){const t=a.c(15),{org:e}=d();let n;t[0]!==e.id||t[1]!==e.slug?(n={connectionId:g,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=n):n=t[2];const i=I(n);let o,l,c;t[3]!==s||t[4]!==e.id?(o=[...s].sort(),c=P,l=p.virtualMcpLastUsed(e.id,o),t[3]=s,t[4]=e.id,t[5]=o,t[6]=l,t[7]=c):(o=t[5],l=t[6],c=t[7]);const C=o.length>0;let u;t[8]!==i||t[9]!==o?(u=async()=>{const M=(await i.callTool({name:"VIRTUAL_MCP_LAST_USED_LIST",arguments:{ids:o}})).structuredContent??{items:[]},f=new Map;for(const m of M.items)f.set(m.id,m);return f},t[8]=i,t[9]=o,t[10]=u):u=t[10];let r;return t[11]!==l||t[12]!==C||t[13]!==u?(r={queryKey:l,enabled:C,staleTime:3e4,queryFn:u},t[11]=l,t[12]=C,t[13]=u,t[14]=r):r=t[14],c(r)}function $(){const s=a.c(3),{org:t}=d();let e;s[0]!==t.id||s[1]!==t.slug?(e={connectionId:g,orgId:t.id,orgSlug:t.slug},s[0]=t.id,s[1]=t.slug,s[2]=e):e=s[2];const n=I(e);return S(t.id,"VIRTUAL_MCP",n)}export{b as a,$ as b,E as c,v as u,R as v};
@@ -0,0 +1 @@
1
+ import{I as u}from"./use-infinite-scroll-BX1nHHVY.js";import{cK as i}from"./index-CFiyU0D9.js";function t(e,r){return i(e,u,r)}export{t as u};
@@ -0,0 +1 @@
1
+ import{I as s}from"./use-infinite-scroll-BX1nHHVY.js";import{cK as u,aD as n}from"./index-CFiyU0D9.js";function a(r,e){return u({...r,enabled:!0,suspense:!0,throwOnError:n},s,e)}export{a as u};
@@ -1 +1 @@
1
- import{ao as Q,ap as y,aq as w,ar as S,as as E,m as q,at as k,au as x,r as p,av as M,aw as H,ax as B,ay as L,az as O,aA as P,aB as A,aC as T}from"./index-DmjWDqcd.js";function R(t,e){const s=new Set(e);return t.filter(r=>!s.has(r))}function z(t,e,s){const r=t.slice(0);return r[e]=s,r}var D=class extends Q{#i;#e;#n;#r;#s;#t;#u;#o;#a;#h=[];constructor(t,e,s){super(),this.#i=t,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(t=>{t.subscribe(e=>{this.#f(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#r=e,y.batch(()=>{const s=this.#s,r=this.#d(this.#n);r.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const i=r.map(u=>u.observer),n=i.map(u=>u.getCurrentResult()),o=s.length!==i.length,c=i.some((u,f)=>u!==s[f]),d=o||c,b=d?!0:n.some((u,f)=>{const g=this.#e[f];return!g||!w(u,g)});!d&&!b||(d&&(this.#h=r,this.#s=i),this.#e=n,this.hasListeners()&&(d&&(R(s,i).forEach(u=>{u.destroy()}),R(i,s).forEach(u=>{u.subscribe(f=>{this.#f(u,f)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(t=>t.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(t,e){const s=this.#d(t),r=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[r,n=>this.#l(n??r,e,i),()=>this.#c(r,s)]}#c(t,e){return e.map((s,r)=>{const i=t[r];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(o=>{o.observer.trackProp(n)})})})}#l(t,e,s){if(e){const r=this.#a,i=s!==void 0&&r!==void 0&&(r.length!==s.length||s.some((n,o)=>n!==r[o]));return(!this.#t||this.#e!==this.#o||i||e!==this.#u)&&(this.#u=e,this.#o=this.#e,s!==void 0&&(this.#a=s),this.#t=S(this.#t,e(t))),this.#t}return t}#b(){return this.#r?.combine!==void 0&&this.#s.some((t,e)=>t.options.suspense&&this.#e[e]?.data===void 0)}#d(t){const e=new Map;this.#s.forEach(r=>{const i=r.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(r):e.set(i,[r])});const s=[];return t.forEach(r=>{const i=this.#i.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new E(this.#i,i);s.push({defaultedQueryOptions:i,observer:o})}),s}#f(t,e){const s=this.#s.indexOf(t);s!==-1&&(this.#e=z(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const t=this.#c(this.#e,this.#h),e=this.#b(),s=this.#t,r=e?s:this.#l(t,this.#r?.combine);(e||s!==r)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function I({queries:t,...e},s){const r=q(s),i=k(),n=x(),o=p.useMemo(()=>t.map(a=>{const h=r.defaultQueryOptions(a);return h._optimisticResults=i?"isRestoring":"optimistic",h}),[t,r,i]);o.forEach(a=>{M(a);const h=r.getQueryCache().get(a.queryHash);H(a,n,h)}),B(n);const[c]=p.useState(()=>new D(r,o,e)),[d,b,u]=c.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(a=>f?c.subscribe(y.batchCalls(a)):L,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),p.useEffect(()=>{c.setQueries(o,e)},[o,e,c]);const m=d.some((a,h)=>O(o[h],a))?d.flatMap((a,h)=>{const l=o[h];if(l&&O(l,a)){const C=new E(r,l);return P(l,C,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=d.find((a,h)=>{const l=o[h];return l&&A({result:a,errorResetBoundary:n,throwOnError:l.throwOnError,query:r.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(u())}function j(t,e){return I({...t,queries:t.queries.map(s=>({...s,suspense:!0,throwOnError:T,enabled:!0,placeholderData:void 0}))},e)}export{j as u};
1
+ import{ap as Q,aq as y,ar as w,as as S,at as E,m as q,au as k,av as x,r as p,aw as M,ax as H,ay as B,az as L,aA as O,aB as P,aC as A,aD as T}from"./index-CFiyU0D9.js";function R(t,e){const s=new Set(e);return t.filter(r=>!s.has(r))}function z(t,e,s){const r=t.slice(0);return r[e]=s,r}var D=class extends Q{#i;#e;#n;#r;#s;#t;#u;#o;#a;#h=[];constructor(t,e,s){super(),this.#i=t,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(t=>{t.subscribe(e=>{this.#f(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#r=e,y.batch(()=>{const s=this.#s,r=this.#d(this.#n);r.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const i=r.map(u=>u.observer),n=i.map(u=>u.getCurrentResult()),o=s.length!==i.length,c=i.some((u,f)=>u!==s[f]),d=o||c,b=d?!0:n.some((u,f)=>{const g=this.#e[f];return!g||!w(u,g)});!d&&!b||(d&&(this.#h=r,this.#s=i),this.#e=n,this.hasListeners()&&(d&&(R(s,i).forEach(u=>{u.destroy()}),R(i,s).forEach(u=>{u.subscribe(f=>{this.#f(u,f)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(t=>t.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(t,e){const s=this.#d(t),r=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[r,n=>this.#l(n??r,e,i),()=>this.#c(r,s)]}#c(t,e){return e.map((s,r)=>{const i=t[r];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(o=>{o.observer.trackProp(n)})})})}#l(t,e,s){if(e){const r=this.#a,i=s!==void 0&&r!==void 0&&(r.length!==s.length||s.some((n,o)=>n!==r[o]));return(!this.#t||this.#e!==this.#o||i||e!==this.#u)&&(this.#u=e,this.#o=this.#e,s!==void 0&&(this.#a=s),this.#t=S(this.#t,e(t))),this.#t}return t}#b(){return this.#r?.combine!==void 0&&this.#s.some((t,e)=>t.options.suspense&&this.#e[e]?.data===void 0)}#d(t){const e=new Map;this.#s.forEach(r=>{const i=r.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(r):e.set(i,[r])});const s=[];return t.forEach(r=>{const i=this.#i.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new E(this.#i,i);s.push({defaultedQueryOptions:i,observer:o})}),s}#f(t,e){const s=this.#s.indexOf(t);s!==-1&&(this.#e=z(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const t=this.#c(this.#e,this.#h),e=this.#b(),s=this.#t,r=e?s:this.#l(t,this.#r?.combine);(e||s!==r)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function I({queries:t,...e},s){const r=q(s),i=k(),n=x(),o=p.useMemo(()=>t.map(a=>{const h=r.defaultQueryOptions(a);return h._optimisticResults=i?"isRestoring":"optimistic",h}),[t,r,i]);o.forEach(a=>{M(a);const h=r.getQueryCache().get(a.queryHash);H(a,n,h)}),B(n);const[c]=p.useState(()=>new D(r,o,e)),[d,b,u]=c.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(a=>f?c.subscribe(y.batchCalls(a)):L,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),p.useEffect(()=>{c.setQueries(o,e)},[o,e,c]);const m=d.some((a,h)=>O(o[h],a))?d.flatMap((a,h)=>{const l=o[h];if(l&&O(l,a)){const C=new E(r,l);return P(l,C,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=d.find((a,h)=>{const l=o[h];return l&&A({result:a,errorResetBoundary:n,throwOnError:l.throwOnError,query:r.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(u())}function j(t,e){return I({...t,queries:t.queries.map(s=>({...s,suspense:!0,throwOnError:T,enabled:!0,placeholderData:void 0}))},e)}export{j as u};