@truefoundry/trueforge 0.2.0-rc.2 → 0.2.0-rc.4

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 (239) hide show
  1. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js +1 -0
  2. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js.gz +0 -0
  4. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js +1 -0
  5. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-3FJ5EE6N-D1pX5Emq.js → AgentOverview-RLJ6HZCN-YJvNjt8b.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-RLJ6HZCN-YJvNjt8b.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-RLJ6HZCN-YJvNjt8b.js.gz +0 -0
  10. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js +1 -0
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js.gz +0 -0
  13. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js +1 -0
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js.gz +0 -0
  16. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js +1 -0
  17. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js.gz +0 -0
  19. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js +1 -0
  20. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-NLFNU6F2-BGJvqqVS.js → DockLayout-J5BRKMJZ-xjQQzILb.js} +1 -1
  23. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js +2 -0
  24. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js.gz +0 -0
  26. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js +1 -0
  27. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js.br +0 -0
  28. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js.gz +0 -0
  29. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js +1 -0
  30. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js.br +0 -0
  31. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js.gz +0 -0
  32. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js +1 -0
  33. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js.br +0 -0
  34. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js.gz +0 -0
  35. package/dist/_frontend/assets/{SettingsBuilder-LSXK2VN4-B0Y9JGuK.js → SettingsBuilder-A4BPYIFZ-B4p1JpXq.js} +2 -2
  36. package/dist/_frontend/assets/SettingsBuilder-A4BPYIFZ-B4p1JpXq.js.br +0 -0
  37. package/dist/_frontend/assets/SettingsBuilder-A4BPYIFZ-B4p1JpXq.js.gz +0 -0
  38. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js +1 -0
  39. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js.br +0 -0
  40. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js.gz +0 -0
  41. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js +2 -0
  42. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js.br +0 -0
  43. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js.gz +0 -0
  44. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js +1 -0
  45. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js.br +0 -0
  46. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js.gz +0 -0
  47. package/dist/_frontend/assets/TrueForgeUIWithRouter-5CDICMCE-DcMl1KUh.js +1 -0
  48. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js +1 -0
  49. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js.br +0 -0
  50. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js.gz +0 -0
  51. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js +1 -0
  52. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js.br +0 -0
  53. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js.gz +0 -0
  54. package/dist/_frontend/assets/{chunk-62JRHF6Z-gAUkEAjv.js → chunk-62JRHF6Z-6aeTVQm8.js} +1 -1
  55. package/dist/_frontend/assets/chunk-62JRHF6Z-6aeTVQm8.js.br +0 -0
  56. package/dist/_frontend/assets/{chunk-62JRHF6Z-gAUkEAjv.js.gz → chunk-62JRHF6Z-6aeTVQm8.js.gz} +0 -0
  57. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js +1 -0
  58. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js.br +0 -0
  59. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js.gz +0 -0
  60. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js +2 -0
  61. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js.gz +0 -0
  63. package/dist/_frontend/assets/cssMode-BSK94pjD.js +1 -0
  64. package/dist/_frontend/assets/cssMode-BSK94pjD.js.br +0 -0
  65. package/dist/_frontend/assets/cssMode-BSK94pjD.js.gz +0 -0
  66. package/dist/_frontend/assets/{freemarker2-BqULNxdn.js → freemarker2-hYZ9lU-u.js} +1 -1
  67. package/dist/_frontend/assets/freemarker2-hYZ9lU-u.js.br +0 -0
  68. package/dist/_frontend/assets/freemarker2-hYZ9lU-u.js.gz +0 -0
  69. package/dist/_frontend/assets/{handlebars-D-wN_MMv.js → handlebars-CJdvCy_0.js} +1 -1
  70. package/dist/_frontend/assets/handlebars-CJdvCy_0.js.br +0 -0
  71. package/dist/_frontend/assets/handlebars-CJdvCy_0.js.gz +0 -0
  72. package/dist/_frontend/assets/{html-DX_2Eu_G.js → html-BHnJtaJv.js} +1 -1
  73. package/dist/_frontend/assets/html-BHnJtaJv.js.br +0 -0
  74. package/dist/_frontend/assets/html-BHnJtaJv.js.gz +0 -0
  75. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js +1 -0
  76. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js.br +0 -0
  77. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js.gz +0 -0
  78. package/dist/_frontend/assets/{index-MPbqVnOf.js → index-B1sBHguz.js} +1 -1
  79. package/dist/_frontend/assets/index-B1sBHguz.js.br +0 -0
  80. package/dist/_frontend/assets/index-B1sBHguz.js.gz +0 -0
  81. package/dist/_frontend/assets/{index-SN54UIUh.css → index-BBGLYdJn.css} +1 -1
  82. package/dist/_frontend/assets/index-BBGLYdJn.css.br +0 -0
  83. package/dist/_frontend/assets/index-BBGLYdJn.css.gz +0 -0
  84. package/dist/_frontend/assets/{index-CNHFMp3w.js → index-BU6gYO7K.js} +4 -4
  85. package/dist/_frontend/assets/index-BU6gYO7K.js.br +0 -0
  86. package/dist/_frontend/assets/index-BU6gYO7K.js.gz +0 -0
  87. package/dist/_frontend/assets/index-DZOZ1xN3.js +933 -0
  88. package/dist/_frontend/assets/index-DZOZ1xN3.js.br +0 -0
  89. package/dist/_frontend/assets/index-DZOZ1xN3.js.gz +0 -0
  90. package/dist/_frontend/assets/index-DhA9jnhv.css +1 -0
  91. package/dist/_frontend/assets/index-DhA9jnhv.css.br +0 -0
  92. package/dist/_frontend/assets/index-DhA9jnhv.css.gz +0 -0
  93. package/dist/_frontend/assets/{javascript-CO_8uS79.js → javascript-BKY4Sujy.js} +1 -1
  94. package/dist/_frontend/assets/{jsonMode-D0kqu8c3.js → jsonMode-B_jTSLwe.js} +4 -4
  95. package/dist/_frontend/assets/jsonMode-B_jTSLwe.js.br +0 -0
  96. package/dist/_frontend/assets/jsonMode-B_jTSLwe.js.gz +0 -0
  97. package/dist/_frontend/assets/{liquid-CB807zJs.js → liquid-OVC8bSZr.js} +1 -1
  98. package/dist/_frontend/assets/liquid-OVC8bSZr.js.br +0 -0
  99. package/dist/_frontend/assets/liquid-OVC8bSZr.js.gz +0 -0
  100. package/dist/_frontend/assets/{lspLanguageFeatures-D0-0mkv4.js → lspLanguageFeatures-BpQc31SX.js} +1 -1
  101. package/dist/_frontend/assets/lspLanguageFeatures-BpQc31SX.js.br +0 -0
  102. package/dist/_frontend/assets/lspLanguageFeatures-BpQc31SX.js.gz +0 -0
  103. package/dist/_frontend/assets/{mdx-7_H2_m8y.js → mdx-Rt-sDg8a.js} +1 -1
  104. package/dist/_frontend/assets/mdx-Rt-sDg8a.js.br +0 -0
  105. package/dist/_frontend/assets/mdx-Rt-sDg8a.js.gz +0 -0
  106. package/dist/_frontend/assets/{python-DhB7kQ15.js → python-CLLuhWlP.js} +1 -1
  107. package/dist/_frontend/assets/python-CLLuhWlP.js.br +0 -0
  108. package/dist/_frontend/assets/python-CLLuhWlP.js.gz +0 -0
  109. package/dist/_frontend/assets/{razor-CDzQiIjH.js → razor-CTEZKBpz.js} +1 -1
  110. package/dist/_frontend/assets/razor-CTEZKBpz.js.br +0 -0
  111. package/dist/_frontend/assets/razor-CTEZKBpz.js.gz +0 -0
  112. package/dist/_frontend/assets/{tsMode-CVP7xaF5.js → tsMode-BsjOp9ss.js} +1 -1
  113. package/dist/_frontend/assets/tsMode-BsjOp9ss.js.br +0 -0
  114. package/dist/_frontend/assets/tsMode-BsjOp9ss.js.gz +0 -0
  115. package/dist/_frontend/assets/{typescript-BTAuo6jN.js → typescript-CpIJvyBH.js} +1 -1
  116. package/dist/_frontend/assets/typescript-CpIJvyBH.js.br +0 -0
  117. package/dist/_frontend/assets/typescript-CpIJvyBH.js.gz +0 -0
  118. package/dist/_frontend/assets/{workers-Dl5avODY.js → workers-C_uhAUan.js} +1 -1
  119. package/dist/_frontend/assets/workers-C_uhAUan.js.br +0 -0
  120. package/dist/_frontend/assets/workers-C_uhAUan.js.gz +0 -0
  121. package/dist/_frontend/assets/{xml-CKI7eM7V.js → xml-BxHi2HCJ.js} +1 -1
  122. package/dist/_frontend/assets/xml-BxHi2HCJ.js.br +0 -0
  123. package/dist/_frontend/assets/xml-BxHi2HCJ.js.gz +0 -0
  124. package/dist/_frontend/assets/{yaml-Czn9FR3r.js → yaml-DyyH_CDu.js} +1 -1
  125. package/dist/_frontend/assets/yaml-DyyH_CDu.js.br +0 -0
  126. package/dist/_frontend/assets/yaml-DyyH_CDu.js.gz +0 -0
  127. package/dist/_frontend/index.html +5 -2
  128. package/dist/controller-main.js +197 -118
  129. package/dist/controller-main.js.map +1 -1
  130. package/dist/main.js +10461 -8718
  131. package/dist/main.js.map +1 -1
  132. package/dist/postgres/migrations/20260907_000001_schedule_run_reason.js +15 -0
  133. package/dist/postgres/migrations/20260907_000001_schedule_run_reason.js.map +1 -0
  134. package/dist/sqlite/migrations/20260907_000001_schedule_run_reason.js +17 -0
  135. package/dist/sqlite/migrations/20260907_000001_schedule_run_reason.js.map +1 -0
  136. package/package.json +3 -4
  137. package/dist/_frontend/assets/AgentCodeSnippets-637HQUXD-C5c8zg9J.js +0 -1
  138. package/dist/_frontend/assets/AgentCodeSnippets-637HQUXD-C5c8zg9J.js.br +0 -0
  139. package/dist/_frontend/assets/AgentCodeSnippets-637HQUXD-C5c8zg9J.js.gz +0 -0
  140. package/dist/_frontend/assets/AgentMetricChart-4FYECRIN-BN07l9mr.js +0 -1
  141. package/dist/_frontend/assets/AgentMetricChart-4FYECRIN-BN07l9mr.js.br +0 -0
  142. package/dist/_frontend/assets/AgentMetricChart-4FYECRIN-BN07l9mr.js.gz +0 -0
  143. package/dist/_frontend/assets/AgentOverview-3FJ5EE6N-D1pX5Emq.js.br +0 -0
  144. package/dist/_frontend/assets/AgentOverview-3FJ5EE6N-D1pX5Emq.js.gz +0 -0
  145. package/dist/_frontend/assets/AgentSessionEventTimeline-VELWUYPR-S1LS04B9.js +0 -1
  146. package/dist/_frontend/assets/AgentSessionEventTimeline-VELWUYPR-S1LS04B9.js.br +0 -0
  147. package/dist/_frontend/assets/AgentSessionEventTimeline-VELWUYPR-S1LS04B9.js.gz +0 -0
  148. package/dist/_frontend/assets/AgentSessionEventTimelineChart-CUKETHWM-D4LvjUpF.js +0 -1
  149. package/dist/_frontend/assets/AgentSessionEventTimelineChart-CUKETHWM-D4LvjUpF.js.br +0 -0
  150. package/dist/_frontend/assets/AgentSessionEventTimelineChart-CUKETHWM-D4LvjUpF.js.gz +0 -0
  151. package/dist/_frontend/assets/AgentSessions-T7MOGOTZ-wppcDkIn.js +0 -1
  152. package/dist/_frontend/assets/AgentSessions-T7MOGOTZ-wppcDkIn.js.br +0 -0
  153. package/dist/_frontend/assets/AgentSessions-T7MOGOTZ-wppcDkIn.js.gz +0 -0
  154. package/dist/_frontend/assets/ConnectorSettings-ESZ2RSRG-DLxrylX3.js +0 -1
  155. package/dist/_frontend/assets/ConnectorSettings-ESZ2RSRG-DLxrylX3.js.br +0 -0
  156. package/dist/_frontend/assets/ConnectorSettings-ESZ2RSRG-DLxrylX3.js.gz +0 -0
  157. package/dist/_frontend/assets/DrawerLayout-PR3SMKA6-C13frtIA.js +0 -2
  158. package/dist/_frontend/assets/DrawerLayout-PR3SMKA6-C13frtIA.js.br +0 -0
  159. package/dist/_frontend/assets/DrawerLayout-PR3SMKA6-C13frtIA.js.gz +0 -0
  160. package/dist/_frontend/assets/ModelSettings-LYW64IRR-BLLhCXsR.js +0 -1
  161. package/dist/_frontend/assets/ModelSettings-LYW64IRR-BLLhCXsR.js.br +0 -0
  162. package/dist/_frontend/assets/ModelSettings-LYW64IRR-BLLhCXsR.js.gz +0 -0
  163. package/dist/_frontend/assets/SandboxSettings-DF64LHYI-7AeygCju.js +0 -1
  164. package/dist/_frontend/assets/SandboxSettings-DF64LHYI-7AeygCju.js.br +0 -0
  165. package/dist/_frontend/assets/SandboxSettings-DF64LHYI-7AeygCju.js.gz +0 -0
  166. package/dist/_frontend/assets/SchedulesPage-WQU4H25F-BGlu6WXG.js +0 -1
  167. package/dist/_frontend/assets/SchedulesPage-WQU4H25F-BGlu6WXG.js.br +0 -0
  168. package/dist/_frontend/assets/SchedulesPage-WQU4H25F-BGlu6WXG.js.gz +0 -0
  169. package/dist/_frontend/assets/SettingsBuilder-LSXK2VN4-B0Y9JGuK.js.br +0 -0
  170. package/dist/_frontend/assets/SettingsBuilder-LSXK2VN4-B0Y9JGuK.js.gz +0 -0
  171. package/dist/_frontend/assets/ShellRouteSync-B22IAV2W-leIgCXVi.js +0 -1
  172. package/dist/_frontend/assets/ShellRouteSync-B22IAV2W-leIgCXVi.js.br +0 -0
  173. package/dist/_frontend/assets/ShellRouteSync-B22IAV2W-leIgCXVi.js.gz +0 -0
  174. package/dist/_frontend/assets/SidebarLayout-XW6LXB7R-Cfmnvl3i.js +0 -2
  175. package/dist/_frontend/assets/SidebarLayout-XW6LXB7R-Cfmnvl3i.js.br +0 -0
  176. package/dist/_frontend/assets/SidebarLayout-XW6LXB7R-Cfmnvl3i.js.gz +0 -0
  177. package/dist/_frontend/assets/SkillSettings-64VXUO6J-CeuMawWX.js +0 -1
  178. package/dist/_frontend/assets/SkillSettings-64VXUO6J-CeuMawWX.js.br +0 -0
  179. package/dist/_frontend/assets/SkillSettings-64VXUO6J-CeuMawWX.js.gz +0 -0
  180. package/dist/_frontend/assets/TrueForgeUIWithRouter-3TSLV22Q-BiR4AwMi.js +0 -1
  181. package/dist/_frontend/assets/WidgetLayout-Q5P7PYSJ-D-NJInrA.js +0 -1
  182. package/dist/_frontend/assets/WidgetLayout-Q5P7PYSJ-D-NJInrA.js.br +0 -0
  183. package/dist/_frontend/assets/WidgetLayout-Q5P7PYSJ-D-NJInrA.js.gz +0 -0
  184. package/dist/_frontend/assets/chunk-62JRHF6Z-gAUkEAjv.js.br +0 -0
  185. package/dist/_frontend/assets/chunk-I3AL54MA--fCRbraS.js +0 -2
  186. package/dist/_frontend/assets/chunk-I3AL54MA--fCRbraS.js.br +0 -0
  187. package/dist/_frontend/assets/chunk-I3AL54MA--fCRbraS.js.gz +0 -0
  188. package/dist/_frontend/assets/chunk-SQGT43Z3-Di5-vYAQ.js +0 -1
  189. package/dist/_frontend/assets/chunk-SQGT43Z3-Di5-vYAQ.js.br +0 -0
  190. package/dist/_frontend/assets/chunk-SQGT43Z3-Di5-vYAQ.js.gz +0 -0
  191. package/dist/_frontend/assets/chunk-VUMGMGKZ-CUX2iOMe.js +0 -1
  192. package/dist/_frontend/assets/chunk-VUMGMGKZ-CUX2iOMe.js.br +0 -0
  193. package/dist/_frontend/assets/chunk-VUMGMGKZ-CUX2iOMe.js.gz +0 -0
  194. package/dist/_frontend/assets/cssMode-Bmk_AUwV.js +0 -1
  195. package/dist/_frontend/assets/cssMode-Bmk_AUwV.js.br +0 -0
  196. package/dist/_frontend/assets/cssMode-Bmk_AUwV.js.gz +0 -0
  197. package/dist/_frontend/assets/freemarker2-BqULNxdn.js.br +0 -0
  198. package/dist/_frontend/assets/freemarker2-BqULNxdn.js.gz +0 -0
  199. package/dist/_frontend/assets/handlebars-D-wN_MMv.js.br +0 -0
  200. package/dist/_frontend/assets/handlebars-D-wN_MMv.js.gz +0 -0
  201. package/dist/_frontend/assets/html-DX_2Eu_G.js.br +0 -0
  202. package/dist/_frontend/assets/html-DX_2Eu_G.js.gz +0 -0
  203. package/dist/_frontend/assets/htmlMode-CqQ0rpq1.js +0 -1
  204. package/dist/_frontend/assets/htmlMode-CqQ0rpq1.js.br +0 -0
  205. package/dist/_frontend/assets/htmlMode-CqQ0rpq1.js.gz +0 -0
  206. package/dist/_frontend/assets/index-CB2SckMT.css +0 -1
  207. package/dist/_frontend/assets/index-CB2SckMT.css.br +0 -0
  208. package/dist/_frontend/assets/index-CB2SckMT.css.gz +0 -0
  209. package/dist/_frontend/assets/index-CNHFMp3w.js.br +0 -0
  210. package/dist/_frontend/assets/index-CNHFMp3w.js.gz +0 -0
  211. package/dist/_frontend/assets/index-G4wOqi3O.js +0 -923
  212. package/dist/_frontend/assets/index-G4wOqi3O.js.br +0 -0
  213. package/dist/_frontend/assets/index-G4wOqi3O.js.gz +0 -0
  214. package/dist/_frontend/assets/index-MPbqVnOf.js.br +0 -0
  215. package/dist/_frontend/assets/index-MPbqVnOf.js.gz +0 -0
  216. package/dist/_frontend/assets/index-SN54UIUh.css.br +0 -0
  217. package/dist/_frontend/assets/index-SN54UIUh.css.gz +0 -0
  218. package/dist/_frontend/assets/jsonMode-D0kqu8c3.js.br +0 -0
  219. package/dist/_frontend/assets/jsonMode-D0kqu8c3.js.gz +0 -0
  220. package/dist/_frontend/assets/liquid-CB807zJs.js.br +0 -0
  221. package/dist/_frontend/assets/liquid-CB807zJs.js.gz +0 -0
  222. package/dist/_frontend/assets/lspLanguageFeatures-D0-0mkv4.js.br +0 -0
  223. package/dist/_frontend/assets/lspLanguageFeatures-D0-0mkv4.js.gz +0 -0
  224. package/dist/_frontend/assets/mdx-7_H2_m8y.js.br +0 -0
  225. package/dist/_frontend/assets/mdx-7_H2_m8y.js.gz +0 -0
  226. package/dist/_frontend/assets/python-DhB7kQ15.js.br +0 -0
  227. package/dist/_frontend/assets/python-DhB7kQ15.js.gz +0 -0
  228. package/dist/_frontend/assets/razor-CDzQiIjH.js.br +0 -0
  229. package/dist/_frontend/assets/razor-CDzQiIjH.js.gz +0 -0
  230. package/dist/_frontend/assets/tsMode-CVP7xaF5.js.br +0 -0
  231. package/dist/_frontend/assets/tsMode-CVP7xaF5.js.gz +0 -0
  232. package/dist/_frontend/assets/typescript-BTAuo6jN.js.br +0 -0
  233. package/dist/_frontend/assets/typescript-BTAuo6jN.js.gz +0 -0
  234. package/dist/_frontend/assets/workers-Dl5avODY.js.br +0 -0
  235. package/dist/_frontend/assets/workers-Dl5avODY.js.gz +0 -0
  236. package/dist/_frontend/assets/xml-CKI7eM7V.js.br +0 -0
  237. package/dist/_frontend/assets/xml-CKI7eM7V.js.gz +0 -0
  238. package/dist/_frontend/assets/yaml-Czn9FR3r.js.br +0 -0
  239. package/dist/_frontend/assets/yaml-Czn9FR3r.js.gz +0 -0
@@ -0,0 +1 @@
1
+ import{c as u,r as s,j as t,I as x,e as i}from"./index-DZOZ1xN3.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{ad as j,r as d,j as a,ay as C,ax as k}from"./index-DZOZ1xN3.js";import{c as F,a as M,d as R,L as S,e as D,P as T,f as p,p as w}from"./index-B1sBHguz.js";M.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:x=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])),b=r[(x+o)%r.length];return{label:s.name,data:c.map(n=>L.get(n)??null),borderColor:b,backgroundColor:b,pointRadius:0,pointHoverRadius:0,borderWidth:2,borderCapStyle:"butt",borderJoinStyle:"miter",tension:0,spanGaps:!0}}))??[]}),[x,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(F,{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};
@@ -1 +1 @@
1
- import{b as R,r as _,j as e,I as O,d as D}from"./index-G4wOqi3O.js";var i="text-right font-mono text-primary-button-bg";function p(t){return typeof t=="object"&&t!=null}function u(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function x(t,...a){for(const l of a){const c=t==null?void 0:t[l];if(c!==void 0)return c}}function U(t){if(!p(t))return!1;const a=x(t,"enableTools","enable_tools");return a===void 0||Array.isArray(a)&&a.includes("@all")}function V(t){const a=t.lastIndexOf("/");return a>=0?t.slice(a+1):t}function L({detail:t}){var C,S,A,I,M,E,T,$;const a=R("Markdown"),l=R("AgentOverviewCard"),[c,F]=_.useState("markdown"),[h,g]=_.useState(!1),n=t.agentSpec,f=n.skills??[],b=n.mcpServers??[],j=p(n.model.params)?n.model.params:null,y=x(j,"maxTokens","max_tokens"),N=x(j,"temperature"),o=p(n.config)?n.config:null,m=p(o==null?void 0:o.sandbox)?o.sandbox:null,d=(C=n.instructions)!=null&&C.trim()?n.instructions:null,v=[["Sandbox",typeof(m==null?void 0:m.enabled)=="boolean"?m.enabled?"Enabled":"Disabled":void 0],["Iteration limit",x(o,"iterationLimit","iteration_limit")],["Response format",x(o,"responseFormat","response_format")]].filter(s=>typeof s[1]=="string"||typeof s[1]=="number"),w=[["Generative UI",(A=(S=n.config)==null?void 0:S.generativeUi)==null?void 0:A.enabled],["Dynamic sub-agents",(M=(I=n.config)==null?void 0:I.dynamicSubAgents)==null?void 0:M.enabled],["Ask user questions",(T=(E=n.config)==null?void 0:E.askUserQuestions)==null?void 0:T.enabled]].filter(s=>typeof s[1]=="boolean"),k=c==="markdown"?"Raw":"Markdown";return e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 overflow-auto p-4 md:grid-cols-[minmax(0,1fr)_18rem] 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(O,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),d?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 ${k}`,onClick:()=>F(s=>s==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:k}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:h?"Copied!":"Copy","aria-label":h?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(d).then(()=>{g(!0),setTimeout(()=>g(!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(O,{name:h?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?c==="markdown"?e.jsx(a,{content:d,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:d}):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:[e.jsx(l,{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:D(i,"truncate"),title:n.model.name,children:V(n.model.name)}),typeof y=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:i,children:y})]}):null,(($=n.model.params)==null?void 0:$.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:i,children:n.model.params.reasoningEffort})]}):null,typeof N=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:i,children:N})]}):null]})}),e.jsx(l,{title:"MCP Servers",icon:"plug",count:b.length,children:b.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No connectors attached."}):e.jsx("ul",{className:"space-y-1.5",children:b.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate",children:u(s)??`Connector ${r+1}`}),U(s)?e.jsx("span",{className:"shrink-0 rounded-full bg-primary-button-bg/10 px-1.5 py-0.5 text-[10px] text-primary-button-bg",children:"All tools"}):null]})},`${u(s)??"connector"}-${r}`))})}),e.jsx(l,{title:"Attached Skills",icon:"lightbulb",count:f.length,children:f.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:f.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:u(s)??`Skill ${r+1}`},`${u(s)??"skill"}-${r}`))})}),v.length>0?e.jsx(l,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:v.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r})]},s))})}):null,w.length>0?e.jsx(l,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:w.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r?"Enabled":"Disabled"})]},s))})}):null]})]})}export{L as default};
1
+ import{c as R,r as _,j as e,I as O,e as D}from"./index-DZOZ1xN3.js";var i="text-right font-mono text-primary-button-bg";function p(t){return typeof t=="object"&&t!=null}function u(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function x(t,...a){for(const l of a){const c=t==null?void 0:t[l];if(c!==void 0)return c}}function U(t){if(!p(t))return!1;const a=x(t,"enableTools","enable_tools");return a===void 0||Array.isArray(a)&&a.includes("@all")}function V(t){const a=t.lastIndexOf("/");return a>=0?t.slice(a+1):t}function L({detail:t}){var C,S,A,I,M,E,T,$;const a=R("Markdown"),l=R("AgentOverviewCard"),[c,F]=_.useState("markdown"),[h,g]=_.useState(!1),n=t.agentSpec,f=n.skills??[],b=n.mcpServers??[],j=p(n.model.params)?n.model.params:null,y=x(j,"maxTokens","max_tokens"),N=x(j,"temperature"),o=p(n.config)?n.config:null,m=p(o==null?void 0:o.sandbox)?o.sandbox:null,d=(C=n.instructions)!=null&&C.trim()?n.instructions:null,v=[["Sandbox",typeof(m==null?void 0:m.enabled)=="boolean"?m.enabled?"Enabled":"Disabled":void 0],["Iteration limit",x(o,"iterationLimit","iteration_limit")],["Response format",x(o,"responseFormat","response_format")]].filter(s=>typeof s[1]=="string"||typeof s[1]=="number"),w=[["Generative UI",(A=(S=n.config)==null?void 0:S.generativeUi)==null?void 0:A.enabled],["Dynamic sub-agents",(M=(I=n.config)==null?void 0:I.dynamicSubAgents)==null?void 0:M.enabled],["Ask user questions",(T=(E=n.config)==null?void 0:E.askUserQuestions)==null?void 0:T.enabled]].filter(s=>typeof s[1]=="boolean"),k=c==="markdown"?"Raw":"Markdown";return e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 overflow-auto p-4 md:grid-cols-[minmax(0,1fr)_18rem] 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(O,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),d?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 ${k}`,onClick:()=>F(s=>s==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:k}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:h?"Copied!":"Copy","aria-label":h?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(d).then(()=>{g(!0),setTimeout(()=>g(!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(O,{name:h?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?c==="markdown"?e.jsx(a,{content:d,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:d}):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:[e.jsx(l,{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:D(i,"truncate"),title:n.model.name,children:V(n.model.name)}),typeof y=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:i,children:y})]}):null,(($=n.model.params)==null?void 0:$.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:i,children:n.model.params.reasoningEffort})]}):null,typeof N=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:i,children:N})]}):null]})}),e.jsx(l,{title:"MCP Servers",icon:"plug",count:b.length,children:b.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No connectors attached."}):e.jsx("ul",{className:"space-y-1.5",children:b.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate",children:u(s)??`Connector ${r+1}`}),U(s)?e.jsx("span",{className:"shrink-0 rounded-full bg-primary-button-bg/10 px-1.5 py-0.5 text-[10px] text-primary-button-bg",children:"All tools"}):null]})},`${u(s)??"connector"}-${r}`))})}),e.jsx(l,{title:"Attached Skills",icon:"lightbulb",count:f.length,children:f.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:f.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:u(s)??`Skill ${r+1}`},`${u(s)??"skill"}-${r}`))})}),v.length>0?e.jsx(l,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:v.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r})]},s))})}):null,w.length>0?e.jsx(l,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:w.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r?"Enabled":"Disabled"})]},s))})}):null]})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{c as u,ad as b,r,ae as f,j as t,af as h,e as S}from"./index-DZOZ1xN3.js";function g({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{g as AgentSessionEventTimeline};
@@ -0,0 +1 @@
1
+ import{ad as Z,r as a,ag as Re,ah as Ie,ai as Pe,aj as De,ak as Le,al as Ge,am as Be,an as m,af as E,ao as $,ap as Y,aq as Oe,ar as $e,as as He,at as Xe,j as s,au as We,av as ze,aw as Ue,ax as Fe,ay as Ve,az as Ke,aA as S,aB as qe,aC as ve}from"./index-DZOZ1xN3.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-B1sBHguz.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};
@@ -0,0 +1 @@
1
+ var $e=e=>{throw TypeError(e)};var He=(e,t,n)=>t.has(e)||$e("Cannot "+n);var ge=(e,t,n)=>(He(e,t,"read from private field"),n?n.call(e):t.get(e)),We=(e,t,n)=>t.has(e)?$e("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ue=(e,t,n,o)=>(He(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n);import{a as kt}from"./chunk-2BDTG544-FxcOqFr-.js";import{r as x,j as P,bn as It,B as Dt,a as Tt,bo as Nt,bp as jt,E as At,c as we,o as Ve,N as Ft,M as Ce,I as Ot,e as Gt,bq as Bt}from"./index-DZOZ1xN3.js";function $t(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function Ht(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function Wt(e){return e/100*window.innerHeight}function Ut(e){return e/100*window.innerWidth}function Vt(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[r,i]=Vt(n);switch(i){case"%":{o=r/100*e;break}case"px":{o=r;break}case"rem":{o=Ht(t,r);break}case"em":{o=$t(t,r);break}case"vh":{o=Wt(r);break}case"vw":{o=Ut(r);break}}return o}function O(e){return parseFloat(e.toFixed(3))}function fe({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,r)=>(o+=t==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o),0)}function Re(e){const{panels:t}=e,n=fe({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:r,panelConstraints:i}=o;let u=0;if(i.collapsedSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.collapsedSize});u=O(c/n*100)}let a;if(i.defaultSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.defaultSize});a=O(c/n*100)}let s=0;if(i.minSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.minSize});s=O(c/n*100)}let l=100;if(i.maxSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.maxSize});l=O(c/n*100)}return{groupResizeBehavior:i.groupResizeBehavior,collapsedSize:u,collapsible:i.collapsible===!0,defaultSize:a,disabled:i.disabled,minSize:s,maxSize:l,panelId:o.id}})}function M(e,t="Assertion error"){if(!e)throw Error(t)}function Ee(e,t){return Array.from(t).sort(e==="horizontal"?qt:Yt)}function qt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function Yt(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function ut(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ct(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 _t({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let r,i=Number.MAX_VALUE;for(const u of t){const{x:a,y:s}=ct(o,u),l=e==="horizontal"?a:s;l<i&&(i=l,r=u)}return M(r,"No rect found"),r}let ye;function Xt(){return ye===void 0&&(typeof matchMedia=="function"?ye=!!matchMedia("(pointer:coarse)").matches:ye=!1),ye}function dt(e){const{element:t,orientation:n,panels:o,separators:r}=e,i=Ee(n,Array.from(t.children).filter(ut).map(v=>({element:v}))).map(({element:v})=>v),u=[];let a=!1,s=!1,l=-1,c=-1,h=0,p,z=[];{let v=-1;for(const d of i)d.hasAttribute("data-panel")&&(v++,d.hasAttribute("data-disabled")||(h++,l===-1&&(l=v),c=v))}if(h>1){let v=-1;for(const d of i)if(d.hasAttribute("data-panel")){v++;const g=o.find(f=>f.element===d);if(g){if(p){const f=p.element.getBoundingClientRect(),b=d.getBoundingClientRect();let y;if(s){const S=n==="horizontal"?new DOMRect(f.right,f.top,0,f.height):new DOMRect(f.left,f.bottom,f.width,0),m=n==="horizontal"?new DOMRect(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(z.length){case 0:{y=[S,m];break}case 1:{const E=z[0],k=_t({orientation:n,rects:[f,b],targetRect:E.element.getBoundingClientRect()});y=[E,k===f?m:S];break}default:{y=z;break}}}else z.length?y=z:y=[n==="horizontal"?new DOMRect(f.right,b.top,b.left-f.right,b.height):new DOMRect(b.left,f.bottom,b.width,b.top-f.bottom)];for(const S of y){let m="width"in S?S:S.element.getBoundingClientRect();const E=Xt()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(m.width<E){const D=E-m.width;m=new DOMRect(m.x-D/2,m.y,m.width+D,m.height)}if(m.height<E){const D=E-m.height;m=new DOMRect(m.x,m.y-D/2,m.width,m.height+D)}const k=v<=l||v>c;!a&&!k&&u.push({group:e,groupSize:fe({group:e}),panels:[p,g],separator:"width"in S?void 0:S,rect:m}),a=!1}}s=!1,p=g,z=[]}}else if(d.hasAttribute("data-separator")){d.ariaDisabled!==null&&(a=!0);const g=r.find(f=>f.element===d);g?z.push(g):(p=void 0,z=[])}else s=!0}return u}var K;class ft{constructor(){We(this,K,{})}addListener(t,n){const o=ge(this,K)[t];return o===void 0?ge(this,K)[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=ge(this,K)[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let r=!1,i=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const s=u[a];try{s.call(null,n)}catch(l){i===null&&(r=!0,i=l)}}if(r)throw i}}removeAllListeners(){Ue(this,K,{})}removeListener(t,n){const o=ge(this,K)[t];if(o!==void 0){const r=o.indexOf(n);r>=0&&o.splice(r,1)}}}K=new WeakMap;let ce={cursorFlags:0,state:"inactive"};const ke=new ft;function te(){return ce}function Jt(e){return ke.addListener("change",e)}function Kt(e){const t=ce,n={...ce};n.cursorFlags=e,ce=n,ke.emit("change",{prev:t,next:n})}function de(e){const t=ce;ce=e,ke.emit("change",{prev:t,next:e})}const Zt=e=>e,Le=()=>{},pt=1,ht=2,gt=4,mt=8,qe=3,Ye=12;let Se;function _e(){return Se===void 0&&(Se=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Se=!0)),Se}function Qt({cursorFlags:e,groups:t,state:n}){let o=0,r=0;switch(n){case"active":case"hover":t.forEach(i=>{if(!i.mutableState.disableCursor)switch(i.orientation){case"horizontal":{o++;break}case"vertical":{r++;break}}})}if(!(o===0&&r===0)){switch(n){case"active":{if(e&&_e()){const i=(e&pt)!==0,u=(e&ht)!==0,a=(e&gt)!==0,s=(e&mt)!==0;if(i)return a?"se-resize":s?"ne-resize":"e-resize";if(u)return a?"sw-resize":s?"nw-resize":"w-resize";if(a)return"s-resize";if(s)return"n-resize"}break}}return _e()?o>0&&r>0?"move":o>0?"ew-resize":"ns-resize":o>0&&r>0?"grab":o>0?"col-resize":"row-resize"}}const Xe=new WeakMap;function Ie(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=Xe.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=te();switch(o.state){case"active":case"hover":{const r=Qt({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),i=`*, *:hover {cursor: ${r} !important; }`;if(t===i)return;t=i,r?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Xe.set(e,{prevStyle:t,styleSheet:n})}let V=new Map;const vt=new ft;function en(e){V=new Map(V),V.delete(e)}function Je(e,t){for(const[n]of V)if(n.id===e)return n}function Z(e,t){for(const[n,o]of V)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Q(){return V}function De(e,t){return vt.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function q(e,t,n){const o=V.get(e);V=new Map(V),V.set(e,t),vt.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:o,next:t})}function bt(e){const t=te(),n=Q();let o=!1;switch(t.state){case"active":de({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Ie(e),o=!0,t.hitRegions.forEach(r=>{if(!n.has(r.group))return;const i=Z(r.group.id,!0);q(r.group,i,{isUserInteraction:!0})}))}return o}function Ke(e){e.defaultPrevented||bt(e.currentTarget)}function tn(e,t,n){let o,r={x:1/0,y:1/0};for(const i of t){const u=ct(n,i.rect);switch(e){case"horizontal":{u.x<=r.x&&(o=i,r=u);break}case"vertical":{u.y<=r.y&&(o=i,r=u);break}}}return o?{distance:r,hitRegion:o}:void 0}function nn(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function on(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:et(e),b:et(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();M(o,"Stacking order can only be calculated for elements with a common ancestor");const r={a:Qe(Ze(n.a)),b:Qe(Ze(n.b))};if(r.a===r.b){const i=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=i.length;for(;a--;){const s=i[a];if(s===u.a)return 1;if(s===u.b)return-1}}return Math.sign(r.a-r.b)}const rn=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function sn(e){const t=getComputedStyle(yt(e)??e).display;return t==="flex"||t==="inline-flex"}function an(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||sn(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"||rn.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ze(e){let t=e.length;for(;t--;){const n=e[t];if(M(n,"Missing node"),an(n))return n}return null}function Qe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function et(e){const t=[];for(;e;)t.push(e),e=yt(e);return t}function yt(e){const{parentNode:t}=e;return nn(t)?t.host:t}function ln(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 un({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ut(n)||n.contains(e)||e.contains(n))return!0;if(on(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(ln(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function Te(e,t){const n=[];return t.forEach((o,r)=>{if(r.disabled)return;const i=dt(r),u=tn(r.orientation,i,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&un({groupElement:r.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function cn(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 F(e,t,n=0){return Math.abs(O(e)-O(t))<=n}function U(e,t){return F(e,t)?0:e>t?1:-1}function ue({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:r=0,collapsible:i,disabled:u,maxSize:a=100,minSize:s=0}=t;if(u&&!e)return n;if(U(o,s)<0)if(i){const l=(r+s)/2;U(o,l)<0?o=r:o=s}else o=s;return o=Math.min(a,o),o=O(o),o}function be({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:r,trigger:i}){if(F(e,0))return t;const u=i==="imperative-api",a=Object.values(t),s=Object.values(r),l=[...a],[c,h]=o;M(c!=null,"Invalid first pivot index"),M(h!=null,"Invalid second pivot index");let p=0;switch(i){case"keyboard":{{const d=e<0?h:c,g=n[d];M(g,`Panel constraints not found for index ${d}`);const{collapsedSize:f=0,collapsible:b,minSize:y=0}=g;if(b){const S=a[d];if(M(S!=null,`Previous layout not found for panel index ${d}`),F(S,f)){const m=y-S;U(m,Math.abs(e))>0&&(e=e<0?0-m:m)}}}{const d=e<0?c:h,g=n[d];M(g,`No panel constraints found for index ${d}`);const{collapsedSize:f=0,collapsible:b,minSize:y=0}=g;if(b){const S=a[d];if(M(S!=null,`Previous layout not found for panel index ${d}`),F(S,y)){const m=S-f;U(m,Math.abs(e))>0&&(e=e<0?0-m:m)}}}break}default:{const d=e<0?h:c,g=n[d];M(g,`Panel constraints not found for index ${d}`);const f=a[d],{collapsible:b,collapsedSize:y,minSize:S}=g;if(b&&U(f,S)<0)if(e>0){const m=S-y,E=m/2,k=f+e;U(k,S)<0&&(e=U(e,E)<=0?0:m)}else{const m=S-y,E=100-m/2,k=f-e;U(k,S)<0&&(e=U(100+e,E)>0?0:-m)}break}}{const d=e<0?1:-1;let g=e<0?h:c,f=0;for(;;){const y=a[g];M(y!=null,`Previous layout not found for panel index ${g}`);const S=ue({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:y,size:100})-y;if(f+=S,g+=d,g<0||g>=n.length)break}const b=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-b:b}{let d=e<0?c:h;for(;d>=0&&d<n.length;){const g=Math.abs(e)-Math.abs(p),f=a[d];M(f!=null,`Previous layout not found for panel index ${d}`);const b=f-g,y=ue({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:f,size:b});if(!F(f,y)&&(p+=f-y,l[d]=y,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(cn(s,l))return r;{const d=e<0?h:c,g=a[d];M(g!=null,`Previous layout not found for panel index ${d}`);const f=g+p,b=ue({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:g,size:f});if(l[d]=b,!F(b,f)){let y=f-b,S=e<0?h:c;for(;S>=0&&S<n.length;){const m=l[S];M(m!=null,`Previous layout not found for panel index ${S}`);const E=m+y,k=ue({overrideDisabledPanels:u,panelConstraints:n[S],prevSize:m,size:E});if(F(m,k)||(y-=k-m,l[S]=k),F(y,0))break;e>0?S--:S++}}}const z=Object.values(l).reduce((d,g)=>g+d,0);if(!F(z,100,.1))return r;const v=Object.keys(r);return l.reduce((d,g,f)=>(d[v[f]]=g,d),{})}function ne(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||U(e[n],t[n])!==0)return!1;return!0}function oe({layout:e,panelConstraints:t}){const n=Object.values(e),o=[...n],r=o.reduce((a,s)=>a+s,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(a=>`${a}%`).join(", ")}`);if(!F(r,100)&&o.length>0)for(let a=0;a<t.length;a++){const s=o[a];M(s!=null,`No layout data found for index ${a}`);const l=100/r*s;o[a]=l}let i=0;for(let a=0;a<t.length;a++){const s=n[a];M(s!=null,`No layout data found for index ${a}`);const l=o[a];M(l!=null,`No layout data found for index ${a}`);const c=ue({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:s,size:l});l!=c&&(i+=l-c,o[a]=c)}if(!F(i,0))for(let a=0;a<t.length;a++){const s=o[a];M(s!=null,`No layout data found for index ${a}`);const l=s+i,c=ue({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:s,size:l});if(s!==c&&(i-=c-s,o[a]=c,F(i,0)))break}const u=Object.keys(e);return o.reduce((a,s,l)=>(a[u[l]]=s,a),{})}function St({groupId:e,panelId:t}){const n=()=>{const s=Q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:h,layout:p,groupSize:z,separatorToPanels:v}]of s)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:h,group:l,groupSize:z,layout:p,separatorToPanels:v};throw Error(`Group ${e} not found`)},o=()=>{const s=n().derivedPanelConstraints.find(l=>l.panelId===t);if(s!==void 0)return s;throw Error(`Panel constraints not found for Panel ${t}`)},r=()=>{const s=n().group.panels.find(l=>l.id===t);if(s!==void 0)return s;throw Error(`Layout not found for Panel ${t}`)},i=()=>{const s=n().layout[t];if(s!==void 0)return s;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:s,panels:l,prevLayout:c,derivedPanelConstraints:h})=>{const p=i(),z=l.findIndex(g=>g.id===t),v=z===0,d=z===l.length-1;if(d&&s<p&&(v||l.slice(0,z).every((g,f)=>{const b=h[f];return(b==null?void 0:b.collapsible)&&F(b.collapsedSize,c[b.panelId])}))){const g=l.slice(0,z).reduce((f,b)=>f+c[b.id],0);return{...c,[t]:O(100-g)}}return be({delta:d?p-s:s-p,initialLayout:c,panelConstraints:h,pivotIndices:d?[z-1,z]:[z,z+1],prevLayout:c,trigger:"imperative-api"})},a=s=>{const l=i();if(s===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:h,group:p,groupSize:z,layout:v,separatorToPanels:d}=n(),g=u({nextSize:s,panels:p.panels,prevLayout:v,derivedPanelConstraints:h}),f=oe({layout:g,panelConstraints:h});ne(v,f)||q(p,{defaultLayoutDeferred:c,derivedPanelConstraints:h,groupSize:z,layout:f,separatorToPanels:d})};return{collapse:()=>{const{collapsible:s,collapsedSize:l}=o(),{mutableValues:c}=r(),h=i();s&&h!==l&&(c.expandToSize=h,a(l))},expand:()=>{const{collapsible:s,collapsedSize:l,minSize:c}=o(),{mutableValues:h}=r(),p=i();if(s&&p===l){let z=h.expandToSize??c;z===0&&(z=1),a(z)}},getSize:()=>{const{group:s}=n(),l=i(),{element:c}=r(),h=s.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:h}},isCollapsed:()=>{const{collapsible:s,collapsedSize:l}=o(),c=i();return s&&F(l,c)},resize:s=>{const{group:l}=n(),{element:c}=r(),h=fe({group:l}),p=me({groupSize:h,panelElement:c,styleProp:s}),z=O(p/h*100);a(z)}}}function tt(e){if(e.defaultPrevented)return;const t=Q();Te(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const o=n.panels.find(r=>r.panelConstraints.defaultSize!==void 0);if(o){const r=o.panelConstraints.defaultSize,i=St({groupId:n.group.id,panelId:o.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function xe(e){const t=Q();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 xt({groupId:e}){const t=()=>{const n=Q();for(const[o,r]of n)if(o.id===e)return{group:o,...r};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:r,group:i,groupSize:u,layout:a,separatorToPanels:s}=t(),l=oe({layout:n,panelConstraints:r});return o?a:(ne(a,l)||q(i,{defaultLayoutDeferred:o,derivedPanelConstraints:r,groupSize:u,layout:l,separatorToPanels:s}),l)}}}function ee(e,t){const n=xe(e),o=Z(n.id,!0),r=n.separators.find(c=>c.element===e);M(r,"Matching separator not found");const i=o.separatorToPanels.get(r);M(i,"Matching panels not found");const u=i.map(c=>n.panels.indexOf(c)),a=xt({groupId:n.id}).getLayout(),s=be({delta:t,initialLayout:a,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:a,trigger:"keyboard"}),l=oe({layout:s,panelConstraints:o.derivedPanelConstraints});ne(a,l)||q(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:l,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function nt(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=xe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&ee(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&ee(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&ee(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&ee(t,-5);break}case"End":{e.preventDefault(),ee(t,100);break}case"Enter":{e.preventDefault();const o=xe(t),r=Z(o.id,!0),{derivedPanelConstraints:i,layout:u,separatorToPanels:a}=r,s=o.separators.find(p=>p.element===t);M(s,"Matching separator not found");const l=a.get(s);M(l,"Matching panels not found");const c=l[0],h=i.find(p=>p.panelId===c.id);if(M(h,"Panel metadata not found"),h.collapsible){const p=u[c.id],z=h.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??h.minSize:h.collapsedSize;ee(t,z-p)}break}case"F6":{e.preventDefault();const o=xe(t).separators.map(u=>u.element),r=Array.from(o).findIndex(u=>u===e.currentTarget);M(r!==null,"Index not found");const i=e.shiftKey?r>0?r-1:o.length-1:r+1<o.length?r+1:0;o[i].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),ee(t,-100);break}}}function ot(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Q(),n=Te(e,t),o=new Map;let r=!1;n.forEach(i=>{i.separator&&(r||(r=!0,i.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(i.group);u&&o.set(i.group,u.layout)}),de({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function zt({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:r,pointerDownAtPoint:i,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:h}=l,{orientation:p,panels:z}=c,{disableCursor:v}=c.mutableState;let d=0;i?p==="horizontal"?d=(t.clientX-i.x)/h*100:d=(t.clientY-i.y)/h*100:p==="horizontal"?d=t.clientX<0?-100:100:d=t.clientY<0?-100:100;const g=o.get(c),f=r.get(c);if(!g||!f)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:y,groupSize:S,layout:m,separatorToPanels:E}=f;if(y&&m&&E){const k=be({delta:d,initialLayout:g,panelConstraints:y,pivotIndices:l.panels.map(D=>z.indexOf(D)),prevLayout:m,trigger:"mouse-or-touch"});if(ne(k,m)){if(d!==0&&!v)switch(p){case"horizontal":{a|=d<0?pt:ht;break}case"vertical":{a|=d<0?gt:mt;break}}}else q(l.group,{defaultLayoutDeferred:b,derivedPanelConstraints:y,groupSize:S,layout:k,separatorToPanels:E})}});let s=0;t.movementX===0?s|=u&qe:s|=a&qe,t.movementY===0?s|=u&Ye:s|=a&Ye,Kt(s),Ie(e)}function rt(e){const t=Q(),n=te();switch(n.state){case"active":zt({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function st(e){var o,r;if(e.defaultPrevented)return;const t=te(),n=Q();switch(t.state){case"active":{if(e.buttons===0){de({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{if(!n.has(i.group))return;const u=Z(i.group.id,!0);q(i.group,u,{isUserInteraction:!0})});return}for(const i of t.hitRegions)if(i.separator){const{element:u}=i.separator;(o=u.hasPointerCapture)!=null&&o.call(u,e.pointerId)||((r=u.setPointerCapture)==null||r.call(u,e.pointerId))}zt({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=Te(e,n);i.length===0?t.state!=="inactive"&&de({cursorFlags:0,state:"inactive"}):de({cursorFlags:0,hitRegions:i,state:"hover"}),Ie(e.currentTarget);break}}}function it(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(te().state){case"hover":de({cursorFlags:0,state:"inactive"})}}function at(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||bt(e.currentTarget)&&e.preventDefault()}function lt(e){let t=0,n=0;const o={};for(const i of e)if(i.defaultSize!==void 0){t++;const u=O(i.defaultSize);n+=u,o[i.panelId]=u}else o[i.panelId]=void 0;const r=e.length-t;if(r!==0){const i=O((100-n)/r);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=i)}return o}function dn(e,t,n){if(!n[0])return;const o=e.panels.find(s=>s.element===t);if(!o||!o.onResize)return;const r=fe({group:e}),i=e.orientation==="horizontal"?o.element.offsetWidth:o.element.offsetHeight,u=o.mutableValues.prevSize,a={asPercentage:O(i/r*100),inPixels:i};o.mutableValues.prevSize=a,o.onResize(a,o.id,u)}function fn(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)=>fn(n,t[o]))}function hn({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let r=0,i=0,u=!1;const a=new Map,s=[];for(const h of e.panels){const p=o[h.id]??0;switch(h.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const z=p/100*n,v=O(z/t*100);a.set(h.id,v),r+=v;break}case"preserve-relative-size":default:{s.push(h.id),i+=p;break}}}if(!u||s.length===0)return o;const l=100-r,c={...o};if(a.forEach((h,p)=>{c[p]=h}),i>0)for(const h of s){const p=o[h]??0;c[h]=O(p/i*l)}else{const h=O(l/s.length);for(const p of s)c[p]=h}return c}function gn(e,t){const n=e.map(r=>r.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const r of n)if(!o.includes(r))return!1;return!0}const le=new Map;function mn(e){let t=!0;M(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,r=new Set,i=new n(v=>{for(const d of v){const{borderBoxSize:g,target:f}=d;if(f===e.element){if(t){const b=fe({group:e});if(b===0)return;const y=Z(e.id);if(!y)return;const S=Re(e),m=y.defaultLayoutDeferred?lt(S):y.layout,E=hn({group:e,nextGroupSize:b,prevGroupSize:y.groupSize,prevLayout:m}),k=oe({layout:E,panelConstraints:S});if(!y.defaultLayoutDeferred&&ne(y.layout,k)&&pn(y.derivedPanelConstraints,S)&&y.groupSize===b)continue;q(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:b,layout:k,separatorToPanels:y.separatorToPanels})}}else dn(e,f,g)}});i.observe(e.element),e.panels.forEach(v=>{M(!o.has(v.id),`Panel ids must be unique; id "${v.id}" was used more than once`),o.add(v.id),v.onResize&&i.observe(v.element)});const u=fe({group:e}),a=Re(e),s=e.panels.map(({id:v})=>v).join(",");let l=e.mutableState.defaultLayout;l&&(gn(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[s]??l??lt(a),h=oe({layout:c,panelConstraints:a}),p=e.element.ownerDocument;le.set(p,(le.get(p)??0)+1);const z=new Map;return dt(e).forEach(v=>{v.separator&&z.set(v.separator,v.panels)}),q(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:h,separatorToPanels:z}),e.separators.forEach(v=>{M(!r.has(v.id),`Separator ids must be unique; id "${v.id}" was used more than once`),r.add(v.id),v.element.addEventListener("keydown",nt)}),le.get(p)===1&&(p.addEventListener("contextmenu",Ke,!0),p.addEventListener("dblclick",tt,!0),p.addEventListener("pointerdown",ot,!0),p.addEventListener("pointerleave",rt),p.addEventListener("pointermove",st),p.addEventListener("pointerout",it),p.addEventListener("pointerup",at,!0)),function(){t=!1,le.set(p,Math.max(0,(le.get(p)??0)-1)),en(e),e.separators.forEach(v=>{v.element.removeEventListener("keydown",nt)}),le.get(p)||(p.removeEventListener("contextmenu",Ke,!0),p.removeEventListener("dblclick",tt,!0),p.removeEventListener("pointerdown",ot,!0),p.removeEventListener("pointerleave",rt),p.removeEventListener("pointermove",st),p.removeEventListener("pointerout",it),p.removeEventListener("pointerup",at,!0)),i.disconnect()}}function vn(){const[e,t]=x.useState({}),n=x.useCallback(()=>t({}),[]);return[e,n]}function Ne(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 je(...e){return ve(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Ae(e){const t=x.useRef({...e});return re(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const wt=x.createContext(null);function bn(e,t){const n=x.useRef({getLayout:()=>({}),setLayout:Zt});x.useImperativeHandle(t,()=>n.current,[]),re(()=>{Object.assign(n.current,xt({groupId:e}))})}function Ct({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:r,elementRef:i,groupRef:u,id:a,onLayoutChange:s,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:h={coarse:20,fine:10},style:p,...z}){const v=x.useRef({onLayoutChange:{},onLayoutChanged:{}}),d=ve(w=>{ne(v.current.onLayoutChange,w)||(v.current.onLayoutChange=w,s==null||s(w))}),g=ve((w,C)=>{ne(v.current.onLayoutChanged,w)||(v.current.onLayoutChanged=w,l==null||l(w,{isUserInteraction:C}))}),f=Ne(a),b=x.useRef(null),[y,S]=vn(),m=x.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:h,separators:[]}),E=je(b,i);bn(f,u);const k=ve((w,C)=>{const I=te(),R=Je(w),T=Z(w);if(T){let B=!1;switch(I.state){case"active":{B=I.hitRegions.some(Y=>Y.group===R);break}}return{flexGrow:T.layout[C]??1,pointerEvents:B?"none":void 0}}if(n!=null&&n[C])return{flexGrow:n==null?void 0:n[C]}}),D=Ae({defaultLayout:n,disableCursor:o}),G=x.useMemo(()=>({get disableCursor(){return!!D.disableCursor},getPanelStyles:k,id:f,orientation:c,registerPanel:w=>{const C=m.current;return C.panels=Ee(c,[...C.panels,w]),S(),()=>{C.panels=C.panels.filter(I=>I!==w),S()}},registerSeparator:w=>{const C=m.current;return C.separators=Ee(c,[...C.separators,w]),S(),()=>{C.separators=C.separators.filter(I=>I!==w),S()}},updatePanelProps:(w,{disabled:C})=>{const I=m.current.panels.find(B=>B.id===w);I&&(I.panelConstraints.disabled=C);const R=Je(f),T=Z(f);R&&T&&q(R,{...T,derivedPanelConstraints:Re(R)})},updateSeparatorProps:(w,{disabled:C,disableDoubleClick:I})=>{const R=m.current.separators.find(T=>T.id===w);R&&(R.disabled=C,R.disableDoubleClick=I)}}),[k,f,S,c,D]),W=x.useRef(null);return re(()=>{const w=b.current;if(w===null)return;const C=m.current;let I;if(D.defaultLayout!==void 0&&Object.keys(D.defaultLayout).length===C.panels.length){I={};for(const $ of C.panels){const X=D.defaultLayout[$.id];X!==void 0&&(I[$.id]=X)}}const R={disabled:!!r,element:w,id:f,mutableState:{defaultLayout:I,disableCursor:!!D.disableCursor,expandedPanelSizes:m.current.lastExpandedPanelSizes,layouts:m.current.layouts},orientation:c,panels:C.panels,resizeTargetMinimumSize:C.resizeTargetMinimumSize,separators:C.separators};W.current=R;const T=mn(R),{defaultLayoutDeferred:B,derivedPanelConstraints:Y,layout:_}=Z(R.id,!0);!B&&Y.length>0&&(d(_),g(_,!1));const N=De(f,$=>{const{defaultLayoutDeferred:X,derivedPanelConstraints:se,layout:ie}=$.next;if(X||se.length===0)return;const pe=R.panels.map(({id:H})=>H).join(",");R.mutableState.layouts[pe]=ie,se.forEach(H=>{if(H.collapsible){const{layout:he}=$.prev??{};if(he){const ze=F(H.collapsedSize,ie[H.panelId]),j=F(H.collapsedSize,he[H.panelId]);ze&&!j&&(R.mutableState.expandedPanelSizes[H.panelId]=he[H.panelId])}}});const ae=te().state!=="active";d(ie),ae&&g(ie,$.isUserInteraction)});return()=>{W.current=null,T(),N()}},[r,f,g,d,c,y,D]),x.useEffect(()=>{const w=W.current;w&&(w.mutableState.defaultLayout=n,w.mutableState.disableCursor=!!o)}),P.jsx(wt.Provider,{value:G,children:P.jsx("div",{...z,className:t,"data-group":!0,"data-testid":f,id:f,ref:E,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}Ct.displayName="Group";function Fe(){const e=x.useContext(wt);return M(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function yn(e,t){const{id:n}=Fe(),o=x.useRef({collapse:Le,expand:Le,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Le});x.useImperativeHandle(t,()=>o.current,[]),re(()=>{Object.assign(o.current,St({groupId:n,panelId:e}))})}function Me({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:r,disabled:i,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:s,maxSize:l="100%",minSize:c="0%",onResize:h,panelRef:p,style:z,...v}){const d=!!s,g=Ne(s),f=Ae({disabled:i}),b=x.useRef(null),y=je(b,u),{getPanelStyles:S,id:m,orientation:E,registerPanel:k,updatePanelProps:D}=Fe(),G=h!==null,W=ve((R,T,B)=>{h==null||h(R,s,B)});re(()=>{const R=b.current;if(R!==null){const T={element:R,id:g,idIsStable:d,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?W:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:r,disabled:f.disabled,maxSize:l,minSize:c}};return k(T)}},[a,n,o,r,G,g,d,l,c,W,k,f]),x.useEffect(()=>{D(g,{disabled:i})},[i,g,D]),yn(g,p);const w=()=>{const R=S(m,g);if(R)return JSON.stringify(R)},C=x.useSyncExternalStore(R=>De(m,R),w,w);let I;return C?I=JSON.parse(C):r!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:r}:I={flexGrow:1},P.jsx("div",{...v,"data-disabled":i||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Sn,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:P.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...z,touchAction:E==="horizontal"?"pan-y":"pan-x"},children:e})})}Me.displayName="Panel";const Sn={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function xn({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let r,i;const u=e[n],a=t.find(s=>s.panelId===n);if(a){const s=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];i=oe({layout:be({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],r=oe({layout:be({delta:s-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:r,valueMin:i,valueNow:u}}function Lt({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:r,id:i,style:u,...a}){const s=Ne(i),l=Ae({disabled:n,disableDoubleClick:o}),[c,h]=x.useState({}),[p,z]=x.useState("inactive"),[v,d]=x.useState(!1),g=x.useRef(null),f=je(g,r),{disableCursor:b,id:y,orientation:S,registerSeparator:m,updateSeparatorProps:E}=Fe(),k=S==="horizontal"?"vertical":"horizontal";re(()=>{const W=g.current;if(W!==null){const w={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:W,id:s},C=m(w),I=Jt(T=>{z(T.next.state!=="inactive"&&T.next.hitRegions.some(B=>B.separator===w)?T.next.state:"inactive")}),R=De(y,T=>{const{derivedPanelConstraints:B,layout:Y,separatorToPanels:_}=T.next,N=_.get(w);if(N){const $=N[0],X=N.indexOf($);h(xn({layout:Y,panelConstraints:B,panelId:$.id,panelIndex:X}))}});return()=>{I(),R(),C()}}},[y,s,m,l]),x.useEffect(()=>{E(s,{disabled:n,disableDoubleClick:o})},[n,o,s,E]);let D;n&&!b&&(D="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:v?G="focus":G=p}return P.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":k,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":s,id:s,onBlur:()=>d(!1),onFocus:()=>d(!0),ref:f,role:"separator",style:{flexBasis:"auto",cursor:D,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Lt.displayName="Separator";async function zn({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 wn="96px";function Pe(e){var n;const t=(n=e.title)==null?void 0:n.trim();return t!=null&&t.length>0?t:"Untitled session"}function Cn(e){return"isMutable"in e&&typeof Reflect.get(e,"isMutable")=="boolean"?Reflect.get(e,"isMutable")===!0:e.agentName==null}function Ln(e){return"sourceType"in e&&Reflect.get(e,"sourceType")==="schedule"?"schedule":void 0}function Mn({agentId:e,startTimestamp:t,endTimestamp:n,shareView:o}){const r=It(),i=Dt(),u=Tt(),a=Nt(),{sessionId:s,updateShareSearch:l}=jt(),{allows:c}=At({resourceType:"session",resourceIds:s==null?[]:[s]}),h=c(s,"MANAGE"),p=we("AgentSessionListRow"),z=we("AgentSessionDetailHeader"),v=we("AgentSessionTimelineContainer"),[d,g]=x.useState([]),[f,b]=x.useState(),[y,S]=x.useState(!0),[m,E]=x.useState(!1),[k,D]=x.useState(!1),[G,W]=x.useState(!1),w=x.useRef(0),C=x.useRef(!1),[I,R]=x.useState(null),[T,B]=x.useState(null),[Y,_]=x.useState(),[N,$]=x.useState(),[X,se]=x.useState(!1),[ie,pe]=x.useState(!1),ae=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 L=++w.current;let A=!1;return C.current=!1,b(void 0),S(!0),E(!1),D(!1),W(!1),r.listSessions(ae).then(J=>{A||w.current!==L||(g(J.data),b(J.nextPageToken))}).catch(()=>{A||w.current!==L||(g([]),b(void 0),W(!0))}).finally(()=>{!A&&w.current===L&&S(!1)}),()=>{A=!0}},[ae,r]);const H=x.useCallback(async()=>{if(y||f==null||C.current)return;const L=w.current;C.current=!0,E(!0),D(!1);try{const A=await r.listSessions({...ae,pageToken:f});if(w.current!==L)return;g(J=>[...J,...A.data]),b(A.nextPageToken)}catch{w.current===L&&D(!0)}finally{w.current===L&&(C.current=!1,E(!1))}},[y,ae,f,r]);x.useEffect(()=>{if(y||f==null||I==null||T==null)return;const L=new IntersectionObserver(A=>{A.some(J=>J.isIntersecting)&&H()},{root:I,rootMargin:wn});return L.observe(T),()=>L.disconnect()},[d.length,I,y,H,f,T]),x.useEffect(()=>{if(s==null||s.length===0){_(void 0),$(void 0),pe(!1),se(!1);return}let L=!1;return se(!0),pe(!1),_(void 0),$(void 0),Promise.all([zn({fetchPage:A=>r.listSessionEvents({sessionId:s,limit:100,...A==null?{}:{pageToken:A}})}),i.getSession({sessionId:s}).catch(()=>{})]).then(([A,J])=>{L||(_([...A].reverse()),$(J))}).catch(()=>{L||pe(!0)}).finally(()=>{L||se(!1)}),()=>{L=!0}},[i,s,r]);const he=L=>{const A=o==="sessions"?Bt(L.createdAt):null;l({sessionId:L.id,...o==="sessions"?{view:"sessions",...A==null?{}:{timeRange:A}}:{agentId:e??null,tab:"sessions",view:null,timeRange:null}})},ze=()=>{s!=null&&l({sessionId:null})},j=d.find(L=>L.id===s),Pt=N!=null?Pe(N):j!=null?Pe(j):s??"Untitled session",Oe=N!=null?Ve(N):j!=null?Ve(j):!1,Rt=N!=null?N.isMutable:j!=null?Cn(j):!0,Ge=Oe?"Resume Agent building":"Resume Chat",Be=s!=null&&a!=null?kt({sessionId:s,routes:a}):null,Et=()=>{if(!h||s==null||u==null)return;const L=(N==null?void 0:N.agentName)??(j==null?void 0:j.agentName);u.openHistorySession({sessionId:s,isMutable:Rt,isCreateAgent:Oe,...L!=null&&L.length>0?{agentName:L}:{}})},Mt=Be!=null?{resumeHref:Be,resumeLabel:Ge}:u!=null?{onResume:Et,resumeLabel:Ge}:{};return!y&&!G&&d.length===0&&(s==null||s.length===0)?P.jsx(Ft,{title:"No Sessions Found",description:"There are no sessions available at the moment.",className:"bg-primary-bg"}):P.jsxs(Ct,{id:"agent-sessions-split",orientation:"horizontal",className:"h-full min-h-0 w-full",resizeTargetMinimumSize:{coarse:24,fine:11},children:[P.jsx(Me,{id:"agent-sessions-list",defaultSize:"35%",minSize:"20%",maxSize:"50%",children:P.jsx("aside",{className:"flex h-full min-h-0 w-full flex-col bg-sidebar-bg",children:P.jsxs("div",{ref:R,className:"scrollbar-none min-h-0 flex-1 overflow-y-auto",children:[y?P.jsx("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading sessions",children:["a","b","c"].map(L=>P.jsx(Ce,{className:"h-16 rounded-md"},L))}):G?P.jsx("p",{className:"px-3 py-6 text-center text-xs text-text-secondary",children:"Sessions could not be loaded."}):d.map(L=>P.jsx(p,{title:Pe(L),agentName:L.agentName??void 0,sourceType:Ln(L),lastActivityAt:L.lastActivityAt,metrics:L.metrics,active:L.id===s,onSelect:()=>he(L)},L.id)),f!=null&&!y&&!G?P.jsx("div",{ref:B,className:"px-3 py-2",children:m?P.jsx(Ce,{className:"h-16 rounded-md",role:"status","aria-label":"Loading more sessions"}):k?P.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 H(),children:"Retry loading sessions"}):null}):null]})})}),P.jsxs(Lt,{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:[P.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 -left-1.25 w-2.75"}),P.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-px bg-border transition-colors"}),P.jsx("div",{"aria-hidden":!0,className:Gt("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:P.jsx(Ot,{name:"grip-vertical",size:10})})]}),P.jsx(Me,{id:"agent-session-detail",defaultSize:"65%",minSize:"30%",children:P.jsx("section",{className:"flex h-full min-w-0 flex-col bg-primary-bg",children:s==null?P.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Select a session to view details"}):ie?P.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session details could not be loaded."}):P.jsxs(P.Fragment,{children:[P.jsx(z,{title:Pt,sessionId:s,agentId:e,createdAt:(N==null?void 0:N.createdAt)??(j==null?void 0:j.createdAt),view:o,onClose:ze,canResume:h,...Mt}),X||Y===void 0?P.jsx("div",{className:"flex flex-1 flex-col p-4",role:"status","aria-label":"Loading session details",children:P.jsx(Ce,{className:"min-h-64 flex-1 rounded-lg"})}):P.jsx(v,{sessionId:s,events:Y,listMetrics:j==null?void 0:j.metrics})]})})})]})}export{Mn as AgentSessions};
@@ -0,0 +1 @@
1
+ import{aF as ee,D as ce,r as a,aG as _,j as e,J as me,L as z,I as w,aI as te,ab as U,aM as ue,e as T,aH as X}from"./index-DZOZ1xN3.js";var xe=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],J=U("h-11 shadow-sm"),B=()=>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,k]=a.useState("dcr"),[C,M]=a.useState(""),[A,S]=a.useState(""),u=r!==void 0,d=U(`h-11 shadow-sm ${u?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{y(""),g(""),m(""),k("dcr"),M(""),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)??""),k((r==null?void 0:r.auth.type)??"dcr"),M(""),S((r==null?void 0:r.auth.type)==="header"?r.auth.headerName??"":""))},[r,n]);const D=l=>{l||i(),p(l)},I=!!C.trim()||(r==null?void 0:r.auth.type)==="header",F=!!b.trim()&&!!N.trim()&&!!j.trim()&&(o!=="header"||I),P=async l=>{if(l.preventDefault(),!F||f)return;const O=o==="header"?{type:"header",apiKey:C.trim(),...A.trim()?{headerName:A.trim()}:{}}:{type:o};try{await h({name:b.trim(),url:j.trim(),description:N.trim(),auth:O}),i(),p(!1)}catch{}};return e.jsx(te,{open:n,onOpenChange:D,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(B,{})]}),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(B,{})]}),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:U("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(B,{})]}),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:J})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(B,{})]}),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:()=>{k(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(B,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:(r==null?void 0:r.auth.type)!=="header",value:C,onChange:l=>{M(l.target.value)},placeholder:"Paste the server token",className:J})]}),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:A,onChange:l=>{S(l.target.value)},placeholder:"Authorization",className:J})]})]}):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:!F||f,className:"w-full shrink-0",children:u?"Save":"Add"})]})]})})},Z=he,K={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),[k,C]=a.useState(null),[M,A]=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(_(i,"Failed to load connector tools"))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[n.authenticated,n.id,b]);const S=async()=>{A(!0),C(null);try{const d=await b.getConnector({id:n.id});h(d)}catch(d){C(_(d,"Failed to refresh connector details"))}finally{A(!1)}},u=j||M;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:K[n.auth.type]??K.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…"}):k?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:[k,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,k]=a.useState(!1),[C,M]=a.useState([]),[A,S]=a.useState(!1),[u,d]=a.useState(null),[i,D]=a.useState(null),[I,F]=a.useState(null),[P,l]=a.useState(""),O=a.useMemo(()=>(C??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[C]),Q=a.useCallback(async()=>{y(!0),g(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);M(s);const c=t??[],E=new Set(c.map(x=>x.id)),W=[...c.map(x=>({connector:x,isConfigured:!0})),...s.filter(x=>!E.has(x.id)).map(x=>({connector:x,isConfigured:!1}))];v({ordered:W,authStatusById:new Map(W.map(x=>[x.connector.id,x.isConfigured?x.connector.authenticated:!1]))}),F(x=>x?t.find(oe=>oe.id===x.id)??null:null)}catch(t){g(_(t,"Failed to load connectors"))}finally{y(!1)}},[n]);a.useEffect(()=>{Q()},[Q]);const L=h.trim().toLowerCase(),q=a.useMemo(()=>L?f.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(L)||(((s=t.description)==null?void 0:s.toLowerCase().includes(L))??!1)||t.url.toLowerCase().includes(L)}):f.ordered,[f.ordered,L]),R=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]),$=a.useMemo(()=>{const t=[];for(const s of q)s.isConfigured||t.push(s.connector);return t},[q]),H=async(t,s=g)=>{k(!0),g(null);try{await t(),await Q()}catch(c){throw s(_(c,"Request failed")),c}finally{k(!1)}},G=()=>{D(null),l(""),m(null)},V=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),D(t);return}H(async()=>{await V(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 V(s,c),G(),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}),F(null)}).catch(()=>{})},ne=t=>{F(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(E=>E.isConfigured&&E.connector.id===t.id?{connector:t,isConfigured:!0}:E),authStatusById:c}})},le=(t,s)=>{const c=O[t.name],E=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(X,{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:()=>{F(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:E}),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=O[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(X,{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:K[t.auth.type]??K.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:()=>{F(null)},onConnectorRefreshed:ne,onEdit:()=>{m(null),d(I),S(!0)},onDisconnect:()=>{re(I)}}),e.jsx(Z,{open:A,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Y,connector:u??void 0,busy:o,error:N})]});const de=R.length>0||$.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&&R.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 · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>le(t))})]}):null,!b&&$.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 · ",$.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:$.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||G()},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:`Paste the token from ${(i==null?void 0:i.name)??"the provider"}`,autoFocus:!0,required:!0,className:U("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:G,disabled:o,children:"Cancel"}),e.jsx(z.Primary,{type:"submit",disabled:!P.trim()||o,children:"Connect"})]})]})}),e.jsx(Z,{open:A,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-I3AL54MA--fCRbraS.js";import{j as o,C as t,d as l}from"./index-G4wOqi3O.js";import"./chunk-VUMGMGKZ-CUX2iOMe.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-VXKNS7FH-Dm2ZAGlE.js";import{j as o,C as t,e as l}from"./index-DZOZ1xN3.js";import"./chunk-TGKQRK3S-D5Bs7icZ.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};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-A4BPYIFZ-B4p1JpXq.js","./index-DZOZ1xN3.js","./index-BBGLYdJn.css","./SchedulesPage-ARWU7BZF-BIZcHayD.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-DZOZ1xN3.js";import{A as k,S as D,N as T,T as R}from"./chunk-TGKQRK3S-D5Bs7icZ.js";var F=a.lazy(()=>p(()=>import("./SettingsBuilder-A4BPYIFZ-B4p1JpXq.js"),__vite__mapDeps([0,1,2]),import.meta.url)),M=a.lazy(()=>p(()=>import("./SchedulesPage-ARWU7BZF-BIZcHayD.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{aF as be,D as fe,r as l,aG as Y,j as e,J as ge,L as B,I as P,aH as ie,aI as xe,aJ as ye,aK as ve,e as T,aL as je,ab as Ne}from"./index-DZOZ1xN3.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:o,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[M,I]=l.useState(""),[y,x]=l.useState(""),[w,$]=l.useState(!1),U=()=>{I(""),x(""),$(!1)};l.useEffect(()=>{n&&(I(""),x(E),$(!1))},[n,E]);const J=i=>{i||U(),o(i)},L=M.trim(),Q=!c||!!L,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:L,baseUrl:y.trim()}),U(),o(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:J,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:M,onChange:i=>{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)=>$(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(P,{name:"chevron-down",className:T("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(o=>{var b,k,p,E,d;return{id:o.id,name:o.name,advancedExpanded:!0,reasoningEfforts:(b=o.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=o.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=o.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],G="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 o=n.trim();if(o==="")return null;const b=Number(o);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}),Me=({open:n,onOpenChange:o,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=l.useState((c==null?void 0:c.name)??""),[F,M]=l.useState((c==null?void 0:c.baseUrl)??""),[I,y]=l.useState(""),[x,w]=l.useState(()=>ue(c)),[$,U]=l.useState(!1),[J,L]=l.useState(!1),Q=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),L(!1)},v=s=>{s||Q(),o(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),L(!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 X=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,W=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,le=!D&&!h&&x.every(s=>!X(s)&&!te(s)),se=$&&D,H=J&&h,A=async()=>{if(K(),!le||p)return;const s=x.findIndex(r=>q(r)||W(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:I.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-1 flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-1 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:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:T(G,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=>M(s.target.value),onBlur:()=>L(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:T(G,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:I,onChange:s=>y(s.target.value),placeholder:"sk-…",className:G}),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=X(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,oe=q(s),C=W(s),z=s.contextTouched&&oe,ae=s.maxTouched&&C;return e.jsxs("div",{className:T("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:T(G,"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:T(G,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(P,{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(P,{name:"chevron-down",className:T("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:T(G,z&&V)}),z?e.jsx(ee,{children:oe}):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:T(G,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:T("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 Z;return i(r,{reasoningEfforts:a?(Z=s.reasoningEfforts)==null?void 0:Z.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(P,{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:!le||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Le(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Te=()=>{const{modelCatalog:n}=be(),o=fe(),[b,k]=l.useState(""),[p,E]=l.useState([]),[d,c]=l.useState([]),[S,O]=l.useState(!0),[F,M]=l.useState(null),[I,y]=l.useState(null),[x,w]=l.useState(!1),[$,U]=l.useState(null),[J,L]=l.useState(null),[Q,v]=l.useState(null),[i,K]=l.useState(!1),[f,D]=l.useState(null),_=l.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),X=l.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);l.useEffect(()=>{X()},[X]);const te=l.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=l.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]),W=l.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]),le=l.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=l.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),L(null),v(null)},A=async(t,a)=>{w(!0),M(null);try{await t(),await X(),H()}catch(m){throw a?a(m):o==null?M(Y(m,"Request failed")):o.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(Y(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(Y(m,"Request failed"))),o==null||o.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(Y(a,"Request failed"))),setTimeout(()=>{o==null||o.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(Y(m,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},oe=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=$!=null?p.find(t=>t.id===$)??null:null,z=J!=null?d.find(t=>t.type===J)??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(P,{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)),Z=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(P,{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),L(null),U(t.id))},children:[e.jsx(P,{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(P,{name:"trash",className:"size-3.5"})})]},N.id)),Z.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 · ",Z.length]}),Z.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&&W.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:W.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(P,{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),U(null),L(t.type)},children:[e.jsx(P,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&W.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?Le(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:Q}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:oe,onSubmit:f?R:j,reasoningEffortOptions:le,busy:x,error:I},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Te;export{ze as default};
@@ -0,0 +1 @@
1
+ import{aF as V,D as H,r,aG as B,j as e,S as J,I as N,a7 as Y,L,aI as Q,aJ as W,aK as X,e as Z,aL as ee,ab as te}from"./index-DZOZ1xN3.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},E=te("h-11 shadow-sm");function U(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:O=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=O??se;k(String(a.execTimeoutMs)),x(String(a.autoStopIntervalInMinutes)),i(String(a.autoArchiveIntervalInMinutes)),o(String(a.autoDeleteIntervalInMinutes)),f(""),v(!1)},[s,O]);const $=a=>{a||S(),l(a)},h=U(m),A=U(u),T=U(M),F=U(p),R=b.trim(),_=(!y||!!R)&&h!=null&&A!=null&&T!=null&&F!=null,z=async a=>{if(a.preventDefault(),!(!_||w||h==null||A==null||T==null||F==null))try{await d({execTimeoutMs:h,autoStopIntervalInMinutes:A,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:F,apiKey:R}),S(),l(!1)}catch{}};return e.jsx(Q,{open:s,onOpenChange:$,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:E})]}),e.jsxs(W,{expanded:P,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(X,{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:Z("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:E})]}),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:E})]}),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:E})]}),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:E})]})]})]})]}),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(L.Primary,{type:"submit",size:"large",disabled:!_||w,className:"w-full shrink-0",children:"Save"})]})]})})},ne=ae,re=1e4,D=({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=H(),[d,g]=r.useState([]),[I,O]=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),O(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(()=>{q()},re)}async function q(){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]),$=r.useMemo(()=>o?D(o):i?D(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,...D(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,...D(t),...t.apiKey?{apiKey:t.apiKey}:{}})},u),b(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`})},0))},F=t=>{h(async()=>{await s.updateSandboxProvider({id:t.id,...D(t)})}).catch(()=>{})},R=t=>{const n=s.deleteSandboxProvider;n&&h(async()=>{await n({id:t.id})}).catch(()=>{})},_=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,q=e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-sm font-medium ${c.className}`,children:[t.snapshotSyncStatus.status==="pending"?e.jsx(J,{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:[q,j?e.jsx(Y,{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(L.Ghost,{size:"small",type:"button",disabled:x,onClick:()=>{F(n)},children:"Retry"}):null,e.jsx(L.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(null),p(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(L.Ghost,{size:"small",className:"text-text-secondary",type:"button",disabled:x,onClick:()=>{R(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(L.Secondary,{type:"button",disabled:x,onClick:()=>{u(null),b(null),p(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:_,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:$,requireApiKey:!z,busy:x,error:k})]})},de=ie;export{de as default};
@@ -0,0 +1 @@
1
+ import{A as Ne,B as Fe,D as je,r as i,E as fe,F as Te,y as ye,G as Me,q as ge,H as Qe,j as e,P as Ke,J as Ye,K as te,L as M,I as C,M as Ze,N as Ce,O as Ee,Q as Je,R as Xe,U as ze,V as J,W as et,X,Y as tt,Z as st,$ as nt,a0 as at,a1 as rt,a2 as lt,a3 as it,e as G,c as ot,a4 as ct,a5 as he,d as dt,a6 as ut,a7 as mt,a as xt,a8 as ht,a9 as ft,aa as gt,ab as Ae,i as bt,ac as pt}from"./index-DZOZ1xN3.js";var Re=[{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 Le(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Nt(t){const n=Le(),l=new Set(Re.map(o=>o.value));return[...[n,t].flatMap(o=>o==null||o.length===0||l.has(o)?[]:(l.add(o),[{value:o,label:o===n?`${o} (Local)`:o}])),...Re]}var $e=[{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"}],jt={"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 xe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Le()}}function yt(t){return jt[t]??t.split("/").pop()??t}function Oe(t){return t.toString().padStart(2,"0")}function de({hour:t,minute:n}){const l=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Oe(n)} ${l}`}function be(t){const n=t.minute,l=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(l)} * * *`;case"weekly":{const a=[...t.weekdays].sort((c,g)=>c-g),o=a.length>0?a.join(","):"*";return`${String(n)} ${String(l)} * * ${o}`}case"custom":return t.customCron.trim()}}function re(t){const n=yt(t.timezone),l=t.cron.trim().split(/\s+/);if(l.length!==5)return t.cron;const[a,o,c,g,b]=l;if(c!=="*"||g!=="*")return t.cron;const u=Number(a),x=Number(o);if(o==="*"&&b==="*"&&a!==void 0&&!Number.isNaN(u))return`Hourly at :${Oe(u)} ${n}`;if(b==="*"&&o!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(u))return`Daily ${de({hour:x,minute:u})} ${n}`;if(b==="1-5"&&o!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(u))return`Weekdays ${de({hour:x,minute:u})} ${n}`;if(b!=null&&/^\d(?:,\d)*$/.test(b)&&o!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(u)){const f=b.split(",").map(p=>{var N;return((N=$e.find(r=>r.value===Number(p)))==null?void 0:N.label)??p});return f.length===1?`Every ${f[0]==="Mon"?"Monday":f[0]} ${de({hour:x,minute:u})} ${n}`:`${f.join(", ")} ${de({hour:x,minute:u})} ${n}`}return t.cron}function Pe(t){const n=xe(),l=t.cron.trim().split(/\s+/);if(l.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,o,c,g,b]=l,u=Number(a),x=Number(o);return c!=="*"||g!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:o==="*"&&b==="*"&&!Number.isNaN(u)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:u,customCron:t.cron}:b==="*"&&!Number.isNaN(x)&&!Number.isNaN(u)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:x,minute:u,customCron:t.cron}:b!=null&&/^\d(?:,\d)*$/.test(b)&&!Number.isNaN(x)&&!Number.isNaN(u)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:x,minute:u,weekdays:b.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(x)?n.hour:x,minute:Number.isNaN(u)?n.minute:u}}function vt(t,n=Date.now()){if(t==null)return"Never";const l=Date.parse(t);if(Number.isNaN(l))return"Never";const a=Math.round((n-l)/1e3);if(a<60)return"just now";const o=Math.round(a/60);if(o<60)return`${String(o)} min ago`;const c=Math.round(o/60);if(c<48)return`${String(c)} hour${c===1?"":"s"} ago`;const g=Math.round(c/24);return`${String(g)} day${g===1?"":"s"} ago`}var St=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"}],kt=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),wt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Tt({values:t,onChange:n,agentId:l,onAgentIdChange:a,agentOptions:o,agentOptionsLoaded:c=!0,agentPickerDisabled:g=!1,onBuildAgent:b}){const u=be(t),x=re({cron:u,timezone:t.timezone}),f=Nt(t.timezone),p=(r,v)=>{n({...t,[r]:v})},N=r=>{const O=t.weekdays.includes(r)?t.weekdays.filter(B=>B!==r):[...t.weekdays,r];n({...t,weekdays:O.length>0?O:[r]})};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(te,{"aria-label":"Agent",placeholder:"Select an agent",value:l,options:o.map(r=>({value:r.agentId,label:r.name})),onValueChange:r=>a==null?void 0:a(r),disabled:g||a==null,emptyContent:c?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",children:"No Agents created yet"}):null,footer:c&&o.length===0&&b!=null?e.jsx("div",{className:"flex justify-end border-t border-border px-2 pt-2",children:e.jsxs(M.Ghost,{type:"button",onClick:b,children:[e.jsx(C,{name:"plus",className:"size-3.5"}),"Build Agent"]})}):null})]}),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:r=>p("name",r.target.value),placeholder:"harness-daily-digest",className:Ae("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:r=>p("task",r.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:Ae("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:St.map(r=>{const v=t.recurrence===r.value;return e.jsx("button",{type:"button",className:G("rounded-md border px-2 py-2 text-sm font-medium transition-colors",v?"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":v,onClick:()=>p("recurrence",r.value),children:r.label},r.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:$e.map(r=>{const v=t.weekdays.includes(r.value);return e.jsx("button",{type:"button",className:G("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",v?"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":v,onClick:()=>N(r.value),children:r.label},r.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(te,{"aria-label":"Hour",value:String(t.hour),options:kt,onValueChange:r=>p("hour",Number(r))})]}):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(te,{"aria-label":"Minute",value:String(t.minute),options:wt,onValueChange:r=>p("minute",Number(r))})]}):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(te,{"aria-label":"Timezone",value:t.timezone,options:f,onValueChange:r=>p("timezone",r),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(C,{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:x||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:u||"—"})]})})]})]})}function Ct(t){return t.startsWith("manual-")}function Et(t){return t==="failed"?"failed":"success"}function Be(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function _e(t){return Ct(t)?"Manual test":"Cron"}function zt(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function pe(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}).format(n)}function At({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:_e(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",pe(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",pe(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]})]})}var Rt={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 Ue({run:t}){const n=Et(t.status),l=pe(t.triggeredAt??t.scheduledFor);return e.jsx(mt,{content:e.jsx(At,{run:t}),side:"top",children:e.jsx("span",{className:G("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Rt[n]),"aria-label":`${Be(t.status)} run at ${l}`,children:e.jsx(C,{name:n==="failed"?"triangle-exclamation":"check",className:"size-3.5"})})})}function He({status:t}){const n=t==="active";return e.jsxs("span",{className:G("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",n?"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:G("size-1.5 shrink-0 rounded-full",n?"bg-emerald-600 dark:bg-emerald-400":"bg-amber-600 dark:bg-amber-400"),"aria-hidden":!0}),n?"Active":"Paused"]})}function Pt(t,n){return t.find(l=>l.name===n||l.id===n)??null}function Dt({connector:t,onConnected:n}){return bt()==null?null:e.jsx(pt,{connector:t,onConnected:n})}function ae({label:t,children:n}){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:n})]})}function It({schedule:t,agentName:n,mcpMounts:l,onEditConfiguration:a}){const o=Ne(),c=je(),{connectors:g,ensureLoaded:b,refreshConnectors:u,loading:x,error:f}=gt(),[p,N]=i.useState(!1),[r,v]=i.useState(null),O=re({cron:t.cron,timezone:t.timezone}),B=async()=>{N(!0);try{const w=await o.createScheduleRun({scheduleId:t.id});v(w),c==null||c.showSuccess({title:"Test run started"})}catch(w){c==null||c.showError(w)}finally{N(!1)}};return i.useEffect(()=>{b()},[b]),i.useEffect(()=>{f!=null&&(c==null||c.showError(f))},[f,c]),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(ae,{label:"Agent",children:n}),e.jsx(ae,{label:"Name",children:t.name}),e.jsx(ae,{label:"Status",children:e.jsx(He,{status:t.status})}),e.jsx(ae,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ae,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:O}),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(M.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(C,{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"})}),l.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:l.map(w=>{const m=Pt(g,w.name),k=(m==null?void 0:m.authenticated)===!0,V=m==null&&!x;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:G("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",k?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:k?e.jsx(C,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:w.name}),k?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):V?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):m!=null&&m.authenticated===!1?e.jsx(Dt,{connector:m,onConnected:u}):x?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},w.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(M.Primary,{type:"button",disabled:p,size:"small",onClick:()=>void B(),children:[e.jsx(C,{name:p?"loader":"play",className:G("size-3.5",p&&"animate-spin")}),"Run Test"]})]}),r==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(Ue,{run:r}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:_e(r.name)}),e.jsx("p",{className:"text-text-secondary",children:vt(r.triggeredAt??r.scheduledFor)})]})]})]})]})}function Ft({open:t,onOpenChange:n,mode:l,schedule:a,initialAgentId:o="",onSaved:c}){var ne;const g=Ne(),b=Fe(),u=xt(),x=je(),[f,p]=i.useState(xe),[N,r]=i.useState(o),[v,O]=i.useState([]),[B,w]=i.useState(!1),[m,k]=i.useState({kind:"form"}),[V,I]=i.useState(!1),[le,y]=i.useState(!1),[_,E]=i.useState(null),se=m.kind==="form"?m.saved:m.schedule,L=l==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,$=m.kind==="form"&&m.saved!=null,q=l==="create"&&m.kind==="form"&&m.saved==null,{allows:W}=fe({resourceType:"agent",resourceIds:N.length===0?[]:[N]});i.useEffect(()=>{if(!t)return;let h=!1;return w(!1),Me(b).then(S=>{h||(O(S),w(!0))}).catch(()=>{}),()=>{h=!0}},[t,b]),i.useEffect(()=>{if(!t){p(xe()),r(o),E(null),k({kind:"form"}),y(!1);return}if(l==="edit"&&a!=null){p(Pe({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),r(a.agentId),k({kind:"form"});return}p(xe()),r(o),k({kind:"form"})},[t,l,a,o]);const Q=i.useMemo(()=>v.map(h=>({agentId:ge(h),name:h.name})),[v]),z=i.useMemo(()=>v.find(h=>ge(h)===N)??null,[v,N]),A=(z==null?void 0:z.name)??(se==null?void 0:se.agentName)??(a==null?void 0:a.agentName)??((ne=Q.find(h=>h.agentId===N))==null?void 0:ne.name)??N,ie=i.useMemo(()=>{var S;return(((S=z==null?void 0:z.agentSpec)==null?void 0:S.mcpServers)??[]).map(ht).filter(T=>T!=null).map(T=>({name:T}))},[z]),U=i.useMemo(()=>{const h=be(f);return f.name.trim().length>0&&f.task.trim().length>0&&h.length>0&&N.length>0&&(!q||W(N,"USE"))},[N,W,f,q]),R=h=>{k({kind:"test",schedule:h}),p(Pe({name:h.name,task:h.task,cron:h.cron,timezone:h.timezone})),r(h.agentId)},K=async h=>{if(h.preventDefault(),!U)return;const S=be(f);I(!0),E(null);try{if(L&&a!=null){await g.updateSchedule({id:a.id,name:f.name.trim(),task:f.task.trim(),cron:S,timezone:f.timezone,status:a.status}),c==null||c(),n(!1);return}if($&&m.kind==="form"&&m.saved!=null){const Z=await g.updateSchedule({id:m.saved.id,name:f.name.trim(),task:f.task.trim(),cron:S,timezone:f.timezone,status:"paused"});c==null||c(),R(Z),x==null||x.showSuccess({title:"Schedule saved as paused",description:re({cron:Z.cron,timezone:Z.timezone})});return}const T=await g.createSchedule({agentId:N,name:f.name.trim(),task:f.task.trim(),cron:S,timezone:f.timezone,status:"paused"});c==null||c(),R(T),x==null||x.showSuccess({title:"Schedule saved as paused",description:re({cron:T.cron,timezone:T.timezone})})}catch(T){const Z=T instanceof Error?T.message:"Failed to save schedule";E(Z)}finally{I(!1)}},oe=async()=>{if(m.kind==="test"){y(!0),E(null);try{await g.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),c==null||c(),x==null||x.showSuccess({title:"Schedule activated"}),n(!1)}catch(h){const S=h instanceof Error?h.message:"Failed to activate schedule";E(S),x==null||x.showError(h)}finally{y(!1)}}},Y=m.kind==="test"?"Test Schedule":L||$?"Edit Schedule":"New Schedule",F=m.kind==="test"?`Recurring unattended runs of ${A}.`:L||$?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let P;return m.kind==="test"?P=e.jsxs("div",{className:"flex flex-col gap-2",children:[_!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:_}):null,e.jsx(M.Secondary,{type:"button",className:"w-full",disabled:le,onClick:()=>void oe(),children:"Activate Schedule"})]}):P=e.jsxs("div",{className:"flex flex-col gap-2",children:[_!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:_}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(M.Secondary,{type:"button",onClick:()=>n(!1),disabled:V,children:"Cancel"}),e.jsx(M.Primary,{type:"submit",form:"schedule-form",disabled:!U||V,children:"Save"})]})]}),e.jsx(ft,{open:t,onOpenChange:n,title:Y,description:F,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(C,{name:m.kind==="test"||L||$?"calendar":"calendar-plus",className:"size-5"})}),footer:P,children:m.kind==="test"?e.jsx(It,{schedule:m.schedule,agentName:A,mcpMounts:ie,onEditConfiguration:()=>{E(null),k({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:h=>void K(h),children:e.jsx(Tt,{values:f,onChange:p,agentId:N,onAgentIdChange:L||$?void 0:r,agentOptions:Q,agentOptionsLoaded:B,agentPickerDisabled:L||$,onBuildAgent:l==="create"&&(u==null?void 0:u.isComposerEnabled)===!0?()=>{n(!1),u.openAgentBuilder()}:void 0})})})}function De(t){return e.jsx(ut,{children:e.jsx(Ft,{...t})})}function Mt({runs:t}){const n=zt(t);return n.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:n.map(l=>e.jsx(Ue,{run:l},l.id))})}var Lt=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Ie=[10,25];function ue(t){return Math.min(Math.max(t,1),25)}function me(t){const n=ye(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all"}}function $t(t){const n=ye(window.location.search);if(!n.isNew)return{kind:"closed"};const l=t??n.agent;return{kind:"create",...l==null?{}:{agentId:l}}}function Ot({schedule:t,running:n,canManage:l,canDelete:a,onRunNow:o,onEdit:c,onTogglePause:g,onDelete:b}){const u=ot("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(u,{allowed:l,children:e.jsxs(M.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:o,children:[e.jsx(C,{name:n?"loader":"play",className:G("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(ct,{align:"end",trigger:e.jsx("button",{type:"button",className:dt({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(C,{name:"ellipsis"})}),children:[e.jsx(u,{allowed:l,children:e.jsxs(he,{onClick:c,children:[e.jsx(C,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(u,{allowed:l,children:e.jsxs(he,{onClick:g,children:[e.jsx(C,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(u,{allowed:a,children:e.jsxs(he,{className:"text-failure-bg focus:text-failure-bg",onClick:b,children:[e.jsx(C,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function _t({agentId:t}){const n=Ne(),l=Fe(),a=je(),[o,c]=i.useState([]),{allows:g}=fe({resourceType:"schedule",resourceIds:o.map(s=>s.id)}),[b,u]=i.useState({}),[x,f]=i.useState(!1),[p,N]=i.useState(()=>new Set),[r,v]=i.useState([]),[O,B]=i.useState(!0),[w,m]=i.useState(null),[k,V]=i.useState(()=>me(window.location.search).nameQuery),[I,le]=i.useState(()=>me(window.location.search).statusFilter),[y,_]=i.useState(()=>t??me(window.location.search).agentFilter),E=t??(y==="all"?null:y),se=i.useMemo(()=>E==null?r.map(s=>s.agentId):[E],[r,E]),{allows:L}=fe({resourceType:"agent",resourceIds:se}),$=l.permissions==null||(E==null?r.some(s=>L(s.agentId,"USE")):L(E,"USE")),[q,W]=i.useState(()=>$t(t)),[Q,z]=i.useState(null),[A,ie]=i.useState(()=>ue(it)),[U,R]=i.useState(void 0),[K,oe]=i.useState(void 0),[Y,F]=i.useState([]),P=i.useRef(0),ne=i.useRef(!1),h=i.useCallback(async({rows:s,gen:d})=>{if(s.length===0){d===P.current&&u({});return}f(!0);try{const j=await Promise.allSettled(s.map(D=>n.listScheduleRuns({scheduleId:D.id})));if(d!==P.current)return;u(Object.fromEntries(s.map((D,H)=>{const ee=j[H],We=(ee==null?void 0:ee.status)==="fulfilled"?ee.value:[];return[D.id,We]})))}finally{d===P.current&&f(!1)}},[n]),S=i.useCallback(async({token:s,size:d,agentId:j})=>{const D=++P.current;B(!0),m(null);try{const H=await n.listSchedules({limit:ue(d),...s===void 0||s===""?{}:{pageToken:s},...j==="all"?{}:{agentIds:[j]}});if(D!==P.current)return;c(H.data),oe(H.nextPageToken),h({rows:H.data,gen:D})}catch(H){if(D!==P.current)return;const ee=H instanceof Error?H.message:"Failed to load schedules";m(ee),c([]),u({}),oe(void 0)}finally{D===P.current&&B(!1)}},[n,h]),T=i.useCallback(s=>{const d=(s==null?void 0:s.size)??A,j=(s==null?void 0:s.agentId)??y;R(void 0),F([]),S({token:void 0,size:d,agentId:j})},[y,S,A]);i.useEffect(()=>{Te({agent:t===void 0&&y!=="all"?y:null,status:I==="all"?null:I,q:k.trim().length===0?null:k})},[y,t,I,k]),i.useEffect(()=>{t!==void 0&&_(s=>s===t?s:(R(void 0),F([]),t))},[t]),i.useEffect(()=>{ne.current||!ye(window.location.search).isNew||(ne.current=!0,Te({isNew:null}))},[]),i.useEffect(()=>{const s=()=>{const d=me(window.location.search);V(d.nameQuery),le(d.statusFilter),_(j=>{const D=t??d.agentFilter;return j===D?j:(R(void 0),F([]),D)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),i.useEffect(()=>{S({token:U,size:A,agentId:y})},[y,A,U,S]),i.useEffect(()=>{let s=!1;return Me(l).then(d=>{s||v(d.map(j=>({agentId:ge(j),name:j.name})))}).catch(()=>{}),()=>{s=!0}},[l]);const Z=i.useMemo(()=>{const s=new Map;for(const d of r)s.set(d.agentId,d.name);return s},[r]),ce=i.useMemo(()=>{const s=k.trim().toLowerCase();return o.filter(d=>!(I!=="all"&&d.status!==I||s.length>0&&!d.name.toLowerCase().includes(s)))},[o,k,I]),ve=Qe(o),Se=Y.length>0||K!=null,Ge=async s=>{if(!g(s.id,"MANAGE"))return;const d=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:d}),await S({token:U,size:A,agentId:y})}catch(j){a==null||a.showError(j)}},Ve=async s=>{if(g(s.id,"MANAGE")){N(d=>new Set(d).add(s.id));try{await n.createScheduleRun({scheduleId:s.id}),a==null||a.showSuccess({title:"Run started"});const d=await n.listScheduleRuns({scheduleId:s.id});u(j=>({...j,[s.id]:d}))}catch(d){a==null||a.showError(d)}finally{N(d=>{const j=new Set(d);return j.delete(s.id),j})}}},qe=async s=>{if(g(s.id,"DELETE")){z(null);try{await n.deleteSchedule({id:s.id}),T()}catch(d){a==null||a.showError(d)}}},ke=()=>{K!=null&&(F(s=>[...s,U??""]),R(K))},we=()=>{if(Y.length===0)return;const s=[...Y],d=s.pop();F(s),R(d===""?void 0:d)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(Ke,{title:t===void 0?"Scheduled Agents":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-56",children:e.jsx(Ye,{query:k,setQuery:V,placeholder:"Search schedules by name"})}),e.jsx(te,{value:I,onValueChange:le,options:Lt,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(te,{value:y,onValueChange:s=>{_(s),R(void 0),F([])},options:[{value:"all",label:"All agents"},...r.map(s=>({value:s.agentId,label:s.name}))],className:"sm:w-40","aria-label":"Filter by agent"}):null,e.jsxs(M.Primary,{type:"button",disabled:!$,onClick:()=>$&&W({kind:"create",agentId:y!=="all"?y:void 0}),children:[e.jsx(C,{name:"plus",className:"size-3.5"}),"Create Schedule"]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4",children:O?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,d)=>e.jsx(Ze,{className:"h-12 w-full rounded-md"},d))}):w!=null?e.jsx("p",{className:"text-failure-bg px-3 py-8 text-center text-sm",children:w}):o.length===0?e.jsx(Ce,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):ce.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Ce,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Se?e.jsx(Ee,{pageSize:A,rowCount:0,canPrev:Y.length>0,canNext:K!=null,onPrev:we,onNext:ke,pageSizeOptions:Ie,onPageSizeChange:s=>{const d=ue(s);ie(d),R(void 0),F([])}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(Je,{className:"min-w-[48rem]",children:[e.jsx(Xe,{children:e.jsxs(ze,{className:"hover:bg-transparent",children:[e.jsx(J,{children:"Name"}),e.jsx(J,{children:"Agent"}),ve?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(et,{children:ce.map(s=>{const d=re({cron:s.cron,timezone:s.timezone}),j=s.agentName??Z.get(s.agentId)??s.agentId;return e.jsxs(ze,{children:[e.jsx(X,{className:"text-text-primary font-medium",children:e.jsx("span",{className:"text-left !no-underline",children:s.name})}),e.jsx(X,{children:j}),ve?e.jsx(X,{children:e.jsx(tt,{subject:s.createdBySubject})}):null,e.jsx(X,{children:d}),e.jsx(X,{children:e.jsx(He,{status:s.status})}),e.jsx(X,{children:x?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(Mt,{runs:b[s.id]??[]})}),e.jsx(X,{className:"text-right",children:e.jsx(Ot,{schedule:s,running:p.has(s.id),canManage:g(s.id,"MANAGE"),canDelete:g(s.id,"DELETE"),onRunNow:()=>void Ve(s),onEdit:()=>{g(s.id,"MANAGE")&&W({kind:"edit",schedule:s})},onTogglePause:()=>void Ge(s),onDelete:()=>{g(s.id,"DELETE")&&z(s)}})})]},s.id)})})]}),(ce.length>0||Se)&&e.jsx(Ee,{pageSize:A,rowCount:ce.length,canPrev:Y.length>0,canNext:K!=null,onPrev:we,onNext:ke,pageSizeOptions:Ie,onPageSizeChange:s=>{const d=ue(s);ie(d),R(void 0),F([])}})]})}),q.kind==="create"?e.jsx(De,{open:!0,mode:"create",initialAgentId:q.agentId??"",onOpenChange:s=>{s||W({kind:"closed"})},onSaved:()=>T()}):null,q.kind==="edit"?e.jsx(De,{open:!0,mode:"edit",schedule:q.schedule,onOpenChange:s=>{s||W({kind:"closed"})},onSaved:()=>void S({token:U,size:A,agentId:y})}):null,Q!=null?e.jsxs(st,{open:!0,onOpenChange:s=>{s||z(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(nt,{children:e.jsxs(at,{children:[e.jsx(rt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",Q.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(lt,{children:[e.jsx(M.Secondary,{type:"button",onClick:()=>z(null),children:"Cancel"}),e.jsx(M.Destructive,{type:"button",disabled:!g(Q.id,"DELETE"),onClick:()=>void qe(Q),children:"Delete"})]})]}):null]})}export{_t as SchedulesPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelSettings-LYW64IRR-BLLhCXsR.js","assets/index-G4wOqi3O.js","assets/index-SN54UIUh.css","assets/ConnectorSettings-ESZ2RSRG-DLxrylX3.js","assets/SkillSettings-64VXUO6J-CeuMawWX.js","assets/SandboxSettings-DF64LHYI-7AeygCju.js"])))=>i.map(i=>d[i]);
2
- import{l as h,n as v,a3 as y,a4 as j,a5 as S,r as t,j as e,P as _,I as p,e as k,d as f,_ as d,S as w}from"./index-G4wOqi3O.js";var E=t.lazy(()=>d(()=>import("./ModelSettings-LYW64IRR-BLLhCXsR.js"),__vite__mapDeps([0,1,2]))),C=t.lazy(()=>d(()=>import("./ConnectorSettings-ESZ2RSRG-DLxrylX3.js"),__vite__mapDeps([3,1,2]))),N=t.lazy(()=>d(()=>import("./SkillSettings-64VXUO6J-CeuMawWX.js"),__vite__mapDeps([4,1,2]))),L=t.lazy(()=>d(()=>import("./SandboxSettings-DF64LHYI-7AeygCju.js"),__vite__mapDeps([5,1,2])));function O(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(w,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var P=()=>{const{settingsOpen:n,settingsSection:l,setSettingsOpen:r}=h(),a=v(),u=y(),{refresh:m}=j(),i=S(),o=(a==null?void 0:a.skillCatalog)!=null,c=(a==null?void 0:a.sandboxCatalog)!=null,x=t.useCallback(()=>{r(!1)},[r]);t.useEffect(()=>{if(n)return()=>{m(),u==null||u()}},[n,m,u]),t.useEffect(()=>{!o&&l==="skills"&&r(n,"models"),!c&&l==="sandbox"&&r(n,"models")},[o,c,l,n,r]),t.useEffect(()=>{if(!n)return;const s=b=>{b.key==="Escape"&&(b.stopImmediatePropagation(),x())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,n]);const g=t.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),s},[o,c]);return!n||!a?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsx(_,{title:"Settings",start:e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:k({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(p,{name:"arrow-left"})})}),e.jsxs("div",{className:f("flex min-h-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"min-w-0":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:g.map(s=>e.jsxs("button",{type:"button","aria-current":l===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",l===s.id?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{r(!0,s.id)},children:[e.jsx(p,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex flex-col h-full flex-1 overflow-y-hidden px-6 py-4",children:e.jsx("div",{className:"w-full max-w-210 h-full min-h-0 flex flex-col mx-auto",children:e.jsxs(t.Suspense,{fallback:e.jsx(O,{}),children:[l==="models"?e.jsx(E,{}):null,l==="connectors"?e.jsx(C,{}):null,l==="skills"&&o?e.jsx(N,{}):null,l==="sandbox"&&c?e.jsx(L,{}):null]})})})]})]})},I=P;export{I as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-VP6WCMGT-DuhYOy95.js","./index-DZOZ1xN3.js","./index-BBGLYdJn.css","./ConnectorSettings-OIGAC2HU-xm76mpmk.js","./SkillSettings-WQPUQ5TE-x17-_tYg.js","./SandboxSettings-GTZT7LD6-F_5p7NeO.js"])))=>i.map(i=>d[i]);
2
+ import{g as h,i as v,aD as y,aa as j,aE as S,r as t,j as e,P as _,I as p,d as k,e as f,_ as d,S as w}from"./index-DZOZ1xN3.js";var E=t.lazy(()=>d(()=>import("./ModelSettings-VP6WCMGT-DuhYOy95.js"),__vite__mapDeps([0,1,2]),import.meta.url)),C=t.lazy(()=>d(()=>import("./ConnectorSettings-OIGAC2HU-xm76mpmk.js"),__vite__mapDeps([3,1,2]),import.meta.url)),N=t.lazy(()=>d(()=>import("./SkillSettings-WQPUQ5TE-x17-_tYg.js"),__vite__mapDeps([4,1,2]),import.meta.url)),D=t.lazy(()=>d(()=>import("./SandboxSettings-GTZT7LD6-F_5p7NeO.js"),__vite__mapDeps([5,1,2]),import.meta.url));function L(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(w,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var O=()=>{const{settingsOpen:n,settingsSection:l,setSettingsOpen:r}=h(),a=v(),u=y(),{refresh:m}=j(),i=S(),o=(a==null?void 0:a.skillCatalog)!=null,c=(a==null?void 0:a.sandboxCatalog)!=null,x=t.useCallback(()=>{r(!1)},[r]);t.useEffect(()=>{if(n)return()=>{m(),u==null||u()}},[n,m,u]),t.useEffect(()=>{!o&&l==="skills"&&r(n,"models"),!c&&l==="sandbox"&&r(n,"models")},[o,c,l,n,r]),t.useEffect(()=>{if(!n)return;const s=b=>{b.key==="Escape"&&(b.stopImmediatePropagation(),x())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,n]);const g=t.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),s},[o,c]);return!n||!a?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsx(_,{title:"Settings",start:e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:k({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(p,{name:"arrow-left"})})}),e.jsxs("div",{className:f("flex min-h-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"min-w-0":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:g.map(s=>e.jsxs("button",{type:"button","aria-current":l===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",l===s.id?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{r(!0,s.id)},children:[e.jsx(p,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex flex-col h-full flex-1 overflow-y-hidden px-6 py-4",children:e.jsx("div",{className:"w-full max-w-210 h-full min-h-0 flex flex-col mx-auto",children:e.jsxs(t.Suspense,{fallback:e.jsx(L,{}),children:[l==="models"?e.jsx(E,{}):null,l==="connectors"?e.jsx(C,{}):null,l==="skills"&&o?e.jsx(N,{}):null,l==="sandbox"&&c?e.jsx(D,{}):null]})})})]})]})},I=O;export{I as default};
@@ -0,0 +1 @@
1
+ import{m as F,p as v,b as J,s as I}from"./chunk-2BDTG544-FxcOqFr-.js";import{g as ne,h as re,i as se,k as ae,l as ie,m as le,n as ue,r as a,t as oe,o as ce,p as ge,q as pe}from"./index-DZOZ1xN3.js";import{u as fe,a as ye}from"./chunk-62JRHF6Z-6aeTVQm8.js";var M="try_agent_name",_="history_agent_name";function V(n){return n!=null&&n.length>0?n:null}function E(n){const i=new URLSearchParams(n.startsWith("?")?n.slice(1):n),l=V(i.get(M));if(l!=null)return{intent:"try-agent",agentName:l};const e=V(i.get(_));return e==null?null:{intent:"history",agentName:e}}function he(n,i){n.delete(M),n.delete(_),i!=null&&n.set(i.intent==="try-agent"?M:_,i.agentName)}function X(n,i){const l=new URLSearchParams(n.startsWith("?")?n.slice(1):n);he(l,i);const e=l.toString();return e.length>0?`?${e}`:""}function Z(n){const i=n.activeRemoteId??n.pendingSessionId;if(i!=null)return{type:"session",sessionId:i};const{mode:l,agentConfigMode:e}=n;if(l.status==="active"&&l.isMutable&&l.isCreateAgent)return{type:"buildAgent"};if(l.status==="active"&&!l.isMutable&&e!=="SingleAgent"){const g=l.agentName??l.agentId;if(g!=null)return{type:"agent",agentName:g}}return{type:"root"}}function de(n){return n.settingsOpen?{type:"settings"}:n.schedulesOpen?{type:"schedules"}:n.sessionsOpen?{type:"sessionsBrowser"}:n.libraryOpen&&n.libraryAgentId!=null?{type:"libraryAgent",agentId:n.libraryAgentId}:n.libraryOpen?{type:"library"}:Z(n)}function b(n){return n.type==="root"||n.type==="agent"||n.type==="session"}function Ae({routes:n,activeRemoteId:i,initialSettingsOpen:l}){var j,z;const e=ne(),g=re(),B=se(),k=ae(),q=ie(),U=le(),$=ue(),C=fe(),s=ye(),o=a.useMemo(()=>oe({routes:n,catalog:B,capabilities:U,sessions:k,schedules:q}),[n,B,U,k,q]),T=o.settings!=null,x=[o.settings,o.sessionsBrowser,o.libraryAgent,o.schedules].join("\0"),W={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:i,mode:e.mode,agentConfigMode:e.agentConfigMode},p=de(W),ee=JSON.stringify(p),S=a.useRef(null),H=a.useRef(null),A=a.useRef(null),O=a.useRef(!1),P=a.useRef(null),m=a.useRef(null),w=a.useRef(null),f=a.useRef(null),Y=a.useRef(!1),G=a.useRef(!1),K=a.useCallback(t=>{if(w.current=t,g==null){e.openHistorySession({sessionId:t});return}g.getSession({sessionId:t}).then(r=>{w.current===t&&e.openHistorySession({sessionId:t,isMutable:r.isMutable,isCreateAgent:ce(r),...r.agentName!=null?{agentName:r.agentName}:{}})}).catch(()=>{w.current===t&&e.openHistorySession({sessionId:t})})},[g,e]),h=a.useCallback(t=>{if(t==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const r=`${t.intent}\0${t.agentName}`,u=e.historyAgentFilter;if((u==null?void 0:u.intent)===t.intent&&u.agentName===t.agentName&&u.agentId!=null){f.current=null;return}f.current=r,e.setHistoryAgentFilter(t),g!=null&&ge({server:g,agentName:t.agentName}).then(c=>{if(f.current===r){if(c==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:pe(c),agentName:c.name,intent:t.intent})}}).catch(()=>{f.current===r&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[g,e]),Q=a.useCallback(t=>{e.selectLibraryAgent({isMutable:!1,agentName:t}),h({intent:"try-agent",agentName:t})},[h,e]),L=a.useCallback(t=>{switch(t.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"libraryAgent":e.openLibraryAgent(t.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===t.sessionId||i===t.sessionId)return;K(t.sessionId);return;case"agent":e.setLibraryOpen(!1),Q(t.agentName);return;case"root":switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}}},[e,i,Q,K]);return a.useEffect(()=>{if(O.current)return;const t=F({pathname:s.pathname,search:s.search,routes:n});if(!$&&(t==null?void 0:t.type)==="settings")return;O.current=!0;const r=F({pathname:s.pathname,search:s.search,routes:o})??{type:"root"},u=r.type==="agent"?{intent:"try-agent",agentName:r.agentName}:b(r)?E(s.search):null;m.current=u,A.current=r;const c=T&&(l||r.type==="settings");if(r.type==="settings")T&&e.setSettingsOpen(!0);else if(r.type==="library")e.setLibraryOpen(!0);else if(r.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(r.type==="libraryAgent")e.openLibraryAgent(r.agentId);else if(r.type==="schedules")e.setSchedulesOpen(!0);else{const R=Z(W);v(R,r)||L(r),c&&e.setSettingsOpen(!0)}r.type!=="agent"&&u!=null?h(u):b(r)||h(null);const d=c?{type:"settings"}:r;P.current=v(p,d)?null:d;const y=J(d,o),N=X(I(d,s.search),u);H.current=d,y!=null&&(y!==s.pathname||N!==s.search)&&(S.current=y!==s.pathname?y:null,C({pathname:y,search:N,hash:s.hash},{replace:!0}))},[$]),a.useEffect(()=>{if(!O.current)return;if(!Y.current){Y.current=!0;return}const t=P.current;if(t!=null){if(!v(p,t))return;P.current=null}const r=J(p,o);if(r==null)return;const c=`${o.basename.endsWith("/")?o.basename.slice(0,-1):o.basename}${s.pathname}`||"/",d=window.location.pathname===c?window.location.search:s.search,y=b(p),N=y?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!y&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const R=X(I(p,d),N),D=H.current;if(H.current=p,r===s.pathname&&R===s.search)return;const te=p.type==="session"&&e.pendingSessionId==null&&D!=null&&D.type!=="session";S.current=r!==s.pathname?r:null,C({pathname:r,search:R,hash:s.hash},{replace:te})},[ee,x,(j=e.historyAgentFilter)==null?void 0:j.agentName,(z=e.historyAgentFilter)==null?void 0:z.intent]),a.useEffect(()=>{if(!O.current)return;if(!G.current){G.current=!0;return}if(S.current===s.pathname){S.current=null,A.current=p;return}const t=F({pathname:s.pathname,search:s.search,routes:o});if(t==null){const u=o.root,c=I({type:"root"},s.search);S.current=u,C({pathname:u,search:c,hash:s.hash},{replace:!0}),L({type:"root"}),h(E(c));return}const r=A.current;A.current=t,(r==null||!v(r,t))&&(t.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),t.type!=="library"&&t.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),t.type!=="sessionsBrowser"&&e.sessionsOpen&&e.setSessionsOpen(!1),t.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),L(t)),t.type!=="agent"&&b(t)?h(E(s.search)):b(t)||h(null)},[s.pathname,s.search]),null}export{Ae as ShellRouteSync};