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

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 (207) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js → AgentCodeSnippets-V5A56M7R-ZCh9CtX_.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-V5A56M7R-ZCh9CtX_.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-V5A56M7R-ZCh9CtX_.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-3D6FUFO6-DzIcybRU.js → AgentMetricChart-GEADURES-CIR5UtB4.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-GEADURES-CIR5UtB4.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-GEADURES-CIR5UtB4.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-RLJ6HZCN-YJvNjt8b.js → AgentOverview-NPC4P2EY-Z0AslRUd.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-NPC4P2EY-Z0AslRUd.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-NPC4P2EY-Z0AslRUd.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js → AgentSessionEventTimeline-UUXOJXTC-Nk5ZgtJk.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-UUXOJXTC-Nk5ZgtJk.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-UUXOJXTC-Nk5ZgtJk.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js → AgentSessionEventTimelineChart-FIAQCYJC-TBWekOBI.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-FIAQCYJC-TBWekOBI.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-FIAQCYJC-TBWekOBI.js.gz +0 -0
  16. package/dist/_frontend/assets/{AgentSessions-UI3L7XY2-CG8nWJdo.js → AgentSessions-WHODEG2M-OzQblCn4.js} +1 -1
  17. package/dist/_frontend/assets/AgentSessions-WHODEG2M-OzQblCn4.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-WHODEG2M-OzQblCn4.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-OIGAC2HU-xm76mpmk.js → ConnectorSettings-QTAI4TQX-PySj_xEm.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-QTAI4TQX-PySj_xEm.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-QTAI4TQX-PySj_xEm.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-J5BRKMJZ-xjQQzILb.js → DockLayout-TATYU5SV-DAuT7yes.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-65YHGHIF-CehQ0ZjJ.js → DrawerLayout-DXHNV33K-BP-6TUEf.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-DXHNV33K-BP-6TUEf.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-DXHNV33K-BP-6TUEf.js.gz +0 -0
  26. package/dist/_frontend/assets/{ModelSettings-VP6WCMGT-DuhYOy95.js → ModelSettings-UWTBHQRG-L5KYrHBM.js} +1 -1
  27. package/dist/_frontend/assets/ModelSettings-UWTBHQRG-L5KYrHBM.js.br +0 -0
  28. package/dist/_frontend/assets/ModelSettings-UWTBHQRG-L5KYrHBM.js.gz +0 -0
  29. package/dist/_frontend/assets/{SandboxSettings-GTZT7LD6-F_5p7NeO.js → SandboxSettings-BITQONS3-COVuckfo.js} +1 -1
  30. package/dist/_frontend/assets/SandboxSettings-BITQONS3-COVuckfo.js.br +0 -0
  31. package/dist/_frontend/assets/SandboxSettings-BITQONS3-COVuckfo.js.gz +0 -0
  32. package/dist/_frontend/assets/{SchedulesPage-ARWU7BZF-BIZcHayD.js → SchedulesPage-JIUWNYUH-5f3ROPme.js} +1 -1
  33. package/dist/_frontend/assets/SchedulesPage-JIUWNYUH-5f3ROPme.js.br +0 -0
  34. package/dist/_frontend/assets/SchedulesPage-JIUWNYUH-5f3ROPme.js.gz +0 -0
  35. package/dist/_frontend/assets/{SettingsBuilder-A4BPYIFZ-B4p1JpXq.js → SettingsBuilder-3OA4UCIM-AN2PJd1q.js} +2 -2
  36. package/dist/_frontend/assets/SettingsBuilder-3OA4UCIM-AN2PJd1q.js.br +0 -0
  37. package/dist/_frontend/assets/SettingsBuilder-3OA4UCIM-AN2PJd1q.js.gz +0 -0
  38. package/dist/_frontend/assets/{ShellRouteSync-SSLGM35F-Cqt-1Q8u.js → ShellRouteSync-J74MV23Q-CDk4uzrR.js} +1 -1
  39. package/dist/_frontend/assets/ShellRouteSync-J74MV23Q-CDk4uzrR.js.br +0 -0
  40. package/dist/_frontend/assets/ShellRouteSync-J74MV23Q-CDk4uzrR.js.gz +0 -0
  41. package/dist/_frontend/assets/{SidebarLayout-MFDOGAVJ-pSgzH70r.js → SidebarLayout-EQXQPYIU-zWCTPIcp.js} +2 -2
  42. package/dist/_frontend/assets/SidebarLayout-EQXQPYIU-zWCTPIcp.js.br +0 -0
  43. package/dist/_frontend/assets/SidebarLayout-EQXQPYIU-zWCTPIcp.js.gz +0 -0
  44. package/dist/_frontend/assets/{SkillSettings-WQPUQ5TE-x17-_tYg.js → SkillSettings-KQ6GQ7JW-oZVHsKV_.js} +1 -1
  45. package/dist/_frontend/assets/SkillSettings-KQ6GQ7JW-oZVHsKV_.js.br +0 -0
  46. package/dist/_frontend/assets/SkillSettings-KQ6GQ7JW-oZVHsKV_.js.gz +0 -0
  47. package/dist/_frontend/assets/TrueForgeUIWithRouter-R3UXQZRY-wD0P6NXT.js +1 -0
  48. package/dist/_frontend/assets/{WidgetLayout-HE7E4UL5-D_jC6D5-.js → WidgetLayout-YWZTYFZL-BgYVWW8O.js} +1 -1
  49. package/dist/_frontend/assets/WidgetLayout-YWZTYFZL-BgYVWW8O.js.br +0 -0
  50. package/dist/_frontend/assets/WidgetLayout-YWZTYFZL-BgYVWW8O.js.gz +0 -0
  51. package/dist/_frontend/assets/{chunk-2BDTG544-FxcOqFr-.js → chunk-4MCIDE2C-ClJFqC75.js} +1 -1
  52. package/dist/_frontend/assets/chunk-4MCIDE2C-ClJFqC75.js.br +0 -0
  53. package/dist/_frontend/assets/chunk-4MCIDE2C-ClJFqC75.js.gz +0 -0
  54. package/dist/_frontend/assets/{chunk-62JRHF6Z-6aeTVQm8.js → chunk-62JRHF6Z-CXLsU_my.js} +1 -1
  55. package/dist/_frontend/assets/chunk-62JRHF6Z-CXLsU_my.js.br +0 -0
  56. package/dist/_frontend/assets/chunk-62JRHF6Z-CXLsU_my.js.gz +0 -0
  57. package/dist/_frontend/assets/{chunk-TGKQRK3S-D5Bs7icZ.js → chunk-7NYDADYN-_y_WJnHd.js} +1 -1
  58. package/dist/_frontend/assets/chunk-7NYDADYN-_y_WJnHd.js.br +0 -0
  59. package/dist/_frontend/assets/chunk-7NYDADYN-_y_WJnHd.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-VXKNS7FH-Dm2ZAGlE.js → chunk-ZZB3JIBQ-EN4V28Ji.js} +2 -2
  61. package/dist/_frontend/assets/chunk-ZZB3JIBQ-EN4V28Ji.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-ZZB3JIBQ-EN4V28Ji.js.gz +0 -0
  63. package/dist/_frontend/assets/{cssMode-BSK94pjD.js → cssMode-Dk1ChNt4.js} +1 -1
  64. package/dist/_frontend/assets/cssMode-Dk1ChNt4.js.br +0 -0
  65. package/dist/_frontend/assets/cssMode-Dk1ChNt4.js.gz +0 -0
  66. package/dist/_frontend/assets/{freemarker2-hYZ9lU-u.js → freemarker2-D_Yi-Euz.js} +1 -1
  67. package/dist/_frontend/assets/freemarker2-D_Yi-Euz.js.br +0 -0
  68. package/dist/_frontend/assets/freemarker2-D_Yi-Euz.js.gz +0 -0
  69. package/dist/_frontend/assets/{handlebars-CJdvCy_0.js → handlebars-Cm_UQxos.js} +1 -1
  70. package/dist/_frontend/assets/handlebars-Cm_UQxos.js.br +0 -0
  71. package/dist/_frontend/assets/handlebars-Cm_UQxos.js.gz +0 -0
  72. package/dist/_frontend/assets/{html-BHnJtaJv.js → html-BIx_CMMA.js} +1 -1
  73. package/dist/_frontend/assets/html-BIx_CMMA.js.br +0 -0
  74. package/dist/_frontend/assets/html-BIx_CMMA.js.gz +0 -0
  75. package/dist/_frontend/assets/{htmlMode-BTNbHYXw.js → htmlMode-D7eeA6bm.js} +1 -1
  76. package/dist/_frontend/assets/htmlMode-D7eeA6bm.js.br +0 -0
  77. package/dist/_frontend/assets/htmlMode-D7eeA6bm.js.gz +0 -0
  78. package/dist/_frontend/assets/{index-BBGLYdJn.css → index-B01pXqvC.css} +1 -1
  79. package/dist/_frontend/assets/index-B01pXqvC.css.br +0 -0
  80. package/dist/_frontend/assets/{index-BBGLYdJn.css.gz → index-B01pXqvC.css.gz} +0 -0
  81. package/dist/_frontend/assets/{index-BU6gYO7K.js → index-BJUe77Ib.js} +3 -3
  82. package/dist/_frontend/assets/index-BJUe77Ib.js.br +0 -0
  83. package/dist/_frontend/assets/index-BJUe77Ib.js.gz +0 -0
  84. package/dist/_frontend/assets/{index-DZOZ1xN3.js → index-Y_4XXAao.js} +225 -225
  85. package/dist/_frontend/assets/index-Y_4XXAao.js.br +0 -0
  86. package/dist/_frontend/assets/index-Y_4XXAao.js.gz +0 -0
  87. package/dist/_frontend/assets/{index-B1sBHguz.js → index-uWXj7DW5.js} +1 -1
  88. package/dist/_frontend/assets/index-uWXj7DW5.js.br +0 -0
  89. package/dist/_frontend/assets/index-uWXj7DW5.js.gz +0 -0
  90. package/dist/_frontend/assets/{javascript-BKY4Sujy.js → javascript-CHojKZO8.js} +1 -1
  91. package/dist/_frontend/assets/{jsonMode-B_jTSLwe.js → jsonMode-BTk9mIUo.js} +1 -1
  92. package/dist/_frontend/assets/jsonMode-BTk9mIUo.js.br +0 -0
  93. package/dist/_frontend/assets/jsonMode-BTk9mIUo.js.gz +0 -0
  94. package/dist/_frontend/assets/{liquid-OVC8bSZr.js → liquid-M5ngFTv5.js} +1 -1
  95. package/dist/_frontend/assets/liquid-M5ngFTv5.js.br +0 -0
  96. package/dist/_frontend/assets/liquid-M5ngFTv5.js.gz +0 -0
  97. package/dist/_frontend/assets/{lspLanguageFeatures-BpQc31SX.js → lspLanguageFeatures-jPhJA8WX.js} +1 -1
  98. package/dist/_frontend/assets/lspLanguageFeatures-jPhJA8WX.js.br +0 -0
  99. package/dist/_frontend/assets/lspLanguageFeatures-jPhJA8WX.js.gz +0 -0
  100. package/dist/_frontend/assets/{mdx-Rt-sDg8a.js → mdx-DmyHsr0E.js} +1 -1
  101. package/dist/_frontend/assets/mdx-DmyHsr0E.js.br +0 -0
  102. package/dist/_frontend/assets/mdx-DmyHsr0E.js.gz +0 -0
  103. package/dist/_frontend/assets/{python-CLLuhWlP.js → python-BRFA9b-I.js} +1 -1
  104. package/dist/_frontend/assets/python-BRFA9b-I.js.br +0 -0
  105. package/dist/_frontend/assets/python-BRFA9b-I.js.gz +0 -0
  106. package/dist/_frontend/assets/{razor-CTEZKBpz.js → razor-CYsS4Kjw.js} +1 -1
  107. package/dist/_frontend/assets/razor-CYsS4Kjw.js.br +0 -0
  108. package/dist/_frontend/assets/razor-CYsS4Kjw.js.gz +0 -0
  109. package/dist/_frontend/assets/{tsMode-BsjOp9ss.js → tsMode-COQtB6OT.js} +1 -1
  110. package/dist/_frontend/assets/tsMode-COQtB6OT.js.br +0 -0
  111. package/dist/_frontend/assets/tsMode-COQtB6OT.js.gz +0 -0
  112. package/dist/_frontend/assets/{typescript-CpIJvyBH.js → typescript-B3uUksf0.js} +1 -1
  113. package/dist/_frontend/assets/typescript-B3uUksf0.js.br +0 -0
  114. package/dist/_frontend/assets/typescript-B3uUksf0.js.gz +0 -0
  115. package/dist/_frontend/assets/{workers-C_uhAUan.js → workers-CgLq606Q.js} +1 -1
  116. package/dist/_frontend/assets/workers-CgLq606Q.js.br +0 -0
  117. package/dist/_frontend/assets/workers-CgLq606Q.js.gz +0 -0
  118. package/dist/_frontend/assets/{xml-BxHi2HCJ.js → xml-YO228FLn.js} +1 -1
  119. package/dist/_frontend/assets/xml-YO228FLn.js.br +0 -0
  120. package/dist/_frontend/assets/xml-YO228FLn.js.gz +0 -0
  121. package/dist/_frontend/assets/{yaml-DyyH_CDu.js → yaml-CirMKB9x.js} +1 -1
  122. package/dist/_frontend/assets/yaml-CirMKB9x.js.br +0 -0
  123. package/dist/_frontend/assets/yaml-CirMKB9x.js.gz +0 -0
  124. package/dist/_frontend/index.html +2 -2
  125. package/dist/main.js +12 -5
  126. package/dist/main.js.map +1 -1
  127. package/package.json +1 -1
  128. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js.br +0 -0
  129. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js.gz +0 -0
  130. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js.br +0 -0
  131. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js.gz +0 -0
  132. package/dist/_frontend/assets/AgentOverview-RLJ6HZCN-YJvNjt8b.js.br +0 -0
  133. package/dist/_frontend/assets/AgentOverview-RLJ6HZCN-YJvNjt8b.js.gz +0 -0
  134. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js.br +0 -0
  135. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js.gz +0 -0
  136. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js.br +0 -0
  137. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js.gz +0 -0
  138. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js.br +0 -0
  139. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js.gz +0 -0
  140. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js.br +0 -0
  141. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js.gz +0 -0
  142. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js.br +0 -0
  143. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js.gz +0 -0
  144. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js.br +0 -0
  145. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js.gz +0 -0
  146. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js.br +0 -0
  147. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js.gz +0 -0
  148. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js.br +0 -0
  149. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js.gz +0 -0
  150. package/dist/_frontend/assets/SettingsBuilder-A4BPYIFZ-B4p1JpXq.js.br +0 -0
  151. package/dist/_frontend/assets/SettingsBuilder-A4BPYIFZ-B4p1JpXq.js.gz +0 -0
  152. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js.br +0 -0
  153. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js.gz +0 -0
  154. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js.br +0 -0
  155. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js.gz +0 -0
  156. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js.br +0 -0
  157. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js.gz +0 -0
  158. package/dist/_frontend/assets/TrueForgeUIWithRouter-5CDICMCE-DcMl1KUh.js +0 -1
  159. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js.br +0 -0
  160. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js.gz +0 -0
  161. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js.br +0 -0
  162. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js.gz +0 -0
  163. package/dist/_frontend/assets/chunk-62JRHF6Z-6aeTVQm8.js.br +0 -0
  164. package/dist/_frontend/assets/chunk-62JRHF6Z-6aeTVQm8.js.gz +0 -0
  165. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js.br +0 -0
  166. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js.gz +0 -0
  167. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js.br +0 -0
  168. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js.gz +0 -0
  169. package/dist/_frontend/assets/cssMode-BSK94pjD.js.br +0 -0
  170. package/dist/_frontend/assets/cssMode-BSK94pjD.js.gz +0 -0
  171. package/dist/_frontend/assets/freemarker2-hYZ9lU-u.js.br +0 -0
  172. package/dist/_frontend/assets/freemarker2-hYZ9lU-u.js.gz +0 -0
  173. package/dist/_frontend/assets/handlebars-CJdvCy_0.js.br +0 -0
  174. package/dist/_frontend/assets/handlebars-CJdvCy_0.js.gz +0 -0
  175. package/dist/_frontend/assets/html-BHnJtaJv.js.br +0 -0
  176. package/dist/_frontend/assets/html-BHnJtaJv.js.gz +0 -0
  177. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js.br +0 -0
  178. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js.gz +0 -0
  179. package/dist/_frontend/assets/index-B1sBHguz.js.br +0 -0
  180. package/dist/_frontend/assets/index-B1sBHguz.js.gz +0 -0
  181. package/dist/_frontend/assets/index-BBGLYdJn.css.br +0 -0
  182. package/dist/_frontend/assets/index-BU6gYO7K.js.br +0 -0
  183. package/dist/_frontend/assets/index-BU6gYO7K.js.gz +0 -0
  184. package/dist/_frontend/assets/index-DZOZ1xN3.js.br +0 -0
  185. package/dist/_frontend/assets/index-DZOZ1xN3.js.gz +0 -0
  186. package/dist/_frontend/assets/jsonMode-B_jTSLwe.js.br +0 -0
  187. package/dist/_frontend/assets/jsonMode-B_jTSLwe.js.gz +0 -0
  188. package/dist/_frontend/assets/liquid-OVC8bSZr.js.br +0 -0
  189. package/dist/_frontend/assets/liquid-OVC8bSZr.js.gz +0 -0
  190. package/dist/_frontend/assets/lspLanguageFeatures-BpQc31SX.js.br +0 -0
  191. package/dist/_frontend/assets/lspLanguageFeatures-BpQc31SX.js.gz +0 -0
  192. package/dist/_frontend/assets/mdx-Rt-sDg8a.js.br +0 -0
  193. package/dist/_frontend/assets/mdx-Rt-sDg8a.js.gz +0 -0
  194. package/dist/_frontend/assets/python-CLLuhWlP.js.br +0 -0
  195. package/dist/_frontend/assets/python-CLLuhWlP.js.gz +0 -0
  196. package/dist/_frontend/assets/razor-CTEZKBpz.js.br +0 -0
  197. package/dist/_frontend/assets/razor-CTEZKBpz.js.gz +0 -0
  198. package/dist/_frontend/assets/tsMode-BsjOp9ss.js.br +0 -0
  199. package/dist/_frontend/assets/tsMode-BsjOp9ss.js.gz +0 -0
  200. package/dist/_frontend/assets/typescript-CpIJvyBH.js.br +0 -0
  201. package/dist/_frontend/assets/typescript-CpIJvyBH.js.gz +0 -0
  202. package/dist/_frontend/assets/workers-C_uhAUan.js.br +0 -0
  203. package/dist/_frontend/assets/workers-C_uhAUan.js.gz +0 -0
  204. package/dist/_frontend/assets/xml-BxHi2HCJ.js.br +0 -0
  205. package/dist/_frontend/assets/xml-BxHi2HCJ.js.gz +0 -0
  206. package/dist/_frontend/assets/yaml-DyyH_CDu.js.br +0 -0
  207. package/dist/_frontend/assets/yaml-DyyH_CDu.js.gz +0 -0
@@ -1 +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};
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-Y_4XXAao.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};
@@ -1 +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};
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-Y_4XXAao.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};
@@ -1 +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
+ 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-Y_4XXAao.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=["./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};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-UWTBHQRG-L5KYrHBM.js","./index-Y_4XXAao.js","./index-B01pXqvC.css","./ConnectorSettings-QTAI4TQX-PySj_xEm.js","./SkillSettings-KQ6GQ7JW-oZVHsKV_.js","./SandboxSettings-BITQONS3-COVuckfo.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-Y_4XXAao.js";var E=t.lazy(()=>d(()=>import("./ModelSettings-UWTBHQRG-L5KYrHBM.js"),__vite__mapDeps([0,1,2]),import.meta.url)),C=t.lazy(()=>d(()=>import("./ConnectorSettings-QTAI4TQX-PySj_xEm.js"),__vite__mapDeps([3,1,2]),import.meta.url)),N=t.lazy(()=>d(()=>import("./SkillSettings-KQ6GQ7JW-oZVHsKV_.js"),__vite__mapDeps([4,1,2]),import.meta.url)),D=t.lazy(()=>d(()=>import("./SandboxSettings-BITQONS3-COVuckfo.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};
@@ -1 +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};
1
+ import{m as F,p as v,b as J,s as I}from"./chunk-4MCIDE2C-ClJFqC75.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-Y_4XXAao.js";import{u as fe,a as ye}from"./chunk-62JRHF6Z-CXLsU_my.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};