@truefoundry/trueforge 0.185.0 → 0.185.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-7VCMMZ5Q-D3ZBNZmT.js → AgentCodeSnippets-H343VMKM-Bw48fB4V.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-H343VMKM-Bw48fB4V.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-H343VMKM-Bw48fB4V.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-5EOXB7E3-DzEa9vqC.js → AgentMetricChart-2A3Q73AO-ByPINDhM.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-2A3Q73AO-ByPINDhM.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-2A3Q73AO-ByPINDhM.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-TOGW6FNJ-D9dS3oqD.js → AgentOverview-PLZP4BE4-B4luQD6n.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-PLZP4BE4-B4luQD6n.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-PLZP4BE4-B4luQD6n.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-SAXINA2W-CRrahdir.js → AgentSessionEventTimeline-YANYUDA5-CZsR7Mad.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-YANYUDA5-CZsR7Mad.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-YANYUDA5-CZsR7Mad.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-2CELTVWR-BuOkJQhM.js → AgentSessionEventTimelineChart-E4JMM6YS-qdgLjjB4.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-E4JMM6YS-qdgLjjB4.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-E4JMM6YS-qdgLjjB4.js.gz +0 -0
  16. package/dist/_frontend/assets/{AgentSessions-VGKHTL7J-DXlCe_Xq.js → AgentSessions-D6O2XY6Y-C4oQgmHA.js} +1 -1
  17. package/dist/_frontend/assets/AgentSessions-D6O2XY6Y-C4oQgmHA.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-D6O2XY6Y-C4oQgmHA.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-VKZWEFWZ-BkoC8A5y.js → ConnectorSettings-GKNCNULP-DWw6csCc.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-GKNCNULP-DWw6csCc.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-GKNCNULP-DWw6csCc.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-CJ5ECZPY-DhsnawY4.js → DockLayout-IE3I37YU-CqOh_TZX.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-G75J4SOY-BY-cGCrF.js → DrawerLayout-RF5C5UUW-CdYLoo0Y.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-RF5C5UUW-CdYLoo0Y.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-RF5C5UUW-CdYLoo0Y.js.gz +0 -0
  26. package/dist/_frontend/assets/{EnvironmentsPage-D75O2D3T-CKOA9E_7.js → EnvironmentsPage-Y7GUFDX6-B4lzlmZl.js} +1 -1
  27. package/dist/_frontend/assets/EnvironmentsPage-Y7GUFDX6-B4lzlmZl.js.br +0 -0
  28. package/dist/_frontend/assets/EnvironmentsPage-Y7GUFDX6-B4lzlmZl.js.gz +0 -0
  29. package/dist/_frontend/assets/{MemorySettings-IEGR7OAY-C9SXeZTk.js → MemorySettings-4RRBDBV6-DeUiqqhK.js} +1 -1
  30. package/dist/_frontend/assets/MemorySettings-4RRBDBV6-DeUiqqhK.js.br +0 -0
  31. package/dist/_frontend/assets/MemorySettings-4RRBDBV6-DeUiqqhK.js.gz +0 -0
  32. package/dist/_frontend/assets/{ModelSettings-QC33FVLM-CLBDEWFa.js → ModelSettings-GYHM5IRX-CETYKyCX.js} +1 -1
  33. package/dist/_frontend/assets/ModelSettings-GYHM5IRX-CETYKyCX.js.br +0 -0
  34. package/dist/_frontend/assets/ModelSettings-GYHM5IRX-CETYKyCX.js.gz +0 -0
  35. package/dist/_frontend/assets/{SandboxSettings-A46TVNZL-Byz-ZSG-.js → SandboxSettings-64C4LPUD-Cnonjif3.js} +1 -1
  36. package/dist/_frontend/assets/SandboxSettings-64C4LPUD-Cnonjif3.js.br +0 -0
  37. package/dist/_frontend/assets/SandboxSettings-64C4LPUD-Cnonjif3.js.gz +0 -0
  38. package/dist/_frontend/assets/{SchedulesPage-KVAX7YQM-B_rcDGg-.js → SchedulesPage-7LTCQWDY-BZlW89Yr.js} +1 -1
  39. package/dist/_frontend/assets/SchedulesPage-7LTCQWDY-BZlW89Yr.js.br +0 -0
  40. package/dist/_frontend/assets/SchedulesPage-7LTCQWDY-BZlW89Yr.js.gz +0 -0
  41. package/dist/_frontend/assets/{SettingsBuilder-VQKZH4QW-C5up_jOV.js → SettingsBuilder-EFI3M2WM-C5-UGRAl.js} +2 -2
  42. package/dist/_frontend/assets/SettingsBuilder-EFI3M2WM-C5-UGRAl.js.br +0 -0
  43. package/dist/_frontend/assets/SettingsBuilder-EFI3M2WM-C5-UGRAl.js.gz +0 -0
  44. package/dist/_frontend/assets/{ShellRouteSync-4T763MWC-CVTflvQQ.js → ShellRouteSync-4T763MWC-Bk2ZHjFW.js} +1 -1
  45. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-Bk2ZHjFW.js.br +0 -0
  46. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-Bk2ZHjFW.js.gz +0 -0
  47. package/dist/_frontend/assets/{SidebarLayout-KAHFKPTH-Cd8-hgi8.js → SidebarLayout-SLXLQ4KI-CgK26FAl.js} +2 -2
  48. package/dist/_frontend/assets/SidebarLayout-SLXLQ4KI-CgK26FAl.js.br +0 -0
  49. package/dist/_frontend/assets/SidebarLayout-SLXLQ4KI-CgK26FAl.js.gz +0 -0
  50. package/dist/_frontend/assets/{SkillSettings-SKHQARUV-D_IZlvmq.js → SkillSettings-2HF7EG6X-BjVk8qd8.js} +1 -1
  51. package/dist/_frontend/assets/SkillSettings-2HF7EG6X-BjVk8qd8.js.br +0 -0
  52. package/dist/_frontend/assets/SkillSettings-2HF7EG6X-BjVk8qd8.js.gz +0 -0
  53. package/dist/_frontend/assets/{TrueForgeUIWithRouter-YSRO7IVL-DHH7cN2N.js → TrueForgeUIWithRouter-T3W5RMEH-DF5Vv3-l.js} +1 -1
  54. package/dist/_frontend/assets/{WebSearchSettings-NUYJVMBL-B8VVOmZt.js → WebSearchSettings-HDYOF3AO-yXj5D86c.js} +1 -1
  55. package/dist/_frontend/assets/WebSearchSettings-HDYOF3AO-yXj5D86c.js.br +0 -0
  56. package/dist/_frontend/assets/WebSearchSettings-HDYOF3AO-yXj5D86c.js.gz +0 -0
  57. package/dist/_frontend/assets/{WidgetLayout-RTWPXCL7-Df0WMKu_.js → WidgetLayout-VEILCOPB-CT3L-nt5.js} +1 -1
  58. package/dist/_frontend/assets/WidgetLayout-VEILCOPB-CT3L-nt5.js.br +0 -0
  59. package/dist/_frontend/assets/WidgetLayout-VEILCOPB-CT3L-nt5.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-RQ7NBDM4-BTpVQH0R.js → chunk-2DR7SPLX-lhr7WyYV.js} +2 -2
  61. package/dist/_frontend/assets/chunk-2DR7SPLX-lhr7WyYV.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-2DR7SPLX-lhr7WyYV.js.gz +0 -0
  63. package/dist/_frontend/assets/{chunk-4LY4NAUC-K0Thc4fl.js → chunk-4LY4NAUC-C1iAiAXz.js} +1 -1
  64. package/dist/_frontend/assets/chunk-4LY4NAUC-C1iAiAXz.js.br +0 -0
  65. package/dist/_frontend/assets/chunk-4LY4NAUC-C1iAiAXz.js.gz +0 -0
  66. package/dist/_frontend/assets/{chunk-OB3PAWPO-C9NyEqw5.js → chunk-OB3PAWPO-CcC39jqv.js} +1 -1
  67. package/dist/_frontend/assets/chunk-OB3PAWPO-CcC39jqv.js.br +0 -0
  68. package/dist/_frontend/assets/chunk-OB3PAWPO-CcC39jqv.js.gz +0 -0
  69. package/dist/_frontend/assets/{chunk-F62I374W-Dwa1z7Cl.js → chunk-US5DQOBQ-Bu-huQ7M.js} +1 -1
  70. package/dist/_frontend/assets/chunk-WUWRYVPF-CCSQgb1W.js +1 -0
  71. package/dist/_frontend/assets/chunk-WUWRYVPF-CCSQgb1W.js.br +0 -0
  72. package/dist/_frontend/assets/chunk-WUWRYVPF-CCSQgb1W.js.gz +0 -0
  73. package/dist/_frontend/assets/{cssMode-DHdOPnmp.js → cssMode-Dj2Xz6jz.js} +1 -1
  74. package/dist/_frontend/assets/cssMode-Dj2Xz6jz.js.br +0 -0
  75. package/dist/_frontend/assets/cssMode-Dj2Xz6jz.js.gz +0 -0
  76. package/dist/_frontend/assets/{freemarker2-BKViPF5X.js → freemarker2-943N0gt5.js} +1 -1
  77. package/dist/_frontend/assets/freemarker2-943N0gt5.js.br +0 -0
  78. package/dist/_frontend/assets/freemarker2-943N0gt5.js.gz +0 -0
  79. package/dist/_frontend/assets/{handlebars-Brwcouvl.js → handlebars-BmWTi7ZS.js} +1 -1
  80. package/dist/_frontend/assets/handlebars-BmWTi7ZS.js.br +0 -0
  81. package/dist/_frontend/assets/handlebars-BmWTi7ZS.js.gz +0 -0
  82. package/dist/_frontend/assets/{html-DIzhH-PY.js → html-8lmTcm-G.js} +1 -1
  83. package/dist/_frontend/assets/html-8lmTcm-G.js.br +0 -0
  84. package/dist/_frontend/assets/html-8lmTcm-G.js.gz +0 -0
  85. package/dist/_frontend/assets/{htmlMode-CWkTMPSo.js → htmlMode-DfBGge2N.js} +1 -1
  86. package/dist/_frontend/assets/htmlMode-DfBGge2N.js.br +0 -0
  87. package/dist/_frontend/assets/htmlMode-DfBGge2N.js.gz +0 -0
  88. package/dist/_frontend/assets/{index-7kzkzyvL.js → index-BQmZxgUA.js} +3 -3
  89. package/dist/_frontend/assets/index-BQmZxgUA.js.br +0 -0
  90. package/dist/_frontend/assets/index-BQmZxgUA.js.gz +0 -0
  91. package/dist/_frontend/assets/{index-lhOueW4w.js → index-CVbSocf1.js} +130 -130
  92. package/dist/_frontend/assets/index-CVbSocf1.js.br +0 -0
  93. package/dist/_frontend/assets/index-CVbSocf1.js.gz +0 -0
  94. package/dist/_frontend/assets/{javascript-CsXJ8UkR.js → javascript-BrPBFTYF.js} +1 -1
  95. package/dist/_frontend/assets/{jsonMode-Do2FRNBn.js → jsonMode-BJ-YqiW2.js} +1 -1
  96. package/dist/_frontend/assets/jsonMode-BJ-YqiW2.js.br +0 -0
  97. package/dist/_frontend/assets/jsonMode-BJ-YqiW2.js.gz +0 -0
  98. package/dist/_frontend/assets/{liquid-DlinQhlv.js → liquid-DHofx8Gl.js} +1 -1
  99. package/dist/_frontend/assets/liquid-DHofx8Gl.js.br +0 -0
  100. package/dist/_frontend/assets/liquid-DHofx8Gl.js.gz +0 -0
  101. package/dist/_frontend/assets/{lspLanguageFeatures-Dw-hxDJI.js → lspLanguageFeatures-C36LEzPR.js} +1 -1
  102. package/dist/_frontend/assets/lspLanguageFeatures-C36LEzPR.js.br +0 -0
  103. package/dist/_frontend/assets/lspLanguageFeatures-C36LEzPR.js.gz +0 -0
  104. package/dist/_frontend/assets/{mdx-DtIO5KvQ.js → mdx-DKcVoDZ1.js} +1 -1
  105. package/dist/_frontend/assets/mdx-DKcVoDZ1.js.br +0 -0
  106. package/dist/_frontend/assets/mdx-DKcVoDZ1.js.gz +0 -0
  107. package/dist/_frontend/assets/{python-BBZr1oz3.js → python-BJ1tC8V2.js} +1 -1
  108. package/dist/_frontend/assets/python-BJ1tC8V2.js.br +0 -0
  109. package/dist/_frontend/assets/python-BJ1tC8V2.js.gz +0 -0
  110. package/dist/_frontend/assets/{razor-D8YKFhw8.js → razor-DwNLptja.js} +1 -1
  111. package/dist/_frontend/assets/razor-DwNLptja.js.br +0 -0
  112. package/dist/_frontend/assets/razor-DwNLptja.js.gz +0 -0
  113. package/dist/_frontend/assets/{tsMode-BbMq9MFu.js → tsMode-LvSj4QG5.js} +1 -1
  114. package/dist/_frontend/assets/tsMode-LvSj4QG5.js.br +0 -0
  115. package/dist/_frontend/assets/tsMode-LvSj4QG5.js.gz +0 -0
  116. package/dist/_frontend/assets/{typescript-RWgDQi2T.js → typescript-ByGf1nW8.js} +1 -1
  117. package/dist/_frontend/assets/typescript-ByGf1nW8.js.br +0 -0
  118. package/dist/_frontend/assets/typescript-ByGf1nW8.js.gz +0 -0
  119. package/dist/_frontend/assets/{workers-CQ8UrDET.js → workers-Ds-LWqXu.js} +1 -1
  120. package/dist/_frontend/assets/workers-Ds-LWqXu.js.br +0 -0
  121. package/dist/_frontend/assets/workers-Ds-LWqXu.js.gz +0 -0
  122. package/dist/_frontend/assets/{xml-CYQf_2f7.js → xml-D-KxU_aA.js} +1 -1
  123. package/dist/_frontend/assets/xml-D-KxU_aA.js.br +0 -0
  124. package/dist/_frontend/assets/xml-D-KxU_aA.js.gz +0 -0
  125. package/dist/_frontend/assets/{yaml-Cr1BdzMD.js → yaml-Dctt39Xw.js} +1 -1
  126. package/dist/_frontend/assets/yaml-Dctt39Xw.js.br +0 -0
  127. package/dist/_frontend/assets/yaml-Dctt39Xw.js.gz +0 -0
  128. package/dist/_frontend/index.html +1 -1
  129. package/package.json +2 -2
  130. package/dist/_frontend/assets/AgentCodeSnippets-7VCMMZ5Q-D3ZBNZmT.js.br +0 -0
  131. package/dist/_frontend/assets/AgentCodeSnippets-7VCMMZ5Q-D3ZBNZmT.js.gz +0 -0
  132. package/dist/_frontend/assets/AgentMetricChart-5EOXB7E3-DzEa9vqC.js.br +0 -0
  133. package/dist/_frontend/assets/AgentMetricChart-5EOXB7E3-DzEa9vqC.js.gz +0 -0
  134. package/dist/_frontend/assets/AgentOverview-TOGW6FNJ-D9dS3oqD.js.br +0 -0
  135. package/dist/_frontend/assets/AgentOverview-TOGW6FNJ-D9dS3oqD.js.gz +0 -0
  136. package/dist/_frontend/assets/AgentSessionEventTimeline-SAXINA2W-CRrahdir.js.br +0 -0
  137. package/dist/_frontend/assets/AgentSessionEventTimeline-SAXINA2W-CRrahdir.js.gz +0 -0
  138. package/dist/_frontend/assets/AgentSessionEventTimelineChart-2CELTVWR-BuOkJQhM.js.br +0 -0
  139. package/dist/_frontend/assets/AgentSessionEventTimelineChart-2CELTVWR-BuOkJQhM.js.gz +0 -0
  140. package/dist/_frontend/assets/AgentSessions-VGKHTL7J-DXlCe_Xq.js.br +0 -0
  141. package/dist/_frontend/assets/AgentSessions-VGKHTL7J-DXlCe_Xq.js.gz +0 -0
  142. package/dist/_frontend/assets/ConnectorSettings-VKZWEFWZ-BkoC8A5y.js.br +0 -0
  143. package/dist/_frontend/assets/ConnectorSettings-VKZWEFWZ-BkoC8A5y.js.gz +0 -0
  144. package/dist/_frontend/assets/DrawerLayout-G75J4SOY-BY-cGCrF.js.br +0 -0
  145. package/dist/_frontend/assets/DrawerLayout-G75J4SOY-BY-cGCrF.js.gz +0 -0
  146. package/dist/_frontend/assets/EnvironmentsPage-D75O2D3T-CKOA9E_7.js.br +0 -0
  147. package/dist/_frontend/assets/EnvironmentsPage-D75O2D3T-CKOA9E_7.js.gz +0 -0
  148. package/dist/_frontend/assets/MemorySettings-IEGR7OAY-C9SXeZTk.js.br +0 -0
  149. package/dist/_frontend/assets/MemorySettings-IEGR7OAY-C9SXeZTk.js.gz +0 -0
  150. package/dist/_frontend/assets/ModelSettings-QC33FVLM-CLBDEWFa.js.br +0 -0
  151. package/dist/_frontend/assets/ModelSettings-QC33FVLM-CLBDEWFa.js.gz +0 -0
  152. package/dist/_frontend/assets/SandboxSettings-A46TVNZL-Byz-ZSG-.js.br +0 -0
  153. package/dist/_frontend/assets/SandboxSettings-A46TVNZL-Byz-ZSG-.js.gz +0 -0
  154. package/dist/_frontend/assets/SchedulesPage-KVAX7YQM-B_rcDGg-.js.br +0 -0
  155. package/dist/_frontend/assets/SchedulesPage-KVAX7YQM-B_rcDGg-.js.gz +0 -0
  156. package/dist/_frontend/assets/SettingsBuilder-VQKZH4QW-C5up_jOV.js.br +0 -0
  157. package/dist/_frontend/assets/SettingsBuilder-VQKZH4QW-C5up_jOV.js.gz +0 -0
  158. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-CVTflvQQ.js.br +0 -0
  159. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-CVTflvQQ.js.gz +0 -0
  160. package/dist/_frontend/assets/SidebarLayout-KAHFKPTH-Cd8-hgi8.js.br +0 -0
  161. package/dist/_frontend/assets/SidebarLayout-KAHFKPTH-Cd8-hgi8.js.gz +0 -0
  162. package/dist/_frontend/assets/SkillSettings-SKHQARUV-D_IZlvmq.js.br +0 -0
  163. package/dist/_frontend/assets/SkillSettings-SKHQARUV-D_IZlvmq.js.gz +0 -0
  164. package/dist/_frontend/assets/WebSearchSettings-NUYJVMBL-B8VVOmZt.js.br +0 -0
  165. package/dist/_frontend/assets/WebSearchSettings-NUYJVMBL-B8VVOmZt.js.gz +0 -0
  166. package/dist/_frontend/assets/WidgetLayout-RTWPXCL7-Df0WMKu_.js.br +0 -0
  167. package/dist/_frontend/assets/WidgetLayout-RTWPXCL7-Df0WMKu_.js.gz +0 -0
  168. package/dist/_frontend/assets/chunk-4LY4NAUC-K0Thc4fl.js.br +0 -0
  169. package/dist/_frontend/assets/chunk-4LY4NAUC-K0Thc4fl.js.gz +0 -0
  170. package/dist/_frontend/assets/chunk-OB3PAWPO-C9NyEqw5.js.br +0 -0
  171. package/dist/_frontend/assets/chunk-OB3PAWPO-C9NyEqw5.js.gz +0 -0
  172. package/dist/_frontend/assets/chunk-RQ7NBDM4-BTpVQH0R.js.br +0 -0
  173. package/dist/_frontend/assets/chunk-RQ7NBDM4-BTpVQH0R.js.gz +0 -0
  174. package/dist/_frontend/assets/chunk-U6PRJTQZ-DtY4Oe0N.js +0 -1
  175. package/dist/_frontend/assets/chunk-U6PRJTQZ-DtY4Oe0N.js.br +0 -0
  176. package/dist/_frontend/assets/chunk-U6PRJTQZ-DtY4Oe0N.js.gz +0 -0
  177. package/dist/_frontend/assets/cssMode-DHdOPnmp.js.br +0 -0
  178. package/dist/_frontend/assets/cssMode-DHdOPnmp.js.gz +0 -0
  179. package/dist/_frontend/assets/freemarker2-BKViPF5X.js.br +0 -0
  180. package/dist/_frontend/assets/freemarker2-BKViPF5X.js.gz +0 -0
  181. package/dist/_frontend/assets/handlebars-Brwcouvl.js.br +0 -0
  182. package/dist/_frontend/assets/handlebars-Brwcouvl.js.gz +0 -0
  183. package/dist/_frontend/assets/html-DIzhH-PY.js.br +0 -0
  184. package/dist/_frontend/assets/html-DIzhH-PY.js.gz +0 -0
  185. package/dist/_frontend/assets/htmlMode-CWkTMPSo.js.br +0 -0
  186. package/dist/_frontend/assets/htmlMode-CWkTMPSo.js.gz +0 -0
  187. package/dist/_frontend/assets/index-7kzkzyvL.js.br +0 -0
  188. package/dist/_frontend/assets/index-7kzkzyvL.js.gz +0 -0
  189. package/dist/_frontend/assets/index-lhOueW4w.js.br +0 -0
  190. package/dist/_frontend/assets/index-lhOueW4w.js.gz +0 -0
  191. package/dist/_frontend/assets/jsonMode-Do2FRNBn.js.br +0 -0
  192. package/dist/_frontend/assets/jsonMode-Do2FRNBn.js.gz +0 -0
  193. package/dist/_frontend/assets/liquid-DlinQhlv.js.br +0 -0
  194. package/dist/_frontend/assets/liquid-DlinQhlv.js.gz +0 -0
  195. package/dist/_frontend/assets/lspLanguageFeatures-Dw-hxDJI.js.br +0 -0
  196. package/dist/_frontend/assets/lspLanguageFeatures-Dw-hxDJI.js.gz +0 -0
  197. package/dist/_frontend/assets/mdx-DtIO5KvQ.js.br +0 -0
  198. package/dist/_frontend/assets/mdx-DtIO5KvQ.js.gz +0 -0
  199. package/dist/_frontend/assets/python-BBZr1oz3.js.br +0 -0
  200. package/dist/_frontend/assets/python-BBZr1oz3.js.gz +0 -0
  201. package/dist/_frontend/assets/razor-D8YKFhw8.js.br +0 -0
  202. package/dist/_frontend/assets/razor-D8YKFhw8.js.gz +0 -0
  203. package/dist/_frontend/assets/tsMode-BbMq9MFu.js.br +0 -0
  204. package/dist/_frontend/assets/tsMode-BbMq9MFu.js.gz +0 -0
  205. package/dist/_frontend/assets/typescript-RWgDQi2T.js.br +0 -0
  206. package/dist/_frontend/assets/typescript-RWgDQi2T.js.gz +0 -0
  207. package/dist/_frontend/assets/workers-CQ8UrDET.js.br +0 -0
  208. package/dist/_frontend/assets/workers-CQ8UrDET.js.gz +0 -0
  209. package/dist/_frontend/assets/xml-CYQf_2f7.js.br +0 -0
  210. package/dist/_frontend/assets/xml-CYQf_2f7.js.gz +0 -0
  211. package/dist/_frontend/assets/yaml-Cr1BdzMD.js.br +0 -0
  212. package/dist/_frontend/assets/yaml-Cr1BdzMD.js.gz +0 -0
@@ -1 +1 @@
1
- import{S as a}from"./chunk-RQ7NBDM4-BTpVQH0R.js";import{j as o,bl as t,c as l}from"./index-lhOueW4w.js";import"./chunk-U6PRJTQZ-DtY4Oe0N.js";function c({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{c as DockLayout};
1
+ import{S as a}from"./chunk-2DR7SPLX-lhr7WyYV.js";import{j as o,bl as t,c as l}from"./index-CVbSocf1.js";import"./chunk-WUWRYVPF-CCSQgb1W.js";function c({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{c as DockLayout};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-VQKZH4QW-C5up_jOV.js","./index-lhOueW4w.js","./index-B01pXqvC.css","./SchedulesPage-KVAX7YQM-B_rcDGg-.js","./chunk-4LY4NAUC-K0Thc4fl.js","./EnvironmentsPage-D75O2D3T-CKOA9E_7.js"])))=>i.map(i=>d[i]);
2
- import{be as T,t as R,bf as V,u as s,r as n,bg as F,bh as M,j as t,P as H,I as p,a3 as g,bi as f,bj as U,c as q,bk as b}from"./index-lhOueW4w.js";import{A as G,S as J,N as K,T as Q}from"./chunk-U6PRJTQZ-DtY4Oe0N.js";var W=n.lazy(()=>b(()=>import("./SettingsBuilder-VQKZH4QW-C5up_jOV.js"),__vite__mapDeps([0,1,2]),import.meta.url)),X=n.lazy(()=>b(()=>import("./SchedulesPage-KVAX7YQM-B_rcDGg-.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(a=>({default:a.SchedulesPage}))),Y=n.lazy(()=>b(()=>import("./EnvironmentsPage-D75O2D3T-CKOA9E_7.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(a=>({default:a.EnvironmentsPage})));function ee({className:a}){const y=T(),e=R(),u=V(),v=s("ClearChatButton"),A=s("ResetAgentBuilderButton"),N=s("AgentDetailsPage"),h=s("AgentsLibrary"),C=s("SessionsPage"),O=s("ShareChatButton"),S=s("SaveAgentButton"),w=s("SelectAgentEmptyState"),E=s("UserAvatar"),_=n.useRef(null),B=(e==null?void 0:e.mode.status)==="idle",d=(e==null?void 0:e.settingsOpen)===!0,r=(e==null?void 0:e.libraryOpen)===!0,m=(e==null?void 0:e.sessionsOpen)===!0,o=(e==null?void 0:e.schedulesOpen)===!0,c=(e==null?void 0:e.environmentsOpen)===!0,l=d||r||m||o||c,P=F(),x=e!=null&&M(e.mode),i=u&&(m||o||c||x&&!d&&!r),k=x&&!l&&!u,j=(e==null?void 0:e.isNewChatEnabled)!==!1,L=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(y.threads().switchToNewThread()).catch(()=>{})},I=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()},z=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setSessionsOpen(!1),e==null||e.setEnvironmentsOpen(!1),i&&x&&(e==null||e.openDraft())},D=i||r||o||c;return t.jsxs("div",{className:q("relative flex h-full min-h-0 w-full bg-primary-bg",a),children:[k?t.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:t.jsx(G,{})}):null,t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(H,{className:"bg-topbar-bg",title:D?t.jsxs("button",{type:"button",className:g({variant:"ghost",size:"small"}),onClick:z,children:[t.jsx(p,{name:"arrow-left"}),"Back to chat"]}):l?null:t.jsx(K,{}),end:t.jsxs(t.Fragment,{children:[!l&&!i?t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsx(O,{}),t.jsx(v,{}),t.jsx(S,{})]}):null,t.jsx(J,{},"shell-actions"),t.jsx(E,{}),!l&&!i?t.jsxs(t.Fragment,{children:[j&&!P?t.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:g({variant:"ghost",size:"icon"}),onClick:L,children:t.jsx(p,{name:"square-pen"})}):null,j&&(e!=null&&e.isComposerEnabled)&&!u?t.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:g({variant:"ghost",size:"icon"}),onClick:I,children:t.jsx(p,{name:"agent-2"})}):null]}):null]})}),t.jsx("div",{ref:_,className:"min-h-0 min-w-0 flex-1",children:d?t.jsx(n.Suspense,{fallback:t.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(f,{size:28,className:"text-text-primary"}),t.jsx("span",{className:"sr-only",children:"Loading"})]}),children:t.jsx(W,{})}):i?t.jsx(U,{}):m?t.jsx(C,{}):r&&(e==null?void 0:e.libraryAgentId)!=null?t.jsx(N,{agentId:e.libraryAgentId},e.libraryAgentId):r?t.jsx(h,{}):o?t.jsx(n.Suspense,{fallback:t.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(f,{size:28,className:"text-text-primary"}),t.jsx("span",{className:"sr-only",children:"Loading"})]}),children:t.jsx(X,{})}):c?t.jsx(n.Suspense,{fallback:t.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(f,{size:28,className:"text-text-primary"}),t.jsx("span",{className:"sr-only",children:"Loading"})]}),children:t.jsx(Y,{})}):B?t.jsx(w,{}):t.jsx(Q,{})})]})]})}export{ee as DrawerLayout};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-EFI3M2WM-C5-UGRAl.js","./index-CVbSocf1.js","./index-B01pXqvC.css","./SchedulesPage-7LTCQWDY-BZlW89Yr.js","./chunk-4LY4NAUC-C1iAiAXz.js","./EnvironmentsPage-Y7GUFDX6-B4lzlmZl.js"])))=>i.map(i=>d[i]);
2
+ import{be as T,t as R,bf as V,u as s,r as n,bg as F,bh as M,j as t,P as H,I as p,a3 as g,bi as f,bj as U,c as q,bk as b}from"./index-CVbSocf1.js";import{A as G,S as J,N as K,T as Q}from"./chunk-WUWRYVPF-CCSQgb1W.js";var W=n.lazy(()=>b(()=>import("./SettingsBuilder-EFI3M2WM-C5-UGRAl.js"),__vite__mapDeps([0,1,2]),import.meta.url)),X=n.lazy(()=>b(()=>import("./SchedulesPage-7LTCQWDY-BZlW89Yr.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(a=>({default:a.SchedulesPage}))),Y=n.lazy(()=>b(()=>import("./EnvironmentsPage-Y7GUFDX6-B4lzlmZl.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(a=>({default:a.EnvironmentsPage})));function ee({className:a}){const y=T(),e=R(),u=V(),v=s("ClearChatButton"),A=s("ResetAgentBuilderButton"),N=s("AgentDetailsPage"),h=s("AgentsLibrary"),C=s("SessionsPage"),O=s("ShareChatButton"),S=s("SaveAgentButton"),w=s("SelectAgentEmptyState"),E=s("UserAvatar"),_=n.useRef(null),B=(e==null?void 0:e.mode.status)==="idle",d=(e==null?void 0:e.settingsOpen)===!0,r=(e==null?void 0:e.libraryOpen)===!0,m=(e==null?void 0:e.sessionsOpen)===!0,o=(e==null?void 0:e.schedulesOpen)===!0,c=(e==null?void 0:e.environmentsOpen)===!0,l=d||r||m||o||c,P=F(),x=e!=null&&M(e.mode),i=u&&(m||o||c||x&&!d&&!r),k=x&&!l&&!u,j=(e==null?void 0:e.isNewChatEnabled)!==!1,L=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(y.threads().switchToNewThread()).catch(()=>{})},I=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()},z=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setSessionsOpen(!1),e==null||e.setEnvironmentsOpen(!1),i&&x&&(e==null||e.openDraft())},D=i||r||o||c;return t.jsxs("div",{className:q("relative flex h-full min-h-0 w-full bg-primary-bg",a),children:[k?t.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:t.jsx(G,{})}):null,t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(H,{className:"bg-topbar-bg",title:D?t.jsxs("button",{type:"button",className:g({variant:"ghost",size:"small"}),onClick:z,children:[t.jsx(p,{name:"arrow-left"}),"Back to chat"]}):l?null:t.jsx(K,{}),end:t.jsxs(t.Fragment,{children:[!l&&!i?t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsx(O,{}),t.jsx(v,{}),t.jsx(S,{})]}):null,t.jsx(J,{},"shell-actions"),t.jsx(E,{}),!l&&!i?t.jsxs(t.Fragment,{children:[j&&!P?t.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:g({variant:"ghost",size:"icon"}),onClick:L,children:t.jsx(p,{name:"square-pen"})}):null,j&&(e!=null&&e.isComposerEnabled)&&!u?t.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:g({variant:"ghost",size:"icon"}),onClick:I,children:t.jsx(p,{name:"agent-2"})}):null]}):null]})}),t.jsx("div",{ref:_,className:"min-h-0 min-w-0 flex-1",children:d?t.jsx(n.Suspense,{fallback:t.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(f,{size:28,className:"text-text-primary"}),t.jsx("span",{className:"sr-only",children:"Loading"})]}),children:t.jsx(W,{})}):i?t.jsx(U,{}):m?t.jsx(C,{}):r&&(e==null?void 0:e.libraryAgentId)!=null?t.jsx(N,{agentId:e.libraryAgentId},e.libraryAgentId):r?t.jsx(h,{}):o?t.jsx(n.Suspense,{fallback:t.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(f,{size:28,className:"text-text-primary"}),t.jsx("span",{className:"sr-only",children:"Loading"})]}),children:t.jsx(X,{})}):c?t.jsx(n.Suspense,{fallback:t.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(f,{size:28,className:"text-text-primary"}),t.jsx("span",{className:"sr-only",children:"Loading"})]}),children:t.jsx(Y,{})}):B?t.jsx(w,{}):t.jsx(Q,{})})]})]})}export{ee as DrawerLayout};
@@ -1,3 +1,3 @@
1
- import{B as Z}from"./chunk-4LY4NAUC-K0Thc4fl.js";import{ae as de,t as Ne,p as me,q as ue,af as je,r as u,w as ye,ag as Q,x as xe,ah as Y,ai as ie,aj as X,j as e,P as ke,S as we,k as _,E as V,I as D,G as $,F as Ee,ak as Se,J as Ce,K as Ae,L as re,M as A,N as Te,O as T,al as De,am as Pe,ad as Re,a1 as Le,a3 as J,H as _e,c as z,R as Ve,U as ze,V as Be,W as Me,X as Oe,Y as Ie,a2 as Fe,an as le,a7 as Ge,_ as W,ao as He,ap as qe}from"./index-lhOueW4w.js";function oe(n){var c,a,r,i,s,o,l,x;return{name:n.name,description:n.description??"",buildScript:((c=n.image)==null?void 0:c.buildScript)??"",cpu:String(((a=n.resources)==null?void 0:a.cpu)??1),memory:String(((r=n.resources)==null?void 0:r.memory)??1),disk:String(((i=n.resources)==null?void 0:i.disk)??3),networkBlockAll:((s=n.networking)==null?void 0:s.networkBlockAll)===!0,domainAllowList:((o=n.networking)==null?void 0:o.domainAllowList)??"",secrets:((x=(l=n.networking)==null?void 0:l.secrets)==null?void 0:x.map(d=>({...d,hosts:[...d.hosts]})))??[],environmentVariables:Object.entries(n.environmentVariables??{}).map(([d,h])=>({key:d,value:h}))}}function Ue(n){const c=Number(n.cpu),a=Number(n.memory),r=Number(n.disk),i=Object.fromEntries(n.environmentVariables.map(o=>[o.key.trim(),o.value]).filter(([o,l])=>o.length>0&&l.length>0)),s=n.networkBlockAll?void 0:n.secrets.map(o=>({env:o.env.trim(),value:o.value,hosts:o.hosts.map(l=>l.trim()).filter(l=>l.length>0)})).filter(o=>o.env.length>0&&o.value.length>0);return{name:n.name.trim(),...n.description.trim().length===0?{}:{description:n.description.trim()},...n.buildScript.trim().length===0?{}:{image:{type:"build",buildScript:n.buildScript}},resources:{cpu:Number.isFinite(c)&&c>0?c:1,memory:Number.isFinite(a)&&a>0?a:1,disk:Number.isFinite(r)&&r>0?r:3},...Object.keys(i).length===0?{}:{environmentVariables:i},networking:n.networkBlockAll?{networkBlockAll:!0}:{networkBlockAll:!1,...n.domainAllowList.trim().length===0?{}:{domainAllowList:n.domainAllowList.trim()},...s==null||s.length===0?{}:{secrets:s}}}}function Qe(n){const c=n.name.trim();if(c.length===0)return"Name is required";if(X(c))return`Name "${qe}" is reserved`;const a=Number(n.cpu),r=Number(n.memory),i=Number(n.disk);if(!Number.isFinite(a)||a<=0)return"CPU must be a positive number";if(!Number.isFinite(r)||r<=0)return"Memory must be a positive number";if(!Number.isFinite(i)||i<=0)return"Disk must be a positive number";if(!n.networkBlockAll){for(const s of n.secrets)if(s.env.trim().length!==0&&s.value.trim().length===0)return"Secret value is required"}return null}var v="w-full rounded-md border border-border bg-input-box-bg px-2.5 py-1.5 text-sm text-text-primary placeholder:text-text-secondary/70 outline-none focus:border-primary-button-bg",ce="text-sm font-medium text-text-primary",O="rounded-lg border border-border p-4 flex flex-col gap-4";function Ye({values:n,onChange:c,nameDisabled:a,readOnly:r=!1}){const i=s=>c({...n,...s});return e.jsxs("fieldset",{disabled:r,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0 pb-8",children:[e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:ce,children:"Name"}),e.jsx("input",{className:z(v,a&&"opacity-70"),value:n.name,disabled:a,placeholder:"my-environment",onChange:s=>i({name:s.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:ce,children:"Description"}),e.jsx("textarea",{className:z(v,"min-h-20 resize-y"),value:n.description,placeholder:"write description ...",onChange:s=>i({description:s.target.value})})]}),e.jsxs("div",{className:O,children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Image And Resources"}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Build Script"}),e.jsx("textarea",{className:z(v,"min-h-24 resize-y font-mono text-xs"),value:n.buildScript,placeholder:`set -ex
1
+ import{B as Z}from"./chunk-4LY4NAUC-C1iAiAXz.js";import{ae as de,t as Ne,p as me,q as ue,af as je,r as u,w as ye,ag as Q,x as xe,ah as Y,ai as ie,aj as X,j as e,P as ke,S as we,k as _,E as V,I as D,G as $,F as Ee,ak as Se,J as Ce,K as Ae,L as re,M as A,N as Te,O as T,al as De,am as Pe,ad as Re,a1 as Le,a3 as J,H as _e,c as z,R as Ve,U as ze,V as Be,W as Me,X as Oe,Y as Ie,a2 as Fe,an as le,a7 as Ge,_ as W,ao as He,ap as qe}from"./index-CVbSocf1.js";function oe(n){var c,a,r,i,s,o,l,x;return{name:n.name,description:n.description??"",buildScript:((c=n.image)==null?void 0:c.buildScript)??"",cpu:String(((a=n.resources)==null?void 0:a.cpu)??1),memory:String(((r=n.resources)==null?void 0:r.memory)??1),disk:String(((i=n.resources)==null?void 0:i.disk)??3),networkBlockAll:((s=n.networking)==null?void 0:s.networkBlockAll)===!0,domainAllowList:((o=n.networking)==null?void 0:o.domainAllowList)??"",secrets:((x=(l=n.networking)==null?void 0:l.secrets)==null?void 0:x.map(d=>({...d,hosts:[...d.hosts]})))??[],environmentVariables:Object.entries(n.environmentVariables??{}).map(([d,h])=>({key:d,value:h}))}}function Ue(n){const c=Number(n.cpu),a=Number(n.memory),r=Number(n.disk),i=Object.fromEntries(n.environmentVariables.map(o=>[o.key.trim(),o.value]).filter(([o,l])=>o.length>0&&l.length>0)),s=n.networkBlockAll?void 0:n.secrets.map(o=>({env:o.env.trim(),value:o.value,hosts:o.hosts.map(l=>l.trim()).filter(l=>l.length>0)})).filter(o=>o.env.length>0&&o.value.length>0);return{name:n.name.trim(),...n.description.trim().length===0?{}:{description:n.description.trim()},...n.buildScript.trim().length===0?{}:{image:{type:"build",buildScript:n.buildScript}},resources:{cpu:Number.isFinite(c)&&c>0?c:1,memory:Number.isFinite(a)&&a>0?a:1,disk:Number.isFinite(r)&&r>0?r:3},...Object.keys(i).length===0?{}:{environmentVariables:i},networking:n.networkBlockAll?{networkBlockAll:!0}:{networkBlockAll:!1,...n.domainAllowList.trim().length===0?{}:{domainAllowList:n.domainAllowList.trim()},...s==null||s.length===0?{}:{secrets:s}}}}function Qe(n){const c=n.name.trim();if(c.length===0)return"Name is required";if(X(c))return`Name "${qe}" is reserved`;const a=Number(n.cpu),r=Number(n.memory),i=Number(n.disk);if(!Number.isFinite(a)||a<=0)return"CPU must be a positive number";if(!Number.isFinite(r)||r<=0)return"Memory must be a positive number";if(!Number.isFinite(i)||i<=0)return"Disk must be a positive number";if(!n.networkBlockAll){for(const s of n.secrets)if(s.env.trim().length!==0&&s.value.trim().length===0)return"Secret value is required"}return null}var v="w-full rounded-md border border-border bg-input-box-bg px-2.5 py-1.5 text-sm text-text-primary placeholder:text-text-secondary/70 outline-none focus:border-primary-button-bg",ce="text-sm font-medium text-text-primary",O="rounded-lg border border-border p-4 flex flex-col gap-4";function Ye({values:n,onChange:c,nameDisabled:a,readOnly:r=!1}){const i=s=>c({...n,...s});return e.jsxs("fieldset",{disabled:r,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0 pb-8",children:[e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:ce,children:"Name"}),e.jsx("input",{className:z(v,a&&"opacity-70"),value:n.name,disabled:a,placeholder:"my-environment",onChange:s=>i({name:s.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:ce,children:"Description"}),e.jsx("textarea",{className:z(v,"min-h-20 resize-y"),value:n.description,placeholder:"write description ...",onChange:s=>i({description:s.target.value})})]}),e.jsxs("div",{className:O,children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Image And Resources"}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Build Script"}),e.jsx("textarea",{className:z(v,"min-h-24 resize-y font-mono text-xs"),value:n.buildScript,placeholder:`set -ex
2
2
  pip install httpx
3
3
  `,onChange:s=>i({buildScript:s.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"CPU"}),e.jsx("input",{className:v,type:"number",min:.1,step:"any",value:n.cpu,placeholder:"type...",onChange:s=>i({cpu:s.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Memory (GB)"}),e.jsx("input",{className:v,type:"number",min:.1,step:"any",value:n.memory,placeholder:"type...",onChange:s=>i({memory:s.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Disk (GB)"}),e.jsx("input",{className:v,type:"number",min:.1,step:"any",value:n.disk,placeholder:"type...",onChange:s=>i({disk:s.target.value})})]})]})]}),e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Environment Variables"}),e.jsx("button",{type:"button",className:"cursor-pointer text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",onClick:()=>i({environmentVariables:[...n.environmentVariables,{key:"",value:""}]}),children:"+ Add Variables"})]}),n.environmentVariables.map((s,o)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("input",{className:v,value:s.key,placeholder:"KEY",onChange:l=>{const x=n.environmentVariables.map((d,h)=>h===o?{...d,key:l.target.value}:d);i({environmentVariables:x})}}),e.jsx("input",{className:v,value:s.value,placeholder:"value",onChange:l=>{const x=n.environmentVariables.map((d,h)=>h===o?{...d,value:l.target.value}:d);i({environmentVariables:x})}})]}),e.jsx("button",{type:"button",className:J({variant:"ghost",size:"icon"}),"aria-label":"Remove environment variable",onClick:()=>i({environmentVariables:n.environmentVariables.filter((l,x)=>x!==o)}),children:e.jsx(D,{name:"trash",className:"size-3.5 text-failure-bg"})})]},o))]}),e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Block All Network"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Overrides the domain allow list"})]}),e.jsx(He,{checked:n.networkBlockAll,onCheckedChange:s=>i({networkBlockAll:s}),"aria-label":"Block All Network"})]}),n.networkBlockAll?null:e.jsxs("label",{className:"flex flex-col gap-1.5 pt-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Domain Allow List"}),e.jsx("input",{className:v,value:n.domainAllowList,placeholder:"api.github.com,api.openai.com",onChange:s=>i({domainAllowList:s.target.value})})]})]}),n.networkBlockAll?null:e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Secrets"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["Synced immediately with existing sandboxes."," ",e.jsxs("a",{href:"https://trueforge.dev/sandbox#how-changes-reach-a-running-session",target:"_blank",rel:"noreferrer",className:"text-primary-button-bg inline-flex items-center gap-1 hover:underline",children:["Learn more",e.jsx(D,{name:"external-link",className:"size-3"})]})]})]}),e.jsx("button",{type:"button",className:"cursor-pointer text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",onClick:()=>i({secrets:[...n.secrets,{env:"",value:"",hosts:[]}]}),children:"+ Add Secret"})]}),n.secrets.map((s,o)=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("input",{className:v,value:s.env,placeholder:"ENV_NAME",onChange:l=>{const x=n.secrets.map((d,h)=>h===o?{...d,env:l.target.value}:d);i({secrets:x})}}),e.jsx("input",{className:v,type:"password",value:s.value,placeholder:"value",onChange:l=>{const x=n.secrets.map((d,h)=>h===o?{...d,value:l.target.value}:d);i({secrets:x})}})]}),e.jsx("button",{type:"button",className:J({variant:"ghost",size:"icon"}),"aria-label":"Remove secret",onClick:()=>i({secrets:n.secrets.filter((l,x)=>x!==o)}),children:e.jsx(D,{name:"trash",className:"size-3.5 text-failure-bg"})})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("input",{className:v,value:s.hosts.join(","),placeholder:"api.github.com,api.openai.com",onChange:l=>{const x=l.target.value.split(",").map(h=>h.trim()),d=n.secrets.map((h,w)=>w===o?{...h,hosts:x}:h);i({secrets:d})}}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Hosts allowed to resolve secret (comma-separated)."})]})]},o))]})]})}function $e({open:n,onOpenChange:c,mode:a,environment:r,readOnly:i=!1,onSaved:s}){const o=de(),l=me(),x=ue(),[d,h]=u.useState(()=>oe(le())),[w,E]=u.useState(!1),[P,f]=u.useState(null);u.useEffect(()=>{if(!n){f(null),E(!1);return}const p=a==="edit"&&r!=null?r.manifest:le();h(oe(p)),f(null)},[n,a,r]);const B=async p=>{p.preventDefault(),f(null);const k=Qe(d);if(k!=null){f(k);return}E(!0);try{const N=Ue(d),b=a==="create"?await o.createEnvironment({manifest:N}):await o.createOrUpdateEnvironment({manifest:N});x(a==="create"?W.Environment.CREATED:W.Environment.EDITED,{environment_name:b.name,environment_id:b.id}),l==null||l.showSuccess({title:a==="create"?"Environment created":"Environment updated"}),s==null||s(),c(!1)}catch(N){f(xe(N,"Failed to save environment")),l==null||l.showError(N)}finally{E(!1)}},y=a==="create"?"New environment":(r==null?void 0:r.name)??"Edit environment";return e.jsx(Ge,{open:n,onOpenChange:c,title:y,description:i?"View the environment configuration.":"Configure the environment.",size:"xl",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(V.Secondary,{type:"button",disabled:w,onClick:()=>c(!1),children:i?"Close":"Cancel"}),i?null:e.jsx(V.Primary,{type:"submit",form:"environment-form",disabled:w,children:w?"Saving…":a==="create"?"Create":"Save"})]}),children:e.jsxs("form",{id:"environment-form",className:"flex min-h-0 flex-1 flex-col gap-4 px-5 pt-4 pb-10",onSubmit:p=>void B(p),children:[P!=null?e.jsx("p",{className:"text-sm text-failure-bg",children:P}):null,e.jsx(Ye,{values:d,onChange:h,nameDisabled:a==="edit",readOnly:i})]})})}var Ke={pending:{label:"Building",variant:"info",icon:"loader"},ready:{label:"Ready",variant:"success",icon:"check"},failed:{label:"Failed",variant:"destructive",icon:"triangle-exclamation"}};function Ze({status:n,statusReason:c}){const a=Ke[n],r=e.jsxs(Z,{variant:a.variant,shape:"rounded",size:"sm",children:[e.jsx(D,{name:a.icon,className:a.icon==="loader"?"size-3.5 shrink-0 animate-spin":"size-3.5 shrink-0"}),a.label]});return n==="failed"&&c!=null&&c.length>0?e.jsx(_,{content:c,children:r}):r}var Je=[10,25],We=1e4;function K(n){return Math.min(Math.max(n,1),25)}function Xe({environment:n,canManage:c,canDelete:a,canSetDefault:r}){const i=c?void 0:"You do not have permission to manage this environment.",s=X(n.name);return{edit:s?"This environment is provided by the platform and cannot be edited.":i,setDefault:i??(r?n.isDefault?"Already the default.":n.enabled?n.status!=="ready"?"Only a ready environment can be the default.":void 0:"Enable the environment before making it the default.":"Only admins can choose the default environment."),toggleEnabled:i??(n.isDefault&&n.enabled?"The default environment cannot be disabled. Make another one the default first.":void 0),delete:s?"This environment is provided by the platform and cannot be deleted.":n.isDefault?"The default environment cannot be deleted. Make another one the default first.":a?void 0:"You do not have permission to delete this environment."}}function I({label:n,icon:c,reason:a,className:r,onClick:i}){const s=e.jsxs(Fe,{className:z("whitespace-nowrap",r),disabled:a!==void 0,onClick:i,children:[e.jsx(D,{name:c,className:"size-3.5"}),n]});return a===void 0?s:e.jsx(_,{content:a,side:"left",className:"max-w-xs whitespace-normal text-left",interactive:!1,children:e.jsx("span",{className:"block w-full",children:s})})}function sn(n){const c=de(),a=Ne(),r=me(),i=ue(),{canCreateSandboxEnvironment:s,loading:o}=je(),[l,x]=u.useState([]),{allows:d}=ye({resourceType:"sandbox_environment",resourceIds:l.map(t=>t.id)}),[h,w]=u.useState(!0),[E,P]=u.useState(null),[f,B]=u.useState(()=>Q(window.location.search).q??""),[y,p]=u.useState({kind:"closed"}),[k,N]=u.useState(null),[b,he]=u.useState(()=>K(Ie)),[R,L]=u.useState(void 0),[F,ee]=u.useState(void 0),[G,H]=u.useState(void 0),M=u.useRef(0),ne=u.useRef(!1),te=u.useRef((a==null?void 0:a.settingsOpen)??!1),q=(a==null?void 0:a.settingsOpen)??!1,S=u.useCallback(async({token:t,size:m,silent:j=!1})=>{const C=++M.current;j||(w(!0),P(null));try{const g=await c.listEnvironments({limit:K(m),...t===void 0||t===""?{}:{pageToken:t}});if(C!==M.current)return;x(g.data),ee(g.nextPageToken),H(g.previousPageToken)}catch(g){if(C!==M.current)return;j||(P(xe(g,"Check your connection and try again.")),x([]),ee(void 0),H(void 0))}finally{C===M.current&&!j&&w(!1)}},[c]);u.useEffect(()=>{Y({q:f.trim().length===0?null:f})},[f]),u.useEffect(()=>{S({token:R,size:b})},[S,b,R]),u.useEffect(()=>{te.current&&!q&&S({token:R,size:b}),te.current=q},[q,S,R,b]),u.useEffect(()=>{const t=l.filter(j=>j.status==="pending");if(t.length===0)return;const m=window.setInterval(async()=>{try{const C=(await Promise.all(t.map(g=>c.getEnvironment({name:g.name}).catch(()=>null)))).filter(g=>g!=null);if(C.length===0)return;x(g=>g.map(ae=>C.find(be=>be.name===ae.name)??ae)),C.some(g=>g.status!=="pending")&&(a==null||a.invalidateEnvironmentsList())}catch{}},We);return()=>window.clearInterval(m)},[l,c,a]),u.useEffect(()=>{if(o)return;const t=Q(window.location.search);if(!ne.current&&t.isNew){ne.current=!0,Y({isNew:null}),p(s?{kind:"create"}:m=>m.kind==="create"?{kind:"closed"}:m);return}s||p(m=>m.kind==="create"?{kind:"closed"}:m)},[s,o]),u.useEffect(()=>{const t=()=>{const m=Q(window.location.search);B(m.q??""),m.isNew&&(o||(Y({isNew:null}),s&&p({kind:"create"})))};return window.addEventListener(ie,t),()=>window.removeEventListener(ie,t)},[s,o]);const U=u.useMemo(()=>{const t=f.trim().toLowerCase();return t.length===0?l:l.filter(m=>m.name.toLowerCase().includes(t)||m.description.toLowerCase().includes(t))},[l,f]),pe=y.kind==="edit"&&(X(y.environment.name)||!d(y.environment.id,"MANAGE")),fe=F!=null||G!=null||l.length>0,ge=()=>{s&&p({kind:"create"})},ve=async()=>{if(k==null)return;const t=k;N(null);try{await c.deleteEnvironment({name:t.name}),i(W.Environment.DELETED,{environment_name:t.name,environment_id:t.id}),r==null||r.showSuccess({title:"Environment deleted"}),L(void 0),a==null||a.invalidateEnvironmentsList(),S({token:void 0,size:b})}catch(m){r==null||r.showError(m)}},se=async({change:t,title:m})=>{try{await t(),r==null||r.showSuccess({title:m}),a==null||a.invalidateEnvironmentsList(),S({token:R,size:b})}catch(j){r==null||r.showError(j)}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(ke,{title:"Environments",end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-64",children:e.jsx(we,{query:f,setQuery:B,placeholder:"Search environments by name"})}),e.jsx(_,{content:s||o?void 0:"Only admins can create sandbox environments",children:e.jsx("span",{className:"inline-flex",children:e.jsxs(V.Primary,{type:"button",onClick:ge,disabled:!s,children:[e.jsx(D,{name:"plus",className:"size-3.5"}),"New Environment"]})})})]})}),e.jsx("div",{className:z("min-h-0 flex-1 overflow-auto px-4 py-4",E!=null?"flex flex-col":void 0),children:E!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx($,{title:"Couldn't load environments",description:E,className:"h-auto min-h-0 flex-none py-0"})}):h?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading environments",children:Array.from({length:5},(t,m)=>e.jsx(Ee,{className:"h-12 w-full rounded-md"},m))}):l.length===0?e.jsx($,{title:"No environments yet",description:"Create an environment to customize sandbox images, resources, and networking.",className:"min-h-full"}):U.length===0?e.jsx($,{title:"No environments found",description:e.jsxs(e.Fragment,{children:["No environments match ",e.jsx(Se,{children:f.trim()}),"."]}),className:"min-h-full"}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(Ce,{className:"min-w-240",children:[e.jsx(Ae,{children:e.jsxs(re,{className:"hover:bg-transparent",children:[e.jsx(A,{className:"w-96 max-w-96",children:"Name"}),e.jsx(A,{children:"Availability"}),e.jsx(A,{children:"Build Status"}),e.jsx(A,{children:"Resources"}),e.jsx(A,{children:"Networking"}),e.jsx(A,{children:"Updated"}),e.jsx(A,{className:"w-16"})]})}),e.jsx(Te,{children:U.map(t=>{const m=Xe({environment:t,canManage:d(t.id,"MANAGE"),canDelete:d(t.id,"DELETE"),canSetDefault:s});return e.jsxs(re,{className:"cursor-pointer",onClick:()=>p({kind:"edit",environment:t}),children:[e.jsx(T,{className:"w-96 max-w-96",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.name}),t.isDefault?e.jsx(_,{content:"Agents that do not pick an environment run in this one.",className:"max-w-xs whitespace-normal text-left",triggerClassName:"shrink-0",children:e.jsx(Z,{variant:"info",shape:"pill",children:"Default"})}):null]}),t.description.length>0?e.jsx(_,{content:t.description,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate text-xs text-text-secondary",children:t.description})}):null]})}),e.jsx(T,{children:e.jsx(Z,{variant:t.enabled?"success":"outline",shape:"pill",dot:!0,children:t.enabled?"Enabled":"Disabled"})}),e.jsx(T,{children:e.jsx(Ze,{status:t.status,statusReason:t.statusReason})}),e.jsx(T,{className:"text-sm text-text-secondary",children:De(t.manifest.resources)}),e.jsx(T,{className:"text-sm text-text-secondary",children:Pe(t.manifest.networking)}),e.jsx(T,{className:"text-sm text-text-secondary",children:Re(t.updatedAt)}),e.jsx(T,{onClick:j=>j.stopPropagation(),children:e.jsxs(Le,{align:"end",className:"min-w-48",trigger:e.jsx("button",{type:"button",className:J({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(D,{name:"ellipsis-vertical",className:"size-3.5"})}),children:[e.jsx(I,{label:"Edit",icon:"pencil",reason:m.edit,onClick:()=>p({kind:"edit",environment:t})}),e.jsx(I,{label:"Set as default",icon:"check",reason:m.setDefault,onClick:()=>void se({change:()=>c.setDefaultEnvironment({name:t.name}),title:`“${t.name}” is now the default`})}),e.jsx(I,{label:t.enabled?"Disable":"Enable",icon:t.enabled?"circle-xmark":"circle-check",reason:m.toggleEnabled,onClick:()=>void se({change:()=>c.setEnvironmentEnabled({name:t.name,enabled:!t.enabled}),title:t.enabled?"Environment disabled":"Environment enabled"})}),e.jsx(I,{label:"Delete",icon:"trash",className:"text-failure-bg focus-visible:text-failure-bg",reason:m.delete,onClick:()=>N(t)})]})})]},t.id)})})]}),fe?e.jsx(_e,{pageSize:b,rowCount:U.length,canPrev:G!=null,canNext:F!=null,onPrev:()=>L(G),onNext:()=>L(F),pageSizeOptions:Je,onPageSizeChange:t=>{he(K(t)),L(void 0),H(void 0)}}):null]})}),e.jsx($e,{open:y.kind!=="closed",mode:y.kind==="edit"?"edit":"create",...y.kind==="edit"?{environment:y.environment,readOnly:pe}:{},onOpenChange:t=>{t||p({kind:"closed"})},onSaved:()=>{L(void 0),a==null||a.invalidateEnvironmentsList(),S({token:void 0,size:b})}}),e.jsx(Ve,{open:k!=null,onOpenChange:t=>!t&&N(null),children:e.jsxs(ze,{children:[e.jsx(Be,{children:e.jsx(Me,{children:"Delete environment"})}),e.jsxs("p",{className:"text-sm text-text-secondary",children:["Delete ",e.jsx("span",{className:"font-medium text-text-primary",children:k==null?void 0:k.name}),"? This cannot be undone. Delete fails if any agent still references the environment."]}),e.jsxs(Oe,{children:[e.jsx(V.Secondary,{type:"button",onClick:()=>N(null),children:"Cancel"}),e.jsx(V.Primary,{type:"button",onClick:()=>void ve(),children:"Delete"})]})]})})]})}export{sn as EnvironmentsPage,We as PENDING_ENVIRONMENTS_POLL_INTERVAL_MS};
@@ -1 +1 @@
1
- import{ab as X,b as ee,br as te,bA as se,bz as re,p as ae,q as ne,r,x as k,j as e,ao as le,I as R,E as T,_ as F,bG as ie,aa as oe}from"./index-lhOueW4w.js";var V=oe("h-11 shadow-sm"),de=({open:y,onOpenChange:p,onSave:E,title:c,description:o,initialServerUrl:a="",requireApiKey:m=!0,busy:M=!1,error:n})=>{const[u,h]=r.useState(""),[N,f]=r.useState(a);r.useEffect(()=>{y&&(h(""),f(a))},[y,a]);const x=i=>{i||(h(""),f(a)),p(i)},b=u.trim(),g=!m||!!b,S=async i=>{if(i.preventDefault(),!(!g||M))try{await E({apiKey:b,serverUrl:N.trim()}),p(!1)}catch{}};return e.jsx(ie,{open:y,onOpenChange:x,title:c,description:o,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(R,{name:"brain",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:S,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",m?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"memory-provider-api-key",type:"password",required:m,value:u,onChange:i=>{h(i.target.value)},placeholder:m?"Zep API key":"Leave blank to keep existing",autoFocus:!0,className:V})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Server URL ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"memory-provider-server-url",type:"url",value:N,onChange:i=>{f(i.target.value)},placeholder:"Leave blank for Zep Cloud",className:V})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[n?e.jsx("p",{className:"text-failure-bg text-sm",children:n}):null,e.jsx(T.Primary,{type:"submit",size:"large",disabled:!g||M,className:"w-full shrink-0",children:"Save"})]})]})})},ce=de,me=()=>{var B,D;const y=X(),p=(B=ee())==null?void 0:B.settings,E=te(),c=se(),o=re(),a=ae(),m=ne(),n=E&&((D=p==null?void 0:p.memoryProviders)==null?void 0:D.manageProviders)!==!1?y==null?void 0:y.memoryCatalog:void 0,[u,h]=r.useState(null),[N,f]=r.useState(!1),[x,b]=r.useState([]),[g,S]=r.useState([]),[i,P]=r.useState(!0),[_,v]=r.useState(null),[$,j]=r.useState(null),[U,L]=r.useState(!1),[d,w]=r.useState(null),[l,C]=r.useState(null),A=r.useCallback(async({quiet:t=!1}={})=>{if(!n){b([]),S([]),P(!1);return}t||P(!0),v(null);try{const[s,W]=await Promise.all([n.listMemoryProviders(),n.getMemoryProviderCatalog()]);b(s),S(W)}catch(s){v(k(s,"Failed to load memory providers"))}finally{t||P(!1)}},[n]);r.useEffect(()=>{A()},[A]),r.useEffect(()=>{if(!o)return;let t=!1;return o.getConfiguration().then(s=>{t||h(s.memory.enabled)}).catch(s=>{t||v(k(s,"Failed to load the memory setting"))}),()=>{t=!0}},[o]);const I=x.length>0,O=r.useMemo(()=>{if(I)return[];const t=new Set(x.map(s=>s.catalogId));return g.filter(s=>!t.has(s.id))},[g,x,I]);if(n==null&&o==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Memory settings are not available."});const G=async t=>{if(o){f(!0),v(null);try{const s=await o.updateConfiguration({memory:{enabled:t}});h(s.memory.enabled),c==null||c(),a==null||a.showSuccess({title:s.memory.enabled?"Memory turned on":"Memory turned off"}),m(F.Settings.MEMORY_TENANT_TOGGLED,{enabled:s.memory.enabled})}catch(s){v(k(s,"Failed to save the memory setting"))}finally{f(!1)}}},K=async t=>{L(!0),j(null);try{await t(),await A({quiet:!0}),c==null||c()}catch(s){throw j(k(s,"Request failed")),s}finally{L(!1)}},Y=async t=>{!d||!n||(await K(async()=>{await n.createMemoryProvider({catalogId:d.id,name:d.name,type:d.type,apiKey:t.apiKey,...t.serverUrl===""?{}:{serverUrl:t.serverUrl}})}),w(null),a==null||a.showSuccess({title:`${d.name} configured`}),m(F.Settings.MEMORY_PROVIDER_SAVED,{provider_name:d.name,mode:"create"}))},Z=async t=>{!l||!n||(await K(async()=>{await n.updateMemoryProvider({id:l.id,...t.apiKey===""?{}:{apiKey:t.apiKey},...t.serverUrl===""?{}:{serverUrl:t.serverUrl}})}),C(null),a==null||a.showSuccess({title:`${l.name} updated`}),m(F.Settings.MEMORY_PROVIDER_SAVED,{provider_name:l.name,mode:"update"}))},q=o==null||u!==null,H=n!=null&&q&&u!==!1,J=d!=null||l!=null,z=l!=null,Q=l?`Update ${l.name}`:d?`Configure ${d.name}`:"Configure memory provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Memory"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Let TrueForge personalize your conversations based on your past chats."}),_?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:_}):null,u!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow memory"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:u?"Agents may remember details from past chats.":"Agents cannot use memory, including in chats that already had it."})]}),e.jsx(le,{checked:u,disabled:N,"aria-label":"Allow memory",onCheckedChange:t=>{G(t)}})]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:H?i?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading memory providers…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can remember details. Only one can be active at a time."}),x.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",x.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:x.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(R,{name:"brain",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:t.serverUrl??"Zep Cloud"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(T.Secondary,{size:"small",type:"button",disabled:U,onClick:()=>{j(null),w(null),C(t)},children:"Update"})]})]},t.id))})]}):null,I?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",O.length]}),O.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:"No memory providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:O.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(R,{name:"brain",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})]}),e.jsx(T.Secondary,{type:"button",disabled:U,onClick:()=>{j(null),C(null),w(t)},children:"Configure"})]},t.id))})]})]}):null}),e.jsx(ce,{open:J,onOpenChange:t=>{t||(j(null),w(null),C(null))},onSave:z?Z:Y,title:Q,description:z?"Update this memory provider. Leave API key blank to keep the existing key.":"Configure this memory provider. API key is never stored in the catalog.",initialServerUrl:(l==null?void 0:l.serverUrl)??"",requireApiKey:!z,busy:U,error:$})]})},xe=me;export{xe as default};
1
+ import{ab as X,b as ee,br as te,bA as se,bz as re,p as ae,q as ne,r,x as k,j as e,ao as le,I as R,E as T,_ as F,bG as ie,aa as oe}from"./index-CVbSocf1.js";var V=oe("h-11 shadow-sm"),de=({open:y,onOpenChange:p,onSave:E,title:c,description:o,initialServerUrl:a="",requireApiKey:m=!0,busy:M=!1,error:n})=>{const[u,h]=r.useState(""),[N,f]=r.useState(a);r.useEffect(()=>{y&&(h(""),f(a))},[y,a]);const x=i=>{i||(h(""),f(a)),p(i)},b=u.trim(),g=!m||!!b,S=async i=>{if(i.preventDefault(),!(!g||M))try{await E({apiKey:b,serverUrl:N.trim()}),p(!1)}catch{}};return e.jsx(ie,{open:y,onOpenChange:x,title:c,description:o,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(R,{name:"brain",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:S,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",m?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"memory-provider-api-key",type:"password",required:m,value:u,onChange:i=>{h(i.target.value)},placeholder:m?"Zep API key":"Leave blank to keep existing",autoFocus:!0,className:V})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Server URL ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"memory-provider-server-url",type:"url",value:N,onChange:i=>{f(i.target.value)},placeholder:"Leave blank for Zep Cloud",className:V})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[n?e.jsx("p",{className:"text-failure-bg text-sm",children:n}):null,e.jsx(T.Primary,{type:"submit",size:"large",disabled:!g||M,className:"w-full shrink-0",children:"Save"})]})]})})},ce=de,me=()=>{var B,D;const y=X(),p=(B=ee())==null?void 0:B.settings,E=te(),c=se(),o=re(),a=ae(),m=ne(),n=E&&((D=p==null?void 0:p.memoryProviders)==null?void 0:D.manageProviders)!==!1?y==null?void 0:y.memoryCatalog:void 0,[u,h]=r.useState(null),[N,f]=r.useState(!1),[x,b]=r.useState([]),[g,S]=r.useState([]),[i,P]=r.useState(!0),[_,v]=r.useState(null),[$,j]=r.useState(null),[U,L]=r.useState(!1),[d,w]=r.useState(null),[l,C]=r.useState(null),A=r.useCallback(async({quiet:t=!1}={})=>{if(!n){b([]),S([]),P(!1);return}t||P(!0),v(null);try{const[s,W]=await Promise.all([n.listMemoryProviders(),n.getMemoryProviderCatalog()]);b(s),S(W)}catch(s){v(k(s,"Failed to load memory providers"))}finally{t||P(!1)}},[n]);r.useEffect(()=>{A()},[A]),r.useEffect(()=>{if(!o)return;let t=!1;return o.getConfiguration().then(s=>{t||h(s.memory.enabled)}).catch(s=>{t||v(k(s,"Failed to load the memory setting"))}),()=>{t=!0}},[o]);const I=x.length>0,O=r.useMemo(()=>{if(I)return[];const t=new Set(x.map(s=>s.catalogId));return g.filter(s=>!t.has(s.id))},[g,x,I]);if(n==null&&o==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Memory settings are not available."});const G=async t=>{if(o){f(!0),v(null);try{const s=await o.updateConfiguration({memory:{enabled:t}});h(s.memory.enabled),c==null||c(),a==null||a.showSuccess({title:s.memory.enabled?"Memory turned on":"Memory turned off"}),m(F.Settings.MEMORY_TENANT_TOGGLED,{enabled:s.memory.enabled})}catch(s){v(k(s,"Failed to save the memory setting"))}finally{f(!1)}}},K=async t=>{L(!0),j(null);try{await t(),await A({quiet:!0}),c==null||c()}catch(s){throw j(k(s,"Request failed")),s}finally{L(!1)}},Y=async t=>{!d||!n||(await K(async()=>{await n.createMemoryProvider({catalogId:d.id,name:d.name,type:d.type,apiKey:t.apiKey,...t.serverUrl===""?{}:{serverUrl:t.serverUrl}})}),w(null),a==null||a.showSuccess({title:`${d.name} configured`}),m(F.Settings.MEMORY_PROVIDER_SAVED,{provider_name:d.name,mode:"create"}))},Z=async t=>{!l||!n||(await K(async()=>{await n.updateMemoryProvider({id:l.id,...t.apiKey===""?{}:{apiKey:t.apiKey},...t.serverUrl===""?{}:{serverUrl:t.serverUrl}})}),C(null),a==null||a.showSuccess({title:`${l.name} updated`}),m(F.Settings.MEMORY_PROVIDER_SAVED,{provider_name:l.name,mode:"update"}))},q=o==null||u!==null,H=n!=null&&q&&u!==!1,J=d!=null||l!=null,z=l!=null,Q=l?`Update ${l.name}`:d?`Configure ${d.name}`:"Configure memory provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Memory"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Let TrueForge personalize your conversations based on your past chats."}),_?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:_}):null,u!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow memory"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:u?"Agents may remember details from past chats.":"Agents cannot use memory, including in chats that already had it."})]}),e.jsx(le,{checked:u,disabled:N,"aria-label":"Allow memory",onCheckedChange:t=>{G(t)}})]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:H?i?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading memory providers…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can remember details. Only one can be active at a time."}),x.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",x.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:x.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(R,{name:"brain",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:t.serverUrl??"Zep Cloud"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(T.Secondary,{size:"small",type:"button",disabled:U,onClick:()=>{j(null),w(null),C(t)},children:"Update"})]})]},t.id))})]}):null,I?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",O.length]}),O.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:"No memory providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:O.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(R,{name:"brain",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})]}),e.jsx(T.Secondary,{type:"button",disabled:U,onClick:()=>{j(null),C(null),w(t)},children:"Configure"})]},t.id))})]})]}):null}),e.jsx(ce,{open:J,onOpenChange:t=>{t||(j(null),w(null),C(null))},onSave:z?Z:Y,title:Q,description:z?"Update this memory provider. Leave API key blank to keep the existing key.":"Configure this memory provider. API key is never stored in the catalog.",initialServerUrl:(l==null?void 0:l.serverUrl)??"",requireApiKey:!z,busy:U,error:$})]})},xe=me;export{xe as default};
@@ -1 +1 @@
1
- import{C as we}from"./chunk-F62I374W-Dwa1z7Cl.js";import{bE as Ee,p as Ce,q as ke,r as l,x as J,j as e,S as Se,E as B,I as T,bF as fe,bG as ye,bH as Me,bI as Le,c as P,bJ as Pe,_ as de,aa as Te}from"./index-lhOueW4w.js";var ve=Te("h-11 shadow-sm"),Ue=({open:a,onOpenChange:i,onSave:f,title:j,description:N,initialBaseUrl:g="",baseUrlPlaceholder:h="https://api.openai.com/v1",requireApiKey:o=!0,submitLabel:K="Save",busy:M=!1,error:I})=>{const[$,C]=l.useState(""),[q,x]=l.useState(""),[p,A]=l.useState(!1),U=()=>{C(""),x(""),A(!1)};l.useEffect(()=>{a&&(C(""),x(g),A(!1))},[a,g]);const H=d=>{d||U(),i(d)},R=$.trim(),_=!o||!!R,Z=async d=>{if(d.preventDefault(),!(!_||M))try{await f({apiKey:R,baseUrl:q.trim()}),U(),i(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:H,title:j,description:N,contentSized:!0,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:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",o?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:o,value:$,onChange:d=>{C(d.target.value)},placeholder:o?"Enter API key":"Enter a new key",autoFocus:!0,className:ve}),o?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(Me,{expanded:p,onChange:(d,ae)=>A(ae),className:"rounded-md border border-border",children:[e.jsx(Le,{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(T,{name:"chevron-down",className:P("size-4 shrink-0 text-text-secondary transition-transform duration-200",p?"rotate-0":"-rotate-90")})]})}),e.jsxs(Pe,{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:q,onChange:d=>{x(d.target.value)},placeholder:h,className:ve}),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:[I?e.jsx("p",{className:"text-failure-bg text-sm",children:I}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!_||M,className:"w-full shrink-0",children:K})]})]})})},Re=Ue,Oe="128000",De="4096",je=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ge=a=>(a==null?void 0:a.models.map(i=>{var f,j,N,g,h;return{id:i.id,name:i.name,advancedExpanded:!0,reasoningEfforts:(f=i.properties)==null?void 0:f.reasoningEfforts,contextLength:((N=(j=i.properties)==null?void 0:j.contextLength)==null?void 0:N.toString())??"",maxOutputTokens:((h=(g=i.properties)==null?void 0:g.maxOutputTokens)==null?void 0:h.toString())??"",nameDirty:!0}}))??[je()],W="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",se="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function pe(a){const i=a.trim();if(i==="")return null;const f=Number(i);return Number.isInteger(f)&&f>0?f:null}function Ie(a){return a.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var ie=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),re=({children:a})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:a}),ce=({children:a})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:a}),$e=({open:a,onOpenChange:i,onSubmit:f,reasoningEffortOptions:j,busy:N=!1,error:g,isEditMode:h=!1,initialValues:o})=>{const[K,M]=l.useState((o==null?void 0:o.name)??""),[I,$]=l.useState((o==null?void 0:o.baseUrl)??""),[C,q]=l.useState(""),[x,p]=l.useState(()=>ge(o)),[A,U]=l.useState(!1),[H,R]=l.useState(!1),_=()=>{M((o==null?void 0:o.name)??""),$((o==null?void 0:o.baseUrl)??""),q(""),p(ge(o)),U(!1),R(!1)},Z=s=>{s||_(),i(s)},d=(s,r)=>{p(y=>y.map((m,b)=>b===s?{...m,...r}:m))},ae=()=>{U(!0),R(!0),p(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},Y=K.trim(),v=Y?null:"Name is required.",z=I.trim();let k=null;if(!z)k="Base URL is required.";else try{new URL(z)}catch{k="Enter a valid URL."}const G=s=>s.id.trim()?null:"Model ID is required.",me=s=>s.name.trim()?null:"Model name is required.",O=s=>pe(s.contextLength)==null?"Set the model's context window.":null,ne=s=>pe(s.maxOutputTokens)==null?"Set the max output tokens.":null,w=!v&&!k&&x.every(s=>!G(s)&&!me(s)),Q=A&&v,V=H&&k,oe=async()=>{if(ae(),!w||N)return;const s=x.findIndex(r=>O(r)||ne(r));if(s!==-1){d(s,{advancedExpanded:!0});const r=x[s],y=r&&O(r)?"context-length":"max-output-tokens";setTimeout(()=>{var b;const m=document.getElementById(`custom-provider-model-${s}-${y}`);(b=m==null?void 0:m.scrollIntoView)==null||b.call(m,{block:"center",behavior:"smooth"}),m==null||m.focus()},0);return}try{await f({name:Y,baseUrl:z,apiKey:C.trim(),models:x.map(r=>{var F;const y={};(F=r.reasoningEfforts)!=null&&F.length&&(y.reasoningEfforts=r.reasoningEfforts);const m=pe(r.contextLength);m!=null&&(y.contextLength=m);const b=pe(r.maxOutputTokens);return b!=null&&(y.maxOutputTokens=b),{id:r.id.trim(),name:r.name.trim(),...Object.keys(y).length>0?{properties:y}:{}}})}),Z(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:Z,title:h?`Edit ${(o==null?void 0:o.name)??K}`:"Add custom provider",description:h?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-auto flex-col",onSubmit:s=>{s.preventDefault(),oe()},children:[e.jsxs("div",{className:"min-h-0 flex-auto space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(ie,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:K,onChange:s=>M(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!h,readOnly:h,"aria-readonly":h,"aria-invalid":Q?!0:void 0,className:P(W,h&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",Q&&se)}),h?e.jsx(ce,{children:"Provider names cannot be changed after creation."}):null,Q?e.jsx(re,{children:v}):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(ie,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:I,onChange:s=>$(s.target.value),onBlur:()=>R(!0),placeholder:"http://localhost:11434/v1",autoFocus:h,"aria-invalid":V?!0:void 0,className:P(W,V&&se)}),V?e.jsx(re,{children:k}):z?null:e.jsx(ce,{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:C,onChange:s=>q(s.target.value),placeholder:"sk-…",className:W}),e.jsx(ce,{children:h?"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(ie,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const y=G(s),m=s.idTouched&&y,b=me(s),F=!!b&&s.nameDirty,ue=O(s),xe=ne(s),ee=s.contextTouched&&ue,le=s.maxTouched&&xe;return e.jsxs("div",{className:P("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:u=>{const D=u.target.value;d(r,{id:D,...s.nameDirty?{}:{name:Ie(D)}})},onBlur:()=>d(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":m?!0:void 0,className:P(W,"font-mono",m&&se)})]}),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:u=>d(r,{name:u.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":F?!0:void 0,className:P(W,F&&se)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||N,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:()=>p(u=>u.filter((D,te)=>te!==r)),children:e.jsx(T,{name:"trash",className:"size-4"})})]}),m?e.jsx(re,{children:y}):null,F?e.jsx(re,{children:b}):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:()=>d(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(T,{name:"chevron-down",className:P("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(ie,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:u=>d(r,{contextLength:u.target.value}),onBlur:()=>d(r,{contextTouched:!0}),placeholder:Oe,"aria-invalid":ee?!0:void 0,className:P(W,ee&&se)}),ee?e.jsx(re,{children:ue}):s.contextLength.trim()===""?e.jsx(ce,{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(ie,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:u=>d(r,{maxOutputTokens:u.target.value}),onBlur:()=>d(r,{maxTouched:!0}),placeholder:De,"aria-invalid":le?!0:void 0,className:P(W,le&&se)}),le?e.jsx(re,{children:xe}):s.maxOutputTokens.trim()===""?e.jsx(ce,{children:"Longest reply the model allows — use its real limit."}):null]}),j&&j.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:N,onChange:u=>d(r,{reasoningEfforts:u.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:j.map(u=>{var te;const D=((te=s.reasoningEfforts)==null?void 0:te.includes(u))??!1;return e.jsx("button",{type:"button","aria-pressed":D,disabled:N,className:P("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",D?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var S;return d(r,{reasoningEfforts:D?(S=s.reasoningEfforts)==null?void 0:S.filter(X=>X!==u):[...s.reasoningEfforts??[],u]})},children:u},u)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>p(s=>[...s,je()]),children:[e.jsx(T,{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:[g?e.jsx("p",{className:"text-failure-bg text-sm",children:g}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!w||N,className:"w-full",children:h?"Save changes":"Add provider"})]})]})})},Ae=$e;function he(a){return a.kind==="model"&&a.provider.models.length===1}function _e(a){return a.kind==="provider"?`“${a.provider.name}” and all of its models will no longer be available to your agents.`:he(a)?`“${a.model.name}” is the only model left in ${a.provider.name}, so the whole provider will be removed.`:`“${a.model.name}” will no longer be available to your agents. The rest of ${a.provider.name} stays configured.`}function ze(a){return"baseUrl"in a&&typeof a.baseUrl=="string"?a.baseUrl:""}var Fe=()=>{const{modelCatalog:a}=Ee(),i=Ce(),f=ke(),[j,N]=l.useState(""),[g,h]=l.useState([]),[o,K]=l.useState([]),[M,I]=l.useState(!0),[$,C]=l.useState(null),[q,x]=l.useState(null),[p,A]=l.useState(!1),[U,H]=l.useState(null),[R,_]=l.useState(null),[Z,d]=l.useState(null),[ae,Y]=l.useState(!1),[v,z]=l.useState(null),[k,G]=l.useState(null),[me,O]=l.useState(null),ne=l.useMemo(()=>(o??[]).reduce((t,n)=>(t[n.name]=n.logo??"",t),{}),[o]),w=j.trim().toLowerCase(),Q=l.useCallback(async()=>{I(!0),C(null);try{const[t,n]=await Promise.all([a.listModelProviders(),a.getModelProviderCatalog()]);h(t),K(n)}catch(t){C(J(t,"Failed to load model providers"))}finally{I(!1)}},[a]);l.useEffect(()=>{Q()},[Q]);const V=l.useMemo(()=>new Set(g.map(t=>t.type)),[g]),oe=l.useMemo(()=>g.filter(t=>{var n;return((n=t.name)==null?void 0:n.toLowerCase().includes(w))||t.models.some(c=>c.name.toLowerCase().includes(w)||c.id.toLowerCase().includes(w))}),[g,w]),s=l.useMemo(()=>o.filter(t=>t.type!=="custom"&&!V.has(t.type)&&(t.name.toLowerCase().includes(w)||t.models.some(n=>n.name.toLowerCase().includes(w)||n.id.toLowerCase().includes(w)))),[o,V,w]),r=l.useMemo(()=>{var t;return(t=o.find(n=>n.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[o]),y=l.useMemo(()=>{const t=new Map;for(const n of o)t.set(n.type,n.models);return t},[o]),m=()=>{H(null),_(null),d(null)},b=async(t,n)=>{A(!0),C(null);try{await t(),await Q(),m()}catch(c){throw n?n(c):i==null?C(J(c,"Request failed")):i.showError(c),c}finally{A(!1)}},F=async(t,n)=>{d(null),await b(async()=>{await a.createModelProvider({type:t.type,name:t.name,...n.baseUrl?{baseUrl:n.baseUrl}:{},apiKey:n.apiKey,models:t.models})},c=>d(J(c,"Request failed"))),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},ue=async(t,n)=>{d(null),await b(async()=>{await a.updateModelProvider({id:t.id,type:t.type,name:t.name,...n.baseUrl?{baseUrl:n.baseUrl}:{},apiKey:n.apiKey,models:t.models})},c=>d(J(c,"Request failed"))),i==null||i.showSuccess({title:`${t.name} updated`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"update"})},xe=()=>{p||(G(null),O(null))},ee=({provider:t,models:n},c)=>b(async()=>{await a.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:n})},c),le=t=>{O(null);const n=L=>O(J(L,"Request failed"));let c;if(t.kind==="model"&&!he(t))c=ee({provider:t.provider,models:t.provider.models.filter(L=>L.id!==t.model.id)},n);else{const L=a.deleteModelProvider;L!==void 0&&(c=b(async()=>{await L({id:t.provider.id}),f(de.Settings.MODEL_PROVIDER_DELETED,{provider_name:t.provider.name})},n))}c==null||c.then(()=>G(null)).catch(()=>{})},u=async t=>{x(null),await b(async()=>{await a.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},n=>x(J(n,"Request failed"))),setTimeout(()=>{i==null||i.showSuccess({title:`${t.name} added`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},0)},D=async t=>{if(!v)return;const n=v;x(null),await b(async()=>{await a.updateModelProvider({id:n.id,type:n.type,name:n.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},c=>x(J(c,"Request failed"))),setTimeout(()=>{i==null||i.showSuccess({title:"Model provider updated",description:`${n.name} was updated successfully.`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:n.name,mode:"update"})},0)},te=v?{name:v.name,baseUrl:v.baseUrl??"",models:v.models}:void 0,S=U!=null?g.find(t=>t.id===U)??null:null,X=R!=null?o.find(t=>t.type===R)??null:null,Ne=S!=null||X!=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."}),$?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:$}):null,e.jsx("div",{className:"mt-4 min-h-0 min-w-0 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full min-w-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Se,{query:j,setQuery:N,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",className:"shrink-0 sm:self-auto",onClick:()=>{x(null),z(null),Y(!0)},children:[e.jsx(T,{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:[M?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!M&&oe.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:oe.map(t=>{const n=y.get(t.type)??[],c=new Set(t.models.map(E=>E.id)),L=n.filter(E=>!c.has(E.id)),be=ne[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:be?e.jsx(fe,{src:be,alt:t.name,className:"size-4.5"}):e.jsx(T,{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:p,onClick:()=>{t.type==="custom"?(m(),x(null),z(t),Y(!0)):(d(null),_(null),H(t.id))},children:[e.jsx(T,{name:"pencil",className:"size-3.5"}),"Edit"]}),a.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:p,onClick:()=>{O(null),G({kind:"provider",provider: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(E=>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:E.name}),t.models.length>1||a.deleteModelProvider?e.jsx("button",{type:"button","aria-label":`Remove ${E.name}`,disabled:p,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:()=>{O(null),G({kind:"model",provider:t,model:E})},children:e.jsx(T,{name:"trash",className:"size-3.5"})}):null]},E.id)),L.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 · ",L.length]}),L.map(E=>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:E.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:p,onClick:()=>{ee({provider:t,models:[...t.models,E]}).catch(()=>{})},children:"Add"})]},E.id))]}):null]})]},t.id)})})]}):null,!M&&s.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:s.map(t=>{const n=ne[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:n?e.jsx(fe,{src:n,alt:t.name,className:"size-4.5"}):e.jsx(T,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",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(c=>c.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:p,onClick:()=>{d(null),H(null),_(t.type)},children:[e.jsx(T,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!M&&oe.length===0&&s.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:w?`No providers match “${j.trim()}”.`:"No model providers yet."}):null]}),k?e.jsx(we,{title:k.kind==="model"&&!he(k)?"Remove model?":"Remove provider?",description:_e(k),busy:p,error:me,onCancel:xe,onConfirm:()=>{le(k)}}):null,e.jsx(Re,{open:Ne,onOpenChange:t=>{t||m()},onSave:t=>{if(S)return ue(S,t);if(X)return F(X,t)},title:S?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:S?S.baseUrl??"":X?ze(X):"",requireApiKey:S==null,submitLabel:S?"Save":"Create",busy:p,error:Z}),e.jsx(Ae,{open:ae,onOpenChange:t=>{Y(t),t||(x(null),z(null))},isEditMode:v!==null,initialValues:te,onSubmit:v?D:u,reasoningEffortOptions:r,busy:p,error:q},(v==null?void 0:v.id)??"add-custom-provider")]})})]})},qe=Fe;export{qe as default};
1
+ import{C as we}from"./chunk-US5DQOBQ-Bu-huQ7M.js";import{bE as Ee,p as Ce,q as ke,r as l,x as J,j as e,S as Se,E as B,I as T,bF as fe,bG as ye,bH as Me,bI as Le,c as P,bJ as Pe,_ as de,aa as Te}from"./index-CVbSocf1.js";var ve=Te("h-11 shadow-sm"),Ue=({open:a,onOpenChange:i,onSave:f,title:j,description:N,initialBaseUrl:g="",baseUrlPlaceholder:h="https://api.openai.com/v1",requireApiKey:o=!0,submitLabel:K="Save",busy:M=!1,error:I})=>{const[$,C]=l.useState(""),[q,x]=l.useState(""),[p,A]=l.useState(!1),U=()=>{C(""),x(""),A(!1)};l.useEffect(()=>{a&&(C(""),x(g),A(!1))},[a,g]);const H=d=>{d||U(),i(d)},R=$.trim(),_=!o||!!R,Z=async d=>{if(d.preventDefault(),!(!_||M))try{await f({apiKey:R,baseUrl:q.trim()}),U(),i(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:H,title:j,description:N,contentSized:!0,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:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",o?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:o,value:$,onChange:d=>{C(d.target.value)},placeholder:o?"Enter API key":"Enter a new key",autoFocus:!0,className:ve}),o?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(Me,{expanded:p,onChange:(d,ae)=>A(ae),className:"rounded-md border border-border",children:[e.jsx(Le,{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(T,{name:"chevron-down",className:P("size-4 shrink-0 text-text-secondary transition-transform duration-200",p?"rotate-0":"-rotate-90")})]})}),e.jsxs(Pe,{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:q,onChange:d=>{x(d.target.value)},placeholder:h,className:ve}),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:[I?e.jsx("p",{className:"text-failure-bg text-sm",children:I}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!_||M,className:"w-full shrink-0",children:K})]})]})})},Re=Ue,Oe="128000",De="4096",je=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ge=a=>(a==null?void 0:a.models.map(i=>{var f,j,N,g,h;return{id:i.id,name:i.name,advancedExpanded:!0,reasoningEfforts:(f=i.properties)==null?void 0:f.reasoningEfforts,contextLength:((N=(j=i.properties)==null?void 0:j.contextLength)==null?void 0:N.toString())??"",maxOutputTokens:((h=(g=i.properties)==null?void 0:g.maxOutputTokens)==null?void 0:h.toString())??"",nameDirty:!0}}))??[je()],W="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",se="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function pe(a){const i=a.trim();if(i==="")return null;const f=Number(i);return Number.isInteger(f)&&f>0?f:null}function Ie(a){return a.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var ie=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),re=({children:a})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:a}),ce=({children:a})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:a}),$e=({open:a,onOpenChange:i,onSubmit:f,reasoningEffortOptions:j,busy:N=!1,error:g,isEditMode:h=!1,initialValues:o})=>{const[K,M]=l.useState((o==null?void 0:o.name)??""),[I,$]=l.useState((o==null?void 0:o.baseUrl)??""),[C,q]=l.useState(""),[x,p]=l.useState(()=>ge(o)),[A,U]=l.useState(!1),[H,R]=l.useState(!1),_=()=>{M((o==null?void 0:o.name)??""),$((o==null?void 0:o.baseUrl)??""),q(""),p(ge(o)),U(!1),R(!1)},Z=s=>{s||_(),i(s)},d=(s,r)=>{p(y=>y.map((m,b)=>b===s?{...m,...r}:m))},ae=()=>{U(!0),R(!0),p(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},Y=K.trim(),v=Y?null:"Name is required.",z=I.trim();let k=null;if(!z)k="Base URL is required.";else try{new URL(z)}catch{k="Enter a valid URL."}const G=s=>s.id.trim()?null:"Model ID is required.",me=s=>s.name.trim()?null:"Model name is required.",O=s=>pe(s.contextLength)==null?"Set the model's context window.":null,ne=s=>pe(s.maxOutputTokens)==null?"Set the max output tokens.":null,w=!v&&!k&&x.every(s=>!G(s)&&!me(s)),Q=A&&v,V=H&&k,oe=async()=>{if(ae(),!w||N)return;const s=x.findIndex(r=>O(r)||ne(r));if(s!==-1){d(s,{advancedExpanded:!0});const r=x[s],y=r&&O(r)?"context-length":"max-output-tokens";setTimeout(()=>{var b;const m=document.getElementById(`custom-provider-model-${s}-${y}`);(b=m==null?void 0:m.scrollIntoView)==null||b.call(m,{block:"center",behavior:"smooth"}),m==null||m.focus()},0);return}try{await f({name:Y,baseUrl:z,apiKey:C.trim(),models:x.map(r=>{var F;const y={};(F=r.reasoningEfforts)!=null&&F.length&&(y.reasoningEfforts=r.reasoningEfforts);const m=pe(r.contextLength);m!=null&&(y.contextLength=m);const b=pe(r.maxOutputTokens);return b!=null&&(y.maxOutputTokens=b),{id:r.id.trim(),name:r.name.trim(),...Object.keys(y).length>0?{properties:y}:{}}})}),Z(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:Z,title:h?`Edit ${(o==null?void 0:o.name)??K}`:"Add custom provider",description:h?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-auto flex-col",onSubmit:s=>{s.preventDefault(),oe()},children:[e.jsxs("div",{className:"min-h-0 flex-auto space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(ie,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:K,onChange:s=>M(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!h,readOnly:h,"aria-readonly":h,"aria-invalid":Q?!0:void 0,className:P(W,h&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",Q&&se)}),h?e.jsx(ce,{children:"Provider names cannot be changed after creation."}):null,Q?e.jsx(re,{children:v}):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(ie,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:I,onChange:s=>$(s.target.value),onBlur:()=>R(!0),placeholder:"http://localhost:11434/v1",autoFocus:h,"aria-invalid":V?!0:void 0,className:P(W,V&&se)}),V?e.jsx(re,{children:k}):z?null:e.jsx(ce,{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:C,onChange:s=>q(s.target.value),placeholder:"sk-…",className:W}),e.jsx(ce,{children:h?"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(ie,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const y=G(s),m=s.idTouched&&y,b=me(s),F=!!b&&s.nameDirty,ue=O(s),xe=ne(s),ee=s.contextTouched&&ue,le=s.maxTouched&&xe;return e.jsxs("div",{className:P("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:u=>{const D=u.target.value;d(r,{id:D,...s.nameDirty?{}:{name:Ie(D)}})},onBlur:()=>d(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":m?!0:void 0,className:P(W,"font-mono",m&&se)})]}),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:u=>d(r,{name:u.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":F?!0:void 0,className:P(W,F&&se)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||N,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:()=>p(u=>u.filter((D,te)=>te!==r)),children:e.jsx(T,{name:"trash",className:"size-4"})})]}),m?e.jsx(re,{children:y}):null,F?e.jsx(re,{children:b}):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:()=>d(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(T,{name:"chevron-down",className:P("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(ie,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:u=>d(r,{contextLength:u.target.value}),onBlur:()=>d(r,{contextTouched:!0}),placeholder:Oe,"aria-invalid":ee?!0:void 0,className:P(W,ee&&se)}),ee?e.jsx(re,{children:ue}):s.contextLength.trim()===""?e.jsx(ce,{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(ie,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:u=>d(r,{maxOutputTokens:u.target.value}),onBlur:()=>d(r,{maxTouched:!0}),placeholder:De,"aria-invalid":le?!0:void 0,className:P(W,le&&se)}),le?e.jsx(re,{children:xe}):s.maxOutputTokens.trim()===""?e.jsx(ce,{children:"Longest reply the model allows — use its real limit."}):null]}),j&&j.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:N,onChange:u=>d(r,{reasoningEfforts:u.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:j.map(u=>{var te;const D=((te=s.reasoningEfforts)==null?void 0:te.includes(u))??!1;return e.jsx("button",{type:"button","aria-pressed":D,disabled:N,className:P("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",D?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var S;return d(r,{reasoningEfforts:D?(S=s.reasoningEfforts)==null?void 0:S.filter(X=>X!==u):[...s.reasoningEfforts??[],u]})},children:u},u)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>p(s=>[...s,je()]),children:[e.jsx(T,{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:[g?e.jsx("p",{className:"text-failure-bg text-sm",children:g}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!w||N,className:"w-full",children:h?"Save changes":"Add provider"})]})]})})},Ae=$e;function he(a){return a.kind==="model"&&a.provider.models.length===1}function _e(a){return a.kind==="provider"?`“${a.provider.name}” and all of its models will no longer be available to your agents.`:he(a)?`“${a.model.name}” is the only model left in ${a.provider.name}, so the whole provider will be removed.`:`“${a.model.name}” will no longer be available to your agents. The rest of ${a.provider.name} stays configured.`}function ze(a){return"baseUrl"in a&&typeof a.baseUrl=="string"?a.baseUrl:""}var Fe=()=>{const{modelCatalog:a}=Ee(),i=Ce(),f=ke(),[j,N]=l.useState(""),[g,h]=l.useState([]),[o,K]=l.useState([]),[M,I]=l.useState(!0),[$,C]=l.useState(null),[q,x]=l.useState(null),[p,A]=l.useState(!1),[U,H]=l.useState(null),[R,_]=l.useState(null),[Z,d]=l.useState(null),[ae,Y]=l.useState(!1),[v,z]=l.useState(null),[k,G]=l.useState(null),[me,O]=l.useState(null),ne=l.useMemo(()=>(o??[]).reduce((t,n)=>(t[n.name]=n.logo??"",t),{}),[o]),w=j.trim().toLowerCase(),Q=l.useCallback(async()=>{I(!0),C(null);try{const[t,n]=await Promise.all([a.listModelProviders(),a.getModelProviderCatalog()]);h(t),K(n)}catch(t){C(J(t,"Failed to load model providers"))}finally{I(!1)}},[a]);l.useEffect(()=>{Q()},[Q]);const V=l.useMemo(()=>new Set(g.map(t=>t.type)),[g]),oe=l.useMemo(()=>g.filter(t=>{var n;return((n=t.name)==null?void 0:n.toLowerCase().includes(w))||t.models.some(c=>c.name.toLowerCase().includes(w)||c.id.toLowerCase().includes(w))}),[g,w]),s=l.useMemo(()=>o.filter(t=>t.type!=="custom"&&!V.has(t.type)&&(t.name.toLowerCase().includes(w)||t.models.some(n=>n.name.toLowerCase().includes(w)||n.id.toLowerCase().includes(w)))),[o,V,w]),r=l.useMemo(()=>{var t;return(t=o.find(n=>n.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[o]),y=l.useMemo(()=>{const t=new Map;for(const n of o)t.set(n.type,n.models);return t},[o]),m=()=>{H(null),_(null),d(null)},b=async(t,n)=>{A(!0),C(null);try{await t(),await Q(),m()}catch(c){throw n?n(c):i==null?C(J(c,"Request failed")):i.showError(c),c}finally{A(!1)}},F=async(t,n)=>{d(null),await b(async()=>{await a.createModelProvider({type:t.type,name:t.name,...n.baseUrl?{baseUrl:n.baseUrl}:{},apiKey:n.apiKey,models:t.models})},c=>d(J(c,"Request failed"))),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},ue=async(t,n)=>{d(null),await b(async()=>{await a.updateModelProvider({id:t.id,type:t.type,name:t.name,...n.baseUrl?{baseUrl:n.baseUrl}:{},apiKey:n.apiKey,models:t.models})},c=>d(J(c,"Request failed"))),i==null||i.showSuccess({title:`${t.name} updated`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"update"})},xe=()=>{p||(G(null),O(null))},ee=({provider:t,models:n},c)=>b(async()=>{await a.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:n})},c),le=t=>{O(null);const n=L=>O(J(L,"Request failed"));let c;if(t.kind==="model"&&!he(t))c=ee({provider:t.provider,models:t.provider.models.filter(L=>L.id!==t.model.id)},n);else{const L=a.deleteModelProvider;L!==void 0&&(c=b(async()=>{await L({id:t.provider.id}),f(de.Settings.MODEL_PROVIDER_DELETED,{provider_name:t.provider.name})},n))}c==null||c.then(()=>G(null)).catch(()=>{})},u=async t=>{x(null),await b(async()=>{await a.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},n=>x(J(n,"Request failed"))),setTimeout(()=>{i==null||i.showSuccess({title:`${t.name} added`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},0)},D=async t=>{if(!v)return;const n=v;x(null),await b(async()=>{await a.updateModelProvider({id:n.id,type:n.type,name:n.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},c=>x(J(c,"Request failed"))),setTimeout(()=>{i==null||i.showSuccess({title:"Model provider updated",description:`${n.name} was updated successfully.`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:n.name,mode:"update"})},0)},te=v?{name:v.name,baseUrl:v.baseUrl??"",models:v.models}:void 0,S=U!=null?g.find(t=>t.id===U)??null:null,X=R!=null?o.find(t=>t.type===R)??null:null,Ne=S!=null||X!=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."}),$?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:$}):null,e.jsx("div",{className:"mt-4 min-h-0 min-w-0 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full min-w-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Se,{query:j,setQuery:N,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",className:"shrink-0 sm:self-auto",onClick:()=>{x(null),z(null),Y(!0)},children:[e.jsx(T,{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:[M?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!M&&oe.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:oe.map(t=>{const n=y.get(t.type)??[],c=new Set(t.models.map(E=>E.id)),L=n.filter(E=>!c.has(E.id)),be=ne[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:be?e.jsx(fe,{src:be,alt:t.name,className:"size-4.5"}):e.jsx(T,{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:p,onClick:()=>{t.type==="custom"?(m(),x(null),z(t),Y(!0)):(d(null),_(null),H(t.id))},children:[e.jsx(T,{name:"pencil",className:"size-3.5"}),"Edit"]}),a.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:p,onClick:()=>{O(null),G({kind:"provider",provider: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(E=>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:E.name}),t.models.length>1||a.deleteModelProvider?e.jsx("button",{type:"button","aria-label":`Remove ${E.name}`,disabled:p,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:()=>{O(null),G({kind:"model",provider:t,model:E})},children:e.jsx(T,{name:"trash",className:"size-3.5"})}):null]},E.id)),L.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 · ",L.length]}),L.map(E=>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:E.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:p,onClick:()=>{ee({provider:t,models:[...t.models,E]}).catch(()=>{})},children:"Add"})]},E.id))]}):null]})]},t.id)})})]}):null,!M&&s.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:s.map(t=>{const n=ne[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:n?e.jsx(fe,{src:n,alt:t.name,className:"size-4.5"}):e.jsx(T,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",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(c=>c.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:p,onClick:()=>{d(null),H(null),_(t.type)},children:[e.jsx(T,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!M&&oe.length===0&&s.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:w?`No providers match “${j.trim()}”.`:"No model providers yet."}):null]}),k?e.jsx(we,{title:k.kind==="model"&&!he(k)?"Remove model?":"Remove provider?",description:_e(k),busy:p,error:me,onCancel:xe,onConfirm:()=>{le(k)}}):null,e.jsx(Re,{open:Ne,onOpenChange:t=>{t||m()},onSave:t=>{if(S)return ue(S,t);if(X)return F(X,t)},title:S?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:S?S.baseUrl??"":X?ze(X):"",requireApiKey:S==null,submitLabel:S?"Save":"Create",busy:p,error:Z}),e.jsx(Ae,{open:ae,onOpenChange:t=>{Y(t),t||(x(null),z(null))},isEditMode:v!==null,initialValues:te,onSubmit:v?D:u,reasoningEffortOptions:r,busy:p,error:q},(v==null?void 0:v.id)??"add-custom-provider")]})})]})},qe=Fe;export{qe as default};
@@ -1 +1 @@
1
- import{C as X}from"./chunk-F62I374W-Dwa1z7Cl.js";import{bE as H,p as J,q as Y,r as a,x as q,bL as Q,j as e,I as T,E as O,bG as W,bH as Z,bI as ee,c as te,bJ as se,_ as U,aa as ae}from"./index-lhOueW4w.js";var ne={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},E=ae("h-11 shadow-sm");function R(n){if(n.trim()==="")return null;const r=Number(n);return!Number.isFinite(r)||r<0?null:r}var re=({open:n,onOpenChange:r,onSave:p,title:c,description:z,initialConfig:y=null,requireApiKey:j=!0,busy:M=!1,error:w})=>{const[k,m]=a.useState(""),[D,d]=a.useState(""),[u,S]=a.useState(""),[l,x]=a.useState(""),[o,b]=a.useState(""),[N,h]=a.useState(!1),P=()=>{m(""),d(""),S(""),x(""),b(""),h(!1)};a.useEffect(()=>{if(!n)return;const s=y??ne;m(String(s.execTimeoutMs)),d(String(s.autoStopIntervalInMinutes)),S(String(s.autoArchiveIntervalInMinutes)),x(String(s.autoDeleteIntervalInMinutes)),b(""),h(!1)},[n,y]);const I=s=>{s||P(),r(s)},f=R(k),v=R(D),g=R(u),A=R(l),C=o.trim(),_=(!j||!!C)&&f!=null&&v!=null&&g!=null&&A!=null,B=async s=>{if(s.preventDefault(),!(!_||M||f==null||v==null||g==null||A==null))try{await p({execTimeoutMs:f,autoStopIntervalInMinutes:v,autoArchiveIntervalInMinutes:g,autoDeleteIntervalInMinutes:A,apiKey:C}),P(),r(!1)}catch{}};return e.jsx(W,{open:n,onOpenChange:I,title:c,description:z,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(T,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:B,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",j?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:j,value:o,onChange:s=>{b(s.target.value)},placeholder:j?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:E})]}),e.jsxs(Z,{expanded:N,onChange:(s,K)=>h(K),className:"rounded-md border border-border",children:[e.jsx(ee,{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(T,{name:"chevron-down",className:te("size-4 shrink-0 text-text-secondary transition-transform duration-200",N?"rotate-0":"-rotate-90")})]})}),e.jsxs(se,{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:k,onChange:s=>{m(s.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:D,onChange:s=>{d(s.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:u,onChange:s=>{S(s.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:l,onChange:s=>{x(s.target.value)},placeholder:"43200",className:E})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[w?e.jsx("p",{className:"text-failure-bg text-sm",children:w}):null,e.jsx(O.Primary,{type:"submit",size:"large",disabled:!_||M,className:"w-full shrink-0",children:"Save"})]})]})})},le=re,V=({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c})=>({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c}),oe=()=>{const{sandboxCatalog:n}=H(),r=J(),p=Y(),[c,z]=a.useState([]),[y,j]=a.useState([]),[M,w]=a.useState(!0),[k,m]=a.useState(null),[D,d]=a.useState(null),[u,S]=a.useState(!1),[l,x]=a.useState(null),[o,b]=a.useState(null),[N,h]=a.useState(null),[P,I]=a.useState(null),f=a.useCallback(async({quiet:t=!1}={})=>{if(n){t||w(!0),m(null);try{const[i,F]=await Promise.all([n.listSandboxProviders(),n.getSandboxProviderCatalog()]);z(i),j(F)}catch(i){m(q(i,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[n]);a.useEffect(()=>{f()},[f]);const v=c.length>0,g=a.useMemo(()=>{if(v)return[];const t=new Set(c.map(i=>i.catalogId));return y.filter(i=>!t.has(i.id))},[y,c,v]),A=a.useMemo(()=>{const t=o??l;return t==null||!Q(t)?null:V(t)},[o,l]);if(!n)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const C=async(t,i=m)=>{S(!0),m(null);try{await t(),await f({quiet:!0})}catch(F){throw i(q(F,"Request failed")),F}finally{S(!1)}},_=async t=>{l&&(d(null),await C(async()=>{await n.createSandboxProvider({catalogId:l.id,name:l.name,type:l.type,...V(t),apiKey:t.apiKey})},d),x(null),setTimeout(()=>{r==null||r.showSuccess({title:`${l.name} configured`}),p(U.Settings.SANDBOX_PROVIDER_SAVED,{provider_name:l.name,mode:"create"})},0))},B=async t=>{o&&(d(null),await C(async()=>{await n.updateSandboxProvider({id:o.id,...V(t),...t.apiKey?{apiKey:t.apiKey}:{}})},d),b(null),setTimeout(()=>{r==null||r.showSuccess({title:`${o.name} updated`}),p(U.Settings.SANDBOX_PROVIDER_SAVED,{provider_name:o.name,mode:"update"})},0))},s=()=>{u||(h(null),I(null))},K=t=>{const i=n.deleteSandboxProvider;i&&(I(null),C(async()=>{await i({id:t.id}),p(U.Settings.SANDBOX_PROVIDER_DELETED,{provider_name:t.name}),h(null)},I).catch(()=>{}))},$=l!=null||o!=null,L=o!=null,G=o?`Update ${o.name}`:l?`Configure ${l.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."}),k?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:k}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:M?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[c.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",c.length]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:[c.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(T,{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.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(O.Secondary,{size:"small",type:"button",disabled:u,onClick:()=>{d(null),x(null),b(t)},children:"Update"}),n.deleteSandboxProvider?e.jsx(O.Ghost,{size:"small",className:"text-text-secondary",type:"button",disabled:u,onClick:()=>{I(null),h(t)},children:"Remove"}):null]})]},t.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 · ",g.length]}),g.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:y.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:g.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(T,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(O.Secondary,{type:"button",disabled:u,onClick:()=>{d(null),b(null),x(t)},children:"Configure"})]},t.id))})]})]})}),N?e.jsx(X,{title:"Remove sandbox provider?",description:`“${N.name}” will stop running sandboxes for code, files and shell commands.`,busy:u,error:P,onCancel:s,onConfirm:()=>{K(N)}}):null,e.jsx(le,{open:$,onOpenChange:t=>{t||(d(null),x(null),b(null))},onSave:L?B:_,title:G,description:L?"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:A,requireApiKey:!L,busy:u,error:D})]})},ce=oe;export{ce as default};
1
+ import{C as X}from"./chunk-US5DQOBQ-Bu-huQ7M.js";import{bE as H,p as J,q as Y,r as a,x as q,bL as Q,j as e,I as T,E as O,bG as W,bH as Z,bI as ee,c as te,bJ as se,_ as U,aa as ae}from"./index-CVbSocf1.js";var ne={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},E=ae("h-11 shadow-sm");function R(n){if(n.trim()==="")return null;const r=Number(n);return!Number.isFinite(r)||r<0?null:r}var re=({open:n,onOpenChange:r,onSave:p,title:c,description:z,initialConfig:y=null,requireApiKey:j=!0,busy:M=!1,error:w})=>{const[k,m]=a.useState(""),[D,d]=a.useState(""),[u,S]=a.useState(""),[l,x]=a.useState(""),[o,b]=a.useState(""),[N,h]=a.useState(!1),P=()=>{m(""),d(""),S(""),x(""),b(""),h(!1)};a.useEffect(()=>{if(!n)return;const s=y??ne;m(String(s.execTimeoutMs)),d(String(s.autoStopIntervalInMinutes)),S(String(s.autoArchiveIntervalInMinutes)),x(String(s.autoDeleteIntervalInMinutes)),b(""),h(!1)},[n,y]);const I=s=>{s||P(),r(s)},f=R(k),v=R(D),g=R(u),A=R(l),C=o.trim(),_=(!j||!!C)&&f!=null&&v!=null&&g!=null&&A!=null,B=async s=>{if(s.preventDefault(),!(!_||M||f==null||v==null||g==null||A==null))try{await p({execTimeoutMs:f,autoStopIntervalInMinutes:v,autoArchiveIntervalInMinutes:g,autoDeleteIntervalInMinutes:A,apiKey:C}),P(),r(!1)}catch{}};return e.jsx(W,{open:n,onOpenChange:I,title:c,description:z,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(T,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:B,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",j?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:j,value:o,onChange:s=>{b(s.target.value)},placeholder:j?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:E})]}),e.jsxs(Z,{expanded:N,onChange:(s,K)=>h(K),className:"rounded-md border border-border",children:[e.jsx(ee,{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(T,{name:"chevron-down",className:te("size-4 shrink-0 text-text-secondary transition-transform duration-200",N?"rotate-0":"-rotate-90")})]})}),e.jsxs(se,{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:k,onChange:s=>{m(s.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:D,onChange:s=>{d(s.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:u,onChange:s=>{S(s.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:l,onChange:s=>{x(s.target.value)},placeholder:"43200",className:E})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[w?e.jsx("p",{className:"text-failure-bg text-sm",children:w}):null,e.jsx(O.Primary,{type:"submit",size:"large",disabled:!_||M,className:"w-full shrink-0",children:"Save"})]})]})})},le=re,V=({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c})=>({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c}),oe=()=>{const{sandboxCatalog:n}=H(),r=J(),p=Y(),[c,z]=a.useState([]),[y,j]=a.useState([]),[M,w]=a.useState(!0),[k,m]=a.useState(null),[D,d]=a.useState(null),[u,S]=a.useState(!1),[l,x]=a.useState(null),[o,b]=a.useState(null),[N,h]=a.useState(null),[P,I]=a.useState(null),f=a.useCallback(async({quiet:t=!1}={})=>{if(n){t||w(!0),m(null);try{const[i,F]=await Promise.all([n.listSandboxProviders(),n.getSandboxProviderCatalog()]);z(i),j(F)}catch(i){m(q(i,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[n]);a.useEffect(()=>{f()},[f]);const v=c.length>0,g=a.useMemo(()=>{if(v)return[];const t=new Set(c.map(i=>i.catalogId));return y.filter(i=>!t.has(i.id))},[y,c,v]),A=a.useMemo(()=>{const t=o??l;return t==null||!Q(t)?null:V(t)},[o,l]);if(!n)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const C=async(t,i=m)=>{S(!0),m(null);try{await t(),await f({quiet:!0})}catch(F){throw i(q(F,"Request failed")),F}finally{S(!1)}},_=async t=>{l&&(d(null),await C(async()=>{await n.createSandboxProvider({catalogId:l.id,name:l.name,type:l.type,...V(t),apiKey:t.apiKey})},d),x(null),setTimeout(()=>{r==null||r.showSuccess({title:`${l.name} configured`}),p(U.Settings.SANDBOX_PROVIDER_SAVED,{provider_name:l.name,mode:"create"})},0))},B=async t=>{o&&(d(null),await C(async()=>{await n.updateSandboxProvider({id:o.id,...V(t),...t.apiKey?{apiKey:t.apiKey}:{}})},d),b(null),setTimeout(()=>{r==null||r.showSuccess({title:`${o.name} updated`}),p(U.Settings.SANDBOX_PROVIDER_SAVED,{provider_name:o.name,mode:"update"})},0))},s=()=>{u||(h(null),I(null))},K=t=>{const i=n.deleteSandboxProvider;i&&(I(null),C(async()=>{await i({id:t.id}),p(U.Settings.SANDBOX_PROVIDER_DELETED,{provider_name:t.name}),h(null)},I).catch(()=>{}))},$=l!=null||o!=null,L=o!=null,G=o?`Update ${o.name}`:l?`Configure ${l.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."}),k?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:k}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:M?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[c.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",c.length]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:[c.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(T,{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.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(O.Secondary,{size:"small",type:"button",disabled:u,onClick:()=>{d(null),x(null),b(t)},children:"Update"}),n.deleteSandboxProvider?e.jsx(O.Ghost,{size:"small",className:"text-text-secondary",type:"button",disabled:u,onClick:()=>{I(null),h(t)},children:"Remove"}):null]})]},t.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 · ",g.length]}),g.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:y.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:g.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(T,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(O.Secondary,{type:"button",disabled:u,onClick:()=>{d(null),b(null),x(t)},children:"Configure"})]},t.id))})]})]})}),N?e.jsx(X,{title:"Remove sandbox provider?",description:`“${N.name}” will stop running sandboxes for code, files and shell commands.`,busy:u,error:P,onCancel:s,onConfirm:()=>{K(N)}}):null,e.jsx(le,{open:$,onOpenChange:t=>{t||(d(null),x(null),b(null))},onSave:L?B:_,title:G,description:L?"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:A,requireApiKey:!L,busy:u,error:D})]})},ce=oe;export{ce as default};
@@ -1 +1 @@
1
- import{B as rt}from"./chunk-4LY4NAUC-K0Thc4fl.js";import{l as Te,o as Ue,p as Ce,q as Ge,t as He,v as lt,r as o,w as ve,x as it,y as Fe,z as Ee,A as ot,j as e,P as ct,S as dt,B as xe,C as qe,D as Ve,E as $,I as R,F as ut,G as Ne,H as _e,J as mt,K as ht,L as Le,M as W,N as xt,O as K,k as We,Q as ft,c as B,R as gt,U as bt,V as pt,W as Nt,X as jt,Y as yt,Z as vt,_ as Q,$ as St,a0 as wt,u as kt,a1 as Tt,a2 as je,a3 as Ct,a4 as Et,a5 as zt,a6 as At,a7 as Rt,a8 as It,a9 as Pt,aa as ye,ab as Dt,ac as Ft,ad as _t}from"./index-lhOueW4w.js";var Oe=[{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 Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Lt(t){const n=Ke(),r=new Set(Oe.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Oe]}var Qe=[{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"}],Ot={"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 fe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ke()}}function Mt(t){return Ot[t]??t.split("/").pop()??t}function Ye(t){return t.toString().padStart(2,"0")}function me({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ye(n)} ${r}`}function Se(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((u,S)=>u-S),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function we(t){return t.trim().split(/\s+/).length===5}function ce(t){const n=Mt(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,u,S,b]=r;if(u!=="*"||S!=="*")return t.cron;const d=Number(a),h=Number(l);if(l==="*"&&b==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ye(d)} ${n}`;if(b==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Daily ${me({hour:h,minute:d})} ${n}`;if(b==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Weekdays ${me({hour:h,minute:d})} ${n}`;if(b!=null&&/^\d(?:,\d)*$/.test(b)&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d)){const j=b.split(",").map(x=>{var k;return((k=Qe.find(p=>p.value===Number(x)))==null?void 0:k.label)??x});return j.length===1?`Every ${j[0]==="Mon"?"Monday":j[0]} ${me({hour:h,minute:d})} ${n}`:`${j.join(", ")} ${me({hour:h,minute:d})} ${n}`}return t.cron}function Me(t){const n=fe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,u,S,b]=r,d=Number(a),h=Number(l);return u!=="*"||S!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&b==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:b==="*"&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:h,minute:d,customCron:t.cron}:b!=null&&/^\d(?:,\d)*$/.test(b)&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:h,minute:d,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(h)?n.hour:h,minute:Number.isNaN(d)?n.minute:d}}function $t(t,n=Date.now()){return _t(t,{fallback:"Never",nowMs:n})}var Bt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Ut=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),Gt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Ht({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:u,agentPickerDisabled:S=!1,onBuildAgent:b}){const d=Se(t),h=ce({cron:d,timezone:t.timezone}),j=Lt(t.timezone),x=(i,y)=>{n({...t,[i]:y})},k=i=>{const y=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:y})},p=i=>{const z=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:z.length>0?z:[i]})};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(qe,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:u,disabled:S||l==null,onBuildAgent:b})]}),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:i=>x("name",i.target.value),placeholder:"harness-daily-digest",className:ye("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:i=>x("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ye("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-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Bt.map(i=>{const y=t.recurrence===i.value;return e.jsx("button",{type:"button",className:B("rounded-md border px-2 py-2 text-sm font-medium transition-colors",y?"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":y,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>x("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!we(t.customCron),className:B(ye("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),we(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):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:Qe.map(i=>{const y=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:B("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",y?"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":y,onClick:()=>p(i.value),children:i.label},i.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(xe,{"aria-label":"Hour",value:String(t.hour),options:Ut,onValueChange:i=>x("hour",Number(i))})]}):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(xe,{"aria-label":"Minute",value:String(t.minute),options:Gt,onValueChange:i=>x("minute",Number(i))})]}):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(xe,{"aria-label":"Timezone",value:t.timezone,options:j,onValueChange:i=>x("timezone",i),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(R,{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:h||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function qt(t){return t.startsWith("manual-")}function Vt(t){return t==="failed"?"failed":"success"}function Ze(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Je(t){return qt(t)?"Manual test":"Cron"}function Wt(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function ke(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":It(n)}function Kt({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:Ze(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Je(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",ke(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",ke(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Qt={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 Xe({run:t,onOpenSession:n}){const r=Vt(t.status),a=ke(t.triggeredAt??t.scheduledFor),l=`${Ze(t.status)} run at ${a}`,u=B("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Qt[r]),S=e.jsx(R,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(We,{content:e.jsx(Kt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:B(u,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:S}):e.jsx("span",{className:u,"aria-label":l,children:S})})}function et({status:t}){const n=t==="active";return e.jsx(rt,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Yt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Zt({connector:t,onConnected:n}){return Dt()==null?null:e.jsx(Ft,{connector:t,onConnected:n})}function ie({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 Jt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=Te(),u=Ce(),{connectors:S,ensureLoaded:b,refreshConnectors:d,loading:h,error:j}=Pt(),[x,k]=o.useState(!1),[p,i]=o.useState(null),y=ce({cron:t.cron,timezone:t.timezone}),z=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),u==null||u.showSuccess({title:"Test run started"})}catch(m){u==null||u.showError(m)}finally{k(!1)}};return o.useEffect(()=>{b()},[b]),o.useEffect(()=>{j!=null&&(u==null||u.showError(j))},[j,u]),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(ie,{label:"Agent",children:n}),e.jsx(ie,{label:"Name",children:t.name}),e.jsx(ie,{label:"Status",children:e.jsx(et,{status:t.status})}),e.jsx(ie,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ie,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:y}),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($.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(R,{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"})}),r.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:r.map(m=>{const C=Yt(S,m.name),U=(C==null?void 0:C.authenticated)===!0,q=C==null&&!h;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:B("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",U?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:U?e.jsx(R,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),U?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):q?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):C!=null&&C.authenticated===!1?e.jsx(Zt,{connector:C,onConnected:d}):h?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.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($.Primary,{type:"button",disabled:x,size:"small",onClick:()=>void z(),children:[e.jsx(R,{name:x?"loader":"play",className:B("size-3.5",x&&"animate-spin")}),"Run Test"]})]}),p==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(Xe,{run:p}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Je(p.name)}),e.jsx("p",{className:"text-text-secondary",children:$t(p.triggeredAt??p.scheduledFor)})]})]})]})]})}function Xt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:u}){const S=Te(),b=Ue(),d=He(),h=Ce(),j=Ge(),[x,k]=o.useState(fe),[p,i]=o.useState(l),[y,z]=o.useState(null),[m,C]=o.useState({kind:"form"}),[U,q]=o.useState(!1),[re,Y]=o.useState(!1),[A,_]=o.useState(null),L=o.useRef(p);L.current=p;const Z=m.kind==="form"?m.saved:m.schedule,N=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,O=m.kind==="form"&&m.saved!=null,T=r==="create"&&m.kind==="form"&&m.saved==null,{allows:J}=ve({resourceType:"agent",resourceIds:p.length===0?[]:[p]});o.useEffect(()=>{if(!t){k(fe()),i(l),z(null),_(null),C({kind:"form"}),Y(!1);return}if(r==="edit"&&a!=null){k(Me({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),z(null),C({kind:"form"});return}k(fe()),i(l),z(null),C({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const v=l;return zt({server:b,agentKey:v}).then(w=>{f||w==null||L.current===v&&(z(w),i(Ve(w)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,b]);const G=(y==null?void 0:y.name)??(Z==null?void 0:Z.agentName)??(a==null?void 0:a.agentName)??(p.length>0?p:""),ge=o.useMemo(()=>{var v;return(((v=y==null?void 0:y.agentSpec)==null?void 0:v.mcpServers)??[]).map(At).filter(w=>w!=null).map(w=>({name:w}))},[y]),le=o.useMemo(()=>{const f=Se(x);return x.name.trim().length>0&&x.task.trim().length>0&&we(f)&&p.length>0&&(!T||J(p,"USE"))},[p,J,x,T]),V=f=>{C({kind:"test",schedule:f}),k(Me({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!le)return;const v=Se(x);q(!0),_(null);try{if(N&&a!=null){await S.updateSchedule({id:a.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:a.status}),j(Q.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),u==null||u(),n(!1);return}if(O&&m.kind==="form"&&m.saved!=null){const I=await S.updateSchedule({id:m.saved.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.EDITED,{schedule_id:I.id,agent_id:I.agentId}),u==null||u(),V(I),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:I.cron,timezone:I.timezone})});return}const w=await S.createSchedule({agentId:p,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.CREATED,{schedule_id:w.id,agent_id:p}),u==null||u(),V(w),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:w.cron,timezone:w.timezone})})}catch(w){const I=w instanceof Error?w.message:"Failed to save schedule";_(I)}finally{q(!1)}},ee=async()=>{if(m.kind==="test"){Y(!0),_(null);try{await S.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),u==null||u(),h==null||h.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const v=f instanceof Error?f.message:"Failed to activate schedule";_(v),h==null||h.showError(f)}finally{Y(!1)}}},te=m.kind==="test"?"Test Schedule":N||O?"Edit Schedule":"New Schedule",M=m.kind==="test"?`Recurring unattended runs of ${G}.`:N||O?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let se;return m.kind==="test"?se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsx($.Secondary,{type:"button",className:"w-full",disabled:re,onClick:()=>void ee(),children:"Activate Schedule"})]}):se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx($.Secondary,{type:"button",onClick:()=>n(!1),disabled:U,children:"Cancel"}),e.jsx($.Primary,{type:"submit",form:"schedule-form",disabled:!le||U,children:"Save"})]})]}),e.jsx(Rt,{open:t,onOpenChange:n,title:te,description:M,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(R,{name:m.kind==="test"||N||O?"calendar":"calendar-plus",className:"size-5"})}),footer:se,children:m.kind==="test"?e.jsx(Jt,{schedule:m.schedule,agentName:G,mcpMounts:ge,onEditConfiguration:()=>{_(null),C({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Ht,{values:x,onChange:k,agentId:p,agentLabel:G,onAgentIdChange:N||O?void 0:f=>{i(f),f.length===0&&z(null)},onAgentPicked:z,agentPickerDisabled:N||O,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function $e(t){return e.jsx(Et,{children:e.jsx(Xt,{...t})})}function es({runs:t,onOpenSession:n}){const r=Wt(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Xe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var ts=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Be=[10,25];function he(t){return Math.min(Math.max(t,1),25)}function oe(t){const n=Ee(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all",scheduleId:n.scheduleId}}function ss(t){const n=Ee(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function ns({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:u,onTogglePause:S,onDelete:b}){const d=kt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs($.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(R,{name:n?"loader":"play",className:B("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(Tt,{align:"end",trigger:e.jsx("button",{type:"button",className:Ct({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(R,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:u,children:[e.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:S,children:[e.jsx(R,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(je,{className:"text-failure-bg focus:text-failure-bg",onClick:b,children:[e.jsx(R,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ls({agentId:t}){const n=Te(),r=Ue(),a=Ce(),l=Ge(),u=He(),S=lt(),b=u!=null&&vt({sessions:S}),[d,h]=o.useState([]),{allows:j}=ve({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[x,k]=o.useState({}),[p,i]=o.useState(!1),[y,z]=o.useState(()=>new Set),[m,C]=o.useState({}),[U,q]=o.useState(!0),[re,Y]=o.useState(null),[A,_]=o.useState(()=>oe(window.location.search).nameQuery),[L,Z]=o.useState(()=>oe(window.location.search).statusFilter),[N,O]=o.useState(()=>t??oe(window.location.search).agentFilter),[T,J]=o.useState(()=>oe(window.location.search).scheduleId),G=t??(N==="all"?null:N),{allows:ge}=ve({resourceType:"agent",resourceIds:G==null?[]:[G]}),le=r.permissions==null||G==null||ge(G,"USE"),[V,X]=o.useState(()=>ss(t)),[ee,te]=o.useState(null),[M,se]=o.useState(()=>he(yt)),[f,v]=o.useState(void 0),[w,I]=o.useState(void 0),[ne,P]=o.useState(void 0),tt=({run:s,schedule:c})=>{if(!b||u==null||s.sessionId==null)return;l(Q.Schedule.RUN_SESSION_OPENED,{schedule_id:c.id,agent_id:c.agentId});const g=St(s.triggeredAt??s.scheduledFor);wt({sessionId:s.sessionId,view:"sessions",...g==null?{}:{timeRange:g}}),u.setSessionsOpen(!0)},H=o.useRef(0),ze=o.useRef(!1),be=o.useCallback(async({rows:s,gen:c})=>{if(s.length===0){c===H.current&&k({});return}i(!0);try{const g=await Promise.allSettled(s.map(E=>n.listScheduleRuns({scheduleId:E.id})));if(c!==H.current)return;k(Object.fromEntries(s.map((E,D)=>{const F=g[D],ue=(F==null?void 0:F.status)==="fulfilled"?F.value:[];return[E.id,ue]})))}finally{c===H.current&&i(!1)}},[n]),ae=o.useCallback(async({token:s,size:c,agentId:g,pinnedScheduleId:E})=>{const D=++H.current;q(!0),Y(null);try{if(E!=null){const ue=await n.getSchedule({id:E});if(D!==H.current)return;h([ue]),I(void 0),P(void 0),be({rows:[ue],gen:D});return}const F=await n.listSchedules({limit:he(c),...s===void 0||s===""?{}:{pageToken:s},...g==="all"?{}:{agentIds:[g]}});if(D!==H.current)return;h(F.data),I(F.nextPageToken),P(F.previousPageToken),be({rows:F.data,gen:D})}catch(F){if(D!==H.current)return;Y(it(F,"Check your connection and try again.")),h([]),k({}),I(void 0),P(void 0)}finally{D===H.current&&q(!1)}},[n,be]),Ae=o.useCallback(s=>{const c=(s==null?void 0:s.size)??M,g=(s==null?void 0:s.agentId)??N;J(null),v(void 0),P(void 0),ae({token:void 0,size:c,agentId:g,pinnedScheduleId:null})},[N,ae,M]);o.useEffect(()=>{Fe({agent:t===void 0&&N!=="all"?N:null,status:L==="all"?null:L,q:A.trim().length===0?null:A,scheduleId:T})},[N,t,L,A,T]),o.useEffect(()=>{t!==void 0&&O(s=>s===t?s:(v(void 0),P(void 0),t))},[t]),o.useEffect(()=>{ze.current||!Ee(window.location.search).isNew||(ze.current=!0,Fe({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const c=oe(window.location.search);_(c.nameQuery),Z(c.statusFilter),J(g=>g===c.scheduleId?g:(v(void 0),P(void 0),c.scheduleId)),O(g=>{const E=t??c.agentFilter;return g===E?g:(v(void 0),P(void 0),E)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{ae({token:f,size:M,agentId:N,pinnedScheduleId:T})},[N,M,f,ae,T]),o.useEffect(()=>{if(T==null||A.trim().length>0)return;const s=d.find(c=>c.id===T);s!=null&&_(s.name)},[A,T,d]);const de=o.useMemo(()=>{if(T!=null)return d;const s=A.trim().toLowerCase();return d.filter(c=>!(L!=="all"&&c.status!==L||s.length>0&&!c.name.toLowerCase().includes(s)))},[d,A,L,T]),Re=ot(d),Ie=ne!=null||w!=null,st=async s=>{if(!j(s.id,"MANAGE"))return;const c=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:c}),l(Q.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:c}),await ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}catch(g){a==null||a.showError(g)}},nt=async s=>{if(j(s.id,"MANAGE")){z(c=>new Set(c).add(s.id));try{if(await n.createScheduleRun({scheduleId:s.id}),l(Q.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"}),T!=null){const g=await n.getSchedule({id:T});h(E=>{const D=E.length===1?E[0]:void 0;return D!=null&&D.id===g.id?[g]:E})}const c=await n.listScheduleRuns({scheduleId:s.id});k(g=>({...g,[s.id]:c}))}catch(c){a==null||a.showError(c)}finally{z(c=>{const g=new Set(c);return g.delete(s.id),g})}}},at=async s=>{if(j(s.id,"DELETE")){te(null);try{await n.deleteSchedule({id:s.id}),l(Q.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Ae()}catch(c){a==null||a.showError(c)}}},Pe=()=>{w!=null&&v(w)},De=()=>{ne==null||ne===""||v(ne)},pe=()=>{T!=null&&(J(null),v(void 0),P(void 0))};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(ct,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(dt,{query:A,setQuery:s=>{_(s),pe()},placeholder:"Search schedules by name"})}),e.jsx(xe,{value:L,onValueChange:s=>{Z(s),pe()},options:ts,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(qe,{value:N,selectedLabel:N==="all"?"All agents":m[N]??N,onValueChange:s=>{O(s),v(void 0),P(void 0),pe()},onAgentPicked:s=>{C(c=>({...c,[Ve(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs($.Primary,{type:"button",disabled:!le,onClick:()=>le&&X({kind:"create",agentId:N!=="all"?N:void 0}),children:[e.jsx(R,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:B("min-h-0 flex-1 overflow-auto px-4 py-4",re!=null?"flex flex-col":void 0),children:U?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,c)=>e.jsx(ut,{className:"h-12 w-full rounded-md"},c))}):re!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Ne,{title:"Couldn't load schedules",description:re,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(Ne,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):de.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Ne,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ie?e.jsx(_e,{pageSize:M,rowCount:0,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(mt,{className:"min-w-240",children:[e.jsx(ht,{children:e.jsxs(Le,{className:"hover:bg-transparent",children:[e.jsx(W,{children:"Schedule Name"}),e.jsx(W,{children:"Task"}),Re?e.jsx(W,{children:"Created by"}):null,e.jsx(W,{children:"Frequency"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Last 5 runs"}),e.jsx(W,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(xt,{children:de.map(s=>{const c=ce({cron:s.cron,timezone:s.timezone}),g=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(Le,{children:[e.jsxs(K,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(R,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:g})]})]}),e.jsx(K,{className:"w-64 max-w-64",children:e.jsx(We,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Re?e.jsx(K,{children:e.jsx(ft,{subject:s.createdBySubject})}):null,e.jsx(K,{children:c}),e.jsx(K,{children:e.jsx(et,{status:s.status})}),e.jsx(K,{children:p?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(es,{runs:x[s.id]??[],...b?{onOpenSession:E=>tt({run:E,schedule:s})}:{}})}),e.jsx(K,{className:"text-right",children:e.jsx(ns,{schedule:s,running:y.has(s.id),canManage:j(s.id,"MANAGE"),canDelete:j(s.id,"DELETE"),onRunNow:()=>void nt(s),onEdit:()=>{j(s.id,"MANAGE")&&X({kind:"edit",schedule:s})},onTogglePause:()=>void st(s),onDelete:()=>{j(s.id,"DELETE")&&te(s)}})})]},s.id)})})]}),(de.length>0||Ie)&&e.jsx(_e,{pageSize:M,rowCount:de.length,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}})]})}),V.kind==="create"?e.jsx($e,{open:!0,mode:"create",initialAgentId:V.agentId??"",onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>Ae()}):null,V.kind==="edit"?e.jsx($e,{open:!0,mode:"edit",schedule:V.schedule,onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>void ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}):null,ee!=null?e.jsxs(gt,{open:!0,onOpenChange:s=>{s||te(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(bt,{children:e.jsxs(pt,{children:[e.jsx(Nt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",ee.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(jt,{children:[e.jsx($.Secondary,{type:"button",onClick:()=>te(null),children:"Cancel"}),e.jsx($.Destructive,{type:"button",disabled:!j(ee.id,"DELETE"),onClick:()=>void at(ee),children:"Delete"})]})]}):null]})}export{ls as SchedulesPage};
1
+ import{B as rt}from"./chunk-4LY4NAUC-C1iAiAXz.js";import{l as Te,o as Ue,p as Ce,q as Ge,t as He,v as lt,r as o,w as ve,x as it,y as Fe,z as Ee,A as ot,j as e,P as ct,S as dt,B as xe,C as qe,D as Ve,E as $,I as R,F as ut,G as Ne,H as _e,J as mt,K as ht,L as Le,M as W,N as xt,O as K,k as We,Q as ft,c as B,R as gt,U as bt,V as pt,W as Nt,X as jt,Y as yt,Z as vt,_ as Q,$ as St,a0 as wt,u as kt,a1 as Tt,a2 as je,a3 as Ct,a4 as Et,a5 as zt,a6 as At,a7 as Rt,a8 as It,a9 as Pt,aa as ye,ab as Dt,ac as Ft,ad as _t}from"./index-CVbSocf1.js";var Oe=[{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 Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Lt(t){const n=Ke(),r=new Set(Oe.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Oe]}var Qe=[{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"}],Ot={"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 fe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ke()}}function Mt(t){return Ot[t]??t.split("/").pop()??t}function Ye(t){return t.toString().padStart(2,"0")}function me({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ye(n)} ${r}`}function Se(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((u,S)=>u-S),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function we(t){return t.trim().split(/\s+/).length===5}function ce(t){const n=Mt(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,u,S,b]=r;if(u!=="*"||S!=="*")return t.cron;const d=Number(a),h=Number(l);if(l==="*"&&b==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ye(d)} ${n}`;if(b==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Daily ${me({hour:h,minute:d})} ${n}`;if(b==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Weekdays ${me({hour:h,minute:d})} ${n}`;if(b!=null&&/^\d(?:,\d)*$/.test(b)&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d)){const j=b.split(",").map(x=>{var k;return((k=Qe.find(p=>p.value===Number(x)))==null?void 0:k.label)??x});return j.length===1?`Every ${j[0]==="Mon"?"Monday":j[0]} ${me({hour:h,minute:d})} ${n}`:`${j.join(", ")} ${me({hour:h,minute:d})} ${n}`}return t.cron}function Me(t){const n=fe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,u,S,b]=r,d=Number(a),h=Number(l);return u!=="*"||S!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&b==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:b==="*"&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:h,minute:d,customCron:t.cron}:b!=null&&/^\d(?:,\d)*$/.test(b)&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:h,minute:d,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(h)?n.hour:h,minute:Number.isNaN(d)?n.minute:d}}function $t(t,n=Date.now()){return _t(t,{fallback:"Never",nowMs:n})}var Bt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Ut=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),Gt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Ht({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:u,agentPickerDisabled:S=!1,onBuildAgent:b}){const d=Se(t),h=ce({cron:d,timezone:t.timezone}),j=Lt(t.timezone),x=(i,y)=>{n({...t,[i]:y})},k=i=>{const y=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:y})},p=i=>{const z=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:z.length>0?z:[i]})};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(qe,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:u,disabled:S||l==null,onBuildAgent:b})]}),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:i=>x("name",i.target.value),placeholder:"harness-daily-digest",className:ye("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:i=>x("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ye("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-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Bt.map(i=>{const y=t.recurrence===i.value;return e.jsx("button",{type:"button",className:B("rounded-md border px-2 py-2 text-sm font-medium transition-colors",y?"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":y,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>x("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!we(t.customCron),className:B(ye("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),we(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):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:Qe.map(i=>{const y=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:B("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",y?"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":y,onClick:()=>p(i.value),children:i.label},i.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(xe,{"aria-label":"Hour",value:String(t.hour),options:Ut,onValueChange:i=>x("hour",Number(i))})]}):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(xe,{"aria-label":"Minute",value:String(t.minute),options:Gt,onValueChange:i=>x("minute",Number(i))})]}):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(xe,{"aria-label":"Timezone",value:t.timezone,options:j,onValueChange:i=>x("timezone",i),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(R,{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:h||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function qt(t){return t.startsWith("manual-")}function Vt(t){return t==="failed"?"failed":"success"}function Ze(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Je(t){return qt(t)?"Manual test":"Cron"}function Wt(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function ke(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":It(n)}function Kt({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:Ze(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Je(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",ke(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",ke(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Qt={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 Xe({run:t,onOpenSession:n}){const r=Vt(t.status),a=ke(t.triggeredAt??t.scheduledFor),l=`${Ze(t.status)} run at ${a}`,u=B("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Qt[r]),S=e.jsx(R,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(We,{content:e.jsx(Kt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:B(u,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:S}):e.jsx("span",{className:u,"aria-label":l,children:S})})}function et({status:t}){const n=t==="active";return e.jsx(rt,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Yt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Zt({connector:t,onConnected:n}){return Dt()==null?null:e.jsx(Ft,{connector:t,onConnected:n})}function ie({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 Jt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=Te(),u=Ce(),{connectors:S,ensureLoaded:b,refreshConnectors:d,loading:h,error:j}=Pt(),[x,k]=o.useState(!1),[p,i]=o.useState(null),y=ce({cron:t.cron,timezone:t.timezone}),z=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),u==null||u.showSuccess({title:"Test run started"})}catch(m){u==null||u.showError(m)}finally{k(!1)}};return o.useEffect(()=>{b()},[b]),o.useEffect(()=>{j!=null&&(u==null||u.showError(j))},[j,u]),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(ie,{label:"Agent",children:n}),e.jsx(ie,{label:"Name",children:t.name}),e.jsx(ie,{label:"Status",children:e.jsx(et,{status:t.status})}),e.jsx(ie,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ie,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:y}),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($.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(R,{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"})}),r.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:r.map(m=>{const C=Yt(S,m.name),U=(C==null?void 0:C.authenticated)===!0,q=C==null&&!h;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:B("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",U?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:U?e.jsx(R,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),U?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):q?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):C!=null&&C.authenticated===!1?e.jsx(Zt,{connector:C,onConnected:d}):h?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.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($.Primary,{type:"button",disabled:x,size:"small",onClick:()=>void z(),children:[e.jsx(R,{name:x?"loader":"play",className:B("size-3.5",x&&"animate-spin")}),"Run Test"]})]}),p==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(Xe,{run:p}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Je(p.name)}),e.jsx("p",{className:"text-text-secondary",children:$t(p.triggeredAt??p.scheduledFor)})]})]})]})]})}function Xt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:u}){const S=Te(),b=Ue(),d=He(),h=Ce(),j=Ge(),[x,k]=o.useState(fe),[p,i]=o.useState(l),[y,z]=o.useState(null),[m,C]=o.useState({kind:"form"}),[U,q]=o.useState(!1),[re,Y]=o.useState(!1),[A,_]=o.useState(null),L=o.useRef(p);L.current=p;const Z=m.kind==="form"?m.saved:m.schedule,N=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,O=m.kind==="form"&&m.saved!=null,T=r==="create"&&m.kind==="form"&&m.saved==null,{allows:J}=ve({resourceType:"agent",resourceIds:p.length===0?[]:[p]});o.useEffect(()=>{if(!t){k(fe()),i(l),z(null),_(null),C({kind:"form"}),Y(!1);return}if(r==="edit"&&a!=null){k(Me({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),z(null),C({kind:"form"});return}k(fe()),i(l),z(null),C({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const v=l;return zt({server:b,agentKey:v}).then(w=>{f||w==null||L.current===v&&(z(w),i(Ve(w)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,b]);const G=(y==null?void 0:y.name)??(Z==null?void 0:Z.agentName)??(a==null?void 0:a.agentName)??(p.length>0?p:""),ge=o.useMemo(()=>{var v;return(((v=y==null?void 0:y.agentSpec)==null?void 0:v.mcpServers)??[]).map(At).filter(w=>w!=null).map(w=>({name:w}))},[y]),le=o.useMemo(()=>{const f=Se(x);return x.name.trim().length>0&&x.task.trim().length>0&&we(f)&&p.length>0&&(!T||J(p,"USE"))},[p,J,x,T]),V=f=>{C({kind:"test",schedule:f}),k(Me({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!le)return;const v=Se(x);q(!0),_(null);try{if(N&&a!=null){await S.updateSchedule({id:a.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:a.status}),j(Q.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),u==null||u(),n(!1);return}if(O&&m.kind==="form"&&m.saved!=null){const I=await S.updateSchedule({id:m.saved.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.EDITED,{schedule_id:I.id,agent_id:I.agentId}),u==null||u(),V(I),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:I.cron,timezone:I.timezone})});return}const w=await S.createSchedule({agentId:p,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.CREATED,{schedule_id:w.id,agent_id:p}),u==null||u(),V(w),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:w.cron,timezone:w.timezone})})}catch(w){const I=w instanceof Error?w.message:"Failed to save schedule";_(I)}finally{q(!1)}},ee=async()=>{if(m.kind==="test"){Y(!0),_(null);try{await S.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),u==null||u(),h==null||h.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const v=f instanceof Error?f.message:"Failed to activate schedule";_(v),h==null||h.showError(f)}finally{Y(!1)}}},te=m.kind==="test"?"Test Schedule":N||O?"Edit Schedule":"New Schedule",M=m.kind==="test"?`Recurring unattended runs of ${G}.`:N||O?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let se;return m.kind==="test"?se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsx($.Secondary,{type:"button",className:"w-full",disabled:re,onClick:()=>void ee(),children:"Activate Schedule"})]}):se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx($.Secondary,{type:"button",onClick:()=>n(!1),disabled:U,children:"Cancel"}),e.jsx($.Primary,{type:"submit",form:"schedule-form",disabled:!le||U,children:"Save"})]})]}),e.jsx(Rt,{open:t,onOpenChange:n,title:te,description:M,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(R,{name:m.kind==="test"||N||O?"calendar":"calendar-plus",className:"size-5"})}),footer:se,children:m.kind==="test"?e.jsx(Jt,{schedule:m.schedule,agentName:G,mcpMounts:ge,onEditConfiguration:()=>{_(null),C({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Ht,{values:x,onChange:k,agentId:p,agentLabel:G,onAgentIdChange:N||O?void 0:f=>{i(f),f.length===0&&z(null)},onAgentPicked:z,agentPickerDisabled:N||O,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function $e(t){return e.jsx(Et,{children:e.jsx(Xt,{...t})})}function es({runs:t,onOpenSession:n}){const r=Wt(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Xe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var ts=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Be=[10,25];function he(t){return Math.min(Math.max(t,1),25)}function oe(t){const n=Ee(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all",scheduleId:n.scheduleId}}function ss(t){const n=Ee(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function ns({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:u,onTogglePause:S,onDelete:b}){const d=kt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs($.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(R,{name:n?"loader":"play",className:B("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(Tt,{align:"end",trigger:e.jsx("button",{type:"button",className:Ct({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(R,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:u,children:[e.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:S,children:[e.jsx(R,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(je,{className:"text-failure-bg focus:text-failure-bg",onClick:b,children:[e.jsx(R,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ls({agentId:t}){const n=Te(),r=Ue(),a=Ce(),l=Ge(),u=He(),S=lt(),b=u!=null&&vt({sessions:S}),[d,h]=o.useState([]),{allows:j}=ve({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[x,k]=o.useState({}),[p,i]=o.useState(!1),[y,z]=o.useState(()=>new Set),[m,C]=o.useState({}),[U,q]=o.useState(!0),[re,Y]=o.useState(null),[A,_]=o.useState(()=>oe(window.location.search).nameQuery),[L,Z]=o.useState(()=>oe(window.location.search).statusFilter),[N,O]=o.useState(()=>t??oe(window.location.search).agentFilter),[T,J]=o.useState(()=>oe(window.location.search).scheduleId),G=t??(N==="all"?null:N),{allows:ge}=ve({resourceType:"agent",resourceIds:G==null?[]:[G]}),le=r.permissions==null||G==null||ge(G,"USE"),[V,X]=o.useState(()=>ss(t)),[ee,te]=o.useState(null),[M,se]=o.useState(()=>he(yt)),[f,v]=o.useState(void 0),[w,I]=o.useState(void 0),[ne,P]=o.useState(void 0),tt=({run:s,schedule:c})=>{if(!b||u==null||s.sessionId==null)return;l(Q.Schedule.RUN_SESSION_OPENED,{schedule_id:c.id,agent_id:c.agentId});const g=St(s.triggeredAt??s.scheduledFor);wt({sessionId:s.sessionId,view:"sessions",...g==null?{}:{timeRange:g}}),u.setSessionsOpen(!0)},H=o.useRef(0),ze=o.useRef(!1),be=o.useCallback(async({rows:s,gen:c})=>{if(s.length===0){c===H.current&&k({});return}i(!0);try{const g=await Promise.allSettled(s.map(E=>n.listScheduleRuns({scheduleId:E.id})));if(c!==H.current)return;k(Object.fromEntries(s.map((E,D)=>{const F=g[D],ue=(F==null?void 0:F.status)==="fulfilled"?F.value:[];return[E.id,ue]})))}finally{c===H.current&&i(!1)}},[n]),ae=o.useCallback(async({token:s,size:c,agentId:g,pinnedScheduleId:E})=>{const D=++H.current;q(!0),Y(null);try{if(E!=null){const ue=await n.getSchedule({id:E});if(D!==H.current)return;h([ue]),I(void 0),P(void 0),be({rows:[ue],gen:D});return}const F=await n.listSchedules({limit:he(c),...s===void 0||s===""?{}:{pageToken:s},...g==="all"?{}:{agentIds:[g]}});if(D!==H.current)return;h(F.data),I(F.nextPageToken),P(F.previousPageToken),be({rows:F.data,gen:D})}catch(F){if(D!==H.current)return;Y(it(F,"Check your connection and try again.")),h([]),k({}),I(void 0),P(void 0)}finally{D===H.current&&q(!1)}},[n,be]),Ae=o.useCallback(s=>{const c=(s==null?void 0:s.size)??M,g=(s==null?void 0:s.agentId)??N;J(null),v(void 0),P(void 0),ae({token:void 0,size:c,agentId:g,pinnedScheduleId:null})},[N,ae,M]);o.useEffect(()=>{Fe({agent:t===void 0&&N!=="all"?N:null,status:L==="all"?null:L,q:A.trim().length===0?null:A,scheduleId:T})},[N,t,L,A,T]),o.useEffect(()=>{t!==void 0&&O(s=>s===t?s:(v(void 0),P(void 0),t))},[t]),o.useEffect(()=>{ze.current||!Ee(window.location.search).isNew||(ze.current=!0,Fe({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const c=oe(window.location.search);_(c.nameQuery),Z(c.statusFilter),J(g=>g===c.scheduleId?g:(v(void 0),P(void 0),c.scheduleId)),O(g=>{const E=t??c.agentFilter;return g===E?g:(v(void 0),P(void 0),E)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{ae({token:f,size:M,agentId:N,pinnedScheduleId:T})},[N,M,f,ae,T]),o.useEffect(()=>{if(T==null||A.trim().length>0)return;const s=d.find(c=>c.id===T);s!=null&&_(s.name)},[A,T,d]);const de=o.useMemo(()=>{if(T!=null)return d;const s=A.trim().toLowerCase();return d.filter(c=>!(L!=="all"&&c.status!==L||s.length>0&&!c.name.toLowerCase().includes(s)))},[d,A,L,T]),Re=ot(d),Ie=ne!=null||w!=null,st=async s=>{if(!j(s.id,"MANAGE"))return;const c=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:c}),l(Q.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:c}),await ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}catch(g){a==null||a.showError(g)}},nt=async s=>{if(j(s.id,"MANAGE")){z(c=>new Set(c).add(s.id));try{if(await n.createScheduleRun({scheduleId:s.id}),l(Q.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"}),T!=null){const g=await n.getSchedule({id:T});h(E=>{const D=E.length===1?E[0]:void 0;return D!=null&&D.id===g.id?[g]:E})}const c=await n.listScheduleRuns({scheduleId:s.id});k(g=>({...g,[s.id]:c}))}catch(c){a==null||a.showError(c)}finally{z(c=>{const g=new Set(c);return g.delete(s.id),g})}}},at=async s=>{if(j(s.id,"DELETE")){te(null);try{await n.deleteSchedule({id:s.id}),l(Q.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Ae()}catch(c){a==null||a.showError(c)}}},Pe=()=>{w!=null&&v(w)},De=()=>{ne==null||ne===""||v(ne)},pe=()=>{T!=null&&(J(null),v(void 0),P(void 0))};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(ct,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(dt,{query:A,setQuery:s=>{_(s),pe()},placeholder:"Search schedules by name"})}),e.jsx(xe,{value:L,onValueChange:s=>{Z(s),pe()},options:ts,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(qe,{value:N,selectedLabel:N==="all"?"All agents":m[N]??N,onValueChange:s=>{O(s),v(void 0),P(void 0),pe()},onAgentPicked:s=>{C(c=>({...c,[Ve(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs($.Primary,{type:"button",disabled:!le,onClick:()=>le&&X({kind:"create",agentId:N!=="all"?N:void 0}),children:[e.jsx(R,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:B("min-h-0 flex-1 overflow-auto px-4 py-4",re!=null?"flex flex-col":void 0),children:U?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,c)=>e.jsx(ut,{className:"h-12 w-full rounded-md"},c))}):re!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Ne,{title:"Couldn't load schedules",description:re,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(Ne,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):de.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Ne,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ie?e.jsx(_e,{pageSize:M,rowCount:0,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(mt,{className:"min-w-240",children:[e.jsx(ht,{children:e.jsxs(Le,{className:"hover:bg-transparent",children:[e.jsx(W,{children:"Schedule Name"}),e.jsx(W,{children:"Task"}),Re?e.jsx(W,{children:"Created by"}):null,e.jsx(W,{children:"Frequency"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Last 5 runs"}),e.jsx(W,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(xt,{children:de.map(s=>{const c=ce({cron:s.cron,timezone:s.timezone}),g=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(Le,{children:[e.jsxs(K,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(R,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:g})]})]}),e.jsx(K,{className:"w-64 max-w-64",children:e.jsx(We,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Re?e.jsx(K,{children:e.jsx(ft,{subject:s.createdBySubject})}):null,e.jsx(K,{children:c}),e.jsx(K,{children:e.jsx(et,{status:s.status})}),e.jsx(K,{children:p?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(es,{runs:x[s.id]??[],...b?{onOpenSession:E=>tt({run:E,schedule:s})}:{}})}),e.jsx(K,{className:"text-right",children:e.jsx(ns,{schedule:s,running:y.has(s.id),canManage:j(s.id,"MANAGE"),canDelete:j(s.id,"DELETE"),onRunNow:()=>void nt(s),onEdit:()=>{j(s.id,"MANAGE")&&X({kind:"edit",schedule:s})},onTogglePause:()=>void st(s),onDelete:()=>{j(s.id,"DELETE")&&te(s)}})})]},s.id)})})]}),(de.length>0||Ie)&&e.jsx(_e,{pageSize:M,rowCount:de.length,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}})]})}),V.kind==="create"?e.jsx($e,{open:!0,mode:"create",initialAgentId:V.agentId??"",onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>Ae()}):null,V.kind==="edit"?e.jsx($e,{open:!0,mode:"edit",schedule:V.schedule,onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>void ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}):null,ee!=null?e.jsxs(gt,{open:!0,onOpenChange:s=>{s||te(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(bt,{children:e.jsxs(pt,{children:[e.jsx(Nt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",ee.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(jt,{children:[e.jsx($.Secondary,{type:"button",onClick:()=>te(null),children:"Cancel"}),e.jsx($.Destructive,{type:"button",disabled:!j(ee.id,"DELETE"),onClick:()=>void at(ee),children:"Delete"})]})]}):null]})}export{ls as SchedulesPage};