@truefoundry/trueforge 0.2.0-rc.9 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-T7PR6PDP-BtYr0hCd.js → AgentCodeSnippets-DAZWEBJS-BRFLL3U-.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-DAZWEBJS-BRFLL3U-.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-DAZWEBJS-BRFLL3U-.js.gz +0 -0
  4. package/dist/_frontend/assets/AgentMetricChart-VDIE3S2P-D_xJ9A8R.js +1 -0
  5. package/dist/_frontend/assets/AgentMetricChart-VDIE3S2P-D_xJ9A8R.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-VDIE3S2P-D_xJ9A8R.js.gz +0 -0
  7. package/dist/_frontend/assets/AgentOverview-5JIVYXPX-C7wS6H9h.js +1 -0
  8. package/dist/_frontend/assets/AgentOverview-5JIVYXPX-C7wS6H9h.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-5JIVYXPX-C7wS6H9h.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-SETKGGCI-T0eprzt1.js → AgentSessionEventTimeline-WELJSS6O-UXUue7Eb.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-WELJSS6O-UXUue7Eb.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-WELJSS6O-UXUue7Eb.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-4Y7PY5SJ-Bp3PJ8em.js → AgentSessionEventTimelineChart-ADB3KICM-Ci7-9UDP.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-ADB3KICM-Ci7-9UDP.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-ADB3KICM-Ci7-9UDP.js.gz +0 -0
  16. package/dist/_frontend/assets/AgentSessions-NSN4LIGJ-ZjsdJ6V6.js +1 -0
  17. package/dist/_frontend/assets/AgentSessions-NSN4LIGJ-ZjsdJ6V6.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-NSN4LIGJ-ZjsdJ6V6.js.gz +0 -0
  19. package/dist/_frontend/assets/ConnectorSettings-C6MFCKYX-BvX0CZ86.js +1 -0
  20. package/dist/_frontend/assets/ConnectorSettings-C6MFCKYX-BvX0CZ86.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-C6MFCKYX-BvX0CZ86.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-JRKCKAG2-bJF_JL96.js → DockLayout-VY7OZ55R-BoHuHGZ4.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-U7YPUZBR-EBVDvExP.js → DrawerLayout-B2UA3CZO-Bnc8xIc0.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-B2UA3CZO-Bnc8xIc0.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-B2UA3CZO-Bnc8xIc0.js.gz +0 -0
  26. package/dist/_frontend/assets/ModelSettings-3YAHICJ3-CYXhuUMp.js +1 -0
  27. package/dist/_frontend/assets/ModelSettings-3YAHICJ3-CYXhuUMp.js.br +0 -0
  28. package/dist/_frontend/assets/ModelSettings-3YAHICJ3-CYXhuUMp.js.gz +0 -0
  29. package/dist/_frontend/assets/SandboxSettings-ALR6F5KU-BhpQsOwg.js +1 -0
  30. package/dist/_frontend/assets/SandboxSettings-ALR6F5KU-BhpQsOwg.js.br +0 -0
  31. package/dist/_frontend/assets/SandboxSettings-ALR6F5KU-BhpQsOwg.js.gz +0 -0
  32. package/dist/_frontend/assets/SchedulesPage-TIS3BH67-CoDDvRbI.js +1 -0
  33. package/dist/_frontend/assets/SchedulesPage-TIS3BH67-CoDDvRbI.js.br +0 -0
  34. package/dist/_frontend/assets/SchedulesPage-TIS3BH67-CoDDvRbI.js.gz +0 -0
  35. package/dist/_frontend/assets/{SettingsBuilder-6FJVZLJT-Drq1vNUK.js → SettingsBuilder-G5CP5X6Q-XQVNLXzw.js} +2 -2
  36. package/dist/_frontend/assets/SettingsBuilder-G5CP5X6Q-XQVNLXzw.js.br +0 -0
  37. package/dist/_frontend/assets/SettingsBuilder-G5CP5X6Q-XQVNLXzw.js.gz +0 -0
  38. package/dist/_frontend/assets/{ShellRouteSync-SJXFKUAJ-Yi-uh3fh.js → ShellRouteSync-G7IJ5VIW-BoBswHkA.js} +1 -1
  39. package/dist/_frontend/assets/ShellRouteSync-G7IJ5VIW-BoBswHkA.js.br +0 -0
  40. package/dist/_frontend/assets/ShellRouteSync-G7IJ5VIW-BoBswHkA.js.gz +0 -0
  41. package/dist/_frontend/assets/SidebarLayout-FKRLGEDB-CqSBeNMU.js +2 -0
  42. package/dist/_frontend/assets/SidebarLayout-FKRLGEDB-CqSBeNMU.js.br +0 -0
  43. package/dist/_frontend/assets/SidebarLayout-FKRLGEDB-CqSBeNMU.js.gz +0 -0
  44. package/dist/_frontend/assets/{SkillSettings-IHVI7FDM-DEkrBUBp.js → SkillSettings-E5SJ4U3T-hOs4000P.js} +1 -1
  45. package/dist/_frontend/assets/SkillSettings-E5SJ4U3T-hOs4000P.js.br +0 -0
  46. package/dist/_frontend/assets/SkillSettings-E5SJ4U3T-hOs4000P.js.gz +0 -0
  47. package/dist/_frontend/assets/TrueForgeUIWithRouter-WD7O3TWR-rfYDejkx.js +1 -0
  48. package/dist/_frontend/assets/{WidgetLayout-PN5ZDOLM-CcGUI6sr.js → WidgetLayout-KQZTQNE7-CLurTXc-.js} +1 -1
  49. package/dist/_frontend/assets/WidgetLayout-KQZTQNE7-CLurTXc-.js.br +0 -0
  50. package/dist/_frontend/assets/WidgetLayout-KQZTQNE7-CLurTXc-.js.gz +0 -0
  51. package/dist/_frontend/assets/{chunk-62JRHF6Z-BrctyCH-.js → chunk-62JRHF6Z-DVHPxtc3.js} +1 -1
  52. package/dist/_frontend/assets/chunk-62JRHF6Z-DVHPxtc3.js.br +0 -0
  53. package/dist/_frontend/assets/chunk-62JRHF6Z-DVHPxtc3.js.gz +0 -0
  54. package/dist/_frontend/assets/{chunk-2QTH6JHX-DrgkYdZs.js → chunk-B76JC5B2-BMXX-7i9.js} +1 -1
  55. package/dist/_frontend/assets/chunk-B76JC5B2-BMXX-7i9.js.br +0 -0
  56. package/dist/_frontend/assets/chunk-B76JC5B2-BMXX-7i9.js.gz +0 -0
  57. package/dist/_frontend/assets/chunk-G7BT4OKG-D-wOOnsv.js +1 -0
  58. package/dist/_frontend/assets/chunk-G7BT4OKG-D-wOOnsv.js.br +0 -0
  59. package/dist/_frontend/assets/chunk-G7BT4OKG-D-wOOnsv.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-2UBSLCKB-Bq4rnsqJ.js → chunk-IGYCJIU7-COFxTXYC.js} +2 -2
  61. package/dist/_frontend/assets/chunk-IGYCJIU7-COFxTXYC.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-IGYCJIU7-COFxTXYC.js.gz +0 -0
  63. package/dist/_frontend/assets/{cssMode-jP6sLsrL.js → cssMode-BMGYEB3M.js} +1 -1
  64. package/dist/_frontend/assets/cssMode-BMGYEB3M.js.br +0 -0
  65. package/dist/_frontend/assets/cssMode-BMGYEB3M.js.gz +0 -0
  66. package/dist/_frontend/assets/{freemarker2-Dbeghe9Y.js → freemarker2-By56tpWC.js} +1 -1
  67. package/dist/_frontend/assets/freemarker2-By56tpWC.js.br +0 -0
  68. package/dist/_frontend/assets/freemarker2-By56tpWC.js.gz +0 -0
  69. package/dist/_frontend/assets/{handlebars-DTmlyeUV.js → handlebars-cEjR9Fs2.js} +1 -1
  70. package/dist/_frontend/assets/handlebars-cEjR9Fs2.js.br +0 -0
  71. package/dist/_frontend/assets/handlebars-cEjR9Fs2.js.gz +0 -0
  72. package/dist/_frontend/assets/{html-CjOPMUvl.js → html-tYW1suOW.js} +1 -1
  73. package/dist/_frontend/assets/html-tYW1suOW.js.br +0 -0
  74. package/dist/_frontend/assets/html-tYW1suOW.js.gz +0 -0
  75. package/dist/_frontend/assets/{htmlMode-lgosNfbL.js → htmlMode-D8PP1KzI.js} +1 -1
  76. package/dist/_frontend/assets/htmlMode-D8PP1KzI.js.br +0 -0
  77. package/dist/_frontend/assets/htmlMode-D8PP1KzI.js.gz +0 -0
  78. package/dist/_frontend/assets/{index-Du3lx1aS.js → index-BS4907Xx.js} +3 -3
  79. package/dist/_frontend/assets/index-BS4907Xx.js.br +0 -0
  80. package/dist/_frontend/assets/index-BS4907Xx.js.gz +0 -0
  81. package/dist/_frontend/assets/{index-CF_3sCub.js → index-DUFuoecn.js} +1 -1
  82. package/dist/_frontend/assets/index-DUFuoecn.js.br +0 -0
  83. package/dist/_frontend/assets/{index-CF_3sCub.js.gz → index-DUFuoecn.js.gz} +0 -0
  84. package/dist/_frontend/assets/index-G7kdtXvB.js +943 -0
  85. package/dist/_frontend/assets/index-G7kdtXvB.js.br +0 -0
  86. package/dist/_frontend/assets/index-G7kdtXvB.js.gz +0 -0
  87. package/dist/_frontend/assets/{javascript-DiHw3Eat.js → javascript-osiUQvXx.js} +1 -1
  88. package/dist/_frontend/assets/{jsonMode-DHUA2y1U.js → jsonMode-CdMHir1V.js} +1 -1
  89. package/dist/_frontend/assets/jsonMode-CdMHir1V.js.br +0 -0
  90. package/dist/_frontend/assets/jsonMode-CdMHir1V.js.gz +0 -0
  91. package/dist/_frontend/assets/{liquid-CprftmsS.js → liquid-DXwQHd5_.js} +1 -1
  92. package/dist/_frontend/assets/liquid-DXwQHd5_.js.br +0 -0
  93. package/dist/_frontend/assets/liquid-DXwQHd5_.js.gz +0 -0
  94. package/dist/_frontend/assets/{lspLanguageFeatures-gYxt31s1.js → lspLanguageFeatures-CEI6BsAF.js} +1 -1
  95. package/dist/_frontend/assets/lspLanguageFeatures-CEI6BsAF.js.br +0 -0
  96. package/dist/_frontend/assets/lspLanguageFeatures-CEI6BsAF.js.gz +0 -0
  97. package/dist/_frontend/assets/{mdx-h6Mzhp-3.js → mdx-9AQsIt7X.js} +1 -1
  98. package/dist/_frontend/assets/mdx-9AQsIt7X.js.br +0 -0
  99. package/dist/_frontend/assets/mdx-9AQsIt7X.js.gz +0 -0
  100. package/dist/_frontend/assets/{python-Fgw1BN-I.js → python-OXQa8Ri9.js} +1 -1
  101. package/dist/_frontend/assets/python-OXQa8Ri9.js.br +0 -0
  102. package/dist/_frontend/assets/python-OXQa8Ri9.js.gz +0 -0
  103. package/dist/_frontend/assets/{razor-u10uqgtH.js → razor-BU90Q8Je.js} +1 -1
  104. package/dist/_frontend/assets/razor-BU90Q8Je.js.br +0 -0
  105. package/dist/_frontend/assets/razor-BU90Q8Je.js.gz +0 -0
  106. package/dist/_frontend/assets/{tsMode-DQQ14WKr.js → tsMode-B3c5Otu4.js} +1 -1
  107. package/dist/_frontend/assets/tsMode-B3c5Otu4.js.br +0 -0
  108. package/dist/_frontend/assets/tsMode-B3c5Otu4.js.gz +0 -0
  109. package/dist/_frontend/assets/{typescript-mwUa5zn0.js → typescript-CtOR5Qmc.js} +1 -1
  110. package/dist/_frontend/assets/typescript-CtOR5Qmc.js.br +0 -0
  111. package/dist/_frontend/assets/typescript-CtOR5Qmc.js.gz +0 -0
  112. package/dist/_frontend/assets/{workers-CZKhoZKF.js → workers-Dx3N8uH5.js} +1 -1
  113. package/dist/_frontend/assets/workers-Dx3N8uH5.js.br +3 -0
  114. package/dist/_frontend/assets/workers-Dx3N8uH5.js.gz +0 -0
  115. package/dist/_frontend/assets/{xml-CZ3_PIeb.js → xml-DW3BhbEz.js} +1 -1
  116. package/dist/_frontend/assets/xml-DW3BhbEz.js.br +0 -0
  117. package/dist/_frontend/assets/xml-DW3BhbEz.js.gz +0 -0
  118. package/dist/_frontend/assets/{yaml-DBARGNE3.js → yaml-BZ76X4yO.js} +1 -1
  119. package/dist/_frontend/assets/yaml-BZ76X4yO.js.br +0 -0
  120. package/dist/_frontend/assets/yaml-BZ76X4yO.js.gz +0 -0
  121. package/dist/_frontend/index.html +1 -1
  122. package/dist/controller-main.js +199 -75
  123. package/dist/controller-main.js.map +1 -1
  124. package/dist/main.js +1483 -784
  125. package/dist/main.js.map +1 -1
  126. package/dist/postgres/migrations/20260727_000001_init.js +572 -4
  127. package/dist/postgres/migrations/20260727_000001_init.js.map +1 -1
  128. package/dist/postgres/migrations/20260916_000001_agent_web_search.js +28 -0
  129. package/dist/postgres/migrations/20260916_000001_agent_web_search.js.map +1 -0
  130. package/dist/postgres/migrations/20260918_000001_turn_active_executor_id.js +32 -0
  131. package/dist/postgres/migrations/20260918_000001_turn_active_executor_id.js.map +1 -0
  132. package/dist/sqlite/migrations/20260916_000001_agent_web_search.js +28 -0
  133. package/dist/sqlite/migrations/20260916_000001_agent_web_search.js.map +1 -0
  134. package/dist/sqlite/migrations/20260918_000001_turn_active_executor_id.js +33 -0
  135. package/dist/sqlite/migrations/20260918_000001_turn_active_executor_id.js.map +1 -0
  136. package/package.json +5 -4
  137. package/dist/_frontend/assets/AgentCodeSnippets-T7PR6PDP-BtYr0hCd.js.br +0 -0
  138. package/dist/_frontend/assets/AgentCodeSnippets-T7PR6PDP-BtYr0hCd.js.gz +0 -0
  139. package/dist/_frontend/assets/AgentMetricChart-J3RCSCAG-BeGf38SC.js +0 -1
  140. package/dist/_frontend/assets/AgentMetricChart-J3RCSCAG-BeGf38SC.js.br +0 -0
  141. package/dist/_frontend/assets/AgentMetricChart-J3RCSCAG-BeGf38SC.js.gz +0 -0
  142. package/dist/_frontend/assets/AgentOverview-WC7WMNMS-Mem5rK6Y.js +0 -1
  143. package/dist/_frontend/assets/AgentOverview-WC7WMNMS-Mem5rK6Y.js.br +0 -0
  144. package/dist/_frontend/assets/AgentOverview-WC7WMNMS-Mem5rK6Y.js.gz +0 -0
  145. package/dist/_frontend/assets/AgentSessionEventTimeline-SETKGGCI-T0eprzt1.js.br +0 -0
  146. package/dist/_frontend/assets/AgentSessionEventTimeline-SETKGGCI-T0eprzt1.js.gz +0 -0
  147. package/dist/_frontend/assets/AgentSessionEventTimelineChart-4Y7PY5SJ-Bp3PJ8em.js.br +0 -0
  148. package/dist/_frontend/assets/AgentSessionEventTimelineChart-4Y7PY5SJ-Bp3PJ8em.js.gz +0 -0
  149. package/dist/_frontend/assets/AgentSessions-YCAPM5GK-BA8KqWPB.js +0 -1
  150. package/dist/_frontend/assets/AgentSessions-YCAPM5GK-BA8KqWPB.js.br +0 -0
  151. package/dist/_frontend/assets/AgentSessions-YCAPM5GK-BA8KqWPB.js.gz +0 -0
  152. package/dist/_frontend/assets/ConnectorSettings-PXWRCFAL-Dgi-SPKS.js +0 -1
  153. package/dist/_frontend/assets/ConnectorSettings-PXWRCFAL-Dgi-SPKS.js.br +0 -0
  154. package/dist/_frontend/assets/ConnectorSettings-PXWRCFAL-Dgi-SPKS.js.gz +0 -0
  155. package/dist/_frontend/assets/DrawerLayout-U7YPUZBR-EBVDvExP.js.br +0 -0
  156. package/dist/_frontend/assets/DrawerLayout-U7YPUZBR-EBVDvExP.js.gz +0 -0
  157. package/dist/_frontend/assets/ModelSettings-VXYMJEMO-YOyVspML.js +0 -1
  158. package/dist/_frontend/assets/ModelSettings-VXYMJEMO-YOyVspML.js.br +0 -0
  159. package/dist/_frontend/assets/ModelSettings-VXYMJEMO-YOyVspML.js.gz +0 -0
  160. package/dist/_frontend/assets/SandboxSettings-6DRUH72J-B_nMtkgp.js +0 -1
  161. package/dist/_frontend/assets/SandboxSettings-6DRUH72J-B_nMtkgp.js.br +0 -0
  162. package/dist/_frontend/assets/SandboxSettings-6DRUH72J-B_nMtkgp.js.gz +0 -0
  163. package/dist/_frontend/assets/SchedulesPage-2G6F4XO6-CXGVFkK8.js +0 -1
  164. package/dist/_frontend/assets/SchedulesPage-2G6F4XO6-CXGVFkK8.js.br +0 -0
  165. package/dist/_frontend/assets/SchedulesPage-2G6F4XO6-CXGVFkK8.js.gz +0 -0
  166. package/dist/_frontend/assets/SettingsBuilder-6FJVZLJT-Drq1vNUK.js.br +0 -0
  167. package/dist/_frontend/assets/SettingsBuilder-6FJVZLJT-Drq1vNUK.js.gz +0 -0
  168. package/dist/_frontend/assets/ShellRouteSync-SJXFKUAJ-Yi-uh3fh.js.br +0 -0
  169. package/dist/_frontend/assets/ShellRouteSync-SJXFKUAJ-Yi-uh3fh.js.gz +0 -0
  170. package/dist/_frontend/assets/SidebarLayout-EQ7EYCWR-D-Rd9Wui.js +0 -2
  171. package/dist/_frontend/assets/SidebarLayout-EQ7EYCWR-D-Rd9Wui.js.br +0 -0
  172. package/dist/_frontend/assets/SidebarLayout-EQ7EYCWR-D-Rd9Wui.js.gz +0 -0
  173. package/dist/_frontend/assets/SkillSettings-IHVI7FDM-DEkrBUBp.js.br +0 -0
  174. package/dist/_frontend/assets/SkillSettings-IHVI7FDM-DEkrBUBp.js.gz +0 -0
  175. package/dist/_frontend/assets/TrueForgeUIWithRouter-5OJFI3PF-BXv2aJab.js +0 -1
  176. package/dist/_frontend/assets/WidgetLayout-PN5ZDOLM-CcGUI6sr.js.br +0 -0
  177. package/dist/_frontend/assets/WidgetLayout-PN5ZDOLM-CcGUI6sr.js.gz +0 -0
  178. package/dist/_frontend/assets/chunk-2QTH6JHX-DrgkYdZs.js.br +0 -0
  179. package/dist/_frontend/assets/chunk-2QTH6JHX-DrgkYdZs.js.gz +0 -0
  180. package/dist/_frontend/assets/chunk-2UBSLCKB-Bq4rnsqJ.js.br +0 -0
  181. package/dist/_frontend/assets/chunk-2UBSLCKB-Bq4rnsqJ.js.gz +0 -0
  182. package/dist/_frontend/assets/chunk-62JRHF6Z-BrctyCH-.js.br +0 -0
  183. package/dist/_frontend/assets/chunk-62JRHF6Z-BrctyCH-.js.gz +0 -0
  184. package/dist/_frontend/assets/chunk-PX6MNNN3-DWHQBAi-.js +0 -1
  185. package/dist/_frontend/assets/chunk-PX6MNNN3-DWHQBAi-.js.br +0 -0
  186. package/dist/_frontend/assets/chunk-PX6MNNN3-DWHQBAi-.js.gz +0 -0
  187. package/dist/_frontend/assets/cssMode-jP6sLsrL.js.br +0 -0
  188. package/dist/_frontend/assets/cssMode-jP6sLsrL.js.gz +0 -0
  189. package/dist/_frontend/assets/freemarker2-Dbeghe9Y.js.br +0 -0
  190. package/dist/_frontend/assets/freemarker2-Dbeghe9Y.js.gz +0 -0
  191. package/dist/_frontend/assets/handlebars-DTmlyeUV.js.br +0 -0
  192. package/dist/_frontend/assets/handlebars-DTmlyeUV.js.gz +0 -0
  193. package/dist/_frontend/assets/html-CjOPMUvl.js.br +0 -0
  194. package/dist/_frontend/assets/html-CjOPMUvl.js.gz +0 -0
  195. package/dist/_frontend/assets/htmlMode-lgosNfbL.js.br +0 -10
  196. package/dist/_frontend/assets/htmlMode-lgosNfbL.js.gz +0 -0
  197. package/dist/_frontend/assets/index-CF_3sCub.js.br +0 -0
  198. package/dist/_frontend/assets/index-DVIyIfJR.js +0 -933
  199. package/dist/_frontend/assets/index-DVIyIfJR.js.br +0 -0
  200. package/dist/_frontend/assets/index-DVIyIfJR.js.gz +0 -0
  201. package/dist/_frontend/assets/index-Du3lx1aS.js.br +0 -0
  202. package/dist/_frontend/assets/index-Du3lx1aS.js.gz +0 -0
  203. package/dist/_frontend/assets/jsonMode-DHUA2y1U.js.br +0 -0
  204. package/dist/_frontend/assets/jsonMode-DHUA2y1U.js.gz +0 -0
  205. package/dist/_frontend/assets/liquid-CprftmsS.js.br +0 -0
  206. package/dist/_frontend/assets/liquid-CprftmsS.js.gz +0 -0
  207. package/dist/_frontend/assets/lspLanguageFeatures-gYxt31s1.js.br +0 -0
  208. package/dist/_frontend/assets/lspLanguageFeatures-gYxt31s1.js.gz +0 -0
  209. package/dist/_frontend/assets/mdx-h6Mzhp-3.js.br +0 -0
  210. package/dist/_frontend/assets/mdx-h6Mzhp-3.js.gz +0 -0
  211. package/dist/_frontend/assets/python-Fgw1BN-I.js.br +0 -0
  212. package/dist/_frontend/assets/python-Fgw1BN-I.js.gz +0 -0
  213. package/dist/_frontend/assets/razor-u10uqgtH.js.br +0 -0
  214. package/dist/_frontend/assets/razor-u10uqgtH.js.gz +0 -0
  215. package/dist/_frontend/assets/tsMode-DQQ14WKr.js.br +0 -0
  216. package/dist/_frontend/assets/tsMode-DQQ14WKr.js.gz +0 -0
  217. package/dist/_frontend/assets/typescript-mwUa5zn0.js.br +0 -0
  218. package/dist/_frontend/assets/typescript-mwUa5zn0.js.gz +0 -0
  219. package/dist/_frontend/assets/workers-CZKhoZKF.js.br +0 -0
  220. package/dist/_frontend/assets/workers-CZKhoZKF.js.gz +0 -0
  221. package/dist/_frontend/assets/xml-CZ3_PIeb.js.br +0 -0
  222. package/dist/_frontend/assets/xml-CZ3_PIeb.js.gz +0 -0
  223. package/dist/_frontend/assets/yaml-DBARGNE3.js.br +0 -0
  224. package/dist/_frontend/assets/yaml-DBARGNE3.js.gz +0 -0
@@ -1 +1 @@
1
- import{c as u,r as s,j as t,I as x,e as i}from"./index-DVIyIfJR.js";function h({snippets:a}){var c;const m=u("AgentCodeBlock"),[d,n]=s.useState((c=a[0])==null?void 0:c.language),[o,l]=s.useState("stream");s.useEffect(()=>{var e;n((e=a[0])==null?void 0:e.language),l("stream")},[a]);const r=a.find(e=>e.language===d)??a[0];return r===void 0?t.jsx("div",{className:"flex h-full min-h-64 items-center justify-center px-6 text-sm text-text-secondary",children:"No code samples for this agent."}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-3 md:flex-row",children:[t.jsx("nav",{"aria-label":"Code sample languages",className:"flex shrink-0 gap-1 overflow-auto md:w-44 md:flex-col",children:a.map(e=>t.jsxs("button",{type:"button","aria-current":r.language===e.language?"page":void 0,className:i("flex h-9 shrink-0 cursor-pointer items-center gap-2 rounded-md px-2.5 text-left text-xs text-text-secondary","hover:bg-ghost-button-hover hover:text-text-primary",r.language===e.language&&"bg-primary-button-bg/10 font-medium text-primary-button-bg"),onClick:()=>n(e.language),children:[e.icon?t.jsx("img",{src:e.icon,alt:"",className:"size-4 shrink-0 object-contain"}):t.jsx(x,{name:"code",className:"size-4 shrink-0"}),e.labelName]},e.language))}),t.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-card-bg",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-1 border-b border-border px-3",children:[t.jsx("div",{className:"flex items-end gap-1",children:[["stream","Stream"],["nonStream","Non-stream"]].map(([e,g])=>t.jsx("button",{type:"button",className:i("relative h-10 cursor-pointer px-3 text-xs font-medium text-text-secondary",o===e&&"text-primary-button-bg after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary-button-bg"),onClick:()=>l(e),children:g},e))}),t.jsxs("a",{href:"https://trueforge.dev/api/use-agent",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-text-secondary",children:[t.jsx("span",{children:"View Docs"}),t.jsx(x,{name:"external-link",className:"size-3 shrink-0"})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(m,{code:r.sampleCode[o],language:r.language})})]})]})}export{h as default};
1
+ import{c as u,r as s,j as t,I as x,e as i}from"./index-G7kdtXvB.js";function h({snippets:a}){var c;const m=u("AgentCodeBlock"),[d,n]=s.useState((c=a[0])==null?void 0:c.language),[o,l]=s.useState("stream");s.useEffect(()=>{var e;n((e=a[0])==null?void 0:e.language),l("stream")},[a]);const r=a.find(e=>e.language===d)??a[0];return r===void 0?t.jsx("div",{className:"flex h-full min-h-64 items-center justify-center px-6 text-sm text-text-secondary",children:"No code samples for this agent."}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-3 md:flex-row",children:[t.jsx("nav",{"aria-label":"Code sample languages",className:"flex shrink-0 gap-1 overflow-auto md:w-44 md:flex-col",children:a.map(e=>t.jsxs("button",{type:"button","aria-current":r.language===e.language?"page":void 0,className:i("flex h-9 shrink-0 cursor-pointer items-center gap-2 rounded-md px-2.5 text-left text-xs text-text-secondary","hover:bg-ghost-button-hover hover:text-text-primary",r.language===e.language&&"bg-primary-button-bg/10 font-medium text-primary-button-bg"),onClick:()=>n(e.language),children:[e.icon?t.jsx("img",{src:e.icon,alt:"",className:"size-4 shrink-0 object-contain"}):t.jsx(x,{name:"code",className:"size-4 shrink-0"}),e.labelName]},e.language))}),t.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-card-bg",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-1 border-b border-border px-3",children:[t.jsx("div",{className:"flex items-end gap-1",children:[["stream","Stream"],["nonStream","Non-stream"]].map(([e,g])=>t.jsx("button",{type:"button",className:i("relative h-10 cursor-pointer px-3 text-xs font-medium text-text-secondary",o===e&&"text-primary-button-bg after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary-button-bg"),onClick:()=>l(e),children:g},e))}),t.jsxs("a",{href:"https://trueforge.dev/api/use-agent",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-text-secondary",children:[t.jsx("span",{children:"View Docs"}),t.jsx(x,{name:"external-link",className:"size-3 shrink-0"})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(m,{code:r.sampleCode[o],language:r.language})})]})]})}export{h as default};
@@ -0,0 +1 @@
1
+ import{as as j,r as d,j as a,aN as C,aM as k}from"./index-G7kdtXvB.js";import{c as M,a as F,d as R,L as S,e as D,P as T,f as p,p as w}from"./index-DUFuoecn.js";F.register(R,S,D,T,p,w);var E=["#6366F1","#2563eb","#0EA5E9"],$=["#6366F1","#60a5fa","#38BDF8"],A=new Intl.NumberFormat(void 0,{maximumFractionDigits:4}),O=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function f(e,t){return t==="$"?C(e):t==="ms"?k(e):`${A.format(e)}${t==="count"||t.length===0?"":` ${t}`}`}function _(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:O.format(t)}function G({graph:e,definition:t,error:u,colorIndex:b=0}){const l=j(),r=l==="dark"?$:E,i=l==="dark"?"#71717a":"#a1a1aa",m=l==="dark"?"#27272a":"#e4e4e7",c=d.useMemo(()=>e==null?[]:[...new Set(e.graphLines.flatMap(s=>s.values.map(o=>o.timestamp)))].sort(),[e]),y=d.useMemo(()=>({labels:c.map(_),datasets:(e==null?void 0:e.graphLines.map((s,o)=>{const L=new Map(s.values.map(n=>[n.timestamp,n.value])),x=r[(b+o)%r.length];return{label:s.name,data:c.map(n=>L.get(n)??null),borderColor:x,backgroundColor:x,pointRadius:0,pointHoverRadius:0,borderWidth:2,borderCapStyle:"butt",borderJoinStyle:"miter",tension:0,spanGaps:!0}}))??[]}),[b,r,e,c]),v=d.useMemo(()=>({responsive:!0,maintainAspectRatio:!1,animation:!1,interaction:{intersect:!1,mode:"index"},plugins:{legend:{display:((e==null?void 0:e.graphLines.length)??0)>1,labels:{color:i,boxWidth:10,boxHeight:2}},tooltip:{callbacks:{label:s=>{const o=s.parsed.y;return`${s.dataset.label??""}: ${o==null?"—":f(o,(e==null?void 0:e.unit)??"")}`}}}},scales:{x:{grid:{display:!1},border:{color:m},ticks:{color:i,maxRotation:0,autoSkip:!0,maxTicksLimit:8}},y:{beginAtZero:!0,grid:{color:m},border:{display:!1},ticks:{color:i,callback:s=>f(Number(s),(e==null?void 0:e.unit)??"")}}}}),[i,e,m]),N=(e==null?void 0:e.graphLines.some(s=>s.values.length>0))===!0;return a.jsxs("section",{className:"min-w-0 rounded-lg border border-border bg-card-bg p-4","data-slot":"agent-metric-chart",children:[a.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:(e==null?void 0:e.displayName)??t.displayName}),a.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:(e==null?void 0:e.description)??t.description}),a.jsx("div",{className:"mt-4 h-64",children:u!=null?a.jsx("div",{className:"flex h-full items-center justify-center text-sm text-failure-bg",children:u}):N?a.jsx(M,{data:y,options:v}):a.jsx("div",{className:"flex h-full items-center justify-center text-sm text-text-secondary",children:"No data"})})]})}export{G as AgentMetricChart};
@@ -0,0 +1 @@
1
+ import{c as I,m as V,r as y,j as e,I as N,e as A,h as q,v as G,w as W,x as Q,y as H,z as J,A as X,B as Y,D as Z,E as ee}from"./index-G7kdtXvB.js";var te={read:"border-border bg-secondary-bg text-text-secondary",write:"border-border bg-secondary-bg text-text-primary",destructive:"border-failure-bg/30 bg-failure-bg/10 text-failure-bg"},P={read:0,write:1,unknown:2,destructive:3};function se(t){return t===1?"1 tool":`${t} tools`}function ne(t){return t.includes(Z)?"All tools":t.filter(l=>l.startsWith("@")).join(" ")}function re({count:t}){return e.jsxs("span",{className:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium","aria-label":`${t} ${t===1?"tool needs":"tools need"} approval`,children:[e.jsx(N,{name:"shield-check",className:"size-2.5"}),t]})}function ae({kind:t}){return e.jsx("span",{className:A("shrink-0 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium",te[t]),children:t})}function oe({approvalRequired:t,toolName:l}){return e.jsx(ee,{content:t?"Asks for approval before running":"Runs without asking for approval",triggerClassName:"shrink-0",children:e.jsx("span",{role:"img","aria-label":`${l} ${t?"requires approval":"runs without approval"}`,className:A("flex size-5 items-center justify-center rounded-md border",t?"border-warning-bg/50 bg-warning-bg/10 text-warning-bg":"border-border text-text-secondary"),children:e.jsx(N,{name:t?"shield-check":"shield",className:"size-3"})})})}function le({mcpServers:t}){const l=I("AgentOverviewCard"),i=q(),c=i==null?void 0:i.getMcpTools,u=y.useMemo(()=>G(t),[t]),[M,w]=y.useState({}),[k,s]=y.useState(()=>new Set);return y.useEffect(()=>{if(c===void 0)return;let r=!1;for(const x of u)c({connectorId:x.name}).then(f=>{r||w(h=>({...h,[x.name]:f}))},()=>{});return()=>{r=!0}},[c,u]),u.length===0?e.jsx(l,{title:"MCP Servers & Tools",icon:"plug",count:0,children:e.jsx("p",{className:"text-text-secondary text-xs",children:"No connectors attached."})}):e.jsx(l,{title:"MCP Servers & Tools",icon:"plug",count:u.length,children:e.jsx("ul",{className:"space-y-1.5",children:u.map(r=>{const x=M[r.name]??[],f=W(r.value),h=Q(r.value),m=H({enableSelectors:h,disableSelectors:J(r.value),tools:x}),d=m.names.map(n=>{const o=x.find(S=>S.name===n),g=o===void 0?void 0:X(o);return{toolName:n,kind:g,approvalRequired:Y({toolName:n,tools:x,selectors:f})}}).sort((n,o)=>P[n.kind??"unknown"]-P[o.kind??"unknown"]),p=d.filter(n=>n.approvalRequired).length,b=k.has(r.id);return e.jsxs("li",{className:"overflow-hidden rounded-md border border-border",children:[e.jsxs("button",{type:"button","aria-expanded":b,disabled:d.length===0,className:"flex w-full cursor-pointer items-center gap-2 bg-secondary-bg px-2.5 py-2 text-left text-xs hover:bg-ghost-button-hover disabled:cursor-default disabled:hover:bg-secondary-bg",onClick:()=>s(n=>{const o=new Set(n);return b?o.delete(r.id):o.add(r.id),o}),children:[e.jsx(N,{name:"chevron-down",className:A("size-3 shrink-0 text-text-secondary transition-transform",b?void 0:"-rotate-90",d.length===0&&"invisible")}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:r.name}),e.jsx("span",{className:"shrink-0 text-text-secondary",children:m.resolved?se(d.length):ne(h)}),p>0?e.jsx(re,{count:p}):null]}),b?e.jsx("ul",{className:"divide-y divide-border border-t border-border",children:d.map(({toolName:n,kind:o,approvalRequired:g})=>e.jsxs("li",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[0.6875rem]",title:n,children:n}),o?e.jsx(ae,{kind:o}):null,e.jsx(oe,{approvalRequired:g,toolName:n})]},n))}):null]},r.id)})})})}var v="text-right font-mono text-primary-button-bg";function T(t){return typeof t=="object"&&t!=null}function U(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function C(t,...l){for(const i of l){const c=t==null?void 0:t[i];if(c!==void 0)return c}}function ie(t){const l=t.lastIndexOf("/");return l>=0?t.slice(l+1):t}function de({detail:t}){var S,E,O,R,_,$,D,F,L,z,B,K;const l=I("Markdown"),i=I("AgentOverviewCard"),c=V(),[u,M]=y.useState("markdown"),[w,k]=y.useState(!1),s=t.agentSpec,r=s.skills??[],x=T(s.model.params)?s.model.params:null,f=C(x,"maxTokens","max_tokens"),h=C(x,"temperature"),m=T(s.config)?s.config:null,d=T(m==null?void 0:m.sandbox)?m.sandbox:null,p=(S=s.instructions)!=null&&S.trim()?s.instructions:null,b=(E=t.description)!=null&&E.trim()?t.description:null,n=[["Sandbox",typeof(d==null?void 0:d.enabled)=="boolean"?d.enabled?"Enabled":"Disabled":void 0],["Iteration limit",C(m,"iterationLimit","iteration_limit")],["Response format",C(m,"responseFormat","response_format")]].filter(a=>typeof a[1]=="string"||typeof a[1]=="number"),o=[["Generative UI",(R=(O=s.config)==null?void 0:O.generativeUi)==null?void 0:R.enabled],["Dynamic sub-agents",($=(_=s.config)==null?void 0:_.dynamicSubAgents)==null?void 0:$.enabled],["Ask user questions",(F=(D=s.config)==null?void 0:D.askUserQuestions)==null?void 0:F.enabled],...((L=c==null?void 0:c.webSearch)==null?void 0:L.enabled)===!0?[["Web search",(B=(z=s.config)==null?void 0:z.webSearch)==null?void 0:B.enabled]]:[]].filter(a=>typeof a[1]=="boolean"),g=u==="markdown"?"Raw":"Markdown";return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 md:overflow-hidden",children:e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 md:grid-cols-[minmax(0,1fr)_22rem] md:overflow-hidden",children:[e.jsxs("section",{className:"flex min-h-64 flex-col rounded-lg border border-border bg-card-bg p-4 text-text-primary",children:[e.jsxs("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-2",children:[e.jsxs("h2",{className:"flex items-center gap-1.5 text-sm font-semibold text-text-primary",children:[e.jsx(N,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),p?e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-md border border-border bg-primary-bg text-xs font-medium text-text-secondary",role:"group","aria-label":"Instructions actions",children:[e.jsx("button",{type:"button","aria-label":`Show ${g}`,onClick:()=>M(a=>a==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:g}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:w?"Copied!":"Copy","aria-label":w?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(p).then(()=>{k(!0),setTimeout(()=>k(!1),2e3)})},className:"inline-flex cursor-pointer items-center justify-center px-2 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:e.jsx(N,{name:w?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:p?u==="markdown"?e.jsx(l,{content:p,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:p}):e.jsx("p",{className:"text-sm text-text-secondary",children:"No instructions for this agent."})})]}),e.jsxs("aside",{className:"flex min-h-0 min-w-0 flex-col gap-3 md:overflow-auto",children:[b?e.jsx(i,{title:"Description",icon:"file",children:e.jsx("p",{className:"text-xs text-text-secondary",children:b})}):null,e.jsx(i,{title:"Model Configuration",icon:"cpu",children:e.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-text-secondary",children:"Model"}),e.jsx("dd",{className:A(v,"truncate"),title:s.model.name,children:ie(s.model.name)}),typeof f=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:v,children:f})]}):null,((K=s.model.params)==null?void 0:K.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:v,children:s.model.params.reasoningEffort})]}):null,typeof h=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:v,children:h})]}):null]})}),e.jsx(le,{mcpServers:s.mcpServers}),e.jsx(i,{title:"Attached Skills",icon:"lightbulb",count:r.length,children:r.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:r.map((a,j)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:U(a)??`Skill ${j+1}`},`${U(a)??"skill"}-${j}`))})}),n.length>0?e.jsx(i,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:n.map(([a,j])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:a}),e.jsx("dd",{className:v,children:j})]},a))})}):null,o.length>0?e.jsx(i,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:o.map(([a,j])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:a}),e.jsx("dd",{className:v,children:j?"Enabled":"Disabled"})]},a))})}):null]})]})})}export{de as default};
@@ -1 +1 @@
1
- import{c as u,aj as b,r,ak as f,j as t,al as h,e as S}from"./index-DVIyIfJR.js";function j({turns:l,segments:a,onSelectTurn:o}){const d=u("AgentSessionEventTimelineChart"),c=b()==="dark",[i,x]=r.useState(()=>new Set),p=r.useMemo(()=>{const e=new Set(a.map(s=>s.type));return f.filter(s=>e.has(s.id))},[a]),m=r.useCallback(e=>{x(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n})},[]);return a.length===0?null:t.jsxs("div",{className:"w-full","data-slot":"agent-session-event-timeline",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2","data-slot":"agent-session-event-types",children:[t.jsx("span",{className:"text-xs font-medium uppercase text-text-secondary",children:"Event types"}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:p.map(e=>{const s=!i.has(e.id);return t.jsxs("button",{type:"button","aria-pressed":s,className:S("flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",s?"border-border text-text-primary":"border-transparent text-text-secondary opacity-80"),onClick:()=>m(e.id),children:[t.jsx("span",{className:"size-2 rounded-sm",style:{backgroundColor:h(e.id,c)}}),e.label]},e.id)})})]}),t.jsx("div",{className:"w-full p-2",children:t.jsx(d,{turns:l,segments:a,hiddenTypes:i,onSelectTurn:o})})]})}export{j as AgentSessionEventTimeline};
1
+ import{c as m,as as b,r,at as f,j as t,au as h,e as S}from"./index-G7kdtXvB.js";function g({turns:l,segments:a,onSelectTurn:o}){const d=m("AgentSessionEventTimelineChart"),c=b()==="dark",[i,x]=r.useState(()=>new Set),p=r.useMemo(()=>{const e=new Set(a.map(s=>s.type));return f.filter(s=>e.has(s.id))},[a]),u=r.useCallback(e=>{x(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n})},[]);return a.length===0?null:t.jsxs("div",{className:"w-full","data-slot":"agent-session-event-timeline",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2","data-slot":"agent-session-event-types",children:[t.jsx("span",{className:"text-xs font-medium uppercase text-text-secondary",children:"Event types"}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:p.map(e=>{const s=!i.has(e.id);return t.jsxs("button",{type:"button","aria-pressed":s,className:S("flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",s?"border-border text-text-primary":"border-transparent text-text-secondary opacity-80"),onClick:()=>u(e.id),children:[t.jsx("span",{className:"size-2 rounded-sm",style:{backgroundColor:h(e.id,c)}}),e.label]},e.id)})})]}),t.jsx("div",{className:"w-full p-2",children:t.jsx(d,{turns:l,segments:a,hiddenTypes:i,onSelectTurn:o})})]})}export{g as AgentSessionEventTimeline};
@@ -1 +1 @@
1
- import{aj as Z,r as a,am as Re,an as Ie,ao as Pe,ap as De,aq as Le,ar as Ge,as as Be,at as m,al as E,au as $,av as Y,aw as Oe,ax as $e,ay as He,az as Xe,j as s,aA as We,aB as ze,aC as Ue,aD as Fe,aE as Ve,aF as Ke,aG as S,aH as qe,aI as ve}from"./index-DVIyIfJR.js";import{C as Ye,a as Je,B as Qe,b as Ze,L as et,P as tt,S as st,p as nt}from"./index-CF_3sCub.js";function at(n){return n.type!=="system"||n.description.trim().length>0}function Me({segment:n,subAgentLabel:r}){const d=!n.isMarker&&!qe.has(n.type),i=n.description.trim();return n.type==="system"?i.length===0?null:s.jsx("p",{className:"max-w-[25rem] whitespace-normal break-words text-xs font-medium text-text-primary",children:i}):s.jsxs("div",{className:"max-h-72 max-w-[25rem] overflow-auto whitespace-normal break-words text-xs",children:[r!=null?s.jsx("div",{className:"border-b border-border py-1.5 text-text-secondary",children:`Sub-Agent: ${r}`}):null,s.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[s.jsx("span",{className:n.type==="error"?"font-medium text-failure-bg":"font-medium text-text-secondary",children:ve(n.type)}),d?s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)}):null]}),i.length>0?s.jsx("p",{className:"mt-1.5 line-clamp-6 font-medium text-text-primary",children:i}):null]})}function rt({turn:n,turnNumber:r,durationMs:d,segments:i}){const C=Z()==="dark";return s.jsxs("div",{className:"max-h-72 w-72 max-w-full overflow-auto text-xs text-text-primary",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-semibold",children:`Turn ${r}`}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:Fe(d)})]}),s.jsxs("div",{className:"mt-1 flex flex-col text-text-secondary",children:[n.totalCostInUsd!=null?s.jsx("span",{children:`Cost: ${Ve(n.totalCostInUsd)}`}):null,n.totalTokens!=null?s.jsx("span",{children:`Tokens: ${Ke(n.totalTokens)}`}):null]}),s.jsx("div",{className:"mt-2 border-t border-border pt-2",children:i.map(l=>{const b=l.type==="tool_call"||l.type==="sub_agent"?l.description:l.title;return s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(l.type,C)}}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:b}),l.isMarker?null:s.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-text-secondary",children:S(l.endMs-l.startMs)})]},l.id)})})]})}function ot({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Tool calls"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(r=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:r.description||r.title}),s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}function lt({group:n}){const r=Z()==="dark",d=n.segments.length===1?n.segments[0]:void 0;return d!=null?s.jsx(Me,{segment:d}):s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Events"}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(i=>s.jsxs("div",{className:"flex min-w-0 items-start gap-1.5 py-0.5",children:[s.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(i.type,r)}}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium text-text-secondary",children:ve(i.type)}),s.jsx("div",{className:"wrap-break-word font-medium text-text-primary",children:i.description.trim()||i.title})]})]},i.id))})]})}function it({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Sub-agents"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map((r,d)=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:n.segments.length===1?r.description||r.title:`Sub-agent ${d+1}: ${r.description||r.title}`}),n.segments.length===1?null:s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}Je.register(Qe,Ze,et,tt,st,nt);var J=4,ye=12,be=12,ct=2,ut=8,dt=2,mt=30;function pt({heights:n,gaps:r}){const d=[];let i=0;return n.forEach((C,l)=>{d.push(i+C/2),i+=C+(r[l]??0)}),{centers:d,band:i}}function Q(n){return n==="sub_agent"?0:n==="model"?2:1}function xt(n){if(!("x"in n)||!("y"in n)||!("base"in n))return null;const{x:r,y:d,base:i}=n;return typeof r!="number"||typeof d!="number"||typeof i!="number"?null:{x:(r+i)/2,y:d}}function yt({turns:n,segments:r,hiddenTypes:d,onSelectTurn:i}){var fe;const l=Z()==="dark",b=l?"#8c8c92":"#71717a",H=l?"#27272a":"#e4e4e7",ee=l?"#3f3f46":"#E0ECFD",te=l?"#52525b":"#E0ECFD",X=a.useRef(null),[se,je]=a.useState(0),[ne,we]=a.useState(mt),[o,ae]=a.useState(null),[ge,W]=a.useState(null),z=a.useRef(""),U=a.useRef(null);a.useEffect(()=>{const e=X.current;if(e==null)return;const t=()=>je(e.clientWidth);t();const c=new ResizeObserver(t);return c.observe(e),()=>c.disconnect()},[]);const f=a.useCallback(()=>{const e=X.current,t=U.current;e==null||t==null||W({left:t,top:e.getBoundingClientRect().bottom})},[]),Ne=a.useCallback(()=>{z.current="",U.current=null,ae(null),W(null)},[]);a.useEffect(()=>{if(o!=null)return f(),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[f,o]);const ke=Math.max(0,...r.map(e=>e.endMs)),v=Math.max(1,ze(ke)),{turnStartsMs:re,turnOrdinals:oe,turnRanges:F}=a.useMemo(()=>Re(r),[r]),T=a.useMemo(()=>re.filter((e,t)=>t===0||e<=v),[v,re]),le=Math.max(0,T.length-1),Ee=Math.max(se/2,se-ye*le-be),M=v/Math.max(1,Ee),x=ye*M,V=v+le*x,ie=V+be*M,ce=a.useMemo(()=>T.slice(1).map((e,t)=>({startMs:e+t*x,endMs:e+(t+1)*x})),[T,x]),_=a.useMemo(()=>r.flatMap(e=>{if(d.has(e.type))return[];const t=(oe.get(e.turnIndex)??0)*x;return[{...e,startMs:e.startMs+t,endMs:e.endMs+t}]}),[d,r,x,oe]),R=a.useMemo(()=>Ie(_),[_]),j=a.useMemo(()=>_.filter(e=>!e.isMarker),[_]),y=a.useMemo(()=>F.length<2?[]:F.map(e=>({...e,id:`turn-${e.turnIndex}`,durationMs:e.endMs-e.startMs,startMs:e.startMs+e.ordinal*x,endMs:e.endMs+e.ordinal*x+J*M})),[M,x,F]),w=a.useMemo(()=>j.filter(e=>e.type==="sub_agent"),[j]),I=a.useMemo(()=>Pe(w),[w]),ue=a.useMemo(()=>De({bars:I,subAgentSegments:w}),[I,w]),g=a.useMemo(()=>Le({subAgentSegments:w,threadSegments:j,minWidthMs:J*M}),[j,M,w]),P=a.useMemo(()=>[...j.filter(e=>e.threadId===Ge),...I].sort((e,t)=>e.startMs-t.startMs||e.endMs-t.endMs),[j,I]),N=a.useMemo(()=>Be(P.filter(e=>e.type==="tool_call")).filter(e=>e.segments.length>1),[P]),de=a.useMemo(()=>new Set(N.flatMap(e=>e.segments.map(t=>t.id))),[N]),D=a.useMemo(()=>P.filter(e=>!de.has(e.id)),[de,P]),me=g.reduce((e,t)=>Math.max(e,t.lane+1),0),K=y.length>0,A=K?1:0,L=A+1,{centers:k,band:G}=a.useMemo(()=>{const e=[...K?[16]:[],10,28,...Array.from({length:me},()=>12)],t=e.map((c,u)=>u===e.length-1?0:u===A?dt:ut);return pt({heights:e,gaps:t})},[K,me,A]),q=a.useMemo(()=>[...y.map(e=>({type:m.turn,bar:e})),...R.map(e=>({type:m.markerGroup,group:e})),...g.flatMap(e=>e.segments.map(t=>({type:m.event,segment:t}))),...D.map(e=>{if(e.type!=="sub_agent")return{type:m.event,segment:e};const t=ue.find(c=>c.barId===e.id);return t==null?{type:m.event,segment:e}:{type:m.subAgentGroup,group:t}}),...N.map(e=>({type:m.toolCallGroup,group:e}))],[D,R,ue,g,N,y]),B=({label:e,range:t,y:c,color:u,hover:p,thickness:h,order:O=1,inflateAmount:he})=>({label:e,data:[{x:Ue(t),y:c}],backgroundColor:u,hoverBackgroundColor:p,hoverBorderColor:p,borderWidth:0,borderSkipped:!1,borderRadius:ct,minBarLength:J,barThickness:h,grouped:!1,order:O,...he==null?{}:{inflateAmount:he}}),Se=a.useMemo(()=>({datasets:[...y.map(e=>B({label:`Turn ${e.ordinal+1}`,range:e,y:k[0]??0,color:ee,hover:te,thickness:16})),...R.map(e=>{var u;const t=e.segments.length===1?(u=e.segments[0])==null?void 0:u.type:"system",c=E(t??"system",l);return{type:"scatter",label:e.segments.map(p=>Y(p.type)).join(", "),data:[{x:e.startMs,y:k[A]??0}],pointStyle:"rectRot",pointRadius:5,pointHoverRadius:6,clip:!1,backgroundColor:c,hoverBackgroundColor:$(t??"system",l),borderWidth:0,order:0}}),...g.flatMap(e=>e.segments.map(t=>B({label:`${Y(t.type)}: ${t.title}`,range:t,y:k[L+1+e.lane]??0,color:E(t.type,l),hover:$(t.type,l),thickness:12,order:Q(t.type),inflateAmount:.5}))),...D.map(e=>B({label:`${Y(e.type)}: ${e.title}`,range:e,y:k[L]??0,color:E(e.type,l),hover:$(e.type,l),thickness:28,order:Q(e.type),inflateAmount:.5})),...N.map(e=>B({label:"Parallel tool calls",range:e,y:k[L]??0,color:E("tool_call",l),hover:$("tool_call",l),thickness:28,order:Q("tool_call"),inflateAmount:.5}))]}),[k,L,l,D,R,A,g,N,y,ee,te]),Ce=a.useMemo(()=>({id:"turnLabels",afterDatasetsDraw(e){const{ctx:t}=e;t.save(),t.fillStyle=b,t.font="500 10px sans-serif",t.textAlign="center",t.textBaseline="middle",y.forEach((c,u)=>{const p=e.getDatasetMeta(u).data[0];if(p==null)return;const h=xt(p);h&&t.fillText(`T${c.ordinal+1}`,h.x,h.y)}),t.restore()}}),[b,y]),Te=a.useMemo(()=>({id:"timelineOverhead",afterLayout(e){const t=Math.round(e.height-e.chartArea.height);we(c=>c===t?c:t)}}),[]),Ae=a.useMemo(()=>({indexAxis:"y",animation:!1,responsive:!0,maintainAspectRatio:!1,onClick:(e,t)=>{var u;const c=q[((u=t[0])==null?void 0:u.datasetIndex)??-1];(c==null?void 0:c.type)===m.turn&&(i==null||i(c.bar.turnIndex))},onHover:(e,t)=>{var O;const c=(O=t[0])==null?void 0:O.datasetIndex,u=c==null?null:q[c]??null,p=e.native;if((p==null?void 0:p.target)instanceof HTMLElement&&(p.target.style.cursor=(u==null?void 0:u.type)===m.turn?"pointer":"default"),p instanceof MouseEvent&&(U.current=p.clientX,f()),c==null)return;const h=Xe(u);if(z.current!==h){if(z.current=h,ae(u),u==null){W(null);return}f()}},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{type:"linear",position:"top",min:0,max:ie,grid:{color:H},border:{color:H},afterBuildTicks:e=>{e.ticks=He({activeTotalMs:v,turnStartsMs:T,turnGapMs:x})},ticks:{color:b,align:"inner",autoSkip:!1,includeBounds:!1,maxTicksLimit:9,callback:e=>{const t=Number(e);return t<=V?Oe($e(t,ce)):""}}},y:{type:"linear",display:!1,reverse:!0,offset:!1,min:0,max:G,grid:{display:!1}}}}),[v,T,b,G,q,H,i,f,ce,ie,V,x]),pe=(o==null?void 0:o.type)===m.turn?n[o.bar.turnIndex]:void 0,_e=a.useMemo(()=>({height:G+ne}),[G,ne]),xe=(o==null?void 0:o.type)===m.turn&&pe!=null?s.jsx(rt,{turn:pe,turnNumber:o.bar.ordinal+1,durationMs:o.bar.durationMs,segments:r.filter(e=>e.turnIndex===o.bar.turnIndex)}):(o==null?void 0:o.type)===m.event&&at(o.segment)?s.jsx(Me,{segment:o.segment,subAgentLabel:o.segment.type==="sub_agent"||(fe=g.find(e=>e.threadId===o.segment.threadId))==null?void 0:fe.track.description}):(o==null?void 0:o.type)===m.toolCallGroup?s.jsx(ot,{group:o.group}):(o==null?void 0:o.type)===m.markerGroup?s.jsx(lt,{group:o.group}):(o==null?void 0:o.type)===m.subAgentGroup?s.jsx(it,{group:o.group}):null;return s.jsx("div",{ref:X,className:"w-full","data-slot":"agent-session-event-timeline-chart",children:s.jsx(We,{title:xe,side:"bottom",triggerClassName:"block w-full",followCursor:!0,open:o!=null&&xe!=null,className:"max-w-[min(25rem,calc(100vw-1rem))] whitespace-normal",anchor:ge,children:s.jsx("div",{className:"w-full",style:_e,onMouseLeave:Ne,children:s.jsx(Ye,{type:"bar",data:Se,options:Ae,plugins:[Ce,Te]})})})})}export{yt as AgentSessionEventTimelineChart};
1
+ import{as as Z,r as a,av as Re,aw as Ie,ax as Pe,ay as De,az as Le,aA as Ge,aB as Be,aC as m,au as E,aD as $,aE as Q,aF as Oe,aG as $e,aH as He,aI as Xe,j as s,aJ as We,aK as ze,aL as Ue,aM as Fe,aN as Ke,aO as Ve,aP as S,aQ as Je,aR as ve}from"./index-G7kdtXvB.js";import{C as Qe,a as Ye,B as qe,b as Ze,L as et,P as tt,S as st,p as nt}from"./index-DUFuoecn.js";function at(n){return n.type!=="system"||n.description.trim().length>0}function Me({segment:n,subAgentLabel:r}){const d=!n.isMarker&&!Je.has(n.type),i=n.description.trim();return n.type==="system"?i.length===0?null:s.jsx("p",{className:"max-w-[25rem] whitespace-normal break-words text-xs font-medium text-text-primary",children:i}):s.jsxs("div",{className:"max-h-72 max-w-[25rem] overflow-auto whitespace-normal break-words text-xs",children:[r!=null?s.jsx("div",{className:"border-b border-border py-1.5 text-text-secondary",children:`Sub-Agent: ${r}`}):null,s.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[s.jsx("span",{className:n.type==="error"?"font-medium text-failure-bg":"font-medium text-text-secondary",children:ve(n.type)}),d?s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)}):null]}),i.length>0?s.jsx("p",{className:"mt-1.5 line-clamp-6 font-medium text-text-primary",children:i}):null]})}function rt({turn:n,turnNumber:r,durationMs:d,segments:i}){const C=Z()==="dark";return s.jsxs("div",{className:"max-h-72 w-72 max-w-full overflow-auto text-xs text-text-primary",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-semibold",children:`Turn ${r}`}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:Fe(d)})]}),s.jsxs("div",{className:"mt-1 flex flex-col text-text-secondary",children:[n.totalCostInUsd!=null?s.jsx("span",{children:`Cost: ${Ke(n.totalCostInUsd)}`}):null,n.totalTokens!=null?s.jsx("span",{children:`Tokens: ${Ve(n.totalTokens)}`}):null]}),s.jsx("div",{className:"mt-2 border-t border-border pt-2",children:i.map(l=>{const b=l.type==="tool_call"||l.type==="sub_agent"?l.description:l.title;return s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(l.type,C)}}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:b}),l.isMarker?null:s.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-text-secondary",children:S(l.endMs-l.startMs)})]},l.id)})})]})}function ot({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Tool calls"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(r=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:r.description||r.title}),s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}function lt({group:n}){const r=Z()==="dark",d=n.segments.length===1?n.segments[0]:void 0;return d!=null?s.jsx(Me,{segment:d}):s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Events"}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(i=>s.jsxs("div",{className:"flex min-w-0 items-start gap-1.5 py-0.5",children:[s.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(i.type,r)}}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium text-text-secondary",children:ve(i.type)}),s.jsx("div",{className:"wrap-break-word font-medium text-text-primary",children:i.description.trim()||i.title})]})]},i.id))})]})}function it({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Sub-agents"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map((r,d)=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:n.segments.length===1?r.description||r.title:`Sub-agent ${d+1}: ${r.description||r.title}`}),n.segments.length===1?null:s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}Ye.register(qe,Ze,et,tt,st,nt);var Y=4,ye=12,be=12,ct=2,ut=8,dt=2,mt=30;function pt({heights:n,gaps:r}){const d=[];let i=0;return n.forEach((C,l)=>{d.push(i+C/2),i+=C+(r[l]??0)}),{centers:d,band:i}}function q(n){return n==="sub_agent"?0:n==="model"?2:1}function xt(n){if(!("x"in n)||!("y"in n)||!("base"in n))return null;const{x:r,y:d,base:i}=n;return typeof r!="number"||typeof d!="number"||typeof i!="number"?null:{x:(r+i)/2,y:d}}function yt({turns:n,segments:r,hiddenTypes:d,onSelectTurn:i}){var fe;const l=Z()==="dark",b=l?"#8c8c92":"#71717a",H=l?"#27272a":"#e4e4e7",ee=l?"#3f3f46":"#E0ECFD",te=l?"#52525b":"#E0ECFD",X=a.useRef(null),[se,je]=a.useState(0),[ne,we]=a.useState(mt),[o,ae]=a.useState(null),[ge,W]=a.useState(null),z=a.useRef(""),U=a.useRef(null);a.useEffect(()=>{const e=X.current;if(e==null)return;const t=()=>je(e.clientWidth);t();const c=new ResizeObserver(t);return c.observe(e),()=>c.disconnect()},[]);const f=a.useCallback(()=>{const e=X.current,t=U.current;e==null||t==null||W({left:t,top:e.getBoundingClientRect().bottom})},[]),Ne=a.useCallback(()=>{z.current="",U.current=null,ae(null),W(null)},[]);a.useEffect(()=>{if(o!=null)return f(),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[f,o]);const ke=Math.max(0,...r.map(e=>e.endMs)),v=Math.max(1,ze(ke)),{turnStartsMs:re,turnOrdinals:oe,turnRanges:F}=a.useMemo(()=>Re(r),[r]),T=a.useMemo(()=>re.filter((e,t)=>t===0||e<=v),[v,re]),le=Math.max(0,T.length-1),Ee=Math.max(se/2,se-ye*le-be),M=v/Math.max(1,Ee),x=ye*M,K=v+le*x,ie=K+be*M,ce=a.useMemo(()=>T.slice(1).map((e,t)=>({startMs:e+t*x,endMs:e+(t+1)*x})),[T,x]),_=a.useMemo(()=>r.flatMap(e=>{if(d.has(e.type))return[];const t=(oe.get(e.turnIndex)??0)*x;return[{...e,startMs:e.startMs+t,endMs:e.endMs+t}]}),[d,r,x,oe]),R=a.useMemo(()=>Ie(_),[_]),j=a.useMemo(()=>_.filter(e=>!e.isMarker),[_]),y=a.useMemo(()=>F.length<2?[]:F.map(e=>({...e,id:`turn-${e.turnIndex}`,durationMs:e.endMs-e.startMs,startMs:e.startMs+e.ordinal*x,endMs:e.endMs+e.ordinal*x+Y*M})),[M,x,F]),w=a.useMemo(()=>j.filter(e=>e.type==="sub_agent"),[j]),I=a.useMemo(()=>Pe(w),[w]),ue=a.useMemo(()=>De({bars:I,subAgentSegments:w}),[I,w]),g=a.useMemo(()=>Le({subAgentSegments:w,threadSegments:j,minWidthMs:Y*M}),[j,M,w]),P=a.useMemo(()=>[...j.filter(e=>e.threadId===Ge),...I].sort((e,t)=>e.startMs-t.startMs||e.endMs-t.endMs),[j,I]),N=a.useMemo(()=>Be(P.filter(e=>e.type==="tool_call")).filter(e=>e.segments.length>1),[P]),de=a.useMemo(()=>new Set(N.flatMap(e=>e.segments.map(t=>t.id))),[N]),D=a.useMemo(()=>P.filter(e=>!de.has(e.id)),[de,P]),me=g.reduce((e,t)=>Math.max(e,t.lane+1),0),V=y.length>0,A=V?1:0,L=A+1,{centers:k,band:G}=a.useMemo(()=>{const e=[...V?[16]:[],10,28,...Array.from({length:me},()=>12)],t=e.map((c,u)=>u===e.length-1?0:u===A?dt:ut);return pt({heights:e,gaps:t})},[V,me,A]),J=a.useMemo(()=>[...y.map(e=>({type:m.turn,bar:e})),...R.map(e=>({type:m.markerGroup,group:e})),...g.flatMap(e=>e.segments.map(t=>({type:m.event,segment:t}))),...D.map(e=>{if(e.type!=="sub_agent")return{type:m.event,segment:e};const t=ue.find(c=>c.barId===e.id);return t==null?{type:m.event,segment:e}:{type:m.subAgentGroup,group:t}}),...N.map(e=>({type:m.toolCallGroup,group:e}))],[D,R,ue,g,N,y]),B=({label:e,range:t,y:c,color:u,hover:p,thickness:h,order:O=1,inflateAmount:he})=>({label:e,data:[{x:Ue(t),y:c}],backgroundColor:u,hoverBackgroundColor:p,hoverBorderColor:p,borderWidth:0,borderSkipped:!1,borderRadius:ct,minBarLength:Y,barThickness:h,grouped:!1,order:O,...he==null?{}:{inflateAmount:he}}),Se=a.useMemo(()=>({datasets:[...y.map(e=>B({label:`Turn ${e.ordinal+1}`,range:e,y:k[0]??0,color:ee,hover:te,thickness:16})),...R.map(e=>{var u;const t=e.segments.length===1?(u=e.segments[0])==null?void 0:u.type:"system",c=E(t??"system",l);return{type:"scatter",label:e.segments.map(p=>Q(p.type)).join(", "),data:[{x:e.startMs,y:k[A]??0}],pointStyle:"rectRot",pointRadius:5,pointHoverRadius:6,clip:!1,backgroundColor:c,hoverBackgroundColor:$(t??"system",l),borderWidth:0,order:0}}),...g.flatMap(e=>e.segments.map(t=>B({label:`${Q(t.type)}: ${t.title}`,range:t,y:k[L+1+e.lane]??0,color:E(t.type,l),hover:$(t.type,l),thickness:12,order:q(t.type),inflateAmount:.5}))),...D.map(e=>B({label:`${Q(e.type)}: ${e.title}`,range:e,y:k[L]??0,color:E(e.type,l),hover:$(e.type,l),thickness:28,order:q(e.type),inflateAmount:.5})),...N.map(e=>B({label:"Parallel tool calls",range:e,y:k[L]??0,color:E("tool_call",l),hover:$("tool_call",l),thickness:28,order:q("tool_call"),inflateAmount:.5}))]}),[k,L,l,D,R,A,g,N,y,ee,te]),Ce=a.useMemo(()=>({id:"turnLabels",afterDatasetsDraw(e){const{ctx:t}=e;t.save(),t.fillStyle=b,t.font="500 10px sans-serif",t.textAlign="center",t.textBaseline="middle",y.forEach((c,u)=>{const p=e.getDatasetMeta(u).data[0];if(p==null)return;const h=xt(p);h&&t.fillText(`T${c.ordinal+1}`,h.x,h.y)}),t.restore()}}),[b,y]),Te=a.useMemo(()=>({id:"timelineOverhead",afterLayout(e){const t=Math.round(e.height-e.chartArea.height);we(c=>c===t?c:t)}}),[]),Ae=a.useMemo(()=>({indexAxis:"y",animation:!1,responsive:!0,maintainAspectRatio:!1,onClick:(e,t)=>{var u;const c=J[((u=t[0])==null?void 0:u.datasetIndex)??-1];(c==null?void 0:c.type)===m.turn&&(i==null||i(c.bar.turnIndex))},onHover:(e,t)=>{var O;const c=(O=t[0])==null?void 0:O.datasetIndex,u=c==null?null:J[c]??null,p=e.native;if((p==null?void 0:p.target)instanceof HTMLElement&&(p.target.style.cursor=(u==null?void 0:u.type)===m.turn?"pointer":"default"),p instanceof MouseEvent&&(U.current=p.clientX,f()),c==null)return;const h=Xe(u);if(z.current!==h){if(z.current=h,ae(u),u==null){W(null);return}f()}},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{type:"linear",position:"top",min:0,max:ie,grid:{color:H},border:{color:H},afterBuildTicks:e=>{e.ticks=He({activeTotalMs:v,turnStartsMs:T,turnGapMs:x})},ticks:{color:b,align:"inner",autoSkip:!1,includeBounds:!1,maxTicksLimit:9,callback:e=>{const t=Number(e);return t<=K?Oe($e(t,ce)):""}}},y:{type:"linear",display:!1,reverse:!0,offset:!1,min:0,max:G,grid:{display:!1}}}}),[v,T,b,G,J,H,i,f,ce,ie,K,x]),pe=(o==null?void 0:o.type)===m.turn?n[o.bar.turnIndex]:void 0,_e=a.useMemo(()=>({height:G+ne}),[G,ne]),xe=(o==null?void 0:o.type)===m.turn&&pe!=null?s.jsx(rt,{turn:pe,turnNumber:o.bar.ordinal+1,durationMs:o.bar.durationMs,segments:r.filter(e=>e.turnIndex===o.bar.turnIndex)}):(o==null?void 0:o.type)===m.event&&at(o.segment)?s.jsx(Me,{segment:o.segment,subAgentLabel:o.segment.type==="sub_agent"||(fe=g.find(e=>e.threadId===o.segment.threadId))==null?void 0:fe.track.description}):(o==null?void 0:o.type)===m.toolCallGroup?s.jsx(ot,{group:o.group}):(o==null?void 0:o.type)===m.markerGroup?s.jsx(lt,{group:o.group}):(o==null?void 0:o.type)===m.subAgentGroup?s.jsx(it,{group:o.group}):null;return s.jsx("div",{ref:X,className:"w-full","data-slot":"agent-session-event-timeline-chart",children:s.jsx(We,{title:xe,side:"bottom",triggerClassName:"block w-full",followCursor:!0,open:o!=null&&xe!=null,className:"max-w-[min(25rem,calc(100vw-1rem))] whitespace-normal",anchor:ge,children:s.jsx("div",{className:"w-full",style:_e,onMouseLeave:Ne,children:s.jsx(Qe,{type:"bar",data:Se,options:Ae,plugins:[Ce,Te]})})})})}export{yt as AgentSessionEventTimelineChart};
@@ -0,0 +1 @@
1
+ var Ue=e=>{throw TypeError(e)};var Ve=(e,t,n)=>t.has(e)||Ue("Cannot "+n);var ge=(e,t,n)=>(Ve(e,t,"read from private field"),n?n.call(e):t.get(e)),Ye=(e,t,n)=>t.has(e)?Ue("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,o)=>(Ve(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n);import{a as Ot}from"./chunk-B76JC5B2-BMXX-7i9.js";import{r as x,j as C,bC as Ft,M as Gt,N as Bt,a as Ht,bD as Wt,bE as $t,c as Re,O as Ut,o as Xe,Y as Vt,X as Ee,I as Yt,e as qt,a6 as Xt,a7 as _t,a8 as Jt,a9 as Kt,aa as Zt,W as _e,bF as Qt}from"./index-G7kdtXvB.js";function en(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function tn(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function nn(e){return e/100*window.innerHeight}function on(e){return e/100*window.innerWidth}function sn(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function me({groupSize:e,panelElement:t,styleProp:n}){let o;const[s,r]=sn(n);switch(r){case"%":{o=s/100*e;break}case"px":{o=s;break}case"rem":{o=tn(t,s);break}case"em":{o=en(t,s);break}case"vh":{o=nn(s);break}case"vw":{o=on(s);break}}return o}function B(e){return parseFloat(e.toFixed(3))}function pe({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,s)=>(o+=t==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,o),0)}function Me(e){const{panels:t}=e,n=pe({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:s,panelConstraints:r}=o;let u=0;if(r.collapsedSize!==void 0){const c=me({groupSize:n,panelElement:s,styleProp:r.collapsedSize});u=B(c/n*100)}let l;if(r.defaultSize!==void 0){const c=me({groupSize:n,panelElement:s,styleProp:r.defaultSize});l=B(c/n*100)}let a=0;if(r.minSize!==void 0){const c=me({groupSize:n,panelElement:s,styleProp:r.minSize});a=B(c/n*100)}let i=100;if(r.maxSize!==void 0){const c=me({groupSize:n,panelElement:s,styleProp:r.maxSize});i=B(c/n*100)}return{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:u,collapsible:r.collapsible===!0,defaultSize:l,disabled:r.disabled,minSize:a,maxSize:i,panelId:o.id}})}function D(e,t="Assertion error"){if(!e)throw Error(t)}function ke(e,t){return Array.from(t).sort(e==="horizontal"?rn:an)}function rn(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function an(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function pt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ht(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function ln({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let s,r=Number.MAX_VALUE;for(const u of t){const{x:l,y:a}=ht(o,u),i=e==="horizontal"?l:a;i<r&&(r=i,s=u)}return D(s,"No rect found"),s}let ze;function un(){return ze===void 0&&(typeof matchMedia=="function"?ze=!!matchMedia("(pointer:coarse)").matches:ze=!1),ze}function gt(e){const{element:t,orientation:n,panels:o,separators:s}=e,r=ke(n,Array.from(t.children).filter(pt).map(m=>({element:m}))).map(({element:m})=>m),u=[];let l=!1,a=!1,i=-1,c=-1,g=0,f,w=[];{let m=-1;for(const d of r)d.hasAttribute("data-panel")&&(m++,d.hasAttribute("data-disabled")||(g++,i===-1&&(i=m),c=m))}if(g>1){let m=-1;for(const d of r)if(d.hasAttribute("data-panel")){m++;const h=o.find(p=>p.element===d);if(h){if(f){const p=f.element.getBoundingClientRect(),b=d.getBoundingClientRect();let S;if(a){const y=n==="horizontal"?new DOMRect(p.right,p.top,0,p.height):new DOMRect(p.left,p.bottom,p.width,0),v=n==="horizontal"?new DOMRect(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(w.length){case 0:{S=[y,v];break}case 1:{const M=w[0],E=ln({orientation:n,rects:[p,b],targetRect:M.element.getBoundingClientRect()});S=[M,E===p?v:y];break}default:{S=w;break}}}else w.length?S=w:S=[n==="horizontal"?new DOMRect(p.right,b.top,b.left-p.right,b.height):new DOMRect(b.left,p.bottom,b.width,b.top-p.bottom)];for(const y of S){let v="width"in y?y:y.element.getBoundingClientRect();const M=un()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(v.width<M){const k=M-v.width;v=new DOMRect(v.x-k/2,v.y,v.width+k,v.height)}if(v.height<M){const k=M-v.height;v=new DOMRect(v.x,v.y-k/2,v.width,v.height+k)}const E=m<=i||m>c;!l&&!E&&u.push({group:e,groupSize:pe({group:e}),panels:[f,h],separator:"width"in y?void 0:y,rect:v}),l=!1}}a=!1,f=h,w=[]}}else if(d.hasAttribute("data-separator")){d.ariaDisabled!==null&&(l=!0);const h=s.find(p=>p.element===d);h?w.push(h):(f=void 0,w=[])}else a=!0}return u}var Z;class mt{constructor(){Ye(this,Z,{})}addListener(t,n){const o=ge(this,Z)[t];return o===void 0?ge(this,Z)[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=ge(this,Z)[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let s=!1,r=null;const u=Array.from(o);for(let l=0;l<u.length;l++){const a=u[l];try{a.call(null,n)}catch(i){r===null&&(s=!0,r=i)}}if(s)throw r}}removeAllListeners(){qe(this,Z,{})}removeListener(t,n){const o=ge(this,Z)[t];if(o!==void 0){const s=o.indexOf(n);s>=0&&o.splice(s,1)}}}Z=new WeakMap;let de={cursorFlags:0,state:"inactive"};const Te=new mt;function ne(){return de}function cn(e){return Te.addListener("change",e)}function dn(e){const t=de,n={...de};n.cursorFlags=e,de=n,Te.emit("change",{prev:t,next:n})}function fe(e){const t=de;de=e,Te.emit("change",{prev:t,next:e})}const fn=e=>e,De=()=>{},vt=1,bt=2,yt=4,St=8,Je=3,Ke=12;let we;function Ze(){return we===void 0&&(we=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(we=!0)),we}function pn({cursorFlags:e,groups:t,state:n}){let o=0,s=0;switch(n){case"active":case"hover":t.forEach(r=>{if(!r.mutableState.disableCursor)switch(r.orientation){case"horizontal":{o++;break}case"vertical":{s++;break}}})}if(!(o===0&&s===0)){switch(n){case"active":{if(e&&Ze()){const r=(e&vt)!==0,u=(e&bt)!==0,l=(e&yt)!==0,a=(e&St)!==0;if(r)return l?"se-resize":a?"ne-resize":"e-resize";if(u)return l?"sw-resize":a?"nw-resize":"w-resize";if(l)return"s-resize";if(a)return"n-resize"}break}}return Ze()?o>0&&s>0?"move":o>0?"ew-resize":"ns-resize":o>0&&s>0?"grab":o>0?"col-resize":"row-resize"}}const Qe=new WeakMap;function je(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=Qe.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=ne();switch(o.state){case"active":case"hover":{const s=pn({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),r=`*, *:hover {cursor: ${s} !important; }`;if(t===r)return;t=r,s?n.cssRules.length===0?n.insertRule(r):n.replaceSync(r):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Qe.set(e,{prevStyle:t,styleSheet:n})}let q=new Map;const xt=new mt;function hn(e){q=new Map(q),q.delete(e)}function et(e,t){for(const[n]of q)if(n.id===e)return n}function Q(e,t){for(const[n,o]of q)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ee(){return q}function Ne(e,t){return xt.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function J(e,t,n){const o=q.get(e);q=new Map(q),q.set(e,t),xt.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:o,next:t})}function zt(e){const t=ne(),n=ee();let o=!1;switch(t.state){case"active":fe({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(je(e),o=!0,t.hitRegions.forEach(s=>{if(!n.has(s.group))return;const r=Q(s.group.id,!0);J(s.group,r,{isUserInteraction:!0})}))}return o}function tt(e){e.defaultPrevented||zt(e.currentTarget)}function gn(e,t,n){let o,s={x:1/0,y:1/0};for(const r of t){const u=ht(n,r.rect);switch(e){case"horizontal":{u.x<=s.x&&(o=r,s=u);break}case"vertical":{u.y<=s.y&&(o=r,s=u);break}}}return o?{distance:s,hitRegion:o}:void 0}function mn(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function vn(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:st(e),b:st(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();D(o,"Stacking order can only be calculated for elements with a common ancestor");const s={a:ot(nt(n.a)),b:ot(nt(n.b))};if(s.a===s.b){const r=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let l=r.length;for(;l--;){const a=r[l];if(a===u.a)return 1;if(a===u.b)return-1}}return Math.sign(s.a-s.b)}const bn=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function yn(e){const t=getComputedStyle(wt(e)??e).display;return t==="flex"||t==="inline-flex"}function Sn(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||yn(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||bn.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function nt(e){let t=e.length;for(;t--;){const n=e[t];if(D(n,"Missing node"),Sn(n))return n}return null}function ot(e){return e&&Number(getComputedStyle(e).zIndex)||0}function st(e){const t=[];for(;e;)t.push(e),e=wt(e);return t}function wt(e){const{parentNode:t}=e;return mn(t)?t.host:t}function xn(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function zn({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!pt(n)||n.contains(e)||e.contains(n))return!0;if(vn(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(xn(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function Ae(e,t){const n=[];return t.forEach((o,s)=>{if(s.disabled)return;const r=gt(s),u=gn(s.orientation,r,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&zn({groupElement:s.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function wn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function O(e,t,n=0){return Math.abs(B(e)-B(t))<=n}function Y(e,t){return O(e,t)?0:e>t?1:-1}function ce({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:s=0,collapsible:r,disabled:u,maxSize:l=100,minSize:a=0}=t;if(u&&!e)return n;if(Y(o,a)<0)if(r){const i=(s+a)/2;Y(o,i)<0?o=s:o=a}else o=a;return o=Math.min(l,o),o=B(o),o}function be({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:s,trigger:r}){if(O(e,0))return t;const u=r==="imperative-api",l=Object.values(t),a=Object.values(s),i=[...l],[c,g]=o;D(c!=null,"Invalid first pivot index"),D(g!=null,"Invalid second pivot index");let f=0;switch(r){case"keyboard":{{const d=e<0?g:c,h=n[d];D(h,`Panel constraints not found for index ${d}`);const{collapsedSize:p=0,collapsible:b,minSize:S=0}=h;if(b){const y=l[d];if(D(y!=null,`Previous layout not found for panel index ${d}`),O(y,p)){const v=S-y;Y(v,Math.abs(e))>0&&(e=e<0?0-v:v)}}}{const d=e<0?c:g,h=n[d];D(h,`No panel constraints found for index ${d}`);const{collapsedSize:p=0,collapsible:b,minSize:S=0}=h;if(b){const y=l[d];if(D(y!=null,`Previous layout not found for panel index ${d}`),O(y,S)){const v=y-p;Y(v,Math.abs(e))>0&&(e=e<0?0-v:v)}}}break}default:{const d=e<0?g:c,h=n[d];D(h,`Panel constraints not found for index ${d}`);const p=l[d],{collapsible:b,collapsedSize:S,minSize:y}=h;if(b&&Y(p,y)<0)if(e>0){const v=y-S,M=v/2,E=p+e;Y(E,y)<0&&(e=Y(e,M)<=0?0:v)}else{const v=y-S,M=100-v/2,E=p-e;Y(E,y)<0&&(e=Y(100+e,M)>0?0:-v)}break}}{const d=e<0?1:-1;let h=e<0?g:c,p=0;for(;;){const S=l[h];D(S!=null,`Previous layout not found for panel index ${h}`);const y=ce({overrideDisabledPanels:u,panelConstraints:n[h],prevSize:S,size:100})-S;if(p+=y,h+=d,h<0||h>=n.length)break}const b=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-b:b}{let d=e<0?c:g;for(;d>=0&&d<n.length;){const h=Math.abs(e)-Math.abs(f),p=l[d];D(p!=null,`Previous layout not found for panel index ${d}`);const b=p-h,S=ce({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:p,size:b});if(!O(p,S)&&(f+=p-S,i[d]=S,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(wn(a,i))return s;{const d=e<0?g:c,h=l[d];D(h!=null,`Previous layout not found for panel index ${d}`);const p=h+f,b=ce({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:h,size:p});if(i[d]=b,!O(b,p)){let S=p-b,y=e<0?g:c;for(;y>=0&&y<n.length;){const v=i[y];D(v!=null,`Previous layout not found for panel index ${y}`);const M=v+S,E=ce({overrideDisabledPanels:u,panelConstraints:n[y],prevSize:v,size:M});if(O(v,E)||(S-=E-v,i[y]=E),O(S,0))break;e>0?y--:y++}}}const w=Object.values(i).reduce((d,h)=>h+d,0);if(!O(w,100,.1))return s;const m=Object.keys(s);return i.reduce((d,h,p)=>(d[m[p]]=h,d),{})}function oe(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Y(e[n],t[n])!==0)return!1;return!0}function se({layout:e,panelConstraints:t}){const n=Object.values(e),o=[...n],s=o.reduce((l,a)=>l+a,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(l=>`${l}%`).join(", ")}`);if(!O(s,100)&&o.length>0)for(let l=0;l<t.length;l++){const a=o[l];D(a!=null,`No layout data found for index ${l}`);const i=100/s*a;o[l]=i}let r=0;for(let l=0;l<t.length;l++){const a=n[l];D(a!=null,`No layout data found for index ${l}`);const i=o[l];D(i!=null,`No layout data found for index ${l}`);const c=ce({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:a,size:i});i!=c&&(r+=i-c,o[l]=c)}if(!O(r,0))for(let l=0;l<t.length;l++){const a=o[l];D(a!=null,`No layout data found for index ${l}`);const i=a+r,c=ce({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:a,size:i});if(a!==c&&(r-=c-a,o[l]=c,O(r,0)))break}const u=Object.keys(e);return o.reduce((l,a,i)=>(l[u[i]]=a,l),{})}function Ct({groupId:e,panelId:t}){const n=()=>{const a=ee();for(const[i,{defaultLayoutDeferred:c,derivedPanelConstraints:g,layout:f,groupSize:w,separatorToPanels:m}]of a)if(i.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:g,group:i,groupSize:w,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},o=()=>{const a=n().derivedPanelConstraints.find(i=>i.panelId===t);if(a!==void 0)return a;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const a=n().group.panels.find(i=>i.id===t);if(a!==void 0)return a;throw Error(`Layout not found for Panel ${t}`)},r=()=>{const a=n().layout[t];if(a!==void 0)return a;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:a,panels:i,prevLayout:c,derivedPanelConstraints:g})=>{const f=r(),w=i.findIndex(h=>h.id===t),m=w===0,d=w===i.length-1;if(d&&a<f&&(m||i.slice(0,w).every((h,p)=>{const b=g[p];return(b==null?void 0:b.collapsible)&&O(b.collapsedSize,c[b.panelId])}))){const h=i.slice(0,w).reduce((p,b)=>p+c[b.id],0);return{...c,[t]:B(100-h)}}return be({delta:d?f-a:a-f,initialLayout:c,panelConstraints:g,pivotIndices:d?[w-1,w]:[w,w+1],prevLayout:c,trigger:"imperative-api"})},l=a=>{const i=r();if(a===i)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:g,group:f,groupSize:w,layout:m,separatorToPanels:d}=n(),h=u({nextSize:a,panels:f.panels,prevLayout:m,derivedPanelConstraints:g}),p=se({layout:h,panelConstraints:g});oe(m,p)||J(f,{defaultLayoutDeferred:c,derivedPanelConstraints:g,groupSize:w,layout:p,separatorToPanels:d})};return{collapse:()=>{const{collapsible:a,collapsedSize:i}=o(),{mutableValues:c}=s(),g=r();a&&g!==i&&(c.expandToSize=g,l(i))},expand:()=>{const{collapsible:a,collapsedSize:i,minSize:c}=o(),{mutableValues:g}=s(),f=r();if(a&&f===i){let w=g.expandToSize??c;w===0&&(w=1),l(w)}},getSize:()=>{const{group:a}=n(),i=r(),{element:c}=s(),g=a.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:i,inPixels:g}},isCollapsed:()=>{const{collapsible:a,collapsedSize:i}=o(),c=r();return a&&O(i,c)},resize:a=>{const{group:i}=n(),{element:c}=s(),g=pe({group:i}),f=me({groupSize:g,panelElement:c,styleProp:a}),w=B(f/g*100);l(w)}}}function rt(e){if(e.defaultPrevented)return;const t=ee();Ae(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const o=n.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(o){const s=o.panelConstraints.defaultSize,r=Ct({groupId:n.group.id,panelId:o.id});r&&s!==void 0&&(r.resize(s),e.preventDefault())}}})}function Le(e){const t=ee();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function Lt({groupId:e}){const t=()=>{const n=ee();for(const[o,s]of n)if(o.id===e)return{group:o,...s};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:s,group:r,groupSize:u,layout:l,separatorToPanels:a}=t(),i=se({layout:n,panelConstraints:s});return o?l:(oe(l,i)||J(r,{defaultLayoutDeferred:o,derivedPanelConstraints:s,groupSize:u,layout:i,separatorToPanels:a}),i)}}}function te(e,t){const n=Le(e),o=Q(n.id,!0),s=n.separators.find(c=>c.element===e);D(s,"Matching separator not found");const r=o.separatorToPanels.get(s);D(r,"Matching panels not found");const u=r.map(c=>n.panels.indexOf(c)),l=Lt({groupId:n.id}).getLayout(),a=be({delta:t,initialLayout:l,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:l,trigger:"keyboard"}),i=se({layout:a,panelConstraints:o.derivedPanelConstraints});oe(l,i)||J(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:i,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function it(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Le(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&te(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&te(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&te(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&te(t,-5);break}case"End":{e.preventDefault(),te(t,100);break}case"Enter":{e.preventDefault();const o=Le(t),s=Q(o.id,!0),{derivedPanelConstraints:r,layout:u,separatorToPanels:l}=s,a=o.separators.find(f=>f.element===t);D(a,"Matching separator not found");const i=l.get(a);D(i,"Matching panels not found");const c=i[0],g=r.find(f=>f.panelId===c.id);if(D(g,"Panel metadata not found"),g.collapsible){const f=u[c.id],w=g.collapsedSize===f?o.mutableState.expandedPanelSizes[c.id]??g.minSize:g.collapsedSize;te(t,w-f)}break}case"F6":{e.preventDefault();const o=Le(t).separators.map(u=>u.element),s=Array.from(o).findIndex(u=>u===e.currentTarget);D(s!==null,"Index not found");const r=e.shiftKey?s>0?s-1:o.length-1:s+1<o.length?s+1:0;o[r].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),te(t,-100);break}}}function at(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ee(),n=Ae(e,t),o=new Map;let s=!1;n.forEach(r=>{r.separator&&(s||(s=!0,r.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(r.group);u&&o.set(r.group,u.layout)}),fe({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function Pt({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:s,pointerDownAtPoint:r,prevCursorFlags:u}){let l=0;n.forEach(i=>{const{group:c,groupSize:g}=i,{orientation:f,panels:w}=c,{disableCursor:m}=c.mutableState;let d=0;r?f==="horizontal"?d=(t.clientX-r.x)/g*100:d=(t.clientY-r.y)/g*100:f==="horizontal"?d=t.clientX<0?-100:100:d=t.clientY<0?-100:100;const h=o.get(c),p=s.get(c);if(!h||!p)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:S,groupSize:y,layout:v,separatorToPanels:M}=p;if(S&&v&&M){const E=be({delta:d,initialLayout:h,panelConstraints:S,pivotIndices:i.panels.map(k=>w.indexOf(k)),prevLayout:v,trigger:"mouse-or-touch"});if(oe(E,v)){if(d!==0&&!m)switch(f){case"horizontal":{l|=d<0?vt:bt;break}case"vertical":{l|=d<0?yt:St;break}}}else J(i.group,{defaultLayoutDeferred:b,derivedPanelConstraints:S,groupSize:y,layout:E,separatorToPanels:M})}});let a=0;t.movementX===0?a|=u&Je:a|=l&Je,t.movementY===0?a|=u&Ke:a|=l&Ke,dn(a),je(e)}function lt(e){const t=ee(),n=ne();switch(n.state){case"active":Pt({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function ut(e){var o,s;if(e.defaultPrevented)return;const t=ne(),n=ee();switch(t.state){case"active":{if(e.buttons===0){fe({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(r=>{if(!n.has(r.group))return;const u=Q(r.group.id,!0);J(r.group,u,{isUserInteraction:!0})});return}for(const r of t.hitRegions)if(r.separator){const{element:u}=r.separator;(o=u.hasPointerCapture)!=null&&o.call(u,e.pointerId)||((s=u.setPointerCapture)==null||s.call(u,e.pointerId))}Pt({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const r=Ae(e,n);r.length===0?t.state!=="inactive"&&fe({cursorFlags:0,state:"inactive"}):fe({cursorFlags:0,hitRegions:r,state:"hover"}),je(e.currentTarget);break}}}function ct(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ne().state){case"hover":fe({cursorFlags:0,state:"inactive"})}}function dt(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||zt(e.currentTarget)&&e.preventDefault()}function ft(e){let t=0,n=0;const o={};for(const r of e)if(r.defaultSize!==void 0){t++;const u=B(r.defaultSize);n+=u,o[r.panelId]=u}else o[r.panelId]=void 0;const s=e.length-t;if(s!==0){const r=B((100-n)/s);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=r)}return o}function Cn(e,t,n){if(!n[0])return;const o=e.panels.find(a=>a.element===t);if(!o||!o.onResize)return;const s=pe({group:e}),r=e.orientation==="horizontal"?o.element.offsetWidth:o.element.offsetHeight,u=o.mutableValues.prevSize,l={asPercentage:B(r/s*100),inPixels:r};o.mutableValues.prevSize=l,o.onResize(l,o.id,u)}function Ln(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Pn(e,t){return e.length!==t.length?!1:e.every((n,o)=>Ln(n,t[o]))}function Rn({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let s=0,r=0,u=!1;const l=new Map,a=[];for(const g of e.panels){const f=o[g.id]??0;switch(g.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const w=f/100*n,m=B(w/t*100);l.set(g.id,m),s+=m;break}case"preserve-relative-size":default:{a.push(g.id),r+=f;break}}}if(!u||a.length===0)return o;const i=100-s,c={...o};if(l.forEach((g,f)=>{c[f]=g}),r>0)for(const g of a){const f=o[g]??0;c[g]=B(f/r*i)}else{const g=B(i/a.length);for(const f of a)c[f]=g}return c}function En(e,t){const n=e.map(s=>s.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n)if(!o.includes(s))return!1;return!0}const ue=new Map;function Dn(e){let t=!0;D(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,s=new Set,r=new n(m=>{for(const d of m){const{borderBoxSize:h,target:p}=d;if(p===e.element){if(t){const b=pe({group:e});if(b===0)return;const S=Q(e.id);if(!S)return;const y=Me(e),v=S.defaultLayoutDeferred?ft(y):S.layout,M=Rn({group:e,nextGroupSize:b,prevGroupSize:S.groupSize,prevLayout:v}),E=se({layout:M,panelConstraints:y});if(!S.defaultLayoutDeferred&&oe(S.layout,E)&&Pn(S.derivedPanelConstraints,y)&&S.groupSize===b)continue;J(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:y,groupSize:b,layout:E,separatorToPanels:S.separatorToPanels})}}else Cn(e,p,h)}});r.observe(e.element),e.panels.forEach(m=>{D(!o.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),o.add(m.id),m.onResize&&r.observe(m.element)});const u=pe({group:e}),l=Me(e),a=e.panels.map(({id:m})=>m).join(",");let i=e.mutableState.defaultLayout;i&&(En(e.panels,i)||(i=void 0));const c=e.mutableState.layouts[a]??i??ft(l),g=se({layout:c,panelConstraints:l}),f=e.element.ownerDocument;ue.set(f,(ue.get(f)??0)+1);const w=new Map;return gt(e).forEach(m=>{m.separator&&w.set(m.separator,m.panels)}),J(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:l,groupSize:u,layout:g,separatorToPanels:w}),e.separators.forEach(m=>{D(!s.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),s.add(m.id),m.element.addEventListener("keydown",it)}),ue.get(f)===1&&(f.addEventListener("contextmenu",tt,!0),f.addEventListener("dblclick",rt,!0),f.addEventListener("pointerdown",at,!0),f.addEventListener("pointerleave",lt),f.addEventListener("pointermove",ut),f.addEventListener("pointerout",ct),f.addEventListener("pointerup",dt,!0)),function(){t=!1,ue.set(f,Math.max(0,(ue.get(f)??0)-1)),hn(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",it)}),ue.get(f)||(f.removeEventListener("contextmenu",tt,!0),f.removeEventListener("dblclick",rt,!0),f.removeEventListener("pointerdown",at,!0),f.removeEventListener("pointerleave",lt),f.removeEventListener("pointermove",ut),f.removeEventListener("pointerout",ct),f.removeEventListener("pointerup",dt,!0)),r.disconnect()}}function Mn(){const[e,t]=x.useState({}),n=x.useCallback(()=>t({}),[]);return[e,n]}function Oe(e){const t=x.useId();return`${e??t}`}const re=typeof window<"u"?x.useLayoutEffect:x.useEffect;function ve(e){const t=x.useRef(e);return re(()=>{t.current=e},[e]),x.useCallback((...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[t])}function Fe(...e){return ve(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Ge(e){const t=x.useRef({...e});return re(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Rt=x.createContext(null);function kn(e,t){const n=x.useRef({getLayout:()=>({}),setLayout:fn});x.useImperativeHandle(t,()=>n.current,[]),re(()=>{Object.assign(n.current,Lt({groupId:e}))})}function Et({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:s,elementRef:r,groupRef:u,id:l,onLayoutChange:a,onLayoutChanged:i,orientation:c="horizontal",resizeTargetMinimumSize:g={coarse:20,fine:10},style:f,...w}){const m=x.useRef({onLayoutChange:{},onLayoutChanged:{}}),d=ve(L=>{oe(m.current.onLayoutChange,L)||(m.current.onLayoutChange=L,a==null||a(L))}),h=ve((L,P)=>{oe(m.current.onLayoutChanged,L)||(m.current.onLayoutChanged=L,i==null||i(L,{isUserInteraction:P}))}),p=Oe(l),b=x.useRef(null),[S,y]=Mn(),v=x.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:g,separators:[]}),M=Fe(b,r);kn(p,u);const E=ve((L,P)=>{const I=ne(),R=et(L),j=Q(L);if(j){let F=!1;switch(I.state){case"active":{F=I.hitRegions.some(X=>X.group===R);break}}return{flexGrow:j.layout[P]??1,pointerEvents:F?"none":void 0}}if(n!=null&&n[P])return{flexGrow:n==null?void 0:n[P]}}),k=Ge({defaultLayout:n,disableCursor:o}),H=x.useMemo(()=>({get disableCursor(){return!!k.disableCursor},getPanelStyles:E,id:p,orientation:c,registerPanel:L=>{const P=v.current;return P.panels=ke(c,[...P.panels,L]),y(),()=>{P.panels=P.panels.filter(I=>I!==L),y()}},registerSeparator:L=>{const P=v.current;return P.separators=ke(c,[...P.separators,L]),y(),()=>{P.separators=P.separators.filter(I=>I!==L),y()}},updatePanelProps:(L,{disabled:P})=>{const I=v.current.panels.find(F=>F.id===L);I&&(I.panelConstraints.disabled=P);const R=et(p),j=Q(p);R&&j&&J(R,{...j,derivedPanelConstraints:Me(R)})},updateSeparatorProps:(L,{disabled:P,disableDoubleClick:I})=>{const R=v.current.separators.find(j=>j.id===L);R&&(R.disabled=P,R.disableDoubleClick=I)}}),[E,p,y,c,k]),N=x.useRef(null);return re(()=>{const L=b.current;if(L===null)return;const P=v.current;let I;if(k.defaultLayout!==void 0&&Object.keys(k.defaultLayout).length===P.panels.length){I={};for(const W of P.panels){const U=k.defaultLayout[W.id];U!==void 0&&(I[W.id]=U)}}const R={disabled:!!s,element:L,id:p,mutableState:{defaultLayout:I,disableCursor:!!k.disableCursor,expandedPanelSizes:v.current.lastExpandedPanelSizes,layouts:v.current.layouts},orientation:c,panels:P.panels,resizeTargetMinimumSize:P.resizeTargetMinimumSize,separators:P.separators};N.current=R;const j=Dn(R),{defaultLayoutDeferred:F,derivedPanelConstraints:X,layout:A}=Q(R.id,!0);!F&&X.length>0&&(d(A),h(A,!1));const _=Ne(p,W=>{const{defaultLayoutDeferred:U,derivedPanelConstraints:ye,layout:K}=W.next;if(U||ye.length===0)return;const ie=R.panels.map(({id:$})=>$).join(",");R.mutableState.layouts[ie]=K,ye.forEach($=>{if($.collapsible){const{layout:he}=W.prev??{};if(he){const le=O($.collapsedSize,K[$.panelId]),Se=O($.collapsedSize,he[$.panelId]);le&&!Se&&(R.mutableState.expandedPanelSizes[$.panelId]=he[$.panelId])}}});const ae=ne().state!=="active";d(K),ae&&h(K,W.isUserInteraction)});return()=>{N.current=null,j(),_()}},[s,p,h,d,c,S,k]),x.useEffect(()=>{const L=N.current;L&&(L.mutableState.defaultLayout=n,L.mutableState.disableCursor=!!o)}),C.jsx(Rt.Provider,{value:H,children:C.jsx("div",{...w,className:t,"data-group":!0,"data-testid":p,id:p,ref:M,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}Et.displayName="Group";function Be(){const e=x.useContext(Rt);return D(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function In(e,t){const{id:n}=Be(),o=x.useRef({collapse:De,expand:De,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:De});x.useImperativeHandle(t,()=>o.current,[]),re(()=>{Object.assign(o.current,Ct({groupId:n,panelId:e}))})}function Ie({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:s,disabled:r,elementRef:u,groupResizeBehavior:l="preserve-relative-size",id:a,maxSize:i="100%",minSize:c="0%",onResize:g,panelRef:f,style:w,...m}){const d=!!a,h=Oe(a),p=Ge({disabled:r}),b=x.useRef(null),S=Fe(b,u),{getPanelStyles:y,id:v,orientation:M,registerPanel:E,updatePanelProps:k}=Be(),H=g!==null,N=ve((R,j,F)=>{g==null||g(R,a,F)});re(()=>{const R=b.current;if(R!==null){const j={element:R,id:h,idIsStable:d,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:H?N:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:n,collapsible:o,defaultSize:s,disabled:p.disabled,maxSize:i,minSize:c}};return E(j)}},[l,n,o,s,H,h,d,i,c,N,E,p]),x.useEffect(()=>{k(h,{disabled:r})},[r,h,k]),In(h,f);const L=()=>{const R=y(v,h);if(R)return JSON.stringify(R)},P=x.useSyncExternalStore(R=>Ne(v,R),L,L);let I;return P?I=JSON.parse(P):s!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:s}:I={flexGrow:1},C.jsx("div",{...m,"data-disabled":r||void 0,"data-panel":!0,"data-testid":h,id:h,ref:S,style:{...Tn,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:C.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...w,touchAction:M==="horizontal"?"pan-y":"pan-x"},children:e})})}Ie.displayName="Panel";const Tn={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function jn({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let s,r;const u=e[n],l=t.find(a=>a.panelId===n);if(l){const a=l.maxSize,i=l.collapsible?l.collapsedSize:l.minSize,c=[o,o+1];r=se({layout:be({delta:i-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],s=se({layout:be({delta:a-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:s,valueMin:r,valueNow:u}}function Dt({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:s,id:r,style:u,...l}){const a=Oe(r),i=Ge({disabled:n,disableDoubleClick:o}),[c,g]=x.useState({}),[f,w]=x.useState("inactive"),[m,d]=x.useState(!1),h=x.useRef(null),p=Fe(h,s),{disableCursor:b,id:S,orientation:y,registerSeparator:v,updateSeparatorProps:M}=Be(),E=y==="horizontal"?"vertical":"horizontal";re(()=>{const N=h.current;if(N!==null){const L={disabled:i.disabled,disableDoubleClick:i.disableDoubleClick,element:N,id:a},P=v(L),I=cn(j=>{w(j.next.state!=="inactive"&&j.next.hitRegions.some(F=>F.separator===L)?j.next.state:"inactive")}),R=Ne(S,j=>{const{derivedPanelConstraints:F,layout:X,separatorToPanels:A}=j.next,_=A.get(L);if(_){const W=_[0],U=_.indexOf(W);g(jn({layout:X,panelConstraints:F,panelId:W.id,panelIndex:U}))}});return()=>{I(),R(),P()}}},[S,a,v,i]),x.useEffect(()=>{M(a,{disabled:n,disableDoubleClick:o})},[n,o,a,M]);let k;n&&!b&&(k="not-allowed");let H;if(n)H="disabled";else switch(f){case"active":{H="active";break}default:m?H="focus":H=f}return C.jsx("div",{...l,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":E,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":H,"data-testid":a,id:a,onBlur:()=>d(!1),onFocus:()=>d(!0),ref:p,role:"separator",style:{flexBasis:"auto",cursor:k,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Dt.displayName="Separator";async function Nn({fetchPage:e}){const t=[];let n;do{const o=await e(n);t.push(...o.data),n=o.nextPageToken}while(n!=null&&n.length>0);return t}var An="96px";function Ce(e){var n;const t=(n=e.title)==null?void 0:n.trim();return t!=null&&t.length>0?t:"Untitled session"}function On(e){return"isMutable"in e&&typeof Reflect.get(e,"isMutable")=="boolean"?Reflect.get(e,"isMutable")===!0:e.agentName==null}function Fn(e){return"sourceType"in e&&Reflect.get(e,"sourceType")==="schedule"?"schedule":void 0}function Wn({agentId:e,startTimestamp:t,endTimestamp:n,shareView:o}){const s=Ft(),r=Gt(),u=Bt(),l=Ht(),a=Wt(),{sessionId:i,updateShareSearch:c}=$t(),g=Re("AgentSessionListRow"),f=Re("AgentSessionDetailHeader"),w=Re("AgentSessionTimelineContainer"),[m,d]=x.useState([]),[h,p]=x.useState(),[b,S]=x.useState(!0),[y,v]=x.useState(!1),[M,E]=x.useState(!1),[k,H]=x.useState(!1),N=x.useRef(0),L=x.useRef(!1),[P,I]=x.useState(null),[R,j]=x.useState(null),[F,X]=x.useState(),[A,_]=x.useState(),[W,U]=x.useState(!1),[ye,K]=x.useState(!1),[ie,ae]=x.useState(null),$=typeof r.deleteSession=="function",he=x.useMemo(()=>{const z=new Set(m.map(T=>T.id));return i!=null&&i.length>0&&z.add(i),[...z]},[m,i]),{allows:le}=Ut({resourceType:"session",resourceIds:he}),Se=le(i,"MANAGE"),xe=x.useMemo(()=>({order:"desc",limit:20,...e==null||e.length===0?{}:{agentId:e},...t==null?{}:{startTimestamp:t},...n==null?{}:{endTimestamp:n}}),[e,n,t]);x.useEffect(()=>{const z=++N.current;let T=!1;return L.current=!1,p(void 0),S(!0),v(!1),E(!1),H(!1),s.listSessions(xe).then(V=>{T||N.current!==z||(d(V.data),p(V.nextPageToken))}).catch(()=>{T||N.current!==z||(d([]),p(void 0),H(!0))}).finally(()=>{!T&&N.current===z&&S(!1)}),()=>{T=!0}},[xe,s]);const Pe=x.useCallback(async()=>{if(b||h==null||L.current)return;const z=N.current;L.current=!0,v(!0),E(!1);try{const T=await s.listSessions({...xe,pageToken:h});if(N.current!==z)return;d(V=>[...V,...T.data]),p(T.nextPageToken)}catch{N.current===z&&E(!0)}finally{N.current===z&&(L.current=!1,v(!1))}},[b,xe,h,s]);x.useEffect(()=>{if(b||h==null||P==null||R==null)return;const z=new IntersectionObserver(T=>{T.some(V=>V.isIntersecting)&&Pe()},{root:P,rootMargin:An});return z.observe(R),()=>z.disconnect()},[m.length,P,b,Pe,h,R]),x.useEffect(()=>{if(i==null||i.length===0){X(void 0),_(void 0),K(!1),U(!1);return}let z=!1;return U(!0),K(!1),X(void 0),_(void 0),Promise.all([Nn({fetchPage:T=>s.listSessionEvents({sessionId:i,limit:100,...T==null?{}:{pageToken:T}})}),r.getSession({sessionId:i}).catch(()=>{})]).then(([T,V])=>{z||(X([...T].reverse()),_(V))}).catch(()=>{z||K(!0)}).finally(()=>{z||U(!1)}),()=>{z=!0}},[r,i,s]);const Mt=z=>{const T=o==="sessions"?Qt(z.createdAt):null;c({sessionId:z.id,...o==="sessions"?{view:"sessions",...T==null?{}:{timeRange:T}}:{agentId:e??null,tab:"sessions",view:null,timeRange:null}})},kt=()=>{i!=null&&c({sessionId:null})},It=async z=>{if(!(!le(z.id,"DELETE")||typeof r.deleteSession!="function")){ae(null);try{await r.deleteSession({sessionId:z.id}),d(T=>T.filter(V=>V.id!==z.id)),i===z.id&&c({sessionId:null})}catch(T){u==null||u.showError(T)}}},G=m.find(z=>z.id===i),Tt=A!=null?Ce(A):G!=null?Ce(G):i??"Untitled session",He=A!=null?Xe(A):G!=null?Xe(G):!1,jt=A!=null?A.isMutable:G!=null?On(G):!0,We=He?"Resume Agent building":"Resume Chat",$e=i!=null&&a!=null?Ot({sessionId:i,routes:a}):null,Nt=()=>{if(!Se||i==null||l==null)return;const z=(A==null?void 0:A.agentName)??(G==null?void 0:G.agentName);l.openHistorySession({sessionId:i,isMutable:jt,isCreateAgent:He,...z!=null&&z.length>0?{agentName:z}:{}})},At=$e!=null?{resumeHref:$e,resumeLabel:We}:l!=null?{onResume:Nt,resumeLabel:We}:{};return!b&&!k&&m.length===0&&(i==null||i.length===0)?C.jsx(Vt,{title:"No Sessions Found",description:"There are no sessions available at the moment.",className:"bg-primary-bg"}):C.jsxs(Et,{id:"agent-sessions-split",orientation:"horizontal",className:"h-full min-h-0 w-full",resizeTargetMinimumSize:{coarse:24,fine:11},children:[C.jsx(Ie,{id:"agent-sessions-list",defaultSize:"35%",minSize:"20%",maxSize:"50%",children:C.jsx("aside",{className:"flex h-full min-h-0 w-full flex-col bg-sidebar-bg",children:C.jsxs("div",{ref:I,className:"scrollbar-none min-h-0 flex-1 overflow-y-auto",children:[b?C.jsx("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading sessions",children:["a","b","c"].map(z=>C.jsx(Ee,{className:"h-16 rounded-md"},z))}):k?C.jsx("p",{className:"px-3 py-6 text-center text-xs text-text-secondary",children:"Sessions could not be loaded."}):m.map(z=>C.jsx(g,{title:Ce(z),agentName:z.agentName??void 0,sourceType:Fn(z),lastActivityAt:z.lastActivityAt,metrics:z.metrics,active:z.id===i,onSelect:()=>Mt(z),...$?{onRequestDelete:()=>ae(z),canDelete:le(z.id,"DELETE")}:{}},z.id)),h!=null&&!b&&!k?C.jsx("div",{ref:j,className:"px-3 py-2",children:y?C.jsx(Ee,{className:"h-16 rounded-md",role:"status","aria-label":"Loading more sessions"}):M?C.jsx("button",{type:"button",className:"h-8 w-full rounded-md border border-border text-xs font-medium text-text-primary hover:bg-ghost-button-hover",onClick:()=>void Pe(),children:"Retry loading sessions"}):null}):null]})})}),C.jsxs(Dt,{id:"agent-sessions-resizer","aria-label":"Resize session list",className:"group/resizer relative z-10 w-0 cursor-col-resize focus-visible:outline-none",children:[C.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 -left-1.25 w-2.75"}),C.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-px bg-border transition-colors"}),C.jsx("div",{"aria-hidden":!0,className:qt("absolute top-1/2 left-0 z-10 flex h-4 w-2 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-xs shadow-sm transition-colors","bg-secondary-button-bg text-text-secondary","group-hover/resizer:bg-primary-button-bg group-hover/resizer:text-primary-button-text","group-active/resizer:bg-primary-button-bg group-active/resizer:text-primary-button-text","group-focus-visible/resizer:bg-primary-button-bg group-focus-visible/resizer:text-primary-button-text"),children:C.jsx(Yt,{name:"grip-vertical",size:10})})]}),C.jsx(Ie,{id:"agent-session-detail",defaultSize:"65%",minSize:"30%",children:C.jsx("section",{className:"flex h-full min-w-0 flex-col bg-primary-bg",children:i==null?C.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Select a session to view details"}):ye?C.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session details could not be loaded."}):C.jsxs(C.Fragment,{children:[C.jsx(f,{title:Tt,sessionId:i,agentId:e,createdAt:(A==null?void 0:A.createdAt)??(G==null?void 0:G.createdAt),view:o,onClose:kt,canResume:Se,...At}),W||F===void 0?C.jsx("div",{className:"flex flex-1 flex-col p-4",role:"status","aria-label":"Loading session details",children:C.jsx(Ee,{className:"min-h-64 flex-1 rounded-lg"})}):C.jsx(w,{sessionId:i,events:F,listMetrics:G==null?void 0:G.metrics})]})})}),ie!=null?C.jsxs(Xt,{open:!0,onOpenChange:z=>{z||ae(null)},"aria-label":"Delete session",className:"max-w-md",children:[C.jsx(_t,{children:C.jsxs(Jt,{children:[C.jsx(Kt,{children:"Delete session"}),C.jsxs("p",{className:"text-text-secondary text-sm",children:["“",Ce(ie),"” will be permanently deleted. This cannot be undone."]})]})}),C.jsxs(Zt,{children:[C.jsx(_e.Secondary,{type:"button",onClick:()=>ae(null),children:"Cancel"}),C.jsx(_e.Destructive,{type:"button",disabled:!le(ie.id,"DELETE"),onClick:()=>void It(ie),children:"Delete"})]})]}):null]})}export{Wn as AgentSessions};
@@ -0,0 +1 @@
1
+ import{aU as ee,N as ce,r as a,aV as U,j as e,U as me,W as z,I as w,aX as te,aq as _,a$ as ue,e as T,aW as J}from"./index-G7kdtXvB.js";var xe=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],G=_("h-11 shadow-sm"),L=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),he=({open:n,onOpenChange:p,onSubmit:h,connector:r,busy:f=!1,error:v})=>{const[b,y]=a.useState(""),[j,g]=a.useState(""),[N,m]=a.useState(""),[o,A]=a.useState("dcr"),[C,F]=a.useState(""),[k,S]=a.useState(""),u=r!==void 0,d=_(`h-11 shadow-sm ${u?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{y(""),g(""),m(""),A("dcr"),F(""),S("")};a.useEffect(()=>{n&&(y((r==null?void 0:r.name)??""),g((r==null?void 0:r.url)??""),m((r==null?void 0:r.description)??""),A((r==null?void 0:r.auth.type)??"dcr"),F(""),S((r==null?void 0:r.auth.type)==="header"?r.auth.headerName??"":""))},[r,n]);const O=l=>{l||i(),p(l)},I=!!C.trim()||(r==null?void 0:r.auth.type)==="header",E=!!b.trim()&&!!N.trim()&&!!j.trim()&&(o!=="header"||I),P=async l=>{if(l.preventDefault(),!E||f)return;const D=o==="header"?{type:"header",apiKey:C.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:o};try{await h({name:b.trim(),url:j.trim(),description:N.trim(),auth:D}),i(),p(!1)}catch{}};return e.jsx(te,{open:n,onOpenChange:O,title:u?"Edit MCP server":"Add MCP server",description:u?"Update how this connector authenticates.":"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void P(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:b,readOnly:u,"aria-disabled":u,onChange:l=>{y(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!u,className:d})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(L,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:N,onChange:l=>{m(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:_("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:j,onChange:l=>{g(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:G})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(L,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:xe.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${o===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:o===l.value,onChange:()=>{A(l.value)},className:"sr-only"}),l.label]},l.value))})]}),o==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(w,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,o==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",(r==null?void 0:r.auth.type)==="header"?e.jsx("span",{className:"font-normal text-text-secondary",children:" (leave blank to keep current)"}):e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:(r==null?void 0:r.auth.type)!=="header",value:C,onChange:l=>{F(l.target.value)},placeholder:"Bearer <Paste the token from the provider>","aria-describedby":"mcp-server-api-key-hint",className:G}),e.jsx("p",{id:"mcp-server-api-key-hint",className:"mt-1.5 text-xs text-text-secondary",children:`This is the value for the "${k.trim()||"Authorization"}" header.`})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:k,onChange:l=>{S(l.target.value)},placeholder:"Authorization",className:G})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[v?e.jsx("p",{className:"text-failure-bg text-sm",children:v}):null,e.jsx(z.Primary,{type:"submit",size:"large",disabled:!E||f,className:"w-full shrink-0",children:u?"Save":"Add"})]})]})})},Z=he,W={dcr:"OAuth2",header:"API Key",none:"No Auth"};function pe({text:n}){const p=a.useRef(null),[h,r]=a.useState(!1),[f,v]=a.useState(!1),[b,y]=a.useState(16);return a.useLayoutEffect(()=>{r(!1),y(16)},[n]),a.useLayoutEffect(()=>{const j=p.current;if(!j)return;if(!h){y(16),v(j.scrollWidth>j.clientWidth+1);return}y(16);const g=requestAnimationFrame(()=>{y(j.scrollHeight)});return()=>cancelAnimationFrame(g)},[n,h]),n?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:p,style:{maxHeight:b},className:T("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!h&&"whitespace-nowrap",!h&&f&&"pr-[5.75rem]"),children:[n,h&&f?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>r(!1),children:"Show less"})]}):null]}),!h&&f?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>r(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var fe=({connector:n,onBack:p,onConnectorRefreshed:h,onEdit:r,onDisconnect:f,busy:v=!1})=>{const{connectorCatalog:b}=ee(),{handleAuthorize:y,isOAuthLoading:j}=ue(),[g,N]=a.useState([]),[m,o]=a.useState(!0),[A,C]=a.useState(null),[F,k]=a.useState(!1);a.useEffect(()=>{let d=!1;return N([]),C(null),o(!0),b.getToolsByConnectorId({id:n.id}).then(i=>{d||N(i)}).catch(i=>{d||C(U(i,"Failed to load connector tools"))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[n.authenticated,n.id,b]);const S=async()=>{k(!0),C(null);try{const d=await b.getConnector({id:n.id});h(d)}catch(d){C(U(d,"Failed to refresh connector details"))}finally{k(!1)}},u=j||F;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:p,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(w,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:n.name}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:W[n.auth.type]??W.none}),e.jsxs("span",{className:T("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",n.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:T("h-1.5 w-1.5 rounded-full",n.authenticated?"bg-success-bg":"bg-primary-button-bg")}),n.authenticated?"Connected":"Not authenticated"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:e.jsx("span",{className:"text-text-secondary",children:n.description})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z.Secondary,{size:"small",type:"button",disabled:v,onClick:r,children:[e.jsx(w,{name:"pencil",className:"size-3"}),"Edit"]}),n.auth.type==="dcr"&&!n.authenticated?e.jsx(z.Secondary,{size:"small",type:"button",disabled:v||u,onClick:()=>{y(n.id,d=>{d&&S()})},children:u?"Connecting…":"Connect"}):n.auth.type==="dcr"&&!n.requiresAuth?e.jsx(z.Secondary,{size:"small",type:"button",disabled:v,onClick:f,children:"Disconnect"}):null]})]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:m?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):A?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[A,n.auth.type==="dcr"&&!n.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):g.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",g.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:g.map(d=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:d.name}),e.jsx(pe,{text:d.description})]})},d.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},be=fe,ge=()=>{const{connectorCatalog:n}=ee(),p=ce(),[h,r]=a.useState(""),[f,v]=a.useState({ordered:[],authStatusById:new Map}),[b,y]=a.useState(!0),[j,g]=a.useState(null),[N,m]=a.useState(null),[o,A]=a.useState(!1),[C,F]=a.useState([]),[k,S]=a.useState(!1),[u,d]=a.useState(null),[i,O]=a.useState(null),[I,E]=a.useState(null),[P,l]=a.useState(""),D=a.useMemo(()=>(C??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[C]),K=a.useCallback(async()=>{y(!0),g(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);F(s);const c=t??[],M=new Set(c.map(x=>x.id)),V=[...c.map(x=>({connector:x,isConfigured:!0})),...s.filter(x=>!M.has(x.id)).map(x=>({connector:x,isConfigured:!1}))];v({ordered:V,authStatusById:new Map(V.map(x=>[x.connector.id,x.isConfigured?x.connector.authenticated:!1]))}),E(x=>x?t.find(oe=>oe.id===x.id)??null:null)}catch(t){g(U(t,"Failed to load connectors"))}finally{y(!1)}},[n]);a.useEffect(()=>{K()},[K]);const B=h.trim().toLowerCase(),q=a.useMemo(()=>B?f.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(B)||(((s=t.description)==null?void 0:s.toLowerCase().includes(B))??!1)||t.url.toLowerCase().includes(B)}):f.ordered,[f.ordered,B]),$=a.useMemo(()=>{const t=[];for(const s of q)if(s.isConfigured){const c=f.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(c===s.connector.authenticated?s.connector:{...s.connector,authenticated:c})}return t},[f.authStatusById,q]),R=a.useMemo(()=>{const t=[];for(const s of q)s.isConfigured||t.push(s.connector);return t},[q]),H=async(t,s=g)=>{A(!0),g(null);try{await t(),await K()}catch(c){throw s(U(c,"Request failed")),c}finally{A(!1)}},Q=()=>{O(null),l(""),m(null)},X=async(t,s)=>{const c=s??(t.auth.type==="header"?{type:"header",...t.auth.headerName?{headerName:t.auth.headerName}:{}}:t.auth.type==="dcr"?{type:"dcr"}:{type:"none"});await n.createConnector({name:t.name,description:t.description??t.url,url:t.url,auth:c})},se=t=>{if(t.auth.type==="header"){l(""),m(null),O(t);return}H(async()=>{await X(t)}).catch(()=>{})},ae=t=>{if(t.preventDefault(),!i||!P.trim())return;const s=i;m(null),H(async()=>{const c={type:"header",apiKey:P.trim(),...s.auth.type==="header"&&s.auth.headerName?{headerName:s.auth.headerName}:{}};await X(s,c),Q(),setTimeout(()=>{p==null||p.showSuccess({title:`${s.name} connected`})},100)},m).catch(()=>{})},Y=async t=>{m(null),await H(async()=>{u?await n.updateConnector({id:u.id,...t}):await n.createConnector({...t})},m),setTimeout(()=>{p==null||p.showSuccess({title:`${t.name} ${u?"updated":"added"}`})},0)},re=t=>{H(async()=>{await n.disconnectConnector({id:t.id}),E(null)}).catch(()=>{})},ne=t=>{E(s=>(s==null?void 0:s.id)===t.id?t:s),v(s=>{const c=new Map(s.authStatusById);return c.set(t.id,t.authenticated),{ordered:s.ordered.map(M=>M.isConfigured&&M.connector.id===t.id?{connector:t,isConfigured:!0}:M),authStatusById:c}})},le=(t,s)=>{const c=D[t.name],M=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:c?e.jsx(J,{src:c,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:T("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:T("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]});return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0 cursor-pointer transition-colors hover:bg-ghost-button-hover/60",onClick:()=>{E(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:M}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z.Secondary,{size:"small",type:"button",disabled:o,onClick:x=>{x.stopPropagation(),m(null),d(t),S(!0)},children:[e.jsx(w,{name:"pencil",className:"size-3"}),"Edit"]}),e.jsx(w,{name:"chevron-right",className:"size-4"})]})]},t.id)},ie=t=>{const s=D[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(J,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:W[t.auth.type]??W.none}),e.jsx(z.Secondary,{size:"small",type:"button",disabled:o,onClick:()=>{se(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)};if(I)return e.jsxs(e.Fragment,{children:[e.jsx(be,{connector:I,busy:o,onBack:()=>{E(null)},onConnectorRefreshed:ne,onEdit:()=>{m(null),d(I),S(!0)},onDisconnect:()=>{re(I)}}),e.jsx(Z,{open:k,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Y,connector:u??void 0,busy:o,error:N})]});const de=$.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),j?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:j}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(me,{query:h,setQuery:r,placeholder:"Search connectors"})}),e.jsxs(z.Secondary,{type:"button",onClick:()=>{m(null),d(null),S(!0)},children:[e.jsx(w,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[b?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!b&&$.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",$.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:$.map(t=>le(t))})]}):null,!b&&R.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>ie(t))})]}):null,!b&&!de?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h.trim()?`No connectors match “${h.trim()}”.`:"No connectors yet."}):null]}),e.jsx(te,{open:i!==null,onOpenChange:t=>{t||Q()},title:`Connect ${(i==null?void 0:i.name)??"connector"}`,description:i==null?void 0:i.url,contentSized:!0,className:"md:max-w-xl",children:e.jsxs("form",{onSubmit:ae,children:[e.jsxs("div",{className:"space-y-5 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6 text-text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-text-primary",children:i==null?void 0:i.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:i==null?void 0:i.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"connector-api-key",className:"mb-2 block text-xs font-semibold uppercase tracking-wide text-text-secondary",children:"API key / token"}),e.jsx("input",{id:"connector-api-key",type:"password",value:P,onChange:t=>{l(t.target.value)},placeholder:`Bearer <Paste the token from ${(i==null?void 0:i.name)??"the provider"}>`,autoFocus:!0,required:!0,className:_("h-11")})]}),N?e.jsx("p",{className:"text-failure-bg text-sm",children:N}):null]}),e.jsxs("footer",{className:"flex justify-end gap-2 border-t border-border px-5 py-4",children:[e.jsx(z.Ghost,{type:"button",onClick:Q,disabled:o,children:"Cancel"}),e.jsx(z.Primary,{type:"submit",disabled:!P.trim()||o,children:"Connect"})]})]})}),e.jsx(Z,{open:k,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Y,connector:u??void 0,busy:o,error:N})]})})]})},je=ge;export{je as default};
@@ -1 +1 @@
1
- import{S as a}from"./chunk-2UBSLCKB-Bq4rnsqJ.js";import{j as o,C as t,e as l}from"./index-DVIyIfJR.js";import"./chunk-PX6MNNN3-DWHQBAi-.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
1
+ import{S as a}from"./chunk-IGYCJIU7-COFxTXYC.js";import{j as o,C as t,e as l}from"./index-G7kdtXvB.js";import"./chunk-G7BT4OKG-D-wOOnsv.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-6FJVZLJT-Drq1vNUK.js","./index-DVIyIfJR.js","./index-B01pXqvC.css","./SchedulesPage-2G6F4XO6-CXGVFkK8.js"])))=>i.map(i=>d[i]);
2
- import{u as E,a as P,b as I,c as t,r as a,s as L,j as s,P as z,I as l,d as c,S as g,e as B,_ as p}from"./index-DVIyIfJR.js";import{A as k,S as D,N as T,T as R}from"./chunk-PX6MNNN3-DWHQBAi-.js";var F=a.lazy(()=>p(()=>import("./SettingsBuilder-6FJVZLJT-Drq1vNUK.js"),__vite__mapDeps([0,1,2]),import.meta.url)),M=a.lazy(()=>p(()=>import("./SchedulesPage-2G6F4XO6-CXGVFkK8.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(i=>({default:i.SchedulesPage})));function V({className:i}){const f=E(),e=P(),d=I(),b=t("ClearChatButton"),j=t("AgentDetailsPage"),y=t("AgentsLibrary"),A=t("SessionsPage"),w=t("SaveAgentButton"),N=t("SelectAgentEmptyState"),v=t("UserAvatar"),S=a.useRef(null),C=(e==null?void 0:e.mode.status)==="idle",u=(e==null?void 0:e.settingsOpen)===!0,n=(e==null?void 0:e.libraryOpen)===!0,m=(e==null?void 0:e.sessionsOpen)===!0,o=(e==null?void 0:e.schedulesOpen)===!0,r=u||n||m||o,h=e!=null&&L(e.mode)&&!r&&(!d||e.agentConfigOpen),x=(e==null?void 0:e.isNewChatEnabled)!==!1,O=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(f.threads().switchToNewThread()).catch(()=>{})},_=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("div",{className:B("relative flex h-full min-h-0 w-full bg-primary-bg",i),children:[h?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:s.jsx(k,{showClose:d})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(z,{className:"bg-topbar-bg",title:r?n||o?s.jsxs("button",{type:"button",className:c({variant:"ghost",size:"small"}),onClick:()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1)},children:[s.jsx(l,{name:"arrow-left"}),"Back to chat"]}):null:s.jsx(T,{}),end:s.jsxs(s.Fragment,{children:[r?null:s.jsxs(s.Fragment,{children:[s.jsx(b,{}),s.jsx(w,{})]}),s.jsx(D,{},"shell-actions"),s.jsx(v,{}),r?null:s.jsxs(s.Fragment,{children:[x?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:c({variant:"ghost",size:"icon"}),onClick:O,children:s.jsx(l,{name:"square-pen"})}):null,x&&(e!=null&&e.isComposerEnabled)?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:c({variant:"ghost",size:"icon"}),onClick:_,children:s.jsx(l,{name:"agent-2"})}):null]})]})}),s.jsx("div",{ref:S,className:"min-h-0 min-w-0 flex-1",children:u?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(F,{})}):m?s.jsx(A,{}):n&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(j,{agentId:e.libraryAgentId},e.libraryAgentId):n?s.jsx(y,{}):o?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(M,{})}):C?s.jsx(N,{}):s.jsx(R,{})})]})]})}export{V as DrawerLayout};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-G5CP5X6Q-XQVNLXzw.js","./index-G7kdtXvB.js","./index-B01pXqvC.css","./SchedulesPage-TIS3BH67-CoDDvRbI.js"])))=>i.map(i=>d[i]);
2
+ import{u as E,a as P,b as I,c as t,r as a,s as L,j as s,P as z,I as l,d as c,S as g,e as B,_ as p}from"./index-G7kdtXvB.js";import{A as k,S as D,N as T,T as R}from"./chunk-G7BT4OKG-D-wOOnsv.js";var F=a.lazy(()=>p(()=>import("./SettingsBuilder-G5CP5X6Q-XQVNLXzw.js"),__vite__mapDeps([0,1,2]),import.meta.url)),M=a.lazy(()=>p(()=>import("./SchedulesPage-TIS3BH67-CoDDvRbI.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(i=>({default:i.SchedulesPage})));function V({className:i}){const f=E(),e=P(),d=I(),b=t("ClearChatButton"),j=t("AgentDetailsPage"),y=t("AgentsLibrary"),A=t("SessionsPage"),w=t("SaveAgentButton"),N=t("SelectAgentEmptyState"),v=t("UserAvatar"),S=a.useRef(null),C=(e==null?void 0:e.mode.status)==="idle",u=(e==null?void 0:e.settingsOpen)===!0,n=(e==null?void 0:e.libraryOpen)===!0,m=(e==null?void 0:e.sessionsOpen)===!0,o=(e==null?void 0:e.schedulesOpen)===!0,r=u||n||m||o,h=e!=null&&L(e.mode)&&!r&&(!d||e.agentConfigOpen),x=(e==null?void 0:e.isNewChatEnabled)!==!1,O=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(f.threads().switchToNewThread()).catch(()=>{})},_=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("div",{className:B("relative flex h-full min-h-0 w-full bg-primary-bg",i),children:[h?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:s.jsx(k,{showClose:d})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(z,{className:"bg-topbar-bg",title:r?n||o?s.jsxs("button",{type:"button",className:c({variant:"ghost",size:"small"}),onClick:()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1)},children:[s.jsx(l,{name:"arrow-left"}),"Back to chat"]}):null:s.jsx(T,{}),end:s.jsxs(s.Fragment,{children:[r?null:s.jsxs(s.Fragment,{children:[s.jsx(b,{}),s.jsx(w,{})]}),s.jsx(D,{},"shell-actions"),s.jsx(v,{}),r?null:s.jsxs(s.Fragment,{children:[x?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:c({variant:"ghost",size:"icon"}),onClick:O,children:s.jsx(l,{name:"square-pen"})}):null,x&&(e!=null&&e.isComposerEnabled)?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:c({variant:"ghost",size:"icon"}),onClick:_,children:s.jsx(l,{name:"agent-2"})}):null]})]})}),s.jsx("div",{ref:S,className:"min-h-0 min-w-0 flex-1",children:u?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(F,{})}):m?s.jsx(A,{}):n&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(j,{agentId:e.libraryAgentId},e.libraryAgentId):n?s.jsx(y,{}):o?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(M,{})}):C?s.jsx(N,{}):s.jsx(R,{})})]})]})}export{V as DrawerLayout};
@@ -0,0 +1 @@
1
+ import{aU as be,N as fe,r as o,aV as J,j as e,U as ge,W as B,I as L,aW as ie,aX as xe,aY as ye,aZ as ve,e as P,a_ as je,aq as Ne}from"./index-G7kdtXvB.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:l,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[U,$]=o.useState(""),[y,x]=o.useState(""),[w,I]=o.useState(!1),M=()=>{$(""),x(""),I(!1)};o.useEffect(()=>{n&&($(""),x(E),I(!1))},[n,E]);const X=i=>{i||M(),l(i)},T=U.trim(),Q=!c||!!T,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:T,baseUrl:y.trim()}),M(),l(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:U,onChange:i=>{$(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>I(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(L,{name:"chevron-down",className:P("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!Q||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(l=>{var b,k,p,E,d;return{id:l.id,name:l.name,advancedExpanded:!0,reasoningEfforts:(b=l.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=l.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=l.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],W="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const l=n.trim();if(l==="")return null;const b=Number(l);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Ue=({open:n,onOpenChange:l,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=o.useState((c==null?void 0:c.name)??""),[F,U]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[I,M]=o.useState(!1),[X,T]=o.useState(!1),Q=()=>{O((c==null?void 0:c.name)??""),U((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),M(!1),T(!1)},v=s=>{s||Q(),l(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{M(!0),T(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const Z=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,G=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!Z(s)&&!te(s)),se=I&&D,H=X&&h,A=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||G(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:$.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-auto flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-auto space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>M(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:P(W,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>U(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:P(W,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:W}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=Z(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,le=q(s),C=G(s),z=s.contextTouched&&le,ae=s.maxTouched&&C;return e.jsxs("div",{className:P("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:P(W,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:P(W,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(L,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(L,{name:"chevron-down",className:P("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:P(W,z&&V)}),z?e.jsx(ee,{children:le}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:P(W,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:P("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var Y;return i(r,{reasoningEfforts:a?(Y=s.reasoningEfforts)==null?void 0:Y.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(L,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!oe||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Me=Ue;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Pe=()=>{const{modelCatalog:n}=be(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,U]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[I,M]=o.useState(null),[X,T]=o.useState(null),[Q,v]=o.useState(null),[i,K]=o.useState(!1),[f,D]=o.useState(null),_=o.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),Z=o.useCallback(async()=>{O(!0),U(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){U(J(t,"Failed to load model providers"))}finally{O(!1)}},[n]);o.useEffect(()=>{Z()},[Z]);const te=o.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=o.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),G=o.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),oe=o.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=o.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{M(null),T(null),v(null)},A=async(t,a)=>{w(!0),U(null);try{await t(),await Z(),H()}catch(m){throw a?a(m):l==null?U(J(m,"Request failed")):l.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await A(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(J(m,"Request failed")))},r=async(t,a)=>{v(null),await A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(J(m,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&A(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await A(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(J(a,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await A(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(J(m,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},le=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=I!=null?p.find(t=>t.id===I)??null:null,z=X!=null?d.find(t=>t.type===X)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(L,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),Y=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),T(null),M(t.id))},children:[e.jsx(L,{name:"pencil",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(L,{name:"trash",className:"size-3.5"})})]},N.id)),Y.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",Y.length]}),Y.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&G.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:G.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:x,onClick:()=>{v(null),M(null),T(t.type)},children:[e.jsx(L,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&G.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Te(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:Q}),e.jsx(Me,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:le,onSubmit:f?R:j,reasoningEffortOptions:oe,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Pe;export{ze as default};
@@ -0,0 +1 @@
1
+ import{aU as V,N as Y,r,aV as B,j as e,S as H,I as N,E as W,W as O,aX as X,aY as Z,aZ as J,e as Q,a_ as ee,aq as te}from"./index-G7kdtXvB.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=te("h-11 shadow-sm");function L(s){if(s.trim()==="")return null;const l=Number(s);return!Number.isFinite(l)||l<0?null:l}var ae=({open:s,onOpenChange:l,onSave:d,title:g,description:I,initialConfig:R=null,requireApiKey:y=!0,busy:w=!1,error:C})=>{const[m,k]=r.useState(""),[u,x]=r.useState(""),[M,i]=r.useState(""),[p,o]=r.useState(""),[b,f]=r.useState(""),[P,v]=r.useState(!1),S=()=>{k(""),x(""),i(""),o(""),f(""),v(!1)};r.useEffect(()=>{if(!s)return;const a=R??se;k(String(a.execTimeoutMs)),x(String(a.autoStopIntervalInMinutes)),i(String(a.autoArchiveIntervalInMinutes)),o(String(a.autoDeleteIntervalInMinutes)),f(""),v(!1)},[s,R]);const q=a=>{a||S(),l(a)},h=L(m),A=L(u),T=L(M),E=L(p),D=b.trim(),U=(!y||!!D)&&h!=null&&A!=null&&T!=null&&E!=null,z=async a=>{if(a.preventDefault(),!(!U||w||h==null||A==null||T==null||E==null))try{await d({execTimeoutMs:h,autoStopIntervalInMinutes:A,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:E,apiKey:D}),S(),l(!1)}catch{}};return e.jsx(X,{open:s,onOpenChange:q,title:g,description:I,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:z,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"sandbox-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",y?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:y,value:b,onChange:a=>{f(a.target.value)},placeholder:y?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:F})]}),e.jsxs(Z,{expanded:P,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(J,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced settings",e.jsx(N,{name:"chevron-down",className:Q("size-4 shrink-0 text-text-secondary transition-transform duration-200",P?"rotate-0":"-rotate-90")})]})}),e.jsxs(ee,{className:"space-y-4 border-t border-border px-3 pb-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-exec-timeout",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Exec timeout (ms)"}),e.jsx("input",{id:"sandbox-exec-timeout",type:"number",min:0,required:!0,value:m,onChange:a=>{k(a.target.value)},placeholder:"300000",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-stop",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-stop interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-stop",type:"number",min:0,required:!0,value:u,onChange:a=>{x(a.target.value)},placeholder:"15",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-archive",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-archive interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-archive",type:"number",min:0,required:!0,value:M,onChange:a=>{i(a.target.value)},placeholder:"10080",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-delete",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-delete interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-delete",type:"number",min:0,required:!0,value:p,onChange:a=>{o(a.target.value)},placeholder:"43200",className:F})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[C?e.jsx("p",{className:"text-failure-bg text-sm",children:C}):null,e.jsx(O.Primary,{type:"submit",size:"large",disabled:!U||w,className:"w-full shrink-0",children:"Save"})]})]})})},ne=ae,re=1e4,_=({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g})=>({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g}),le=s=>{switch(s){case"pending":return{label:"Syncing image...",className:"text-warning-bg"};case"ready":return{label:"Connected",className:"text-success-bg"};case"failed":return{label:"Sync failed",className:"text-failure-bg"};default:return{label:s,className:"text-text-secondary"}}},ie=()=>{const{sandboxCatalog:s}=V(),l=Y(),[d,g]=r.useState([]),[I,R]=r.useState([]),[y,w]=r.useState(!0),[C,m]=r.useState(null),[k,u]=r.useState(null),[x,M]=r.useState(!1),[i,p]=r.useState(null),[o,b]=r.useState(null),f=r.useCallback(async({quiet:t=!1}={})=>{if(s){t||w(!0),m(null);try{const[n,c]=await Promise.all([s.listSandboxProviders(),s.getSandboxProviderCatalog()]);g(n),R(c)}catch(n){m(B(n,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[s]);r.useEffect(()=>{f()},[f]);const P=d.some(t=>t.snapshotSyncStatus.status==="pending");r.useEffect(()=>{if(!s||!P)return;const t=s;let n=!1,c;function j(){c=window.setTimeout(()=>{$()},re)}async function $(){try{const K=await t.listSandboxProviders();if(n)return;g(K),m(null),K.some(G=>G.snapshotSyncStatus.status==="pending")&&j()}catch(K){if(n)return;m(B(K,"Failed to refresh sandbox providers")),j()}}return j(),()=>{n=!0,c!==void 0&&window.clearTimeout(c)}},[s,P]);const v=d.length>0,S=r.useMemo(()=>{if(v)return[];const t=new Set(d.map(n=>n.data.catalogId));return I.filter(n=>!t.has(n.id))},[I,d,v]),q=r.useMemo(()=>o?_(o):i?_(i):null,[o,i]);if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const h=async(t,n=m)=>{M(!0),m(null);try{await t(),await f({quiet:!0})}catch(c){throw n(B(c,"Request failed")),c}finally{M(!1)}},A=async t=>{i&&(u(null),await h(async()=>{await s.createSandboxProvider({catalogId:i.id,name:i.name,type:i.type,..._(t),apiKey:t.apiKey})},u),p(null),setTimeout(()=>{l==null||l.showSuccess({title:`${i.name} configured`})},0))},T=async t=>{o&&(u(null),await h(async()=>{await s.updateSandboxProvider({id:o.id,..._(t),...t.apiKey?{apiKey:t.apiKey}:{}})},u),b(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`})},0))},E=t=>{h(async()=>{await s.updateSandboxProvider({id:t.id,..._(t)})}).catch(()=>{})},D=t=>{const n=s.deleteSandboxProvider;n&&h(async()=>{await n({id:t.id})}).catch(()=>{})},U=i!=null||o!=null,z=o!=null,a=o?`Update ${o.name}`:i?`Configure ${i.name}`:"Configure sandbox provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Sandbox providers"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose a provider that runs sandboxes for code, files and shell commands. Only one can be active at a time."}),C?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:C}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:y?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[d.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",d.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:d.map(t=>{const n=t.data,c=le(t.snapshotSyncStatus.status),j=t.snapshotSyncStatus.statusReason,$=e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-sm font-medium ${c.className}`,children:[t.snapshotSyncStatus.status==="pending"?e.jsx(H,{size:16,"aria-label":"Syncing snapshot image"}):t.snapshotSyncStatus.status==="ready"?e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}):t.snapshotSyncStatus.status==="failed"?e.jsx(N,{name:"triangle-exclamation",className:"size-4"}):null,c.label]});return e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:n.name})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[$,j?e.jsx(W,{content:j,children:e.jsx("button",{type:"button","aria-label":"Snapshot sync status details",className:"inline-flex text-text-secondary transition-colors hover:text-text-primary",children:e.jsx(N,{name:"info",className:"size-4"})})}):null,t.snapshotSyncStatus.status==="failed"?e.jsx(O.Ghost,{size:"small",type:"button",disabled:x,onClick:()=>{E(n)},children:"Retry"}):null,e.jsx(O.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(null),p(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(O.Ghost,{size:"small",className:"text-text-secondary",type:"button",disabled:x,onClick:()=>{D(n)},children:"Remove"}):null]})]},n.id)})})]}):null,v?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",S.length]}),S.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:I.length>0?"All catalog providers are configured.":"No sandbox providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:S.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(O.Secondary,{type:"button",disabled:x,onClick:()=>{u(null),b(null),p(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:U,onOpenChange:t=>{t||(u(null),p(null),b(null))},onSave:z?T:A,title:a,description:z?"Update this sandbox provider. Leave API key blank to keep the existing key.":"Configure this sandbox provider. API key is never stored in the catalog.",initialConfig:q,requireApiKey:!z,busy:x,error:k})]})},de=ie;export{de as default};
@@ -0,0 +1 @@
1
+ import{L as be,M as Le,N as ge,r as l,O as xe,Q as Se,J as pe,R as Qe,j as e,P as We,U as Ke,V as ce,q as ue,W as q,I as A,X as Ye,Y as ke,Z as Te,$ as Ze,a0 as Je,a1 as Ce,a2 as J,a3 as Xe,a4 as X,a5 as et,a6 as tt,a7 as st,a8 as nt,a9 as at,aa as rt,ab as lt,ac as it,ad as ot,e as $,ae as Ee,af as ct,ag as dt,ah as ut,c as mt,ai as xt,aj as me,d as ht,ak as ft,E as bt,a as gt,al as pt,am as Nt,an as yt,ao as jt,ap as vt,aq as ze,i as wt,ar as St}from"./index-G7kdtXvB.js";function Fe({value:t,selectedLabel:s,onValueChange:i,onAgentPicked:a,disabled:r=!1,onBuildAgent:d,allOption:g,"aria-label":y="Agent",placeholder:m="Search agent",className:f}){const[u,p]=l.useState(!1),[j,o]=l.useState(""),[w,E]=l.useState(null),b=l.useRef(null),k=l.useRef(null),C=l.useRef(null),z=l.useRef(null),H=l.useId(),{agents:R,isInitialLoading:F,isSearching:v,loadingMore:W,hasMore:B,error:D,listRef:I,sentinelRef:G}=it({enabled:u&&!r,query:j});l.useEffect(()=>{u||o("")},[u]),l.useLayoutEffect(()=>{if(!u){E(null);return}const h=()=>{const c=k.current;if(!c)return;const N=c.getBoundingClientRect();E({top:N.bottom+4,left:N.left,width:N.width})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[u]),l.useEffect(()=>{if(!u)return;const h=c=>{var N,S;c.target instanceof Node&&((N=b.current)!=null&&N.contains(c.target)||(S=z.current)!=null&&S.contains(c.target)||p(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[u]);const O=()=>{var h;p(!1),o(""),(h=C.current)==null||h.blur()},_=h=>{const c=ue(h);i(c),a==null||a(h),O()},K=()=>{g!=null&&(i(g.value),O())},P=u?j:s,U=j.trim(),V=!F&&D!=null,L=!F&&D==null&&R.length===0&&U==="",Q=!F&&D==null&&R.length===0&&U!=="",ee=u&&w!=null&&!r?ot.createPortal(e.jsxs("div",{ref:z,className:ct("fixed z-[200] flex max-h-64 flex-col overflow-hidden"),style:{top:w.top,left:w.left,width:w.width},onMouseDown:h=>h.stopPropagation(),children:[e.jsxs("div",{ref:I,id:H,role:"listbox","aria-label":y,className:"min-h-0 flex-1 overflow-y-auto p-1",children:[g!=null&&U===""?e.jsxs("button",{type:"button",role:"option","aria-selected":t===g.value,className:Ee(),onClick:K,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),e.jsx(A,{name:"check",className:$("ml-auto size-4 shrink-0",t===g.value?"opacity-100":"opacity-0")})]}):null,F?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:"Loading…"}):V?e.jsx("p",{className:"text-failure-bg px-3 py-5 text-center text-sm",role:"alert",children:D}):L?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",children:"No Agents created yet"}):Q?e.jsxs("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:['No agents match "',U,'".']}):e.jsxs(e.Fragment,{children:[v?e.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null,R.map(h=>{const c=ue(h),N=t===c;return e.jsxs("button",{type:"button",role:"option","aria-selected":N,className:Ee(),onClick:()=>_(h),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:h.name}),e.jsx(A,{name:"check",className:$("ml-auto size-4 shrink-0",N?"opacity-100":"opacity-0")})]},c)}),B?e.jsx("div",{ref:G,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:W?e.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]}),L&&d!=null?e.jsx("div",{className:"flex justify-end border-t border-border px-2 pt-2",children:e.jsxs(q.Ghost,{type:"button",onClick:d,children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"Build Agent"]})}):null]}),dt(b.current)):null;return e.jsxs("div",{ref:b,className:$("relative",f),children:[e.jsxs("div",{ref:k,className:ut(r?"cursor-not-allowed opacity-50":"cursor-text"),children:[e.jsx("input",{ref:C,type:"text",role:"combobox","aria-label":y,"aria-expanded":u,"aria-controls":u?H:void 0,"aria-autocomplete":"list",disabled:r,placeholder:m,value:P,className:"min-w-0 flex-1 bg-transparent outline-none placeholder:text-text-secondary/70 disabled:cursor-not-allowed",onFocus:()=>{r||p(!0)},onChange:h=>{r||(o(h.target.value),p(!0))},onKeyDown:h=>{var c;if(h.key==="Escape"){h.preventDefault(),p(!1),(c=C.current)==null||c.blur();return}h.key==="ArrowDown"&&!u&&!r&&(h.preventDefault(),p(!0))}}),e.jsx(A,{name:"chevron-down",className:"size-4 shrink-0 text-text-secondary"})]}),ee]})}var Ae=[{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"America/Denver",label:"America/Denver (MT)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"UTC",label:"UTC"},{value:"Europe/London",label:"Europe/London (GMT/BST)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Kolkata",label:"Asia/Kolkata (IST)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}];function Ie(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function kt(t){const s=Ie(),i=new Set(Ae.map(r=>r.value));return[...[s,t].flatMap(r=>r==null||r.length===0||i.has(r)?[]:(i.add(r),[{value:r,label:r===s?`${r} (Local)`:r}])),...Ae]}var Me=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],Tt={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function de(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ie()}}function Ct(t){return Tt[t]??t.split("/").pop()??t}function $e(t){return t.toString().padStart(2,"0")}function le({hour:t,minute:s}){const i=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${$e(s)} ${i}`}function he(t){const s=t.minute,i=t.hour;switch(t.recurrence){case"hourly":return`${String(s)} * * * *`;case"daily":return`${String(s)} ${String(i)} * * *`;case"weekly":{const a=[...t.weekdays].sort((d,g)=>d-g),r=a.length>0?a.join(","):"*";return`${String(s)} ${String(i)} * * ${r}`}case"custom":return t.customCron.trim()}}function ae(t){const s=Ct(t.timezone),i=t.cron.trim().split(/\s+/);if(i.length!==5)return t.cron;const[a,r,d,g,y]=i;if(d!=="*"||g!=="*")return t.cron;const m=Number(a),f=Number(r);if(r==="*"&&y==="*"&&a!==void 0&&!Number.isNaN(m))return`Hourly at :${$e(m)} ${s}`;if(y==="*"&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m))return`Daily ${le({hour:f,minute:m})} ${s}`;if(y==="1-5"&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m))return`Weekdays ${le({hour:f,minute:m})} ${s}`;if(y!=null&&/^\d(?:,\d)*$/.test(y)&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m)){const u=y.split(",").map(p=>{var j;return((j=Me.find(o=>o.value===Number(p)))==null?void 0:j.label)??p});return u.length===1?`Every ${u[0]==="Mon"?"Monday":u[0]} ${le({hour:f,minute:m})} ${s}`:`${u.join(", ")} ${le({hour:f,minute:m})} ${s}`}return t.cron}function Re(t){const s=de(),i=t.cron.trim().split(/\s+/);if(i.length!==5)return{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,r,d,g,y]=i,m=Number(a),f=Number(r);return d!=="*"||g!=="*"?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:r==="*"&&y==="*"&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:m,customCron:t.cron}:y==="*"&&!Number.isNaN(f)&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:f,minute:m,customCron:t.cron}:y!=null&&/^\d(?:,\d)*$/.test(y)&&!Number.isNaN(f)&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:f,minute:m,weekdays:y.split(",").map(Number),customCron:t.cron}:{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(f)?s.hour:f,minute:Number.isNaN(m)?s.minute:m}}function Et(t,s=Date.now()){if(t==null)return"Never";const i=Date.parse(t);if(Number.isNaN(i))return"Never";const a=Math.round((s-i)/1e3);if(a<60)return"just now";const r=Math.round(a/60);if(r<60)return`${String(r)} min ago`;const d=Math.round(r/60);if(d<48)return`${String(d)} hour${d===1?"":"s"} ago`;const g=Math.round(d/24);return`${String(g)} day${g===1?"":"s"} ago`}var zt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"}],At=Array.from({length:24},(t,s)=>({value:String(s),label:s.toString().padStart(2,"0")})),Rt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Dt({values:t,onChange:s,agentId:i,agentLabel:a,onAgentIdChange:r,onAgentPicked:d,agentPickerDisabled:g=!1,onBuildAgent:y}){const m=he(t),f=ae({cron:m,timezone:t.timezone}),u=kt(t.timezone),p=(o,w)=>{s({...t,[o]:w})},j=o=>{const E=t.weekdays.includes(o)?t.weekdays.filter(b=>b!==o):[...t.weekdays,o];s({...t,weekdays:E.length>0?E:[o]})};return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent"}),e.jsx(Fe,{"aria-label":"Agent",placeholder:"Search agent",value:i,selectedLabel:a,onValueChange:o=>r==null?void 0:r(o),onAgentPicked:d,disabled:g||r==null,onBuildAgent:y})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Name"}),e.jsx("input",{value:t.name,onChange:o=>p("name",o.target.value),placeholder:"harness-daily-digest",className:ze("h-8"),required:!0})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Task"}),e.jsx("textarea",{value:t.task,onChange:o=>p("task",o.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ze("resize-y py-2"),required:!0})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Frequency"}),e.jsx("div",{className:"rounded-t-lg border border-border p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:zt.map(o=>{const w=t.recurrence===o.value;return e.jsx("button",{type:"button",className:$("rounded-md border px-2 py-2 text-sm font-medium transition-colors",w?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-transparent text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":w,onClick:()=>p("recurrence",o.value),children:o.label},o.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"rounded-md border border-border bg-secondary-bg/40 px-3 py-2",children:[e.jsx("span",{className:"block text-xs text-text-secondary",children:"Existing custom schedule"}),e.jsx("code",{className:"mt-1 block font-mono text-sm text-text-primary",children:t.customCron}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"Select Hourly, Daily, or Weekly to replace this schedule."})]}):null,t.recurrence==="weekly"?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-2 text-sm font-medium",children:"Days"}),e.jsx("div",{className:"flex gap-2",children:Me.map(o=>{const w=t.weekdays.includes(o.value);return e.jsx("button",{type:"button",className:$("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",w?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-border text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":w,onClick:()=>j(o.value),children:o.label},o.value)})})]}):null,e.jsxs("div",{className:"flex gap-4",children:[t.recurrence==="daily"||t.recurrence==="weekly"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Hour"}),e.jsx(ce,{"aria-label":"Hour",value:String(t.hour),options:At,onValueChange:o=>p("hour",Number(o))})]}):null,t.recurrence!=="custom"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Minute"}),e.jsx(ce,{"aria-label":"Minute",value:String(t.minute),options:Rt,onValueChange:o=>p("minute",Number(o))})]}):null,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Timezone"}),e.jsx(ce,{"aria-label":"Timezone",value:t.timezone,options:u,onValueChange:o=>p("timezone",o),menuClassName:"w-full min-w-0"})]})]})]})}),e.jsx("div",{className:"rounded-b-lg border border-t-0 border-border bg-primary-button-bg/10 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:f||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:m||"—"})]})})]})]})}function Pt(t){return t.startsWith("manual-")}function Lt(t){return t==="failed"?"failed":"success"}function Be(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Oe(t){return Pt(t)?"Manual test":"Cron"}function Ft(t,s=5){return t.filter(a=>a.status!=="scheduled").slice(0,s).reverse()}function fe(t){if(t==null)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":jt(s)}function It({run:t}){return e.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Be(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Oe(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",fe(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",fe(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]})]})}var Mt={success:"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",failed:"border-red-600/30 bg-red-500/10 text-red-700 dark:border-red-400/35 dark:bg-red-500/15 dark:text-red-300"};function _e({run:t}){const s=Lt(t.status),i=fe(t.triggeredAt??t.scheduledFor);return e.jsx(bt,{content:e.jsx(It,{run:t}),side:"top",children:e.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Mt[s]),"aria-label":`${Be(t.status)} run at ${i}`,children:e.jsx(A,{name:s==="failed"?"triangle-exclamation":"check",className:"size-3.5"})})})}function Ue({status:t}){const s=t==="active";return e.jsxs("span",{className:$("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",s?"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300":"border-amber-600/30 bg-amber-500/10 text-amber-800 dark:border-amber-400/35 dark:bg-amber-500/15 dark:text-amber-300"),children:[e.jsx("span",{className:$("size-1.5 shrink-0 rounded-full",s?"bg-emerald-600 dark:bg-emerald-400":"bg-amber-600 dark:bg-amber-400"),"aria-hidden":!0}),s?"Active":"Paused"]})}function $t(t,s){return t.find(i=>i.name===s||i.id===s)??null}function Bt({connector:t,onConnected:s}){return wt()==null?null:e.jsx(St,{connector:t,onConnected:s})}function ne({label:t,children:s}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border px-3 py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-text-secondary shrink-0 text-[10px] font-semibold tracking-wide uppercase",children:t}),e.jsx("div",{className:"min-w-0 text-right text-sm text-text-primary",children:s})]})}function Ot({schedule:t,agentName:s,mcpMounts:i,onEditConfiguration:a}){const r=be(),d=ge(),{connectors:g,ensureLoaded:y,refreshConnectors:m,loading:f,error:u}=vt(),[p,j]=l.useState(!1),[o,w]=l.useState(null),E=ae({cron:t.cron,timezone:t.timezone}),b=async()=>{j(!0);try{const k=await r.createScheduleRun({scheduleId:t.id});w(k),d==null||d.showSuccess({title:"Test run started"})}catch(k){d==null||d.showError(k)}finally{j(!1)}};return l.useEffect(()=>{y()},[y]),l.useEffect(()=>{u!=null&&(d==null||d.showError(u))},[u,d]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ne,{label:"Agent",children:s}),e.jsx(ne,{label:"Name",children:t.name}),e.jsx(ne,{label:"Status",children:e.jsx(Ue,{status:t.status})}),e.jsx(ne,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ne,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:E}),e.jsx("code",{className:"text-text-secondary font-mono text-xs",children:t.cron})]})}),e.jsx("div",{className:"flex justify-end px-3 py-2.5",children:e.jsxs(q.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),i.length===0?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"No MCP connectors configured for this agent."}):e.jsx("ul",{className:"divide-y divide-border",children:i.map(k=>{const C=$t(g,k.name),z=(C==null?void 0:C.authenticated)===!0,H=C==null&&!f;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:$("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",z?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:z?e.jsx(A,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:k.name}),z?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):H?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):C!=null&&C.authenticated===!1?e.jsx(Bt,{connector:C,onConnected:m}):f?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},k.name)})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Test Run"}),e.jsxs(q.Primary,{type:"button",disabled:p,size:"small",onClick:()=>void b(),children:[e.jsx(A,{name:p?"loader":"play",className:$("size-3.5",p&&"animate-spin")}),"Run Test"]})]}),o==null?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"Run a one-off test using the schedule task. This does not change the cron pending run."}):e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3",children:[e.jsx(_e,{run:o}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Oe(o.name)}),e.jsx("p",{className:"text-text-secondary",children:Et(o.triggeredAt??o.scheduledFor)})]})]})]})]})}function _t({open:t,onOpenChange:s,mode:i,schedule:a,initialAgentId:r="",onSaved:d}){const g=be(),y=Le(),m=gt(),f=ge(),[u,p]=l.useState(de),[j,o]=l.useState(r),[w,E]=l.useState(null),[b,k]=l.useState({kind:"form"}),[C,z]=l.useState(!1),[H,R]=l.useState(!1),[F,v]=l.useState(null),W=l.useRef(j);W.current=j;const B=b.kind==="form"?b.saved:b.schedule,D=i==="edit"&&b.kind==="form"&&b.saved==null&&a!=null,I=b.kind==="form"&&b.saved!=null,G=i==="create"&&b.kind==="form"&&b.saved==null,{allows:O}=xe({resourceType:"agent",resourceIds:j.length===0?[]:[j]});l.useEffect(()=>{if(!t){p(de()),o(r),E(null),v(null),k({kind:"form"}),R(!1);return}if(i==="edit"&&a!=null){p(Re({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),o(a.agentId),E(null),k({kind:"form"});return}p(de()),o(r),E(null),k({kind:"form"})},[t,i,a,r]),l.useEffect(()=>{if(!t||i!=="create"||r.length===0)return;let c=!1;const N=r;return pt({server:y,agentKey:N}).then(S=>{c||S==null||W.current===N&&(E(S),o(ue(S)))}).catch(()=>{}),()=>{c=!0}},[t,i,r,y]);const _=(w==null?void 0:w.name)??(B==null?void 0:B.agentName)??(a==null?void 0:a.agentName)??(j.length>0?j:""),K=l.useMemo(()=>{var N;return(((N=w==null?void 0:w.agentSpec)==null?void 0:N.mcpServers)??[]).map(Nt).filter(S=>S!=null).map(S=>({name:S}))},[w]),P=l.useMemo(()=>{const c=he(u);return u.name.trim().length>0&&u.task.trim().length>0&&c.length>0&&j.length>0&&(!G||O(j,"USE"))},[j,O,u,G]),U=c=>{k({kind:"test",schedule:c}),p(Re({name:c.name,task:c.task,cron:c.cron,timezone:c.timezone})),o(c.agentId)},V=async c=>{if(c.preventDefault(),!P)return;const N=he(u);z(!0),v(null);try{if(D&&a!=null){await g.updateSchedule({id:a.id,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:a.status}),d==null||d(),s(!1);return}if(I&&b.kind==="form"&&b.saved!=null){const Y=await g.updateSchedule({id:b.saved.id,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:"paused"});d==null||d(),U(Y),f==null||f.showSuccess({title:"Schedule saved as paused",description:ae({cron:Y.cron,timezone:Y.timezone})});return}const S=await g.createSchedule({agentId:j,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:"paused"});d==null||d(),U(S),f==null||f.showSuccess({title:"Schedule saved as paused",description:ae({cron:S.cron,timezone:S.timezone})})}catch(S){const Y=S instanceof Error?S.message:"Failed to save schedule";v(Y)}finally{z(!1)}},L=async()=>{if(b.kind==="test"){R(!0),v(null);try{await g.updateSchedule({id:b.schedule.id,name:b.schedule.name,task:b.schedule.task,cron:b.schedule.cron,timezone:b.schedule.timezone,status:"active"}),d==null||d(),f==null||f.showSuccess({title:"Schedule activated"}),s(!1)}catch(c){const N=c instanceof Error?c.message:"Failed to activate schedule";v(N),f==null||f.showError(c)}finally{R(!1)}}},Q=b.kind==="test"?"Test Schedule":D||I?"Edit Schedule":"New Schedule",ee=b.kind==="test"?`Recurring unattended runs of ${_}.`:D||I?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let h;return b.kind==="test"?h=e.jsxs("div",{className:"flex flex-col gap-2",children:[F!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(q.Secondary,{type:"button",className:"w-full",disabled:H,onClick:()=>void L(),children:"Activate Schedule"})]}):h=e.jsxs("div",{className:"flex flex-col gap-2",children:[F!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(q.Secondary,{type:"button",onClick:()=>s(!1),disabled:C,children:"Cancel"}),e.jsx(q.Primary,{type:"submit",form:"schedule-form",disabled:!P||C,children:"Save"})]})]}),e.jsx(yt,{open:t,onOpenChange:s,title:Q,description:ee,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(A,{name:b.kind==="test"||D||I?"calendar":"calendar-plus",className:"size-5"})}),footer:h,children:b.kind==="test"?e.jsx(Ot,{schedule:b.schedule,agentName:_,mcpMounts:K,onEditConfiguration:()=>{v(null),k({kind:"form",saved:b.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:c=>void V(c),children:e.jsx(Dt,{values:u,onChange:p,agentId:j,agentLabel:_,onAgentIdChange:D||I?void 0:c=>{o(c),c.length===0&&E(null)},onAgentPicked:E,agentPickerDisabled:D||I,onBuildAgent:i==="create"&&(m==null?void 0:m.isComposerEnabled)===!0?()=>{s(!1),m.openAgentBuilder()}:void 0})})})}function De(t){return e.jsx(ft,{children:e.jsx(_t,{...t})})}function Ut({runs:t}){const s=Ft(t);return s.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:s.map(i=>e.jsx(_e,{run:i},i.id))})}var qt=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Pe=[10,25];function ie(t){return Math.min(Math.max(t,1),25)}function oe(t){const s=pe(t);return{nameQuery:s.q??"",statusFilter:s.status??"all",agentFilter:s.agent??"all"}}function Ht(t){const s=pe(window.location.search);if(!s.isNew)return{kind:"closed"};const i=t??s.agent;return{kind:"create",...i==null?{}:{agentId:i}}}function Gt({schedule:t,running:s,canManage:i,canDelete:a,onRunNow:r,onEdit:d,onTogglePause:g,onDelete:y}){const m=mt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(m,{allowed:i,children:e.jsxs(q.Secondary,{type:"button",disabled:s,"aria-label":`Run now ${t.name}`,size:"large",onClick:r,children:[e.jsx(A,{name:s?"loader":"play",className:$("size-3.5",s&&"animate-spin")}),"Run now"]})}),e.jsxs(xt,{align:"end",trigger:e.jsx("button",{type:"button",className:ht({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(A,{name:"ellipsis"})}),children:[e.jsx(m,{allowed:i,children:e.jsxs(me,{onClick:d,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(m,{allowed:i,children:e.jsxs(me,{onClick:g,children:[e.jsx(A,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(m,{allowed:a,children:e.jsxs(me,{className:"text-failure-bg focus:text-failure-bg",onClick:y,children:[e.jsx(A,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function Qt({agentId:t}){const s=be(),i=Le(),a=ge(),[r,d]=l.useState([]),{allows:g}=xe({resourceType:"schedule",resourceIds:r.map(n=>n.id)}),[y,m]=l.useState({}),[f,u]=l.useState(!1),[p,j]=l.useState(()=>new Set),[o,w]=l.useState({}),[E,b]=l.useState(!0),[k,C]=l.useState(null),[z,H]=l.useState(()=>oe(window.location.search).nameQuery),[R,F]=l.useState(()=>oe(window.location.search).statusFilter),[v,W]=l.useState(()=>t??oe(window.location.search).agentFilter),B=t??(v==="all"?null:v),{allows:D}=xe({resourceType:"agent",resourceIds:B==null?[]:[B]}),I=i.permissions==null||B==null||D(B,"USE"),[G,O]=l.useState(()=>Ht(t)),[_,K]=l.useState(null),[P,U]=l.useState(()=>ie(lt)),[V,L]=l.useState(void 0),[Q,ee]=l.useState(void 0),[h,c]=l.useState([]),N=l.useRef(0),S=l.useRef(!1),Y=l.useCallback(async({rows:n,gen:x})=>{if(n.length===0){x===N.current&&m({});return}u(!0);try{const T=await Promise.allSettled(n.map(M=>s.listScheduleRuns({scheduleId:M.id})));if(x!==N.current)return;m(Object.fromEntries(n.map((M,Z)=>{const se=T[Z],Ve=(se==null?void 0:se.status)==="fulfilled"?se.value:[];return[M.id,Ve]})))}finally{x===N.current&&u(!1)}},[s]),te=l.useCallback(async({token:n,size:x,agentId:T})=>{const M=++N.current;b(!0),C(null);try{const Z=await s.listSchedules({limit:ie(x),...n===void 0||n===""?{}:{pageToken:n},...T==="all"?{}:{agentIds:[T]}});if(M!==N.current)return;d(Z.data),ee(Z.nextPageToken),Y({rows:Z.data,gen:M})}catch(Z){if(M!==N.current)return;const se=Z instanceof Error?Z.message:"Failed to load schedules";C(se),d([]),m({}),ee(void 0)}finally{M===N.current&&b(!1)}},[s,Y]),Ne=l.useCallback(n=>{const x=(n==null?void 0:n.size)??P,T=(n==null?void 0:n.agentId)??v;L(void 0),c([]),te({token:void 0,size:x,agentId:T})},[v,te,P]);l.useEffect(()=>{Se({agent:t===void 0&&v!=="all"?v:null,status:R==="all"?null:R,q:z.trim().length===0?null:z})},[v,t,R,z]),l.useEffect(()=>{t!==void 0&&W(n=>n===t?n:(L(void 0),c([]),t))},[t]),l.useEffect(()=>{S.current||!pe(window.location.search).isNew||(S.current=!0,Se({isNew:null}))},[]),l.useEffect(()=>{const n=()=>{const x=oe(window.location.search);H(x.nameQuery),F(x.statusFilter),W(T=>{const M=t??x.agentFilter;return T===M?T:(L(void 0),c([]),M)})};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[t]),l.useEffect(()=>{te({token:V,size:P,agentId:v})},[v,P,V,te]);const re=l.useMemo(()=>{const n=z.trim().toLowerCase();return r.filter(x=>!(R!=="all"&&x.status!==R||n.length>0&&!x.name.toLowerCase().includes(n)))},[r,z,R]),ye=Qe(r),je=h.length>0||Q!=null,qe=async n=>{if(!g(n.id,"MANAGE"))return;const x=n.status==="active"?"paused":"active";try{await s.updateSchedule({...n,status:x}),await te({token:V,size:P,agentId:v})}catch(T){a==null||a.showError(T)}},He=async n=>{if(g(n.id,"MANAGE")){j(x=>new Set(x).add(n.id));try{await s.createScheduleRun({scheduleId:n.id}),a==null||a.showSuccess({title:"Run started"});const x=await s.listScheduleRuns({scheduleId:n.id});m(T=>({...T,[n.id]:x}))}catch(x){a==null||a.showError(x)}finally{j(x=>{const T=new Set(x);return T.delete(n.id),T})}}},Ge=async n=>{if(g(n.id,"DELETE")){K(null);try{await s.deleteSchedule({id:n.id}),Ne()}catch(x){a==null||a.showError(x)}}},ve=()=>{Q!=null&&(c(n=>[...n,V??""]),L(Q))},we=()=>{if(h.length===0)return;const n=[...h],x=n.pop();c(n),L(x===""?void 0:x)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(We,{title:t===void 0?"Scheduled Agents":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(Ke,{query:z,setQuery:H,placeholder:"Search schedules by name"})}),e.jsx(ce,{value:R,onValueChange:F,options:qt,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(Fe,{value:v,selectedLabel:v==="all"?"All agents":o[v]??v,onValueChange:n=>{W(n),L(void 0),c([])},onAgentPicked:n=>{w(x=>({...x,[ue(n)]:n.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs(q.Primary,{type:"button",disabled:!I,onClick:()=>I&&O({kind:"create",agentId:v!=="all"?v:void 0}),children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4",children:E?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(n,x)=>e.jsx(Ye,{className:"h-12 w-full rounded-md"},x))}):k!=null?e.jsx("p",{className:"text-failure-bg px-3 py-8 text-center text-sm",children:k}):r.length===0?e.jsx(ke,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):re.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(ke,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),je?e.jsx(Te,{pageSize:P,rowCount:0,canPrev:h.length>0,canNext:Q!=null,onPrev:we,onNext:ve,pageSizeOptions:Pe,onPageSizeChange:n=>{const x=ie(n);U(x),L(void 0),c([])}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(Ze,{className:"min-w-[48rem]",children:[e.jsx(Je,{children:e.jsxs(Ce,{className:"hover:bg-transparent",children:[e.jsx(J,{children:"Name"}),e.jsx(J,{children:"Agent"}),ye?e.jsx(J,{children:"Created by"}):null,e.jsx(J,{children:"Frequency"}),e.jsx(J,{children:"Status"}),e.jsx(J,{children:"Last 5 runs"}),e.jsx(J,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(Xe,{children:re.map(n=>{const x=ae({cron:n.cron,timezone:n.timezone}),T=n.agentName??o[n.agentId]??n.agentId;return e.jsxs(Ce,{children:[e.jsx(X,{className:"text-text-primary font-medium",children:e.jsx("span",{className:"text-left !no-underline",children:n.name})}),e.jsx(X,{children:T}),ye?e.jsx(X,{children:e.jsx(et,{subject:n.createdBySubject})}):null,e.jsx(X,{children:x}),e.jsx(X,{children:e.jsx(Ue,{status:n.status})}),e.jsx(X,{children:f?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(Ut,{runs:y[n.id]??[]})}),e.jsx(X,{className:"text-right",children:e.jsx(Gt,{schedule:n,running:p.has(n.id),canManage:g(n.id,"MANAGE"),canDelete:g(n.id,"DELETE"),onRunNow:()=>void He(n),onEdit:()=>{g(n.id,"MANAGE")&&O({kind:"edit",schedule:n})},onTogglePause:()=>void qe(n),onDelete:()=>{g(n.id,"DELETE")&&K(n)}})})]},n.id)})})]}),(re.length>0||je)&&e.jsx(Te,{pageSize:P,rowCount:re.length,canPrev:h.length>0,canNext:Q!=null,onPrev:we,onNext:ve,pageSizeOptions:Pe,onPageSizeChange:n=>{const x=ie(n);U(x),L(void 0),c([])}})]})}),G.kind==="create"?e.jsx(De,{open:!0,mode:"create",initialAgentId:G.agentId??"",onOpenChange:n=>{n||O({kind:"closed"})},onSaved:()=>Ne()}):null,G.kind==="edit"?e.jsx(De,{open:!0,mode:"edit",schedule:G.schedule,onOpenChange:n=>{n||O({kind:"closed"})},onSaved:()=>void te({token:V,size:P,agentId:v})}):null,_!=null?e.jsxs(tt,{open:!0,onOpenChange:n=>{n||K(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(st,{children:e.jsxs(nt,{children:[e.jsx(at,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",_.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(rt,{children:[e.jsx(q.Secondary,{type:"button",onClick:()=>K(null),children:"Cancel"}),e.jsx(q.Destructive,{type:"button",disabled:!g(_.id,"DELETE"),onClick:()=>void Ge(_),children:"Delete"})]})]}):null]})}export{Qt as SchedulesPage};