@truefoundry/trueforge 0.180.0 → 0.181.0-rc.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 (237) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-SQIFBJRR-DzPCvf4d.js → AgentCodeSnippets-7YBGYKYT-COw5-jCA.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-COw5-jCA.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-COw5-jCA.js.gz +0 -0
  4. package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-DJTSZ671.js +1 -0
  5. package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-DJTSZ671.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-DJTSZ671.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-SONOXEA2-DVW9dpOp.js → AgentOverview-NCWC4XDZ-DqZqGo8V.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-DqZqGo8V.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-DqZqGo8V.js.gz +0 -0
  10. package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-BrVSrckq.js +1 -0
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-BrVSrckq.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-BrVSrckq.js.gz +0 -0
  13. package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-DAeb-1-p.js +1 -0
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-DAeb-1-p.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-DAeb-1-p.js.gz +0 -0
  16. package/dist/_frontend/assets/AgentSessions-V2V6W7CC-D1eUhvgn.js +1 -0
  17. package/dist/_frontend/assets/AgentSessions-V2V6W7CC-D1eUhvgn.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-V2V6W7CC-D1eUhvgn.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-FAMLKHRT-CbgoOQBA.js → ConnectorSettings-DYJ6Z6YL-DhF84SXP.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-DhF84SXP.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-DhF84SXP.js.gz +0 -0
  22. package/dist/_frontend/assets/DockLayout-YZPEWKJV-DyDyUCtl.js +1 -0
  23. package/dist/_frontend/assets/{DrawerLayout-MB3JP4YC-Cs4K8WbP.js → DrawerLayout-OWUKLUSV-DQnh_BPt.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-DQnh_BPt.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-DQnh_BPt.js.gz +0 -0
  26. package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-DT8-DDE7.js +3 -0
  27. package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-DT8-DDE7.js.br +0 -0
  28. package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-DT8-DDE7.js.gz +0 -0
  29. package/dist/_frontend/assets/{ModelSettings-KYX762EG-fzXe6Th3.js → ModelSettings-Y5NTNBCL-BFS8Ev0r.js} +1 -1
  30. package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BFS8Ev0r.js.br +0 -0
  31. package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BFS8Ev0r.js.gz +0 -0
  32. package/dist/_frontend/assets/{SandboxSettings-ZE4Z65F5-RaO5UYxl.js → SandboxSettings-KLDK6WZH-BB_J0XaX.js} +1 -1
  33. package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-BB_J0XaX.js.br +0 -0
  34. package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-BB_J0XaX.js.gz +0 -0
  35. package/dist/_frontend/assets/SchedulesPage-4F5FX65T-DVKEEd4R.js +1 -0
  36. package/dist/_frontend/assets/SchedulesPage-4F5FX65T-DVKEEd4R.js.br +0 -0
  37. package/dist/_frontend/assets/SchedulesPage-4F5FX65T-DVKEEd4R.js.gz +0 -0
  38. package/dist/_frontend/assets/SettingsBuilder-72KREKYT-Dmu76Wzi.js +2 -0
  39. package/dist/_frontend/assets/SettingsBuilder-72KREKYT-Dmu76Wzi.js.br +0 -0
  40. package/dist/_frontend/assets/SettingsBuilder-72KREKYT-Dmu76Wzi.js.gz +0 -0
  41. package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-C4RD0M9w.js +1 -0
  42. package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-C4RD0M9w.js.br +0 -0
  43. package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-C4RD0M9w.js.gz +0 -0
  44. package/dist/_frontend/assets/SidebarLayout-BWR7N76R-B3Zm0kWX.js +2 -0
  45. package/dist/_frontend/assets/SidebarLayout-BWR7N76R-B3Zm0kWX.js.br +0 -0
  46. package/dist/_frontend/assets/SidebarLayout-BWR7N76R-B3Zm0kWX.js.gz +0 -0
  47. package/dist/_frontend/assets/SkillSettings-F7X7TZII-DYRS-1zQ.js +1 -0
  48. package/dist/_frontend/assets/SkillSettings-F7X7TZII-DYRS-1zQ.js.br +0 -0
  49. package/dist/_frontend/assets/SkillSettings-F7X7TZII-DYRS-1zQ.js.gz +0 -0
  50. package/dist/_frontend/assets/{TrueForgeUIWithRouter-76JMT47N-CnpzH7-n.js → TrueForgeUIWithRouter-KPZEEO7D-BAuDAM4m.js} +1 -1
  51. package/dist/_frontend/assets/{WebSearchSettings-LFQ4V4FB-D7w_63MH.js → WebSearchSettings-VNL63UFQ-BL3QLgS_.js} +1 -1
  52. package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-BL3QLgS_.js.br +0 -0
  53. package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-BL3QLgS_.js.gz +0 -0
  54. package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-BXKkzHl9.js +1 -0
  55. package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-BXKkzHl9.js.br +0 -0
  56. package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-BXKkzHl9.js.gz +0 -0
  57. package/dist/_frontend/assets/{chunk-C43ZVKUS-ClJ9CpD6.js → chunk-HB2ZQ4CZ-DnCTK9KS.js} +1 -1
  58. package/dist/_frontend/assets/chunk-NRMAG6HF-BKTcpJl0.js +1 -0
  59. package/dist/_frontend/assets/chunk-NRMAG6HF-BKTcpJl0.js.br +0 -0
  60. package/dist/_frontend/assets/chunk-NRMAG6HF-BKTcpJl0.js.gz +0 -0
  61. package/dist/_frontend/assets/{chunk-OB3PAWPO-D3Luy7W3.js → chunk-OB3PAWPO-CDXWnkeP.js} +1 -1
  62. package/dist/_frontend/assets/chunk-OB3PAWPO-CDXWnkeP.js.br +0 -0
  63. package/dist/_frontend/assets/chunk-OB3PAWPO-CDXWnkeP.js.gz +0 -0
  64. package/dist/_frontend/assets/{chunk-ZSP5XG3J-9vEyCWu1.js → chunk-QYZB5BFZ-C1Zl8SCi.js} +2 -2
  65. package/dist/_frontend/assets/chunk-QYZB5BFZ-C1Zl8SCi.js.br +0 -0
  66. package/dist/_frontend/assets/chunk-QYZB5BFZ-C1Zl8SCi.js.gz +0 -0
  67. package/dist/_frontend/assets/{chunk-4BKRLRXL-DLUyrNQ3.js → chunk-XIE7TJW5-C05XSTa4.js} +1 -1
  68. package/dist/_frontend/assets/chunk-XIE7TJW5-C05XSTa4.js.br +0 -0
  69. package/dist/_frontend/assets/chunk-XIE7TJW5-C05XSTa4.js.gz +0 -0
  70. package/dist/_frontend/assets/{cssMode-JOuT28rz.js → cssMode-XDzIuvZX.js} +1 -1
  71. package/dist/_frontend/assets/cssMode-XDzIuvZX.js.br +6 -0
  72. package/dist/_frontend/assets/cssMode-XDzIuvZX.js.gz +0 -0
  73. package/dist/_frontend/assets/{freemarker2-CZJ58vDF.js → freemarker2-CMM6eRZY.js} +1 -1
  74. package/dist/_frontend/assets/freemarker2-CMM6eRZY.js.br +0 -0
  75. package/dist/_frontend/assets/freemarker2-CMM6eRZY.js.gz +0 -0
  76. package/dist/_frontend/assets/{handlebars-CUvie110.js → handlebars-zWdybys2.js} +1 -1
  77. package/dist/_frontend/assets/handlebars-zWdybys2.js.br +0 -0
  78. package/dist/_frontend/assets/handlebars-zWdybys2.js.gz +0 -0
  79. package/dist/_frontend/assets/{html-DD_vjw5l.js → html-FSsE5b6P.js} +1 -1
  80. package/dist/_frontend/assets/html-FSsE5b6P.js.br +0 -0
  81. package/dist/_frontend/assets/html-FSsE5b6P.js.gz +0 -0
  82. package/dist/_frontend/assets/{htmlMode-Bs5cHvWx.js → htmlMode-Ba0OQ7ke.js} +1 -1
  83. package/dist/_frontend/assets/htmlMode-Ba0OQ7ke.js.br +0 -0
  84. package/dist/_frontend/assets/htmlMode-Ba0OQ7ke.js.gz +0 -0
  85. package/dist/_frontend/assets/index-CHtf87eT.js +1019 -0
  86. package/dist/_frontend/assets/index-CHtf87eT.js.br +0 -0
  87. package/dist/_frontend/assets/index-CHtf87eT.js.gz +0 -0
  88. package/dist/_frontend/assets/{index-IV_K3kGI.js → index-DJwMhvnU.js} +3 -3
  89. package/dist/_frontend/assets/index-DJwMhvnU.js.br +0 -0
  90. package/dist/_frontend/assets/index-DJwMhvnU.js.gz +0 -0
  91. package/dist/_frontend/assets/{javascript-R_9qXwYL.js → javascript-Ce1crFvb.js} +1 -1
  92. package/dist/_frontend/assets/{jsonMode-8OQdDgk6.js → jsonMode-BMBeYqZi.js} +1 -1
  93. package/dist/_frontend/assets/jsonMode-BMBeYqZi.js.br +0 -0
  94. package/dist/_frontend/assets/jsonMode-BMBeYqZi.js.gz +0 -0
  95. package/dist/_frontend/assets/{liquid-BAdDEBi9.js → liquid-cKR-cSWX.js} +1 -1
  96. package/dist/_frontend/assets/liquid-cKR-cSWX.js.br +0 -0
  97. package/dist/_frontend/assets/liquid-cKR-cSWX.js.gz +0 -0
  98. package/dist/_frontend/assets/{lspLanguageFeatures-CNxTXCEe.js → lspLanguageFeatures-RvCvbT7h.js} +1 -1
  99. package/dist/_frontend/assets/lspLanguageFeatures-RvCvbT7h.js.br +0 -0
  100. package/dist/_frontend/assets/lspLanguageFeatures-RvCvbT7h.js.gz +0 -0
  101. package/dist/_frontend/assets/{mdx-zRCES-UR.js → mdx-DWyx_s0A.js} +1 -1
  102. package/dist/_frontend/assets/mdx-DWyx_s0A.js.br +0 -0
  103. package/dist/_frontend/assets/mdx-DWyx_s0A.js.gz +0 -0
  104. package/dist/_frontend/assets/{python-CHTiGyj6.js → python-BZT89b5u.js} +1 -1
  105. package/dist/_frontend/assets/python-BZT89b5u.js.br +0 -0
  106. package/dist/_frontend/assets/python-BZT89b5u.js.gz +0 -0
  107. package/dist/_frontend/assets/{razor-CU2s7Hbi.js → razor-C4RJ85c7.js} +1 -1
  108. package/dist/_frontend/assets/razor-C4RJ85c7.js.br +0 -0
  109. package/dist/_frontend/assets/razor-C4RJ85c7.js.gz +0 -0
  110. package/dist/_frontend/assets/{tsMode-CJLsaAN3.js → tsMode-BFOytUIs.js} +1 -1
  111. package/dist/_frontend/assets/tsMode-BFOytUIs.js.br +0 -0
  112. package/dist/_frontend/assets/tsMode-BFOytUIs.js.gz +0 -0
  113. package/dist/_frontend/assets/{typescript-C6qGKHm0.js → typescript-B_aWPfCP.js} +1 -1
  114. package/dist/_frontend/assets/typescript-B_aWPfCP.js.br +0 -0
  115. package/dist/_frontend/assets/typescript-B_aWPfCP.js.gz +0 -0
  116. package/dist/_frontend/assets/{workers-DeOwcFUN.js → workers-DhT6ONBN.js} +1 -1
  117. package/dist/_frontend/assets/workers-DhT6ONBN.js.br +0 -0
  118. package/dist/_frontend/assets/workers-DhT6ONBN.js.gz +0 -0
  119. package/dist/_frontend/assets/{xml-ccL_LPm9.js → xml-CIXW7ba5.js} +1 -1
  120. package/dist/_frontend/assets/xml-CIXW7ba5.js.br +0 -0
  121. package/dist/_frontend/assets/xml-CIXW7ba5.js.gz +0 -0
  122. package/dist/_frontend/assets/{yaml-YzcQ27WY.js → yaml-B06RGyXK.js} +1 -1
  123. package/dist/_frontend/assets/yaml-B06RGyXK.js.br +0 -0
  124. package/dist/_frontend/assets/yaml-B06RGyXK.js.gz +0 -0
  125. package/dist/_frontend/index.html +1 -1
  126. package/dist/controller-main.js +338 -200
  127. package/dist/controller-main.js.map +1 -1
  128. package/dist/main.js +1262 -437
  129. package/dist/main.js.map +1 -1
  130. package/dist/postgres/migrations/20260727_000001_init.js +1 -1
  131. package/dist/postgres/migrations/20260727_000001_init.js.map +1 -1
  132. package/dist/postgres/migrations/20261016_000001_schedule_run_session_id.js +22 -0
  133. package/dist/postgres/migrations/20261016_000001_schedule_run_session_id.js.map +1 -0
  134. package/dist/postgres/migrations/20261018_000001_session_last_turn_details.js +25 -0
  135. package/dist/postgres/migrations/20261018_000001_session_last_turn_details.js.map +1 -0
  136. package/dist/sqlite/migrations/20261016_000001_schedule_run_session_id.js +28 -0
  137. package/dist/sqlite/migrations/20261016_000001_schedule_run_session_id.js.map +1 -0
  138. package/dist/sqlite/migrations/20261018_000001_session_last_turn_details.js +26 -0
  139. package/dist/sqlite/migrations/20261018_000001_session_last_turn_details.js.map +1 -0
  140. package/package.json +9 -6
  141. package/dist/_frontend/assets/AgentCodeSnippets-SQIFBJRR-DzPCvf4d.js.br +0 -0
  142. package/dist/_frontend/assets/AgentCodeSnippets-SQIFBJRR-DzPCvf4d.js.gz +0 -0
  143. package/dist/_frontend/assets/AgentMetricChart-GGEDYHIM-D4y11_kp.js +0 -1
  144. package/dist/_frontend/assets/AgentMetricChart-GGEDYHIM-D4y11_kp.js.br +0 -0
  145. package/dist/_frontend/assets/AgentMetricChart-GGEDYHIM-D4y11_kp.js.gz +0 -0
  146. package/dist/_frontend/assets/AgentOverview-SONOXEA2-DVW9dpOp.js.br +0 -0
  147. package/dist/_frontend/assets/AgentOverview-SONOXEA2-DVW9dpOp.js.gz +0 -0
  148. package/dist/_frontend/assets/AgentSessionEventTimeline-VTUD4LL3-uCjuzqN4.js +0 -1
  149. package/dist/_frontend/assets/AgentSessionEventTimeline-VTUD4LL3-uCjuzqN4.js.br +0 -0
  150. package/dist/_frontend/assets/AgentSessionEventTimeline-VTUD4LL3-uCjuzqN4.js.gz +0 -0
  151. package/dist/_frontend/assets/AgentSessionEventTimelineChart-K3HU6HSO-XJLVw6b2.js +0 -1
  152. package/dist/_frontend/assets/AgentSessionEventTimelineChart-K3HU6HSO-XJLVw6b2.js.br +0 -0
  153. package/dist/_frontend/assets/AgentSessionEventTimelineChart-K3HU6HSO-XJLVw6b2.js.gz +0 -0
  154. package/dist/_frontend/assets/AgentSessions-5AD6ZDRM-C5RT7EY0.js +0 -1
  155. package/dist/_frontend/assets/AgentSessions-5AD6ZDRM-C5RT7EY0.js.br +0 -0
  156. package/dist/_frontend/assets/AgentSessions-5AD6ZDRM-C5RT7EY0.js.gz +0 -0
  157. package/dist/_frontend/assets/ConnectorSettings-FAMLKHRT-CbgoOQBA.js.br +0 -0
  158. package/dist/_frontend/assets/ConnectorSettings-FAMLKHRT-CbgoOQBA.js.gz +0 -0
  159. package/dist/_frontend/assets/DockLayout-6X5P5E3T-DKDOGTZ4.js +0 -1
  160. package/dist/_frontend/assets/DrawerLayout-MB3JP4YC-Cs4K8WbP.js.br +0 -0
  161. package/dist/_frontend/assets/DrawerLayout-MB3JP4YC-Cs4K8WbP.js.gz +0 -0
  162. package/dist/_frontend/assets/EnvironmentsPage-AD3I5BXA-B1Bwzgoh.js +0 -3
  163. package/dist/_frontend/assets/EnvironmentsPage-AD3I5BXA-B1Bwzgoh.js.br +0 -0
  164. package/dist/_frontend/assets/EnvironmentsPage-AD3I5BXA-B1Bwzgoh.js.gz +0 -0
  165. package/dist/_frontend/assets/ModelSettings-KYX762EG-fzXe6Th3.js.br +0 -0
  166. package/dist/_frontend/assets/ModelSettings-KYX762EG-fzXe6Th3.js.gz +0 -0
  167. package/dist/_frontend/assets/SandboxSettings-ZE4Z65F5-RaO5UYxl.js.br +0 -0
  168. package/dist/_frontend/assets/SandboxSettings-ZE4Z65F5-RaO5UYxl.js.gz +0 -0
  169. package/dist/_frontend/assets/SchedulesPage-QI2TK6XX-C_OjU_1-.js +0 -1
  170. package/dist/_frontend/assets/SchedulesPage-QI2TK6XX-C_OjU_1-.js.br +0 -0
  171. package/dist/_frontend/assets/SchedulesPage-QI2TK6XX-C_OjU_1-.js.gz +0 -0
  172. package/dist/_frontend/assets/SettingsBuilder-OTFRXULU-Cc6qAu_o.js +0 -2
  173. package/dist/_frontend/assets/SettingsBuilder-OTFRXULU-Cc6qAu_o.js.br +0 -0
  174. package/dist/_frontend/assets/SettingsBuilder-OTFRXULU-Cc6qAu_o.js.gz +0 -0
  175. package/dist/_frontend/assets/ShellRouteSync-ZNUJRPCZ-7PDpM3Tt.js +0 -1
  176. package/dist/_frontend/assets/ShellRouteSync-ZNUJRPCZ-7PDpM3Tt.js.br +0 -0
  177. package/dist/_frontend/assets/ShellRouteSync-ZNUJRPCZ-7PDpM3Tt.js.gz +0 -0
  178. package/dist/_frontend/assets/SidebarLayout-WMJUGCNE-DlivhNaL.js +0 -2
  179. package/dist/_frontend/assets/SidebarLayout-WMJUGCNE-DlivhNaL.js.br +0 -0
  180. package/dist/_frontend/assets/SidebarLayout-WMJUGCNE-DlivhNaL.js.gz +0 -0
  181. package/dist/_frontend/assets/SkillSettings-V2YF42KU-BJs98jMY.js +0 -1
  182. package/dist/_frontend/assets/SkillSettings-V2YF42KU-BJs98jMY.js.br +0 -0
  183. package/dist/_frontend/assets/SkillSettings-V2YF42KU-BJs98jMY.js.gz +0 -0
  184. package/dist/_frontend/assets/WebSearchSettings-LFQ4V4FB-D7w_63MH.js.br +0 -0
  185. package/dist/_frontend/assets/WebSearchSettings-LFQ4V4FB-D7w_63MH.js.gz +0 -0
  186. package/dist/_frontend/assets/WidgetLayout-TB2YRZUR-Bymizc6I.js +0 -1
  187. package/dist/_frontend/assets/WidgetLayout-TB2YRZUR-Bymizc6I.js.br +0 -0
  188. package/dist/_frontend/assets/WidgetLayout-TB2YRZUR-Bymizc6I.js.gz +0 -0
  189. package/dist/_frontend/assets/chunk-4BKRLRXL-DLUyrNQ3.js.br +0 -0
  190. package/dist/_frontend/assets/chunk-4BKRLRXL-DLUyrNQ3.js.gz +0 -0
  191. package/dist/_frontend/assets/chunk-OB3PAWPO-D3Luy7W3.js.br +0 -0
  192. package/dist/_frontend/assets/chunk-OB3PAWPO-D3Luy7W3.js.gz +0 -0
  193. package/dist/_frontend/assets/chunk-W7NO436B-9jA-ex4y.js +0 -1
  194. package/dist/_frontend/assets/chunk-W7NO436B-9jA-ex4y.js.br +0 -0
  195. package/dist/_frontend/assets/chunk-W7NO436B-9jA-ex4y.js.gz +0 -0
  196. package/dist/_frontend/assets/chunk-ZSP5XG3J-9vEyCWu1.js.br +0 -0
  197. package/dist/_frontend/assets/chunk-ZSP5XG3J-9vEyCWu1.js.gz +0 -0
  198. package/dist/_frontend/assets/cssMode-JOuT28rz.js.br +0 -0
  199. package/dist/_frontend/assets/cssMode-JOuT28rz.js.gz +0 -0
  200. package/dist/_frontend/assets/freemarker2-CZJ58vDF.js.br +0 -0
  201. package/dist/_frontend/assets/freemarker2-CZJ58vDF.js.gz +0 -0
  202. package/dist/_frontend/assets/handlebars-CUvie110.js.br +0 -0
  203. package/dist/_frontend/assets/handlebars-CUvie110.js.gz +0 -0
  204. package/dist/_frontend/assets/html-DD_vjw5l.js.br +0 -0
  205. package/dist/_frontend/assets/html-DD_vjw5l.js.gz +0 -0
  206. package/dist/_frontend/assets/htmlMode-Bs5cHvWx.js.br +0 -0
  207. package/dist/_frontend/assets/htmlMode-Bs5cHvWx.js.gz +0 -0
  208. package/dist/_frontend/assets/index-IV_K3kGI.js.br +0 -0
  209. package/dist/_frontend/assets/index-IV_K3kGI.js.gz +0 -0
  210. package/dist/_frontend/assets/index-JVnCghrh.js +0 -18
  211. package/dist/_frontend/assets/index-JVnCghrh.js.br +0 -0
  212. package/dist/_frontend/assets/index-JVnCghrh.js.gz +0 -0
  213. package/dist/_frontend/assets/index-PV6Uc-B5.js +0 -1000
  214. package/dist/_frontend/assets/index-PV6Uc-B5.js.br +0 -0
  215. package/dist/_frontend/assets/index-PV6Uc-B5.js.gz +0 -0
  216. package/dist/_frontend/assets/jsonMode-8OQdDgk6.js.br +0 -0
  217. package/dist/_frontend/assets/jsonMode-8OQdDgk6.js.gz +0 -0
  218. package/dist/_frontend/assets/liquid-BAdDEBi9.js.br +0 -0
  219. package/dist/_frontend/assets/liquid-BAdDEBi9.js.gz +0 -0
  220. package/dist/_frontend/assets/lspLanguageFeatures-CNxTXCEe.js.br +0 -0
  221. package/dist/_frontend/assets/lspLanguageFeatures-CNxTXCEe.js.gz +0 -0
  222. package/dist/_frontend/assets/mdx-zRCES-UR.js.br +0 -0
  223. package/dist/_frontend/assets/mdx-zRCES-UR.js.gz +0 -0
  224. package/dist/_frontend/assets/python-CHTiGyj6.js.br +0 -0
  225. package/dist/_frontend/assets/python-CHTiGyj6.js.gz +0 -0
  226. package/dist/_frontend/assets/razor-CU2s7Hbi.js.br +0 -0
  227. package/dist/_frontend/assets/razor-CU2s7Hbi.js.gz +0 -0
  228. package/dist/_frontend/assets/tsMode-CJLsaAN3.js.br +0 -0
  229. package/dist/_frontend/assets/tsMode-CJLsaAN3.js.gz +0 -0
  230. package/dist/_frontend/assets/typescript-C6qGKHm0.js.br +0 -0
  231. package/dist/_frontend/assets/typescript-C6qGKHm0.js.gz +0 -0
  232. package/dist/_frontend/assets/workers-DeOwcFUN.js.br +0 -0
  233. package/dist/_frontend/assets/workers-DeOwcFUN.js.gz +0 -0
  234. package/dist/_frontend/assets/xml-ccL_LPm9.js.br +0 -0
  235. package/dist/_frontend/assets/xml-ccL_LPm9.js.gz +0 -0
  236. package/dist/_frontend/assets/yaml-YzcQ27WY.js.br +0 -0
  237. package/dist/_frontend/assets/yaml-YzcQ27WY.js.gz +0 -0
@@ -1 +1 @@
1
- import{C as we}from"./chunk-C43ZVKUS-ClJ9CpD6.js";import{b6 as Ce,p as Ee,q as ke,r as l,v as W,j as e,S as Se,C as B,I as T,b7 as fe,b8 as ye,b9 as Me,ba as Le,c as P,bb as Pe,_ as de,a6 as Te}from"./index-PV6Uc-B5.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:$})=>{const[A,E]=l.useState(""),[q,x]=l.useState(""),[p,I]=l.useState(!1),U=()=>{E(""),x(""),I(!1)};l.useEffect(()=>{a&&(E(""),x(g),I(!1))},[a,g]);const H=d=>{d||U(),i(d)},R=A.trim(),_=!o||!!R,J=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:J,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:A,onChange:d=>{E(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)=>I(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:[$?e.jsx("p",{className:"text-failure-bg text-sm",children:$}):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()],Z="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 $e(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}),Ae=({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)??""),[$,A]=l.useState((o==null?void 0:o.baseUrl)??""),[E,q]=l.useState(""),[x,p]=l.useState(()=>ge(o)),[I,U]=l.useState(!1),[H,R]=l.useState(!1),_=()=>{M((o==null?void 0:o.name)??""),A((o==null?void 0:o.baseUrl)??""),q(""),p(ge(o)),U(!1),R(!1)},J=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=$.trim();let k=null;if(!z)k="Base URL is required.";else try{new URL(z)}catch{k="Enter a valid URL."}const Q=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=>!Q(s)&&!me(s)),X=I&&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:E.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}:{}}})}),J(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:J,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":X?!0:void 0,className:P(Z,h&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",X&&se)}),h?e.jsx(ce,{children:"Provider names cannot be changed after creation."}):null,X?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:$,onChange:s=>A(s.target.value),onBlur:()=>R(!0),placeholder:"http://localhost:11434/v1",autoFocus:h,"aria-invalid":V?!0:void 0,className:P(Z,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:E,onChange:s=>q(s.target.value),placeholder:"sk-…",className:Z}),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=Q(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:$e(D)}})},onBlur:()=>d(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":m?!0:void 0,className:P(Z,"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(Z,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(Z,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(Z,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(G=>G!==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"})]})]})})},Ie=Ae;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}=Ce(),i=Ee(),f=ke(),[j,N]=l.useState(""),[g,h]=l.useState([]),[o,K]=l.useState([]),[M,$]=l.useState(!0),[A,E]=l.useState(null),[q,x]=l.useState(null),[p,I]=l.useState(!1),[U,H]=l.useState(null),[R,_]=l.useState(null),[J,d]=l.useState(null),[ae,Y]=l.useState(!1),[v,z]=l.useState(null),[k,Q]=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(),X=l.useCallback(async()=>{$(!0),E(null);try{const[t,n]=await Promise.all([a.listModelProviders(),a.getModelProviderCatalog()]);h(t),K(n)}catch(t){E(W(t,"Failed to load model providers"))}finally{$(!1)}},[a]);l.useEffect(()=>{X()},[X]);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)=>{I(!0),E(null);try{await t(),await X(),m()}catch(c){throw n?n(c):i==null?E(W(c,"Request failed")):i.showError(c),c}finally{I(!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(W(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(W(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||(Q(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(W(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(()=>Q(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(W(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(W(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,G=R!=null?o.find(t=>t.type===R)??null:null,Ne=S!=null||G!=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."}),A?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:A}):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(C=>C.id)),L=n.filter(C=>!c.has(C.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),Q({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(C=>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:C.name}),t.models.length>1||a.deleteModelProvider?e.jsx("button",{type:"button","aria-label":`Remove ${C.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),Q({kind:"model",provider:t,model:C})},children:e.jsx(T,{name:"trash",className:"size-3.5"})}):null]},C.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(C=>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:C.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:p,onClick:()=>{ee({provider:t,models:[...t.models,C]}).catch(()=>{})},children:"Add"})]},C.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(G)return F(G,t)},title:S?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:S?S.baseUrl??"":G?ze(G):"",requireApiKey:S==null,submitLabel:S?"Save":"Create",busy:p,error:J}),e.jsx(Ie,{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-HB2ZQ4CZ-DnCTK9KS.js";import{bo as Ee,p as Ce,q as ke,r as l,x as W,j as e,S as Se,E as B,I as T,bp as fe,bq as ye,br as Me,bs as Le,c as P,bt as Pe,_ as de,aa as Te}from"./index-CHtf87eT.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:$})=>{const[A,C]=l.useState(""),[q,x]=l.useState(""),[p,I]=l.useState(!1),U=()=>{C(""),x(""),I(!1)};l.useEffect(()=>{a&&(C(""),x(g),I(!1))},[a,g]);const H=d=>{d||U(),i(d)},R=A.trim(),_=!o||!!R,J=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:J,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:A,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)=>I(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:[$?e.jsx("p",{className:"text-failure-bg text-sm",children:$}):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()],Z="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 $e(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}),Ae=({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)??""),[$,A]=l.useState((o==null?void 0:o.baseUrl)??""),[C,q]=l.useState(""),[x,p]=l.useState(()=>ge(o)),[I,U]=l.useState(!1),[H,R]=l.useState(!1),_=()=>{M((o==null?void 0:o.name)??""),A((o==null?void 0:o.baseUrl)??""),q(""),p(ge(o)),U(!1),R(!1)},J=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=$.trim();let k=null;if(!z)k="Base URL is required.";else try{new URL(z)}catch{k="Enter a valid URL."}const Q=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=>!Q(s)&&!me(s)),X=I&&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}:{}}})}),J(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:J,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":X?!0:void 0,className:P(Z,h&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",X&&se)}),h?e.jsx(ce,{children:"Provider names cannot be changed after creation."}):null,X?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:$,onChange:s=>A(s.target.value),onBlur:()=>R(!0),placeholder:"http://localhost:11434/v1",autoFocus:h,"aria-invalid":V?!0:void 0,className:P(Z,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:Z}),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=Q(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:$e(D)}})},onBlur:()=>d(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":m?!0:void 0,className:P(Z,"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(Z,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(Z,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(Z,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(G=>G!==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"})]})]})})},Ie=Ae;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,$]=l.useState(!0),[A,C]=l.useState(null),[q,x]=l.useState(null),[p,I]=l.useState(!1),[U,H]=l.useState(null),[R,_]=l.useState(null),[J,d]=l.useState(null),[ae,Y]=l.useState(!1),[v,z]=l.useState(null),[k,Q]=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(),X=l.useCallback(async()=>{$(!0),C(null);try{const[t,n]=await Promise.all([a.listModelProviders(),a.getModelProviderCatalog()]);h(t),K(n)}catch(t){C(W(t,"Failed to load model providers"))}finally{$(!1)}},[a]);l.useEffect(()=>{X()},[X]);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)=>{I(!0),C(null);try{await t(),await X(),m()}catch(c){throw n?n(c):i==null?C(W(c,"Request failed")):i.showError(c),c}finally{I(!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(W(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(W(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||(Q(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(W(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(()=>Q(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(W(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(W(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,G=R!=null?o.find(t=>t.type===R)??null:null,Ne=S!=null||G!=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."}),A?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:A}):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),Q({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),Q({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(G)return F(G,t)},title:S?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:S?S.baseUrl??"":G?ze(G):"",requireApiKey:S==null,submitLabel:S?"Save":"Create",busy:p,error:J}),e.jsx(Ie,{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 G}from"./chunk-C43ZVKUS-ClJ9CpD6.js";import{b6 as Y,p as H,q as J,r as a,v as L,bd as Q,j as e,I as T,C as O,b8 as W,b9 as Z,ba as ee,c as te,bb as se,_ as V,a6 as ae}from"./index-PV6Uc-B5.js";var ne={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},M=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:E=!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)},v=R(k),f=R(D),g=R(u),A=R(l),C=o.trim(),_=(!j||!!C)&&v!=null&&f!=null&&g!=null&&A!=null,B=async s=>{if(s.preventDefault(),!(!_||E||v==null||f==null||g==null||A==null))try{await p({execTimeoutMs:v,autoStopIntervalInMinutes:f,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:M})]}),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:M})]}),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:M})]}),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:M})]}),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:M})]})]})]})]}),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:!_||E,className:"w-full shrink-0",children:"Save"})]})]})})},le=re,q=({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c})=>({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c}),oe=()=>{const{sandboxCatalog:n}=Y(),r=H(),p=J(),[c,z]=a.useState([]),[y,j]=a.useState([]),[E,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),v=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(L(i,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[n]);a.useEffect(()=>{v()},[v]);const f=c.length>0,g=a.useMemo(()=>{if(f)return[];const t=new Set(c.map(i=>i.catalogId));return y.filter(i=>!t.has(i.id))},[y,c,f]),A=a.useMemo(()=>{const t=o??l;return t==null||!Q(t)?null:q(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 v({quiet:!0})}catch(F){throw i(L(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,...q(t),apiKey:t.apiKey})},d),x(null),setTimeout(()=>{r==null||r.showSuccess({title:`${l.name} configured`}),p(V.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,...q(t),...t.apiKey?{apiKey:t.apiKey}:{}})},d),b(null),setTimeout(()=>{r==null||r.showSuccess({title:`${o.name} updated`}),p(V.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(V.Settings.SANDBOX_PROVIDER_DELETED,{provider_name:t.name}),h(null)},I).catch(()=>{}))},$=l!=null||o!=null,U=o!=null,X=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:E?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,f?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(G,{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:U?B:_,title:X,description:U?"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:!U,busy:u,error:D})]})},ce=oe;export{ce as default};
1
+ import{C as G}from"./chunk-HB2ZQ4CZ-DnCTK9KS.js";import{bo as Y,p as H,q as J,r as a,x as L,bv as Q,j as e,I as T,E as O,bq as W,br as Z,bs as ee,c as te,bt as se,_ as U,aa as ae}from"./index-CHtf87eT.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)},v=R(k),f=R(D),g=R(u),A=R(l),C=o.trim(),_=(!j||!!C)&&v!=null&&f!=null&&g!=null&&A!=null,B=async s=>{if(s.preventDefault(),!(!_||M||v==null||f==null||g==null||A==null))try{await p({execTimeoutMs:v,autoStopIntervalInMinutes:f,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}=Y(),r=H(),p=J(),[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),v=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(L(i,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[n]);a.useEffect(()=>{v()},[v]);const f=c.length>0,g=a.useMemo(()=>{if(f)return[];const t=new Set(c.map(i=>i.catalogId));return y.filter(i=>!t.has(i.id))},[y,c,f]),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 v({quiet:!0})}catch(F){throw i(L(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,q=o!=null,X=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,f?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(G,{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:q?B:_,title:X,description:q?"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:!q,busy:u,error:D})]})},ce=oe;export{ce as default};
@@ -0,0 +1 @@
1
+ import{B as st}from"./chunk-XIE7TJW5-C05XSTa4.js";import{l as ye,o as Oe,p as ve,q as Me,t as $e,v as nt,r as o,w as be,x as at,y as Re,z as Se,A as rt,j as e,P as lt,S as it,B as me,C as Be,D as Ue,E as L,I as A,F as ot,G as he,H as Pe,J as ct,K as dt,L as De,M as V,N as ut,O as W,k as Ge,Q as mt,c as O,R as xt,U as ht,V as ft,W as gt,X as bt,Y as pt,Z as Nt,_ as K,$ as jt,a0 as yt,u as vt,a1 as St,a2 as fe,a3 as kt,a4 as wt,a5 as Tt,a6 as Ct,a7 as Et,a8 as zt,a9 as At,aa as ge,ab as Rt,ac as Pt,ad as Dt}from"./index-CHtf87eT.js";var Ie=[{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 He(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function It(t){const n=He(),r=new Set(Ie.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}])),...Ie]}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"}],Ft={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function xe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:He()}}function _t(t){return Ft[t]??t.split("/").pop()??t}function Ve(t){return t.toString().padStart(2,"0")}function ce({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ve(n)} ${r}`}function pe(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((c,v)=>c-v),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function Ne(t){return t.trim().split(/\s+/).length===5}function ae(t){const n=_t(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,c,v,g]=r;if(c!=="*"||v!=="*")return t.cron;const d=Number(a),x=Number(l);if(l==="*"&&g==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ve(d)} ${n}`;if(g==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d))return`Daily ${ce({hour:x,minute:d})} ${n}`;if(g==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d))return`Weekdays ${ce({hour:x,minute:d})} ${n}`;if(g!=null&&/^\d(?:,\d)*$/.test(g)&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d)){const N=g.split(",").map(h=>{var k;return((k=qe.find(b=>b.value===Number(h)))==null?void 0:k.label)??h});return N.length===1?`Every ${N[0]==="Mon"?"Monday":N[0]} ${ce({hour:x,minute:d})} ${n}`:`${N.join(", ")} ${ce({hour:x,minute:d})} ${n}`}return t.cron}function Fe(t){const n=xe(),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,c,v,g]=r,d=Number(a),x=Number(l);return c!=="*"||v!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&g==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:g==="*"&&!Number.isNaN(x)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:x,minute:d,customCron:t.cron}:g!=null&&/^\d(?:,\d)*$/.test(g)&&!Number.isNaN(x)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:x,minute:d,weekdays:g.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(x)?n.hour:x,minute:Number.isNaN(d)?n.minute:d}}function Lt(t,n=Date.now()){return Dt(t,{fallback:"Never",nowMs:n})}var Ot=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Mt=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),$t=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Bt({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:c,agentPickerDisabled:v=!1,onBuildAgent:g}){const d=pe(t),x=ae({cron:d,timezone:t.timezone}),N=It(t.timezone),h=(i,j)=>{n({...t,[i]:j})},k=i=>{const j=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:j})},b=i=>{const C=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:C.length>0?C:[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(Be,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:c,disabled:v||l==null,onBuildAgent:g})]}),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=>h("name",i.target.value),placeholder:"harness-daily-digest",className:ge("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=>h("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ge("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:Ot.map(i=>{const j=t.recurrence===i.value;return e.jsx("button",{type:"button",className:O("rounded-md border px-2 py-2 text-sm font-medium transition-colors",j?"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":j,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=>h("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!Ne(t.customCron),className:O(ge("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."}),Ne(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 j=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:O("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",j?"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":j,onClick:()=>b(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(me,{"aria-label":"Hour",value:String(t.hour),options:Mt,onValueChange:i=>h("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(me,{"aria-label":"Minute",value:String(t.minute),options:$t,onValueChange:i=>h("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(me,{"aria-label":"Timezone",value:t.timezone,options:N,onValueChange:i=>h("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(A,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:x||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function Ut(t){return t.startsWith("manual-")}function Gt(t){return t==="failed"?"failed":"success"}function We(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Ke(t){return Ut(t)?"Manual test":"Cron"}function Ht(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function je(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":zt(n)}function qt({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:We(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Ke(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",je(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",je(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 Vt={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 Qe({run:t,onOpenSession:n}){const r=Gt(t.status),a=je(t.triggeredAt??t.scheduledFor),l=`${We(t.status)} run at ${a}`,c=O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Vt[r]),v=e.jsx(A,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(Ge,{content:e.jsx(qt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:O(c,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:v}):e.jsx("span",{className:c,"aria-label":l,children:v})})}function Ye({status:t}){const n=t==="active";return e.jsx(st,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Wt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Kt({connector:t,onConnected:n}){return Rt()==null?null:e.jsx(Pt,{connector:t,onConnected:n})}function ne({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 Qt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=ye(),c=ve(),{connectors:v,ensureLoaded:g,refreshConnectors:d,loading:x,error:N}=At(),[h,k]=o.useState(!1),[b,i]=o.useState(null),j=ae({cron:t.cron,timezone:t.timezone}),C=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),c==null||c.showSuccess({title:"Test run started"})}catch(m){c==null||c.showError(m)}finally{k(!1)}};return o.useEffect(()=>{g()},[g]),o.useEffect(()=>{N!=null&&(c==null||c.showError(N))},[N,c]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ne,{label:"Agent",children:n}),e.jsx(ne,{label:"Name",children:t.name}),e.jsx(ne,{label:"Status",children:e.jsx(Ye,{status:t.status})}),e.jsx(ne,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ne,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:j}),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(L.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),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 T=Wt(v,m.name),M=(T==null?void 0:T.authenticated)===!0,B=T==null&&!x;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:O("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",M?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:M?e.jsx(A,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),M?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):B?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):T!=null&&T.authenticated===!1?e.jsx(Kt,{connector:T,onConnected:d}):x?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(L.Primary,{type:"button",disabled:h,size:"small",onClick:()=>void C(),children:[e.jsx(A,{name:h?"loader":"play",className:O("size-3.5",h&&"animate-spin")}),"Run Test"]})]}),b==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(Qe,{run:b}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Ke(b.name)}),e.jsx("p",{className:"text-text-secondary",children:Lt(b.triggeredAt??b.scheduledFor)})]})]})]})]})}function Yt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:c}){const v=ye(),g=Oe(),d=$e(),x=ve(),N=Me(),[h,k]=o.useState(xe),[b,i]=o.useState(l),[j,C]=o.useState(null),[m,T]=o.useState({kind:"form"}),[M,B]=o.useState(!1),[se,Q]=o.useState(!1),[P,_]=o.useState(null),D=o.useRef(b);D.current=b;const Y=m.kind==="form"?m.saved:m.schedule,p=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,I=m.kind==="form"&&m.saved!=null,U=r==="create"&&m.kind==="form"&&m.saved==null,{allows:re}=be({resourceType:"agent",resourceIds:b.length===0?[]:[b]});o.useEffect(()=>{if(!t){k(xe()),i(l),C(null),_(null),T({kind:"form"}),Q(!1);return}if(r==="edit"&&a!=null){k(Fe({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),C(null),T({kind:"form"});return}k(xe()),i(l),C(null),T({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const E=l;return Tt({server:g,agentKey:E}).then(y=>{f||y==null||D.current===E&&(C(y),i(Ue(y)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,g]);const Z=(j==null?void 0:j.name)??(Y==null?void 0:Y.agentName)??(a==null?void 0:a.agentName)??(b.length>0?b:""),J=o.useMemo(()=>{var E;return(((E=j==null?void 0:j.agentSpec)==null?void 0:E.mcpServers)??[]).map(Ct).filter(y=>y!=null).map(y=>({name:y}))},[j]),G=o.useMemo(()=>{const f=pe(h);return h.name.trim().length>0&&h.task.trim().length>0&&Ne(f)&&b.length>0&&(!U||re(b,"USE"))},[b,re,h,U]),H=f=>{T({kind:"test",schedule:f}),k(Fe({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!G)return;const E=pe(h);B(!0),_(null);try{if(p&&a!=null){await v.updateSchedule({id:a.id,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:a.status}),N(K.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),c==null||c(),n(!1);return}if(I&&m.kind==="form"&&m.saved!=null){const w=await v.updateSchedule({id:m.saved.id,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:"paused"});N(K.Schedule.EDITED,{schedule_id:w.id,agent_id:w.agentId}),c==null||c(),H(w),x==null||x.showSuccess({title:"Schedule saved as paused",description:ae({cron:w.cron,timezone:w.timezone})});return}const y=await v.createSchedule({agentId:b,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:"paused"});N(K.Schedule.CREATED,{schedule_id:y.id,agent_id:b}),c==null||c(),H(y),x==null||x.showSuccess({title:"Schedule saved as paused",description:ae({cron:y.cron,timezone:y.timezone})})}catch(y){const w=y instanceof Error?y.message:"Failed to save schedule";_(w)}finally{B(!1)}},F=async()=>{if(m.kind==="test"){Q(!0),_(null);try{await v.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),c==null||c(),x==null||x.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const E=f instanceof Error?f.message:"Failed to activate schedule";_(E),x==null||x.showError(f)}finally{Q(!1)}}},le=m.kind==="test"?"Test Schedule":p||I?"Edit Schedule":"New Schedule",ee=m.kind==="test"?`Recurring unattended runs of ${Z}.`:p||I?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let R;return m.kind==="test"?R=e.jsxs("div",{className:"flex flex-col gap-2",children:[P!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:P}):null,e.jsx(L.Secondary,{type:"button",className:"w-full",disabled:se,onClick:()=>void F(),children:"Activate Schedule"})]}):R=e.jsxs("div",{className:"flex flex-col gap-2",children:[P!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:P}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(L.Secondary,{type:"button",onClick:()=>n(!1),disabled:M,children:"Cancel"}),e.jsx(L.Primary,{type:"submit",form:"schedule-form",disabled:!G||M,children:"Save"})]})]}),e.jsx(Et,{open:t,onOpenChange:n,title:le,description:ee,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(A,{name:m.kind==="test"||p||I?"calendar":"calendar-plus",className:"size-5"})}),footer:R,children:m.kind==="test"?e.jsx(Qt,{schedule:m.schedule,agentName:Z,mcpMounts:J,onEditConfiguration:()=>{_(null),T({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Bt,{values:h,onChange:k,agentId:b,agentLabel:Z,onAgentIdChange:p||I?void 0:f=>{i(f),f.length===0&&C(null)},onAgentPicked:C,agentPickerDisabled:p||I,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function _e(t){return e.jsx(wt,{children:e.jsx(Yt,{...t})})}function Zt({runs:t,onOpenSession:n}){const r=Ht(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(Qe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var Jt=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Le=[10,25];function de(t){return Math.min(Math.max(t,1),25)}function ue(t){const n=Se(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all"}}function Xt(t){const n=Se(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function es({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:c,onTogglePause:v,onDelete:g}){const d=vt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs(L.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(A,{name:n?"loader":"play",className:O("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(St,{align:"end",trigger:e.jsx("button",{type:"button",className:kt({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(A,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(fe,{onClick:c,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(fe,{onClick:v,children:[e.jsx(A,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(fe,{className:"text-failure-bg focus:text-failure-bg",onClick:g,children:[e.jsx(A,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ns({agentId:t}){const n=ye(),r=Oe(),a=ve(),l=Me(),c=$e(),v=nt(),g=c!=null&&Nt({sessions:v}),[d,x]=o.useState([]),{allows:N}=be({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[h,k]=o.useState({}),[b,i]=o.useState(!1),[j,C]=o.useState(()=>new Set),[m,T]=o.useState({}),[M,B]=o.useState(!0),[se,Q]=o.useState(null),[P,_]=o.useState(()=>ue(window.location.search).nameQuery),[D,Y]=o.useState(()=>ue(window.location.search).statusFilter),[p,I]=o.useState(()=>t??ue(window.location.search).agentFilter),U=t??(p==="all"?null:p),{allows:re}=be({resourceType:"agent",resourceIds:U==null?[]:[U]}),Z=r.permissions==null||U==null||re(U,"USE"),[J,G]=o.useState(()=>Xt(t)),[H,X]=o.useState(null),[F,le]=o.useState(()=>de(pt)),[ee,R]=o.useState(void 0),[f,E]=o.useState(void 0),[y,w]=o.useState(void 0),Ze=({run:s,schedule:u})=>{if(!g||c==null||s.sessionId==null)return;l(K.Schedule.RUN_SESSION_OPENED,{schedule_id:u.id,agent_id:u.agentId});const S=jt(s.triggeredAt??s.scheduledFor);yt({sessionId:s.sessionId,view:"sessions",...S==null?{}:{timeRange:S}}),c.setSessionsOpen(!0)},q=o.useRef(0),ke=o.useRef(!1),we=o.useCallback(async({rows:s,gen:u})=>{if(s.length===0){u===q.current&&k({});return}i(!0);try{const S=await Promise.allSettled(s.map(z=>n.listScheduleRuns({scheduleId:z.id})));if(u!==q.current)return;k(Object.fromEntries(s.map((z,$)=>{const oe=S[$],tt=(oe==null?void 0:oe.status)==="fulfilled"?oe.value:[];return[z.id,tt]})))}finally{u===q.current&&i(!1)}},[n]),te=o.useCallback(async({token:s,size:u,agentId:S})=>{const z=++q.current;B(!0),Q(null);try{const $=await n.listSchedules({limit:de(u),...s===void 0||s===""?{}:{pageToken:s},...S==="all"?{}:{agentIds:[S]}});if(z!==q.current)return;x($.data),E($.nextPageToken),w($.previousPageToken),we({rows:$.data,gen:z})}catch($){if(z!==q.current)return;Q(at($,"Check your connection and try again.")),x([]),k({}),E(void 0),w(void 0)}finally{z===q.current&&B(!1)}},[n,we]),Te=o.useCallback(s=>{const u=(s==null?void 0:s.size)??F,S=(s==null?void 0:s.agentId)??p;R(void 0),w(void 0),te({token:void 0,size:u,agentId:S})},[p,te,F]);o.useEffect(()=>{Re({agent:t===void 0&&p!=="all"?p:null,status:D==="all"?null:D,q:P.trim().length===0?null:P})},[p,t,D,P]),o.useEffect(()=>{t!==void 0&&I(s=>s===t?s:(R(void 0),w(void 0),t))},[t]),o.useEffect(()=>{ke.current||!Se(window.location.search).isNew||(ke.current=!0,Re({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const u=ue(window.location.search);_(u.nameQuery),Y(u.statusFilter),I(S=>{const z=t??u.agentFilter;return S===z?S:(R(void 0),w(void 0),z)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{te({token:ee,size:F,agentId:p})},[p,F,ee,te]);const ie=o.useMemo(()=>{const s=P.trim().toLowerCase();return d.filter(u=>!(D!=="all"&&u.status!==D||s.length>0&&!u.name.toLowerCase().includes(s)))},[d,P,D]),Ce=rt(d),Ee=y!=null||f!=null,Je=async s=>{if(!N(s.id,"MANAGE"))return;const u=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:u}),l(K.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:u}),await te({token:ee,size:F,agentId:p})}catch(S){a==null||a.showError(S)}},Xe=async s=>{if(N(s.id,"MANAGE")){C(u=>new Set(u).add(s.id));try{await n.createScheduleRun({scheduleId:s.id}),l(K.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"});const u=await n.listScheduleRuns({scheduleId:s.id});k(S=>({...S,[s.id]:u}))}catch(u){a==null||a.showError(u)}finally{C(u=>{const S=new Set(u);return S.delete(s.id),S})}}},et=async s=>{if(N(s.id,"DELETE")){X(null);try{await n.deleteSchedule({id:s.id}),l(K.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Te()}catch(u){a==null||a.showError(u)}}},ze=()=>{f!=null&&R(f)},Ae=()=>{y==null||y===""||R(y)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(lt,{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(it,{query:P,setQuery:_,placeholder:"Search schedules by name"})}),e.jsx(me,{value:D,onValueChange:Y,options:Jt,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(Be,{value:p,selectedLabel:p==="all"?"All agents":m[p]??p,onValueChange:s=>{I(s),R(void 0),w(void 0)},onAgentPicked:s=>{T(u=>({...u,[Ue(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs(L.Primary,{type:"button",disabled:!Z,onClick:()=>Z&&G({kind:"create",agentId:p!=="all"?p:void 0}),children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:O("min-h-0 flex-1 overflow-auto px-4 py-4",se!=null?"flex flex-col":void 0),children:M?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,u)=>e.jsx(ot,{className:"h-12 w-full rounded-md"},u))}):se!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(he,{title:"Couldn't load schedules",description:se,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(he,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):ie.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(he,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ee?e.jsx(Pe,{pageSize:F,rowCount:0,canPrev:y!=null,canNext:f!=null,onPrev:Ae,onNext:ze,pageSizeOptions:Le,onPageSizeChange:s=>{const u=de(s);le(u),R(void 0),w(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(ct,{className:"min-w-240",children:[e.jsx(dt,{children:e.jsxs(De,{className:"hover:bg-transparent",children:[e.jsx(V,{children:"Schedule Name"}),e.jsx(V,{children:"Task"}),Ce?e.jsx(V,{children:"Created by"}):null,e.jsx(V,{children:"Frequency"}),e.jsx(V,{children:"Status"}),e.jsx(V,{children:"Last 5 runs"}),e.jsx(V,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(ut,{children:ie.map(s=>{const u=ae({cron:s.cron,timezone:s.timezone}),S=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(De,{children:[e.jsxs(W,{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(A,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S})]})]}),e.jsx(W,{className:"w-64 max-w-64",children:e.jsx(Ge,{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})})}),Ce?e.jsx(W,{children:e.jsx(mt,{subject:s.createdBySubject})}):null,e.jsx(W,{children:u}),e.jsx(W,{children:e.jsx(Ye,{status:s.status})}),e.jsx(W,{children:b?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(Zt,{runs:h[s.id]??[],...g?{onOpenSession:z=>Ze({run:z,schedule:s})}:{}})}),e.jsx(W,{className:"text-right",children:e.jsx(es,{schedule:s,running:j.has(s.id),canManage:N(s.id,"MANAGE"),canDelete:N(s.id,"DELETE"),onRunNow:()=>void Xe(s),onEdit:()=>{N(s.id,"MANAGE")&&G({kind:"edit",schedule:s})},onTogglePause:()=>void Je(s),onDelete:()=>{N(s.id,"DELETE")&&X(s)}})})]},s.id)})})]}),(ie.length>0||Ee)&&e.jsx(Pe,{pageSize:F,rowCount:ie.length,canPrev:y!=null,canNext:f!=null,onPrev:Ae,onNext:ze,pageSizeOptions:Le,onPageSizeChange:s=>{const u=de(s);le(u),R(void 0),w(void 0)}})]})}),J.kind==="create"?e.jsx(_e,{open:!0,mode:"create",initialAgentId:J.agentId??"",onOpenChange:s=>{s||G({kind:"closed"})},onSaved:()=>Te()}):null,J.kind==="edit"?e.jsx(_e,{open:!0,mode:"edit",schedule:J.schedule,onOpenChange:s=>{s||G({kind:"closed"})},onSaved:()=>void te({token:ee,size:F,agentId:p})}):null,H!=null?e.jsxs(xt,{open:!0,onOpenChange:s=>{s||X(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(ht,{children:e.jsxs(ft,{children:[e.jsx(gt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",H.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(bt,{children:[e.jsx(L.Secondary,{type:"button",onClick:()=>X(null),children:"Cancel"}),e.jsx(L.Destructive,{type:"button",disabled:!N(H.id,"DELETE"),onClick:()=>void et(H),children:"Delete"})]})]}):null]})}export{ns as SchedulesPage};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-Y5NTNBCL-BFS8Ev0r.js","./chunk-HB2ZQ4CZ-DnCTK9KS.js","./index-CHtf87eT.js","./index-B01pXqvC.css","./ConnectorSettings-DYJ6Z6YL-DhF84SXP.js","./SkillSettings-F7X7TZII-DYRS-1zQ.js","./SandboxSettings-KLDK6WZH-BB_J0XaX.js","./WebSearchSettings-VNL63UFQ-BL3QLgS_.js"])))=>i.map(i=>d[i]);
2
+ import{b9 as j,ab as E,bl as k,q as C,a9 as N,bm as O,b1 as D,r as l,_ as g,j as e,P as L,I as v,a3 as I,c as f,bn as P,b6 as d,b4 as A}from"./index-CHtf87eT.js";var T=l.lazy(()=>d(()=>import("./ModelSettings-Y5NTNBCL-BFS8Ev0r.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),z=l.lazy(()=>d(()=>import("./ConnectorSettings-DYJ6Z6YL-DhF84SXP.js"),__vite__mapDeps([4,1,2,3]),import.meta.url)),M=l.lazy(()=>d(()=>import("./SkillSettings-F7X7TZII-DYRS-1zQ.js"),__vite__mapDeps([5,1,2,3]),import.meta.url)),R=l.lazy(()=>d(()=>import("./SandboxSettings-KLDK6WZH-BB_J0XaX.js"),__vite__mapDeps([6,1,2,3]),import.meta.url)),B=l.lazy(()=>d(()=>import("./WebSearchSettings-VNL63UFQ-BL3QLgS_.js"),__vite__mapDeps([7,2,3]),import.meta.url));function V(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(A,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var W=({headerStart:y}={})=>{const{settingsOpen:a,settingsSection:t,setSettingsOpen:r}=j(),n=E(),b=k(),m=C(),{refresh:p}=N(),S=O(),w=D(),i=S||w,o=(n==null?void 0:n.skillCatalog)!=null,c=(n==null?void 0:n.sandboxCatalog)!=null,u=(n==null?void 0:n.webSearchCatalog)!=null,x=l.useCallback(()=>{m(g.Settings.CLOSED,{section:t}),r(!1)},[t,r,m]);l.useEffect(()=>{if(a)return()=>{p(),b==null||b()}},[a,p,b]),l.useEffect(()=>{!o&&t==="skills"&&r(a,"models"),!c&&t==="sandbox"&&r(a,"models"),!u&&t==="web-search"&&r(a,"models")},[o,c,u,t,a,r]),l.useEffect(()=>{if(!a)return;const s=h=>{h.key==="Escape"&&(P()||(h.stopImmediatePropagation(),x()))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,a]);const _=l.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),u&&s.push({id:"web-search",label:"Web search",icon:"search"}),s},[o,c,u]);return!a||!n?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden bg-primary-bg",children:[e.jsx(L,{title:"Settings",start:y??e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:I({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(v,{name:"arrow-left"})})}),e.jsxs("div",{className:f("flex min-h-0 min-w-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full min-w-0 gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"overflow-x-auto":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:_.map(s=>e.jsxs("button",{type:"button","aria-current":t===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",t===s.id?"bg-primary-button-bg/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{m(g.Settings.SECTION_CHANGED,{section:s.id}),r(!0,s.id)},children:[e.jsx(v,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-hidden px-4 py-4 sm:px-6",children:e.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full min-w-0 max-w-210 flex-col",children:e.jsxs(l.Suspense,{fallback:e.jsx(V,{}),children:[t==="models"?e.jsx(T,{}):null,t==="connectors"?e.jsx(z,{}):null,t==="skills"&&o?e.jsx(M,{}):null,t==="sandbox"&&c?e.jsx(R,{}):null,t==="web-search"&&u?e.jsx(B,{}):null]})})})]})]})},q=W;export{q as default};
@@ -0,0 +1 @@
1
+ import{b9 as ce,d as pe,ab as ge,v as fe,ba as ye,bb as he,bc as de,b as me,bd as Se,r as a,be,bf as Ae,x as Oe,bg as ve,D as Ne,bh as _,bi as C,bj as ne,bk as B}from"./index-CHtf87eT.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-CDXWnkeP.js";var T="try_agent_name",$="history_agent_name";function te(t){return t!=null&&t.length>0?t:null}function k(t){const o=new URLSearchParams(t.startsWith("?")?t.slice(1):t),u=te(o.get(T));if(u!=null)return{intent:"try-agent",agentName:u};const e=te(o.get($));return e==null?null:{intent:"history",agentName:e}}function Pe(t,o){t.delete(T),t.delete($),o!=null&&t.set(o.intent==="try-agent"?T:$,o.agentName)}function se(t,o){const u=new URLSearchParams(t.startsWith("?")?t.slice(1):t);Pe(u,o);const e=u.toString();return e.length>0?`?${e}`:""}function re(t){const o=t.sessionAccessError!=null?t.pendingSessionId:t.activeRemoteId??t.pendingSessionId;if(o!=null)return{type:"session",sessionId:o};const{mode:u,agentConfigMode:e}=t;if(u.status==="active"&&u.isMutable&&u.isCreateAgent)return{type:"buildAgent"};if(u.status==="active"&&!u.isMutable&&e!=="SingleAgent"){const p=u.agentName??u.agentId;if(p!=null)return{type:"agent",agentName:p}}return{type:"root"}}function Ce(t){return t.settingsOpen?{type:"settings"}:t.schedulesOpen?{type:"schedules"}:t.environmentsOpen?{type:"environments"}:t.sessionsOpen&&t.sharedSessionId!=null?{type:"sharedSession",sessionId:t.sharedSessionId}:t.sessionsOpen?{type:"sessionsBrowser"}:t.libraryOpen&&t.libraryAgentId!=null?{type:"libraryAgent",agentId:t.libraryAgentId}:t.libraryOpen?{type:"library"}:re(t)}function O(t){return t.type==="root"||t.type==="agent"||t.type==="session"}function Ie(t){return t.type==="sessionsBrowser"||t.type==="sharedSession"}function Le({routes:t,activeRemoteId:o,initialSettingsOpen:u}){var Z,x;const e=ce(),p=pe(),q=ge(),v=fe(),I=ye(),U=he(),G=de(),K=me(),W=Se(),H=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:K,sessions:v,schedules:U,sandboxEnvironments:G}),[t,q,K,v,U,G]),Y=c.settings!=null,ae=[c.settings,c.sessionsBrowser,c.sharedSession,c.libraryAgent,c.schedules,c.environments].join("\0"),j={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,sharedSessionId:e.sharedSessionId,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,environmentsOpen:e.environmentsOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:o,sessionAccessError:e.sessionAccessError,mode:e.mode,agentConfigMode:e.agentConfigMode},g=Ce(j),ie=JSON.stringify(g),S=a.useRef(null),w=a.useRef(null),N=a.useRef(null),R=a.useRef(!1),b=a.useRef(null),[le,oe]=a.useState(0),m=a.useRef(null),L=a.useRef(null),D=`${e.runtimeKey}\0${e.pendingSessionEpoch}`,M=a.useRef(D);M.current=D;const f=a.useRef(null),Q=a.useRef(!1),z=a.useRef(!1),J=a.useCallback(()=>{switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.setEnvironmentsOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}},[e]),A=a.useCallback(n=>{const s=b.current;(s==null?void 0:s.type)==="session"&&s.sessionId===n&&(b.current=null,oe(l=>l+1))},[]),V=a.useCallback(n=>{if(L.current=n,p==null){e.openHistorySession({sessionId:n});return}const s=M.current,l=I==null||v==null?Promise.resolve(!0):I.listPermissions({resourceType:"session",resourceIds:[n]}).then(i=>(i.data.permissions[n]??[]).includes("MANAGE")).catch(()=>!0);Promise.all([p.getSession({sessionId:n}),l]).then(([i,y])=>{if(L.current!==n){A(n);return}if(!y){A(n),e.openSharedSession(n);return}e.openHistorySession({sessionId:n,isMutable:i.isMutable,isCreateAgent:Ae(i),...i.agentName!=null?{agentName:i.agentName}:{}})}).catch(i=>{if(L.current!==n){A(n);return}if(M.current!==s){A(n);return}e.openInaccessibleSession({sessionId:n,message:Oe(i,"This session could not be loaded.")})})},[I,A,p,v,e]),d=a.useCallback(n=>{if(n==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const s=`${n.intent}\0${n.agentName}`,l=e.historyAgentFilter;if((l==null?void 0:l.intent)===n.intent&&l.agentName===n.agentName&&l.agentId!=null){f.current=null;return}f.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(f.current===s){if(i==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{f.current===s&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[p,e]),X=a.useCallback(n=>{e.selectLibraryAgent({isMutable:!1,agentName:n}),d({intent:"try-agent",agentName:n})},[d,e]),F=a.useCallback(n=>{switch(n.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"sharedSession":e.openSharedSession(n.sessionId);return;case"libraryAgent":e.openLibraryAgent(n.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"environments":e.setEnvironmentsOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===n.sessionId||o===n.sessionId)return;V(n.sessionId);return;case"agent":e.setLibraryOpen(!1),X(n.agentName);return;case"root":J();return}},[e,o,J,X,V]);return a.useEffect(()=>{if(R.current)return;const n=_({pathname:r.pathname,search:r.search,routes:t});if(!W&&(n==null?void 0:n.type)==="settings")return;R.current=!0;const s=_({pathname:r.pathname,search:r.search,routes:c})??{type:"root"},l=s.type==="agent"?{intent:"try-agent",agentName:s.agentName}:O(s)?k(r.search):null;m.current=l,N.current=s;const i=Y&&(u||s.type==="settings");if(s.type==="settings")Y&&e.setSettingsOpen(!0);else if(s.type==="library")e.setLibraryOpen(!0);else if(s.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(s.type==="libraryAgent")e.openLibraryAgent(s.agentId);else if(s.type==="schedules")e.setSchedulesOpen(!0);else if(s.type==="environments")e.setEnvironmentsOpen(!0);else{const P=re(j);C(P,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const y=i?{type:"settings"}:s;b.current=C(g,y)?null:y;const h=ne(y,c),E=se(B(y,r.search),l);w.current=y,h!=null&&(h!==r.pathname||E!==r.search)&&(S.current=h!==r.pathname?h:null,H({pathname:h,search:E,hash:r.hash},{replace:!0}))},[W]),a.useEffect(()=>{if(!R.current)return;if(!Q.current){Q.current=!0;return}const n=b.current;if(n!=null){if(!C(g,n))return;b.current=null}const s=ne(g,c);if(s==null)return;const i=`${c.basename.endsWith("/")?c.basename.slice(0,-1):c.basename}${r.pathname}`||"/",y=window.location.pathname===i?window.location.search:r.search,h=O(g),E=h?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!h&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const P=se(B(g,y),E),ee=w.current;if(w.current=g,s===r.pathname&&P===r.search)return;const ue=g.type==="session"&&e.pendingSessionId==null&&ee!=null&&ee.type!=="session";S.current=s!==r.pathname?s:null,H({pathname:s,search:P,hash:r.hash},{replace:ue})},[ie,ae,le,(Z=e.historyAgentFilter)==null?void 0:Z.agentName,(x=e.historyAgentFilter)==null?void 0:x.intent]),a.useEffect(()=>{if(!R.current)return;if(!z.current){z.current=!0;return}if(S.current===r.pathname){S.current=null,N.current=g;return}const n=_({pathname:r.pathname,search:r.search,routes:c});if(n==null){const l=c.root,i=B({type:"root"},r.search);S.current=l,H({pathname:l,search:i,hash:r.hash},{replace:!0}),F({type:"root"}),d(k(i));return}const s=N.current;N.current=n,(s==null||!C(s,n))&&(n.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),n.type!=="library"&&n.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),!Ie(n)&&e.sessionsOpen&&e.setSessionsOpen(!1),n.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),n.type!=="environments"&&e.environmentsOpen&&e.setEnvironmentsOpen(!1),F(n)),n.type!=="agent"&&O(n)?d(k(r.search)):O(n)||d(null)},[r.pathname,r.search]),null}export{Le as ShellRouteSync};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-72KREKYT-Dmu76Wzi.js","./index-CHtf87eT.js","./index-B01pXqvC.css","./SchedulesPage-4F5FX65T-DVKEEd4R.js","./chunk-XIE7TJW5-C05XSTa4.js","./EnvironmentsPage-KOMO4W53-DT8-DDE7.js"])))=>i.map(i=>d[i]);
2
+ import{cj as _,ck as Jt,b0 as Y,j as r,cl as en,r as m,bD as E,cm as Xe,cn as tn,co as Ye,cp as qe,cq as Qe,cr as Ze,cs as Je,ct as Z,cu as nn,cv as N,cw as rn,cx as sn,cy as on,cz as an,cA as cn,cB as ln,cC as un,cD as dn,cE as je,cF as mn,cG as fn,cH as me,cI as pn,cJ as hn,cK as xn,cL as et,cM as Fe,cN as fe,cO as Me,cP as ae,cQ as Se,cR as Ce,cS as Le,cT as Ke,d as Re,q as tt,t as ne,u as C,w as gn,cU as vn,c as z,p as bn,cV as wn,_ as le,bB as ue,cW as ge,cX as yn,b1 as Te,bm as nt,cY as In,S as jn,a2 as $e,I as H,D as Mn,a3 as te,cZ as rt,c_ as Sn,c$ as Cn,d0 as Ln,d1 as ze,bq as Rn,aa as Tn,E as Ge,b3 as st,d2 as Nn,P as Pn,d3 as En,b4 as ve,b5 as Dn,d4 as ot,d5 as at,bP as An,b6 as Ne,d6 as _n,cg as On}from"./index-CHtf87eT.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-NRMAG6HF-BKTcpJl0.js";const Pe=n=>{const e=_(8),{index:t,archived:s,children:o}=n;let i;e[0]!==s||e[1]!==t?(i=Jt({source:"threads",query:{type:"index",index:t,archived:s},get:u=>u.threads().item({index:t,archived:s})}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let c;e[3]!==i?(c={threadListItem:i},e[3]=i,e[4]=c):c=e[4];const a=Y(c);let d;return e[5]!==a||e[6]!==o?(d=r.jsx(en,{value:a,children:o}),e[5]=a,e[6]=o,e[7]=d):d=e[7],d},ct=m.memo(n=>{const e=_(6),{index:t,archived:s,components:o}=n,i=s===void 0?!1:s,c=o.ThreadListItem;let a;e[0]!==c?(a=r.jsx(c,{}),e[0]=c,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==t||e[4]!==a?(d=r.jsx(Pe,{index:t,archived:i,children:a}),e[2]=i,e[3]=t,e[4]=a,e[5]=d):d=e[5],d},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);ct.displayName="ThreadListPrimitive.ItemByIndex";const He=({archived:n,children:e})=>{const t=E(s=>n?s.threads.archivedThreadIds.length:s.threads.threadIds.length);return Xe(()=>Array.from({length:t},(s,o)=>r.jsx(Pe,{index:o,archived:n,children:r.jsx(tn,{getItemState:i=>i.threads().item({index:o,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},o)),[t,n,e])},lt=n=>{const e=_(8),{archived:t,components:s,children:o}=n,i=t===void 0?!1:t;if(s){const a=s.ThreadListItem;let d;e[0]!==a?(d=()=>r.jsx(a,{}),e[0]=a,e[1]=d):d=e[1];let u;return e[2]!==i||e[3]!==d?(u=r.jsx(He,{archived:i,children:d}),e[2]=i,e[3]=d,e[4]=u):u=e[4],u}let c;return e[5]!==i||e[6]!==o?(c=r.jsx(He,{archived:i,children:o}),e[5]=i,e[6]=o,e[7]=c):c=e[7],c};lt.displayName="ThreadListPrimitive.Items";const ut=n=>{const e=_(2),{fallback:t}=n,s=E(Kn)||t;let o;return e[0]!==s?(o=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=o):o=e[1],o};ut.displayName="ThreadListItemPrimitive.Title";function Kn(n){return n.threadListItem.title}const $n=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={archive:s},n[2]=s,n[3]=o):o=n[3],o},zn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={delete:s},n[2]=s,n[3]=o):o=n[3],o},Gn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={unarchive:s},n[2]=s,n[3]=o):o=n[3],o},Hn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchTo:s},n[2]=s,n[3]=o):o=n[3],o},Un=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchToNewThread:s},n[2]=s,n[3]=o):o=n[3],o},Vn=()=>{const n=_(5),e=Y(),t=E(Wn);let s;n[0]!==e?(s=()=>{e.threads().loadMore()},n[0]=e,n[1]=s):s=n[1];const o=s;let i;return n[2]!==t||n[3]!==o?(i={loadMore:o,disabled:t},n[2]=t,n[3]=o,n[4]=i):i=n[4],i};function Wn(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var Xn=Object.defineProperty,L=(n,e)=>Xn(n,"name",{value:e,configurable:!0}),Yn=["Enter"," "],qn=["ArrowDown","PageUp","Home"],dt=["ArrowUp","PageDown","End"],Qn=[...qn,...dt],pe="Menu",[we,Zn,Jn]=Ze(pe),[J,mt]=Ye(pe,[Jn,qe,Qe]),Ee=qe(),ft=Qe(),[er,ie]=J(pe),[tr,De]=J(pe),nr=L(n=>{const{__scopeMenu:e,open:t=!1,children:s,dir:o,onOpenChange:i,modal:c=!0}=n,a=Ee(e),[d,u]=m.useState(null),l=m.useRef(!1),h=fn(i),p=me(o);return m.useEffect(()=>{const f=L(()=>{l.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},"handleKeyDown"),x=L(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),m.useEffect(()=>{if(!t)return;const f=L(()=>h(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[t,h]),r.jsx(pn,{...a,children:r.jsx(er,{scope:e,open:t,onOpenChange:h,content:d,onContentChange:u,children:r.jsx(tr,{scope:e,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:l,dir:p,modal:c,children:s})})})},"Menu"),rr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e,i=Ee(s);return r.jsx(hn,{...i,...o,ref:t})},"MenuAnchor")),pt="MenuPortal",[sr,or]=J(pt,{forceMount:void 0}),ar=L(n=>{const{__scopeMenu:e,forceMount:t,children:s,container:o}=n,i=ie(pt,e);return r.jsx(sr,{scope:e,forceMount:t,children:r.jsx(Je,{present:t||i.open,children:r.jsx(xn,{asChild:!0,container:o,children:s})})})},"MenuPortal"),Q="MenuContent",[ir,ht]=J(Q),cr=m.forwardRef(L(function(e,t){const s=or(Q,e.__scopeMenu),{forceMount:o=s.forceMount,...i}=e,c=ie(Q,e.__scopeMenu),a=De(Q,e.__scopeMenu);return r.jsx(we.Provider,{scope:e.__scopeMenu,children:r.jsx(Je,{present:o||c.open,children:r.jsx(we.Slot,{scope:e.__scopeMenu,children:a.modal?r.jsx(lr,{...i,ref:t}):r.jsx(ur,{...i,ref:t})})})})},"MenuContent")),lr=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu),o=m.useRef(null),i=Z(t,o);return m.useEffect(()=>{const c=o.current;if(c)return nn(c)},[]),r.jsx(xt,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:N(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),ur=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu);return r.jsx(xt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),dr=mn("MenuContent.ScrollLock"),xt=m.forwardRef(L(function(e,t){const{__scopeMenu:s,loop:o=!1,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:a,disableOutsidePointerEvents:d,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,disableOutsideScroll:g,...I}=e,j=ie(Q,s),M=De(Q,s),y=Ee(s),B=ft(s),P=Zn(s),[F,K]=m.useState(null),O=m.useRef(null),S=Z(t,O,j.onContentChange),R=m.useRef(0),T=m.useRef(""),U=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),G=m.useRef(0),W=g?sn:m.Fragment,w=g?{as:dr,allowPinchZoom:!0}:void 0,D=L(v=>{var ee,ke;const A=T.current+v,k=P().filter(q=>!q.disabled),X=document.activeElement,he=(ee=k.find(q=>q.ref.current===X))==null?void 0:ee.textValue,xe=k.map(q=>q.textValue),Oe=yt(xe,A,he),oe=(ke=k.find(q=>q.textValue===Oe))==null?void 0:ke.ref.current;L((function q(Be){T.current=Be,window.clearTimeout(R.current),Be!==""&&(R.current=window.setTimeout(()=>q(""),1e3))}),"updateSearch")(A),oe&&setTimeout(()=>oe.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(R.current),[]),rn();const b=m.useCallback(v=>{var k,X;return V.current===((k=$.current)==null?void 0:k.side)&&jt(v,(X=$.current)==null?void 0:X.area)},[]);return r.jsx(ir,{scope:s,searchRef:T,onItemEnter:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),onItemLeave:m.useCallback(v=>{var A;b(v)||((A=O.current)==null||A.focus(),K(null))},[b]),onTriggerLeave:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),pointerGraceTimerRef:U,onPointerGraceIntentChange:m.useCallback(v=>{$.current=v},[]),children:r.jsx(W,{...w,children:r.jsx(on,{asChild:!0,trapped:i,onMountAutoFocus:N(c,v=>{var A;v.preventDefault(),(A=O.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:r.jsx(an,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,children:r.jsx(cn,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:K,onEntryFocus:N(u,v=>{M.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(ln,{role:"menu","aria-orientation":"vertical","data-state":gt(j.open),"data-radix-menu-content":"",dir:M.dir,...y,...I,ref:S,style:{outline:"none",...I.style},onKeyDown:N(I.onKeyDown,v=>{const k=v.target.closest("[data-radix-menu-content]")===v.currentTarget,X=v.ctrlKey||v.altKey||v.metaKey,he=v.key.length===1;k&&(v.key==="Tab"&&v.preventDefault(),!X&&he&&D(v.key));const xe=O.current;if(v.target!==xe||!Qn.includes(v.key))return;v.preventDefault();const oe=P().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dt.includes(v.key)&&oe.reverse(),bt(oe)}),onBlur:N(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),T.current="")}),onPointerMove:N(e.onPointerMove,de(v=>{const A=v.target,k=G.current!==v.clientX;if(v.currentTarget.contains(A)&&k){const X=v.clientX>G.current?"right":"left";V.current=X,G.current=v.clientX}}))})})})})})})},"MenuContentImpl")),ye="MenuItem",Ue="menu.itemSelect",mr=m.forwardRef(L(function(e,t){const{disabled:s=!1,onSelect:o,...i}=e,c=m.useRef(null),a=De(ye,e.__scopeMenu),d=ht(ye,e.__scopeMenu),u=Z(t,c),l=m.useRef(!1),h=L(()=>{const p=c.current;if(!s&&p){const f=new CustomEvent(Ue,{bubbles:!0,cancelable:!0});p.addEventListener(Ue,x=>o==null?void 0:o(x),{once:!0}),un(p,f),f.defaultPrevented?l.current=!1:a.onClose()}},"handleSelect");return r.jsx(fr,{...i,ref:u,disabled:s,onClick:N(e.onClick,h),onPointerDown:p=>{var f;(f=e.onPointerDown)==null||f.call(e,p),l.current=!0},onPointerUp:N(e.onPointerUp,p=>{var f;l.current||(f=p.currentTarget)==null||f.click()}),onKeyDown:N(e.onKeyDown,p=>{s||p.target!==p.currentTarget||d.searchRef.current!==""&&p.key===" "||Yn.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),fr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,disabled:o=!1,textValue:i,...c}=e,a=ht(ye,s),d=ft(s),u=m.useRef(null),l=Z(t,u),[h,p]=m.useState(!1),[f,x]=m.useState("");return m.useEffect(()=>{const g=u.current;g&&x((g.textContent??"").trim())},[c.children]),r.jsx(we.ItemSlot,{scope:s,disabled:o,textValue:i??f,children:r.jsx(dn,{asChild:!0,...d,focusable:!o,children:r.jsx(je.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...c,ref:l,onPointerMove:N(e.onPointerMove,de(g=>{o?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:N(e.onPointerLeave,de(g=>a.onItemLeave(g))),onFocus:N(e.onFocus,()=>p(!0)),onBlur:N(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),pr="MenuRadioGroup",[js,Ms]=J(pr,{value:void 0,onValueChange:L(()=>{},"onValueChange")}),hr="MenuItemIndicator",[Ss,Cs]=J(hr,{checked:!1}),xr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e;return r.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})},"MenuSeparator")),gr="MenuSub",[Ls,Rs]=J(gr);function gt(n){return n?"open":"closed"}L(gt,"getOpenState");function vt(n){return n==="indeterminate"}L(vt,"isIndeterminate");function vr(n){return vt(n)?"indeterminate":n?"checked":"unchecked"}L(vr,"getCheckedState");function bt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}L(bt,"focusFirst");function wt(n,e){return n.map((t,s)=>n[(e+s)%n.length])}L(wt,"wrapArray");function yt(n,e,t){const o=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let c=wt(n,Math.max(i,0));o.length===1&&(c=c.filter(u=>u!==t));const d=c.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==t?d:void 0}L(yt,"getNextMatch");function It(n,e){const{x:t,y:s}=n;let o=!1;for(let i=0,c=e.length-1;i<e.length;c=i++){const a=e[i],d=e[c],u=a.x,l=a.y,h=d.x,p=d.y;l>s!=p>s&&t<(h-u)*(s-l)/(p-l)+u&&(o=!o)}return o}L(It,"isPointInPolygon");function jt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return It(t,e)}L(jt,"isPointerInGraceArea");function de(n){return e=>e.pointerType==="mouse"?n(e):void 0}L(de,"whenMouse");var br=nr,wr=rr,yr=ar,Ir=cr,jr=mr,Mr=xr,Sr=Object.defineProperty,re=(n,e)=>Sr(n,"name",{value:e,configurable:!0}),Ae="DropdownMenu",[Cr,Mt]=Ye(Ae,[mt]),se=mt(),[Lr,St]=Cr(Ae),Ct=re(n=>{const{__scopeDropdownMenu:e,children:t,dir:s,open:o,defaultOpen:i,onOpenChange:c,modal:a=!0}=n,d=se(e),u=m.useRef(null),[l,h]=et({prop:o,defaultProp:i??!1,onChange:c,caller:Ae});return r.jsx(Lr,{scope:e,triggerId:Fe(),triggerRef:u,contentId:Fe(),open:l,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),modal:a,children:r.jsx(br,{...d,open:l,onOpenChange:h,dir:s,modal:a,children:t})})},"DropdownMenu"),Rr="DropdownMenuTrigger",Lt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,disabled:o=!1,...i}=e,c=St(Rr,s),a=se(s),d=Z(t,c.triggerRef);return r.jsx(wr,{asChild:!0,...a,children:r.jsx(je.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":o?"":void 0,disabled:o,...i,ref:d,onPointerDown:N(e.onPointerDown,u=>{!o&&u.button===0&&u.ctrlKey===!1&&(c.onOpenToggle(),c.open||u.preventDefault())}),onKeyDown:N(e.onKeyDown,u=>{o||(["Enter"," "].includes(u.key)&&c.onOpenToggle(),u.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),Rt=re(n=>{const{__scopeDropdownMenu:e,...t}=n,s=se(e);return r.jsx(yr,{...s,...t})},"DropdownMenuPortal"),Tr="DropdownMenuContent",Tt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=St(Tr,s),c=se(s),a=m.useRef(!1);return r.jsx(Ir,{id:i.contentId,"aria-labelledby":i.triggerId,...c,...o,ref:t,onCloseAutoFocus:N(e.onCloseAutoFocus,d=>{var u;a.current||(u=i.triggerRef.current)==null||u.focus(),a.current=!1,d.preventDefault()}),onInteractOutside:N(e.onInteractOutside,d=>{const u=d.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,h=u.button===2||l;(!i.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Nt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(jr,{...i,...o,ref:t})},"DropdownMenuItem")),Pt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(Mr,{...i,...o,ref:t})},"DropdownMenuSeparator")),Et=Ct,Dt=Lt,Nr=Rt,At=Tt,_t=Nt,Ot=Pt;const Pr=Object.freeze(Object.defineProperty({__proto__:null,Content:At,DropdownMenu:Ct,DropdownMenuContent:Tt,DropdownMenuItem:Nt,DropdownMenuPortal:Rt,DropdownMenuSeparator:Pt,DropdownMenuTrigger:Lt,Item:_t,Portal:Nr,Root:Et,Separator:Ot,Trigger:Dt,createDropdownMenuScope:Mt},Symbol.toStringTag,{value:"Module"})),Er=fe(Dt),Dr=fe(At),Ar=fe(_t),_r=fe(Ot),kt=m.forwardRef((n,e)=>{const t=_(15);let s,o,i;t[0]!==n?({onClick:o,disabled:s,...i}=n,t[0]=n,t[1]=s,t[2]=o,t[3]=i):(s=t[1],o=t[2],i=t[3]);const c=E(Or),{switchToNewThread:a}=Un();let d;t[4]!==c?(d=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=d):d=t[5];let u;t[6]!==o||t[7]!==a?(u=N(o,a),t[6]=o,t[7]=a,t[8]=u):u=t[8];let l;return t[9]!==s||t[10]!==e||t[11]!==i||t[12]!==d||t[13]!==u?(l=r.jsx(Me.button,{type:"button",...d,...i,ref:e,disabled:s,onClick:u}),t[9]=s,t[10]=e,t[11]=i,t[12]=d,t[13]=u,t[14]=l):l=t[14],l});kt.displayName="ThreadListPrimitive.New";function Or(n){return n.threads.newThreadId===n.threads.mainThreadId}const kr=()=>{const{loadMore:n,disabled:e}=Vn();return e?null:n},Br=ae("ThreadListPrimitive.LoadMore",kr),[Fr,Kr]=Ze("ThreadList"),Ie=Fr,Bt=Ce(null),$r=Bt.Provider,_e=()=>Se(Bt),Ft=m.forwardRef((n,e)=>{const t=_(3);let s;return t[0]!==n||t[1]!==e?(s=r.jsx(Ie.Provider,{scope:void 0,children:r.jsx(Ie.Slot,{scope:void 0,children:r.jsx(Me.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=s):s=t[2],s});Ft.displayName="ThreadListPrimitive.Root";var zr=Le({ItemByIndex:()=>ct,Items:()=>lt,LoadMore:()=>Br,New:()=>kt,Root:()=>Ft});const Kt=m.forwardRef((n,e)=>{const t=E(u=>u.threads.mainThreadId===u.threadListItem.id),s=Ke(null),o=Ke(null),i=Xe(()=>({triggerRef:s,moreRef:o}),[]),c=Kr(void 0),a=me(),d=u=>{const l=a==="rtl"?"ArrowLeft":"ArrowRight",h=a==="rtl"?"ArrowRight":"ArrowLeft",p=s.current,f=o.current;if(p&&u.target===p)if(u.key==="ArrowDown"||u.key==="ArrowUp"){const x=c().map(I=>I.ref.current).filter(I=>I!==null),g=x[x.indexOf(p)+(u.key==="ArrowDown"?1:-1)];g&&(g.focus(),u.preventDefault())}else u.key===l&&f&&(f.focus(),u.preventDefault());else f&&u.target===f&&u.key===h&&(p==null||p.focus(),u.preventDefault())};return r.jsx($r,{value:i,children:r.jsx(Me.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:N(n.onKeyDown,d),ref:e})})});Kt.displayName="ThreadListItemPrimitive.Root";const Gr=()=>{const{archive:n}=$n();return n},Hr=ae("ThreadListItemPrimitive.Archive",Gr),Ur=()=>{const{unarchive:n}=Gn();return n},Vr=ae("ThreadListItemPrimitive.Unarchive",Ur),Wr=()=>{const{delete:n}=zn();return n},Xr=ae("ThreadListItemPrimitive.Delete",Wr),Yr=()=>{const{switchTo:n}=Hn();return n},qr=ae("ThreadListItemPrimitive.Trigger",Yr),$t=m.forwardRef((n,e)=>{var i;const t=_(3),s=Z(e,(i=_e())==null?void 0:i.triggerRef);let o;return t[0]!==n||t[1]!==s?(o=r.jsx(Ie.ItemSlot,{scope:void 0,children:r.jsx(qr,{...n,ref:s})}),t[0]=n,t[1]=s,t[2]=o):o=t[2],o});$t.displayName="ThreadListItemPrimitive.Trigger";var zt=Le({Archive:()=>Hr,Delete:()=>Xr,Root:()=>Kt,Title:()=>ut,Trigger:()=>$t,Unarchive:()=>Vr});const ce=Mt(),Gt=Ce(()=>{}),Ht=()=>Se(Gt),Ut=Ce(!1),Vt=()=>Se(Ut),Wt=n=>{const e=_(26);let t,s,o,i,c,a,d;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:s,onOpenChange:i,sharedFocusGroup:d,modal:o,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=c,e[6]=a,e[7]=d):(t=e[1],s=e[2],o=e[3],i=e[4],c=e[5],a=e[6],d=e[7]);const u=d===void 0?!1:d,l=u?!1:o??!0,h=ce(t),p=s??!1;let f;e[8]!==i?(f=i?{onChange:i}:{},e[8]=i,e[9]=f):f=e[9];let x;e[10]!==c||e[11]!==p||e[12]!==f?(x={prop:c,defaultProp:p,caller:"ThreadListItemMorePrimitive.Root",...f},e[10]=c,e[11]=p,e[12]=f,e[13]=x):x=e[13];const[g,I]=et(x);let j;e[14]!==l||e[15]!==g||e[16]!==a||e[17]!==h||e[18]!==I?(j=r.jsx(Et,{...h,...a,modal:l,open:g,onOpenChange:I}),e[14]=l,e[15]=g,e[16]=a,e[17]=h,e[18]=I,e[19]=j):j=e[19];let M;e[20]!==I||e[21]!==j?(M=r.jsx(Gt.Provider,{value:I,children:j}),e[20]=I,e[21]=j,e[22]=M):M=e[22];let y;return e[23]!==u||e[24]!==M?(y=r.jsx(Ut.Provider,{value:u,children:M}),e[23]=u,e[24]=M,e[25]=y):y=e[25],y};Wt.displayName="ThreadListItemMorePrimitive.Root";const Xt=m.forwardRef((n,e)=>{const t=_(10),{__scopeThreadListItemMore:s,...o}=n,i=ce(s),c=_e(),a=Ht(),d=Vt(),u=Z(e,c==null?void 0:c.moreRef),l=me()==="rtl"?"ArrowLeft":"ArrowRight",h=Er;let p;t[0]!==l||t[1]!==a||t[2]!==d?(p=g=>{!d||g.key!==l||(g.preventDefault(),a(!0))},t[0]=l,t[1]=a,t[2]=d,t[3]=p):p=t[3];const f=N(o.onKeyDown,p);let x;return t[4]!==h||t[5]!==u||t[6]!==o||t[7]!==i||t[8]!==f?(x=r.jsx(h,{...i,...o,onKeyDown:f,ref:u}),t[4]=h,t[5]=u,t[6]=o,t[7]=i,t[8]=f,t[9]=x):x=t[9],x});Xt.displayName="ThreadListItemMorePrimitive.Trigger";const Yt=m.forwardRef((n,e)=>{const t=_(21),{__scopeThreadListItemMore:s,portalProps:o,sideOffset:i,...c}=n,a=i===void 0?4:i,d=ce(s),u=Ht(),l=_e(),h=Vt(),p=me()==="rtl"?"ArrowRight":"ArrowLeft",f=Pr,x=Dr;let g;t[0]!==p||t[1]!==(l==null?void 0:l.moreRef)||t[2]!==u||t[3]!==h?(g=P=>{var F;!h||P.key!==p||(P.preventDefault(),u(!1),(F=l==null?void 0:l.moreRef.current)==null||F.focus())},t[0]=p,t[1]=l==null?void 0:l.moreRef,t[2]=u,t[3]=h,t[4]=g):g=t[4];const I=N(c.onKeyDown,g);let j;t[5]!==(l==null?void 0:l.moreRef)||t[6]!==h?(j=()=>{var P;h&&((P=l==null?void 0:l.moreRef.current)==null||P.focus())},t[5]=l==null?void 0:l.moreRef,t[6]=h,t[7]=j):j=t[7];const M=N(c.onEscapeKeyDown,j);let y;t[8]!==x||t[9]!==e||t[10]!==c||t[11]!==d||t[12]!==a||t[13]!==I||t[14]!==M?(y=r.jsx(x,{...d,...c,onKeyDown:I,onEscapeKeyDown:M,ref:e,sideOffset:a}),t[8]=x,t[9]=e,t[10]=c,t[11]=d,t[12]=a,t[13]=I,t[14]=M,t[15]=y):y=t[15];let B;return t[16]!==o||t[17]!==d||t[18]!==f.Portal||t[19]!==y?(B=r.jsx(f.Portal,{...d,...o,children:y}),t[16]=o,t[17]=d,t[18]=f.Portal,t[19]=y,t[20]=B):B=t[20],B});Yt.displayName="ThreadListItemMorePrimitive.Content";const qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(Ar,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});qt.displayName="ThreadListItemMorePrimitive.Item";const Qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(_r,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});Qt.displayName="ThreadListItemMorePrimitive.Separator";var be=Le({Content:()=>Yt,Item:()=>qt,Root:()=>Wt,Separator:()=>Qt,Trigger:()=>Xt});function Qr(){const n=ne(),e=Re(),t=Te(),s=nt(),o=t||s,[i,c]=m.useState(!1),[a,d]=m.useState(""),[u,l]=m.useState(null),h=m.useRef(null),p=m.useRef(null),f=m.useId(),x=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,g=(n==null?void 0:n.historyAgentFilter)??null;m.useEffect(()=>{i||d("")},[i]);const{agents:I,isInitialLoading:j,isSearching:M,loadingMore:y,hasMore:B,listRef:P,sentinelRef:F}=In({enabled:i&&x,query:a});if(m.useLayoutEffect(()=>{if(!i||o){l(null);return}const S=()=>{var T;const R=(T=h.current)==null?void 0:T.getBoundingClientRect();R&&l({top:R.top,left:R.right+4})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,o]),m.useEffect(()=>{if(!i||o)return;const S=R=>{var U,$;const T=R.target;(U=h.current)!=null&&U.contains(T)||($=p.current)!=null&&$.contains(T)||c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i,o]),!x)return null;const K=S=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(S),c(!1)},O=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"p-1",onMouseDown:S=>S.stopPropagation(),children:[r.jsx(jn,{query:a,setQuery:d,placeholder:"Search agents"}),M?r.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),r.jsxs("div",{ref:P,className:z("mt-1 overflow-y-auto",o?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[a.trim()===""?r.jsxs($e,{className:z("justify-between",g==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K(null),children:["All chats",g==null?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,j?r.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):I.length===0?r.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:a.trim()?`No agents match "${a.trim()}".`:"No agents yet."}):r.jsxs(r.Fragment,{children:[I.map(S=>{const R=Mn(S),T=(g==null?void 0:g.agentId)===R;return r.jsxs($e,{className:z("justify-between gap-2 text-left",T&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K({agentId:R,agentName:S.name,intent:"history"}),children:[r.jsx("span",{className:"min-w-0 truncate",children:S.name}),T?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),B?r.jsx("div",{ref:F,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:y?r.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return r.jsxs("div",{className:"relative shrink-0",children:[r.jsxs("button",{ref:h,type:"button","aria-label":g!=null?`Filter chat history by agent (${g.agentName})`:"Filter chat history by agent","aria-haspopup":o?"dialog":"menu","aria-expanded":i,"aria-controls":i?f:void 0,title:"Filter by agent",className:te({variant:"ghost",size:"icon",className:z("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",g!=null&&"text-text-primary")}),onClick:()=>c(S=>!S),children:[r.jsx(H,{name:"funnel",className:"size-3.5"}),g!=null?r.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),o&&i?r.jsx(rt,{open:!0,onOpenChange:c,id:f,"aria-label":"Filter agents",children:r.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:O})}):null,!o&&i&&u!=null?Sn.createPortal(r.jsx("div",{ref:p,id:f,role:"menu","aria-label":"Filter agents",style:{top:u.top,left:u.left},className:"aui-popup-enter font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:O}),Cn(h.current)):null]})}function Zr({open:n,initialTitle:e,saving:t=!1,onOpenChange:s,onSave:o}){const[i,c]=m.useState(e),a=m.useRef(null);m.useEffect(()=>{n&&c(e)},[n,e]),m.useEffect(()=>{if(!n)return;const f=a.current;f!=null&&(f.focus(),f.select())},[n]);const d=i.trim(),l=d.length>0&&d.length<=ze&&!t,h=()=>{l&&o(d)},p=f=>{t||s(f)};return r.jsx(Rn,{open:n,onOpenChange:p,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(Ge.Secondary,{type:"button",disabled:t,onClick:()=>p(!1),children:"Cancel"}),r.jsx(Ge.Primary,{type:"button",disabled:!l,onClick:h,children:"Save"})]}),children:r.jsx("div",{className:"px-5 py-4",children:r.jsx("input",{ref:a,"aria-label":"Session title",value:i,readOnly:t,maxLength:ze,className:Tn("h-9"),onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}})})})}var Jr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",es="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function ts({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:s,onRename:o,onDelete:i}){const c=C("PermissionGuard"),a=nt(),d=Te(),[u,l]=m.useState(!1),[h,p]=m.useState(),f=d||a,x=m.useCallback(M=>{const y=M==null?void 0:M.closest(".aui-theme-root");p(y instanceof HTMLElement?y:void 0)},[]),g=te({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),I=n?r.jsx(c,{allowed:!e,children:r.jsxs("button",{type:"button",className:Jr,disabled:e,onClick:()=>{e||(l(!1),o())},children:[r.jsx(H,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,j=t?r.jsx(c,{allowed:!s,children:r.jsxs(zt.Delete,{className:es,onClick:()=>{s||(l(!1),i())},children:[r.jsx(H,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return f?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":u,className:g,onClick:()=>l(!0),children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),u?r.jsx(rt,{open:!0,onOpenChange:l,"aria-label":"Session actions",children:r.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[I,j]})}):null]}):r.jsxs(be.Root,{sharedFocusGroup:!0,children:[r.jsx(be.Trigger,{ref:x,"aria-label":"Session actions",title:"Session actions",className:g,children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),r.jsxs(be.Content,{portalProps:{container:h},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[I,j]})]})}function ns({selectionRef:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i}){const c=Y(),a=ne(),d=Re(),u=m.useRef(a==null?void 0:a.runtimeKey);u.current=a==null?void 0:a.runtimeKey;const l=tt(),h=bn(),p=C("ThreadListRow"),f=E(w=>w.threadListItem.id),x=E(w=>w.threadListItem.remoteId),g=E(w=>w.threadListItem.title),I=E(w=>w.threadListItem.lastMessageAt),j=E(w=>w.threadListItem.custom),M=E(w=>w.threads.mainThreadId),y=wn(j),B=t&&x!=null,P=s&&x!=null,F=B||P,K=x!=null&&!o(x),O=x!=null&&!i(x),S=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0||(a==null?void 0:a.environmentsOpen)===!0,[R,T]=m.useState(!1),[U,$]=m.useState(!1),V=g??"New Chat",G=async w=>{if(w===(g??"").trim()){T(!1);return}$(!0);try{await c.threadListItem().rename(w),l(le.Session.RENAMED,ue(void 0,{sessionId:x,agentName:y})),T(!1)}catch(D){h==null||h.showError(D)}finally{$(!1)}},W=({sessionMutable:w,rowAgentName:D})=>{const b=!w&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(D==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===D||a.mode.agentId===D),v=Ln({sessionMutable:w,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:x,pendingSessionId:a==null?void 0:a.pendingSessionId});if((b||v)&&x!=null&&(a==null?void 0:a.sessionAccessError)==null){Promise.resolve(c.threads().switchToThread(f)).catch(()=>{});return}if(x!=null){a==null||a.openHistorySession({sessionId:x,isMutable:w,...D!=null?{agentName:D}:{}});return}Promise.resolve(c.threads().switchToThread(f)).catch(()=>{})};return r.jsxs(zt.Root,{className:"min-w-0",children:[r.jsx(p,{title:V,active:f===M&&!S,agentName:y,lastMessageAt:I,onSelect:()=>{l(le.Session.SELECTED,ue({is_mutable:ge(j)},{sessionId:x,agentName:y}));const w=++n.current,D=a==null?void 0:a.runtimeKey;if(e==null||e(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1),a==null||a.setEnvironmentsOpen(!1),x!=null&&d!=null&&yn(j)===void 0&&y==null){d.getSession({sessionId:x}).then(b=>({sessionMutable:b.isMutable,rowAgentName:b.agentName??void 0}),()=>({sessionMutable:ge(j),rowAgentName:y})).then(b=>{n.current===w&&u.current===D&&W(b)});return}W({sessionMutable:ge(j),rowAgentName:y})},actions:F?r.jsx(ts,{canRename:B,renameDisabled:K,canDelete:P,deleteDisabled:O,onRename:()=>T(!0),onDelete:()=>{l(le.Session.DELETED,ue(void 0,{sessionId:x,agentName:y}))}}):void 0}),r.jsx(Zr,{open:R,initialTitle:g??"",saving:U,onOpenChange:T,onSave:w=>{G(w)}})]})}function rs(n){const e=E(s=>s.threads.threadIds),t=E(s=>s.threads.threadItems);return m.useMemo(()=>{const s=vn({threadIds:e,threadItems:t});if(n==="default")return s;const o=new Map;for(const i of t)o.set(i.id,i),i.remoteId!=null&&o.set(i.remoteId,i);return s.filter(i=>{const c=e[i];if(c===void 0)return!1;const a=o.get(c);return(a==null?void 0:a.remoteId)!=null})},[e,t,n])}function ss(n){return n==="recent-history"||n==="mobile-drawer"}function os({selectionRef:n,indices:e,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c}){const a=E(d=>d.threads.threadIds);return r.jsx(r.Fragment,{children:e.map(d=>{const u=a[d]??String(d);return r.jsx(Pe,{index:d,archived:!1,children:r.jsx(ns,{selectionRef:n,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c})},u)})})}var as="aui_thread-list-viewport",is=80;function cs({children:n,viewportRef:e,hideScrollbar:t}){var d;const s=ne(),o=E(u=>u.threadListItem.remoteId),i=(d=s==null?void 0:s.historyAgentFilter)==null?void 0:d.intent,c=(s==null?void 0:s.isLibraryEnabled)===!0&&i!=="try-agent"&&(i==="history"||s.mode.status!=="active"||s.mode.isMutable||s.pendingSessionId!=null||o!=null),a=(s==null?void 0:s.historyAgentFilter)==null?"Chat History":`Chats for ${s.historyAgentFilter.agentName}`;return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[r.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:a}),c?r.jsx(Qr,{}):null]}),r.jsx("div",{ref:e,"data-slot":as,className:z("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Zt({onThreadOpen:n,variant:e="default"}={}){const t=Y(),s=Re(),o=tt(),i=E(b=>b.threads.isLoading),c=E(b=>b.threads.isLoadingMore),a=E(b=>b.threads.hasMore),d=E(b=>b.threads.threadIds),u=E(b=>b.threads.threadItems),l=ne(),h=C("ThreadListShell"),p=C("ThreadListNewButton"),f=C("AgentsLibraryButton"),x=C("SessionsBrowserButton"),g=C("SchedulesButton"),I=C("EnvironmentsButton"),j=C("ThreadListRowSkeleton"),M=C("ThreadListEmptyState"),y=rs(e),B=m.useRef(null),P=m.useRef(a),F=m.useRef(t),K=m.useRef(0);P.current=a,F.current=t;const O=(l==null?void 0:l.isNewChatEnabled)!==!1,S=(l==null?void 0:l.mode.status)==="idle",R=ss(e),T=e==="mobile-drawer",U=typeof(s==null?void 0:s.renameSession)=="function",$=typeof(s==null?void 0:s.deleteSession)=="function",V=m.useMemo(()=>u.flatMap(b=>b.remoteId==null?[]:[b.remoteId]),[u]),{allows:G}=gn({resourceType:"session",resourceIds:V});m.useEffect(()=>{if(S||i||c)return;const b=B.current;if(!b)return;let v=!1;const A=()=>{if(v||!P.current||b.clientHeight<=0)return;const X=b.scrollHeight-b.scrollTop-b.clientHeight;b.scrollHeight>b.clientHeight&&X>is||F.current.threads().loadMore()};b.addEventListener("scroll",A,{passive:!0});const k=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>A());return k?k.observe(b):window.addEventListener("resize",A),A(),()=>{v=!0,b.removeEventListener("scroll",A),k==null||k.disconnect(),k||window.removeEventListener("resize",A)}},[a,S,i,c,d.length]);const W=()=>{if(o(le.Session.NEW,ue({is_composer_enabled:(l==null?void 0:l.isComposerEnabled)===!0},{...(l==null?void 0:l.mode.status)==="active"?{agentId:l.mode.agentId,agentName:l.mode.agentName}:{}})),n==null||n(),l==null||l.setLibraryOpen(!1),l==null||l.setSessionsOpen(!1),l!=null&&l.isComposerEnabled){l.openDraft();return}l==null||l.setSettingsOpen(!1),l==null||l.setSchedulesOpen(!1),l==null||l.setEnvironmentsOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let w;S?w=r.jsx(M,{message:R?"No recent chats":void 0}):i?w=r.jsx(j,{}):y.length===0?w=r.jsx(M,{message:R?"No recent chats":void 0}):w=r.jsx(zr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:r.jsx(os,{selectionRef:K,indices:y,onThreadOpen:n,canRenameSession:U,canDeleteSession:$,canManageResource:b=>G(b,"MANAGE"),canDeleteResource:b=>G(b,"DELETE")})});const D=e==="recent-history"?null:r.jsxs("div",{className:"flex flex-col gap-1",children:[O?r.jsx(p,{onClick:W}):null,r.jsx("div",{className:"contents",onClick:()=>{T&&(n==null||n())},children:r.jsx(f,{})}),T?null:r.jsxs(r.Fragment,{children:[r.jsx(x,{}),r.jsx(g,{}),r.jsx(I,{})]})]});return r.jsx(h,{header:D,children:r.jsxs(cs,{viewportRef:B,hideScrollbar:R,children:[w,!S&&a?r.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var ls=m.lazy(()=>Ne(()=>import("./SettingsBuilder-72KREKYT-Dmu76Wzi.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-4F5FX65T-DVKEEd4R.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-KOMO4W53-DT8-DDE7.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(n=>({default:n.EnvironmentsPage}))),ms="h-5 w-5 max-w-40 shrink-0 object-contain",fs="h-5 max-w-40 shrink-0 object-contain",ps="w-20",hs="w-80",Ve=z(On,"text-sidebar-text"),We="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function xs({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function gs(){return An().presentation==="full"?null:r.jsx("aside",{"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:r.jsx(Zt,{variant:"recent-history"})})}function vs(){var f;const n=Y(),e=ne(),t=C("AgentsLibraryButton"),s=C("SessionsBrowserButton"),o=C("SchedulesButton"),i=C("EnvironmentsButton"),c=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0||(e==null?void 0:e.environmentsOpen)===!0,d=e==null?void 0:e.mode,u=!a&&(d==null?void 0:d.status)==="active"&&!d.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",l=!a&&d!=null&&st(d),h=()=>{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(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return r.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[c?r.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:te({variant:"ghost",className:z(Ve,u&&We)}),onClick:h,children:[r.jsx(H,{name:"square-pen",size:14}),r.jsx("span",{className:"text-center",children:"New Chat"})]}):null,c&&(e!=null&&e.isComposerEnabled)?r.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":l?"page":void 0,className:te({variant:"ghost",className:z(Ve,l&&We)}),onClick:p,children:[r.jsx(H,{name:"agent-2",size:14}),r.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,r.jsx(t,{compact:!0}),r.jsx(s,{compact:!0}),r.jsx(o,{compact:!0}),r.jsx(i,{compact:!0})]})}function bs({className:n,railRef:e,...t}){const s=ot(),o=at(s),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:e,className:z(ps,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",n),...t,children:[r.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:r.jsx(i,{variant:o.collapsedVariant,className:ms})}),r.jsx(vs,{}),r.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[r.jsx(it,{labeled:!0,className:"flex-col"}),r.jsx(c,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function ws({drawerRef:n,onClose:e}){const t=ot(),s=at(t),o=_n(),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:n,role:"dialog","aria-label":"Navigation",tabIndex:-1,className:z(hs,"absolute inset-y-0 left-0 z-10 flex min-h-0 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden"),children:[r.jsxs("div",{className:"flex h-14 w-full shrink-0 items-center gap-2 border-b border-border px-3 text-text-primary",children:[r.jsx(i,{variant:s.expandedVariant,className:fs}),s.showTitle&&o!=null?r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}):r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("button",{type:"button","aria-label":"Close navigation",className:te({variant:"ghost",size:"icon"}),onClick:e,children:r.jsx(H,{name:"xmark"})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Zt,{variant:"mobile-drawer",onThreadOpen:e})}),r.jsxs("footer",{className:"flex shrink-0 items-center justify-around gap-1 border-t border-border p-2 text-sidebar-text",children:[r.jsx(it,{labeled:!0,onAction:e,className:"contents"}),r.jsx(c,{labeled:!0})]})]})}function Ts({className:n}){const e=ne(),t=Te(),s=C("AgentDetailsPage"),o=C("AgentsLibrary"),i=C("SessionsPage"),c=C("ShareChatButton"),a=C("ResetAgentBuilderButton"),d=C("ClearChatButton"),u=C("SaveAgentButton"),l=C("SelectAgentEmptyState"),[h,p]=m.useState(!1),f=m.useRef(null),x=m.useRef(null),g=m.useRef(null),I=m.useRef(!1),j=(e==null?void 0:e.mode.status)==="idle",M=(e==null?void 0:e.settingsOpen)===!0,y=(e==null?void 0:e.libraryOpen)===!0,B=y&&(e==null?void 0:e.libraryAgentId)==null,P=(e==null?void 0:e.sessionsOpen)===!0,F=(e==null?void 0:e.schedulesOpen)===!0,K=(e==null?void 0:e.environmentsOpen)===!0,O=M||y||P||F||K,S=e!=null&&st(e.mode),R=t&&(P||F||K||S&&!M&&!y),T=S&&!O&&!t,U=xs({overlayOpen:O,mode:e==null?void 0:e.mode}),$=Nn(),V=t&&(M||B),G=()=>p(!1),W=r.jsx("button",{ref:f,type:"button","aria-label":"Navigation","aria-expanded":h,className:z(te({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>p(!0),children:r.jsx(H,{name:"panel-left"})});return m.useEffect(()=>{if(!h)return;const w=D=>{D.key==="Escape"&&(D.stopImmediatePropagation(),p(!1))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[h]),m.useEffect(()=>{var D,b;const w=g.current;if(h){I.current=!0,w&&(w.inert=!0),(D=x.current)==null||D.focus();return}I.current&&(w&&(w.inert=!1),(b=f.current)==null||b.focus(),I.current=!1)},[h]),r.jsxs("div",{className:z("relative flex h-full min-h-0 w-full min-w-0",n),children:[r.jsx(bs,{className:"hidden md:flex"}),T?r.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:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:r.jsx(kn,{})}):null,r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[V?null:r.jsx(Pn,{className:z("bg-topbar-bg",(O||j||!$||R)&&"md:hidden"),start:W,title:!O&&!R?r.jsx(Bn,{}):null,end:!O&&!R?r.jsxs(r.Fragment,{children:[r.jsx(a,{}),r.jsx(c,{}),r.jsx(d,{}),r.jsx(u,{})]}):null}),r.jsx(En,{children:r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[U?r.jsx(gs,{}):null,r.jsx("div",{ref:g,className:"min-h-0 min-w-0 flex-1",children:M?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ls,{...V?{headerStart:W}:{}})}):R?r.jsx(Dn,{}):P?r.jsx(i,{}):y&&(e==null?void 0:e.libraryAgentId)!=null?r.jsx(s,{agentId:e.libraryAgentId},e.libraryAgentId):y?r.jsx(o,{onSelectAgent:G,...V?{headerStart:W}:{}}):F?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(us,{})}):K?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ds,{})}):j?r.jsx(l,{}):r.jsx(Fn,{})})]})})]}),h?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close navigation backdrop",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:G}),r.jsx(ws,{drawerRef:x,onClose:G})]}):null]})}export{Ts as SidebarLayout};
@@ -0,0 +1 @@
1
+ import{C as J}from"./chunk-HB2ZQ4CZ-DnCTK9KS.js";import{bo as V,p as W,q as X,r as l,x as U,j as e,S as Y,E,I as q,bq as Z,aa as k,_ as z}from"./index-CHtf87eT.js";var ee=({open:s,onOpenChange:c,onImport:d,busy:p=!1,error:y})=>{const[i,N]=l.useState(""),[m,C]=l.useState(""),[n,j]=l.useState(""),[u,x]=l.useState(""),[b,h]=l.useState(""),o=()=>{N(""),C(""),j(""),x(""),h("")},v=()=>{o(),c(!1)},f=async a=>{if(a.preventDefault(),!(!i.trim()||!m.trim()||!n.trim()||!u.trim()||!b.trim()||p))try{await d({name:i.trim(),description:m.trim(),repoURL:n.trim(),path:u.trim(),ref:b.trim()}),v()}catch{}},L=!!(i.trim()&&m.trim()&&n.trim()&&u.trim()&&b.trim())&&!p;return e.jsx(Z,{open:s,onOpenChange:a=>{a||v()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",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",children:e.jsx(q,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:a=>void f(a),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:i,onChange:a=>{N(a.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:m,onChange:a=>{C(a.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:k("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:n,onChange:a=>{j(a.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:u,onChange:a=>{x(a.target.value)},placeholder:"skills/release-notes",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:b,onChange:a=>{h(a.target.value)},placeholder:"main",required:!0,className:k("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[y?e.jsx("p",{className:"text-failure-bg text-sm",children:y}):null,e.jsx(E.Primary,{type:"submit",disabled:!L,className:"w-full",children:"Import"})]})]})})})},te=ee,B=(s,c,d)=>!s||c.toLowerCase().includes(s)||d.toLowerCase().includes(s),se=s=>"catalogId"in s;function le(s){return typeof s=="object"&&s!==null&&Reflect.get(s,"statusCode")===424}var ae=()=>{const{skillCatalog:s}=V(),c=W(),d=X(),[p,y]=l.useState(""),[i,N]=l.useState([]),[m,C]=l.useState([]),[n,j]=l.useState(!0),[u,x]=l.useState(null),[b,h]=l.useState(null),[o,v]=l.useState(!1),[f,L]=l.useState(!1),[a,G]=l.useState(!1),[D,F]=l.useState(null),[P,I]=l.useState(null),M=l.useCallback(async()=>{if(s){j(!0),x(null);try{const[t,r]=await Promise.all([s.listSkills(),s.getSkillCatalog()]);N(t),C(r)}catch(t){x(U(t,"Failed to load skills"))}finally{j(!1)}}},[s]);l.useEffect(()=>{M()},[M]);const S=p.trim().toLowerCase(),w=l.useMemo(()=>i.filter(t=>B(S,t.name,t.description)),[i,S]),R=l.useMemo(()=>{const t=new Set(i.flatMap(r=>se(r)?[r.catalogId]:[]));return m.filter(r=>!t.has(r.id)&&B(S,r.name,r.description))},[m,i,S]),_=async(t,r=x)=>{v(!0),x(null);try{await t(),await M()}catch(g){throw le(g)&&L(!0),r(U(g,"Request failed")),g}finally{v(!1)}};if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const T=t=>{_(async()=>{await s.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})}).catch(()=>{})},K=()=>{o||(F(null),I(null))},$=t=>{const r=s.deleteSkill;r&&(I(null),_(async()=>{await r({id:t.id}),d(z.Settings.SKILL_DELETED,{skill_name:t.name}),F(null)},I).catch(()=>{}))},H=async t=>{h(null),await _(async()=>{await s.createSkill(t)},h),setTimeout(()=>{c==null||c.showSuccess({title:`${t.name} imported`}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})},0)},O=({key:t,name:r,description:g,action:Q})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(q,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),g?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:g}):null]}),Q]},t),A=w.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import custom skills from GitHub."}),u?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:u}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Y,{query:p,setQuery:y,placeholder:"Search skills"})}),e.jsxs(E.Secondary,{type:"button",className:"shrink-0",disabled:o||f,onClick:()=>{h(null),G(!0)},children:[e.jsx(q,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[n?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!n&&w.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",w.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:w.map(t=>O({key:t.id,name:t.name,description:t.description,action:s.deleteSkill?e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Remove ${t.name}`,onClick:()=>{I(null),F(t)},children:"Remove"}):null}))})]}):null,!n&&R.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>O({key:t.id,name:t.name,description:t.description,action:e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Enable ${t.name}`,onClick:()=>{T(t)},children:"Enable"})}))})]}):null,!n&&!A?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:S?`No skills match “${p.trim()}”.`:"No skills yet."}):null]})]}),D?e.jsx(J,{title:"Remove skill?",description:`“${D.name}” will no longer be available to your agents.`,busy:o,error:P,onCancel:K,onConfirm:()=>{$(D)}}):null,e.jsx(te,{open:a,onOpenChange:t=>{G(t),t||h(null)},onImport:H,busy:o||f,error:b})]})},ne=ae;export{ne as default};
@@ -1 +1 @@
1
- import{r as t,a,j as o,T as n}from"./index-PV6Uc-B5.js";import{B as u}from"./chunk-OB3PAWPO-D3Luy7W3.js";function l({routes:e,...s}){const r=t.useMemo(()=>a(e),[e]);return o.jsx(u,{basename:r.basename||void 0,children:o.jsx(n,{...s,resolvedRoutes:r})})}export{l as TrueForgeUIWithRouter};
1
+ import{r as t,a,j as o,T as n}from"./index-CHtf87eT.js";import{B as u}from"./chunk-OB3PAWPO-CDXWnkeP.js";function l({routes:e,...s}){const r=t.useMemo(()=>a(e),[e]);return o.jsx(u,{basename:r.basename||void 0,children:o.jsx(n,{...s,resolvedRoutes:r})})}export{l as TrueForgeUIWithRouter};
@@ -1 +1 @@
1
- import{b6 as B,p as O,q as U,r as t,v as A,j as e,I as P,C as I,b8 as D,_,a6 as T}from"./index-PV6Uc-B5.js";var V=T("h-11 shadow-sm"),L=({open:r,onOpenChange:l,onSave:b,title:c,description:N,requireApiKey:d=!0,busy:p=!1,error:f})=>{const[h,u]=t.useState(""),m=()=>{u("")};t.useEffect(()=>{r&&u("")},[r]);const w=a=>{a||m(),l(a)},n=h.trim(),x=!d||!!n,g=async a=>{if(a.preventDefault(),!(!x||p))try{await b({apiKey:n}),m(),l(!1)}catch{}};return e.jsx(D,{open:r,onOpenChange:w,title:c,description:N,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(P,{name:"search",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:g,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"web-search-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",d?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"web-search-api-key",type:"password",required:d,value:h,onChange:a=>{u(a.target.value)},placeholder:d?"Parallel API key":"Leave blank to keep existing",autoFocus:!0,className:V})]})}),e.jsxs("div",{className:"mt-6 space-y-3",children:[f?e.jsx("p",{className:"text-failure-bg text-sm",children:f}):null,e.jsx(I.Primary,{type:"submit",size:"large",disabled:!x||p,className:"w-full shrink-0",children:"Save"})]})]})})},M=L,$=()=>{const{webSearchCatalog:r}=B(),l=O(),b=U(),[c,N]=t.useState([]),[d,p]=t.useState([]),[f,h]=t.useState(!0),[u,m]=t.useState(null),[w,n]=t.useState(null),[x,g]=t.useState(!1),[a,y]=t.useState(null),[o,v]=t.useState(null),S=t.useCallback(async({quiet:s=!1}={})=>{if(r){s||h(!0),m(null);try{const[i,j]=await Promise.all([r.listWebSearchProviders(),r.getWebSearchProviderCatalog()]);N(i),p(j)}catch(i){m(A(i,"Failed to load web search providers"))}finally{s||h(!1)}}},[r]);t.useEffect(()=>{S()},[S]);const C=c.length>0,k=t.useMemo(()=>{if(C)return[];const s=new Set(c.map(i=>i.catalogId));return d.filter(i=>!s.has(i.id))},[d,c,C]);if(!r)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Web search provider catalog is not available."});const W=async(s,i=m)=>{g(!0),m(null);try{await s(),await S({quiet:!0})}catch(j){throw i(A(j,"Request failed")),j}finally{g(!1)}},z=async s=>{a&&(n(null),await W(async()=>{await r.createWebSearchProvider({catalogId:a.id,name:a.name,type:a.type,apiKey:s.apiKey})},n),y(null),setTimeout(()=>{l==null||l.showSuccess({title:`${a.name} configured`}),b(_.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:a.name,mode:"create"})},0))},F=async s=>{o&&(n(null),await W(async()=>{await r.updateWebSearchProvider({id:o.id,...s.apiKey?{apiKey:s.apiKey}:{}})},n),v(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`}),b(_.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:o.name,mode:"update"})},0))},R=a!=null||o!=null,E=o!=null,K=o?`Update ${o.name}`:a?`Configure ${a.name}`:"Configure web search provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Web search"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Configure a provider so agents can search the web. Only one can be active at a time."}),u?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:u}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:f?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading web search 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.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:c.map(s=>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(P,{name:"search",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:s.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),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(I.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{n(null),y(null),v(s)},children:"Update"})]})]},s.id))})]}):null,C?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",k.length]}),k.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:d.length>0?"All catalog providers are configured.":"No web search providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:k.map(s=>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(P,{name:"search",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:s.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsx(I.Secondary,{type:"button",disabled:x,onClick:()=>{n(null),v(null),y(s)},children:"Configure"})]},s.id))})]})]})}),e.jsx(M,{open:R,onOpenChange:s=>{s||(n(null),y(null),v(null))},onSave:E?F:z,title:K,description:E?"Update this web search provider. Leave API key blank to keep the existing key.":"Configure this web search provider. API key is never stored in the catalog.",requireApiKey:!E,busy:x,error:w})]})},q=$;export{q as default};
1
+ import{bo as B,p as O,q as U,r as t,x as A,j as e,I as P,E as I,bq as D,_,aa as T}from"./index-CHtf87eT.js";var V=T("h-11 shadow-sm"),L=({open:r,onOpenChange:l,onSave:b,title:c,description:N,requireApiKey:d=!0,busy:p=!1,error:f})=>{const[h,u]=t.useState(""),m=()=>{u("")};t.useEffect(()=>{r&&u("")},[r]);const w=a=>{a||m(),l(a)},n=h.trim(),x=!d||!!n,g=async a=>{if(a.preventDefault(),!(!x||p))try{await b({apiKey:n}),m(),l(!1)}catch{}};return e.jsx(D,{open:r,onOpenChange:w,title:c,description:N,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(P,{name:"search",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:g,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"web-search-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",d?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"web-search-api-key",type:"password",required:d,value:h,onChange:a=>{u(a.target.value)},placeholder:d?"Parallel API key":"Leave blank to keep existing",autoFocus:!0,className:V})]})}),e.jsxs("div",{className:"mt-6 space-y-3",children:[f?e.jsx("p",{className:"text-failure-bg text-sm",children:f}):null,e.jsx(I.Primary,{type:"submit",size:"large",disabled:!x||p,className:"w-full shrink-0",children:"Save"})]})]})})},M=L,$=()=>{const{webSearchCatalog:r}=B(),l=O(),b=U(),[c,N]=t.useState([]),[d,p]=t.useState([]),[f,h]=t.useState(!0),[u,m]=t.useState(null),[w,n]=t.useState(null),[x,g]=t.useState(!1),[a,y]=t.useState(null),[o,v]=t.useState(null),S=t.useCallback(async({quiet:s=!1}={})=>{if(r){s||h(!0),m(null);try{const[i,j]=await Promise.all([r.listWebSearchProviders(),r.getWebSearchProviderCatalog()]);N(i),p(j)}catch(i){m(A(i,"Failed to load web search providers"))}finally{s||h(!1)}}},[r]);t.useEffect(()=>{S()},[S]);const C=c.length>0,k=t.useMemo(()=>{if(C)return[];const s=new Set(c.map(i=>i.catalogId));return d.filter(i=>!s.has(i.id))},[d,c,C]);if(!r)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Web search provider catalog is not available."});const W=async(s,i=m)=>{g(!0),m(null);try{await s(),await S({quiet:!0})}catch(j){throw i(A(j,"Request failed")),j}finally{g(!1)}},z=async s=>{a&&(n(null),await W(async()=>{await r.createWebSearchProvider({catalogId:a.id,name:a.name,type:a.type,apiKey:s.apiKey})},n),y(null),setTimeout(()=>{l==null||l.showSuccess({title:`${a.name} configured`}),b(_.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:a.name,mode:"create"})},0))},F=async s=>{o&&(n(null),await W(async()=>{await r.updateWebSearchProvider({id:o.id,...s.apiKey?{apiKey:s.apiKey}:{}})},n),v(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`}),b(_.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:o.name,mode:"update"})},0))},R=a!=null||o!=null,E=o!=null,K=o?`Update ${o.name}`:a?`Configure ${a.name}`:"Configure web search provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Web search"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Configure a provider so agents can search the web. Only one can be active at a time."}),u?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:u}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:f?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading web search 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.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:c.map(s=>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(P,{name:"search",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:s.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),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(I.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{n(null),y(null),v(s)},children:"Update"})]})]},s.id))})]}):null,C?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",k.length]}),k.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:d.length>0?"All catalog providers are configured.":"No web search providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:k.map(s=>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(P,{name:"search",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:s.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsx(I.Secondary,{type:"button",disabled:x,onClick:()=>{n(null),v(null),y(s)},children:"Configure"})]},s.id))})]})]})}),e.jsx(M,{open:R,onOpenChange:s=>{s||(n(null),y(null),v(null))},onSave:E?F:z,title:K,description:E?"Update this web search provider. Leave API key blank to keep the existing key.":"Configure this web search provider. API key is never stored in the catalog.",requireApiKey:!E,busy:x,error:w})]})},H=$;export{H as default};
@@ -0,0 +1 @@
1
+ import{S as m}from"./chunk-QYZB5BFZ-C1Zl8SCi.js";import{u as x,b8 as f,r,j as e,b7 as p,I as b,a3 as h,c as v}from"./index-CHtf87eT.js";import"./chunk-NRMAG6HF-BKTcpJl0.js";function j({className:u}){const d=x("BrandLogo"),{open:a,setOpen:n}=f(),l=r.useRef(null),s=r.useRef(null),i=r.useRef(!1);return r.useEffect(()=>{if(!a)return;const t=o=>{var c;o.key==="Escape"&&!((c=s.current)!=null&&c.querySelector("dialog[open]"))&&n(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a,n]),r.useEffect(()=>{var t,o;if(a){i.current=!0,(t=s.current)==null||t.focus();return}i.current&&((o=l.current)==null||o.focus(),i.current=!1)},[a]),e.jsxs("div",{className:v("pointer-events-none relative h-full min-h-0 w-full",u),children:[a?e.jsx("div",{ref:s,"data-aui-compact-layout":!0,className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[calc(5.25rem+env(safe-area-inset-bottom,0px))] z-[19] flex h-[min(560px,calc(100%-6.5rem-env(safe-area-inset-bottom,0px)))] max-h-[calc(100%-6.5rem)] w-[min(380px,calc(100%-2.5rem))] flex-col overflow-hidden rounded-xl border border-border bg-primary-bg shadow-[0_16px_48px_color-mix(in_oklab,var(--shadow-color)_14%,transparent)] outline-none",role:"dialog","aria-modal":!0,"aria-label":"Chat",tabIndex:-1,children:e.jsx(p,{children:e.jsx(m,{threadHeaderEnd:e.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:h({variant:"ghost",size:"icon"}),onClick:()=>n(!1),children:e.jsx(b,{name:"xmark"})})})})}):null,e.jsx("button",{ref:l,type:"button",className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[max(1.25rem,env(safe-area-inset-bottom,0px))] z-20 flex size-14 cursor-pointer items-center justify-center rounded-full text-sm font-medium shadow-[0_8px_24px_color-mix(in_oklab,var(--primary-button-bg)_45%,transparent)]",style:{backgroundColor:"var(--primary-button-bg)",color:"var(--primary-button-text)"},"aria-expanded":a,"aria-label":a?"Close chat":"Open chat",onClick:()=>n(t=>!t),children:a?e.jsx("span",{"aria-hidden":!0,className:"text-xl leading-none",children:"×"}):e.jsx(d,{variant:"icon",className:"size-6"})})]})}export{j as WidgetLayout};
@@ -1 +1 @@
1
- import{j as e,O as m,Q as u,R as h,U as j,V as p,C as n}from"./index-PV6Uc-B5.js";function g(a){return a.replace(/\?$/,"").replace(/^Remove /i,"Can't remove ")}var f=({title:a,description:o,confirmLabel:c="Remove",busy:i=!1,error:l=null,onCancel:t,onConfirm:d})=>{const s=l!=null&&l!=="",r=s?g(a):a;return e.jsxs(m,{open:!0,onOpenChange:x=>{x||t()},"aria-label":r,className:"max-w-md",children:[e.jsx(u,{children:e.jsxs(h,{children:[e.jsx(j,{children:r}),s?e.jsx("p",{role:"alert",className:"text-sm text-failure-bg",children:l}):e.jsx("p",{className:"text-sm text-text-secondary",children:o})]})}),e.jsx(p,{children:s?e.jsx(n.Secondary,{type:"button",onClick:t,children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(n.Secondary,{type:"button",disabled:i,onClick:t,children:"Cancel"}),e.jsx(n.Destructive,{type:"button",disabled:i,onClick:d,children:c})]})})]})},D=f;export{D as C};
1
+ import{j as e,R as m,U as u,V as h,W as j,X as p,E as n}from"./index-CHtf87eT.js";function g(a){return a.replace(/\?$/,"").replace(/^Remove /i,"Can't remove ")}var f=({title:a,description:o,confirmLabel:c="Remove",busy:i=!1,error:l=null,onCancel:t,onConfirm:d})=>{const s=l!=null&&l!=="",r=s?g(a):a;return e.jsxs(m,{open:!0,onOpenChange:x=>{x||t()},"aria-label":r,className:"max-w-md",children:[e.jsx(u,{children:e.jsxs(h,{children:[e.jsx(j,{children:r}),s?e.jsx("p",{role:"alert",className:"text-sm text-failure-bg",children:l}):e.jsx("p",{className:"text-sm text-text-secondary",children:o})]})}),e.jsx(p,{children:s?e.jsx(n.Secondary,{type:"button",onClick:t,children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(n.Secondary,{type:"button",disabled:i,onClick:t,children:"Cancel"}),e.jsx(n.Destructive,{type:"button",disabled:i,onClick:d,children:c})]})})]})},C=f;export{C};