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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-N546FNNS-DlWVvctF.js → AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-U6KQWVBJ-mo8URLKV.js.gz +0 -0
  4. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js +1 -0
  5. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-3D6FUFO6-DzIcybRU.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-VF74XC7I-DuR4GDFb.js → AgentOverview-RLJ6HZCN-YJvNjt8b.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-RLJ6HZCN-YJvNjt8b.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-RLJ6HZCN-YJvNjt8b.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-RFR6LQMY-B_5nS70p.js → AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-CDXRRUZQ-CnbfBoc3.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-27CQF6FX-DSTwylcS.js → AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-S2WX6ZEA-BjzWPaWE.js.gz +0 -0
  16. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js +1 -0
  17. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-UI3L7XY2-CG8nWJdo.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-R5VEP7BO-Cvdqimeu.js → ConnectorSettings-OIGAC2HU-xm76mpmk.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-OIGAC2HU-xm76mpmk.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-F44RWGEY-DVcqWNpi.js → DockLayout-J5BRKMJZ-xjQQzILb.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-SQ323AVM-CrsDJpVR.js → DrawerLayout-65YHGHIF-CehQ0ZjJ.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-65YHGHIF-CehQ0ZjJ.js.gz +0 -0
  26. package/dist/_frontend/assets/{ModelSettings-6QLS63HM-B0omK7y_.js → ModelSettings-VP6WCMGT-DuhYOy95.js} +1 -1
  27. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js.br +0 -0
  28. package/dist/_frontend/assets/ModelSettings-VP6WCMGT-DuhYOy95.js.gz +0 -0
  29. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js +1 -0
  30. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js.br +0 -0
  31. package/dist/_frontend/assets/SandboxSettings-GTZT7LD6-F_5p7NeO.js.gz +0 -0
  32. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js +1 -0
  33. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js.br +0 -0
  34. package/dist/_frontend/assets/SchedulesPage-ARWU7BZF-BIZcHayD.js.gz +0 -0
  35. package/dist/_frontend/assets/{SettingsBuilder-GISAH2WU-2fVa9yeg.js → SettingsBuilder-A4BPYIFZ-B4p1JpXq.js} +2 -2
  36. package/dist/_frontend/assets/SettingsBuilder-A4BPYIFZ-B4p1JpXq.js.br +0 -0
  37. package/dist/_frontend/assets/SettingsBuilder-A4BPYIFZ-B4p1JpXq.js.gz +0 -0
  38. package/dist/_frontend/assets/{ShellRouteSync-EN33DUQ7-C280D67g.js → ShellRouteSync-SSLGM35F-Cqt-1Q8u.js} +1 -1
  39. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js.br +0 -0
  40. package/dist/_frontend/assets/ShellRouteSync-SSLGM35F-Cqt-1Q8u.js.gz +0 -0
  41. package/dist/_frontend/assets/{SidebarLayout-35K4AKTC-0-Mjo6gf.js → SidebarLayout-MFDOGAVJ-pSgzH70r.js} +2 -2
  42. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js.br +0 -0
  43. package/dist/_frontend/assets/SidebarLayout-MFDOGAVJ-pSgzH70r.js.gz +0 -0
  44. package/dist/_frontend/assets/{SkillSettings-JSX2BTII-BriJH4Oj.js → SkillSettings-WQPUQ5TE-x17-_tYg.js} +1 -1
  45. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js.br +0 -0
  46. package/dist/_frontend/assets/SkillSettings-WQPUQ5TE-x17-_tYg.js.gz +0 -0
  47. package/dist/_frontend/assets/TrueForgeUIWithRouter-5CDICMCE-DcMl1KUh.js +1 -0
  48. package/dist/_frontend/assets/{WidgetLayout-RKBSN2FZ-u6iVYu3w.js → WidgetLayout-HE7E4UL5-D_jC6D5-.js} +1 -1
  49. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js.br +0 -0
  50. package/dist/_frontend/assets/WidgetLayout-HE7E4UL5-D_jC6D5-.js.gz +0 -0
  51. package/dist/_frontend/assets/{chunk-73FQVITT-mgvTPDmd.js → chunk-2BDTG544-FxcOqFr-.js} +1 -1
  52. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js.br +0 -0
  53. package/dist/_frontend/assets/chunk-2BDTG544-FxcOqFr-.js.gz +0 -0
  54. package/dist/_frontend/assets/{chunk-62JRHF6Z-DYrEQoq5.js → chunk-62JRHF6Z-6aeTVQm8.js} +1 -1
  55. package/dist/_frontend/assets/chunk-62JRHF6Z-6aeTVQm8.js.br +0 -0
  56. package/dist/_frontend/assets/chunk-62JRHF6Z-6aeTVQm8.js.gz +0 -0
  57. package/dist/_frontend/assets/{chunk-LUG7E6BL-QKvrInc2.js → chunk-TGKQRK3S-D5Bs7icZ.js} +1 -1
  58. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js.br +0 -0
  59. package/dist/_frontend/assets/chunk-TGKQRK3S-D5Bs7icZ.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-GIPFF6FZ-DPTdcXQj.js → chunk-VXKNS7FH-Dm2ZAGlE.js} +2 -2
  61. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-VXKNS7FH-Dm2ZAGlE.js.gz +0 -0
  63. package/dist/_frontend/assets/{cssMode-BNfxrwWp.js → cssMode-BSK94pjD.js} +1 -1
  64. package/dist/_frontend/assets/cssMode-BSK94pjD.js.br +0 -0
  65. package/dist/_frontend/assets/cssMode-BSK94pjD.js.gz +0 -0
  66. package/dist/_frontend/assets/{freemarker2-ClbLzW-k.js → freemarker2-hYZ9lU-u.js} +1 -1
  67. package/dist/_frontend/assets/freemarker2-hYZ9lU-u.js.br +0 -0
  68. package/dist/_frontend/assets/freemarker2-hYZ9lU-u.js.gz +0 -0
  69. package/dist/_frontend/assets/{handlebars-5nE6yTDt.js → handlebars-CJdvCy_0.js} +1 -1
  70. package/dist/_frontend/assets/handlebars-CJdvCy_0.js.br +0 -0
  71. package/dist/_frontend/assets/handlebars-CJdvCy_0.js.gz +0 -0
  72. package/dist/_frontend/assets/{html-BZRf7Zhg.js → html-BHnJtaJv.js} +1 -1
  73. package/dist/_frontend/assets/html-BHnJtaJv.js.br +0 -0
  74. package/dist/_frontend/assets/html-BHnJtaJv.js.gz +0 -0
  75. package/dist/_frontend/assets/{htmlMode-C6O73C_r.js → htmlMode-BTNbHYXw.js} +1 -1
  76. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js.br +0 -0
  77. package/dist/_frontend/assets/htmlMode-BTNbHYXw.js.gz +0 -0
  78. package/dist/_frontend/assets/{index-D0Yf366e.js → index-B1sBHguz.js} +1 -1
  79. package/dist/_frontend/assets/index-B1sBHguz.js.br +0 -0
  80. package/dist/_frontend/assets/index-B1sBHguz.js.gz +0 -0
  81. package/dist/_frontend/assets/{index-DBjak9Sg.js → index-BU6gYO7K.js} +3 -3
  82. package/dist/_frontend/assets/index-BU6gYO7K.js.br +0 -0
  83. package/dist/_frontend/assets/index-BU6gYO7K.js.gz +0 -0
  84. package/dist/_frontend/assets/{index-XpZpj5Rl.js → index-DZOZ1xN3.js} +240 -240
  85. package/dist/_frontend/assets/index-DZOZ1xN3.js.br +0 -0
  86. package/dist/_frontend/assets/index-DZOZ1xN3.js.gz +0 -0
  87. package/dist/_frontend/assets/{javascript-CrSAQdU4.js → javascript-BKY4Sujy.js} +1 -1
  88. package/dist/_frontend/assets/{jsonMode-Dal25yu2.js → jsonMode-B_jTSLwe.js} +1 -1
  89. package/dist/_frontend/assets/jsonMode-B_jTSLwe.js.br +0 -0
  90. package/dist/_frontend/assets/jsonMode-B_jTSLwe.js.gz +0 -0
  91. package/dist/_frontend/assets/{liquid-Ci7gjLGv.js → liquid-OVC8bSZr.js} +1 -1
  92. package/dist/_frontend/assets/liquid-OVC8bSZr.js.br +0 -0
  93. package/dist/_frontend/assets/liquid-OVC8bSZr.js.gz +0 -0
  94. package/dist/_frontend/assets/{lspLanguageFeatures-rM-QiA57.js → lspLanguageFeatures-BpQc31SX.js} +1 -1
  95. package/dist/_frontend/assets/lspLanguageFeatures-BpQc31SX.js.br +0 -0
  96. package/dist/_frontend/assets/lspLanguageFeatures-BpQc31SX.js.gz +0 -0
  97. package/dist/_frontend/assets/{mdx-J3rSuJw4.js → mdx-Rt-sDg8a.js} +1 -1
  98. package/dist/_frontend/assets/mdx-Rt-sDg8a.js.br +0 -0
  99. package/dist/_frontend/assets/mdx-Rt-sDg8a.js.gz +0 -0
  100. package/dist/_frontend/assets/{python-BSpXGEco.js → python-CLLuhWlP.js} +1 -1
  101. package/dist/_frontend/assets/python-CLLuhWlP.js.br +0 -0
  102. package/dist/_frontend/assets/python-CLLuhWlP.js.gz +0 -0
  103. package/dist/_frontend/assets/{razor-DLV1uhEc.js → razor-CTEZKBpz.js} +1 -1
  104. package/dist/_frontend/assets/razor-CTEZKBpz.js.br +0 -0
  105. package/dist/_frontend/assets/razor-CTEZKBpz.js.gz +0 -0
  106. package/dist/_frontend/assets/{tsMode-CQqRu3mP.js → tsMode-BsjOp9ss.js} +1 -1
  107. package/dist/_frontend/assets/tsMode-BsjOp9ss.js.br +0 -0
  108. package/dist/_frontend/assets/tsMode-BsjOp9ss.js.gz +0 -0
  109. package/dist/_frontend/assets/{typescript-BExfm66c.js → typescript-CpIJvyBH.js} +1 -1
  110. package/dist/_frontend/assets/typescript-CpIJvyBH.js.br +0 -0
  111. package/dist/_frontend/assets/typescript-CpIJvyBH.js.gz +0 -0
  112. package/dist/_frontend/assets/{workers-Cn25A5Lb.js → workers-C_uhAUan.js} +1 -1
  113. package/dist/_frontend/assets/workers-C_uhAUan.js.br +0 -0
  114. package/dist/_frontend/assets/workers-C_uhAUan.js.gz +0 -0
  115. package/dist/_frontend/assets/{xml-D2IDD-hb.js → xml-BxHi2HCJ.js} +1 -1
  116. package/dist/_frontend/assets/xml-BxHi2HCJ.js.br +0 -0
  117. package/dist/_frontend/assets/xml-BxHi2HCJ.js.gz +0 -0
  118. package/dist/_frontend/assets/{yaml-CY4c2A0Y.js → yaml-DyyH_CDu.js} +1 -1
  119. package/dist/_frontend/assets/yaml-DyyH_CDu.js.br +0 -0
  120. package/dist/_frontend/assets/yaml-DyyH_CDu.js.gz +0 -0
  121. package/dist/_frontend/index.html +1 -1
  122. package/dist/controller-main.js +101 -108
  123. package/dist/controller-main.js.map +1 -1
  124. package/dist/main.js +459 -277
  125. package/dist/main.js.map +1 -1
  126. package/package.json +2 -2
  127. package/dist/_frontend/assets/AgentCodeSnippets-N546FNNS-DlWVvctF.js.br +0 -0
  128. package/dist/_frontend/assets/AgentCodeSnippets-N546FNNS-DlWVvctF.js.gz +0 -0
  129. package/dist/_frontend/assets/AgentMetricChart-YWJYVYYA-DTDXcVgE.js +0 -1
  130. package/dist/_frontend/assets/AgentMetricChart-YWJYVYYA-DTDXcVgE.js.br +0 -0
  131. package/dist/_frontend/assets/AgentMetricChart-YWJYVYYA-DTDXcVgE.js.gz +0 -0
  132. package/dist/_frontend/assets/AgentOverview-VF74XC7I-DuR4GDFb.js.br +0 -0
  133. package/dist/_frontend/assets/AgentOverview-VF74XC7I-DuR4GDFb.js.gz +0 -0
  134. package/dist/_frontend/assets/AgentSessionEventTimeline-RFR6LQMY-B_5nS70p.js.br +0 -0
  135. package/dist/_frontend/assets/AgentSessionEventTimeline-RFR6LQMY-B_5nS70p.js.gz +0 -0
  136. package/dist/_frontend/assets/AgentSessionEventTimelineChart-27CQF6FX-DSTwylcS.js.br +0 -0
  137. package/dist/_frontend/assets/AgentSessionEventTimelineChart-27CQF6FX-DSTwylcS.js.gz +0 -0
  138. package/dist/_frontend/assets/AgentSessions-4IVX2SGD-Bf2N2ega.js +0 -1
  139. package/dist/_frontend/assets/AgentSessions-4IVX2SGD-Bf2N2ega.js.br +0 -0
  140. package/dist/_frontend/assets/AgentSessions-4IVX2SGD-Bf2N2ega.js.gz +0 -0
  141. package/dist/_frontend/assets/ConnectorSettings-R5VEP7BO-Cvdqimeu.js.br +0 -0
  142. package/dist/_frontend/assets/ConnectorSettings-R5VEP7BO-Cvdqimeu.js.gz +0 -0
  143. package/dist/_frontend/assets/DrawerLayout-SQ323AVM-CrsDJpVR.js.br +0 -0
  144. package/dist/_frontend/assets/DrawerLayout-SQ323AVM-CrsDJpVR.js.gz +0 -0
  145. package/dist/_frontend/assets/ModelSettings-6QLS63HM-B0omK7y_.js.br +0 -0
  146. package/dist/_frontend/assets/ModelSettings-6QLS63HM-B0omK7y_.js.gz +0 -0
  147. package/dist/_frontend/assets/SandboxSettings-OLKDXIQS-O1pf1zn0.js +0 -1
  148. package/dist/_frontend/assets/SandboxSettings-OLKDXIQS-O1pf1zn0.js.br +0 -0
  149. package/dist/_frontend/assets/SandboxSettings-OLKDXIQS-O1pf1zn0.js.gz +0 -0
  150. package/dist/_frontend/assets/SchedulesPage-TMOTK6DR-D9JlkZFv.js +0 -1
  151. package/dist/_frontend/assets/SchedulesPage-TMOTK6DR-D9JlkZFv.js.br +0 -0
  152. package/dist/_frontend/assets/SchedulesPage-TMOTK6DR-D9JlkZFv.js.gz +0 -0
  153. package/dist/_frontend/assets/SettingsBuilder-GISAH2WU-2fVa9yeg.js.br +0 -0
  154. package/dist/_frontend/assets/SettingsBuilder-GISAH2WU-2fVa9yeg.js.gz +0 -0
  155. package/dist/_frontend/assets/ShellRouteSync-EN33DUQ7-C280D67g.js.br +0 -0
  156. package/dist/_frontend/assets/ShellRouteSync-EN33DUQ7-C280D67g.js.gz +0 -0
  157. package/dist/_frontend/assets/SidebarLayout-35K4AKTC-0-Mjo6gf.js.br +0 -0
  158. package/dist/_frontend/assets/SidebarLayout-35K4AKTC-0-Mjo6gf.js.gz +0 -0
  159. package/dist/_frontend/assets/SkillSettings-JSX2BTII-BriJH4Oj.js.br +0 -0
  160. package/dist/_frontend/assets/SkillSettings-JSX2BTII-BriJH4Oj.js.gz +0 -0
  161. package/dist/_frontend/assets/TrueForgeUIWithRouter-6VCR7ES3-CtIaYnA8.js +0 -1
  162. package/dist/_frontend/assets/WidgetLayout-RKBSN2FZ-u6iVYu3w.js.br +0 -0
  163. package/dist/_frontend/assets/WidgetLayout-RKBSN2FZ-u6iVYu3w.js.gz +0 -0
  164. package/dist/_frontend/assets/chunk-62JRHF6Z-DYrEQoq5.js.br +0 -0
  165. package/dist/_frontend/assets/chunk-62JRHF6Z-DYrEQoq5.js.gz +0 -0
  166. package/dist/_frontend/assets/chunk-73FQVITT-mgvTPDmd.js.br +0 -0
  167. package/dist/_frontend/assets/chunk-73FQVITT-mgvTPDmd.js.gz +0 -0
  168. package/dist/_frontend/assets/chunk-GIPFF6FZ-DPTdcXQj.js.br +0 -0
  169. package/dist/_frontend/assets/chunk-GIPFF6FZ-DPTdcXQj.js.gz +0 -0
  170. package/dist/_frontend/assets/chunk-LUG7E6BL-QKvrInc2.js.br +0 -0
  171. package/dist/_frontend/assets/chunk-LUG7E6BL-QKvrInc2.js.gz +0 -0
  172. package/dist/_frontend/assets/cssMode-BNfxrwWp.js.br +0 -0
  173. package/dist/_frontend/assets/cssMode-BNfxrwWp.js.gz +0 -0
  174. package/dist/_frontend/assets/freemarker2-ClbLzW-k.js.br +0 -0
  175. package/dist/_frontend/assets/freemarker2-ClbLzW-k.js.gz +0 -0
  176. package/dist/_frontend/assets/handlebars-5nE6yTDt.js.br +0 -0
  177. package/dist/_frontend/assets/handlebars-5nE6yTDt.js.gz +0 -0
  178. package/dist/_frontend/assets/html-BZRf7Zhg.js.br +0 -0
  179. package/dist/_frontend/assets/html-BZRf7Zhg.js.gz +0 -0
  180. package/dist/_frontend/assets/htmlMode-C6O73C_r.js.br +0 -0
  181. package/dist/_frontend/assets/htmlMode-C6O73C_r.js.gz +0 -0
  182. package/dist/_frontend/assets/index-D0Yf366e.js.br +0 -0
  183. package/dist/_frontend/assets/index-D0Yf366e.js.gz +0 -0
  184. package/dist/_frontend/assets/index-DBjak9Sg.js.br +0 -0
  185. package/dist/_frontend/assets/index-DBjak9Sg.js.gz +0 -0
  186. package/dist/_frontend/assets/index-XpZpj5Rl.js.br +0 -0
  187. package/dist/_frontend/assets/index-XpZpj5Rl.js.gz +0 -0
  188. package/dist/_frontend/assets/jsonMode-Dal25yu2.js.br +0 -0
  189. package/dist/_frontend/assets/jsonMode-Dal25yu2.js.gz +0 -0
  190. package/dist/_frontend/assets/liquid-Ci7gjLGv.js.br +0 -0
  191. package/dist/_frontend/assets/liquid-Ci7gjLGv.js.gz +0 -0
  192. package/dist/_frontend/assets/lspLanguageFeatures-rM-QiA57.js.br +0 -0
  193. package/dist/_frontend/assets/lspLanguageFeatures-rM-QiA57.js.gz +0 -0
  194. package/dist/_frontend/assets/mdx-J3rSuJw4.js.br +0 -0
  195. package/dist/_frontend/assets/mdx-J3rSuJw4.js.gz +0 -0
  196. package/dist/_frontend/assets/python-BSpXGEco.js.br +0 -0
  197. package/dist/_frontend/assets/python-BSpXGEco.js.gz +0 -0
  198. package/dist/_frontend/assets/razor-DLV1uhEc.js.br +0 -0
  199. package/dist/_frontend/assets/razor-DLV1uhEc.js.gz +0 -0
  200. package/dist/_frontend/assets/tsMode-CQqRu3mP.js.br +0 -0
  201. package/dist/_frontend/assets/tsMode-CQqRu3mP.js.gz +0 -0
  202. package/dist/_frontend/assets/typescript-BExfm66c.js.br +0 -0
  203. package/dist/_frontend/assets/typescript-BExfm66c.js.gz +0 -0
  204. package/dist/_frontend/assets/workers-Cn25A5Lb.js.br +0 -0
  205. package/dist/_frontend/assets/workers-Cn25A5Lb.js.gz +0 -0
  206. package/dist/_frontend/assets/xml-D2IDD-hb.js.br +0 -0
  207. package/dist/_frontend/assets/xml-D2IDD-hb.js.gz +0 -0
  208. package/dist/_frontend/assets/yaml-CY4c2A0Y.js.br +0 -0
  209. package/dist/_frontend/assets/yaml-CY4c2A0Y.js.gz +0 -0
@@ -1 +1 @@
1
- import{c as u,r as s,j as t,I as x,e as i}from"./index-XpZpj5Rl.js";function h({snippets:a}){var c;const m=u("AgentCodeBlock"),[d,n]=s.useState((c=a[0])==null?void 0:c.language),[o,l]=s.useState("stream");s.useEffect(()=>{var e;n((e=a[0])==null?void 0:e.language),l("stream")},[a]);const r=a.find(e=>e.language===d)??a[0];return r===void 0?t.jsx("div",{className:"flex h-full min-h-64 items-center justify-center px-6 text-sm text-text-secondary",children:"No code samples for this agent."}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-3 md:flex-row",children:[t.jsx("nav",{"aria-label":"Code sample languages",className:"flex shrink-0 gap-1 overflow-auto md:w-44 md:flex-col",children:a.map(e=>t.jsxs("button",{type:"button","aria-current":r.language===e.language?"page":void 0,className:i("flex h-9 shrink-0 cursor-pointer items-center gap-2 rounded-md px-2.5 text-left text-xs text-text-secondary","hover:bg-ghost-button-hover hover:text-text-primary",r.language===e.language&&"bg-primary-button-bg/10 font-medium text-primary-button-bg"),onClick:()=>n(e.language),children:[e.icon?t.jsx("img",{src:e.icon,alt:"",className:"size-4 shrink-0 object-contain"}):t.jsx(x,{name:"code",className:"size-4 shrink-0"}),e.labelName]},e.language))}),t.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-card-bg",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-1 border-b border-border px-3",children:[t.jsx("div",{className:"flex items-end gap-1",children:[["stream","Stream"],["nonStream","Non-stream"]].map(([e,g])=>t.jsx("button",{type:"button",className:i("relative h-10 cursor-pointer px-3 text-xs font-medium text-text-secondary",o===e&&"text-primary-button-bg after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary-button-bg"),onClick:()=>l(e),children:g},e))}),t.jsxs("a",{href:"https://trueforge.dev/api/use-agent",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-text-secondary",children:[t.jsx("span",{children:"View Docs"}),t.jsx(x,{name:"external-link",className:"size-3 shrink-0"})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(m,{code:r.sampleCode[o],language:r.language})})]})]})}export{h as default};
1
+ import{c as u,r as s,j as t,I as x,e as i}from"./index-DZOZ1xN3.js";function h({snippets:a}){var c;const m=u("AgentCodeBlock"),[d,n]=s.useState((c=a[0])==null?void 0:c.language),[o,l]=s.useState("stream");s.useEffect(()=>{var e;n((e=a[0])==null?void 0:e.language),l("stream")},[a]);const r=a.find(e=>e.language===d)??a[0];return r===void 0?t.jsx("div",{className:"flex h-full min-h-64 items-center justify-center px-6 text-sm text-text-secondary",children:"No code samples for this agent."}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-3 md:flex-row",children:[t.jsx("nav",{"aria-label":"Code sample languages",className:"flex shrink-0 gap-1 overflow-auto md:w-44 md:flex-col",children:a.map(e=>t.jsxs("button",{type:"button","aria-current":r.language===e.language?"page":void 0,className:i("flex h-9 shrink-0 cursor-pointer items-center gap-2 rounded-md px-2.5 text-left text-xs text-text-secondary","hover:bg-ghost-button-hover hover:text-text-primary",r.language===e.language&&"bg-primary-button-bg/10 font-medium text-primary-button-bg"),onClick:()=>n(e.language),children:[e.icon?t.jsx("img",{src:e.icon,alt:"",className:"size-4 shrink-0 object-contain"}):t.jsx(x,{name:"code",className:"size-4 shrink-0"}),e.labelName]},e.language))}),t.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-card-bg",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-1 border-b border-border px-3",children:[t.jsx("div",{className:"flex items-end gap-1",children:[["stream","Stream"],["nonStream","Non-stream"]].map(([e,g])=>t.jsx("button",{type:"button",className:i("relative h-10 cursor-pointer px-3 text-xs font-medium text-text-secondary",o===e&&"text-primary-button-bg after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary-button-bg"),onClick:()=>l(e),children:g},e))}),t.jsxs("a",{href:"https://trueforge.dev/api/use-agent",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-text-secondary",children:[t.jsx("span",{children:"View Docs"}),t.jsx(x,{name:"external-link",className:"size-3 shrink-0"})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(m,{code:r.sampleCode[o],language:r.language})})]})]})}export{h as default};
@@ -0,0 +1 @@
1
+ import{ad as j,r as d,j as a,ay as C,ax as k}from"./index-DZOZ1xN3.js";import{c as F,a as M,d as R,L as S,e as D,P as T,f as p,p as w}from"./index-B1sBHguz.js";M.register(R,S,D,T,p,w);var E=["#6366F1","#2563eb","#0EA5E9"],$=["#6366F1","#60a5fa","#38BDF8"],A=new Intl.NumberFormat(void 0,{maximumFractionDigits:4}),O=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function f(e,t){return t==="$"?C(e):t==="ms"?k(e):`${A.format(e)}${t==="count"||t.length===0?"":` ${t}`}`}function _(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:O.format(t)}function G({graph:e,definition:t,error:u,colorIndex:x=0}){const l=j(),r=l==="dark"?$:E,i=l==="dark"?"#71717a":"#a1a1aa",m=l==="dark"?"#27272a":"#e4e4e7",c=d.useMemo(()=>e==null?[]:[...new Set(e.graphLines.flatMap(s=>s.values.map(o=>o.timestamp)))].sort(),[e]),y=d.useMemo(()=>({labels:c.map(_),datasets:(e==null?void 0:e.graphLines.map((s,o)=>{const L=new Map(s.values.map(n=>[n.timestamp,n.value])),b=r[(x+o)%r.length];return{label:s.name,data:c.map(n=>L.get(n)??null),borderColor:b,backgroundColor:b,pointRadius:0,pointHoverRadius:0,borderWidth:2,borderCapStyle:"butt",borderJoinStyle:"miter",tension:0,spanGaps:!0}}))??[]}),[x,r,e,c]),v=d.useMemo(()=>({responsive:!0,maintainAspectRatio:!1,animation:!1,interaction:{intersect:!1,mode:"index"},plugins:{legend:{display:((e==null?void 0:e.graphLines.length)??0)>1,labels:{color:i,boxWidth:10,boxHeight:2}},tooltip:{callbacks:{label:s=>{const o=s.parsed.y;return`${s.dataset.label??""}: ${o==null?"—":f(o,(e==null?void 0:e.unit)??"")}`}}}},scales:{x:{grid:{display:!1},border:{color:m},ticks:{color:i,maxRotation:0,autoSkip:!0,maxTicksLimit:8}},y:{beginAtZero:!0,grid:{color:m},border:{display:!1},ticks:{color:i,callback:s=>f(Number(s),(e==null?void 0:e.unit)??"")}}}}),[i,e,m]),N=(e==null?void 0:e.graphLines.some(s=>s.values.length>0))===!0;return a.jsxs("section",{className:"min-w-0 rounded-lg border border-border bg-card-bg p-4","data-slot":"agent-metric-chart",children:[a.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:(e==null?void 0:e.displayName)??t.displayName}),a.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:(e==null?void 0:e.description)??t.description}),a.jsx("div",{className:"mt-4 h-64",children:u!=null?a.jsx("div",{className:"flex h-full items-center justify-center text-sm text-failure-bg",children:u}):N?a.jsx(F,{data:y,options:v}):a.jsx("div",{className:"flex h-full items-center justify-center text-sm text-text-secondary",children:"No data"})})]})}export{G as AgentMetricChart};
@@ -1 +1 @@
1
- import{c as R,r as _,j as e,I as O,e as D}from"./index-XpZpj5Rl.js";var i="text-right font-mono text-primary-button-bg";function p(t){return typeof t=="object"&&t!=null}function u(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function x(t,...a){for(const l of a){const c=t==null?void 0:t[l];if(c!==void 0)return c}}function U(t){if(!p(t))return!1;const a=x(t,"enableTools","enable_tools");return a===void 0||Array.isArray(a)&&a.includes("@all")}function V(t){const a=t.lastIndexOf("/");return a>=0?t.slice(a+1):t}function L({detail:t}){var C,S,A,I,M,E,T,$;const a=R("Markdown"),l=R("AgentOverviewCard"),[c,F]=_.useState("markdown"),[h,g]=_.useState(!1),n=t.agentSpec,f=n.skills??[],b=n.mcpServers??[],j=p(n.model.params)?n.model.params:null,y=x(j,"maxTokens","max_tokens"),N=x(j,"temperature"),o=p(n.config)?n.config:null,m=p(o==null?void 0:o.sandbox)?o.sandbox:null,d=(C=n.instructions)!=null&&C.trim()?n.instructions:null,v=[["Sandbox",typeof(m==null?void 0:m.enabled)=="boolean"?m.enabled?"Enabled":"Disabled":void 0],["Iteration limit",x(o,"iterationLimit","iteration_limit")],["Response format",x(o,"responseFormat","response_format")]].filter(s=>typeof s[1]=="string"||typeof s[1]=="number"),w=[["Generative UI",(A=(S=n.config)==null?void 0:S.generativeUi)==null?void 0:A.enabled],["Dynamic sub-agents",(M=(I=n.config)==null?void 0:I.dynamicSubAgents)==null?void 0:M.enabled],["Ask user questions",(T=(E=n.config)==null?void 0:E.askUserQuestions)==null?void 0:T.enabled]].filter(s=>typeof s[1]=="boolean"),k=c==="markdown"?"Raw":"Markdown";return e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 overflow-auto p-4 md:grid-cols-[minmax(0,1fr)_18rem] md:overflow-hidden",children:[e.jsxs("section",{className:"flex min-h-64 flex-col rounded-lg border border-border bg-card-bg p-4 text-text-primary",children:[e.jsxs("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-2",children:[e.jsxs("h2",{className:"flex items-center gap-1.5 text-sm font-semibold text-text-primary",children:[e.jsx(O,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),d?e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-md border border-border bg-primary-bg text-xs font-medium text-text-secondary",role:"group","aria-label":"Instructions actions",children:[e.jsx("button",{type:"button","aria-label":`Show ${k}`,onClick:()=>F(s=>s==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:k}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:h?"Copied!":"Copy","aria-label":h?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(d).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)})},className:"inline-flex cursor-pointer items-center justify-center px-2 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:e.jsx(O,{name:h?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?c==="markdown"?e.jsx(a,{content:d,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:d}):e.jsx("p",{className:"text-sm text-text-secondary",children:"No instructions for this agent."})})]}),e.jsxs("aside",{className:"flex min-h-0 min-w-0 flex-col gap-3 md:overflow-auto",children:[e.jsx(l,{title:"Model Configuration",icon:"cpu",children:e.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-text-secondary",children:"Model"}),e.jsx("dd",{className:D(i,"truncate"),title:n.model.name,children:V(n.model.name)}),typeof y=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:i,children:y})]}):null,(($=n.model.params)==null?void 0:$.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:i,children:n.model.params.reasoningEffort})]}):null,typeof N=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:i,children:N})]}):null]})}),e.jsx(l,{title:"MCP Servers",icon:"plug",count:b.length,children:b.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No connectors attached."}):e.jsx("ul",{className:"space-y-1.5",children:b.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate",children:u(s)??`Connector ${r+1}`}),U(s)?e.jsx("span",{className:"shrink-0 rounded-full bg-primary-button-bg/10 px-1.5 py-0.5 text-[10px] text-primary-button-bg",children:"All tools"}):null]})},`${u(s)??"connector"}-${r}`))})}),e.jsx(l,{title:"Attached Skills",icon:"lightbulb",count:f.length,children:f.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:f.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:u(s)??`Skill ${r+1}`},`${u(s)??"skill"}-${r}`))})}),v.length>0?e.jsx(l,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:v.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r})]},s))})}):null,w.length>0?e.jsx(l,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:w.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r?"Enabled":"Disabled"})]},s))})}):null]})]})}export{L as default};
1
+ import{c as R,r as _,j as e,I as O,e as D}from"./index-DZOZ1xN3.js";var i="text-right font-mono text-primary-button-bg";function p(t){return typeof t=="object"&&t!=null}function u(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function x(t,...a){for(const l of a){const c=t==null?void 0:t[l];if(c!==void 0)return c}}function U(t){if(!p(t))return!1;const a=x(t,"enableTools","enable_tools");return a===void 0||Array.isArray(a)&&a.includes("@all")}function V(t){const a=t.lastIndexOf("/");return a>=0?t.slice(a+1):t}function L({detail:t}){var C,S,A,I,M,E,T,$;const a=R("Markdown"),l=R("AgentOverviewCard"),[c,F]=_.useState("markdown"),[h,g]=_.useState(!1),n=t.agentSpec,f=n.skills??[],b=n.mcpServers??[],j=p(n.model.params)?n.model.params:null,y=x(j,"maxTokens","max_tokens"),N=x(j,"temperature"),o=p(n.config)?n.config:null,m=p(o==null?void 0:o.sandbox)?o.sandbox:null,d=(C=n.instructions)!=null&&C.trim()?n.instructions:null,v=[["Sandbox",typeof(m==null?void 0:m.enabled)=="boolean"?m.enabled?"Enabled":"Disabled":void 0],["Iteration limit",x(o,"iterationLimit","iteration_limit")],["Response format",x(o,"responseFormat","response_format")]].filter(s=>typeof s[1]=="string"||typeof s[1]=="number"),w=[["Generative UI",(A=(S=n.config)==null?void 0:S.generativeUi)==null?void 0:A.enabled],["Dynamic sub-agents",(M=(I=n.config)==null?void 0:I.dynamicSubAgents)==null?void 0:M.enabled],["Ask user questions",(T=(E=n.config)==null?void 0:E.askUserQuestions)==null?void 0:T.enabled]].filter(s=>typeof s[1]=="boolean"),k=c==="markdown"?"Raw":"Markdown";return e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 overflow-auto p-4 md:grid-cols-[minmax(0,1fr)_18rem] md:overflow-hidden",children:[e.jsxs("section",{className:"flex min-h-64 flex-col rounded-lg border border-border bg-card-bg p-4 text-text-primary",children:[e.jsxs("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-2",children:[e.jsxs("h2",{className:"flex items-center gap-1.5 text-sm font-semibold text-text-primary",children:[e.jsx(O,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),d?e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-md border border-border bg-primary-bg text-xs font-medium text-text-secondary",role:"group","aria-label":"Instructions actions",children:[e.jsx("button",{type:"button","aria-label":`Show ${k}`,onClick:()=>F(s=>s==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:k}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:h?"Copied!":"Copy","aria-label":h?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(d).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)})},className:"inline-flex cursor-pointer items-center justify-center px-2 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:e.jsx(O,{name:h?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?c==="markdown"?e.jsx(a,{content:d,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:d}):e.jsx("p",{className:"text-sm text-text-secondary",children:"No instructions for this agent."})})]}),e.jsxs("aside",{className:"flex min-h-0 min-w-0 flex-col gap-3 md:overflow-auto",children:[e.jsx(l,{title:"Model Configuration",icon:"cpu",children:e.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-text-secondary",children:"Model"}),e.jsx("dd",{className:D(i,"truncate"),title:n.model.name,children:V(n.model.name)}),typeof y=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:i,children:y})]}):null,(($=n.model.params)==null?void 0:$.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:i,children:n.model.params.reasoningEffort})]}):null,typeof N=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:i,children:N})]}):null]})}),e.jsx(l,{title:"MCP Servers",icon:"plug",count:b.length,children:b.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No connectors attached."}):e.jsx("ul",{className:"space-y-1.5",children:b.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate",children:u(s)??`Connector ${r+1}`}),U(s)?e.jsx("span",{className:"shrink-0 rounded-full bg-primary-button-bg/10 px-1.5 py-0.5 text-[10px] text-primary-button-bg",children:"All tools"}):null]})},`${u(s)??"connector"}-${r}`))})}),e.jsx(l,{title:"Attached Skills",icon:"lightbulb",count:f.length,children:f.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:f.map((s,r)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:u(s)??`Skill ${r+1}`},`${u(s)??"skill"}-${r}`))})}),v.length>0?e.jsx(l,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:v.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r})]},s))})}):null,w.length>0?e.jsx(l,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:w.map(([s,r])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:s}),e.jsx("dd",{className:i,children:r?"Enabled":"Disabled"})]},s))})}):null]})]})}export{L as default};
@@ -1 +1 @@
1
- import{c as u,ab as b,r,ac as f,j as t,ad as h,e as S}from"./index-XpZpj5Rl.js";function g({turns:l,segments:a,onSelectTurn:o}){const d=u("AgentSessionEventTimelineChart"),c=b()==="dark",[i,x]=r.useState(()=>new Set),p=r.useMemo(()=>{const e=new Set(a.map(s=>s.type));return f.filter(s=>e.has(s.id))},[a]),m=r.useCallback(e=>{x(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n})},[]);return a.length===0?null:t.jsxs("div",{className:"w-full","data-slot":"agent-session-event-timeline",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2","data-slot":"agent-session-event-types",children:[t.jsx("span",{className:"text-xs font-medium uppercase text-text-secondary",children:"Event types"}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:p.map(e=>{const s=!i.has(e.id);return t.jsxs("button",{type:"button","aria-pressed":s,className:S("flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",s?"border-border text-text-primary":"border-transparent text-text-secondary opacity-80"),onClick:()=>m(e.id),children:[t.jsx("span",{className:"size-2 rounded-sm",style:{backgroundColor:h(e.id,c)}}),e.label]},e.id)})})]}),t.jsx("div",{className:"w-full p-2",children:t.jsx(d,{turns:l,segments:a,hiddenTypes:i,onSelectTurn:o})})]})}export{g as AgentSessionEventTimeline};
1
+ import{c as u,ad as b,r,ae as f,j as t,af as h,e as S}from"./index-DZOZ1xN3.js";function g({turns:l,segments:a,onSelectTurn:o}){const d=u("AgentSessionEventTimelineChart"),c=b()==="dark",[i,x]=r.useState(()=>new Set),p=r.useMemo(()=>{const e=new Set(a.map(s=>s.type));return f.filter(s=>e.has(s.id))},[a]),m=r.useCallback(e=>{x(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n})},[]);return a.length===0?null:t.jsxs("div",{className:"w-full","data-slot":"agent-session-event-timeline",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2","data-slot":"agent-session-event-types",children:[t.jsx("span",{className:"text-xs font-medium uppercase text-text-secondary",children:"Event types"}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:p.map(e=>{const s=!i.has(e.id);return t.jsxs("button",{type:"button","aria-pressed":s,className:S("flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",s?"border-border text-text-primary":"border-transparent text-text-secondary opacity-80"),onClick:()=>m(e.id),children:[t.jsx("span",{className:"size-2 rounded-sm",style:{backgroundColor:h(e.id,c)}}),e.label]},e.id)})})]}),t.jsx("div",{className:"w-full p-2",children:t.jsx(d,{turns:l,segments:a,hiddenTypes:i,onSelectTurn:o})})]})}export{g as AgentSessionEventTimeline};
@@ -1 +1 @@
1
- import{ab as Z,r as a,ae as Re,af as Ie,ag as Pe,ah as De,ai as Le,aj as Ge,ak as Be,al as m,ad as E,am as $,an as Y,ao as Oe,ap as $e,aq as He,ar as Xe,j as s,as as We,at as ze,au as Ue,av as Fe,aw as Ve,ax as Ke,ay as S,az as qe,aA as ve}from"./index-XpZpj5Rl.js";import{C as Ye,a as Je,B as Qe,b as Ze,L as et,P as tt,S as st,p as nt}from"./index-D0Yf366e.js";function at(n){return n.type!=="system"||n.description.trim().length>0}function Me({segment:n,subAgentLabel:r}){const d=!n.isMarker&&!qe.has(n.type),i=n.description.trim();return n.type==="system"?i.length===0?null:s.jsx("p",{className:"max-w-[25rem] whitespace-normal break-words text-xs font-medium text-text-primary",children:i}):s.jsxs("div",{className:"max-h-72 max-w-[25rem] overflow-auto whitespace-normal break-words text-xs",children:[r!=null?s.jsx("div",{className:"border-b border-border py-1.5 text-text-secondary",children:`Sub-Agent: ${r}`}):null,s.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[s.jsx("span",{className:n.type==="error"?"font-medium text-failure-bg":"font-medium text-text-secondary",children:ve(n.type)}),d?s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)}):null]}),i.length>0?s.jsx("p",{className:"mt-1.5 line-clamp-6 font-medium text-text-primary",children:i}):null]})}function rt({turn:n,turnNumber:r,durationMs:d,segments:i}){const C=Z()==="dark";return s.jsxs("div",{className:"max-h-72 w-72 max-w-full overflow-auto text-xs text-text-primary",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-semibold",children:`Turn ${r}`}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:Fe(d)})]}),s.jsxs("div",{className:"mt-1 flex flex-col text-text-secondary",children:[n.totalCostInUsd!=null?s.jsx("span",{children:`Cost: ${Ve(n.totalCostInUsd)}`}):null,n.totalTokens!=null?s.jsx("span",{children:`Tokens: ${Ke(n.totalTokens)}`}):null]}),s.jsx("div",{className:"mt-2 border-t border-border pt-2",children:i.map(l=>{const b=l.type==="tool_call"||l.type==="sub_agent"?l.description:l.title;return s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(l.type,C)}}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:b}),l.isMarker?null:s.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-text-secondary",children:S(l.endMs-l.startMs)})]},l.id)})})]})}function ot({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Tool calls"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(r=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:r.description||r.title}),s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}function lt({group:n}){const r=Z()==="dark",d=n.segments.length===1?n.segments[0]:void 0;return d!=null?s.jsx(Me,{segment:d}):s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Events"}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(i=>s.jsxs("div",{className:"flex min-w-0 items-start gap-1.5 py-0.5",children:[s.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(i.type,r)}}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium text-text-secondary",children:ve(i.type)}),s.jsx("div",{className:"wrap-break-word font-medium text-text-primary",children:i.description.trim()||i.title})]})]},i.id))})]})}function it({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Sub-agents"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map((r,d)=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:n.segments.length===1?r.description||r.title:`Sub-agent ${d+1}: ${r.description||r.title}`}),n.segments.length===1?null:s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}Je.register(Qe,Ze,et,tt,st,nt);var J=4,ye=12,be=12,ct=2,ut=8,dt=2,mt=30;function pt({heights:n,gaps:r}){const d=[];let i=0;return n.forEach((C,l)=>{d.push(i+C/2),i+=C+(r[l]??0)}),{centers:d,band:i}}function Q(n){return n==="sub_agent"?0:n==="model"?2:1}function xt(n){if(!("x"in n)||!("y"in n)||!("base"in n))return null;const{x:r,y:d,base:i}=n;return typeof r!="number"||typeof d!="number"||typeof i!="number"?null:{x:(r+i)/2,y:d}}function yt({turns:n,segments:r,hiddenTypes:d,onSelectTurn:i}){var fe;const l=Z()==="dark",b=l?"#8c8c92":"#71717a",H=l?"#27272a":"#e4e4e7",ee=l?"#3f3f46":"#E0ECFD",te=l?"#52525b":"#E0ECFD",X=a.useRef(null),[se,je]=a.useState(0),[ne,we]=a.useState(mt),[o,ae]=a.useState(null),[ge,W]=a.useState(null),z=a.useRef(""),U=a.useRef(null);a.useEffect(()=>{const e=X.current;if(e==null)return;const t=()=>je(e.clientWidth);t();const c=new ResizeObserver(t);return c.observe(e),()=>c.disconnect()},[]);const f=a.useCallback(()=>{const e=X.current,t=U.current;e==null||t==null||W({left:t,top:e.getBoundingClientRect().bottom})},[]),Ne=a.useCallback(()=>{z.current="",U.current=null,ae(null),W(null)},[]);a.useEffect(()=>{if(o!=null)return f(),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[f,o]);const ke=Math.max(0,...r.map(e=>e.endMs)),v=Math.max(1,ze(ke)),{turnStartsMs:re,turnOrdinals:oe,turnRanges:F}=a.useMemo(()=>Re(r),[r]),T=a.useMemo(()=>re.filter((e,t)=>t===0||e<=v),[v,re]),le=Math.max(0,T.length-1),Ee=Math.max(se/2,se-ye*le-be),M=v/Math.max(1,Ee),x=ye*M,V=v+le*x,ie=V+be*M,ce=a.useMemo(()=>T.slice(1).map((e,t)=>({startMs:e+t*x,endMs:e+(t+1)*x})),[T,x]),_=a.useMemo(()=>r.flatMap(e=>{if(d.has(e.type))return[];const t=(oe.get(e.turnIndex)??0)*x;return[{...e,startMs:e.startMs+t,endMs:e.endMs+t}]}),[d,r,x,oe]),R=a.useMemo(()=>Ie(_),[_]),j=a.useMemo(()=>_.filter(e=>!e.isMarker),[_]),y=a.useMemo(()=>F.length<2?[]:F.map(e=>({...e,id:`turn-${e.turnIndex}`,durationMs:e.endMs-e.startMs,startMs:e.startMs+e.ordinal*x,endMs:e.endMs+e.ordinal*x+J*M})),[M,x,F]),w=a.useMemo(()=>j.filter(e=>e.type==="sub_agent"),[j]),I=a.useMemo(()=>Pe(w),[w]),ue=a.useMemo(()=>De({bars:I,subAgentSegments:w}),[I,w]),g=a.useMemo(()=>Le({subAgentSegments:w,threadSegments:j,minWidthMs:J*M}),[j,M,w]),P=a.useMemo(()=>[...j.filter(e=>e.threadId===Ge),...I].sort((e,t)=>e.startMs-t.startMs||e.endMs-t.endMs),[j,I]),N=a.useMemo(()=>Be(P.filter(e=>e.type==="tool_call")).filter(e=>e.segments.length>1),[P]),de=a.useMemo(()=>new Set(N.flatMap(e=>e.segments.map(t=>t.id))),[N]),D=a.useMemo(()=>P.filter(e=>!de.has(e.id)),[de,P]),me=g.reduce((e,t)=>Math.max(e,t.lane+1),0),K=y.length>0,A=K?1:0,L=A+1,{centers:k,band:G}=a.useMemo(()=>{const e=[...K?[16]:[],10,28,...Array.from({length:me},()=>12)],t=e.map((c,u)=>u===e.length-1?0:u===A?dt:ut);return pt({heights:e,gaps:t})},[K,me,A]),q=a.useMemo(()=>[...y.map(e=>({type:m.turn,bar:e})),...R.map(e=>({type:m.markerGroup,group:e})),...g.flatMap(e=>e.segments.map(t=>({type:m.event,segment:t}))),...D.map(e=>{if(e.type!=="sub_agent")return{type:m.event,segment:e};const t=ue.find(c=>c.barId===e.id);return t==null?{type:m.event,segment:e}:{type:m.subAgentGroup,group:t}}),...N.map(e=>({type:m.toolCallGroup,group:e}))],[D,R,ue,g,N,y]),B=({label:e,range:t,y:c,color:u,hover:p,thickness:h,order:O=1,inflateAmount:he})=>({label:e,data:[{x:Ue(t),y:c}],backgroundColor:u,hoverBackgroundColor:p,hoverBorderColor:p,borderWidth:0,borderSkipped:!1,borderRadius:ct,minBarLength:J,barThickness:h,grouped:!1,order:O,...he==null?{}:{inflateAmount:he}}),Se=a.useMemo(()=>({datasets:[...y.map(e=>B({label:`Turn ${e.ordinal+1}`,range:e,y:k[0]??0,color:ee,hover:te,thickness:16})),...R.map(e=>{var u;const t=e.segments.length===1?(u=e.segments[0])==null?void 0:u.type:"system",c=E(t??"system",l);return{type:"scatter",label:e.segments.map(p=>Y(p.type)).join(", "),data:[{x:e.startMs,y:k[A]??0}],pointStyle:"rectRot",pointRadius:5,pointHoverRadius:6,clip:!1,backgroundColor:c,hoverBackgroundColor:$(t??"system",l),borderWidth:0,order:0}}),...g.flatMap(e=>e.segments.map(t=>B({label:`${Y(t.type)}: ${t.title}`,range:t,y:k[L+1+e.lane]??0,color:E(t.type,l),hover:$(t.type,l),thickness:12,order:Q(t.type),inflateAmount:.5}))),...D.map(e=>B({label:`${Y(e.type)}: ${e.title}`,range:e,y:k[L]??0,color:E(e.type,l),hover:$(e.type,l),thickness:28,order:Q(e.type),inflateAmount:.5})),...N.map(e=>B({label:"Parallel tool calls",range:e,y:k[L]??0,color:E("tool_call",l),hover:$("tool_call",l),thickness:28,order:Q("tool_call"),inflateAmount:.5}))]}),[k,L,l,D,R,A,g,N,y,ee,te]),Ce=a.useMemo(()=>({id:"turnLabels",afterDatasetsDraw(e){const{ctx:t}=e;t.save(),t.fillStyle=b,t.font="500 10px sans-serif",t.textAlign="center",t.textBaseline="middle",y.forEach((c,u)=>{const p=e.getDatasetMeta(u).data[0];if(p==null)return;const h=xt(p);h&&t.fillText(`T${c.ordinal+1}`,h.x,h.y)}),t.restore()}}),[b,y]),Te=a.useMemo(()=>({id:"timelineOverhead",afterLayout(e){const t=Math.round(e.height-e.chartArea.height);we(c=>c===t?c:t)}}),[]),Ae=a.useMemo(()=>({indexAxis:"y",animation:!1,responsive:!0,maintainAspectRatio:!1,onClick:(e,t)=>{var u;const c=q[((u=t[0])==null?void 0:u.datasetIndex)??-1];(c==null?void 0:c.type)===m.turn&&(i==null||i(c.bar.turnIndex))},onHover:(e,t)=>{var O;const c=(O=t[0])==null?void 0:O.datasetIndex,u=c==null?null:q[c]??null,p=e.native;if((p==null?void 0:p.target)instanceof HTMLElement&&(p.target.style.cursor=(u==null?void 0:u.type)===m.turn?"pointer":"default"),p instanceof MouseEvent&&(U.current=p.clientX,f()),c==null)return;const h=Xe(u);if(z.current!==h){if(z.current=h,ae(u),u==null){W(null);return}f()}},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{type:"linear",position:"top",min:0,max:ie,grid:{color:H},border:{color:H},afterBuildTicks:e=>{e.ticks=He({activeTotalMs:v,turnStartsMs:T,turnGapMs:x})},ticks:{color:b,align:"inner",autoSkip:!1,includeBounds:!1,maxTicksLimit:9,callback:e=>{const t=Number(e);return t<=V?Oe($e(t,ce)):""}}},y:{type:"linear",display:!1,reverse:!0,offset:!1,min:0,max:G,grid:{display:!1}}}}),[v,T,b,G,q,H,i,f,ce,ie,V,x]),pe=(o==null?void 0:o.type)===m.turn?n[o.bar.turnIndex]:void 0,_e=a.useMemo(()=>({height:G+ne}),[G,ne]),xe=(o==null?void 0:o.type)===m.turn&&pe!=null?s.jsx(rt,{turn:pe,turnNumber:o.bar.ordinal+1,durationMs:o.bar.durationMs,segments:r.filter(e=>e.turnIndex===o.bar.turnIndex)}):(o==null?void 0:o.type)===m.event&&at(o.segment)?s.jsx(Me,{segment:o.segment,subAgentLabel:o.segment.type==="sub_agent"||(fe=g.find(e=>e.threadId===o.segment.threadId))==null?void 0:fe.track.description}):(o==null?void 0:o.type)===m.toolCallGroup?s.jsx(ot,{group:o.group}):(o==null?void 0:o.type)===m.markerGroup?s.jsx(lt,{group:o.group}):(o==null?void 0:o.type)===m.subAgentGroup?s.jsx(it,{group:o.group}):null;return s.jsx("div",{ref:X,className:"w-full","data-slot":"agent-session-event-timeline-chart",children:s.jsx(We,{title:xe,side:"bottom",triggerClassName:"block w-full",followCursor:!0,open:o!=null&&xe!=null,className:"max-w-[min(25rem,calc(100vw-1rem))] whitespace-normal",anchor:ge,children:s.jsx("div",{className:"w-full",style:_e,onMouseLeave:Ne,children:s.jsx(Ye,{type:"bar",data:Se,options:Ae,plugins:[Ce,Te]})})})})}export{yt as AgentSessionEventTimelineChart};
1
+ import{ad as Z,r as a,ag as Re,ah as Ie,ai as Pe,aj as De,ak as Le,al as Ge,am as Be,an as m,af as E,ao as $,ap as Y,aq as Oe,ar as $e,as as He,at as Xe,j as s,au as We,av as ze,aw as Ue,ax as Fe,ay as Ve,az as Ke,aA as S,aB as qe,aC as ve}from"./index-DZOZ1xN3.js";import{C as Ye,a as Je,B as Qe,b as Ze,L as et,P as tt,S as st,p as nt}from"./index-B1sBHguz.js";function at(n){return n.type!=="system"||n.description.trim().length>0}function Me({segment:n,subAgentLabel:r}){const d=!n.isMarker&&!qe.has(n.type),i=n.description.trim();return n.type==="system"?i.length===0?null:s.jsx("p",{className:"max-w-[25rem] whitespace-normal break-words text-xs font-medium text-text-primary",children:i}):s.jsxs("div",{className:"max-h-72 max-w-[25rem] overflow-auto whitespace-normal break-words text-xs",children:[r!=null?s.jsx("div",{className:"border-b border-border py-1.5 text-text-secondary",children:`Sub-Agent: ${r}`}):null,s.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[s.jsx("span",{className:n.type==="error"?"font-medium text-failure-bg":"font-medium text-text-secondary",children:ve(n.type)}),d?s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)}):null]}),i.length>0?s.jsx("p",{className:"mt-1.5 line-clamp-6 font-medium text-text-primary",children:i}):null]})}function rt({turn:n,turnNumber:r,durationMs:d,segments:i}){const C=Z()==="dark";return s.jsxs("div",{className:"max-h-72 w-72 max-w-full overflow-auto text-xs text-text-primary",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-semibold",children:`Turn ${r}`}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:Fe(d)})]}),s.jsxs("div",{className:"mt-1 flex flex-col text-text-secondary",children:[n.totalCostInUsd!=null?s.jsx("span",{children:`Cost: ${Ve(n.totalCostInUsd)}`}):null,n.totalTokens!=null?s.jsx("span",{children:`Tokens: ${Ke(n.totalTokens)}`}):null]}),s.jsx("div",{className:"mt-2 border-t border-border pt-2",children:i.map(l=>{const b=l.type==="tool_call"||l.type==="sub_agent"?l.description:l.title;return s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(l.type,C)}}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:b}),l.isMarker?null:s.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-text-secondary",children:S(l.endMs-l.startMs)})]},l.id)})})]})}function ot({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Tool calls"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(r=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:r.description||r.title}),s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}function lt({group:n}){const r=Z()==="dark",d=n.segments.length===1?n.segments[0]:void 0;return d!=null?s.jsx(Me,{segment:d}):s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Events"}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map(i=>s.jsxs("div",{className:"flex min-w-0 items-start gap-1.5 py-0.5",children:[s.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{backgroundColor:E(i.type,r)}}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium text-text-secondary",children:ve(i.type)}),s.jsx("div",{className:"wrap-break-word font-medium text-text-primary",children:i.description.trim()||i.title})]})]},i.id))})]})}function it({group:n}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Sub-agents"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:S(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map((r,d)=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-text-primary",children:n.segments.length===1?r.description||r.title:`Sub-agent ${d+1}: ${r.description||r.title}`}),n.segments.length===1?null:s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:S(r.endMs-r.startMs)})]},r.id))})]})}Je.register(Qe,Ze,et,tt,st,nt);var J=4,ye=12,be=12,ct=2,ut=8,dt=2,mt=30;function pt({heights:n,gaps:r}){const d=[];let i=0;return n.forEach((C,l)=>{d.push(i+C/2),i+=C+(r[l]??0)}),{centers:d,band:i}}function Q(n){return n==="sub_agent"?0:n==="model"?2:1}function xt(n){if(!("x"in n)||!("y"in n)||!("base"in n))return null;const{x:r,y:d,base:i}=n;return typeof r!="number"||typeof d!="number"||typeof i!="number"?null:{x:(r+i)/2,y:d}}function yt({turns:n,segments:r,hiddenTypes:d,onSelectTurn:i}){var fe;const l=Z()==="dark",b=l?"#8c8c92":"#71717a",H=l?"#27272a":"#e4e4e7",ee=l?"#3f3f46":"#E0ECFD",te=l?"#52525b":"#E0ECFD",X=a.useRef(null),[se,je]=a.useState(0),[ne,we]=a.useState(mt),[o,ae]=a.useState(null),[ge,W]=a.useState(null),z=a.useRef(""),U=a.useRef(null);a.useEffect(()=>{const e=X.current;if(e==null)return;const t=()=>je(e.clientWidth);t();const c=new ResizeObserver(t);return c.observe(e),()=>c.disconnect()},[]);const f=a.useCallback(()=>{const e=X.current,t=U.current;e==null||t==null||W({left:t,top:e.getBoundingClientRect().bottom})},[]),Ne=a.useCallback(()=>{z.current="",U.current=null,ae(null),W(null)},[]);a.useEffect(()=>{if(o!=null)return f(),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[f,o]);const ke=Math.max(0,...r.map(e=>e.endMs)),v=Math.max(1,ze(ke)),{turnStartsMs:re,turnOrdinals:oe,turnRanges:F}=a.useMemo(()=>Re(r),[r]),T=a.useMemo(()=>re.filter((e,t)=>t===0||e<=v),[v,re]),le=Math.max(0,T.length-1),Ee=Math.max(se/2,se-ye*le-be),M=v/Math.max(1,Ee),x=ye*M,V=v+le*x,ie=V+be*M,ce=a.useMemo(()=>T.slice(1).map((e,t)=>({startMs:e+t*x,endMs:e+(t+1)*x})),[T,x]),_=a.useMemo(()=>r.flatMap(e=>{if(d.has(e.type))return[];const t=(oe.get(e.turnIndex)??0)*x;return[{...e,startMs:e.startMs+t,endMs:e.endMs+t}]}),[d,r,x,oe]),R=a.useMemo(()=>Ie(_),[_]),j=a.useMemo(()=>_.filter(e=>!e.isMarker),[_]),y=a.useMemo(()=>F.length<2?[]:F.map(e=>({...e,id:`turn-${e.turnIndex}`,durationMs:e.endMs-e.startMs,startMs:e.startMs+e.ordinal*x,endMs:e.endMs+e.ordinal*x+J*M})),[M,x,F]),w=a.useMemo(()=>j.filter(e=>e.type==="sub_agent"),[j]),I=a.useMemo(()=>Pe(w),[w]),ue=a.useMemo(()=>De({bars:I,subAgentSegments:w}),[I,w]),g=a.useMemo(()=>Le({subAgentSegments:w,threadSegments:j,minWidthMs:J*M}),[j,M,w]),P=a.useMemo(()=>[...j.filter(e=>e.threadId===Ge),...I].sort((e,t)=>e.startMs-t.startMs||e.endMs-t.endMs),[j,I]),N=a.useMemo(()=>Be(P.filter(e=>e.type==="tool_call")).filter(e=>e.segments.length>1),[P]),de=a.useMemo(()=>new Set(N.flatMap(e=>e.segments.map(t=>t.id))),[N]),D=a.useMemo(()=>P.filter(e=>!de.has(e.id)),[de,P]),me=g.reduce((e,t)=>Math.max(e,t.lane+1),0),K=y.length>0,A=K?1:0,L=A+1,{centers:k,band:G}=a.useMemo(()=>{const e=[...K?[16]:[],10,28,...Array.from({length:me},()=>12)],t=e.map((c,u)=>u===e.length-1?0:u===A?dt:ut);return pt({heights:e,gaps:t})},[K,me,A]),q=a.useMemo(()=>[...y.map(e=>({type:m.turn,bar:e})),...R.map(e=>({type:m.markerGroup,group:e})),...g.flatMap(e=>e.segments.map(t=>({type:m.event,segment:t}))),...D.map(e=>{if(e.type!=="sub_agent")return{type:m.event,segment:e};const t=ue.find(c=>c.barId===e.id);return t==null?{type:m.event,segment:e}:{type:m.subAgentGroup,group:t}}),...N.map(e=>({type:m.toolCallGroup,group:e}))],[D,R,ue,g,N,y]),B=({label:e,range:t,y:c,color:u,hover:p,thickness:h,order:O=1,inflateAmount:he})=>({label:e,data:[{x:Ue(t),y:c}],backgroundColor:u,hoverBackgroundColor:p,hoverBorderColor:p,borderWidth:0,borderSkipped:!1,borderRadius:ct,minBarLength:J,barThickness:h,grouped:!1,order:O,...he==null?{}:{inflateAmount:he}}),Se=a.useMemo(()=>({datasets:[...y.map(e=>B({label:`Turn ${e.ordinal+1}`,range:e,y:k[0]??0,color:ee,hover:te,thickness:16})),...R.map(e=>{var u;const t=e.segments.length===1?(u=e.segments[0])==null?void 0:u.type:"system",c=E(t??"system",l);return{type:"scatter",label:e.segments.map(p=>Y(p.type)).join(", "),data:[{x:e.startMs,y:k[A]??0}],pointStyle:"rectRot",pointRadius:5,pointHoverRadius:6,clip:!1,backgroundColor:c,hoverBackgroundColor:$(t??"system",l),borderWidth:0,order:0}}),...g.flatMap(e=>e.segments.map(t=>B({label:`${Y(t.type)}: ${t.title}`,range:t,y:k[L+1+e.lane]??0,color:E(t.type,l),hover:$(t.type,l),thickness:12,order:Q(t.type),inflateAmount:.5}))),...D.map(e=>B({label:`${Y(e.type)}: ${e.title}`,range:e,y:k[L]??0,color:E(e.type,l),hover:$(e.type,l),thickness:28,order:Q(e.type),inflateAmount:.5})),...N.map(e=>B({label:"Parallel tool calls",range:e,y:k[L]??0,color:E("tool_call",l),hover:$("tool_call",l),thickness:28,order:Q("tool_call"),inflateAmount:.5}))]}),[k,L,l,D,R,A,g,N,y,ee,te]),Ce=a.useMemo(()=>({id:"turnLabels",afterDatasetsDraw(e){const{ctx:t}=e;t.save(),t.fillStyle=b,t.font="500 10px sans-serif",t.textAlign="center",t.textBaseline="middle",y.forEach((c,u)=>{const p=e.getDatasetMeta(u).data[0];if(p==null)return;const h=xt(p);h&&t.fillText(`T${c.ordinal+1}`,h.x,h.y)}),t.restore()}}),[b,y]),Te=a.useMemo(()=>({id:"timelineOverhead",afterLayout(e){const t=Math.round(e.height-e.chartArea.height);we(c=>c===t?c:t)}}),[]),Ae=a.useMemo(()=>({indexAxis:"y",animation:!1,responsive:!0,maintainAspectRatio:!1,onClick:(e,t)=>{var u;const c=q[((u=t[0])==null?void 0:u.datasetIndex)??-1];(c==null?void 0:c.type)===m.turn&&(i==null||i(c.bar.turnIndex))},onHover:(e,t)=>{var O;const c=(O=t[0])==null?void 0:O.datasetIndex,u=c==null?null:q[c]??null,p=e.native;if((p==null?void 0:p.target)instanceof HTMLElement&&(p.target.style.cursor=(u==null?void 0:u.type)===m.turn?"pointer":"default"),p instanceof MouseEvent&&(U.current=p.clientX,f()),c==null)return;const h=Xe(u);if(z.current!==h){if(z.current=h,ae(u),u==null){W(null);return}f()}},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{type:"linear",position:"top",min:0,max:ie,grid:{color:H},border:{color:H},afterBuildTicks:e=>{e.ticks=He({activeTotalMs:v,turnStartsMs:T,turnGapMs:x})},ticks:{color:b,align:"inner",autoSkip:!1,includeBounds:!1,maxTicksLimit:9,callback:e=>{const t=Number(e);return t<=V?Oe($e(t,ce)):""}}},y:{type:"linear",display:!1,reverse:!0,offset:!1,min:0,max:G,grid:{display:!1}}}}),[v,T,b,G,q,H,i,f,ce,ie,V,x]),pe=(o==null?void 0:o.type)===m.turn?n[o.bar.turnIndex]:void 0,_e=a.useMemo(()=>({height:G+ne}),[G,ne]),xe=(o==null?void 0:o.type)===m.turn&&pe!=null?s.jsx(rt,{turn:pe,turnNumber:o.bar.ordinal+1,durationMs:o.bar.durationMs,segments:r.filter(e=>e.turnIndex===o.bar.turnIndex)}):(o==null?void 0:o.type)===m.event&&at(o.segment)?s.jsx(Me,{segment:o.segment,subAgentLabel:o.segment.type==="sub_agent"||(fe=g.find(e=>e.threadId===o.segment.threadId))==null?void 0:fe.track.description}):(o==null?void 0:o.type)===m.toolCallGroup?s.jsx(ot,{group:o.group}):(o==null?void 0:o.type)===m.markerGroup?s.jsx(lt,{group:o.group}):(o==null?void 0:o.type)===m.subAgentGroup?s.jsx(it,{group:o.group}):null;return s.jsx("div",{ref:X,className:"w-full","data-slot":"agent-session-event-timeline-chart",children:s.jsx(We,{title:xe,side:"bottom",triggerClassName:"block w-full",followCursor:!0,open:o!=null&&xe!=null,className:"max-w-[min(25rem,calc(100vw-1rem))] whitespace-normal",anchor:ge,children:s.jsx("div",{className:"w-full",style:_e,onMouseLeave:Ne,children:s.jsx(Ye,{type:"bar",data:Se,options:Ae,plugins:[Ce,Te]})})})})}export{yt as AgentSessionEventTimelineChart};
@@ -0,0 +1 @@
1
+ var $e=e=>{throw TypeError(e)};var He=(e,t,n)=>t.has(e)||$e("Cannot "+n);var ge=(e,t,n)=>(He(e,t,"read from private field"),n?n.call(e):t.get(e)),We=(e,t,n)=>t.has(e)?$e("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ue=(e,t,n,o)=>(He(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n);import{a as kt}from"./chunk-2BDTG544-FxcOqFr-.js";import{r as x,j as P,bn as It,B as Dt,a as Tt,bo as Nt,bp as jt,E as At,c as we,o as Ve,N as Ft,M as Ce,I as Ot,e as Gt,bq as Bt}from"./index-DZOZ1xN3.js";function $t(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function Ht(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function Wt(e){return e/100*window.innerHeight}function Ut(e){return e/100*window.innerWidth}function Vt(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function me({groupSize:e,panelElement:t,styleProp:n}){let o;const[r,i]=Vt(n);switch(i){case"%":{o=r/100*e;break}case"px":{o=r;break}case"rem":{o=Ht(t,r);break}case"em":{o=$t(t,r);break}case"vh":{o=Wt(r);break}case"vw":{o=Ut(r);break}}return o}function O(e){return parseFloat(e.toFixed(3))}function fe({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,r)=>(o+=t==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o),0)}function Re(e){const{panels:t}=e,n=fe({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:r,panelConstraints:i}=o;let u=0;if(i.collapsedSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.collapsedSize});u=O(c/n*100)}let a;if(i.defaultSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.defaultSize});a=O(c/n*100)}let s=0;if(i.minSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.minSize});s=O(c/n*100)}let l=100;if(i.maxSize!==void 0){const c=me({groupSize:n,panelElement:r,styleProp:i.maxSize});l=O(c/n*100)}return{groupResizeBehavior:i.groupResizeBehavior,collapsedSize:u,collapsible:i.collapsible===!0,defaultSize:a,disabled:i.disabled,minSize:s,maxSize:l,panelId:o.id}})}function M(e,t="Assertion error"){if(!e)throw Error(t)}function Ee(e,t){return Array.from(t).sort(e==="horizontal"?qt:Yt)}function qt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function Yt(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function ut(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ct(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function _t({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let r,i=Number.MAX_VALUE;for(const u of t){const{x:a,y:s}=ct(o,u),l=e==="horizontal"?a:s;l<i&&(i=l,r=u)}return M(r,"No rect found"),r}let ye;function Xt(){return ye===void 0&&(typeof matchMedia=="function"?ye=!!matchMedia("(pointer:coarse)").matches:ye=!1),ye}function dt(e){const{element:t,orientation:n,panels:o,separators:r}=e,i=Ee(n,Array.from(t.children).filter(ut).map(v=>({element:v}))).map(({element:v})=>v),u=[];let a=!1,s=!1,l=-1,c=-1,h=0,p,z=[];{let v=-1;for(const d of i)d.hasAttribute("data-panel")&&(v++,d.hasAttribute("data-disabled")||(h++,l===-1&&(l=v),c=v))}if(h>1){let v=-1;for(const d of i)if(d.hasAttribute("data-panel")){v++;const g=o.find(f=>f.element===d);if(g){if(p){const f=p.element.getBoundingClientRect(),b=d.getBoundingClientRect();let y;if(s){const S=n==="horizontal"?new DOMRect(f.right,f.top,0,f.height):new DOMRect(f.left,f.bottom,f.width,0),m=n==="horizontal"?new DOMRect(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(z.length){case 0:{y=[S,m];break}case 1:{const E=z[0],k=_t({orientation:n,rects:[f,b],targetRect:E.element.getBoundingClientRect()});y=[E,k===f?m:S];break}default:{y=z;break}}}else z.length?y=z:y=[n==="horizontal"?new DOMRect(f.right,b.top,b.left-f.right,b.height):new DOMRect(b.left,f.bottom,b.width,b.top-f.bottom)];for(const S of y){let m="width"in S?S:S.element.getBoundingClientRect();const E=Xt()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(m.width<E){const D=E-m.width;m=new DOMRect(m.x-D/2,m.y,m.width+D,m.height)}if(m.height<E){const D=E-m.height;m=new DOMRect(m.x,m.y-D/2,m.width,m.height+D)}const k=v<=l||v>c;!a&&!k&&u.push({group:e,groupSize:fe({group:e}),panels:[p,g],separator:"width"in S?void 0:S,rect:m}),a=!1}}s=!1,p=g,z=[]}}else if(d.hasAttribute("data-separator")){d.ariaDisabled!==null&&(a=!0);const g=r.find(f=>f.element===d);g?z.push(g):(p=void 0,z=[])}else s=!0}return u}var K;class ft{constructor(){We(this,K,{})}addListener(t,n){const o=ge(this,K)[t];return o===void 0?ge(this,K)[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=ge(this,K)[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let r=!1,i=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const s=u[a];try{s.call(null,n)}catch(l){i===null&&(r=!0,i=l)}}if(r)throw i}}removeAllListeners(){Ue(this,K,{})}removeListener(t,n){const o=ge(this,K)[t];if(o!==void 0){const r=o.indexOf(n);r>=0&&o.splice(r,1)}}}K=new WeakMap;let ce={cursorFlags:0,state:"inactive"};const ke=new ft;function te(){return ce}function Jt(e){return ke.addListener("change",e)}function Kt(e){const t=ce,n={...ce};n.cursorFlags=e,ce=n,ke.emit("change",{prev:t,next:n})}function de(e){const t=ce;ce=e,ke.emit("change",{prev:t,next:e})}const Zt=e=>e,Le=()=>{},pt=1,ht=2,gt=4,mt=8,qe=3,Ye=12;let Se;function _e(){return Se===void 0&&(Se=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Se=!0)),Se}function Qt({cursorFlags:e,groups:t,state:n}){let o=0,r=0;switch(n){case"active":case"hover":t.forEach(i=>{if(!i.mutableState.disableCursor)switch(i.orientation){case"horizontal":{o++;break}case"vertical":{r++;break}}})}if(!(o===0&&r===0)){switch(n){case"active":{if(e&&_e()){const i=(e&pt)!==0,u=(e&ht)!==0,a=(e&gt)!==0,s=(e&mt)!==0;if(i)return a?"se-resize":s?"ne-resize":"e-resize";if(u)return a?"sw-resize":s?"nw-resize":"w-resize";if(a)return"s-resize";if(s)return"n-resize"}break}}return _e()?o>0&&r>0?"move":o>0?"ew-resize":"ns-resize":o>0&&r>0?"grab":o>0?"col-resize":"row-resize"}}const Xe=new WeakMap;function Ie(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=Xe.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=te();switch(o.state){case"active":case"hover":{const r=Qt({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),i=`*, *:hover {cursor: ${r} !important; }`;if(t===i)return;t=i,r?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Xe.set(e,{prevStyle:t,styleSheet:n})}let V=new Map;const vt=new ft;function en(e){V=new Map(V),V.delete(e)}function Je(e,t){for(const[n]of V)if(n.id===e)return n}function Z(e,t){for(const[n,o]of V)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Q(){return V}function De(e,t){return vt.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function q(e,t,n){const o=V.get(e);V=new Map(V),V.set(e,t),vt.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:o,next:t})}function bt(e){const t=te(),n=Q();let o=!1;switch(t.state){case"active":de({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Ie(e),o=!0,t.hitRegions.forEach(r=>{if(!n.has(r.group))return;const i=Z(r.group.id,!0);q(r.group,i,{isUserInteraction:!0})}))}return o}function Ke(e){e.defaultPrevented||bt(e.currentTarget)}function tn(e,t,n){let o,r={x:1/0,y:1/0};for(const i of t){const u=ct(n,i.rect);switch(e){case"horizontal":{u.x<=r.x&&(o=i,r=u);break}case"vertical":{u.y<=r.y&&(o=i,r=u);break}}}return o?{distance:r,hitRegion:o}:void 0}function nn(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function on(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:et(e),b:et(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();M(o,"Stacking order can only be calculated for elements with a common ancestor");const r={a:Qe(Ze(n.a)),b:Qe(Ze(n.b))};if(r.a===r.b){const i=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=i.length;for(;a--;){const s=i[a];if(s===u.a)return 1;if(s===u.b)return-1}}return Math.sign(r.a-r.b)}const rn=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function sn(e){const t=getComputedStyle(yt(e)??e).display;return t==="flex"||t==="inline-flex"}function an(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||sn(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||rn.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ze(e){let t=e.length;for(;t--;){const n=e[t];if(M(n,"Missing node"),an(n))return n}return null}function Qe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function et(e){const t=[];for(;e;)t.push(e),e=yt(e);return t}function yt(e){const{parentNode:t}=e;return nn(t)?t.host:t}function ln(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function un({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ut(n)||n.contains(e)||e.contains(n))return!0;if(on(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(ln(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function Te(e,t){const n=[];return t.forEach((o,r)=>{if(r.disabled)return;const i=dt(r),u=tn(r.orientation,i,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&un({groupElement:r.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function cn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function F(e,t,n=0){return Math.abs(O(e)-O(t))<=n}function U(e,t){return F(e,t)?0:e>t?1:-1}function ue({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:r=0,collapsible:i,disabled:u,maxSize:a=100,minSize:s=0}=t;if(u&&!e)return n;if(U(o,s)<0)if(i){const l=(r+s)/2;U(o,l)<0?o=r:o=s}else o=s;return o=Math.min(a,o),o=O(o),o}function be({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:r,trigger:i}){if(F(e,0))return t;const u=i==="imperative-api",a=Object.values(t),s=Object.values(r),l=[...a],[c,h]=o;M(c!=null,"Invalid first pivot index"),M(h!=null,"Invalid second pivot index");let p=0;switch(i){case"keyboard":{{const d=e<0?h:c,g=n[d];M(g,`Panel constraints not found for index ${d}`);const{collapsedSize:f=0,collapsible:b,minSize:y=0}=g;if(b){const S=a[d];if(M(S!=null,`Previous layout not found for panel index ${d}`),F(S,f)){const m=y-S;U(m,Math.abs(e))>0&&(e=e<0?0-m:m)}}}{const d=e<0?c:h,g=n[d];M(g,`No panel constraints found for index ${d}`);const{collapsedSize:f=0,collapsible:b,minSize:y=0}=g;if(b){const S=a[d];if(M(S!=null,`Previous layout not found for panel index ${d}`),F(S,y)){const m=S-f;U(m,Math.abs(e))>0&&(e=e<0?0-m:m)}}}break}default:{const d=e<0?h:c,g=n[d];M(g,`Panel constraints not found for index ${d}`);const f=a[d],{collapsible:b,collapsedSize:y,minSize:S}=g;if(b&&U(f,S)<0)if(e>0){const m=S-y,E=m/2,k=f+e;U(k,S)<0&&(e=U(e,E)<=0?0:m)}else{const m=S-y,E=100-m/2,k=f-e;U(k,S)<0&&(e=U(100+e,E)>0?0:-m)}break}}{const d=e<0?1:-1;let g=e<0?h:c,f=0;for(;;){const y=a[g];M(y!=null,`Previous layout not found for panel index ${g}`);const S=ue({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:y,size:100})-y;if(f+=S,g+=d,g<0||g>=n.length)break}const b=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-b:b}{let d=e<0?c:h;for(;d>=0&&d<n.length;){const g=Math.abs(e)-Math.abs(p),f=a[d];M(f!=null,`Previous layout not found for panel index ${d}`);const b=f-g,y=ue({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:f,size:b});if(!F(f,y)&&(p+=f-y,l[d]=y,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(cn(s,l))return r;{const d=e<0?h:c,g=a[d];M(g!=null,`Previous layout not found for panel index ${d}`);const f=g+p,b=ue({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:g,size:f});if(l[d]=b,!F(b,f)){let y=f-b,S=e<0?h:c;for(;S>=0&&S<n.length;){const m=l[S];M(m!=null,`Previous layout not found for panel index ${S}`);const E=m+y,k=ue({overrideDisabledPanels:u,panelConstraints:n[S],prevSize:m,size:E});if(F(m,k)||(y-=k-m,l[S]=k),F(y,0))break;e>0?S--:S++}}}const z=Object.values(l).reduce((d,g)=>g+d,0);if(!F(z,100,.1))return r;const v=Object.keys(r);return l.reduce((d,g,f)=>(d[v[f]]=g,d),{})}function ne(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||U(e[n],t[n])!==0)return!1;return!0}function oe({layout:e,panelConstraints:t}){const n=Object.values(e),o=[...n],r=o.reduce((a,s)=>a+s,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(a=>`${a}%`).join(", ")}`);if(!F(r,100)&&o.length>0)for(let a=0;a<t.length;a++){const s=o[a];M(s!=null,`No layout data found for index ${a}`);const l=100/r*s;o[a]=l}let i=0;for(let a=0;a<t.length;a++){const s=n[a];M(s!=null,`No layout data found for index ${a}`);const l=o[a];M(l!=null,`No layout data found for index ${a}`);const c=ue({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:s,size:l});l!=c&&(i+=l-c,o[a]=c)}if(!F(i,0))for(let a=0;a<t.length;a++){const s=o[a];M(s!=null,`No layout data found for index ${a}`);const l=s+i,c=ue({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:s,size:l});if(s!==c&&(i-=c-s,o[a]=c,F(i,0)))break}const u=Object.keys(e);return o.reduce((a,s,l)=>(a[u[l]]=s,a),{})}function St({groupId:e,panelId:t}){const n=()=>{const s=Q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:h,layout:p,groupSize:z,separatorToPanels:v}]of s)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:h,group:l,groupSize:z,layout:p,separatorToPanels:v};throw Error(`Group ${e} not found`)},o=()=>{const s=n().derivedPanelConstraints.find(l=>l.panelId===t);if(s!==void 0)return s;throw Error(`Panel constraints not found for Panel ${t}`)},r=()=>{const s=n().group.panels.find(l=>l.id===t);if(s!==void 0)return s;throw Error(`Layout not found for Panel ${t}`)},i=()=>{const s=n().layout[t];if(s!==void 0)return s;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:s,panels:l,prevLayout:c,derivedPanelConstraints:h})=>{const p=i(),z=l.findIndex(g=>g.id===t),v=z===0,d=z===l.length-1;if(d&&s<p&&(v||l.slice(0,z).every((g,f)=>{const b=h[f];return(b==null?void 0:b.collapsible)&&F(b.collapsedSize,c[b.panelId])}))){const g=l.slice(0,z).reduce((f,b)=>f+c[b.id],0);return{...c,[t]:O(100-g)}}return be({delta:d?p-s:s-p,initialLayout:c,panelConstraints:h,pivotIndices:d?[z-1,z]:[z,z+1],prevLayout:c,trigger:"imperative-api"})},a=s=>{const l=i();if(s===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:h,group:p,groupSize:z,layout:v,separatorToPanels:d}=n(),g=u({nextSize:s,panels:p.panels,prevLayout:v,derivedPanelConstraints:h}),f=oe({layout:g,panelConstraints:h});ne(v,f)||q(p,{defaultLayoutDeferred:c,derivedPanelConstraints:h,groupSize:z,layout:f,separatorToPanels:d})};return{collapse:()=>{const{collapsible:s,collapsedSize:l}=o(),{mutableValues:c}=r(),h=i();s&&h!==l&&(c.expandToSize=h,a(l))},expand:()=>{const{collapsible:s,collapsedSize:l,minSize:c}=o(),{mutableValues:h}=r(),p=i();if(s&&p===l){let z=h.expandToSize??c;z===0&&(z=1),a(z)}},getSize:()=>{const{group:s}=n(),l=i(),{element:c}=r(),h=s.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:h}},isCollapsed:()=>{const{collapsible:s,collapsedSize:l}=o(),c=i();return s&&F(l,c)},resize:s=>{const{group:l}=n(),{element:c}=r(),h=fe({group:l}),p=me({groupSize:h,panelElement:c,styleProp:s}),z=O(p/h*100);a(z)}}}function tt(e){if(e.defaultPrevented)return;const t=Q();Te(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const o=n.panels.find(r=>r.panelConstraints.defaultSize!==void 0);if(o){const r=o.panelConstraints.defaultSize,i=St({groupId:n.group.id,panelId:o.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function xe(e){const t=Q();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function xt({groupId:e}){const t=()=>{const n=Q();for(const[o,r]of n)if(o.id===e)return{group:o,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:r,group:i,groupSize:u,layout:a,separatorToPanels:s}=t(),l=oe({layout:n,panelConstraints:r});return o?a:(ne(a,l)||q(i,{defaultLayoutDeferred:o,derivedPanelConstraints:r,groupSize:u,layout:l,separatorToPanels:s}),l)}}}function ee(e,t){const n=xe(e),o=Z(n.id,!0),r=n.separators.find(c=>c.element===e);M(r,"Matching separator not found");const i=o.separatorToPanels.get(r);M(i,"Matching panels not found");const u=i.map(c=>n.panels.indexOf(c)),a=xt({groupId:n.id}).getLayout(),s=be({delta:t,initialLayout:a,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:a,trigger:"keyboard"}),l=oe({layout:s,panelConstraints:o.derivedPanelConstraints});ne(a,l)||q(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:l,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function nt(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=xe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&ee(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&ee(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&ee(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&ee(t,-5);break}case"End":{e.preventDefault(),ee(t,100);break}case"Enter":{e.preventDefault();const o=xe(t),r=Z(o.id,!0),{derivedPanelConstraints:i,layout:u,separatorToPanels:a}=r,s=o.separators.find(p=>p.element===t);M(s,"Matching separator not found");const l=a.get(s);M(l,"Matching panels not found");const c=l[0],h=i.find(p=>p.panelId===c.id);if(M(h,"Panel metadata not found"),h.collapsible){const p=u[c.id],z=h.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??h.minSize:h.collapsedSize;ee(t,z-p)}break}case"F6":{e.preventDefault();const o=xe(t).separators.map(u=>u.element),r=Array.from(o).findIndex(u=>u===e.currentTarget);M(r!==null,"Index not found");const i=e.shiftKey?r>0?r-1:o.length-1:r+1<o.length?r+1:0;o[i].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),ee(t,-100);break}}}function ot(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Q(),n=Te(e,t),o=new Map;let r=!1;n.forEach(i=>{i.separator&&(r||(r=!0,i.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(i.group);u&&o.set(i.group,u.layout)}),de({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function zt({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:r,pointerDownAtPoint:i,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:h}=l,{orientation:p,panels:z}=c,{disableCursor:v}=c.mutableState;let d=0;i?p==="horizontal"?d=(t.clientX-i.x)/h*100:d=(t.clientY-i.y)/h*100:p==="horizontal"?d=t.clientX<0?-100:100:d=t.clientY<0?-100:100;const g=o.get(c),f=r.get(c);if(!g||!f)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:y,groupSize:S,layout:m,separatorToPanels:E}=f;if(y&&m&&E){const k=be({delta:d,initialLayout:g,panelConstraints:y,pivotIndices:l.panels.map(D=>z.indexOf(D)),prevLayout:m,trigger:"mouse-or-touch"});if(ne(k,m)){if(d!==0&&!v)switch(p){case"horizontal":{a|=d<0?pt:ht;break}case"vertical":{a|=d<0?gt:mt;break}}}else q(l.group,{defaultLayoutDeferred:b,derivedPanelConstraints:y,groupSize:S,layout:k,separatorToPanels:E})}});let s=0;t.movementX===0?s|=u&qe:s|=a&qe,t.movementY===0?s|=u&Ye:s|=a&Ye,Kt(s),Ie(e)}function rt(e){const t=Q(),n=te();switch(n.state){case"active":zt({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function st(e){var o,r;if(e.defaultPrevented)return;const t=te(),n=Q();switch(t.state){case"active":{if(e.buttons===0){de({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{if(!n.has(i.group))return;const u=Z(i.group.id,!0);q(i.group,u,{isUserInteraction:!0})});return}for(const i of t.hitRegions)if(i.separator){const{element:u}=i.separator;(o=u.hasPointerCapture)!=null&&o.call(u,e.pointerId)||((r=u.setPointerCapture)==null||r.call(u,e.pointerId))}zt({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=Te(e,n);i.length===0?t.state!=="inactive"&&de({cursorFlags:0,state:"inactive"}):de({cursorFlags:0,hitRegions:i,state:"hover"}),Ie(e.currentTarget);break}}}function it(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(te().state){case"hover":de({cursorFlags:0,state:"inactive"})}}function at(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||bt(e.currentTarget)&&e.preventDefault()}function lt(e){let t=0,n=0;const o={};for(const i of e)if(i.defaultSize!==void 0){t++;const u=O(i.defaultSize);n+=u,o[i.panelId]=u}else o[i.panelId]=void 0;const r=e.length-t;if(r!==0){const i=O((100-n)/r);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=i)}return o}function dn(e,t,n){if(!n[0])return;const o=e.panels.find(s=>s.element===t);if(!o||!o.onResize)return;const r=fe({group:e}),i=e.orientation==="horizontal"?o.element.offsetWidth:o.element.offsetHeight,u=o.mutableValues.prevSize,a={asPercentage:O(i/r*100),inPixels:i};o.mutableValues.prevSize=a,o.onResize(a,o.id,u)}function fn(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function pn(e,t){return e.length!==t.length?!1:e.every((n,o)=>fn(n,t[o]))}function hn({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let r=0,i=0,u=!1;const a=new Map,s=[];for(const h of e.panels){const p=o[h.id]??0;switch(h.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const z=p/100*n,v=O(z/t*100);a.set(h.id,v),r+=v;break}case"preserve-relative-size":default:{s.push(h.id),i+=p;break}}}if(!u||s.length===0)return o;const l=100-r,c={...o};if(a.forEach((h,p)=>{c[p]=h}),i>0)for(const h of s){const p=o[h]??0;c[h]=O(p/i*l)}else{const h=O(l/s.length);for(const p of s)c[p]=h}return c}function gn(e,t){const n=e.map(r=>r.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const r of n)if(!o.includes(r))return!1;return!0}const le=new Map;function mn(e){let t=!0;M(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,r=new Set,i=new n(v=>{for(const d of v){const{borderBoxSize:g,target:f}=d;if(f===e.element){if(t){const b=fe({group:e});if(b===0)return;const y=Z(e.id);if(!y)return;const S=Re(e),m=y.defaultLayoutDeferred?lt(S):y.layout,E=hn({group:e,nextGroupSize:b,prevGroupSize:y.groupSize,prevLayout:m}),k=oe({layout:E,panelConstraints:S});if(!y.defaultLayoutDeferred&&ne(y.layout,k)&&pn(y.derivedPanelConstraints,S)&&y.groupSize===b)continue;q(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:b,layout:k,separatorToPanels:y.separatorToPanels})}}else dn(e,f,g)}});i.observe(e.element),e.panels.forEach(v=>{M(!o.has(v.id),`Panel ids must be unique; id "${v.id}" was used more than once`),o.add(v.id),v.onResize&&i.observe(v.element)});const u=fe({group:e}),a=Re(e),s=e.panels.map(({id:v})=>v).join(",");let l=e.mutableState.defaultLayout;l&&(gn(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[s]??l??lt(a),h=oe({layout:c,panelConstraints:a}),p=e.element.ownerDocument;le.set(p,(le.get(p)??0)+1);const z=new Map;return dt(e).forEach(v=>{v.separator&&z.set(v.separator,v.panels)}),q(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:h,separatorToPanels:z}),e.separators.forEach(v=>{M(!r.has(v.id),`Separator ids must be unique; id "${v.id}" was used more than once`),r.add(v.id),v.element.addEventListener("keydown",nt)}),le.get(p)===1&&(p.addEventListener("contextmenu",Ke,!0),p.addEventListener("dblclick",tt,!0),p.addEventListener("pointerdown",ot,!0),p.addEventListener("pointerleave",rt),p.addEventListener("pointermove",st),p.addEventListener("pointerout",it),p.addEventListener("pointerup",at,!0)),function(){t=!1,le.set(p,Math.max(0,(le.get(p)??0)-1)),en(e),e.separators.forEach(v=>{v.element.removeEventListener("keydown",nt)}),le.get(p)||(p.removeEventListener("contextmenu",Ke,!0),p.removeEventListener("dblclick",tt,!0),p.removeEventListener("pointerdown",ot,!0),p.removeEventListener("pointerleave",rt),p.removeEventListener("pointermove",st),p.removeEventListener("pointerout",it),p.removeEventListener("pointerup",at,!0)),i.disconnect()}}function vn(){const[e,t]=x.useState({}),n=x.useCallback(()=>t({}),[]);return[e,n]}function Ne(e){const t=x.useId();return`${e??t}`}const re=typeof window<"u"?x.useLayoutEffect:x.useEffect;function ve(e){const t=x.useRef(e);return re(()=>{t.current=e},[e]),x.useCallback((...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[t])}function je(...e){return ve(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Ae(e){const t=x.useRef({...e});return re(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const wt=x.createContext(null);function bn(e,t){const n=x.useRef({getLayout:()=>({}),setLayout:Zt});x.useImperativeHandle(t,()=>n.current,[]),re(()=>{Object.assign(n.current,xt({groupId:e}))})}function Ct({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:r,elementRef:i,groupRef:u,id:a,onLayoutChange:s,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:h={coarse:20,fine:10},style:p,...z}){const v=x.useRef({onLayoutChange:{},onLayoutChanged:{}}),d=ve(w=>{ne(v.current.onLayoutChange,w)||(v.current.onLayoutChange=w,s==null||s(w))}),g=ve((w,C)=>{ne(v.current.onLayoutChanged,w)||(v.current.onLayoutChanged=w,l==null||l(w,{isUserInteraction:C}))}),f=Ne(a),b=x.useRef(null),[y,S]=vn(),m=x.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:h,separators:[]}),E=je(b,i);bn(f,u);const k=ve((w,C)=>{const I=te(),R=Je(w),T=Z(w);if(T){let B=!1;switch(I.state){case"active":{B=I.hitRegions.some(Y=>Y.group===R);break}}return{flexGrow:T.layout[C]??1,pointerEvents:B?"none":void 0}}if(n!=null&&n[C])return{flexGrow:n==null?void 0:n[C]}}),D=Ae({defaultLayout:n,disableCursor:o}),G=x.useMemo(()=>({get disableCursor(){return!!D.disableCursor},getPanelStyles:k,id:f,orientation:c,registerPanel:w=>{const C=m.current;return C.panels=Ee(c,[...C.panels,w]),S(),()=>{C.panels=C.panels.filter(I=>I!==w),S()}},registerSeparator:w=>{const C=m.current;return C.separators=Ee(c,[...C.separators,w]),S(),()=>{C.separators=C.separators.filter(I=>I!==w),S()}},updatePanelProps:(w,{disabled:C})=>{const I=m.current.panels.find(B=>B.id===w);I&&(I.panelConstraints.disabled=C);const R=Je(f),T=Z(f);R&&T&&q(R,{...T,derivedPanelConstraints:Re(R)})},updateSeparatorProps:(w,{disabled:C,disableDoubleClick:I})=>{const R=m.current.separators.find(T=>T.id===w);R&&(R.disabled=C,R.disableDoubleClick=I)}}),[k,f,S,c,D]),W=x.useRef(null);return re(()=>{const w=b.current;if(w===null)return;const C=m.current;let I;if(D.defaultLayout!==void 0&&Object.keys(D.defaultLayout).length===C.panels.length){I={};for(const $ of C.panels){const X=D.defaultLayout[$.id];X!==void 0&&(I[$.id]=X)}}const R={disabled:!!r,element:w,id:f,mutableState:{defaultLayout:I,disableCursor:!!D.disableCursor,expandedPanelSizes:m.current.lastExpandedPanelSizes,layouts:m.current.layouts},orientation:c,panels:C.panels,resizeTargetMinimumSize:C.resizeTargetMinimumSize,separators:C.separators};W.current=R;const T=mn(R),{defaultLayoutDeferred:B,derivedPanelConstraints:Y,layout:_}=Z(R.id,!0);!B&&Y.length>0&&(d(_),g(_,!1));const N=De(f,$=>{const{defaultLayoutDeferred:X,derivedPanelConstraints:se,layout:ie}=$.next;if(X||se.length===0)return;const pe=R.panels.map(({id:H})=>H).join(",");R.mutableState.layouts[pe]=ie,se.forEach(H=>{if(H.collapsible){const{layout:he}=$.prev??{};if(he){const ze=F(H.collapsedSize,ie[H.panelId]),j=F(H.collapsedSize,he[H.panelId]);ze&&!j&&(R.mutableState.expandedPanelSizes[H.panelId]=he[H.panelId])}}});const ae=te().state!=="active";d(ie),ae&&g(ie,$.isUserInteraction)});return()=>{W.current=null,T(),N()}},[r,f,g,d,c,y,D]),x.useEffect(()=>{const w=W.current;w&&(w.mutableState.defaultLayout=n,w.mutableState.disableCursor=!!o)}),P.jsx(wt.Provider,{value:G,children:P.jsx("div",{...z,className:t,"data-group":!0,"data-testid":f,id:f,ref:E,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}Ct.displayName="Group";function Fe(){const e=x.useContext(wt);return M(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function yn(e,t){const{id:n}=Fe(),o=x.useRef({collapse:Le,expand:Le,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Le});x.useImperativeHandle(t,()=>o.current,[]),re(()=>{Object.assign(o.current,St({groupId:n,panelId:e}))})}function Me({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:r,disabled:i,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:s,maxSize:l="100%",minSize:c="0%",onResize:h,panelRef:p,style:z,...v}){const d=!!s,g=Ne(s),f=Ae({disabled:i}),b=x.useRef(null),y=je(b,u),{getPanelStyles:S,id:m,orientation:E,registerPanel:k,updatePanelProps:D}=Fe(),G=h!==null,W=ve((R,T,B)=>{h==null||h(R,s,B)});re(()=>{const R=b.current;if(R!==null){const T={element:R,id:g,idIsStable:d,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?W:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:r,disabled:f.disabled,maxSize:l,minSize:c}};return k(T)}},[a,n,o,r,G,g,d,l,c,W,k,f]),x.useEffect(()=>{D(g,{disabled:i})},[i,g,D]),yn(g,p);const w=()=>{const R=S(m,g);if(R)return JSON.stringify(R)},C=x.useSyncExternalStore(R=>De(m,R),w,w);let I;return C?I=JSON.parse(C):r!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:r}:I={flexGrow:1},P.jsx("div",{...v,"data-disabled":i||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Sn,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:P.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...z,touchAction:E==="horizontal"?"pan-y":"pan-x"},children:e})})}Me.displayName="Panel";const Sn={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function xn({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let r,i;const u=e[n],a=t.find(s=>s.panelId===n);if(a){const s=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];i=oe({layout:be({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],r=oe({layout:be({delta:s-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:r,valueMin:i,valueNow:u}}function Lt({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:r,id:i,style:u,...a}){const s=Ne(i),l=Ae({disabled:n,disableDoubleClick:o}),[c,h]=x.useState({}),[p,z]=x.useState("inactive"),[v,d]=x.useState(!1),g=x.useRef(null),f=je(g,r),{disableCursor:b,id:y,orientation:S,registerSeparator:m,updateSeparatorProps:E}=Fe(),k=S==="horizontal"?"vertical":"horizontal";re(()=>{const W=g.current;if(W!==null){const w={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:W,id:s},C=m(w),I=Jt(T=>{z(T.next.state!=="inactive"&&T.next.hitRegions.some(B=>B.separator===w)?T.next.state:"inactive")}),R=De(y,T=>{const{derivedPanelConstraints:B,layout:Y,separatorToPanels:_}=T.next,N=_.get(w);if(N){const $=N[0],X=N.indexOf($);h(xn({layout:Y,panelConstraints:B,panelId:$.id,panelIndex:X}))}});return()=>{I(),R(),C()}}},[y,s,m,l]),x.useEffect(()=>{E(s,{disabled:n,disableDoubleClick:o})},[n,o,s,E]);let D;n&&!b&&(D="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:v?G="focus":G=p}return P.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":k,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":s,id:s,onBlur:()=>d(!1),onFocus:()=>d(!0),ref:f,role:"separator",style:{flexBasis:"auto",cursor:D,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Lt.displayName="Separator";async function zn({fetchPage:e}){const t=[];let n;do{const o=await e(n);t.push(...o.data),n=o.nextPageToken}while(n!=null&&n.length>0);return t}var wn="96px";function Pe(e){var n;const t=(n=e.title)==null?void 0:n.trim();return t!=null&&t.length>0?t:"Untitled session"}function Cn(e){return"isMutable"in e&&typeof Reflect.get(e,"isMutable")=="boolean"?Reflect.get(e,"isMutable")===!0:e.agentName==null}function Ln(e){return"sourceType"in e&&Reflect.get(e,"sourceType")==="schedule"?"schedule":void 0}function Mn({agentId:e,startTimestamp:t,endTimestamp:n,shareView:o}){const r=It(),i=Dt(),u=Tt(),a=Nt(),{sessionId:s,updateShareSearch:l}=jt(),{allows:c}=At({resourceType:"session",resourceIds:s==null?[]:[s]}),h=c(s,"MANAGE"),p=we("AgentSessionListRow"),z=we("AgentSessionDetailHeader"),v=we("AgentSessionTimelineContainer"),[d,g]=x.useState([]),[f,b]=x.useState(),[y,S]=x.useState(!0),[m,E]=x.useState(!1),[k,D]=x.useState(!1),[G,W]=x.useState(!1),w=x.useRef(0),C=x.useRef(!1),[I,R]=x.useState(null),[T,B]=x.useState(null),[Y,_]=x.useState(),[N,$]=x.useState(),[X,se]=x.useState(!1),[ie,pe]=x.useState(!1),ae=x.useMemo(()=>({order:"desc",limit:20,...e==null||e.length===0?{}:{agentId:e},...t==null?{}:{startTimestamp:t},...n==null?{}:{endTimestamp:n}}),[e,n,t]);x.useEffect(()=>{const L=++w.current;let A=!1;return C.current=!1,b(void 0),S(!0),E(!1),D(!1),W(!1),r.listSessions(ae).then(J=>{A||w.current!==L||(g(J.data),b(J.nextPageToken))}).catch(()=>{A||w.current!==L||(g([]),b(void 0),W(!0))}).finally(()=>{!A&&w.current===L&&S(!1)}),()=>{A=!0}},[ae,r]);const H=x.useCallback(async()=>{if(y||f==null||C.current)return;const L=w.current;C.current=!0,E(!0),D(!1);try{const A=await r.listSessions({...ae,pageToken:f});if(w.current!==L)return;g(J=>[...J,...A.data]),b(A.nextPageToken)}catch{w.current===L&&D(!0)}finally{w.current===L&&(C.current=!1,E(!1))}},[y,ae,f,r]);x.useEffect(()=>{if(y||f==null||I==null||T==null)return;const L=new IntersectionObserver(A=>{A.some(J=>J.isIntersecting)&&H()},{root:I,rootMargin:wn});return L.observe(T),()=>L.disconnect()},[d.length,I,y,H,f,T]),x.useEffect(()=>{if(s==null||s.length===0){_(void 0),$(void 0),pe(!1),se(!1);return}let L=!1;return se(!0),pe(!1),_(void 0),$(void 0),Promise.all([zn({fetchPage:A=>r.listSessionEvents({sessionId:s,limit:100,...A==null?{}:{pageToken:A}})}),i.getSession({sessionId:s}).catch(()=>{})]).then(([A,J])=>{L||(_([...A].reverse()),$(J))}).catch(()=>{L||pe(!0)}).finally(()=>{L||se(!1)}),()=>{L=!0}},[i,s,r]);const he=L=>{const A=o==="sessions"?Bt(L.createdAt):null;l({sessionId:L.id,...o==="sessions"?{view:"sessions",...A==null?{}:{timeRange:A}}:{agentId:e??null,tab:"sessions",view:null,timeRange:null}})},ze=()=>{s!=null&&l({sessionId:null})},j=d.find(L=>L.id===s),Pt=N!=null?Pe(N):j!=null?Pe(j):s??"Untitled session",Oe=N!=null?Ve(N):j!=null?Ve(j):!1,Rt=N!=null?N.isMutable:j!=null?Cn(j):!0,Ge=Oe?"Resume Agent building":"Resume Chat",Be=s!=null&&a!=null?kt({sessionId:s,routes:a}):null,Et=()=>{if(!h||s==null||u==null)return;const L=(N==null?void 0:N.agentName)??(j==null?void 0:j.agentName);u.openHistorySession({sessionId:s,isMutable:Rt,isCreateAgent:Oe,...L!=null&&L.length>0?{agentName:L}:{}})},Mt=Be!=null?{resumeHref:Be,resumeLabel:Ge}:u!=null?{onResume:Et,resumeLabel:Ge}:{};return!y&&!G&&d.length===0&&(s==null||s.length===0)?P.jsx(Ft,{title:"No Sessions Found",description:"There are no sessions available at the moment.",className:"bg-primary-bg"}):P.jsxs(Ct,{id:"agent-sessions-split",orientation:"horizontal",className:"h-full min-h-0 w-full",resizeTargetMinimumSize:{coarse:24,fine:11},children:[P.jsx(Me,{id:"agent-sessions-list",defaultSize:"35%",minSize:"20%",maxSize:"50%",children:P.jsx("aside",{className:"flex h-full min-h-0 w-full flex-col bg-sidebar-bg",children:P.jsxs("div",{ref:R,className:"scrollbar-none min-h-0 flex-1 overflow-y-auto",children:[y?P.jsx("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading sessions",children:["a","b","c"].map(L=>P.jsx(Ce,{className:"h-16 rounded-md"},L))}):G?P.jsx("p",{className:"px-3 py-6 text-center text-xs text-text-secondary",children:"Sessions could not be loaded."}):d.map(L=>P.jsx(p,{title:Pe(L),agentName:L.agentName??void 0,sourceType:Ln(L),lastActivityAt:L.lastActivityAt,metrics:L.metrics,active:L.id===s,onSelect:()=>he(L)},L.id)),f!=null&&!y&&!G?P.jsx("div",{ref:B,className:"px-3 py-2",children:m?P.jsx(Ce,{className:"h-16 rounded-md",role:"status","aria-label":"Loading more sessions"}):k?P.jsx("button",{type:"button",className:"h-8 w-full rounded-md border border-border text-xs font-medium text-text-primary hover:bg-ghost-button-hover",onClick:()=>void H(),children:"Retry loading sessions"}):null}):null]})})}),P.jsxs(Lt,{id:"agent-sessions-resizer","aria-label":"Resize session list",className:"group/resizer relative z-10 w-0 cursor-col-resize focus-visible:outline-none",children:[P.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 -left-1.25 w-2.75"}),P.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-px bg-border transition-colors"}),P.jsx("div",{"aria-hidden":!0,className:Gt("absolute top-1/2 left-0 z-10 flex h-4 w-2 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-xs shadow-sm transition-colors","bg-secondary-button-bg text-text-secondary","group-hover/resizer:bg-primary-button-bg group-hover/resizer:text-primary-button-text","group-active/resizer:bg-primary-button-bg group-active/resizer:text-primary-button-text","group-focus-visible/resizer:bg-primary-button-bg group-focus-visible/resizer:text-primary-button-text"),children:P.jsx(Ot,{name:"grip-vertical",size:10})})]}),P.jsx(Me,{id:"agent-session-detail",defaultSize:"65%",minSize:"30%",children:P.jsx("section",{className:"flex h-full min-w-0 flex-col bg-primary-bg",children:s==null?P.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Select a session to view details"}):ie?P.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session details could not be loaded."}):P.jsxs(P.Fragment,{children:[P.jsx(z,{title:Pt,sessionId:s,agentId:e,createdAt:(N==null?void 0:N.createdAt)??(j==null?void 0:j.createdAt),view:o,onClose:ze,canResume:h,...Mt}),X||Y===void 0?P.jsx("div",{className:"flex flex-1 flex-col p-4",role:"status","aria-label":"Loading session details",children:P.jsx(Ce,{className:"min-h-64 flex-1 rounded-lg"})}):P.jsx(v,{sessionId:s,events:Y,listMetrics:j==null?void 0:j.metrics})]})})})]})}export{Mn as AgentSessions};
@@ -1 +1 @@
1
- import{aD as ee,D as ce,r as a,aE as _,j as e,H as me,K as z,I as w,aG as te,a9 as K,aK as ue,e as D,aF as X}from"./index-XpZpj5Rl.js";var xe=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],V=K("h-11 shadow-sm"),B=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),he=({open:n,onOpenChange:p,onSubmit:h,connector:r,busy:f=!1,error:v})=>{const[b,y]=a.useState(""),[j,g]=a.useState(""),[N,m]=a.useState(""),[o,k]=a.useState("dcr"),[C,F]=a.useState(""),[A,S]=a.useState(""),u=r!==void 0,d=K(`h-11 shadow-sm ${u?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{y(""),g(""),m(""),k("dcr"),F(""),S("")};a.useEffect(()=>{n&&(y((r==null?void 0:r.name)??""),g((r==null?void 0:r.url)??""),m((r==null?void 0:r.description)??""),k((r==null?void 0:r.auth.type)??"dcr"),F(""),S((r==null?void 0:r.auth.type)==="header"?r.auth.headerName??"":""))},[r,n]);const T=l=>{l||i(),p(l)},I=!!C.trim()||(r==null?void 0:r.auth.type)==="header",E=!!b.trim()&&!!N.trim()&&!!j.trim()&&(o!=="header"||I),P=async l=>{if(l.preventDefault(),!E||f)return;const O=o==="header"?{type:"header",apiKey:C.trim(),...A.trim()?{headerName:A.trim()}:{}}:{type:o};try{await h({name:b.trim(),url:j.trim(),description:N.trim(),auth:O}),i(),p(!1)}catch{}};return e.jsx(te,{open:n,onOpenChange:T,title:u?"Edit MCP server":"Add MCP server",description:u?"Update how this connector authenticates.":"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void P(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:b,readOnly:u,"aria-disabled":u,onChange:l=>{y(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!u,className:d})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(B,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:N,onChange:l=>{m(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:K("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:j,onChange:l=>{g(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:V})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(B,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:xe.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${o===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:o===l.value,onChange:()=>{k(l.value)},className:"sr-only"}),l.label]},l.value))})]}),o==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(w,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,o==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",(r==null?void 0:r.auth.type)==="header"?e.jsx("span",{className:"font-normal text-text-secondary",children:" (leave blank to keep current)"}):e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:(r==null?void 0:r.auth.type)!=="header",value:C,onChange:l=>{F(l.target.value)},placeholder:"Paste the server token",className:V})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:A,onChange:l=>{S(l.target.value)},placeholder:"Authorization",className:V})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[v?e.jsx("p",{className:"text-failure-bg text-sm",children:v}):null,e.jsx(z.Primary,{type:"submit",size:"large",disabled:!E||f,className:"w-full shrink-0",children:u?"Save":"Add"})]})]})})},Z=he,U={dcr:"OAuth2",header:"API Key",none:"No Auth"};function pe({text:n}){const p=a.useRef(null),[h,r]=a.useState(!1),[f,v]=a.useState(!1),[b,y]=a.useState(16);return a.useLayoutEffect(()=>{r(!1),y(16)},[n]),a.useLayoutEffect(()=>{const j=p.current;if(!j)return;if(!h){y(16),v(j.scrollWidth>j.clientWidth+1);return}y(16);const g=requestAnimationFrame(()=>{y(j.scrollHeight)});return()=>cancelAnimationFrame(g)},[n,h]),n?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:p,style:{maxHeight:b},className:D("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!h&&"whitespace-nowrap",!h&&f&&"pr-[5.75rem]"),children:[n,h&&f?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>r(!1),children:"Show less"})]}):null]}),!h&&f?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>r(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var fe=({connector:n,onBack:p,onConnectorRefreshed:h,onEdit:r,onDisconnect:f,busy:v=!1})=>{const{connectorCatalog:b}=ee(),{handleAuthorize:y,isOAuthLoading:j}=ue(),[g,N]=a.useState([]),[m,o]=a.useState(!0),[k,C]=a.useState(null),[F,A]=a.useState(!1);a.useEffect(()=>{let d=!1;return N([]),C(null),o(!0),b.getToolsByConnectorId({id:n.id}).then(i=>{d||N(i)}).catch(i=>{d||C(_(i,"Failed to load connector tools"))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[n.authenticated,n.id,b]);const S=async()=>{A(!0),C(null);try{const d=await b.getConnector({id:n.id});h(d)}catch(d){C(_(d,"Failed to refresh connector details"))}finally{A(!1)}},u=j||F;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:p,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(w,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:n.name}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:U[n.auth.type]??U.none}),e.jsxs("span",{className:D("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",n.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:D("h-1.5 w-1.5 rounded-full",n.authenticated?"bg-success-bg":"bg-primary-button-bg")}),n.authenticated?"Connected":"Not authenticated"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:e.jsx("span",{className:"text-text-secondary",children:n.description})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z.Secondary,{size:"small",type:"button",disabled:v,onClick:r,children:[e.jsx(w,{name:"pencil",className:"size-3"}),"Edit"]}),n.auth.type==="dcr"&&!n.authenticated?e.jsx(z.Secondary,{size:"small",type:"button",disabled:v||u,onClick:()=>{y(n.id,d=>{d&&S()})},children:u?"Connecting…":"Connect"}):n.auth.type==="dcr"&&!n.requiresAuth?e.jsx(z.Secondary,{size:"small",type:"button",disabled:v,onClick:f,children:"Disconnect"}):null]})]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:m?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):k?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[k,n.auth.type==="dcr"&&!n.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):g.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",g.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:g.map(d=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:d.name}),e.jsx(pe,{text:d.description})]})},d.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},be=fe,ge=()=>{const{connectorCatalog:n}=ee(),p=ce(),[h,r]=a.useState(""),[f,v]=a.useState({ordered:[],authStatusById:new Map}),[b,y]=a.useState(!0),[j,g]=a.useState(null),[N,m]=a.useState(null),[o,k]=a.useState(!1),[C,F]=a.useState([]),[A,S]=a.useState(!1),[u,d]=a.useState(null),[i,T]=a.useState(null),[I,E]=a.useState(null),[P,l]=a.useState(""),O=a.useMemo(()=>(C??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[C]),Q=a.useCallback(async()=>{y(!0),g(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);F(s);const c=t??[],M=new Set(c.map(x=>x.id)),W=[...c.map(x=>({connector:x,isConfigured:!0})),...s.filter(x=>!M.has(x.id)).map(x=>({connector:x,isConfigured:!1}))];v({ordered:W,authStatusById:new Map(W.map(x=>[x.connector.id,x.isConfigured?x.connector.authenticated:!1]))}),E(x=>x?t.find(oe=>oe.id===x.id)??null:null)}catch(t){g(_(t,"Failed to load connectors"))}finally{y(!1)}},[n]);a.useEffect(()=>{Q()},[Q]);const L=h.trim().toLowerCase(),q=a.useMemo(()=>L?f.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(L)||(((s=t.description)==null?void 0:s.toLowerCase().includes(L))??!1)||t.url.toLowerCase().includes(L)}):f.ordered,[f.ordered,L]),R=a.useMemo(()=>{const t=[];for(const s of q)if(s.isConfigured){const c=f.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(c===s.connector.authenticated?s.connector:{...s.connector,authenticated:c})}return t},[f.authStatusById,q]),$=a.useMemo(()=>{const t=[];for(const s of q)s.isConfigured||t.push(s.connector);return t},[q]),H=async(t,s=g)=>{k(!0),g(null);try{await t(),await Q()}catch(c){throw s(_(c,"Request failed")),c}finally{k(!1)}},G=()=>{T(null),l(""),m(null)},Y=async(t,s)=>{const c=s??(t.auth.type==="header"?{type:"header",...t.auth.headerName?{headerName:t.auth.headerName}:{}}:t.auth.type==="dcr"?{type:"dcr"}:{type:"none"});await n.createConnector({name:t.name,description:t.description??t.url,url:t.url,auth:c})},se=t=>{if(t.auth.type==="header"){l(""),m(null),T(t);return}H(async()=>{await Y(t)}).catch(()=>{})},ae=t=>{if(t.preventDefault(),!i||!P.trim())return;const s=i;m(null),H(async()=>{const c={type:"header",apiKey:P.trim(),...s.auth.type==="header"&&s.auth.headerName?{headerName:s.auth.headerName}:{}};await Y(s,c),G(),setTimeout(()=>{p==null||p.showSuccess({title:`${s.name} connected`})},100)},m).catch(()=>{})},J=async t=>{m(null),await H(async()=>{u?await n.updateConnector({id:u.id,...t}):await n.createConnector({...t})},m),setTimeout(()=>{p==null||p.showSuccess({title:`${t.name} ${u?"updated":"added"}`})},0)},re=t=>{H(async()=>{await n.disconnectConnector({id:t.id}),E(null)}).catch(()=>{})},ne=t=>{E(s=>(s==null?void 0:s.id)===t.id?t:s),v(s=>{const c=new Map(s.authStatusById);return c.set(t.id,t.authenticated),{ordered:s.ordered.map(M=>M.isConfigured&&M.connector.id===t.id?{connector:t,isConfigured:!0}:M),authStatusById:c}})},le=(t,s)=>{const c=O[t.name],M=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:c?e.jsx(X,{src:c,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:D("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:D("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]});return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0 cursor-pointer transition-colors hover:bg-ghost-button-hover/60",onClick:()=>{E(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:M}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z.Secondary,{size:"small",type:"button",disabled:o,onClick:x=>{x.stopPropagation(),m(null),d(t),S(!0)},children:[e.jsx(w,{name:"pencil",className:"size-3"}),"Edit"]}),e.jsx(w,{name:"chevron-right",className:"size-4"})]})]},t.id)},ie=t=>{const s=O[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(X,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:U[t.auth.type]??U.none}),e.jsx(z.Secondary,{size:"small",type:"button",disabled:o,onClick:()=>{se(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)};if(I)return e.jsxs(e.Fragment,{children:[e.jsx(be,{connector:I,busy:o,onBack:()=>{E(null)},onConnectorRefreshed:ne,onEdit:()=>{m(null),d(I),S(!0)},onDisconnect:()=>{re(I)}}),e.jsx(Z,{open:A,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:J,connector:u??void 0,busy:o,error:N})]});const de=R.length>0||$.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),j?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:j}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(me,{query:h,setQuery:r,placeholder:"Search connectors"})}),e.jsxs(z.Secondary,{type:"button",onClick:()=>{m(null),d(null),S(!0)},children:[e.jsx(w,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[b?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!b&&R.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>le(t))})]}):null,!b&&$.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",$.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:$.map(t=>ie(t))})]}):null,!b&&!de?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h.trim()?`No connectors match “${h.trim()}”.`:"No connectors yet."}):null]}),e.jsx(te,{open:i!==null,onOpenChange:t=>{t||G()},title:`Connect ${(i==null?void 0:i.name)??"connector"}`,description:i==null?void 0:i.url,contentSized:!0,className:"md:max-w-xl",children:e.jsxs("form",{onSubmit:ae,children:[e.jsxs("div",{className:"space-y-5 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6 text-text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-text-primary",children:i==null?void 0:i.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:i==null?void 0:i.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"connector-api-key",className:"mb-2 block text-xs font-semibold uppercase tracking-wide text-text-secondary",children:"API key / token"}),e.jsx("input",{id:"connector-api-key",type:"password",value:P,onChange:t=>{l(t.target.value)},placeholder:`Paste the token from ${(i==null?void 0:i.name)??"the provider"}`,autoFocus:!0,required:!0,className:K("h-11")})]}),N?e.jsx("p",{className:"text-failure-bg text-sm",children:N}):null]}),e.jsxs("footer",{className:"flex justify-end gap-2 border-t border-border px-5 py-4",children:[e.jsx(z.Ghost,{type:"button",onClick:G,disabled:o,children:"Cancel"}),e.jsx(z.Primary,{type:"submit",disabled:!P.trim()||o,children:"Connect"})]})]})}),e.jsx(Z,{open:A,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:J,connector:u??void 0,busy:o,error:N})]})})]})},je=ge;export{je as default};
1
+ import{aF as ee,D as ce,r as a,aG as _,j as e,J as me,L as z,I as w,aI as te,ab as U,aM as ue,e as T,aH as X}from"./index-DZOZ1xN3.js";var xe=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],J=U("h-11 shadow-sm"),B=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),he=({open:n,onOpenChange:p,onSubmit:h,connector:r,busy:f=!1,error:v})=>{const[b,y]=a.useState(""),[j,g]=a.useState(""),[N,m]=a.useState(""),[o,k]=a.useState("dcr"),[C,M]=a.useState(""),[A,S]=a.useState(""),u=r!==void 0,d=U(`h-11 shadow-sm ${u?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{y(""),g(""),m(""),k("dcr"),M(""),S("")};a.useEffect(()=>{n&&(y((r==null?void 0:r.name)??""),g((r==null?void 0:r.url)??""),m((r==null?void 0:r.description)??""),k((r==null?void 0:r.auth.type)??"dcr"),M(""),S((r==null?void 0:r.auth.type)==="header"?r.auth.headerName??"":""))},[r,n]);const D=l=>{l||i(),p(l)},I=!!C.trim()||(r==null?void 0:r.auth.type)==="header",F=!!b.trim()&&!!N.trim()&&!!j.trim()&&(o!=="header"||I),P=async l=>{if(l.preventDefault(),!F||f)return;const O=o==="header"?{type:"header",apiKey:C.trim(),...A.trim()?{headerName:A.trim()}:{}}:{type:o};try{await h({name:b.trim(),url:j.trim(),description:N.trim(),auth:O}),i(),p(!1)}catch{}};return e.jsx(te,{open:n,onOpenChange:D,title:u?"Edit MCP server":"Add MCP server",description:u?"Update how this connector authenticates.":"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void P(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:b,readOnly:u,"aria-disabled":u,onChange:l=>{y(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!u,className:d})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(B,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:N,onChange:l=>{m(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:U("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:j,onChange:l=>{g(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:J})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(B,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:xe.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${o===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:o===l.value,onChange:()=>{k(l.value)},className:"sr-only"}),l.label]},l.value))})]}),o==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(w,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,o==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",(r==null?void 0:r.auth.type)==="header"?e.jsx("span",{className:"font-normal text-text-secondary",children:" (leave blank to keep current)"}):e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:(r==null?void 0:r.auth.type)!=="header",value:C,onChange:l=>{M(l.target.value)},placeholder:"Paste the server token",className:J})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:A,onChange:l=>{S(l.target.value)},placeholder:"Authorization",className:J})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[v?e.jsx("p",{className:"text-failure-bg text-sm",children:v}):null,e.jsx(z.Primary,{type:"submit",size:"large",disabled:!F||f,className:"w-full shrink-0",children:u?"Save":"Add"})]})]})})},Z=he,K={dcr:"OAuth2",header:"API Key",none:"No Auth"};function pe({text:n}){const p=a.useRef(null),[h,r]=a.useState(!1),[f,v]=a.useState(!1),[b,y]=a.useState(16);return a.useLayoutEffect(()=>{r(!1),y(16)},[n]),a.useLayoutEffect(()=>{const j=p.current;if(!j)return;if(!h){y(16),v(j.scrollWidth>j.clientWidth+1);return}y(16);const g=requestAnimationFrame(()=>{y(j.scrollHeight)});return()=>cancelAnimationFrame(g)},[n,h]),n?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:p,style:{maxHeight:b},className:T("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!h&&"whitespace-nowrap",!h&&f&&"pr-[5.75rem]"),children:[n,h&&f?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>r(!1),children:"Show less"})]}):null]}),!h&&f?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>r(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var fe=({connector:n,onBack:p,onConnectorRefreshed:h,onEdit:r,onDisconnect:f,busy:v=!1})=>{const{connectorCatalog:b}=ee(),{handleAuthorize:y,isOAuthLoading:j}=ue(),[g,N]=a.useState([]),[m,o]=a.useState(!0),[k,C]=a.useState(null),[M,A]=a.useState(!1);a.useEffect(()=>{let d=!1;return N([]),C(null),o(!0),b.getToolsByConnectorId({id:n.id}).then(i=>{d||N(i)}).catch(i=>{d||C(_(i,"Failed to load connector tools"))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[n.authenticated,n.id,b]);const S=async()=>{A(!0),C(null);try{const d=await b.getConnector({id:n.id});h(d)}catch(d){C(_(d,"Failed to refresh connector details"))}finally{A(!1)}},u=j||M;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:p,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(w,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:n.name}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:K[n.auth.type]??K.none}),e.jsxs("span",{className:T("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",n.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:T("h-1.5 w-1.5 rounded-full",n.authenticated?"bg-success-bg":"bg-primary-button-bg")}),n.authenticated?"Connected":"Not authenticated"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:e.jsx("span",{className:"text-text-secondary",children:n.description})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z.Secondary,{size:"small",type:"button",disabled:v,onClick:r,children:[e.jsx(w,{name:"pencil",className:"size-3"}),"Edit"]}),n.auth.type==="dcr"&&!n.authenticated?e.jsx(z.Secondary,{size:"small",type:"button",disabled:v||u,onClick:()=>{y(n.id,d=>{d&&S()})},children:u?"Connecting…":"Connect"}):n.auth.type==="dcr"&&!n.requiresAuth?e.jsx(z.Secondary,{size:"small",type:"button",disabled:v,onClick:f,children:"Disconnect"}):null]})]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:m?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):k?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[k,n.auth.type==="dcr"&&!n.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):g.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",g.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:g.map(d=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:d.name}),e.jsx(pe,{text:d.description})]})},d.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},be=fe,ge=()=>{const{connectorCatalog:n}=ee(),p=ce(),[h,r]=a.useState(""),[f,v]=a.useState({ordered:[],authStatusById:new Map}),[b,y]=a.useState(!0),[j,g]=a.useState(null),[N,m]=a.useState(null),[o,k]=a.useState(!1),[C,M]=a.useState([]),[A,S]=a.useState(!1),[u,d]=a.useState(null),[i,D]=a.useState(null),[I,F]=a.useState(null),[P,l]=a.useState(""),O=a.useMemo(()=>(C??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[C]),Q=a.useCallback(async()=>{y(!0),g(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);M(s);const c=t??[],E=new Set(c.map(x=>x.id)),W=[...c.map(x=>({connector:x,isConfigured:!0})),...s.filter(x=>!E.has(x.id)).map(x=>({connector:x,isConfigured:!1}))];v({ordered:W,authStatusById:new Map(W.map(x=>[x.connector.id,x.isConfigured?x.connector.authenticated:!1]))}),F(x=>x?t.find(oe=>oe.id===x.id)??null:null)}catch(t){g(_(t,"Failed to load connectors"))}finally{y(!1)}},[n]);a.useEffect(()=>{Q()},[Q]);const L=h.trim().toLowerCase(),q=a.useMemo(()=>L?f.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(L)||(((s=t.description)==null?void 0:s.toLowerCase().includes(L))??!1)||t.url.toLowerCase().includes(L)}):f.ordered,[f.ordered,L]),R=a.useMemo(()=>{const t=[];for(const s of q)if(s.isConfigured){const c=f.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(c===s.connector.authenticated?s.connector:{...s.connector,authenticated:c})}return t},[f.authStatusById,q]),$=a.useMemo(()=>{const t=[];for(const s of q)s.isConfigured||t.push(s.connector);return t},[q]),H=async(t,s=g)=>{k(!0),g(null);try{await t(),await Q()}catch(c){throw s(_(c,"Request failed")),c}finally{k(!1)}},G=()=>{D(null),l(""),m(null)},V=async(t,s)=>{const c=s??(t.auth.type==="header"?{type:"header",...t.auth.headerName?{headerName:t.auth.headerName}:{}}:t.auth.type==="dcr"?{type:"dcr"}:{type:"none"});await n.createConnector({name:t.name,description:t.description??t.url,url:t.url,auth:c})},se=t=>{if(t.auth.type==="header"){l(""),m(null),D(t);return}H(async()=>{await V(t)}).catch(()=>{})},ae=t=>{if(t.preventDefault(),!i||!P.trim())return;const s=i;m(null),H(async()=>{const c={type:"header",apiKey:P.trim(),...s.auth.type==="header"&&s.auth.headerName?{headerName:s.auth.headerName}:{}};await V(s,c),G(),setTimeout(()=>{p==null||p.showSuccess({title:`${s.name} connected`})},100)},m).catch(()=>{})},Y=async t=>{m(null),await H(async()=>{u?await n.updateConnector({id:u.id,...t}):await n.createConnector({...t})},m),setTimeout(()=>{p==null||p.showSuccess({title:`${t.name} ${u?"updated":"added"}`})},0)},re=t=>{H(async()=>{await n.disconnectConnector({id:t.id}),F(null)}).catch(()=>{})},ne=t=>{F(s=>(s==null?void 0:s.id)===t.id?t:s),v(s=>{const c=new Map(s.authStatusById);return c.set(t.id,t.authenticated),{ordered:s.ordered.map(E=>E.isConfigured&&E.connector.id===t.id?{connector:t,isConfigured:!0}:E),authStatusById:c}})},le=(t,s)=>{const c=O[t.name],E=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:c?e.jsx(X,{src:c,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:T("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:T("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]});return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0 cursor-pointer transition-colors hover:bg-ghost-button-hover/60",onClick:()=>{F(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:E}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z.Secondary,{size:"small",type:"button",disabled:o,onClick:x=>{x.stopPropagation(),m(null),d(t),S(!0)},children:[e.jsx(w,{name:"pencil",className:"size-3"}),"Edit"]}),e.jsx(w,{name:"chevron-right",className:"size-4"})]})]},t.id)},ie=t=>{const s=O[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(X,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:K[t.auth.type]??K.none}),e.jsx(z.Secondary,{size:"small",type:"button",disabled:o,onClick:()=>{se(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)};if(I)return e.jsxs(e.Fragment,{children:[e.jsx(be,{connector:I,busy:o,onBack:()=>{F(null)},onConnectorRefreshed:ne,onEdit:()=>{m(null),d(I),S(!0)},onDisconnect:()=>{re(I)}}),e.jsx(Z,{open:A,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Y,connector:u??void 0,busy:o,error:N})]});const de=R.length>0||$.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),j?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:j}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(me,{query:h,setQuery:r,placeholder:"Search connectors"})}),e.jsxs(z.Secondary,{type:"button",onClick:()=>{m(null),d(null),S(!0)},children:[e.jsx(w,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[b?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!b&&R.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>le(t))})]}):null,!b&&$.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",$.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:$.map(t=>ie(t))})]}):null,!b&&!de?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h.trim()?`No connectors match “${h.trim()}”.`:"No connectors yet."}):null]}),e.jsx(te,{open:i!==null,onOpenChange:t=>{t||G()},title:`Connect ${(i==null?void 0:i.name)??"connector"}`,description:i==null?void 0:i.url,contentSized:!0,className:"md:max-w-xl",children:e.jsxs("form",{onSubmit:ae,children:[e.jsxs("div",{className:"space-y-5 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6 text-text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-text-primary",children:i==null?void 0:i.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:i==null?void 0:i.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"connector-api-key",className:"mb-2 block text-xs font-semibold uppercase tracking-wide text-text-secondary",children:"API key / token"}),e.jsx("input",{id:"connector-api-key",type:"password",value:P,onChange:t=>{l(t.target.value)},placeholder:`Paste the token from ${(i==null?void 0:i.name)??"the provider"}`,autoFocus:!0,required:!0,className:U("h-11")})]}),N?e.jsx("p",{className:"text-failure-bg text-sm",children:N}):null]}),e.jsxs("footer",{className:"flex justify-end gap-2 border-t border-border px-5 py-4",children:[e.jsx(z.Ghost,{type:"button",onClick:G,disabled:o,children:"Cancel"}),e.jsx(z.Primary,{type:"submit",disabled:!P.trim()||o,children:"Connect"})]})]})}),e.jsx(Z,{open:A,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Y,connector:u??void 0,busy:o,error:N})]})})]})},je=ge;export{je as default};
@@ -1 +1 @@
1
- import{S as a}from"./chunk-GIPFF6FZ-DPTdcXQj.js";import{j as o,C as t,e as l}from"./index-XpZpj5Rl.js";import"./chunk-LUG7E6BL-QKvrInc2.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
1
+ import{S as a}from"./chunk-VXKNS7FH-Dm2ZAGlE.js";import{j as o,C as t,e as l}from"./index-DZOZ1xN3.js";import"./chunk-TGKQRK3S-D5Bs7icZ.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-GISAH2WU-2fVa9yeg.js","./index-XpZpj5Rl.js","./index-BBGLYdJn.css","./SchedulesPage-TMOTK6DR-D9JlkZFv.js"])))=>i.map(i=>d[i]);
2
- import{u as E,a as P,b as I,c as t,r as a,s as L,j as s,P as z,I as l,d as c,S as g,e as B,_ as p}from"./index-XpZpj5Rl.js";import{A as k,S as D,N as T,T as R}from"./chunk-LUG7E6BL-QKvrInc2.js";var F=a.lazy(()=>p(()=>import("./SettingsBuilder-GISAH2WU-2fVa9yeg.js"),__vite__mapDeps([0,1,2]),import.meta.url)),M=a.lazy(()=>p(()=>import("./SchedulesPage-TMOTK6DR-D9JlkZFv.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(i=>({default:i.SchedulesPage})));function V({className:i}){const f=E(),e=P(),d=I(),b=t("ClearChatButton"),j=t("AgentDetailsPage"),y=t("AgentsLibrary"),A=t("SessionsPage"),w=t("SaveAgentButton"),N=t("SelectAgentEmptyState"),v=t("UserAvatar"),S=a.useRef(null),C=(e==null?void 0:e.mode.status)==="idle",u=(e==null?void 0:e.settingsOpen)===!0,n=(e==null?void 0:e.libraryOpen)===!0,m=(e==null?void 0:e.sessionsOpen)===!0,o=(e==null?void 0:e.schedulesOpen)===!0,r=u||n||m||o,h=e!=null&&L(e.mode)&&!r&&(!d||e.agentConfigOpen),x=(e==null?void 0:e.isNewChatEnabled)!==!1,O=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(f.threads().switchToNewThread()).catch(()=>{})},_=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("div",{className:B("relative flex h-full min-h-0 w-full bg-primary-bg",i),children:[h?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:s.jsx(k,{showClose:d})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(z,{className:"bg-topbar-bg",title:r?n||o?s.jsxs("button",{type:"button",className:c({variant:"ghost",size:"small"}),onClick:()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1)},children:[s.jsx(l,{name:"arrow-left"}),"Back to chat"]}):null:s.jsx(T,{}),end:s.jsxs(s.Fragment,{children:[r?null:s.jsxs(s.Fragment,{children:[s.jsx(b,{}),s.jsx(w,{})]}),s.jsx(D,{},"shell-actions"),s.jsx(v,{}),r?null:s.jsxs(s.Fragment,{children:[x?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:c({variant:"ghost",size:"icon"}),onClick:O,children:s.jsx(l,{name:"square-pen"})}):null,x&&(e!=null&&e.isComposerEnabled)?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:c({variant:"ghost",size:"icon"}),onClick:_,children:s.jsx(l,{name:"agent-2"})}):null]})]})}),s.jsx("div",{ref:S,className:"min-h-0 min-w-0 flex-1",children:u?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(F,{})}):m?s.jsx(A,{}):n&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(j,{agentId:e.libraryAgentId},e.libraryAgentId):n?s.jsx(y,{}):o?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(M,{})}):C?s.jsx(N,{}):s.jsx(R,{})})]})]})}export{V as DrawerLayout};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-A4BPYIFZ-B4p1JpXq.js","./index-DZOZ1xN3.js","./index-BBGLYdJn.css","./SchedulesPage-ARWU7BZF-BIZcHayD.js"])))=>i.map(i=>d[i]);
2
+ import{u as E,a as P,b as I,c as t,r as a,s as L,j as s,P as z,I as l,d as c,S as g,e as B,_ as p}from"./index-DZOZ1xN3.js";import{A as k,S as D,N as T,T as R}from"./chunk-TGKQRK3S-D5Bs7icZ.js";var F=a.lazy(()=>p(()=>import("./SettingsBuilder-A4BPYIFZ-B4p1JpXq.js"),__vite__mapDeps([0,1,2]),import.meta.url)),M=a.lazy(()=>p(()=>import("./SchedulesPage-ARWU7BZF-BIZcHayD.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(i=>({default:i.SchedulesPage})));function V({className:i}){const f=E(),e=P(),d=I(),b=t("ClearChatButton"),j=t("AgentDetailsPage"),y=t("AgentsLibrary"),A=t("SessionsPage"),w=t("SaveAgentButton"),N=t("SelectAgentEmptyState"),v=t("UserAvatar"),S=a.useRef(null),C=(e==null?void 0:e.mode.status)==="idle",u=(e==null?void 0:e.settingsOpen)===!0,n=(e==null?void 0:e.libraryOpen)===!0,m=(e==null?void 0:e.sessionsOpen)===!0,o=(e==null?void 0:e.schedulesOpen)===!0,r=u||n||m||o,h=e!=null&&L(e.mode)&&!r&&(!d||e.agentConfigOpen),x=(e==null?void 0:e.isNewChatEnabled)!==!1,O=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(f.threads().switchToNewThread()).catch(()=>{})},_=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("div",{className:B("relative flex h-full min-h-0 w-full bg-primary-bg",i),children:[h?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:s.jsx(k,{showClose:d})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(z,{className:"bg-topbar-bg",title:r?n||o?s.jsxs("button",{type:"button",className:c({variant:"ghost",size:"small"}),onClick:()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1)},children:[s.jsx(l,{name:"arrow-left"}),"Back to chat"]}):null:s.jsx(T,{}),end:s.jsxs(s.Fragment,{children:[r?null:s.jsxs(s.Fragment,{children:[s.jsx(b,{}),s.jsx(w,{})]}),s.jsx(D,{},"shell-actions"),s.jsx(v,{}),r?null:s.jsxs(s.Fragment,{children:[x?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:c({variant:"ghost",size:"icon"}),onClick:O,children:s.jsx(l,{name:"square-pen"})}):null,x&&(e!=null&&e.isComposerEnabled)?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:c({variant:"ghost",size:"icon"}),onClick:_,children:s.jsx(l,{name:"agent-2"})}):null]})]})}),s.jsx("div",{ref:S,className:"min-h-0 min-w-0 flex-1",children:u?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(F,{})}):m?s.jsx(A,{}):n&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(j,{agentId:e.libraryAgentId},e.libraryAgentId):n?s.jsx(y,{}):o?s.jsx(a.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(g,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(M,{})}):C?s.jsx(N,{}):s.jsx(R,{})})]})]})}export{V as DrawerLayout};
@@ -1 +1 @@
1
- import{aD as be,D as fe,r as l,aE as Y,j as e,H as ge,K as B,I as L,aF as ie,aG as xe,aH as ye,aI as ve,e as P,aJ as je,a9 as Ne}from"./index-XpZpj5Rl.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:o,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[M,I]=l.useState(""),[y,x]=l.useState(""),[w,$]=l.useState(!1),U=()=>{I(""),x(""),$(!1)};l.useEffect(()=>{n&&(I(""),x(E),$(!1))},[n,E]);const Q=i=>{i||U(),o(i)},T=M.trim(),X=!c||!!T,v=async i=>{if(i.preventDefault(),!(!X||O))try{await b({apiKey:T,baseUrl:y.trim()}),U(),o(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:Q,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{I(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>$(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(L,{name:"chevron-down",className:P("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!X||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(o=>{var b,k,p,E,d;return{id:o.id,name:o.name,advancedExpanded:!0,reasoningEfforts:(b=o.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=o.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=o.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],G="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const o=n.trim();if(o==="")return null;const b=Number(o);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:o,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=l.useState((c==null?void 0:c.name)??""),[F,M]=l.useState((c==null?void 0:c.baseUrl)??""),[I,y]=l.useState(""),[x,w]=l.useState(()=>ue(c)),[$,U]=l.useState(!1),[Q,T]=l.useState(!1),X=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),T(!1)},v=s=>{s||X(),o(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),T(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const J=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,W=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,le=!D&&!h&&x.every(s=>!J(s)&&!te(s)),se=$&&D,H=Q&&h,A=async()=>{if(K(),!le||p)return;const s=x.findIndex(r=>q(r)||W(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:I.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:P(G,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:P(G,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:I,onChange:s=>y(s.target.value),placeholder:"sk-…",className:G}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=J(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,oe=q(s),C=W(s),z=s.contextTouched&&oe,ae=s.maxTouched&&C;return e.jsxs("div",{className:P("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:P(G,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:P(G,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(L,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(L,{name:"chevron-down",className:P("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:P(G,z&&V)}),z?e.jsx(ee,{children:oe}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:P(G,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:P("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var Z;return i(r,{reasoningEfforts:a?(Z=s.reasoningEfforts)==null?void 0:Z.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(L,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!le||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Pe=()=>{const{modelCatalog:n}=be(),o=fe(),[b,k]=l.useState(""),[p,E]=l.useState([]),[d,c]=l.useState([]),[S,O]=l.useState(!0),[F,M]=l.useState(null),[I,y]=l.useState(null),[x,w]=l.useState(!1),[$,U]=l.useState(null),[Q,T]=l.useState(null),[X,v]=l.useState(null),[i,K]=l.useState(!1),[f,D]=l.useState(null),_=l.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),J=l.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);l.useEffect(()=>{J()},[J]);const te=l.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=l.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),W=l.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),le=l.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=l.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),T(null),v(null)},A=async(t,a)=>{w(!0),M(null);try{await t(),await J(),H()}catch(m){throw a?a(m):o==null?M(Y(m,"Request failed")):o.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await A(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),o==null||o.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&A(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await A(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await A(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},oe=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=$!=null?p.find(t=>t.id===$)??null:null,z=Q!=null?d.find(t=>t.type===Q)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(L,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),Z=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),T(null),U(t.id))},children:[e.jsx(L,{name:"pencil",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(L,{name:"trash",className:"size-3.5"})})]},N.id)),Z.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",Z.length]}),Z.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&W.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:W.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:x,onClick:()=>{v(null),U(null),T(t.type)},children:[e.jsx(L,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&W.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Te(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:X}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:oe,onSubmit:f?R:j,reasoningEffortOptions:le,busy:x,error:I},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Pe;export{ze as default};
1
+ import{aF as be,D as fe,r as l,aG as Y,j as e,J as ge,L as B,I as P,aH as ie,aI as xe,aJ as ye,aK as ve,e as T,aL as je,ab as Ne}from"./index-DZOZ1xN3.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:o,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[M,I]=l.useState(""),[y,x]=l.useState(""),[w,$]=l.useState(!1),U=()=>{I(""),x(""),$(!1)};l.useEffect(()=>{n&&(I(""),x(E),$(!1))},[n,E]);const J=i=>{i||U(),o(i)},L=M.trim(),Q=!c||!!L,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:L,baseUrl:y.trim()}),U(),o(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:J,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{I(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>$(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(P,{name:"chevron-down",className:T("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!Q||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(o=>{var b,k,p,E,d;return{id:o.id,name:o.name,advancedExpanded:!0,reasoningEfforts:(b=o.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=o.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=o.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],G="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const o=n.trim();if(o==="")return null;const b=Number(o);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:o,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=l.useState((c==null?void 0:c.name)??""),[F,M]=l.useState((c==null?void 0:c.baseUrl)??""),[I,y]=l.useState(""),[x,w]=l.useState(()=>ue(c)),[$,U]=l.useState(!1),[J,L]=l.useState(!1),Q=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),L(!1)},v=s=>{s||Q(),o(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),L(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const X=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,W=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,le=!D&&!h&&x.every(s=>!X(s)&&!te(s)),se=$&&D,H=J&&h,A=async()=>{if(K(),!le||p)return;const s=x.findIndex(r=>q(r)||W(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:I.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:T(G,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>L(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:T(G,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:I,onChange:s=>y(s.target.value),placeholder:"sk-…",className:G}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=X(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,oe=q(s),C=W(s),z=s.contextTouched&&oe,ae=s.maxTouched&&C;return e.jsxs("div",{className:T("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:T(G,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:T(G,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(P,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(P,{name:"chevron-down",className:T("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:T(G,z&&V)}),z?e.jsx(ee,{children:oe}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:T(G,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:T("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var Z;return i(r,{reasoningEfforts:a?(Z=s.reasoningEfforts)==null?void 0:Z.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(P,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!le||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Le(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Te=()=>{const{modelCatalog:n}=be(),o=fe(),[b,k]=l.useState(""),[p,E]=l.useState([]),[d,c]=l.useState([]),[S,O]=l.useState(!0),[F,M]=l.useState(null),[I,y]=l.useState(null),[x,w]=l.useState(!1),[$,U]=l.useState(null),[J,L]=l.useState(null),[Q,v]=l.useState(null),[i,K]=l.useState(!1),[f,D]=l.useState(null),_=l.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),X=l.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);l.useEffect(()=>{X()},[X]);const te=l.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=l.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),W=l.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),le=l.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=l.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),L(null),v(null)},A=async(t,a)=>{w(!0),M(null);try{await t(),await X(),H()}catch(m){throw a?a(m):o==null?M(Y(m,"Request failed")):o.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await A(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),o==null||o.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&A(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await A(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await A(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},oe=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=$!=null?p.find(t=>t.id===$)??null:null,z=J!=null?d.find(t=>t.type===J)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(P,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),Z=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),L(null),U(t.id))},children:[e.jsx(P,{name:"pencil",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(P,{name:"trash",className:"size-3.5"})})]},N.id)),Z.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",Z.length]}),Z.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&W.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:W.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:x,onClick:()=>{v(null),U(null),L(t.type)},children:[e.jsx(P,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&W.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Le(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:Q}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:oe,onSubmit:f?R:j,reasoningEffortOptions:le,busy:x,error:I},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Te;export{ze as default};