@truefoundry/trueforge 0.3.0-rc.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-BPC6TD7K-B1T1mqKJ.js → AgentCodeSnippets-JR3K2V5D-Cqyz2skH.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-JR3K2V5D-Cqyz2skH.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-JR3K2V5D-Cqyz2skH.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-T6DZZ37Y-BikFOApC.js → AgentMetricChart-7YNFN467-CI1kbCGF.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-7YNFN467-CI1kbCGF.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-7YNFN467-CI1kbCGF.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-BFU7EO4Y-B_AVURNj.js → AgentOverview-M43ZHZXR-CpdMIV0Y.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-M43ZHZXR-CpdMIV0Y.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-M43ZHZXR-CpdMIV0Y.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-ATVBTYDF-CQqNlw83.js → AgentSessionEventTimeline-6KPF7GAB-CUz-8u0T.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-6KPF7GAB-CUz-8u0T.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-6KPF7GAB-CUz-8u0T.js.gz +0 -0
  13. package/dist/_frontend/assets/AgentSessionEventTimelineChart-TX6JSA7I-U5tqELpZ.js +1 -0
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-TX6JSA7I-U5tqELpZ.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-TX6JSA7I-U5tqELpZ.js.gz +0 -0
  16. package/dist/_frontend/assets/AgentSessions-72DUGY4X-Czs9VTVd.js +1 -0
  17. package/dist/_frontend/assets/AgentSessions-72DUGY4X-Czs9VTVd.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-72DUGY4X-Czs9VTVd.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-FYNF6J3F-COur0yqS.js → ConnectorSettings-OYKNP6QY-QykZynci.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-OYKNP6QY-QykZynci.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-OYKNP6QY-QykZynci.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-SGUOMZ5E-CEDMk1ae.js → DockLayout-CDGNHPRZ-BC52lbPZ.js} +1 -1
  23. package/dist/_frontend/assets/DrawerLayout-DDFZOELS-DEL0H12V.js +2 -0
  24. package/dist/_frontend/assets/DrawerLayout-DDFZOELS-DEL0H12V.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-DDFZOELS-DEL0H12V.js.gz +0 -0
  26. package/dist/_frontend/assets/{ModelSettings-6EW7U2MP-DbtZxzUW.js → ModelSettings-ZL5ITPNM-Bw5-gYWk.js} +1 -1
  27. package/dist/_frontend/assets/ModelSettings-ZL5ITPNM-Bw5-gYWk.js.br +0 -0
  28. package/dist/_frontend/assets/ModelSettings-ZL5ITPNM-Bw5-gYWk.js.gz +0 -0
  29. package/dist/_frontend/assets/SandboxSettings-6JWRHKBS-D7-28FdA.js +1 -0
  30. package/dist/_frontend/assets/SandboxSettings-6JWRHKBS-D7-28FdA.js.br +0 -0
  31. package/dist/_frontend/assets/SandboxSettings-6JWRHKBS-D7-28FdA.js.gz +0 -0
  32. package/dist/_frontend/assets/SchedulesPage-SIJSKRWV-ZmB5E6Lh.js +1 -0
  33. package/dist/_frontend/assets/SchedulesPage-SIJSKRWV-ZmB5E6Lh.js.br +0 -0
  34. package/dist/_frontend/assets/SchedulesPage-SIJSKRWV-ZmB5E6Lh.js.gz +0 -0
  35. package/dist/_frontend/assets/{SettingsBuilder-FODMI7HG-CyRho5Uc.js → SettingsBuilder-RGEYBYPN-B0-R3y76.js} +2 -2
  36. package/dist/_frontend/assets/SettingsBuilder-RGEYBYPN-B0-R3y76.js.br +0 -0
  37. package/dist/_frontend/assets/SettingsBuilder-RGEYBYPN-B0-R3y76.js.gz +0 -0
  38. package/dist/_frontend/assets/ShellRouteSync-VUEPO6BA-Da6U5Fkz.js +1 -0
  39. package/dist/_frontend/assets/ShellRouteSync-VUEPO6BA-Da6U5Fkz.js.br +0 -0
  40. package/dist/_frontend/assets/ShellRouteSync-VUEPO6BA-Da6U5Fkz.js.gz +0 -0
  41. package/dist/_frontend/assets/{SidebarLayout-ZLWG2YGO-iNuRGXgp.js → SidebarLayout-CG2YXXJS-DL_v6euj.js} +2 -2
  42. package/dist/_frontend/assets/SidebarLayout-CG2YXXJS-DL_v6euj.js.br +0 -0
  43. package/dist/_frontend/assets/SidebarLayout-CG2YXXJS-DL_v6euj.js.gz +0 -0
  44. package/dist/_frontend/assets/{SkillSettings-AFSAOU6O-EcWn2HFB.js → SkillSettings-2Q3S365A-C8FPvsE4.js} +1 -1
  45. package/dist/_frontend/assets/SkillSettings-2Q3S365A-C8FPvsE4.js.br +0 -0
  46. package/dist/_frontend/assets/SkillSettings-2Q3S365A-C8FPvsE4.js.gz +0 -0
  47. package/dist/_frontend/assets/TrueForgeUIWithRouter-BQ7V7K6N-Go8y3qBj.js +1 -0
  48. package/dist/_frontend/assets/{WebSearchSettings-BW4CWGRR-Cs-t9iMH.js → WebSearchSettings-IT5FIYZ4-D-lKhkE9.js} +1 -1
  49. package/dist/_frontend/assets/WebSearchSettings-IT5FIYZ4-D-lKhkE9.js.br +0 -0
  50. package/dist/_frontend/assets/WebSearchSettings-IT5FIYZ4-D-lKhkE9.js.gz +0 -0
  51. package/dist/_frontend/assets/WidgetLayout-MLAXXZHR-sCzOfmkw.js +1 -0
  52. package/dist/_frontend/assets/WidgetLayout-MLAXXZHR-sCzOfmkw.js.br +0 -0
  53. package/dist/_frontend/assets/WidgetLayout-MLAXXZHR-sCzOfmkw.js.gz +0 -0
  54. package/dist/_frontend/assets/{chunk-62JRHF6Z-DWQVXP0g.js → chunk-62JRHF6Z-Cbscd_Zf.js} +1 -1
  55. package/dist/_frontend/assets/chunk-62JRHF6Z-Cbscd_Zf.js.br +0 -0
  56. package/dist/_frontend/assets/chunk-62JRHF6Z-Cbscd_Zf.js.gz +0 -0
  57. package/dist/_frontend/assets/chunk-BZ2EOR5X-BgN-bqzz.js +1 -0
  58. package/dist/_frontend/assets/chunk-FYQP67GV-BjaXnOYn.js +2 -0
  59. package/dist/_frontend/assets/chunk-FYQP67GV-BjaXnOYn.js.br +0 -0
  60. package/dist/_frontend/assets/chunk-FYQP67GV-BjaXnOYn.js.gz +0 -0
  61. package/dist/_frontend/assets/{chunk-TFQWCBFQ-CObdB7gd.js → chunk-WOPPIMOW-r3_Xqwsn.js} +1 -1
  62. package/dist/_frontend/assets/chunk-WOPPIMOW-r3_Xqwsn.js.br +0 -0
  63. package/dist/_frontend/assets/chunk-WOPPIMOW-r3_Xqwsn.js.gz +0 -0
  64. package/dist/_frontend/assets/{cssMode-BLgfUUIP.js → cssMode-Ds2Ditv6.js} +1 -1
  65. package/dist/_frontend/assets/cssMode-Ds2Ditv6.js.br +0 -0
  66. package/dist/_frontend/assets/cssMode-Ds2Ditv6.js.gz +0 -0
  67. package/dist/_frontend/assets/{freemarker2-D9Zhxhbo.js → freemarker2-Puiju1uU.js} +1 -1
  68. package/dist/_frontend/assets/freemarker2-Puiju1uU.js.br +0 -0
  69. package/dist/_frontend/assets/freemarker2-Puiju1uU.js.gz +0 -0
  70. package/dist/_frontend/assets/{handlebars-Cr-mYRIr.js → handlebars-DjKVrgaO.js} +1 -1
  71. package/dist/_frontend/assets/handlebars-DjKVrgaO.js.br +0 -0
  72. package/dist/_frontend/assets/handlebars-DjKVrgaO.js.gz +0 -0
  73. package/dist/_frontend/assets/{html-BSXsByU9.js → html-Dc3FuqUU.js} +1 -1
  74. package/dist/_frontend/assets/html-Dc3FuqUU.js.br +0 -0
  75. package/dist/_frontend/assets/html-Dc3FuqUU.js.gz +0 -0
  76. package/dist/_frontend/assets/{htmlMode-Dl_li53P.js → htmlMode-C62S3mtw.js} +1 -1
  77. package/dist/_frontend/assets/htmlMode-C62S3mtw.js.br +0 -0
  78. package/dist/_frontend/assets/htmlMode-C62S3mtw.js.gz +0 -0
  79. package/dist/_frontend/assets/{index-DbkdD8rw.js → index-Bp-ZdtF_.js} +3 -3
  80. package/dist/_frontend/assets/index-Bp-ZdtF_.js.br +0 -0
  81. package/dist/_frontend/assets/index-Bp-ZdtF_.js.gz +0 -0
  82. package/dist/_frontend/assets/{index-Dwv00glI.js → index-DL_GegUd.js} +1 -1
  83. package/dist/_frontend/assets/index-DL_GegUd.js.br +0 -0
  84. package/dist/_frontend/assets/index-DL_GegUd.js.gz +0 -0
  85. package/dist/_frontend/assets/{index-CPHXhr9t.js → index-eDNLQ9X2.js} +270 -255
  86. package/dist/_frontend/assets/index-eDNLQ9X2.js.br +0 -0
  87. package/dist/_frontend/assets/index-eDNLQ9X2.js.gz +0 -0
  88. package/dist/_frontend/assets/{javascript-qaGDMU9N.js → javascript-DO0Nr-vv.js} +1 -1
  89. package/dist/_frontend/assets/{jsonMode-BINBtD9i.js → jsonMode-DIcRVlzg.js} +1 -1
  90. package/dist/_frontend/assets/jsonMode-DIcRVlzg.js.br +0 -0
  91. package/dist/_frontend/assets/jsonMode-DIcRVlzg.js.gz +0 -0
  92. package/dist/_frontend/assets/{liquid-DSnOJ-2h.js → liquid-C1cJR-D-.js} +1 -1
  93. package/dist/_frontend/assets/liquid-C1cJR-D-.js.br +0 -0
  94. package/dist/_frontend/assets/liquid-C1cJR-D-.js.gz +0 -0
  95. package/dist/_frontend/assets/{lspLanguageFeatures-B7zTxQeR.js → lspLanguageFeatures-BglPdZ9k.js} +1 -1
  96. package/dist/_frontend/assets/lspLanguageFeatures-BglPdZ9k.js.br +0 -0
  97. package/dist/_frontend/assets/lspLanguageFeatures-BglPdZ9k.js.gz +0 -0
  98. package/dist/_frontend/assets/{mdx-BkeHwsFe.js → mdx-8XdfXAL0.js} +1 -1
  99. package/dist/_frontend/assets/mdx-8XdfXAL0.js.br +0 -0
  100. package/dist/_frontend/assets/mdx-8XdfXAL0.js.gz +0 -0
  101. package/dist/_frontend/assets/{python-CBbLT2F3.js → python-DQOdvHyX.js} +1 -1
  102. package/dist/_frontend/assets/python-DQOdvHyX.js.br +0 -0
  103. package/dist/_frontend/assets/python-DQOdvHyX.js.gz +0 -0
  104. package/dist/_frontend/assets/{razor-CqJ8opAm.js → razor-C1xHwuXD.js} +1 -1
  105. package/dist/_frontend/assets/razor-C1xHwuXD.js.br +0 -0
  106. package/dist/_frontend/assets/razor-C1xHwuXD.js.gz +0 -0
  107. package/dist/_frontend/assets/{tsMode-Dcw7IR7T.js → tsMode-D3pF1ez-.js} +1 -1
  108. package/dist/_frontend/assets/tsMode-D3pF1ez-.js.br +0 -0
  109. package/dist/_frontend/assets/tsMode-D3pF1ez-.js.gz +0 -0
  110. package/dist/_frontend/assets/{typescript-y4i1eGHh.js → typescript-YEfYOIai.js} +1 -1
  111. package/dist/_frontend/assets/typescript-YEfYOIai.js.br +0 -0
  112. package/dist/_frontend/assets/typescript-YEfYOIai.js.gz +0 -0
  113. package/dist/_frontend/assets/{workers-zrfOS25q.js → workers-BR_tlgTN.js} +1 -1
  114. package/dist/_frontend/assets/workers-BR_tlgTN.js.br +0 -0
  115. package/dist/_frontend/assets/workers-BR_tlgTN.js.gz +0 -0
  116. package/dist/_frontend/assets/{xml-ByQHPnmR.js → xml-Bsw5Rnro.js} +1 -1
  117. package/dist/_frontend/assets/xml-Bsw5Rnro.js.br +0 -0
  118. package/dist/_frontend/assets/xml-Bsw5Rnro.js.gz +0 -0
  119. package/dist/_frontend/assets/{yaml-sPjcg_YH.js → yaml-CyHnqnMx.js} +1 -1
  120. package/dist/_frontend/assets/yaml-CyHnqnMx.js.br +0 -0
  121. package/dist/_frontend/assets/yaml-CyHnqnMx.js.gz +0 -0
  122. package/dist/_frontend/index.html +1 -1
  123. package/dist/controller-main.js +207 -23
  124. package/dist/controller-main.js.map +1 -1
  125. package/dist/main.js +1827 -919
  126. package/dist/main.js.map +1 -1
  127. package/dist/postgres/migrations/20260727_000001_init.js +35 -3
  128. package/dist/postgres/migrations/20260727_000001_init.js.map +1 -1
  129. package/dist/postgres/migrations/20260831_000001_session_external_id.js.map +1 -1
  130. package/dist/postgres/migrations/20260902_000002_agent_external_id.js.map +1 -1
  131. package/dist/postgres/migrations/20260903_000002_created_by_subject.js.map +1 -1
  132. package/dist/postgres/migrations/20260904_000001_schedule_agent_id.js.map +1 -1
  133. package/dist/postgres/migrations/20260904_000002_session_source.js.map +1 -1
  134. package/dist/postgres/migrations/20260904_000003_session_metadata_gin.js.map +1 -1
  135. package/dist/postgres/migrations/20260924_000001_turn_inbound_events.js +21 -0
  136. package/dist/postgres/migrations/20260924_000001_turn_inbound_events.js.map +1 -0
  137. package/dist/postgres/migrations/20260924_000002_session_shared.js +20 -0
  138. package/dist/postgres/migrations/20260924_000002_session_shared.js.map +1 -0
  139. package/dist/postgres/migrations/20260926_000001_sandbox_environment.js +41 -0
  140. package/dist/postgres/migrations/20260926_000001_sandbox_environment.js.map +1 -0
  141. package/dist/sqlite/migrations/20260831_000001_session_external_id.js.map +1 -1
  142. package/dist/sqlite/migrations/20260902_000001_session_metadata.js.map +1 -1
  143. package/dist/sqlite/migrations/20260902_000002_agent_external_id.js.map +1 -1
  144. package/dist/sqlite/migrations/20260903_000001_drop_agent_metadata.js.map +1 -1
  145. package/dist/sqlite/migrations/20260903_000002_created_by_subject.js.map +1 -1
  146. package/dist/sqlite/migrations/20260904_000001_schedule_agent_id.js.map +1 -1
  147. package/dist/sqlite/migrations/20260904_000002_session_source.js.map +1 -1
  148. package/dist/sqlite/migrations/20260924_000001_turn_inbound_events.js +33 -0
  149. package/dist/sqlite/migrations/20260924_000001_turn_inbound_events.js.map +1 -0
  150. package/dist/sqlite/migrations/20260924_000002_session_shared.js +20 -0
  151. package/dist/sqlite/migrations/20260924_000002_session_shared.js.map +1 -0
  152. package/dist/sqlite/migrations/20260926_000001_sandbox_environment.js +75 -0
  153. package/dist/sqlite/migrations/20260926_000001_sandbox_environment.js.map +1 -0
  154. package/package.json +5 -4
  155. package/dist/_frontend/assets/AgentCodeSnippets-BPC6TD7K-B1T1mqKJ.js.br +0 -0
  156. package/dist/_frontend/assets/AgentCodeSnippets-BPC6TD7K-B1T1mqKJ.js.gz +0 -0
  157. package/dist/_frontend/assets/AgentMetricChart-T6DZZ37Y-BikFOApC.js.br +0 -0
  158. package/dist/_frontend/assets/AgentMetricChart-T6DZZ37Y-BikFOApC.js.gz +0 -0
  159. package/dist/_frontend/assets/AgentOverview-BFU7EO4Y-B_AVURNj.js.br +0 -0
  160. package/dist/_frontend/assets/AgentOverview-BFU7EO4Y-B_AVURNj.js.gz +0 -0
  161. package/dist/_frontend/assets/AgentSessionEventTimeline-ATVBTYDF-CQqNlw83.js.br +0 -0
  162. package/dist/_frontend/assets/AgentSessionEventTimeline-ATVBTYDF-CQqNlw83.js.gz +0 -0
  163. package/dist/_frontend/assets/AgentSessionEventTimelineChart-H577STKW-C60m-0SZ.js +0 -1
  164. package/dist/_frontend/assets/AgentSessionEventTimelineChart-H577STKW-C60m-0SZ.js.br +0 -0
  165. package/dist/_frontend/assets/AgentSessionEventTimelineChart-H577STKW-C60m-0SZ.js.gz +0 -0
  166. package/dist/_frontend/assets/AgentSessions-GDLBXFIK-DnsZyTRr.js +0 -1
  167. package/dist/_frontend/assets/AgentSessions-GDLBXFIK-DnsZyTRr.js.br +0 -0
  168. package/dist/_frontend/assets/AgentSessions-GDLBXFIK-DnsZyTRr.js.gz +0 -0
  169. package/dist/_frontend/assets/ConnectorSettings-FYNF6J3F-COur0yqS.js.br +0 -0
  170. package/dist/_frontend/assets/ConnectorSettings-FYNF6J3F-COur0yqS.js.gz +0 -0
  171. package/dist/_frontend/assets/DrawerLayout-MJJYQDCW-D8DQQcQF.js +0 -2
  172. package/dist/_frontend/assets/DrawerLayout-MJJYQDCW-D8DQQcQF.js.br +0 -0
  173. package/dist/_frontend/assets/DrawerLayout-MJJYQDCW-D8DQQcQF.js.gz +0 -0
  174. package/dist/_frontend/assets/ModelSettings-6EW7U2MP-DbtZxzUW.js.br +0 -0
  175. package/dist/_frontend/assets/ModelSettings-6EW7U2MP-DbtZxzUW.js.gz +0 -0
  176. package/dist/_frontend/assets/SandboxSettings-HQVBGHXZ-CZe1E4Rj.js +0 -1
  177. package/dist/_frontend/assets/SandboxSettings-HQVBGHXZ-CZe1E4Rj.js.br +0 -0
  178. package/dist/_frontend/assets/SandboxSettings-HQVBGHXZ-CZe1E4Rj.js.gz +0 -0
  179. package/dist/_frontend/assets/SchedulesPage-ZO3PJY4J-DnSsCsve.js +0 -1
  180. package/dist/_frontend/assets/SchedulesPage-ZO3PJY4J-DnSsCsve.js.br +0 -0
  181. package/dist/_frontend/assets/SchedulesPage-ZO3PJY4J-DnSsCsve.js.gz +0 -0
  182. package/dist/_frontend/assets/SettingsBuilder-FODMI7HG-CyRho5Uc.js.br +0 -0
  183. package/dist/_frontend/assets/SettingsBuilder-FODMI7HG-CyRho5Uc.js.gz +0 -0
  184. package/dist/_frontend/assets/ShellRouteSync-4I5BP2VY-SuZYdmPG.js +0 -1
  185. package/dist/_frontend/assets/ShellRouteSync-4I5BP2VY-SuZYdmPG.js.br +0 -0
  186. package/dist/_frontend/assets/ShellRouteSync-4I5BP2VY-SuZYdmPG.js.gz +0 -0
  187. package/dist/_frontend/assets/SidebarLayout-ZLWG2YGO-iNuRGXgp.js.br +0 -0
  188. package/dist/_frontend/assets/SidebarLayout-ZLWG2YGO-iNuRGXgp.js.gz +0 -0
  189. package/dist/_frontend/assets/SkillSettings-AFSAOU6O-EcWn2HFB.js.br +0 -0
  190. package/dist/_frontend/assets/SkillSettings-AFSAOU6O-EcWn2HFB.js.gz +0 -0
  191. package/dist/_frontend/assets/TrueForgeUIWithRouter-RQX5XWGI-afnJ79jt.js +0 -1
  192. package/dist/_frontend/assets/WebSearchSettings-BW4CWGRR-Cs-t9iMH.js.br +0 -0
  193. package/dist/_frontend/assets/WebSearchSettings-BW4CWGRR-Cs-t9iMH.js.gz +0 -0
  194. package/dist/_frontend/assets/WidgetLayout-WIPKUIL4-VyhjEehs.js +0 -1
  195. package/dist/_frontend/assets/WidgetLayout-WIPKUIL4-VyhjEehs.js.br +0 -0
  196. package/dist/_frontend/assets/WidgetLayout-WIPKUIL4-VyhjEehs.js.gz +0 -0
  197. package/dist/_frontend/assets/chunk-62JRHF6Z-DWQVXP0g.js.br +0 -0
  198. package/dist/_frontend/assets/chunk-62JRHF6Z-DWQVXP0g.js.gz +0 -0
  199. package/dist/_frontend/assets/chunk-TFQWCBFQ-CObdB7gd.js.br +0 -0
  200. package/dist/_frontend/assets/chunk-TFQWCBFQ-CObdB7gd.js.gz +0 -0
  201. package/dist/_frontend/assets/chunk-TJGGIEF6-NrA1UOxh.js +0 -1
  202. package/dist/_frontend/assets/chunk-TJGGIEF6-NrA1UOxh.js.br +0 -0
  203. package/dist/_frontend/assets/chunk-TJGGIEF6-NrA1UOxh.js.gz +0 -0
  204. package/dist/_frontend/assets/chunk-YN5ZBBQM-C6IH83Y_.js +0 -2
  205. package/dist/_frontend/assets/chunk-YN5ZBBQM-C6IH83Y_.js.br +0 -0
  206. package/dist/_frontend/assets/chunk-YN5ZBBQM-C6IH83Y_.js.gz +0 -0
  207. package/dist/_frontend/assets/cssMode-BLgfUUIP.js.br +0 -0
  208. package/dist/_frontend/assets/cssMode-BLgfUUIP.js.gz +0 -0
  209. package/dist/_frontend/assets/freemarker2-D9Zhxhbo.js.br +0 -0
  210. package/dist/_frontend/assets/freemarker2-D9Zhxhbo.js.gz +0 -0
  211. package/dist/_frontend/assets/handlebars-Cr-mYRIr.js.br +0 -0
  212. package/dist/_frontend/assets/handlebars-Cr-mYRIr.js.gz +0 -0
  213. package/dist/_frontend/assets/html-BSXsByU9.js.br +0 -0
  214. package/dist/_frontend/assets/html-BSXsByU9.js.gz +0 -0
  215. package/dist/_frontend/assets/htmlMode-Dl_li53P.js.br +0 -0
  216. package/dist/_frontend/assets/htmlMode-Dl_li53P.js.gz +0 -0
  217. package/dist/_frontend/assets/index-CPHXhr9t.js.br +0 -0
  218. package/dist/_frontend/assets/index-CPHXhr9t.js.gz +0 -0
  219. package/dist/_frontend/assets/index-DbkdD8rw.js.br +0 -0
  220. package/dist/_frontend/assets/index-DbkdD8rw.js.gz +0 -0
  221. package/dist/_frontend/assets/index-Dwv00glI.js.br +0 -0
  222. package/dist/_frontend/assets/index-Dwv00glI.js.gz +0 -0
  223. package/dist/_frontend/assets/jsonMode-BINBtD9i.js.br +0 -0
  224. package/dist/_frontend/assets/jsonMode-BINBtD9i.js.gz +0 -0
  225. package/dist/_frontend/assets/liquid-DSnOJ-2h.js.br +0 -0
  226. package/dist/_frontend/assets/liquid-DSnOJ-2h.js.gz +0 -0
  227. package/dist/_frontend/assets/lspLanguageFeatures-B7zTxQeR.js.br +0 -0
  228. package/dist/_frontend/assets/lspLanguageFeatures-B7zTxQeR.js.gz +0 -0
  229. package/dist/_frontend/assets/mdx-BkeHwsFe.js.br +0 -0
  230. package/dist/_frontend/assets/mdx-BkeHwsFe.js.gz +0 -0
  231. package/dist/_frontend/assets/python-CBbLT2F3.js.br +0 -0
  232. package/dist/_frontend/assets/python-CBbLT2F3.js.gz +0 -0
  233. package/dist/_frontend/assets/razor-CqJ8opAm.js.br +0 -0
  234. package/dist/_frontend/assets/razor-CqJ8opAm.js.gz +0 -0
  235. package/dist/_frontend/assets/tsMode-Dcw7IR7T.js.br +0 -0
  236. package/dist/_frontend/assets/tsMode-Dcw7IR7T.js.gz +0 -0
  237. package/dist/_frontend/assets/typescript-y4i1eGHh.js.br +0 -0
  238. package/dist/_frontend/assets/typescript-y4i1eGHh.js.gz +0 -0
  239. package/dist/_frontend/assets/workers-zrfOS25q.js.br +0 -0
  240. package/dist/_frontend/assets/workers-zrfOS25q.js.gz +0 -0
  241. package/dist/_frontend/assets/xml-ByQHPnmR.js.br +0 -0
  242. package/dist/_frontend/assets/xml-ByQHPnmR.js.gz +0 -0
  243. package/dist/_frontend/assets/yaml-sPjcg_YH.js.br +0 -0
  244. package/dist/_frontend/assets/yaml-sPjcg_YH.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-CPHXhr9t.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{d as u,r as s,j as t,I as x,g as d}from"./index-eDNLQ9X2.js";function h({snippets:a}){var c;const i=u("AgentCodeBlock"),[m,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===m)??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:d("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:d("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(i,{code:r.sampleCode[o],language:r.language})})]})]})}export{h as default};
@@ -1 +1 @@
1
- import{as as j,r as d,j as a,aN as C,aM as k}from"./index-CPHXhr9t.js";import{c as M,a as F,d as R,L as S,e as D,P as T,f as p,p as w}from"./index-Dwv00glI.js";F.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:b=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])),x=r[(b+o)%r.length];return{label:s.name,data:c.map(n=>L.get(n)??null),borderColor:x,backgroundColor:x,pointRadius:0,pointHoverRadius:0,borderWidth:2,borderCapStyle:"butt",borderJoinStyle:"miter",tension:0,spanGaps:!0}}))??[]}),[b,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(M,{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
+ import{ap as j,r as d,j as a,aK as C,aJ as k}from"./index-eDNLQ9X2.js";import{c as F,a as M,d as R,L as S,e as p,P as D,f as T,p as w}from"./index-DL_GegUd.js";M.register(R,S,p,D,T,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:b=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])),x=r[(b+o)%r.length];return{label:s.name,data:c.map(n=>L.get(n)??null),borderColor:x,backgroundColor:x,pointRadius:0,pointHoverRadius:0,borderWidth:2,borderCapStyle:"butt",borderJoinStyle:"miter",tension:0,spanGaps:!0}}))??[]}),[b,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 I,m as V,r as y,j as e,I as N,e as A,h as q,v as G,w as W,x as Q,y as H,z as J,A as X,B as Y,D as Z,E as ee}from"./index-CPHXhr9t.js";var te={read:"border-border bg-secondary-bg text-text-secondary",write:"border-border bg-secondary-bg text-text-primary",destructive:"border-failure-bg/30 bg-failure-bg/10 text-failure-bg"},P={read:0,write:1,unknown:2,destructive:3};function se(t){return t===1?"1 tool":`${t} tools`}function ne(t){return t.includes(Z)?"All tools":t.filter(l=>l.startsWith("@")).join(" ")}function re({count:t}){return e.jsxs("span",{className:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium","aria-label":`${t} ${t===1?"tool needs":"tools need"} approval`,children:[e.jsx(N,{name:"shield-check",className:"size-2.5"}),t]})}function ae({kind:t}){return e.jsx("span",{className:A("shrink-0 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium",te[t]),children:t})}function oe({approvalRequired:t,toolName:l}){return e.jsx(ee,{content:t?"Asks for approval before running":"Runs without asking for approval",triggerClassName:"shrink-0",children:e.jsx("span",{role:"img","aria-label":`${l} ${t?"requires approval":"runs without approval"}`,className:A("flex size-5 items-center justify-center rounded-md border",t?"border-warning-bg/50 bg-warning-bg/10 text-warning-bg":"border-border text-text-secondary"),children:e.jsx(N,{name:t?"shield-check":"shield",className:"size-3"})})})}function le({mcpServers:t}){const l=I("AgentOverviewCard"),i=q(),c=i==null?void 0:i.getMcpTools,u=y.useMemo(()=>G(t),[t]),[M,w]=y.useState({}),[k,s]=y.useState(()=>new Set);return y.useEffect(()=>{if(c===void 0)return;let r=!1;for(const x of u)c({connectorId:x.name}).then(f=>{r||w(h=>({...h,[x.name]:f}))},()=>{});return()=>{r=!0}},[c,u]),u.length===0?e.jsx(l,{title:"MCP Servers & Tools",icon:"plug",count:0,children:e.jsx("p",{className:"text-text-secondary text-xs",children:"No connectors attached."})}):e.jsx(l,{title:"MCP Servers & Tools",icon:"plug",count:u.length,children:e.jsx("ul",{className:"space-y-1.5",children:u.map(r=>{const x=M[r.name]??[],f=W(r.value),h=Q(r.value),m=H({enableSelectors:h,disableSelectors:J(r.value),tools:x}),d=m.names.map(n=>{const o=x.find(S=>S.name===n),g=o===void 0?void 0:X(o);return{toolName:n,kind:g,approvalRequired:Y({toolName:n,tools:x,selectors:f})}}).sort((n,o)=>P[n.kind??"unknown"]-P[o.kind??"unknown"]),p=d.filter(n=>n.approvalRequired).length,b=k.has(r.id);return e.jsxs("li",{className:"overflow-hidden rounded-md border border-border",children:[e.jsxs("button",{type:"button","aria-expanded":b,disabled:d.length===0,className:"flex w-full cursor-pointer items-center gap-2 bg-secondary-bg px-2.5 py-2 text-left text-xs hover:bg-ghost-button-hover disabled:cursor-default disabled:hover:bg-secondary-bg",onClick:()=>s(n=>{const o=new Set(n);return b?o.delete(r.id):o.add(r.id),o}),children:[e.jsx(N,{name:"chevron-down",className:A("size-3 shrink-0 text-text-secondary transition-transform",b?void 0:"-rotate-90",d.length===0&&"invisible")}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:r.name}),e.jsx("span",{className:"shrink-0 text-text-secondary",children:m.resolved?se(d.length):ne(h)}),p>0?e.jsx(re,{count:p}):null]}),b?e.jsx("ul",{className:"divide-y divide-border border-t border-border",children:d.map(({toolName:n,kind:o,approvalRequired:g})=>e.jsxs("li",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[0.6875rem]",title:n,children:n}),o?e.jsx(ae,{kind:o}):null,e.jsx(oe,{approvalRequired:g,toolName:n})]},n))}):null]},r.id)})})})}var v="text-right font-mono text-primary-button-bg";function T(t){return typeof t=="object"&&t!=null}function U(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function C(t,...l){for(const i of l){const c=t==null?void 0:t[i];if(c!==void 0)return c}}function ie(t){const l=t.lastIndexOf("/");return l>=0?t.slice(l+1):t}function de({detail:t}){var S,E,O,R,_,$,D,F,L,z,B,K;const l=I("Markdown"),i=I("AgentOverviewCard"),c=V(),[u,M]=y.useState("markdown"),[w,k]=y.useState(!1),s=t.agentSpec,r=s.skills??[],x=T(s.model.params)?s.model.params:null,f=C(x,"maxTokens","max_tokens"),h=C(x,"temperature"),m=T(s.config)?s.config:null,d=T(m==null?void 0:m.sandbox)?m.sandbox:null,p=(S=s.instructions)!=null&&S.trim()?s.instructions:null,b=(E=t.description)!=null&&E.trim()?t.description:null,n=[["Sandbox",typeof(d==null?void 0:d.enabled)=="boolean"?d.enabled?"Enabled":"Disabled":void 0],["Iteration limit",C(m,"iterationLimit","iteration_limit")],["Response format",C(m,"responseFormat","response_format")]].filter(a=>typeof a[1]=="string"||typeof a[1]=="number"),o=[["Generative UI",(R=(O=s.config)==null?void 0:O.generativeUi)==null?void 0:R.enabled],["Dynamic sub-agents",($=(_=s.config)==null?void 0:_.dynamicSubAgents)==null?void 0:$.enabled],["Ask user questions",(F=(D=s.config)==null?void 0:D.askUserQuestions)==null?void 0:F.enabled],...((L=c==null?void 0:c.webSearch)==null?void 0:L.enabled)===!0?[["Web search",(B=(z=s.config)==null?void 0:z.webSearch)==null?void 0:B.enabled]]:[]].filter(a=>typeof a[1]=="boolean"),g=u==="markdown"?"Raw":"Markdown";return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 md:overflow-hidden",children:e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 md:grid-cols-[minmax(0,1fr)_22rem] 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(N,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),p?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 ${g}`,onClick:()=>M(a=>a==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:g}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:w?"Copied!":"Copy","aria-label":w?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(p).then(()=>{k(!0),setTimeout(()=>k(!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(N,{name:w?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:p?u==="markdown"?e.jsx(l,{content:p,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:p}):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:[b?e.jsx(i,{title:"Description",icon:"file",children:e.jsx("p",{className:"text-xs text-text-secondary",children:b})}):null,e.jsx(i,{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:A(v,"truncate"),title:s.model.name,children:ie(s.model.name)}),typeof f=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:v,children:f})]}):null,((K=s.model.params)==null?void 0:K.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:v,children:s.model.params.reasoningEffort})]}):null,typeof h=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:v,children:h})]}):null]})}),e.jsx(le,{mcpServers:s.mcpServers}),e.jsx(i,{title:"Attached Skills",icon:"lightbulb",count:r.length,children:r.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:r.map((a,j)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:U(a)??`Skill ${j+1}`},`${U(a)??"skill"}-${j}`))})}),n.length>0?e.jsx(i,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:n.map(([a,j])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:a}),e.jsx("dd",{className:v,children:j})]},a))})}):null,o.length>0?e.jsx(i,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:o.map(([a,j])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:a}),e.jsx("dd",{className:v,children:j?"Enabled":"Disabled"})]},a))})}):null]})]})})}export{de as default};
1
+ import{d as I,o as U,r as y,j as e,I as w,g as M,k as V,D as q,E as W,F as H,G as J,H as Q,J as X,K as Y,L as Z,M as ee}from"./index-eDNLQ9X2.js";var te={read:"border-border bg-secondary-bg text-text-secondary",write:"border-border bg-secondary-bg text-text-primary",destructive:"border-failure-bg/30 bg-failure-bg/10 text-failure-bg"},B={read:0,write:1,unknown:2,destructive:3};function se(t){return t===1?"1 tool":`${t} tools`}function ne(t){return t.includes(Z)?"All tools":t.filter(l=>l.startsWith("@")).join(" ")}function re({count:t}){return e.jsxs("span",{className:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium","aria-label":`${t} ${t===1?"tool needs":"tools need"} approval`,children:[e.jsx(w,{name:"shield-check",className:"size-2.5"}),t]})}function ae({kind:t}){return e.jsx("span",{className:M("shrink-0 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium",te[t]),children:t})}function oe({approvalRequired:t,toolName:l}){return e.jsx(ee,{content:t?"Asks for approval before running":"Runs without asking for approval",triggerClassName:"shrink-0",children:e.jsx("span",{role:"img","aria-label":`${l} ${t?"requires approval":"runs without approval"}`,className:M("flex size-5 items-center justify-center rounded-md border",t?"border-warning-bg/50 bg-warning-bg/10 text-warning-bg":"border-border text-text-secondary"),children:e.jsx(w,{name:t?"shield-check":"shield",className:"size-3"})})})}function le({mcpServers:t}){const l=I("AgentOverviewCard"),i=V(),c=i==null?void 0:i.getMcpTools,u=y.useMemo(()=>q(t),[t]),[T,N]=y.useState({}),[k,s]=y.useState(()=>new Set);return y.useEffect(()=>{if(c===void 0)return;let r=!1;for(const x of u)c({connectorId:x.name}).then(f=>{r||N(h=>({...h,[x.name]:f}))},()=>{});return()=>{r=!0}},[c,u]),u.length===0?e.jsx(l,{title:"MCP Servers & Tools",icon:"plug",count:0,children:e.jsx("p",{className:"text-text-secondary text-xs",children:"No connectors attached."})}):e.jsx(l,{title:"MCP Servers & Tools",icon:"plug",count:u.length,children:e.jsx("ul",{className:"space-y-1.5",children:u.map(r=>{const x=T[r.name]??[],f=W(r.value),h=H(r.value),m=J({enableSelectors:h,disableSelectors:Q(r.value),tools:x}),d=m.names.map(n=>{const o=x.find(S=>S.name===n),g=o===void 0?void 0:X(o);return{toolName:n,kind:g,approvalRequired:Y({toolName:n,tools:x,selectors:f})}}).sort((n,o)=>B[n.kind??"unknown"]-B[o.kind??"unknown"]),p=d.filter(n=>n.approvalRequired).length,b=k.has(r.id);return e.jsxs("li",{className:"overflow-hidden rounded-md border border-border",children:[e.jsxs("button",{type:"button","aria-expanded":b,disabled:d.length===0,className:"flex w-full cursor-pointer items-center gap-2 bg-secondary-bg px-2.5 py-2 text-left text-xs hover:bg-ghost-button-hover disabled:cursor-default disabled:hover:bg-secondary-bg",onClick:()=>s(n=>{const o=new Set(n);return b?o.delete(r.id):o.add(r.id),o}),children:[e.jsx(w,{name:"chevron-down",className:M("size-3 shrink-0 text-text-secondary transition-transform",b?void 0:"-rotate-90",d.length===0&&"invisible")}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:r.name}),e.jsx("span",{className:"shrink-0 text-text-secondary",children:m.resolved?se(d.length):ne(h)}),p>0?e.jsx(re,{count:p}):null]}),b?e.jsx("ul",{className:"divide-y divide-border border-t border-border",children:d.map(({toolName:n,kind:o,approvalRequired:g})=>e.jsxs("li",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[0.6875rem]",title:n,children:n}),o?e.jsx(ae,{kind:o}):null,e.jsx(oe,{approvalRequired:g,toolName:n})]},n))}):null]},r.id)})})})}var v="text-right font-mono text-primary-button-bg";function A(t){return typeof t=="object"&&t!=null}function G(t){return!("name"in t)||typeof t.name!="string"?null:t.name}function C(t,...l){for(const i of l){const c=t==null?void 0:t[i];if(c!==void 0)return c}}function ie(t){const l=t.lastIndexOf("/");return l>=0?t.slice(l+1):t}function de({detail:t}){var S,E,O,F,L,R,_,$,D,z,K,P;const l=I("Markdown"),i=I("AgentOverviewCard"),c=U(),[u,T]=y.useState("markdown"),[N,k]=y.useState(!1),s=t.agentSpec,r=s.skills??[],x=A(s.model.params)?s.model.params:null,f=C(x,"maxTokens","max_tokens"),h=C(x,"temperature"),m=A(s.config)?s.config:null,d=A(m==null?void 0:m.sandbox)?m.sandbox:null,p=(S=s.instructions)!=null&&S.trim()?s.instructions:null,b=(E=t.description)!=null&&E.trim()?t.description:null,n=[["Sandbox",typeof(d==null?void 0:d.enabled)=="boolean"?d.enabled?"Enabled":"Disabled":void 0],["Iteration limit",C(m,"iterationLimit","iteration_limit")],["Response format",C(m,"responseFormat","response_format")]].filter(a=>typeof a[1]=="string"||typeof a[1]=="number"),o=[["Generative UI",(F=(O=s.config)==null?void 0:O.generativeUi)==null?void 0:F.enabled],["Dynamic sub-agents",(R=(L=s.config)==null?void 0:L.dynamicSubAgents)==null?void 0:R.enabled],["Ask user questions",($=(_=s.config)==null?void 0:_.askUserQuestions)==null?void 0:$.enabled],...((D=c==null?void 0:c.webSearch)==null?void 0:D.enabled)===!0?[["Web search",(K=(z=s.config)==null?void 0:z.webSearch)==null?void 0:K.enabled]]:[]].filter(a=>typeof a[1]=="boolean"),g=u==="markdown"?"Raw":"Markdown";return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 md:overflow-hidden",children:e.jsxs("div",{className:"grid min-h-0 flex-1 gap-3 md:grid-cols-[minmax(0,1fr)_22rem] 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(w,{name:"book-open",className:"size-4 text-text-secondary"}),"Instructions"]}),p?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 ${g}`,onClick:()=>T(a=>a==="markdown"?"raw":"markdown"),className:"cursor-pointer px-2.5 transition-colors hover:bg-ghost-button-hover hover:text-text-primary",children:g}),e.jsx("span",{className:"w-px self-stretch bg-border","aria-hidden":!0}),e.jsx("button",{type:"button",title:N?"Copied!":"Copy","aria-label":N?"Copied!":"Copy",onClick:()=>{navigator.clipboard.writeText(p).then(()=>{k(!0),setTimeout(()=>k(!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(w,{name:N?"check":"copy",size:12})})]}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:p?u==="markdown"?e.jsx(l,{content:p,readOnly:!0,className:"text-sm"}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm text-text-primary",children:p}):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:[b?e.jsx(i,{title:"Description",icon:"file",children:e.jsx("p",{className:"text-xs text-text-secondary",children:b})}):null,e.jsx(i,{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:M(v,"truncate"),title:s.model.name,children:ie(s.model.name)}),typeof f=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Max tokens"}),e.jsx("dd",{className:v,children:f})]}):null,((P=s.model.params)==null?void 0:P.reasoningEffort)!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Reasoning"}),e.jsx("dd",{className:v,children:s.model.params.reasoningEffort})]}):null,typeof h=="number"?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-text-secondary",children:"Temperature"}),e.jsx("dd",{className:v,children:h})]}):null]})}),e.jsx(le,{mcpServers:s.mcpServers}),e.jsx(i,{title:"Attached Skills",icon:"lightbulb",count:r.length,children:r.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No skills attached."}):e.jsx("ul",{className:"space-y-1.5",children:r.map((a,j)=>e.jsx("li",{className:"rounded-md bg-secondary-bg px-2 py-1.5 text-xs",children:G(a)??`Skill ${j+1}`},`${G(a)??"skill"}-${j}`))})}),n.length>0?e.jsx(i,{title:"Execution",icon:"terminal",children:e.jsx("dl",{className:"space-y-1 text-xs",children:n.map(([a,j])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:a}),e.jsx("dd",{className:v,children:j})]},a))})}):null,o.length>0?e.jsx(i,{title:"Capabilities",icon:"cube",children:e.jsx("dl",{className:"space-y-1 text-xs",children:o.map(([a,j])=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-text-secondary",children:a}),e.jsx("dd",{className:v,children:j?"Enabled":"Disabled"})]},a))})}):null]})]})})}export{de as default};
@@ -1 +1 @@
1
- import{c as m,as as b,r,at as f,j as t,au as h,e as S}from"./index-CPHXhr9t.js";function g({turns:l,segments:a,onSelectTurn:o}){const d=m("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]),u=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:()=>u(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{d as u,ap as b,r,aq as f,j as t,ar as h,g as S}from"./index-eDNLQ9X2.js";function g({turns:l,segments:a,onSelectTurn:o}){const d=u("AgentSessionEventTimelineChart"),c=b()==="dark",[i,x]=r.useState(()=>new Set),p=r.useMemo(()=>{const e=new Set(a.map(s=>s.type));return f.filter(s=>e.has(s.id))},[a]),m=r.useCallback(e=>{x(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n})},[]);return a.length===0?null:t.jsxs("div",{className:"w-full","data-slot":"agent-session-event-timeline",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2","data-slot":"agent-session-event-types",children:[t.jsx("span",{className:"text-xs font-medium uppercase text-text-secondary",children:"Event types"}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:p.map(e=>{const s=!i.has(e.id);return t.jsxs("button",{type:"button","aria-pressed":s,className:S("flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",s?"border-border text-text-primary":"border-transparent text-text-secondary opacity-80"),onClick:()=>m(e.id),children:[t.jsx("span",{className:"size-2 rounded-sm",style:{backgroundColor:h(e.id,c)}}),e.label]},e.id)})})]}),t.jsx("div",{className:"w-full p-2",children:t.jsx(d,{turns:l,segments:a,hiddenTypes:i,onSelectTurn:o})})]})}export{g as AgentSessionEventTimeline};
@@ -0,0 +1 @@
1
+ import{ap as te,r as a,as as Le,at as Ge,au as Be,av as Oe,aw as $e,ax as Me,ay as He,az as m,ar as v,aA as P,aB as Z,aC as Xe,aD as We,aE as ze,aF as Ue,j as s,aG as Fe,aH as Ke,aI as Ve,aJ as Je,aK as Ye,aL as qe,aM as C,aN as Qe,aO as we}from"./index-eDNLQ9X2.js";import{C as Ze,a as et,B as tt,b as st,L as nt,P as at,S as rt,p as ot}from"./index-DL_GegUd.js";function lt(n){return n.type!=="system"||n.description.trim().length>0}function Ne({segment:n,subAgentLabel:o}){const c=!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:[o!=null?s.jsx("div",{className:"border-b border-border py-1.5 text-text-secondary",children:`Sub-Agent: ${o}`}):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:we(n.type)}),c?s.jsx("span",{className:"tabular-nums text-text-secondary",children:C(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 it({turn:n,turnNumber:o,durationMs:c,segments:i}){const E=te()==="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 ${o}`}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:Je(c)})]}),s.jsxs("div",{className:"mt-1 flex flex-col text-text-secondary",children:[n.totalCostInUsd!=null?s.jsx("span",{children:`Cost: ${Ye(n.totalCostInUsd)}`}):null,n.totalTokens!=null?s.jsx("span",{children:`Tokens: ${qe(n.totalTokens)}`}):null]}),s.jsx("div",{className:"mt-2 border-t border-border pt-2",children:i.map(l=>{const M=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:v(l.type,E)}}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M}),l.isMarker?null:s.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-text-secondary",children:C(l.endMs-l.startMs)})]},l.id)})})]})}function ct({group:n,subAgentLabel:o}){return s.jsxs("div",{className:"max-h-72 w-80 max-w-full overflow-auto text-xs",children:[o!=null?s.jsx("div",{className:"border-b border-border py-1.5 text-text-secondary",children:`Sub-Agent: ${o}`}):null,s.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[s.jsx("span",{className:"font-medium text-text-secondary",children:"Tool calls"}),s.jsx("span",{className:"tabular-nums text-text-secondary",children:C(n.endMs-n.startMs)})]}),s.jsx("div",{className:o==null?"mt-1.5 border-t border-border pt-1.5":"mt-1.5",children:n.segments.map(c=>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:c.description||c.title}),s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:C(c.endMs-c.startMs)})]},c.id))})]})}function ut({group:n}){const o=te()==="dark",c=n.segments.length===1?n.segments[0]:void 0;return c!=null?s.jsx(Ne,{segment:c}):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:v(i.type,o)}}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium text-text-secondary",children:we(i.type)}),s.jsx("div",{className:"wrap-break-word font-medium text-text-primary",children:i.description.trim()||i.title})]})]},i.id))})]})}function dt({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:C(n.endMs-n.startMs)})]}),s.jsx("div",{className:"mt-1.5 border-t border-border pt-1.5",children:n.segments.map((o,c)=>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?o.description||o.title:`Sub-agent ${c+1}: ${o.description||o.title}`}),n.segments.length===1?null:s.jsx("span",{className:"shrink-0 tabular-nums text-text-secondary",children:C(o.endMs-o.startMs)})]},o.id))})]})}et.register(tt,st,nt,at,rt,ot);var ee=4,ge=12,je=12,mt=2,pt=8,xt=2,ft=30;function ht({heights:n,gaps:o}){const c=[];let i=0;return n.forEach((E,l)=>{c.push(i+E/2),i+=E+(o[l]??0)}),{centers:c,band:i}}function W(n){return n==="sub_agent"?0:n==="model"?2:1}function bt(n){if(!("x"in n)||!("y"in n)||!("base"in n))return null;const{x:o,y:c,base:i}=n;return typeof o!="number"||typeof c!="number"||typeof i!="number"?null:{x:(o+i)/2,y:c}}function Mt({turns:n,segments:o,hiddenTypes:c,onSelectTurn:i}){var ye;const l=te()==="dark",M=l?"#8c8c92":"#71717a",z=l?"#27272a":"#e4e4e7",se=l?"#3f3f46":"#E0ECFD",ne=l?"#52525b":"#E0ECFD",U=a.useRef(null),[ae,ke]=a.useState(0),[re,Se]=a.useState(ft),[r,oe]=a.useState(null),[Ae,F]=a.useState(null),K=a.useRef(""),V=a.useRef(null);a.useEffect(()=>{const e=U.current;if(e==null)return;const t=()=>ke(e.clientWidth);t();const u=new ResizeObserver(t);return u.observe(e),()=>u.disconnect()},[]);const f=a.useCallback(()=>{const e=U.current,t=V.current;e==null||t==null||F({left:t,top:e.getBoundingClientRect().bottom})},[]),Ce=a.useCallback(()=>{K.current="",V.current=null,oe(null),F(null)},[]);a.useEffect(()=>{if(r!=null)return f(),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[f,r]);const Ee=Math.max(0,...o.map(e=>e.endMs)),g=Math.max(1,Ke(Ee)),{turnStartsMs:le,turnOrdinals:ie,turnRanges:J}=a.useMemo(()=>Le(o),[o]),T=a.useMemo(()=>le.filter((e,t)=>t===0||e<=g),[g,le]),ce=Math.max(0,T.length-1),Te=Math.max(ae/2,ae-ge*ce-je),j=g/Math.max(1,Te),x=ge*j,Y=g+ce*x,ue=Y+je*j,de=a.useMemo(()=>T.slice(1).map((e,t)=>({startMs:e+t*x,endMs:e+(t+1)*x})),[T,x]),D=a.useMemo(()=>o.flatMap(e=>{if(c.has(e.type))return[];const t=(ie.get(e.turnIndex)??0)*x;return[{...e,startMs:e.startMs+t,endMs:e.endMs+t}]}),[c,o,x,ie]),L=a.useMemo(()=>Ge(D),[D]),w=a.useMemo(()=>D.filter(e=>!e.isMarker),[D]),b=a.useMemo(()=>J.length<2?[]:J.map(e=>({...e,id:`turn-${e.turnIndex}`,durationMs:e.endMs-e.startMs,startMs:e.startMs+e.ordinal*x,endMs:e.endMs+e.ordinal*x+ee*j})),[j,x,J]),N=a.useMemo(()=>w.filter(e=>e.type==="sub_agent"),[w]),G=a.useMemo(()=>Be(N),[N]),me=a.useMemo(()=>Oe({bars:G,subAgentSegments:N}),[G,N]),k=a.useMemo(()=>$e({subAgentSegments:N,threadSegments:w,minWidthMs:ee*j}),[w,j,N]),S=a.useMemo(()=>k.flatMap(e=>Me(e.segments.filter(t=>t.type==="tool_call")).filter(t=>t.segments.length>1).map(t=>({group:t,lane:e.lane,subAgentLabel:e.track.description}))),[k]),pe=a.useMemo(()=>new Set(S.flatMap(({group:e})=>e.segments.map(t=>t.id))),[S]),B=a.useMemo(()=>k.flatMap(e=>e.segments.filter(t=>!pe.has(t.id)).map(t=>({segment:t,lane:e.lane}))),[pe,k]),O=a.useMemo(()=>[...w.filter(e=>e.threadId===He),...G].sort((e,t)=>e.startMs-t.startMs||e.endMs-t.endMs),[w,G]),A=a.useMemo(()=>Me(O.filter(e=>e.type==="tool_call")).filter(e=>e.segments.length>1),[O]),xe=a.useMemo(()=>new Set(A.flatMap(e=>e.segments.map(t=>t.id))),[A]),$=a.useMemo(()=>O.filter(e=>!xe.has(e.id)),[xe,O]),fe=k.reduce((e,t)=>Math.max(e,t.lane+1),0),q=b.length>0,_=q?1:0,I=_+1,{centers:y,band:H}=a.useMemo(()=>{const e=[...q?[16]:[],10,28,...Array.from({length:fe},()=>12)],t=e.map((u,d)=>d===e.length-1?0:d===_?xt:pt);return ht({heights:e,gaps:t})},[q,fe,_]),Q=a.useMemo(()=>[...b.map(e=>({type:m.turn,bar:e})),...L.map(e=>({type:m.markerGroup,group:e})),...B.map(({segment:e})=>({type:m.event,segment:e})),...S.map(({group:e,subAgentLabel:t})=>({type:m.toolCallGroup,group:e,subAgentLabel:t})),...$.map(e=>{if(e.type!=="sub_agent")return{type:m.event,segment:e};const t=me.find(u=>u.barId===e.id);return t==null?{type:m.event,segment:e}:{type:m.subAgentGroup,group:t}}),...A.map(e=>({type:m.toolCallGroup,group:e}))],[$,L,B,me,S,A,b]),R=({label:e,range:t,y:u,color:d,hover:p,thickness:h,order:X=1,inflateAmount:ve})=>({label:e,data:[{x:Ve(t),y:u}],backgroundColor:d,hoverBackgroundColor:p,hoverBorderColor:p,borderWidth:0,borderSkipped:!1,borderRadius:mt,minBarLength:ee,barThickness:h,grouped:!1,order:X,...ve==null?{}:{inflateAmount:ve}}),_e=a.useMemo(()=>({datasets:[...b.map(e=>R({label:`Turn ${e.ordinal+1}`,range:e,y:y[0]??0,color:se,hover:ne,thickness:16})),...L.map(e=>{var d;const t=e.segments.length===1?(d=e.segments[0])==null?void 0:d.type:"system",u=v(t??"system",l);return{type:"scatter",label:e.segments.map(p=>Z(p.type)).join(", "),data:[{x:e.startMs,y:y[_]??0}],pointStyle:"rectRot",pointRadius:5,pointHoverRadius:6,clip:!1,backgroundColor:u,hoverBackgroundColor:P(t??"system",l),borderWidth:0,order:0}}),...B.map(({segment:e,lane:t})=>R({label:`${Z(e.type)}: ${e.title}`,range:e,y:y[I+1+t]??0,color:v(e.type,l),hover:P(e.type,l),thickness:12,order:W(e.type),inflateAmount:.5})),...S.map(({group:e,lane:t})=>R({label:"Parallel tool calls",range:e,y:y[I+1+t]??0,color:v("tool_call",l),hover:P("tool_call",l),thickness:12,order:W("tool_call"),inflateAmount:.5})),...$.map(e=>R({label:`${Z(e.type)}: ${e.title}`,range:e,y:y[I]??0,color:v(e.type,l),hover:P(e.type,l),thickness:28,order:W(e.type),inflateAmount:.5})),...A.map(e=>R({label:"Parallel tool calls",range:e,y:y[I]??0,color:v("tool_call",l),hover:P("tool_call",l),thickness:28,order:W("tool_call"),inflateAmount:.5}))]}),[y,I,l,$,L,_,B,S,A,b,se,ne]),Ie=a.useMemo(()=>({id:"turnLabels",afterDatasetsDraw(e){const{ctx:t}=e;t.save(),t.fillStyle=M,t.font="500 10px sans-serif",t.textAlign="center",t.textBaseline="middle",b.forEach((u,d)=>{const p=e.getDatasetMeta(d).data[0];if(p==null)return;const h=bt(p);h&&t.fillText(`T${u.ordinal+1}`,h.x,h.y)}),t.restore()}}),[M,b]),Re=a.useMemo(()=>({id:"timelineOverhead",afterLayout(e){const t=Math.round(e.height-e.chartArea.height);Se(u=>u===t?u:t)}}),[]),Pe=a.useMemo(()=>({indexAxis:"y",animation:!1,responsive:!0,maintainAspectRatio:!1,onClick:(e,t)=>{var d;const u=Q[((d=t[0])==null?void 0:d.datasetIndex)??-1];(u==null?void 0:u.type)===m.turn&&(i==null||i(u.bar.turnIndex))},onHover:(e,t)=>{var X;const u=(X=t[0])==null?void 0:X.datasetIndex,d=u==null?null:Q[u]??null,p=e.native;if((p==null?void 0:p.target)instanceof HTMLElement&&(p.target.style.cursor=(d==null?void 0:d.type)===m.turn?"pointer":"default"),p instanceof MouseEvent&&(V.current=p.clientX,f()),u==null)return;const h=Ue(d);if(K.current!==h){if(K.current=h,oe(d),d==null){F(null);return}f()}},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{type:"linear",position:"top",min:0,max:ue,grid:{color:z},border:{color:z},afterBuildTicks:e=>{e.ticks=ze({activeTotalMs:g,turnStartsMs:T,turnGapMs:x})},ticks:{color:M,align:"inner",autoSkip:!1,includeBounds:!1,maxTicksLimit:9,callback:e=>{const t=Number(e);return t<=Y?Xe(We(t,de)):""}}},y:{type:"linear",display:!1,reverse:!0,offset:!1,min:0,max:H,grid:{display:!1}}}}),[g,T,M,H,Q,z,i,f,de,ue,Y,x]),he=(r==null?void 0:r.type)===m.turn?n[r.bar.turnIndex]:void 0,De=a.useMemo(()=>({height:H+re}),[H,re]),be=(r==null?void 0:r.type)===m.turn&&he!=null?s.jsx(it,{turn:he,turnNumber:r.bar.ordinal+1,durationMs:r.bar.durationMs,segments:o.filter(e=>e.turnIndex===r.bar.turnIndex)}):(r==null?void 0:r.type)===m.event&&lt(r.segment)?s.jsx(Ne,{segment:r.segment,subAgentLabel:r.segment.type==="sub_agent"||(ye=k.find(e=>e.threadId===r.segment.threadId))==null?void 0:ye.track.description}):(r==null?void 0:r.type)===m.toolCallGroup?s.jsx(ct,{group:r.group,...r.subAgentLabel==null?{}:{subAgentLabel:r.subAgentLabel}}):(r==null?void 0:r.type)===m.markerGroup?s.jsx(ut,{group:r.group}):(r==null?void 0:r.type)===m.subAgentGroup?s.jsx(dt,{group:r.group}):null;return s.jsx("div",{ref:U,className:"w-full","data-slot":"agent-session-event-timeline-chart",children:s.jsx(Fe,{title:be,side:"bottom",triggerClassName:"block w-full",followCursor:!0,open:r!=null&&be!=null,className:"max-w-[min(25rem,calc(100vw-1rem))] whitespace-normal",anchor:Ae,children:s.jsx("div",{className:"w-full",style:De,onMouseLeave:Ce,children:s.jsx(Ze,{type:"bar",data:_e,options:Pe,plugins:[Ie,Re]})})})})}export{Mt as AgentSessionEventTimelineChart};
@@ -0,0 +1 @@
1
+ var Xe=e=>{throw TypeError(e)};var Je=(e,t,n)=>t.has(e)||Xe("Cannot "+n);var me=(e,t,n)=>(Je(e,t,"read from private field"),n?n.call(e):t.get(e)),Ze=(e,t,n)=>t.has(e)?Xe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ke=(e,t,n,s)=>(Je(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);import{r as Wt}from"./chunk-BZ2EOR5X-BgN-bqzz.js";import{r as x,j as C,bA as Ut,O as Vt,q as qt,b as Yt,bB as _t,bC as Xt,d as ke,Q as Jt,v as Qe,bD as Zt,$ as De,a0 as Kt,Z as Ie,I as Qt,g as en,a9 as tn,aa as nn,ab as sn,ac as on,ad as rn,bE as an}from"./index-eDNLQ9X2.js";function ln(e,t){const n=getComputedStyle(e),s=parseFloat(n.fontSize);return t*s}function un(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),s=parseFloat(n.fontSize);return t*s}function cn(e){return e/100*window.innerHeight}function dn(e){return e/100*window.innerWidth}function fn(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 ve({groupSize:e,panelElement:t,styleProp:n}){let s;const[o,r]=fn(n);switch(r){case"%":{s=o/100*e;break}case"px":{s=o;break}case"rem":{s=un(t,o);break}case"em":{s=ln(t,o);break}case"vh":{s=cn(o);break}case"vw":{s=dn(o);break}}return s}function F(e){return parseFloat(e.toFixed(3))}function fe({group:e}){const{orientation:t,panels:n}=e;return n.reduce((s,o)=>(s+=t==="horizontal"?o.element.offsetWidth:o.element.offsetHeight,s),0)}function je(e){const{panels:t}=e,n=fe({group:e});return n===0?t.map(s=>({groupResizeBehavior:s.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:s.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:s.panelConstraints.disabled,minSize:0,maxSize:100,panelId:s.id})):t.map(s=>{const{element:o,panelConstraints:r}=s;let u=0;if(r.collapsedSize!==void 0){const d=ve({groupSize:n,panelElement:o,styleProp:r.collapsedSize});u=F(d/n*100)}let a;if(r.defaultSize!==void 0){const d=ve({groupSize:n,panelElement:o,styleProp:r.defaultSize});a=F(d/n*100)}let i=0;if(r.minSize!==void 0){const d=ve({groupSize:n,panelElement:o,styleProp:r.minSize});i=F(d/n*100)}let l=100;if(r.maxSize!==void 0){const d=ve({groupSize:n,panelElement:o,styleProp:r.maxSize});l=F(d/n*100)}return{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:u,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:i,maxSize:l,panelId:s.id}})}function k(e,t="Assertion error"){if(!e)throw Error(t)}function Ne(e,t){return Array.from(t).sort(e==="horizontal"?pn:hn)}function pn(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function hn(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function vt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function bt(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 gn({orientation:e,rects:t,targetRect:n}){const s={x:n.x+n.width/2,y:n.y+n.height/2};let o,r=Number.MAX_VALUE;for(const u of t){const{x:a,y:i}=bt(s,u),l=e==="horizontal"?a:i;l<r&&(r=l,o=u)}return k(o,"No rect found"),o}let we;function mn(){return we===void 0&&(typeof matchMedia=="function"?we=!!matchMedia("(pointer:coarse)").matches:we=!1),we}function yt(e){const{element:t,orientation:n,panels:s,separators:o}=e,r=Ne(n,Array.from(t.children).filter(vt).map(v=>({element:v}))).map(({element:v})=>v),u=[];let a=!1,i=!1,l=-1,d=-1,h=0,f,w=[];{let v=-1;for(const c of r)c.hasAttribute("data-panel")&&(v++,c.hasAttribute("data-disabled")||(h++,l===-1&&(l=v),d=v))}if(h>1){let v=-1;for(const c of r)if(c.hasAttribute("data-panel")){v++;const m=s.find(p=>p.element===c);if(m){if(f){const p=f.element.getBoundingClientRect(),y=c.getBoundingClientRect();let S;if(i){const b=n==="horizontal"?new DOMRect(p.right,p.top,0,p.height):new DOMRect(p.left,p.bottom,p.width,0),g=n==="horizontal"?new DOMRect(y.left,y.top,0,y.height):new DOMRect(y.left,y.top,y.width,0);switch(w.length){case 0:{S=[b,g];break}case 1:{const M=w[0],E=gn({orientation:n,rects:[p,y],targetRect:M.element.getBoundingClientRect()});S=[M,E===p?g:b];break}default:{S=w;break}}}else w.length?S=w:S=[n==="horizontal"?new DOMRect(p.right,y.top,y.left-p.right,y.height):new DOMRect(y.left,p.bottom,y.width,y.top-p.bottom)];for(const b of S){let g="width"in b?b:b.element.getBoundingClientRect();const M=mn()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(g.width<M){const j=M-g.width;g=new DOMRect(g.x-j/2,g.y,g.width+j,g.height)}if(g.height<M){const j=M-g.height;g=new DOMRect(g.x,g.y-j/2,g.width,g.height+j)}const E=v<=l||v>d;!a&&!E&&u.push({group:e,groupSize:fe({group:e}),panels:[f,m],separator:"width"in b?void 0:b,rect:g}),a=!1}}i=!1,f=m,w=[]}}else if(c.hasAttribute("data-separator")){c.ariaDisabled!==null&&(a=!0);const m=o.find(p=>p.element===c);m?w.push(m):(f=void 0,w=[])}else i=!0}return u}var Z;class St{constructor(){Ze(this,Z,{})}addListener(t,n){const s=me(this,Z)[t];return s===void 0?me(this,Z)[t]=[n]:s.includes(n)||s.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const s=me(this,Z)[t];if(s!==void 0)if(s.length===1)s[0].call(null,n);else{let o=!1,r=null;const u=Array.from(s);for(let a=0;a<u.length;a++){const i=u[a];try{i.call(null,n)}catch(l){r===null&&(o=!0,r=l)}}if(o)throw r}}removeAllListeners(){Ke(this,Z,{})}removeListener(t,n){const s=me(this,Z)[t];if(s!==void 0){const o=s.indexOf(n);o>=0&&s.splice(o,1)}}}Z=new WeakMap;let ce={cursorFlags:0,state:"inactive"};const Fe=new St;function te(){return ce}function vn(e){return Fe.addListener("change",e)}function bn(e){const t=ce,n={...ce};n.cursorFlags=e,ce=n,Fe.emit("change",{prev:t,next:n})}function de(e){const t=ce;ce=e,Fe.emit("change",{prev:t,next:e})}const yn=e=>e,Te=()=>{},xt=1,zt=2,wt=4,Ct=8,et=3,tt=12;let Ce;function nt(){return Ce===void 0&&(Ce=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ce=!0)),Ce}function Sn({cursorFlags:e,groups:t,state:n}){let s=0,o=0;switch(n){case"active":case"hover":t.forEach(r=>{if(!r.mutableState.disableCursor)switch(r.orientation){case"horizontal":{s++;break}case"vertical":{o++;break}}})}if(!(s===0&&o===0)){switch(n){case"active":{if(e&&nt()){const r=(e&xt)!==0,u=(e&zt)!==0,a=(e&wt)!==0,i=(e&Ct)!==0;if(r)return a?"se-resize":i?"ne-resize":"e-resize";if(u)return a?"sw-resize":i?"nw-resize":"w-resize";if(a)return"s-resize";if(i)return"n-resize"}break}}return nt()?s>0&&o>0?"move":s>0?"ew-resize":"ns-resize":s>0&&o>0?"grab":s>0?"col-resize":"row-resize"}}const st=new WeakMap;function Oe(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=st.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 s=te();switch(s.state){case"active":case"hover":{const o=Sn({cursorFlags:s.cursorFlags,groups:s.hitRegions.map(u=>u.group),state:s.state}),r=`*, *:hover {cursor: ${o} !important; }`;if(t===r)return;t=r,o?n.cssRules.length===0?n.insertRule(r):n.replaceSync(r):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}st.set(e,{prevStyle:t,styleSheet:n})}let q=new Map;const Lt=new St;function xn(e){q=new Map(q),q.delete(e)}function ot(e,t){for(const[n]of q)if(n.id===e)return n}function K(e,t){for(const[n,s]of q)if(n.id===e)return s;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Q(){return q}function Ge(e,t){return Lt.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function J(e,t,n){const s=q.get(e);q=new Map(q),q.set(e,t),Lt.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:s,next:t})}function Pt(e){const t=te(),n=Q();let s=!1;switch(t.state){case"active":de({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Oe(e),s=!0,t.hitRegions.forEach(o=>{if(!n.has(o.group))return;const r=K(o.group.id,!0);J(o.group,r,{isUserInteraction:!0})}))}return s}function rt(e){e.defaultPrevented||Pt(e.currentTarget)}function zn(e,t,n){let s,o={x:1/0,y:1/0};for(const r of t){const u=bt(n,r.rect);switch(e){case"horizontal":{u.x<=o.x&&(s=r,o=u);break}case"vertical":{u.y<=o.y&&(s=r,o=u);break}}}return s?{distance:o,hitRegion:s}:void 0}function wn(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Cn(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:lt(e),b:lt(t)};let s;for(;n.a.at(-1)===n.b.at(-1);)s=n.a.pop(),n.b.pop();k(s,"Stacking order can only be calculated for elements with a common ancestor");const o={a:at(it(n.a)),b:at(it(n.b))};if(o.a===o.b){const r=s.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=r.length;for(;a--;){const i=r[a];if(i===u.a)return 1;if(i===u.b)return-1}}return Math.sign(o.a-o.b)}const Ln=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Pn(e){const t=getComputedStyle(Et(e)??e).display;return t==="flex"||t==="inline-flex"}function En(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Pn(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"||Ln.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function it(e){let t=e.length;for(;t--;){const n=e[t];if(k(n,"Missing node"),En(n))return n}return null}function at(e){return e&&Number(getComputedStyle(e).zIndex)||0}function lt(e){const t=[];for(;e;)t.push(e),e=Et(e);return t}function Et(e){const{parentNode:t}=e;return wn(t)?t.host:t}function Rn(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 Mn({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!vt(n)||n.contains(e)||e.contains(n))return!0;if(Cn(n,e)>0){let s=n;for(;s;){if(s.contains(e))return!0;if(Rn(s.getBoundingClientRect(),t))return!1;s=s.parentElement}}return!0}function Be(e,t){const n=[];return t.forEach((s,o)=>{if(o.disabled)return;const r=yt(o),u=zn(o.orientation,r,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&Mn({groupElement:o.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function kn(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 A(e,t,n=0){return Math.abs(F(e)-F(t))<=n}function V(e,t){return A(e,t)?0:e>t?1:-1}function ue({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:s}){const{collapsedSize:o=0,collapsible:r,disabled:u,maxSize:a=100,minSize:i=0}=t;if(u&&!e)return n;if(V(s,i)<0)if(r){const l=(o+i)/2;V(s,l)<0?s=o:s=i}else s=i;return s=Math.min(a,s),s=F(s),s}function ye({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:s,prevLayout:o,trigger:r}){if(A(e,0))return t;const u=r==="imperative-api",a=Object.values(t),i=Object.values(o),l=[...a],[d,h]=s;k(d!=null,"Invalid first pivot index"),k(h!=null,"Invalid second pivot index");let f=0;switch(r){case"keyboard":{{const c=e<0?h:d,m=n[c];k(m,`Panel constraints not found for index ${c}`);const{collapsedSize:p=0,collapsible:y,minSize:S=0}=m;if(y){const b=a[c];if(k(b!=null,`Previous layout not found for panel index ${c}`),A(b,p)){const g=S-b;V(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const c=e<0?d:h,m=n[c];k(m,`No panel constraints found for index ${c}`);const{collapsedSize:p=0,collapsible:y,minSize:S=0}=m;if(y){const b=a[c];if(k(b!=null,`Previous layout not found for panel index ${c}`),A(b,S)){const g=b-p;V(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}break}default:{const c=e<0?h:d,m=n[c];k(m,`Panel constraints not found for index ${c}`);const p=a[c],{collapsible:y,collapsedSize:S,minSize:b}=m;if(y&&V(p,b)<0)if(e>0){const g=b-S,M=g/2,E=p+e;V(E,b)<0&&(e=V(e,M)<=0?0:g)}else{const g=b-S,M=100-g/2,E=p-e;V(E,b)<0&&(e=V(100+e,M)>0?0:-g)}break}}{const c=e<0?1:-1;let m=e<0?h:d,p=0;for(;;){const S=a[m];k(S!=null,`Previous layout not found for panel index ${m}`);const b=ue({overrideDisabledPanels:u,panelConstraints:n[m],prevSize:S,size:100})-S;if(p+=b,m+=c,m<0||m>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-y:y}{let c=e<0?d:h;for(;c>=0&&c<n.length;){const m=Math.abs(e)-Math.abs(f),p=a[c];k(p!=null,`Previous layout not found for panel index ${c}`);const y=p-m,S=ue({overrideDisabledPanels:u,panelConstraints:n[c],prevSize:p,size:y});if(!A(p,S)&&(f+=p-S,l[c]=S,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?c--:c++}}if(kn(i,l))return o;{const c=e<0?h:d,m=a[c];k(m!=null,`Previous layout not found for panel index ${c}`);const p=m+f,y=ue({overrideDisabledPanels:u,panelConstraints:n[c],prevSize:m,size:p});if(l[c]=y,!A(y,p)){let S=p-y,b=e<0?h:d;for(;b>=0&&b<n.length;){const g=l[b];k(g!=null,`Previous layout not found for panel index ${b}`);const M=g+S,E=ue({overrideDisabledPanels:u,panelConstraints:n[b],prevSize:g,size:M});if(A(g,E)||(S-=E-g,l[b]=E),A(S,0))break;e>0?b--:b++}}}const w=Object.values(l).reduce((c,m)=>m+c,0);if(!A(w,100,.1))return o;const v=Object.keys(o);return l.reduce((c,m,p)=>(c[v[p]]=m,c),{})}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||V(e[n],t[n])!==0)return!1;return!0}function se({layout:e,panelConstraints:t}){const n=Object.values(e),s=[...n],o=s.reduce((a,i)=>a+i,0);if(s.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${s.map(a=>`${a}%`).join(", ")}`);if(!A(o,100)&&s.length>0)for(let a=0;a<t.length;a++){const i=s[a];k(i!=null,`No layout data found for index ${a}`);const l=100/o*i;s[a]=l}let r=0;for(let a=0;a<t.length;a++){const i=n[a];k(i!=null,`No layout data found for index ${a}`);const l=s[a];k(l!=null,`No layout data found for index ${a}`);const d=ue({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:i,size:l});l!=d&&(r+=l-d,s[a]=d)}if(!A(r,0))for(let a=0;a<t.length;a++){const i=s[a];k(i!=null,`No layout data found for index ${a}`);const l=i+r,d=ue({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:i,size:l});if(i!==d&&(r-=d-i,s[a]=d,A(r,0)))break}const u=Object.keys(e);return s.reduce((a,i,l)=>(a[u[l]]=i,a),{})}function Rt({groupId:e,panelId:t}){const n=()=>{const i=Q();for(const[l,{defaultLayoutDeferred:d,derivedPanelConstraints:h,layout:f,groupSize:w,separatorToPanels:v}]of i)if(l.id===e)return{defaultLayoutDeferred:d,derivedPanelConstraints:h,group:l,groupSize:w,layout:f,separatorToPanels:v};throw Error(`Group ${e} not found`)},s=()=>{const i=n().derivedPanelConstraints.find(l=>l.panelId===t);if(i!==void 0)return i;throw Error(`Panel constraints not found for Panel ${t}`)},o=()=>{const i=n().group.panels.find(l=>l.id===t);if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},r=()=>{const i=n().layout[t];if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:i,panels:l,prevLayout:d,derivedPanelConstraints:h})=>{const f=r(),w=l.findIndex(m=>m.id===t),v=w===0,c=w===l.length-1;if(c&&i<f&&(v||l.slice(0,w).every((m,p)=>{const y=h[p];return(y==null?void 0:y.collapsible)&&A(y.collapsedSize,d[y.panelId])}))){const m=l.slice(0,w).reduce((p,y)=>p+d[y.id],0);return{...d,[t]:F(100-m)}}return ye({delta:c?f-i:i-f,initialLayout:d,panelConstraints:h,pivotIndices:c?[w-1,w]:[w,w+1],prevLayout:d,trigger:"imperative-api"})},a=i=>{const l=r();if(i===l)return;const{defaultLayoutDeferred:d,derivedPanelConstraints:h,group:f,groupSize:w,layout:v,separatorToPanels:c}=n(),m=u({nextSize:i,panels:f.panels,prevLayout:v,derivedPanelConstraints:h}),p=se({layout:m,panelConstraints:h});ne(v,p)||J(f,{defaultLayoutDeferred:d,derivedPanelConstraints:h,groupSize:w,layout:p,separatorToPanels:c})};return{collapse:()=>{const{collapsible:i,collapsedSize:l}=s(),{mutableValues:d}=o(),h=r();i&&h!==l&&(d.expandToSize=h,a(l))},expand:()=>{const{collapsible:i,collapsedSize:l,minSize:d}=s(),{mutableValues:h}=o(),f=r();if(i&&f===l){let w=h.expandToSize??d;w===0&&(w=1),a(w)}},getSize:()=>{const{group:i}=n(),l=r(),{element:d}=o(),h=i.orientation==="horizontal"?d.offsetWidth:d.offsetHeight;return{asPercentage:l,inPixels:h}},isCollapsed:()=>{const{collapsible:i,collapsedSize:l}=s(),d=r();return i&&A(l,d)},resize:i=>{const{group:l}=n(),{element:d}=o(),h=fe({group:l}),f=ve({groupSize:h,panelElement:d,styleProp:i}),w=F(f/h*100);a(w)}}}function ut(e){if(e.defaultPrevented)return;const t=Q();Be(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const s=n.panels.find(o=>o.panelConstraints.defaultSize!==void 0);if(s){const o=s.panelConstraints.defaultSize,r=Rt({groupId:n.group.id,panelId:s.id});r&&o!==void 0&&(r.resize(o),e.preventDefault())}}})}function Pe(e){const t=Q();for(const[n]of t)if(n.separators.some(s=>s.element===e))return n;throw Error("Could not find parent Group for separator element")}function Mt({groupId:e}){const t=()=>{const n=Q();for(const[s,o]of n)if(s.id===e)return{group:s,...o};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:s}=t();return n?{}:s},setLayout(n){const{defaultLayoutDeferred:s,derivedPanelConstraints:o,group:r,groupSize:u,layout:a,separatorToPanels:i}=t(),l=se({layout:n,panelConstraints:o});return s?a:(ne(a,l)||J(r,{defaultLayoutDeferred:s,derivedPanelConstraints:o,groupSize:u,layout:l,separatorToPanels:i}),l)}}}function ee(e,t){const n=Pe(e),s=K(n.id,!0),o=n.separators.find(d=>d.element===e);k(o,"Matching separator not found");const r=s.separatorToPanels.get(o);k(r,"Matching panels not found");const u=r.map(d=>n.panels.indexOf(d)),a=Mt({groupId:n.id}).getLayout(),i=ye({delta:t,initialLayout:a,panelConstraints:s.derivedPanelConstraints,pivotIndices:u,prevLayout:a,trigger:"keyboard"}),l=se({layout:i,panelConstraints:s.derivedPanelConstraints});ne(a,l)||J(n,{defaultLayoutDeferred:s.defaultLayoutDeferred,derivedPanelConstraints:s.derivedPanelConstraints,groupSize:s.groupSize,layout:l,separatorToPanels:s.separatorToPanels},{isUserInteraction:!0})}function ct(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Pe(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 s=Pe(t),o=K(s.id,!0),{derivedPanelConstraints:r,layout:u,separatorToPanels:a}=o,i=s.separators.find(f=>f.element===t);k(i,"Matching separator not found");const l=a.get(i);k(l,"Matching panels not found");const d=l[0],h=r.find(f=>f.panelId===d.id);if(k(h,"Panel metadata not found"),h.collapsible){const f=u[d.id],w=h.collapsedSize===f?s.mutableState.expandedPanelSizes[d.id]??h.minSize:h.collapsedSize;ee(t,w-f)}break}case"F6":{e.preventDefault();const s=Pe(t).separators.map(u=>u.element),o=Array.from(s).findIndex(u=>u===e.currentTarget);k(o!==null,"Index not found");const r=e.shiftKey?o>0?o-1:s.length-1:o+1<s.length?o+1:0;s[r].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),ee(t,-100);break}}}function dt(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Q(),n=Be(e,t),s=new Map;let o=!1;n.forEach(r=>{r.separator&&(o||(o=!0,r.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(r.group);u&&s.set(r.group,u.layout)}),de({cursorFlags:0,hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function kt({document:e,event:t,hitRegions:n,initialLayoutMap:s,mountedGroups:o,pointerDownAtPoint:r,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:d,groupSize:h}=l,{orientation:f,panels:w}=d,{disableCursor:v}=d.mutableState;let c=0;r?f==="horizontal"?c=(t.clientX-r.x)/h*100:c=(t.clientY-r.y)/h*100:f==="horizontal"?c=t.clientX<0?-100:100:c=t.clientY<0?-100:100;const m=s.get(d),p=o.get(d);if(!m||!p)return;const{defaultLayoutDeferred:y,derivedPanelConstraints:S,groupSize:b,layout:g,separatorToPanels:M}=p;if(S&&g&&M){const E=ye({delta:c,initialLayout:m,panelConstraints:S,pivotIndices:l.panels.map(j=>w.indexOf(j)),prevLayout:g,trigger:"mouse-or-touch"});if(ne(E,g)){if(c!==0&&!v)switch(f){case"horizontal":{a|=c<0?xt:zt;break}case"vertical":{a|=c<0?wt:Ct;break}}}else J(l.group,{defaultLayoutDeferred:y,derivedPanelConstraints:S,groupSize:b,layout:E,separatorToPanels:M})}});let i=0;t.movementX===0?i|=u&et:i|=a&et,t.movementY===0?i|=u&tt:i|=a&tt,bn(i),Oe(e)}function ft(e){const t=Q(),n=te();switch(n.state){case"active":kt({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function pt(e){var s,o;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(r=>{if(!n.has(r.group))return;const u=K(r.group.id,!0);J(r.group,u,{isUserInteraction:!0})});return}for(const r of t.hitRegions)if(r.separator){const{element:u}=r.separator;(s=u.hasPointerCapture)!=null&&s.call(u,e.pointerId)||((o=u.setPointerCapture)==null||o.call(u,e.pointerId))}kt({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const r=Be(e,n);r.length===0?t.state!=="inactive"&&de({cursorFlags:0,state:"inactive"}):de({cursorFlags:0,hitRegions:r,state:"hover"}),Oe(e.currentTarget);break}}}function ht(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(te().state){case"hover":de({cursorFlags:0,state:"inactive"})}}function gt(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||Pt(e.currentTarget)&&e.preventDefault()}function mt(e){let t=0,n=0;const s={};for(const r of e)if(r.defaultSize!==void 0){t++;const u=F(r.defaultSize);n+=u,s[r.panelId]=u}else s[r.panelId]=void 0;const o=e.length-t;if(o!==0){const r=F((100-n)/o);for(const u of e)u.defaultSize===void 0&&(s[u.panelId]=r)}return s}function Dn(e,t,n){if(!n[0])return;const s=e.panels.find(i=>i.element===t);if(!s||!s.onResize)return;const o=fe({group:e}),r=e.orientation==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,u=s.mutableValues.prevSize,a={asPercentage:F(r/o*100),inPixels:r};s.mutableValues.prevSize=a,s.onResize(a,s.id,u)}function In(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 Tn(e,t){return e.length!==t.length?!1:e.every((n,s)=>In(n,t[s]))}function jn({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:s}){if(n<=0||t<=0||n===t)return s;let o=0,r=0,u=!1;const a=new Map,i=[];for(const h of e.panels){const f=s[h.id]??0;switch(h.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const w=f/100*n,v=F(w/t*100);a.set(h.id,v),o+=v;break}case"preserve-relative-size":default:{i.push(h.id),r+=f;break}}}if(!u||i.length===0)return s;const l=100-o,d={...s};if(a.forEach((h,f)=>{d[f]=h}),r>0)for(const h of i){const f=s[h]??0;d[h]=F(f/r*l)}else{const h=F(l/i.length);for(const f of i)d[f]=h}return d}function Nn(e,t){const n=e.map(o=>o.id),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of n)if(!s.includes(o))return!1;return!0}const le=new Map;function An(e){let t=!0;k(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,s=new Set,o=new Set,r=new n(v=>{for(const c of v){const{borderBoxSize:m,target:p}=c;if(p===e.element){if(t){const y=fe({group:e});if(y===0)return;const S=K(e.id);if(!S)return;const b=je(e),g=S.defaultLayoutDeferred?mt(b):S.layout,M=jn({group:e,nextGroupSize:y,prevGroupSize:S.groupSize,prevLayout:g}),E=se({layout:M,panelConstraints:b});if(!S.defaultLayoutDeferred&&ne(S.layout,E)&&Tn(S.derivedPanelConstraints,b)&&S.groupSize===y)continue;J(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:b,groupSize:y,layout:E,separatorToPanels:S.separatorToPanels})}}else Dn(e,p,m)}});r.observe(e.element),e.panels.forEach(v=>{k(!s.has(v.id),`Panel ids must be unique; id "${v.id}" was used more than once`),s.add(v.id),v.onResize&&r.observe(v.element)});const u=fe({group:e}),a=je(e),i=e.panels.map(({id:v})=>v).join(",");let l=e.mutableState.defaultLayout;l&&(Nn(e.panels,l)||(l=void 0));const d=e.mutableState.layouts[i]??l??mt(a),h=se({layout:d,panelConstraints:a}),f=e.element.ownerDocument;le.set(f,(le.get(f)??0)+1);const w=new Map;return yt(e).forEach(v=>{v.separator&&w.set(v.separator,v.panels)}),J(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:h,separatorToPanels:w}),e.separators.forEach(v=>{k(!o.has(v.id),`Separator ids must be unique; id "${v.id}" was used more than once`),o.add(v.id),v.element.addEventListener("keydown",ct)}),le.get(f)===1&&(f.addEventListener("contextmenu",rt,!0),f.addEventListener("dblclick",ut,!0),f.addEventListener("pointerdown",dt,!0),f.addEventListener("pointerleave",ft),f.addEventListener("pointermove",pt),f.addEventListener("pointerout",ht),f.addEventListener("pointerup",gt,!0)),function(){t=!1,le.set(f,Math.max(0,(le.get(f)??0)-1)),xn(e),e.separators.forEach(v=>{v.element.removeEventListener("keydown",ct)}),le.get(f)||(f.removeEventListener("contextmenu",rt,!0),f.removeEventListener("dblclick",ut,!0),f.removeEventListener("pointerdown",dt,!0),f.removeEventListener("pointerleave",ft),f.removeEventListener("pointermove",pt),f.removeEventListener("pointerout",ht),f.removeEventListener("pointerup",gt,!0)),r.disconnect()}}function Fn(){const[e,t]=x.useState({}),n=x.useCallback(()=>t({}),[]);return[e,n]}function $e(e){const t=x.useId();return`${e??t}`}const oe=typeof window<"u"?x.useLayoutEffect:x.useEffect;function be(e){const t=x.useRef(e);return oe(()=>{t.current=e},[e]),x.useCallback((...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[t])}function He(...e){return be(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function We(e){const t=x.useRef({...e});return oe(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Dt=x.createContext(null);function On(e,t){const n=x.useRef({getLayout:()=>({}),setLayout:yn});x.useImperativeHandle(t,()=>n.current,[]),oe(()=>{Object.assign(n.current,Mt({groupId:e}))})}function It({children:e,className:t,defaultLayout:n,disableCursor:s,disabled:o,elementRef:r,groupRef:u,id:a,onLayoutChange:i,onLayoutChanged:l,orientation:d="horizontal",resizeTargetMinimumSize:h={coarse:20,fine:10},style:f,...w}){const v=x.useRef({onLayoutChange:{},onLayoutChanged:{}}),c=be(L=>{ne(v.current.onLayoutChange,L)||(v.current.onLayoutChange=L,i==null||i(L))}),m=be((L,P)=>{ne(v.current.onLayoutChanged,L)||(v.current.onLayoutChanged=L,l==null||l(L,{isUserInteraction:P}))}),p=$e(a),y=x.useRef(null),[S,b]=Fn(),g=x.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:h,separators:[]}),M=He(y,r);On(p,u);const E=be((L,P)=>{const I=te(),R=ot(L),D=K(L);if(D){let N=!1;switch(I.state){case"active":{N=I.hitRegions.some(Y=>Y.group===R);break}}return{flexGrow:D.layout[P]??1,pointerEvents:N?"none":void 0}}if(n!=null&&n[P])return{flexGrow:n==null?void 0:n[P]}}),j=We({defaultLayout:n,disableCursor:s}),$=x.useMemo(()=>({get disableCursor(){return!!j.disableCursor},getPanelStyles:E,id:p,orientation:d,registerPanel:L=>{const P=g.current;return P.panels=Ne(d,[...P.panels,L]),b(),()=>{P.panels=P.panels.filter(I=>I!==L),b()}},registerSeparator:L=>{const P=g.current;return P.separators=Ne(d,[...P.separators,L]),b(),()=>{P.separators=P.separators.filter(I=>I!==L),b()}},updatePanelProps:(L,{disabled:P})=>{const I=g.current.panels.find(N=>N.id===L);I&&(I.panelConstraints.disabled=P);const R=ot(p),D=K(p);R&&D&&J(R,{...D,derivedPanelConstraints:je(R)})},updateSeparatorProps:(L,{disabled:P,disableDoubleClick:I})=>{const R=g.current.separators.find(D=>D.id===L);R&&(R.disabled=P,R.disableDoubleClick=I)}}),[E,p,b,d,j]),O=x.useRef(null);return oe(()=>{const L=y.current;if(L===null)return;const P=g.current;let I;if(j.defaultLayout!==void 0&&Object.keys(j.defaultLayout).length===P.panels.length){I={};for(const W of P.panels){const X=j.defaultLayout[W.id];X!==void 0&&(I[W.id]=X)}}const R={disabled:!!o,element:L,id:p,mutableState:{defaultLayout:I,disableCursor:!!j.disableCursor,expandedPanelSizes:g.current.lastExpandedPanelSizes,layouts:g.current.layouts},orientation:d,panels:P.panels,resizeTargetMinimumSize:P.resizeTargetMinimumSize,separators:P.separators};O.current=R;const D=An(R),{defaultLayoutDeferred:N,derivedPanelConstraints:Y,layout:re}=K(R.id,!0);!N&&Y.length>0&&(c(re),m(re,!1));const _=Ge(p,W=>{const{defaultLayoutDeferred:X,derivedPanelConstraints:ie,layout:G}=W.next;if(X||ie.length===0)return;const pe=R.panels.map(({id:B})=>B).join(",");R.mutableState.layouts[pe]=G,ie.forEach(B=>{if(B.collapsible){const{layout:he}=W.prev??{};if(he){const ge=A(B.collapsedSize,G[B.panelId]),ae=A(B.collapsedSize,he[B.panelId]);ge&&!ae&&(R.mutableState.expandedPanelSizes[B.panelId]=he[B.panelId])}}});const Ee=te().state!=="active";c(G),Ee&&m(G,W.isUserInteraction)});return()=>{O.current=null,D(),_()}},[o,p,m,c,d,S,j]),x.useEffect(()=>{const L=O.current;L&&(L.mutableState.defaultLayout=n,L.mutableState.disableCursor=!!s)}),C.jsx(Dt.Provider,{value:$,children:C.jsx("div",{...w,className:t,"data-group":!0,"data-testid":p,id:p,ref:M,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:d==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:d==="horizontal"?"pan-y":"pan-x"},children:e})})}It.displayName="Group";function Ue(){const e=x.useContext(Dt);return k(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Gn(e,t){const{id:n}=Ue(),s=x.useRef({collapse:Te,expand:Te,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Te});x.useImperativeHandle(t,()=>s.current,[]),oe(()=>{Object.assign(s.current,Rt({groupId:n,panelId:e}))})}function Ae({children:e,className:t,collapsedSize:n="0%",collapsible:s=!1,defaultSize:o,disabled:r,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:i,maxSize:l="100%",minSize:d="0%",onResize:h,panelRef:f,style:w,...v}){const c=!!i,m=$e(i),p=We({disabled:r}),y=x.useRef(null),S=He(y,u),{getPanelStyles:b,id:g,orientation:M,registerPanel:E,updatePanelProps:j}=Ue(),$=h!==null,O=be((R,D,N)=>{h==null||h(R,i,N)});oe(()=>{const R=y.current;if(R!==null){const D={element:R,id:m,idIsStable:c,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:$?O:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:s,defaultSize:o,disabled:p.disabled,maxSize:l,minSize:d}};return E(D)}},[a,n,s,o,$,m,c,l,d,O,E,p]),x.useEffect(()=>{j(m,{disabled:r})},[r,m,j]),Gn(m,f);const L=()=>{const R=b(g,m);if(R)return JSON.stringify(R)},P=x.useSyncExternalStore(R=>Ge(g,R),L,L);let I;return P?I=JSON.parse(P):o!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:o}:I={flexGrow:1},C.jsx("div",{...v,"data-disabled":r||void 0,"data-panel":!0,"data-testid":m,id:m,ref:S,style:{...Bn,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:C.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...w,touchAction:M==="horizontal"?"pan-y":"pan-x"},children:e})})}Ae.displayName="Panel";const Bn={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function $n({layout:e,panelConstraints:t,panelId:n,panelIndex:s}){let o,r;const u=e[n],a=t.find(i=>i.panelId===n);if(a){const i=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,d=[s,s+1];r=se({layout:ye({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n],o=se({layout:ye({delta:i-u,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:o,valueMin:r,valueNow:u}}function Tt({children:e,className:t,disabled:n,disableDoubleClick:s,elementRef:o,id:r,style:u,...a}){const i=$e(r),l=We({disabled:n,disableDoubleClick:s}),[d,h]=x.useState({}),[f,w]=x.useState("inactive"),[v,c]=x.useState(!1),m=x.useRef(null),p=He(m,o),{disableCursor:y,id:S,orientation:b,registerSeparator:g,updateSeparatorProps:M}=Ue(),E=b==="horizontal"?"vertical":"horizontal";oe(()=>{const O=m.current;if(O!==null){const L={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:O,id:i},P=g(L),I=vn(D=>{w(D.next.state!=="inactive"&&D.next.hitRegions.some(N=>N.separator===L)?D.next.state:"inactive")}),R=Ge(S,D=>{const{derivedPanelConstraints:N,layout:Y,separatorToPanels:re}=D.next,_=re.get(L);if(_){const W=_[0],X=_.indexOf(W);h($n({layout:Y,panelConstraints:N,panelId:W.id,panelIndex:X}))}});return()=>{I(),R(),P()}}},[S,i,g,l]),x.useEffect(()=>{M(i,{disabled:n,disableDoubleClick:s})},[n,s,i,M]);let j;n&&!y&&(j="not-allowed");let $;if(n)$="disabled";else switch(f){case"active":{$="active";break}default:v?$="focus":$=f}return C.jsx("div",{...a,"aria-controls":d.valueControls,"aria-disabled":n||void 0,"aria-orientation":E,"aria-valuemax":d.valueMax,"aria-valuemin":d.valueMin,"aria-valuenow":d.valueNow,children:e,className:t,"data-separator":$,"data-testid":i,id:i,onBlur:()=>c(!1),onFocus:()=>c(!0),ref:p,role:"separator",style:{flexBasis:"auto",cursor:j,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Tt.displayName="Separator";async function Hn({fetchPage:e}){const t=[];let n;do{const s=await e(n);t.push(...s.data),n=s.nextPageToken}while(n!=null&&n.length>0);return t}var Wn="96px";function Le(e){var n;const t=(n=e.title)==null?void 0:n.trim();return t!=null&&t.length>0?t:"Untitled session"}function Un(e){return"isMutable"in e&&typeof Reflect.get(e,"isMutable")=="boolean"?Reflect.get(e,"isMutable")===!0:e.agentName==null}function Vn(e){return"sourceType"in e&&Reflect.get(e,"sourceType")==="schedule"?"schedule":void 0}function Xn({agentId:e,startTimestamp:t,endTimestamp:n,shareView:s,detailOnly:o=!1,detailSessionId:r,onCloseDetail:u,onLoadRecentSessions:a}){const i=Ut(),l=Vt(),d=qt(),h=Yt(),f=_t(),{sessionId:w,updateShareSearch:v}=Xt(),c=o?r??null:w,m=ke("AgentSessionListRow"),p=ke("AgentSessionDetailHeader"),y=ke("AgentSessionTimelineContainer"),[S,b]=x.useState([]),[g,M]=x.useState(),[E,j]=x.useState(!0),[$,O]=x.useState(!1),[L,P]=x.useState(!1),[I,R]=x.useState(!1),D=x.useRef(0),N=x.useRef(!1),[Y,re]=x.useState(null),[_,W]=x.useState(null),[X,ie]=x.useState(),[G,pe]=x.useState(),[Ee,B]=x.useState(!1),[he,ge]=x.useState(!1),[ae,Se]=x.useState(null),jt=typeof l.deleteSession=="function",Nt=x.useMemo(()=>{const z=new Set(S.map(T=>T.id));return c!=null&&c.length>0&&z.add(c),[...z]},[S,c]),{allows:xe}=Jt({resourceType:"session",resourceIds:Nt}),Re=xe(c,"MANAGE"),ze=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 z=++D.current;let T=!1;return N.current=!1,M(void 0),o?(b([]),j(!1),O(!1),P(!1),R(!1),()=>{T=!0}):(j(!0),O(!1),P(!1),R(!1),i.listSessions(ze).then(U=>{T||D.current!==z||(b(U.data),M(U.nextPageToken))}).catch(()=>{T||D.current!==z||(b([]),M(void 0),R(!0))}).finally(()=>{!T&&D.current===z&&j(!1)}),()=>{T=!0})},[o,ze,i]);const Me=x.useCallback(async()=>{if(E||g==null||N.current)return;const z=D.current;N.current=!0,O(!0),P(!1);try{const T=await i.listSessions({...ze,pageToken:g});if(D.current!==z)return;b(U=>[...U,...T.data]),M(T.nextPageToken)}catch{D.current===z&&P(!0)}finally{D.current===z&&(N.current=!1,O(!1))}},[E,ze,g,i]);x.useEffect(()=>{if(E||g==null||Y==null||_==null)return;const z=new IntersectionObserver(T=>{T.some(U=>U.isIntersecting)&&Me()},{root:Y,rootMargin:Wn});return z.observe(_),()=>z.disconnect()},[S.length,Y,E,Me,g,_]),x.useEffect(()=>{if(c==null||c.length===0){ie(void 0),pe(void 0),ge(!1),B(!1);return}let z=!1;return B(!0),ge(!1),ie(void 0),pe(void 0),Promise.all([Hn({fetchPage:T=>i.listSessionEvents({sessionId:c,limit:100,...T==null?{}:{pageToken:T}})}),l.getSession({sessionId:c})]).then(([T,U])=>{z||(ie([...T].reverse()),pe(U))}).catch(T=>{if(!z){if(Wt({error:T,...d!=null?{showError:d.showError}:{}}),o){u==null||u();return}ge(!0)}}).finally(()=>{z||B(!1)}),()=>{z=!0}},[l,o,u,c,i,d]);const At=z=>{const T=s==="sessions"?an(z.createdAt):null;v({sessionId:z.id,...s==="sessions"?{view:"sessions",...T==null?{}:{timeRange:T}}:{agentId:e??null,tab:"sessions",view:null,timeRange:null}})},Ft=()=>{if(c!=null){if(o){u==null||u();return}v({sessionId:null})}},Ot=async z=>{if(!(!xe(z.id,"DELETE")||typeof l.deleteSession!="function")){Se(null);try{await l.deleteSession({sessionId:z.id}),b(T=>T.filter(U=>U.id!==z.id)),c===z.id&&v({sessionId:null})}catch(T){d==null||d.showError(T)}}},H=S.find(z=>z.id===c),Gt=G!=null?Le(G):H!=null?Le(H):c??"Untitled session",Ve=G!=null?Qe(G):H!=null?Qe(H):!1,Bt=G!=null?G.isMutable:H!=null?Un(H):!0,qe=Ve?"Resume Agent building":"Resume Chat",Ye=c!=null&&f!=null?Zt({sessionId:c,routes:f}):null,$t=()=>{if(!Re||c==null||h==null)return;const z=(G==null?void 0:G.agentName)??(H==null?void 0:H.agentName);h.openHistorySession({sessionId:c,isMutable:Bt,isCreateAgent:Ve,...z!=null&&z.length>0?{agentName:z}:{}})},Ht=Ye!=null?{resumeHref:Ye,resumeLabel:qe}:h!=null?{onResume:$t,resumeLabel:qe}:{},_e=C.jsx("section",{className:"flex h-full min-w-0 flex-col bg-primary-bg",children:c==null?C.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Select a session to view details"}):he?C.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session details could not be loaded."}):C.jsxs(C.Fragment,{children:[C.jsx(p,{title:Gt,sessionId:c,onClose:Ft,canResume:Re,canShare:Re,...Ht}),Ee||X===void 0?C.jsx("div",{className:"flex flex-1 flex-col p-4",role:"status","aria-label":"Loading session details",children:C.jsx(De,{className:"min-h-64 flex-1 rounded-lg"})}):C.jsx(y,{sessionId:c,events:X,listMetrics:H==null?void 0:H.metrics,...o?{contentMaxWidth:"60rem"}:{}})]})});return o?C.jsx("div",{className:"h-full min-h-0 w-full",children:_e}):!E&&!I&&S.length===0&&(c==null||c.length===0)&&a==null?C.jsx(Kt,{title:"No Sessions Found",description:"There are no sessions available at the moment.",className:"bg-primary-bg"}):C.jsxs(It,{id:"agent-sessions-split",orientation:"horizontal",className:"h-full min-h-0 w-full",resizeTargetMinimumSize:{coarse:24,fine:11},children:[C.jsx(Ae,{id:"agent-sessions-list",defaultSize:"35%",minSize:"20%",maxSize:"50%",children:C.jsxs("aside",{className:"flex h-full min-h-0 w-full flex-col bg-sidebar-bg",children:[a!=null?C.jsx("div",{className:"flex shrink-0 justify-center border-b border-border p-3",children:C.jsx(Ie.Secondary,{type:"button",size:"small",onClick:a,children:"Load recent sessions"})}):null,C.jsxs("div",{ref:re,className:"scrollbar-none min-h-0 flex-1 overflow-y-auto",children:[E?C.jsx("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading sessions",children:["a","b","c"].map(z=>C.jsx(De,{className:"h-16 rounded-md"},z))}):I?C.jsx("p",{className:"px-3 py-6 text-center text-xs text-text-secondary",children:"Sessions could not be loaded."}):S.map(z=>C.jsx(m,{title:Le(z),agentName:z.agentName??void 0,sourceType:Vn(z),lastActivityAt:z.lastActivityAt,metrics:z.metrics,active:z.id===c,onSelect:()=>At(z),...jt?{onRequestDelete:()=>Se(z),canDelete:xe(z.id,"DELETE")}:{}},z.id)),g!=null&&!E&&!I?C.jsx("div",{ref:W,className:"px-3 py-2",children:$?C.jsx(De,{className:"h-16 rounded-md",role:"status","aria-label":"Loading more sessions"}):L?C.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 Me(),children:"Retry loading sessions"}):null}):null]})]})}),C.jsxs(Tt,{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:[C.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 -left-1.25 w-2.75"}),C.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-px bg-border transition-colors"}),C.jsx("div",{"aria-hidden":!0,className:en("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:C.jsx(Qt,{name:"grip-vertical",size:10})})]}),C.jsx(Ae,{id:"agent-session-detail",defaultSize:"65%",minSize:"30%",children:_e}),ae!=null?C.jsxs(tn,{open:!0,onOpenChange:z=>{z||Se(null)},"aria-label":"Delete session",className:"max-w-md",children:[C.jsx(nn,{children:C.jsxs(sn,{children:[C.jsx(on,{children:"Delete session"}),C.jsxs("p",{className:"text-text-secondary text-sm",children:["“",Le(ae),"” will be permanently deleted. This cannot be undone."]})]})}),C.jsxs(rn,{children:[C.jsx(Ie.Secondary,{type:"button",onClick:()=>Se(null),children:"Cancel"}),C.jsx(Ie.Destructive,{type:"button",disabled:!xe(ae.id,"DELETE"),onClick:()=>void Ot(ae),children:"Delete"})]})]}):null]})}export{Xn as AgentSessions};
@@ -1 +1 @@
1
- import{aU as ee,N as ce,r as a,aV as U,j as e,U as me,W as z,I as w,aX as te,aq as _,a$ as ue,e as T,aW as J}from"./index-CPHXhr9t.js";var xe=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],G=_("h-11 shadow-sm"),L=()=>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,A]=a.useState("dcr"),[C,F]=a.useState(""),[k,S]=a.useState(""),u=r!==void 0,d=_(`h-11 shadow-sm ${u?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{y(""),g(""),m(""),A("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)??""),A((r==null?void 0:r.auth.type)??"dcr"),F(""),S((r==null?void 0:r.auth.type)==="header"?r.auth.headerName??"":""))},[r,n]);const O=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 D=o==="header"?{type:"header",apiKey:C.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:o};try{await h({name:b.trim(),url:j.trim(),description:N.trim(),auth:D}),i(),p(!1)}catch{}};return e.jsx(te,{open:n,onOpenChange:O,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(L,{})]}),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(L,{})]}),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:_("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(L,{})]}),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:G})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(L,{})]}),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:()=>{A(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(L,{})]}),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:"Bearer <Paste the token from the provider>","aria-describedby":"mcp-server-api-key-hint",className:G}),e.jsx("p",{id:"mcp-server-api-key-hint",className:"mt-1.5 text-xs text-text-secondary",children:`This is the value for the "${k.trim()||"Authorization"}" header.`})]}),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:k,onChange:l=>{S(l.target.value)},placeholder:"Authorization",className:G})]})]}):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,W={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),[A,C]=a.useState(null),[F,k]=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(U(i,"Failed to load connector tools"))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[n.authenticated,n.id,b]);const S=async()=>{k(!0),C(null);try{const d=await b.getConnector({id:n.id});h(d)}catch(d){C(U(d,"Failed to refresh connector details"))}finally{k(!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:W[n.auth.type]??W.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…"}):A?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:[A,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,A]=a.useState(!1),[C,F]=a.useState([]),[k,S]=a.useState(!1),[u,d]=a.useState(null),[i,O]=a.useState(null),[I,E]=a.useState(null),[P,l]=a.useState(""),D=a.useMemo(()=>(C??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[C]),K=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)),V=[...c.map(x=>({connector:x,isConfigured:!0})),...s.filter(x=>!M.has(x.id)).map(x=>({connector:x,isConfigured:!1}))];v({ordered:V,authStatusById:new Map(V.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(U(t,"Failed to load connectors"))}finally{y(!1)}},[n]);a.useEffect(()=>{K()},[K]);const B=h.trim().toLowerCase(),q=a.useMemo(()=>B?f.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(B)||(((s=t.description)==null?void 0:s.toLowerCase().includes(B))??!1)||t.url.toLowerCase().includes(B)}):f.ordered,[f.ordered,B]),$=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]),R=a.useMemo(()=>{const t=[];for(const s of q)s.isConfigured||t.push(s.connector);return t},[q]),H=async(t,s=g)=>{A(!0),g(null);try{await t(),await K()}catch(c){throw s(U(c,"Request failed")),c}finally{A(!1)}},Q=()=>{O(null),l(""),m(null)},X=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),O(t);return}H(async()=>{await X(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 X(s,c),Q(),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}),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=D[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(J,{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:()=>{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=D[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(J,{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:W[t.auth.type]??W.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:k,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Y,connector:u??void 0,busy:o,error:N})]});const de=$.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"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&&$.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 · ",$.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:$.map(t=>le(t))})]}):null,!b&&R.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 · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.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||Q()},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:`Bearer <Paste the token from ${(i==null?void 0:i.name)??"the provider"}>`,autoFocus:!0,required:!0,className:_("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:Q,disabled:o,children:"Cancel"}),e.jsx(z.Primary,{type:"submit",disabled:!P.trim()||o,children:"Connect"})]})]})}),e.jsx(Z,{open:k,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
+ import{aR as ee,q as ce,r as a,aS as _,j as e,W as me,Z as z,I as w,aU as te,an as U,aY as ue,g as T,aT as J}from"./index-eDNLQ9X2.js";var xe=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],G=U("h-11 shadow-sm"),L=()=>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,A]=a.useState("dcr"),[C,F]=a.useState(""),[k,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(""),A("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)??""),A((r==null?void 0:r.auth.type)??"dcr"),F(""),S((r==null?void 0:r.auth.type)==="header"?r.auth.headerName??"":""))},[r,n]);const O=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 D=o==="header"?{type:"header",apiKey:C.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:o};try{await h({name:b.trim(),url:j.trim(),description:N.trim(),auth:D}),i(),p(!1)}catch{}};return e.jsx(te,{open:n,onOpenChange:O,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(L,{})]}),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(L,{})]}),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(L,{})]}),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:G})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(L,{})]}),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:()=>{A(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(L,{})]}),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:"Bearer <Paste the token from the provider>","aria-describedby":"mcp-server-api-key-hint",className:G}),e.jsx("p",{id:"mcp-server-api-key-hint",className:"mt-1.5 text-xs text-text-secondary",children:`This is the value for the "${k.trim()||"Authorization"}" header.`})]}),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:k,onChange:l=>{S(l.target.value)},placeholder:"Authorization",className:G})]})]}):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"})]})]})})},X=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),[A,C]=a.useState(null),[F,k]=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()=>{k(!0),C(null);try{const d=await b.getConnector({id:n.id});h(d)}catch(d){C(_(d,"Failed to refresh connector details"))}finally{k(!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: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…"}):A?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:[A,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,A]=a.useState(!1),[C,F]=a.useState([]),[k,S]=a.useState(!1),[u,d]=a.useState(null),[i,O]=a.useState(null),[I,E]=a.useState(null),[P,l]=a.useState(""),D=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)),Y=[...c.map(x=>({connector:x,isConfigured:!0})),...s.filter(x=>!M.has(x.id)).map(x=>({connector:x,isConfigured:!1}))];v({ordered:Y,authStatusById:new Map(Y.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 B=h.trim().toLowerCase(),q=a.useMemo(()=>B?f.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(B)||(((s=t.description)==null?void 0:s.toLowerCase().includes(B))??!1)||t.url.toLowerCase().includes(B)}):f.ordered,[f.ordered,B]),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)=>{A(!0),g(null);try{await t(),await Q()}catch(c){throw s(_(c,"Request failed")),c}finally{A(!1)}},W=()=>{O(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),O(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),W(),setTimeout(()=>{p==null||p.showSuccess({title:`${s.name} connected`})},100)},m).catch(()=>{})},Z=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=D[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(J,{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:()=>{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=D[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(J,{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:()=>{E(null)},onConnectorRefreshed:ne,onEdit:()=>{m(null),d(I),S(!0)},onDisconnect:()=>{re(I)}}),e.jsx(X,{open:k,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Z,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||W()},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:`Bearer <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:W,disabled:o,children:"Cancel"}),e.jsx(z.Primary,{type:"submit",disabled:!P.trim()||o,children:"Connect"})]})]})}),e.jsx(X,{open:k,onOpenChange:t=>{S(t),t||(d(null),m(null))},onSubmit:Z,connector:u??void 0,busy:o,error:N})]})})]})},je=ge;export{je as default};
@@ -1 +1 @@
1
- import{S as a}from"./chunk-YN5ZBBQM-C6IH83Y_.js";import{j as o,C as t,e as l}from"./index-CPHXhr9t.js";import"./chunk-TFQWCBFQ-CObdB7gd.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-FYQP67GV-BjaXnOYn.js";import{j as o,C as t,g as l}from"./index-eDNLQ9X2.js";import"./chunk-WOPPIMOW-r3_Xqwsn.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-RGEYBYPN-B0-R3y76.js","./index-eDNLQ9X2.js","./index-B01pXqvC.css","./SchedulesPage-SIJSKRWV-ZmB5E6Lh.js"])))=>i.map(i=>d[i]);
2
+ import{u as I,b as L,c as B,d as t,r as a,e as z,s as k,j as s,P as D,I as c,f as l,S as g,g as T,_ as p}from"./index-eDNLQ9X2.js";import{A as R,S as V,N as F,T as M}from"./chunk-WOPPIMOW-r3_Xqwsn.js";var H=a.lazy(()=>p(()=>import("./SettingsBuilder-RGEYBYPN-B0-R3y76.js"),__vite__mapDeps([0,1,2]),import.meta.url)),U=a.lazy(()=>p(()=>import("./SchedulesPage-SIJSKRWV-ZmB5E6Lh.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(i=>({default:i.SchedulesPage})));function J({className:i}){const f=I(),e=L(),u=B(),b=t("ClearChatButton"),j=t("AgentDetailsPage"),y=t("AgentsLibrary"),A=t("SessionsPage"),h=t("ShareChatButton"),C=t("SaveAgentButton"),S=t("SelectAgentEmptyState"),w=t("UserAvatar"),N=a.useRef(null),v=(e==null?void 0:e.mode.status)==="idle",d=(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=d||n||m||o,O=z(),_=e!=null&&k(e.mode)&&!r&&(!u||e.agentConfigOpen),x=(e==null?void 0:e.isNewChatEnabled)!==!1,E=()=>{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(()=>{})},P=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("div",{className:T("relative flex h-full min-h-0 w-full bg-primary-bg",i),children:[_?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(R,{showClose:u})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(D,{className:"bg-topbar-bg",title:r?n||o?s.jsxs("button",{type:"button",className:l({variant:"ghost",size:"small"}),onClick:()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1)},children:[s.jsx(c,{name:"arrow-left"}),"Back to chat"]}):null:s.jsx(F,{}),end:s.jsxs(s.Fragment,{children:[r?null:s.jsxs(s.Fragment,{children:[s.jsx(h,{}),s.jsx(b,{}),s.jsx(C,{})]}),s.jsx(V,{},"shell-actions"),s.jsx(w,{}),r?null:s.jsxs(s.Fragment,{children:[x&&!O?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:l({variant:"ghost",size:"icon"}),onClick:E,children:s.jsx(c,{name:"square-pen"})}):null,x&&(e!=null&&e.isComposerEnabled)?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:l({variant:"ghost",size:"icon"}),onClick:P,children:s.jsx(c,{name:"agent-2"})}):null]})]})}),s.jsx("div",{ref:N,className:"min-h-0 min-w-0 flex-1",children:d?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(H,{})}):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(U,{})}):v?s.jsx(S,{}):s.jsx(M,{})})]})]})}export{J as DrawerLayout};
@@ -1 +1 @@
1
- import{aU as be,N as fe,r as o,aV as J,j as e,U as ge,W as B,I as L,aW as ie,aX as xe,aY as ye,aZ as ve,e as P,a_ as je,aq as Ne}from"./index-CPHXhr9t.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:l,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[U,$]=o.useState(""),[y,x]=o.useState(""),[w,I]=o.useState(!1),M=()=>{$(""),x(""),I(!1)};o.useEffect(()=>{n&&($(""),x(E),I(!1))},[n,E]);const X=i=>{i||M(),l(i)},T=U.trim(),Q=!c||!!T,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:T,baseUrl:y.trim()}),M(),l(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,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:U,onChange: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)=>I(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:!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(l=>{var b,k,p,E,d;return{id:l.id,name:l.name,advancedExpanded:!0,reasoningEfforts:(b=l.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=l.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=l.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],W="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const l=n.trim();if(l==="")return null;const b=Number(l);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}),Ue=({open:n,onOpenChange:l,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=o.useState((c==null?void 0:c.name)??""),[F,U]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[I,M]=o.useState(!1),[X,T]=o.useState(!1),Q=()=>{O((c==null?void 0:c.name)??""),U((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),M(!1),T(!1)},v=s=>{s||Q(),l(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{M(!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 Z=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,G=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!Z(s)&&!te(s)),se=I&&D,H=X&&h,A=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||G(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:$.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-auto flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-auto space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>M(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:P(W,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=>U(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:P(W,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:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:W}),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=Z(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,le=q(s),C=G(s),z=s.contextTouched&&le,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(W,"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(W,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(W,z&&V)}),z?e.jsx(ee,{children:le}):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(W,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 Y;return i(r,{reasoningEfforts:a?(Y=s.reasoningEfforts)==null?void 0:Y.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:!oe||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Me=Ue;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Pe=()=>{const{modelCatalog:n}=be(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,U]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[I,M]=o.useState(null),[X,T]=o.useState(null),[Q,v]=o.useState(null),[i,K]=o.useState(!1),[f,D]=o.useState(null),_=o.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),Z=o.useCallback(async()=>{O(!0),U(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){U(J(t,"Failed to load model providers"))}finally{O(!1)}},[n]);o.useEffect(()=>{Z()},[Z]);const te=o.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=o.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]),G=o.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]),oe=o.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=o.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{M(null),T(null),v(null)},A=async(t,a)=>{w(!0),U(null);try{await t(),await Z(),H()}catch(m){throw a?a(m):l==null?U(J(m,"Request failed")):l.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(J(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(J(m,"Request failed"))),l==null||l.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(J(a,"Request failed"))),setTimeout(()=>{l==null||l.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(J(m,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},le=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=I!=null?p.find(t=>t.id===I)??null:null,z=X!=null?d.find(t=>t.type===X)??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)),Y=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),M(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)),Y.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 · ",Y.length]}),Y.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&&G.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:G.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),M(null),T(t.type)},children:[e.jsx(L,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&G.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:Q}),e.jsx(Me,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:le,onSubmit:f?R:j,reasoningEffortOptions:oe,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Pe;export{ze as default};
1
+ import{aR as be,q as fe,r as o,aS as Y,j as e,W as ge,Z as B,I as L,aT as ie,aU as xe,aV as ye,aW as ve,g as P,aX as je,an as Ne}from"./index-eDNLQ9X2.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:l,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,$]=o.useState(""),[y,x]=o.useState(""),[w,I]=o.useState(!1),U=()=>{$(""),x(""),I(!1)};o.useEffect(()=>{n&&($(""),x(E),I(!1))},[n,E]);const X=i=>{i||U(),l(i)},T=M.trim(),Q=!c||!!T,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:T,baseUrl:y.trim()}),U(),l(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,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.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)=>I(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:!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(l=>{var b,k,p,E,d;return{id:l.id,name:l.name,advancedExpanded:!0,reasoningEfforts:(b=l.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=l.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=l.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],W="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const l=n.trim();if(l==="")return null;const b=Number(l);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:l,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=o.useState((c==null?void 0:c.name)??""),[F,M]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[I,U]=o.useState(!1),[X,T]=o.useState(!1),Q=()=>{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||Q(),l(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 Z=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,G=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!Z(s)&&!te(s)),se=I&&D,H=X&&h,R=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||G(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:$.trim(),models:x.map(r=>{var A;const g={};(A=r.reasoningEfforts)!=null&&A.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-auto flex-col",onSubmit:s=>{s.preventDefault(),R()},children:[e.jsxs("div",{className:"min-h-0 flex-auto space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(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(W,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(W,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:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:W}),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=Z(s),u=s.idTouched&&g,j=te(s),A=!!j&&s.nameDirty,le=q(s),C=G(s),z=s.contextTouched&&le,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(W,"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":A?!0:void 0,className:P(W,A&&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,A?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(W,z&&V)}),z?e.jsx(ee,{children:le}):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(W,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 J;return i(r,{reasoningEfforts:a?(J=s.reasoningEfforts)==null?void 0:J.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:!oe||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(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,M]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[I,U]=o.useState(null),[X,T]=o.useState(null),[Q,v]=o.useState(null),[i,K]=o.useState(!1),[f,D]=o.useState(null),_=o.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),Z=o.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]);o.useEffect(()=>{Z()},[Z]);const te=o.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=o.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]),G=o.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]),oe=o.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=o.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)},R=async(t,a)=>{w(!0),M(null);try{await t(),await Z(),H()}catch(m){throw a?a(m):l==null?M(Y(m,"Request failed")):l.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await R(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 R(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"))),l==null||l.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&R(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{R(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 R(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(()=>{l==null||l.showSuccess({title:`${t.name} added`})},0)},A=async t=>{if(!f)return;const a=f;y(null),await R(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(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},le=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=I!=null?p.find(t=>t.id===I)??null:null,z=X!=null?d.find(t=>t.type===X)??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)),J=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)),J.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 · ",J.length]}),J.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&&G.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:G.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&&G.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:Q}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:le,onSubmit:f?A:j,reasoningEffortOptions:oe,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Pe;export{ze as default};