@truefoundry/trueforge 0.186.0-rc.3 → 0.187.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/dist/_frontend/assets/AgentCodeSnippets-IQBCA7PK-BjFskF44.js +1 -0
  2. package/dist/_frontend/assets/AgentCodeSnippets-IQBCA7PK-BjFskF44.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-IQBCA7PK-BjFskF44.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-TCZEIIUV-DbrMMNdJ.js → AgentMetricChart-7V42QCLW-B6i3t-3u.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-7V42QCLW-B6i3t-3u.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-7V42QCLW-B6i3t-3u.js.gz +0 -0
  7. package/dist/_frontend/assets/AgentOverview-NUS7DF3V-BLN7Mc1A.js +1 -0
  8. package/dist/_frontend/assets/AgentOverview-NUS7DF3V-BLN7Mc1A.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-NUS7DF3V-BLN7Mc1A.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-26TTGY3F-CsLh4dWe.js → AgentSessionEventTimeline-YV5IMM36-CjuIEqY5.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-YV5IMM36-CjuIEqY5.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-YV5IMM36-CjuIEqY5.js.gz +0 -0
  13. package/dist/_frontend/assets/AgentSessionEventTimelineChart-T47VTMR6-cJdpKneN.js +2 -0
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-T47VTMR6-cJdpKneN.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-T47VTMR6-cJdpKneN.js.gz +0 -0
  16. package/dist/_frontend/assets/AgentSessions-JVLIS2OC-DfKqLMq_.js +1 -0
  17. package/dist/_frontend/assets/AgentSessions-JVLIS2OC-DfKqLMq_.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-JVLIS2OC-DfKqLMq_.js.gz +0 -0
  19. package/dist/_frontend/assets/AppearanceSettings-EY2WXRWB-C3VtWEAm.js +1 -0
  20. package/dist/_frontend/assets/AppearanceSettings-EY2WXRWB-C3VtWEAm.js.br +0 -0
  21. package/dist/_frontend/assets/AppearanceSettings-EY2WXRWB-C3VtWEAm.js.gz +0 -0
  22. package/dist/_frontend/assets/ConnectorSettings-X6OHZ6KA-u4N4OWzr.js +1 -0
  23. package/dist/_frontend/assets/ConnectorSettings-X6OHZ6KA-u4N4OWzr.js.br +0 -0
  24. package/dist/_frontend/assets/ConnectorSettings-X6OHZ6KA-u4N4OWzr.js.gz +0 -0
  25. package/dist/_frontend/assets/DockLayout-SEEHTHCB-qMMUFfFT.js +1 -0
  26. package/dist/_frontend/assets/DrawerLayout-DPIUGY42-Bxv9hChU.js +2 -0
  27. package/dist/_frontend/assets/DrawerLayout-DPIUGY42-Bxv9hChU.js.br +0 -0
  28. package/dist/_frontend/assets/DrawerLayout-DPIUGY42-Bxv9hChU.js.gz +0 -0
  29. package/dist/_frontend/assets/EnvironmentsPage-EUA7T7IZ-B9cZm1H2.js +1 -0
  30. package/dist/_frontend/assets/EnvironmentsPage-EUA7T7IZ-B9cZm1H2.js.br +0 -0
  31. package/dist/_frontend/assets/EnvironmentsPage-EUA7T7IZ-B9cZm1H2.js.gz +0 -0
  32. package/dist/_frontend/assets/MemorySettings-7IT3OBVB-CXPWhBSp.js +1 -0
  33. package/dist/_frontend/assets/MemorySettings-7IT3OBVB-CXPWhBSp.js.br +0 -0
  34. package/dist/_frontend/assets/MemorySettings-7IT3OBVB-CXPWhBSp.js.gz +0 -0
  35. package/dist/_frontend/assets/ModelSettings-PNXNGQ5L-ePcg3Aqh.js +1 -0
  36. package/dist/_frontend/assets/ModelSettings-PNXNGQ5L-ePcg3Aqh.js.br +0 -0
  37. package/dist/_frontend/assets/ModelSettings-PNXNGQ5L-ePcg3Aqh.js.gz +0 -0
  38. package/dist/_frontend/assets/SandboxSettings-H5NXXJGM-D5w4szt5.js +1 -0
  39. package/dist/_frontend/assets/SandboxSettings-H5NXXJGM-D5w4szt5.js.br +0 -0
  40. package/dist/_frontend/assets/SandboxSettings-H5NXXJGM-D5w4szt5.js.gz +0 -0
  41. package/dist/_frontend/assets/SchedulesPage-CAQD2Q4F-CO8Z5teK.js +1 -0
  42. package/dist/_frontend/assets/SchedulesPage-CAQD2Q4F-CO8Z5teK.js.br +0 -0
  43. package/dist/_frontend/assets/SchedulesPage-CAQD2Q4F-CO8Z5teK.js.gz +0 -0
  44. package/dist/_frontend/assets/SettingsBuilder-YMBHISA3-BXfV41lI.js +2 -0
  45. package/dist/_frontend/assets/SettingsBuilder-YMBHISA3-BXfV41lI.js.br +0 -0
  46. package/dist/_frontend/assets/SettingsBuilder-YMBHISA3-BXfV41lI.js.gz +0 -0
  47. package/dist/_frontend/assets/ShellRouteSync-RY46ZMDU-9e9CFMDE.js +1 -0
  48. package/dist/_frontend/assets/ShellRouteSync-RY46ZMDU-9e9CFMDE.js.br +0 -0
  49. package/dist/_frontend/assets/ShellRouteSync-RY46ZMDU-9e9CFMDE.js.gz +0 -0
  50. package/dist/_frontend/assets/SidebarLayout-DSB56OFA-CjOToD_g.js +2 -0
  51. package/dist/_frontend/assets/SidebarLayout-DSB56OFA-CjOToD_g.js.br +0 -0
  52. package/dist/_frontend/assets/SidebarLayout-DSB56OFA-CjOToD_g.js.gz +0 -0
  53. package/dist/_frontend/assets/SkillSettings-NVL4XWDS-BYXZ85YV.js +1 -0
  54. package/dist/_frontend/assets/SkillSettings-NVL4XWDS-BYXZ85YV.js.br +0 -0
  55. package/dist/_frontend/assets/SkillSettings-NVL4XWDS-BYXZ85YV.js.gz +0 -0
  56. package/dist/_frontend/assets/{TrueForgeUIWithRouter-LFJ4E5VL-D9VrxQsf.js → TrueForgeUIWithRouter-7O2WTUMN-B1RH13sW.js} +1 -1
  57. package/dist/_frontend/assets/WebSearchSettings-QHDG5HBJ-BnNzyKFb.js +1 -0
  58. package/dist/_frontend/assets/WebSearchSettings-QHDG5HBJ-BnNzyKFb.js.br +0 -0
  59. package/dist/_frontend/assets/WebSearchSettings-QHDG5HBJ-BnNzyKFb.js.gz +0 -0
  60. package/dist/_frontend/assets/WidgetLayout-VSLU2TXO-DRJouw53.js +1 -0
  61. package/dist/_frontend/assets/WidgetLayout-VSLU2TXO-DRJouw53.js.br +0 -0
  62. package/dist/_frontend/assets/WidgetLayout-VSLU2TXO-DRJouw53.js.gz +0 -0
  63. package/dist/_frontend/assets/{chunk-HWOHXUGH-KXcUS5XW.js → chunk-2PBSR643-DucDomKE.js} +1 -1
  64. package/dist/_frontend/assets/chunk-2PBSR643-DucDomKE.js.br +0 -0
  65. package/dist/_frontend/assets/chunk-2PBSR643-DucDomKE.js.gz +0 -0
  66. package/dist/_frontend/assets/chunk-EAY2YDVF-BEYTBRlX.js +2 -0
  67. package/dist/_frontend/assets/chunk-EAY2YDVF-BEYTBRlX.js.br +0 -0
  68. package/dist/_frontend/assets/chunk-EAY2YDVF-BEYTBRlX.js.gz +0 -0
  69. package/dist/_frontend/assets/chunk-KWC2LXMU-DxiqJRhP.js +1 -0
  70. package/dist/_frontend/assets/chunk-KWC2LXMU-DxiqJRhP.js.br +0 -0
  71. package/dist/_frontend/assets/chunk-KWC2LXMU-DxiqJRhP.js.gz +0 -0
  72. package/dist/_frontend/assets/{chunk-OB3PAWPO-Bm8RoZbE.js → chunk-OB3PAWPO-CdLNGkFp.js} +1 -1
  73. package/dist/_frontend/assets/chunk-OB3PAWPO-CdLNGkFp.js.br +0 -0
  74. package/dist/_frontend/assets/chunk-OB3PAWPO-CdLNGkFp.js.gz +0 -0
  75. package/dist/_frontend/assets/chunk-OO6QO7FR-Clj6a-iP.js +1 -0
  76. package/dist/_frontend/assets/chunk-OO6QO7FR-Clj6a-iP.js.br +0 -0
  77. package/dist/_frontend/assets/chunk-OO6QO7FR-Clj6a-iP.js.gz +0 -0
  78. package/dist/_frontend/assets/chunk-XOQYBULH-CRvLiR9N.js +1 -0
  79. package/dist/_frontend/assets/{cssMode-CKX3vknZ.js → cssMode-DuqNkvPv.js} +1 -1
  80. package/dist/_frontend/assets/cssMode-DuqNkvPv.js.br +0 -0
  81. package/dist/_frontend/assets/cssMode-DuqNkvPv.js.gz +0 -0
  82. package/dist/_frontend/assets/{freemarker2-BxWZ5P9I.js → freemarker2-BUfzpeUx.js} +1 -1
  83. package/dist/_frontend/assets/freemarker2-BUfzpeUx.js.br +0 -0
  84. package/dist/_frontend/assets/freemarker2-BUfzpeUx.js.gz +0 -0
  85. package/dist/_frontend/assets/{handlebars-By1rPqIP.js → handlebars-BLeRLDUd.js} +1 -1
  86. package/dist/_frontend/assets/handlebars-BLeRLDUd.js.br +0 -0
  87. package/dist/_frontend/assets/handlebars-BLeRLDUd.js.gz +0 -0
  88. package/dist/_frontend/assets/{html-DV1yPfEc.js → html-wpJwQ7Au.js} +1 -1
  89. package/dist/_frontend/assets/html-wpJwQ7Au.js.br +0 -0
  90. package/dist/_frontend/assets/html-wpJwQ7Au.js.gz +0 -0
  91. package/dist/_frontend/assets/{htmlMode-Elrz_gVm.js → htmlMode-BWjgtyr-.js} +1 -1
  92. package/dist/_frontend/assets/htmlMode-BWjgtyr-.js.br +0 -0
  93. package/dist/_frontend/assets/htmlMode-BWjgtyr-.js.gz +0 -0
  94. package/dist/_frontend/assets/index-DJa8qqht.css +1 -0
  95. package/dist/_frontend/assets/index-DJa8qqht.css.br +0 -0
  96. package/dist/_frontend/assets/index-DJa8qqht.css.gz +0 -0
  97. package/dist/_frontend/assets/{index-aDyvsTqL.js → index-DdfF63OT.js} +432 -397
  98. package/dist/_frontend/assets/index-DdfF63OT.js.br +0 -0
  99. package/dist/_frontend/assets/index-DdfF63OT.js.gz +0 -0
  100. package/dist/_frontend/assets/{index-DUcQ3h0s.js → index-aGz8KXsj.js} +3 -3
  101. package/dist/_frontend/assets/index-aGz8KXsj.js.br +0 -0
  102. package/dist/_frontend/assets/index-aGz8KXsj.js.gz +0 -0
  103. package/dist/_frontend/assets/{javascript-DItLzBZi.js → javascript-680NVpb6.js} +1 -1
  104. package/dist/_frontend/assets/{jsonMode-DqOjSnL2.js → jsonMode-B1wjPa_B.js} +1 -1
  105. package/dist/_frontend/assets/jsonMode-B1wjPa_B.js.br +0 -0
  106. package/dist/_frontend/assets/jsonMode-B1wjPa_B.js.gz +0 -0
  107. package/dist/_frontend/assets/{liquid-DLYzaUKm.js → liquid-DLZXw_l9.js} +1 -1
  108. package/dist/_frontend/assets/liquid-DLZXw_l9.js.br +0 -0
  109. package/dist/_frontend/assets/liquid-DLZXw_l9.js.gz +0 -0
  110. package/dist/_frontend/assets/{lspLanguageFeatures-PB1varoG.js → lspLanguageFeatures-D2El5kWs.js} +1 -1
  111. package/dist/_frontend/assets/lspLanguageFeatures-D2El5kWs.js.br +0 -0
  112. package/dist/_frontend/assets/lspLanguageFeatures-D2El5kWs.js.gz +0 -0
  113. package/dist/_frontend/assets/{mdx-DHNySSed.js → mdx-BzqZXT2Y.js} +1 -1
  114. package/dist/_frontend/assets/mdx-BzqZXT2Y.js.br +0 -0
  115. package/dist/_frontend/assets/mdx-BzqZXT2Y.js.gz +0 -0
  116. package/dist/_frontend/assets/{python-yMHIyjYS.js → python-CL4qUpZU.js} +1 -1
  117. package/dist/_frontend/assets/python-CL4qUpZU.js.br +0 -0
  118. package/dist/_frontend/assets/python-CL4qUpZU.js.gz +0 -0
  119. package/dist/_frontend/assets/{razor-Bnk6A3iA.js → razor-Dx9DYEQN.js} +1 -1
  120. package/dist/_frontend/assets/razor-Dx9DYEQN.js.br +0 -0
  121. package/dist/_frontend/assets/razor-Dx9DYEQN.js.gz +0 -0
  122. package/dist/_frontend/assets/{tsMode-kj0LQhk5.js → tsMode-BSSS0gzy.js} +1 -1
  123. package/dist/_frontend/assets/tsMode-BSSS0gzy.js.br +0 -0
  124. package/dist/_frontend/assets/tsMode-BSSS0gzy.js.gz +0 -0
  125. package/dist/_frontend/assets/{typescript-D7hMcG1O.js → typescript-BFmTNmj1.js} +1 -1
  126. package/dist/_frontend/assets/typescript-BFmTNmj1.js.br +0 -0
  127. package/dist/_frontend/assets/typescript-BFmTNmj1.js.gz +0 -0
  128. package/dist/_frontend/assets/{workers-CGQFLoPd.js → workers-DJIs8BcT.js} +1 -1
  129. package/dist/_frontend/assets/workers-DJIs8BcT.js.br +0 -0
  130. package/dist/_frontend/assets/workers-DJIs8BcT.js.gz +0 -0
  131. package/dist/_frontend/assets/{xml-Bm7N302L.js → xml-D3m5kfkf.js} +1 -1
  132. package/dist/_frontend/assets/xml-D3m5kfkf.js.br +0 -0
  133. package/dist/_frontend/assets/xml-D3m5kfkf.js.gz +0 -0
  134. package/dist/_frontend/assets/{yaml-DauWP5pc.js → yaml-DFIuplXI.js} +1 -1
  135. package/dist/_frontend/assets/yaml-DFIuplXI.js.br +0 -0
  136. package/dist/_frontend/assets/yaml-DFIuplXI.js.gz +0 -0
  137. package/dist/_frontend/index.html +6 -2
  138. package/dist/controller-main.js +67 -7
  139. package/dist/controller-main.js.map +1 -1
  140. package/dist/main.js +2506 -1506
  141. package/dist/main.js.map +1 -1
  142. package/dist/postgres/migrations/20260727_000001_init.js +31 -1
  143. package/dist/postgres/migrations/20260727_000001_init.js.map +1 -1
  144. package/dist/postgres/migrations/20261103_000001_sandbox_environment_type_truefoundry.js +31 -1
  145. package/dist/postgres/migrations/20261103_000001_sandbox_environment_type_truefoundry.js.map +1 -1
  146. package/dist/postgres/migrations/20261116_000001_sandbox_environment_name_backfill.js +61 -0
  147. package/dist/postgres/migrations/20261116_000001_sandbox_environment_name_backfill.js.map +1 -0
  148. package/dist/postgres/migrations/20261118_000001_turn_thread_model.js +32 -0
  149. package/dist/postgres/migrations/20261118_000001_turn_thread_model.js.map +1 -0
  150. package/dist/postgres/migrations/20261119_000001_artifact.js +29 -0
  151. package/dist/postgres/migrations/20261119_000001_artifact.js.map +1 -0
  152. package/dist/postgres/migrations/20261123_000001_drop_artifact_slug.js +19 -0
  153. package/dist/postgres/migrations/20261123_000001_drop_artifact_slug.js.map +1 -0
  154. package/dist/postgres/migrations/20261123_000002_artifact_name_latest_entry_point.js +17 -0
  155. package/dist/postgres/migrations/20261123_000002_artifact_name_latest_entry_point.js.map +1 -0
  156. package/dist/postgres/migrations/20261123_000003_session_tfg_is_create_agent.js +27 -0
  157. package/dist/postgres/migrations/20261123_000003_session_tfg_is_create_agent.js.map +1 -0
  158. package/dist/postgres/migrations/20261125_000001_artifact_version_created_by_and_files_metadata.js +35 -0
  159. package/dist/postgres/migrations/20261125_000001_artifact_version_created_by_and_files_metadata.js.map +1 -0
  160. package/dist/postgres/migrations/20261126_000001_agent_spec_model_type.js +56 -0
  161. package/dist/postgres/migrations/20261126_000001_agent_spec_model_type.js.map +1 -0
  162. package/dist/sqlite/migrations/20261116_000001_sandbox_environment_name_backfill.js +62 -0
  163. package/dist/sqlite/migrations/20261116_000001_sandbox_environment_name_backfill.js.map +1 -0
  164. package/dist/sqlite/migrations/20261118_000001_turn_thread_model.js +34 -0
  165. package/dist/sqlite/migrations/20261118_000001_turn_thread_model.js.map +1 -0
  166. package/dist/sqlite/migrations/20261119_000001_artifact.js +55 -0
  167. package/dist/sqlite/migrations/20261119_000001_artifact.js.map +1 -0
  168. package/dist/sqlite/migrations/20261123_000001_drop_artifact_slug.js +119 -0
  169. package/dist/sqlite/migrations/20261123_000001_drop_artifact_slug.js.map +1 -0
  170. package/dist/sqlite/migrations/20261123_000002_artifact_name_latest_entry_point.js +19 -0
  171. package/dist/sqlite/migrations/20261123_000002_artifact_name_latest_entry_point.js.map +1 -0
  172. package/dist/sqlite/migrations/20261123_000003_session_tfg_is_create_agent.js +41 -0
  173. package/dist/sqlite/migrations/20261123_000003_session_tfg_is_create_agent.js.map +1 -0
  174. package/dist/sqlite/migrations/20261125_000001_artifact_version_created_by_and_files_metadata.js +44 -0
  175. package/dist/sqlite/migrations/20261125_000001_artifact_version_created_by_and_files_metadata.js.map +1 -0
  176. package/dist/sqlite/migrations/20261126_000001_agent_spec_model_type.js +62 -0
  177. package/dist/sqlite/migrations/20261126_000001_agent_spec_model_type.js.map +1 -0
  178. package/package.json +4 -4
  179. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-B16-5UJ8.js +0 -1
  180. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-B16-5UJ8.js.br +0 -0
  181. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-B16-5UJ8.js.gz +0 -0
  182. package/dist/_frontend/assets/AgentMetricChart-TCZEIIUV-DbrMMNdJ.js.br +0 -0
  183. package/dist/_frontend/assets/AgentMetricChart-TCZEIIUV-DbrMMNdJ.js.gz +0 -0
  184. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-l5cpV4_J.js +0 -1
  185. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-l5cpV4_J.js.br +0 -0
  186. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-l5cpV4_J.js.gz +0 -0
  187. package/dist/_frontend/assets/AgentSessionEventTimeline-26TTGY3F-CsLh4dWe.js.br +0 -0
  188. package/dist/_frontend/assets/AgentSessionEventTimeline-26TTGY3F-CsLh4dWe.js.gz +0 -0
  189. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-DcBfkYyl.js +0 -2
  190. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-DcBfkYyl.js.br +0 -0
  191. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-DcBfkYyl.js.gz +0 -0
  192. package/dist/_frontend/assets/AgentSessions-W2EDVBCS-CgUHXoz0.js +0 -1
  193. package/dist/_frontend/assets/AgentSessions-W2EDVBCS-CgUHXoz0.js.br +0 -0
  194. package/dist/_frontend/assets/AgentSessions-W2EDVBCS-CgUHXoz0.js.gz +0 -0
  195. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-Bqrsm5Dp.js +0 -1
  196. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-Bqrsm5Dp.js.br +0 -0
  197. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-Bqrsm5Dp.js.gz +0 -0
  198. package/dist/_frontend/assets/DockLayout-OYD7YJSD-CKhifnZT.js +0 -1
  199. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-BIDPsNsC.js +0 -2
  200. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-BIDPsNsC.js.br +0 -0
  201. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-BIDPsNsC.js.gz +0 -0
  202. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-CcV5njoc.js +0 -3
  203. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-CcV5njoc.js.br +0 -0
  204. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-CcV5njoc.js.gz +0 -0
  205. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-O-E_902u.js +0 -1
  206. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-O-E_902u.js.br +0 -0
  207. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-O-E_902u.js.gz +0 -0
  208. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-BUbTYQmV.js +0 -1
  209. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-BUbTYQmV.js.br +0 -0
  210. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-BUbTYQmV.js.gz +0 -0
  211. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-CunudcIx.js +0 -1
  212. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-CunudcIx.js.br +0 -0
  213. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-CunudcIx.js.gz +0 -0
  214. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-BKu9sdHs.js +0 -1
  215. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-BKu9sdHs.js.br +0 -0
  216. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-BKu9sdHs.js.gz +0 -0
  217. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-DtS3ib0p.js +0 -2
  218. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-DtS3ib0p.js.br +0 -0
  219. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-DtS3ib0p.js.gz +0 -0
  220. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-DJolNJIN.js +0 -1
  221. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-DJolNJIN.js.br +0 -0
  222. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-DJolNJIN.js.gz +0 -0
  223. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-BMDCIIhu.js +0 -2
  224. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-BMDCIIhu.js.br +0 -0
  225. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-BMDCIIhu.js.gz +0 -0
  226. package/dist/_frontend/assets/SkillSettings-XLK6REIA-UZs1mGXm.js +0 -1
  227. package/dist/_frontend/assets/SkillSettings-XLK6REIA-UZs1mGXm.js.br +0 -0
  228. package/dist/_frontend/assets/SkillSettings-XLK6REIA-UZs1mGXm.js.gz +0 -0
  229. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-vhZuRM_V.js +0 -1
  230. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-vhZuRM_V.js.br +0 -0
  231. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-vhZuRM_V.js.gz +0 -0
  232. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-Cd_pMqY7.js +0 -1
  233. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-Cd_pMqY7.js.br +0 -0
  234. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-Cd_pMqY7.js.gz +0 -0
  235. package/dist/_frontend/assets/chunk-HED32BFK-BfnKrlUJ.js +0 -2
  236. package/dist/_frontend/assets/chunk-HED32BFK-BfnKrlUJ.js.br +0 -0
  237. package/dist/_frontend/assets/chunk-HED32BFK-BfnKrlUJ.js.gz +0 -0
  238. package/dist/_frontend/assets/chunk-HK4WITDD-DSX_ymmz.js +0 -1
  239. package/dist/_frontend/assets/chunk-HK4WITDD-DSX_ymmz.js.br +0 -0
  240. package/dist/_frontend/assets/chunk-HK4WITDD-DSX_ymmz.js.gz +0 -0
  241. package/dist/_frontend/assets/chunk-HWOHXUGH-KXcUS5XW.js.br +0 -0
  242. package/dist/_frontend/assets/chunk-HWOHXUGH-KXcUS5XW.js.gz +0 -0
  243. package/dist/_frontend/assets/chunk-LFIIKLPG-DcaznAz-.js +0 -1
  244. package/dist/_frontend/assets/chunk-OB3PAWPO-Bm8RoZbE.js.br +0 -0
  245. package/dist/_frontend/assets/chunk-OB3PAWPO-Bm8RoZbE.js.gz +0 -0
  246. package/dist/_frontend/assets/chunk-OXW7TUTC-UBWEIyxU.js +0 -1
  247. package/dist/_frontend/assets/chunk-OXW7TUTC-UBWEIyxU.js.br +0 -0
  248. package/dist/_frontend/assets/chunk-OXW7TUTC-UBWEIyxU.js.gz +0 -0
  249. package/dist/_frontend/assets/cssMode-CKX3vknZ.js.br +0 -9
  250. package/dist/_frontend/assets/cssMode-CKX3vknZ.js.gz +0 -0
  251. package/dist/_frontend/assets/freemarker2-BxWZ5P9I.js.br +0 -0
  252. package/dist/_frontend/assets/freemarker2-BxWZ5P9I.js.gz +0 -0
  253. package/dist/_frontend/assets/handlebars-By1rPqIP.js.br +0 -0
  254. package/dist/_frontend/assets/handlebars-By1rPqIP.js.gz +0 -0
  255. package/dist/_frontend/assets/html-DV1yPfEc.js.br +0 -0
  256. package/dist/_frontend/assets/html-DV1yPfEc.js.gz +0 -0
  257. package/dist/_frontend/assets/htmlMode-Elrz_gVm.js.br +0 -0
  258. package/dist/_frontend/assets/htmlMode-Elrz_gVm.js.gz +0 -0
  259. package/dist/_frontend/assets/index-B01pXqvC.css +0 -1
  260. package/dist/_frontend/assets/index-B01pXqvC.css.br +0 -0
  261. package/dist/_frontend/assets/index-B01pXqvC.css.gz +0 -0
  262. package/dist/_frontend/assets/index-DUcQ3h0s.js.br +0 -0
  263. package/dist/_frontend/assets/index-DUcQ3h0s.js.gz +0 -0
  264. package/dist/_frontend/assets/index-aDyvsTqL.js.br +0 -0
  265. package/dist/_frontend/assets/index-aDyvsTqL.js.gz +0 -0
  266. package/dist/_frontend/assets/jsonMode-DqOjSnL2.js.br +0 -0
  267. package/dist/_frontend/assets/jsonMode-DqOjSnL2.js.gz +0 -0
  268. package/dist/_frontend/assets/liquid-DLYzaUKm.js.br +0 -0
  269. package/dist/_frontend/assets/liquid-DLYzaUKm.js.gz +0 -0
  270. package/dist/_frontend/assets/lspLanguageFeatures-PB1varoG.js.br +0 -0
  271. package/dist/_frontend/assets/lspLanguageFeatures-PB1varoG.js.gz +0 -0
  272. package/dist/_frontend/assets/mdx-DHNySSed.js.br +0 -0
  273. package/dist/_frontend/assets/mdx-DHNySSed.js.gz +0 -0
  274. package/dist/_frontend/assets/python-yMHIyjYS.js.br +0 -0
  275. package/dist/_frontend/assets/python-yMHIyjYS.js.gz +0 -0
  276. package/dist/_frontend/assets/razor-Bnk6A3iA.js.br +0 -0
  277. package/dist/_frontend/assets/razor-Bnk6A3iA.js.gz +0 -0
  278. package/dist/_frontend/assets/tsMode-kj0LQhk5.js.br +0 -0
  279. package/dist/_frontend/assets/tsMode-kj0LQhk5.js.gz +0 -0
  280. package/dist/_frontend/assets/typescript-D7hMcG1O.js.br +0 -0
  281. package/dist/_frontend/assets/typescript-D7hMcG1O.js.gz +0 -0
  282. package/dist/_frontend/assets/workers-CGQFLoPd.js.br +0 -7
  283. package/dist/_frontend/assets/workers-CGQFLoPd.js.gz +0 -0
  284. package/dist/_frontend/assets/xml-Bm7N302L.js.br +0 -0
  285. package/dist/_frontend/assets/xml-Bm7N302L.js.gz +0 -0
  286. package/dist/_frontend/assets/yaml-DauWP5pc.js.br +0 -0
  287. package/dist/_frontend/assets/yaml-DauWP5pc.js.gz +0 -0
@@ -1 +0,0 @@
1
- import{ab as X,b as ee,br as te,bA as se,bz as re,p as ae,q as ne,r,x as k,j as e,ao as le,I as R,E as T,_ as F,bG as ie,aa as oe}from"./index-aDyvsTqL.js";var V=oe("h-11 shadow-sm"),de=({open:y,onOpenChange:p,onSave:E,title:c,description:o,initialServerUrl:a="",requireApiKey:m=!0,busy:M=!1,error:n})=>{const[u,h]=r.useState(""),[N,f]=r.useState(a);r.useEffect(()=>{y&&(h(""),f(a))},[y,a]);const x=i=>{i||(h(""),f(a)),p(i)},b=u.trim(),g=!m||!!b,S=async i=>{if(i.preventDefault(),!(!g||M))try{await E({apiKey:b,serverUrl:N.trim()}),p(!1)}catch{}};return e.jsx(ie,{open:y,onOpenChange:x,title:c,description:o,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(R,{name:"brain",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:S,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",m?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"memory-provider-api-key",type:"password",required:m,value:u,onChange:i=>{h(i.target.value)},placeholder:m?"Zep API key":"Leave blank to keep existing",autoFocus:!0,className:V})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Server URL ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"memory-provider-server-url",type:"url",value:N,onChange:i=>{f(i.target.value)},placeholder:"Leave blank for Zep Cloud",className:V})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[n?e.jsx("p",{className:"text-failure-bg text-sm",children:n}):null,e.jsx(T.Primary,{type:"submit",size:"large",disabled:!g||M,className:"w-full shrink-0",children:"Save"})]})]})})},ce=de,me=()=>{var B,D;const y=X(),p=(B=ee())==null?void 0:B.settings,E=te(),c=se(),o=re(),a=ae(),m=ne(),n=E&&((D=p==null?void 0:p.memoryProviders)==null?void 0:D.manageProviders)!==!1?y==null?void 0:y.memoryCatalog:void 0,[u,h]=r.useState(null),[N,f]=r.useState(!1),[x,b]=r.useState([]),[g,S]=r.useState([]),[i,P]=r.useState(!0),[_,v]=r.useState(null),[$,j]=r.useState(null),[U,L]=r.useState(!1),[d,w]=r.useState(null),[l,C]=r.useState(null),A=r.useCallback(async({quiet:t=!1}={})=>{if(!n){b([]),S([]),P(!1);return}t||P(!0),v(null);try{const[s,W]=await Promise.all([n.listMemoryProviders(),n.getMemoryProviderCatalog()]);b(s),S(W)}catch(s){v(k(s,"Failed to load memory providers"))}finally{t||P(!1)}},[n]);r.useEffect(()=>{A()},[A]),r.useEffect(()=>{if(!o)return;let t=!1;return o.getConfiguration().then(s=>{t||h(s.memory.enabled)}).catch(s=>{t||v(k(s,"Failed to load the memory setting"))}),()=>{t=!0}},[o]);const I=x.length>0,O=r.useMemo(()=>{if(I)return[];const t=new Set(x.map(s=>s.catalogId));return g.filter(s=>!t.has(s.id))},[g,x,I]);if(n==null&&o==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Memory settings are not available."});const G=async t=>{if(o){f(!0),v(null);try{const s=await o.updateConfiguration({memory:{enabled:t}});h(s.memory.enabled),c==null||c(),a==null||a.showSuccess({title:s.memory.enabled?"Memory turned on":"Memory turned off"}),m(F.Settings.MEMORY_TENANT_TOGGLED,{enabled:s.memory.enabled})}catch(s){v(k(s,"Failed to save the memory setting"))}finally{f(!1)}}},K=async t=>{L(!0),j(null);try{await t(),await A({quiet:!0}),c==null||c()}catch(s){throw j(k(s,"Request failed")),s}finally{L(!1)}},Y=async t=>{!d||!n||(await K(async()=>{await n.createMemoryProvider({catalogId:d.id,name:d.name,type:d.type,apiKey:t.apiKey,...t.serverUrl===""?{}:{serverUrl:t.serverUrl}})}),w(null),a==null||a.showSuccess({title:`${d.name} configured`}),m(F.Settings.MEMORY_PROVIDER_SAVED,{provider_name:d.name,mode:"create"}))},Z=async t=>{!l||!n||(await K(async()=>{await n.updateMemoryProvider({id:l.id,...t.apiKey===""?{}:{apiKey:t.apiKey},...t.serverUrl===""?{}:{serverUrl:t.serverUrl}})}),C(null),a==null||a.showSuccess({title:`${l.name} updated`}),m(F.Settings.MEMORY_PROVIDER_SAVED,{provider_name:l.name,mode:"update"}))},q=o==null||u!==null,H=n!=null&&q&&u!==!1,J=d!=null||l!=null,z=l!=null,Q=l?`Update ${l.name}`:d?`Configure ${d.name}`:"Configure memory provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Memory"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Let TrueForge personalize your conversations based on your past chats."}),_?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:_}):null,u!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow memory"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:u?"Agents may remember details from past chats.":"Agents cannot use memory, including in chats that already had it."})]}),e.jsx(le,{checked:u,disabled:N,"aria-label":"Allow memory",onCheckedChange:t=>{G(t)}})]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:H?i?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading memory providers…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can remember details. Only one can be active at a time."}),x.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",x.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:x.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(R,{name:"brain",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:t.serverUrl??"Zep Cloud"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(T.Secondary,{size:"small",type:"button",disabled:U,onClick:()=>{j(null),w(null),C(t)},children:"Update"})]})]},t.id))})]}):null,I?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",O.length]}),O.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:"No memory providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:O.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(R,{name:"brain",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})]}),e.jsx(T.Secondary,{type:"button",disabled:U,onClick:()=>{j(null),C(null),w(t)},children:"Configure"})]},t.id))})]})]}):null}),e.jsx(ce,{open:J,onOpenChange:t=>{t||(j(null),w(null),C(null))},onSave:z?Z:Y,title:Q,description:z?"Update this memory provider. Leave API key blank to keep the existing key.":"Configure this memory provider. API key is never stored in the catalog.",initialServerUrl:(l==null?void 0:l.serverUrl)??"",requireApiKey:!z,busy:U,error:$})]})},xe=me;export{xe as default};
@@ -1 +0,0 @@
1
- import{C as we}from"./chunk-LFIIKLPG-DcaznAz-.js";import{bE as Ee,p as Ce,q as ke,r as l,x as J,j as e,S as Se,E as B,I as T,bF as fe,bG as ye,bH as Me,bI as Le,c as P,bJ as Pe,_ as de,aa as Te}from"./index-aDyvsTqL.js";var ve=Te("h-11 shadow-sm"),Ue=({open:a,onOpenChange:i,onSave:f,title:j,description:N,initialBaseUrl:g="",baseUrlPlaceholder:h="https://api.openai.com/v1",requireApiKey:o=!0,submitLabel:K="Save",busy:M=!1,error:I})=>{const[$,C]=l.useState(""),[q,x]=l.useState(""),[p,A]=l.useState(!1),U=()=>{C(""),x(""),A(!1)};l.useEffect(()=>{a&&(C(""),x(g),A(!1))},[a,g]);const H=d=>{d||U(),i(d)},R=$.trim(),_=!o||!!R,Z=async d=>{if(d.preventDefault(),!(!_||M))try{await f({apiKey:R,baseUrl:q.trim()}),U(),i(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:H,title:j,description:N,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:Z,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",o?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:o,value:$,onChange:d=>{C(d.target.value)},placeholder:o?"Enter API key":"Enter a new key",autoFocus:!0,className:ve}),o?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(Me,{expanded:p,onChange:(d,ae)=>A(ae),className:"rounded-md border border-border",children:[e.jsx(Le,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(T,{name:"chevron-down",className:P("size-4 shrink-0 text-text-secondary transition-transform duration-200",p?"rotate-0":"-rotate-90")})]})}),e.jsxs(Pe,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:q,onChange:d=>{x(d.target.value)},placeholder:h,className:ve}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[I?e.jsx("p",{className:"text-failure-bg text-sm",children:I}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!_||M,className:"w-full shrink-0",children:K})]})]})})},Re=Ue,Oe="128000",De="4096",je=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ge=a=>(a==null?void 0:a.models.map(i=>{var f,j,N,g,h;return{id:i.id,name:i.name,advancedExpanded:!0,reasoningEfforts:(f=i.properties)==null?void 0:f.reasoningEfforts,contextLength:((N=(j=i.properties)==null?void 0:j.contextLength)==null?void 0:N.toString())??"",maxOutputTokens:((h=(g=i.properties)==null?void 0:g.maxOutputTokens)==null?void 0:h.toString())??"",nameDirty:!0}}))??[je()],W="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",se="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function pe(a){const i=a.trim();if(i==="")return null;const f=Number(i);return Number.isInteger(f)&&f>0?f:null}function Ie(a){return a.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var ie=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),re=({children:a})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:a}),ce=({children:a})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:a}),$e=({open:a,onOpenChange:i,onSubmit:f,reasoningEffortOptions:j,busy:N=!1,error:g,isEditMode:h=!1,initialValues:o})=>{const[K,M]=l.useState((o==null?void 0:o.name)??""),[I,$]=l.useState((o==null?void 0:o.baseUrl)??""),[C,q]=l.useState(""),[x,p]=l.useState(()=>ge(o)),[A,U]=l.useState(!1),[H,R]=l.useState(!1),_=()=>{M((o==null?void 0:o.name)??""),$((o==null?void 0:o.baseUrl)??""),q(""),p(ge(o)),U(!1),R(!1)},Z=s=>{s||_(),i(s)},d=(s,r)=>{p(y=>y.map((m,b)=>b===s?{...m,...r}:m))},ae=()=>{U(!0),R(!0),p(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},Y=K.trim(),v=Y?null:"Name is required.",z=I.trim();let k=null;if(!z)k="Base URL is required.";else try{new URL(z)}catch{k="Enter a valid URL."}const G=s=>s.id.trim()?null:"Model ID is required.",me=s=>s.name.trim()?null:"Model name is required.",O=s=>pe(s.contextLength)==null?"Set the model's context window.":null,ne=s=>pe(s.maxOutputTokens)==null?"Set the max output tokens.":null,w=!v&&!k&&x.every(s=>!G(s)&&!me(s)),Q=A&&v,V=H&&k,oe=async()=>{if(ae(),!w||N)return;const s=x.findIndex(r=>O(r)||ne(r));if(s!==-1){d(s,{advancedExpanded:!0});const r=x[s],y=r&&O(r)?"context-length":"max-output-tokens";setTimeout(()=>{var b;const m=document.getElementById(`custom-provider-model-${s}-${y}`);(b=m==null?void 0:m.scrollIntoView)==null||b.call(m,{block:"center",behavior:"smooth"}),m==null||m.focus()},0);return}try{await f({name:Y,baseUrl:z,apiKey:C.trim(),models:x.map(r=>{var F;const y={};(F=r.reasoningEfforts)!=null&&F.length&&(y.reasoningEfforts=r.reasoningEfforts);const m=pe(r.contextLength);m!=null&&(y.contextLength=m);const b=pe(r.maxOutputTokens);return b!=null&&(y.maxOutputTokens=b),{id:r.id.trim(),name:r.name.trim(),...Object.keys(y).length>0?{properties:y}:{}}})}),Z(!1)}catch{}};return e.jsx(ye,{open:a,onOpenChange:Z,title:h?`Edit ${(o==null?void 0:o.name)??K}`:"Add custom provider",description:h?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-auto flex-col",onSubmit:s=>{s.preventDefault(),oe()},children:[e.jsxs("div",{className:"min-h-0 flex-auto space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(ie,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:K,onChange:s=>M(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!h,readOnly:h,"aria-readonly":h,"aria-invalid":Q?!0:void 0,className:P(W,h&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",Q&&se)}),h?e.jsx(ce,{children:"Provider names cannot be changed after creation."}):null,Q?e.jsx(re,{children:v}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(ie,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:I,onChange:s=>$(s.target.value),onBlur:()=>R(!0),placeholder:"http://localhost:11434/v1",autoFocus:h,"aria-invalid":V?!0:void 0,className:P(W,V&&se)}),V?e.jsx(re,{children:k}):z?null:e.jsx(ce,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:C,onChange:s=>q(s.target.value),placeholder:"sk-…",className:W}),e.jsx(ce,{children:h?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(ie,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const y=G(s),m=s.idTouched&&y,b=me(s),F=!!b&&s.nameDirty,ue=O(s),xe=ne(s),ee=s.contextTouched&&ue,le=s.maxTouched&&xe;return e.jsxs("div",{className:P("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:u=>{const D=u.target.value;d(r,{id:D,...s.nameDirty?{}:{name:Ie(D)}})},onBlur:()=>d(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":m?!0:void 0,className:P(W,"font-mono",m&&se)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:u=>d(r,{name:u.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":F?!0:void 0,className:P(W,F&&se)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||N,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>p(u=>u.filter((D,te)=>te!==r)),children:e.jsx(T,{name:"trash",className:"size-4"})})]}),m?e.jsx(re,{children:y}):null,F?e.jsx(re,{children:b}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>d(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(T,{name:"chevron-down",className:P("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(ie,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:u=>d(r,{contextLength:u.target.value}),onBlur:()=>d(r,{contextTouched:!0}),placeholder:Oe,"aria-invalid":ee?!0:void 0,className:P(W,ee&&se)}),ee?e.jsx(re,{children:ue}):s.contextLength.trim()===""?e.jsx(ce,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(ie,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:u=>d(r,{maxOutputTokens:u.target.value}),onBlur:()=>d(r,{maxTouched:!0}),placeholder:De,"aria-invalid":le?!0:void 0,className:P(W,le&&se)}),le?e.jsx(re,{children:xe}):s.maxOutputTokens.trim()===""?e.jsx(ce,{children:"Longest reply the model allows — use its real limit."}):null]}),j&&j.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:N,onChange:u=>d(r,{reasoningEfforts:u.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:j.map(u=>{var te;const D=((te=s.reasoningEfforts)==null?void 0:te.includes(u))??!1;return e.jsx("button",{type:"button","aria-pressed":D,disabled:N,className:P("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",D?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var S;return d(r,{reasoningEfforts:D?(S=s.reasoningEfforts)==null?void 0:S.filter(X=>X!==u):[...s.reasoningEfforts??[],u]})},children:u},u)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>p(s=>[...s,je()]),children:[e.jsx(T,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[g?e.jsx("p",{className:"text-failure-bg text-sm",children:g}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!w||N,className:"w-full",children:h?"Save changes":"Add provider"})]})]})})},Ae=$e;function he(a){return a.kind==="model"&&a.provider.models.length===1}function _e(a){return a.kind==="provider"?`“${a.provider.name}” and all of its models will no longer be available to your agents.`:he(a)?`“${a.model.name}” is the only model left in ${a.provider.name}, so the whole provider will be removed.`:`“${a.model.name}” will no longer be available to your agents. The rest of ${a.provider.name} stays configured.`}function ze(a){return"baseUrl"in a&&typeof a.baseUrl=="string"?a.baseUrl:""}var Fe=()=>{const{modelCatalog:a}=Ee(),i=Ce(),f=ke(),[j,N]=l.useState(""),[g,h]=l.useState([]),[o,K]=l.useState([]),[M,I]=l.useState(!0),[$,C]=l.useState(null),[q,x]=l.useState(null),[p,A]=l.useState(!1),[U,H]=l.useState(null),[R,_]=l.useState(null),[Z,d]=l.useState(null),[ae,Y]=l.useState(!1),[v,z]=l.useState(null),[k,G]=l.useState(null),[me,O]=l.useState(null),ne=l.useMemo(()=>(o??[]).reduce((t,n)=>(t[n.name]=n.logo??"",t),{}),[o]),w=j.trim().toLowerCase(),Q=l.useCallback(async()=>{I(!0),C(null);try{const[t,n]=await Promise.all([a.listModelProviders(),a.getModelProviderCatalog()]);h(t),K(n)}catch(t){C(J(t,"Failed to load model providers"))}finally{I(!1)}},[a]);l.useEffect(()=>{Q()},[Q]);const V=l.useMemo(()=>new Set(g.map(t=>t.type)),[g]),oe=l.useMemo(()=>g.filter(t=>{var n;return((n=t.name)==null?void 0:n.toLowerCase().includes(w))||t.models.some(c=>c.name.toLowerCase().includes(w)||c.id.toLowerCase().includes(w))}),[g,w]),s=l.useMemo(()=>o.filter(t=>t.type!=="custom"&&!V.has(t.type)&&(t.name.toLowerCase().includes(w)||t.models.some(n=>n.name.toLowerCase().includes(w)||n.id.toLowerCase().includes(w)))),[o,V,w]),r=l.useMemo(()=>{var t;return(t=o.find(n=>n.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[o]),y=l.useMemo(()=>{const t=new Map;for(const n of o)t.set(n.type,n.models);return t},[o]),m=()=>{H(null),_(null),d(null)},b=async(t,n)=>{A(!0),C(null);try{await t(),await Q(),m()}catch(c){throw n?n(c):i==null?C(J(c,"Request failed")):i.showError(c),c}finally{A(!1)}},F=async(t,n)=>{d(null),await b(async()=>{await a.createModelProvider({type:t.type,name:t.name,...n.baseUrl?{baseUrl:n.baseUrl}:{},apiKey:n.apiKey,models:t.models})},c=>d(J(c,"Request failed"))),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},ue=async(t,n)=>{d(null),await b(async()=>{await a.updateModelProvider({id:t.id,type:t.type,name:t.name,...n.baseUrl?{baseUrl:n.baseUrl}:{},apiKey:n.apiKey,models:t.models})},c=>d(J(c,"Request failed"))),i==null||i.showSuccess({title:`${t.name} updated`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"update"})},xe=()=>{p||(G(null),O(null))},ee=({provider:t,models:n},c)=>b(async()=>{await a.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:n})},c),le=t=>{O(null);const n=L=>O(J(L,"Request failed"));let c;if(t.kind==="model"&&!he(t))c=ee({provider:t.provider,models:t.provider.models.filter(L=>L.id!==t.model.id)},n);else{const L=a.deleteModelProvider;L!==void 0&&(c=b(async()=>{await L({id:t.provider.id}),f(de.Settings.MODEL_PROVIDER_DELETED,{provider_name:t.provider.name})},n))}c==null||c.then(()=>G(null)).catch(()=>{})},u=async t=>{x(null),await b(async()=>{await a.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},n=>x(J(n,"Request failed"))),setTimeout(()=>{i==null||i.showSuccess({title:`${t.name} added`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},0)},D=async t=>{if(!v)return;const n=v;x(null),await b(async()=>{await a.updateModelProvider({id:n.id,type:n.type,name:n.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},c=>x(J(c,"Request failed"))),setTimeout(()=>{i==null||i.showSuccess({title:"Model provider updated",description:`${n.name} was updated successfully.`}),f(de.Settings.MODEL_PROVIDER_SAVED,{provider_name:n.name,mode:"update"})},0)},te=v?{name:v.name,baseUrl:v.baseUrl??"",models:v.models}:void 0,S=U!=null?g.find(t=>t.id===U)??null:null,X=R!=null?o.find(t=>t.type===R)??null:null,Ne=S!=null||X!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),$?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:$}):null,e.jsx("div",{className:"mt-4 min-h-0 min-w-0 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full min-w-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Se,{query:j,setQuery:N,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",className:"shrink-0 sm:self-auto",onClick:()=>{x(null),z(null),Y(!0)},children:[e.jsx(T,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[M?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!M&&oe.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:oe.map(t=>{const n=y.get(t.type)??[],c=new Set(t.models.map(E=>E.id)),L=n.filter(E=>!c.has(E.id)),be=ne[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:be?e.jsx(fe,{src:be,alt:t.name,className:"size-4.5"}):e.jsx(T,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:p,onClick:()=>{t.type==="custom"?(m(),x(null),z(t),Y(!0)):(d(null),_(null),H(t.id))},children:[e.jsx(T,{name:"pencil",className:"size-3.5"}),"Edit"]}),a.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:p,onClick:()=>{O(null),G({kind:"provider",provider:t})},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(E=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),t.models.length>1||a.deleteModelProvider?e.jsx("button",{type:"button","aria-label":`Remove ${E.name}`,disabled:p,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{O(null),G({kind:"model",provider:t,model:E})},children:e.jsx(T,{name:"trash",className:"size-3.5"})}):null]},E.id)),L.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",L.length]}),L.map(E=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:p,onClick:()=>{ee({provider:t,models:[...t.models,E]}).catch(()=>{})},children:"Add"})]},E.id))]}):null]})]},t.id)})})]}):null,!M&&s.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:s.map(t=>{const n=ne[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:n?e.jsx(fe,{src:n,alt:t.name,className:"size-4.5"}):e.jsx(T,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(c=>c.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:p,onClick:()=>{d(null),H(null),_(t.type)},children:[e.jsx(T,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!M&&oe.length===0&&s.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:w?`No providers match “${j.trim()}”.`:"No model providers yet."}):null]}),k?e.jsx(we,{title:k.kind==="model"&&!he(k)?"Remove model?":"Remove provider?",description:_e(k),busy:p,error:me,onCancel:xe,onConfirm:()=>{le(k)}}):null,e.jsx(Re,{open:Ne,onOpenChange:t=>{t||m()},onSave:t=>{if(S)return ue(S,t);if(X)return F(X,t)},title:S?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:S?S.baseUrl??"":X?ze(X):"",requireApiKey:S==null,submitLabel:S?"Save":"Create",busy:p,error:Z}),e.jsx(Ae,{open:ae,onOpenChange:t=>{Y(t),t||(x(null),z(null))},isEditMode:v!==null,initialValues:te,onSubmit:v?D:u,reasoningEffortOptions:r,busy:p,error:q},(v==null?void 0:v.id)??"add-custom-provider")]})})]})},qe=Fe;export{qe as default};
@@ -1 +0,0 @@
1
- import{C as X}from"./chunk-LFIIKLPG-DcaznAz-.js";import{bE as H,p as J,q as Y,r as a,x as q,bL as Q,j as e,I as T,E as O,bG as W,bH as Z,bI as ee,c as te,bJ as se,_ as U,aa as ae}from"./index-aDyvsTqL.js";var ne={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},E=ae("h-11 shadow-sm");function R(n){if(n.trim()==="")return null;const r=Number(n);return!Number.isFinite(r)||r<0?null:r}var re=({open:n,onOpenChange:r,onSave:p,title:c,description:z,initialConfig:y=null,requireApiKey:j=!0,busy:M=!1,error:w})=>{const[k,m]=a.useState(""),[D,d]=a.useState(""),[u,S]=a.useState(""),[l,x]=a.useState(""),[o,b]=a.useState(""),[N,h]=a.useState(!1),P=()=>{m(""),d(""),S(""),x(""),b(""),h(!1)};a.useEffect(()=>{if(!n)return;const s=y??ne;m(String(s.execTimeoutMs)),d(String(s.autoStopIntervalInMinutes)),S(String(s.autoArchiveIntervalInMinutes)),x(String(s.autoDeleteIntervalInMinutes)),b(""),h(!1)},[n,y]);const I=s=>{s||P(),r(s)},f=R(k),v=R(D),g=R(u),A=R(l),C=o.trim(),_=(!j||!!C)&&f!=null&&v!=null&&g!=null&&A!=null,B=async s=>{if(s.preventDefault(),!(!_||M||f==null||v==null||g==null||A==null))try{await p({execTimeoutMs:f,autoStopIntervalInMinutes:v,autoArchiveIntervalInMinutes:g,autoDeleteIntervalInMinutes:A,apiKey:C}),P(),r(!1)}catch{}};return e.jsx(W,{open:n,onOpenChange:I,title:c,description:z,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(T,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:B,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"sandbox-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",j?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:j,value:o,onChange:s=>{b(s.target.value)},placeholder:j?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:E})]}),e.jsxs(Z,{expanded:N,onChange:(s,K)=>h(K),className:"rounded-md border border-border",children:[e.jsx(ee,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced settings",e.jsx(T,{name:"chevron-down",className:te("size-4 shrink-0 text-text-secondary transition-transform duration-200",N?"rotate-0":"-rotate-90")})]})}),e.jsxs(se,{className:"space-y-4 border-t border-border px-3 pb-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-exec-timeout",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Exec timeout (ms)"}),e.jsx("input",{id:"sandbox-exec-timeout",type:"number",min:0,required:!0,value:k,onChange:s=>{m(s.target.value)},placeholder:"300000",className:E})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-stop",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-stop interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-stop",type:"number",min:0,required:!0,value:D,onChange:s=>{d(s.target.value)},placeholder:"15",className:E})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-archive",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-archive interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-archive",type:"number",min:0,required:!0,value:u,onChange:s=>{S(s.target.value)},placeholder:"10080",className:E})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-delete",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-delete interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-delete",type:"number",min:0,required:!0,value:l,onChange:s=>{x(s.target.value)},placeholder:"43200",className:E})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[w?e.jsx("p",{className:"text-failure-bg text-sm",children:w}):null,e.jsx(O.Primary,{type:"submit",size:"large",disabled:!_||M,className:"w-full shrink-0",children:"Save"})]})]})})},le=re,V=({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c})=>({execTimeoutMs:n,autoStopIntervalInMinutes:r,autoArchiveIntervalInMinutes:p,autoDeleteIntervalInMinutes:c}),oe=()=>{const{sandboxCatalog:n}=H(),r=J(),p=Y(),[c,z]=a.useState([]),[y,j]=a.useState([]),[M,w]=a.useState(!0),[k,m]=a.useState(null),[D,d]=a.useState(null),[u,S]=a.useState(!1),[l,x]=a.useState(null),[o,b]=a.useState(null),[N,h]=a.useState(null),[P,I]=a.useState(null),f=a.useCallback(async({quiet:t=!1}={})=>{if(n){t||w(!0),m(null);try{const[i,F]=await Promise.all([n.listSandboxProviders(),n.getSandboxProviderCatalog()]);z(i),j(F)}catch(i){m(q(i,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[n]);a.useEffect(()=>{f()},[f]);const v=c.length>0,g=a.useMemo(()=>{if(v)return[];const t=new Set(c.map(i=>i.catalogId));return y.filter(i=>!t.has(i.id))},[y,c,v]),A=a.useMemo(()=>{const t=o??l;return t==null||!Q(t)?null:V(t)},[o,l]);if(!n)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const C=async(t,i=m)=>{S(!0),m(null);try{await t(),await f({quiet:!0})}catch(F){throw i(q(F,"Request failed")),F}finally{S(!1)}},_=async t=>{l&&(d(null),await C(async()=>{await n.createSandboxProvider({catalogId:l.id,name:l.name,type:l.type,...V(t),apiKey:t.apiKey})},d),x(null),setTimeout(()=>{r==null||r.showSuccess({title:`${l.name} configured`}),p(U.Settings.SANDBOX_PROVIDER_SAVED,{provider_name:l.name,mode:"create"})},0))},B=async t=>{o&&(d(null),await C(async()=>{await n.updateSandboxProvider({id:o.id,...V(t),...t.apiKey?{apiKey:t.apiKey}:{}})},d),b(null),setTimeout(()=>{r==null||r.showSuccess({title:`${o.name} updated`}),p(U.Settings.SANDBOX_PROVIDER_SAVED,{provider_name:o.name,mode:"update"})},0))},s=()=>{u||(h(null),I(null))},K=t=>{const i=n.deleteSandboxProvider;i&&(I(null),C(async()=>{await i({id:t.id}),p(U.Settings.SANDBOX_PROVIDER_DELETED,{provider_name:t.name}),h(null)},I).catch(()=>{}))},$=l!=null||o!=null,L=o!=null,G=o?`Update ${o.name}`:l?`Configure ${l.name}`:"Configure sandbox provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Sandbox providers"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose a provider that runs sandboxes for code, files and shell commands. Only one can be active at a time."}),k?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:k}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:M?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[c.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",c.length]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:[c.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(T,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(O.Secondary,{size:"small",type:"button",disabled:u,onClick:()=>{d(null),x(null),b(t)},children:"Update"}),n.deleteSandboxProvider?e.jsx(O.Ghost,{size:"small",className:"text-text-secondary",type:"button",disabled:u,onClick:()=>{I(null),h(t)},children:"Remove"}):null]})]},t.id))," "]})]}):null,v?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",g.length]}),g.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:y.length>0?"All catalog providers are configured.":"No sandbox providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:g.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(T,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(O.Secondary,{type:"button",disabled:u,onClick:()=>{d(null),b(null),x(t)},children:"Configure"})]},t.id))})]})]})}),N?e.jsx(X,{title:"Remove sandbox provider?",description:`“${N.name}” will stop running sandboxes for code, files and shell commands.`,busy:u,error:P,onCancel:s,onConfirm:()=>{K(N)}}):null,e.jsx(le,{open:$,onOpenChange:t=>{t||(d(null),x(null),b(null))},onSave:L?B:_,title:G,description:L?"Update this sandbox provider. Leave API key blank to keep the existing key.":"Configure this sandbox provider. API key is never stored in the catalog.",initialConfig:A,requireApiKey:!L,busy:u,error:D})]})},ce=oe;export{ce as default};
@@ -1 +0,0 @@
1
- import{B as rt}from"./chunk-HWOHXUGH-KXcUS5XW.js";import{l as Te,o as Ue,p as Ce,q as Ge,t as He,v as lt,r as o,w as ve,x as it,y as Fe,z as Ee,A as ot,j as e,P as ct,S as dt,B as xe,C as qe,D as Ve,E as $,I as R,F as ut,G as Ne,H as _e,J as mt,K as ht,L as Le,M as W,N as xt,O as K,k as We,Q as ft,c as B,R as gt,U as bt,V as pt,W as Nt,X as jt,Y as yt,Z as vt,_ as Q,$ as St,a0 as wt,u as kt,a1 as Tt,a2 as je,a3 as Ct,a4 as Et,a5 as zt,a6 as At,a7 as Rt,a8 as It,a9 as Pt,aa as ye,ab as Dt,ac as Ft,ad as _t}from"./index-aDyvsTqL.js";var Oe=[{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"America/Denver",label:"America/Denver (MT)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"UTC",label:"UTC"},{value:"Europe/London",label:"Europe/London (GMT/BST)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Kolkata",label:"Asia/Kolkata (IST)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}];function Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Lt(t){const n=Ke(),r=new Set(Oe.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Oe]}var Qe=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],Ot={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function fe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ke()}}function Mt(t){return Ot[t]??t.split("/").pop()??t}function Ye(t){return t.toString().padStart(2,"0")}function me({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ye(n)} ${r}`}function Se(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((u,S)=>u-S),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function we(t){return t.trim().split(/\s+/).length===5}function ce(t){const n=Mt(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,u,S,b]=r;if(u!=="*"||S!=="*")return t.cron;const d=Number(a),h=Number(l);if(l==="*"&&b==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ye(d)} ${n}`;if(b==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Daily ${me({hour:h,minute:d})} ${n}`;if(b==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Weekdays ${me({hour:h,minute:d})} ${n}`;if(b!=null&&/^\d(?:,\d)*$/.test(b)&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d)){const j=b.split(",").map(x=>{var k;return((k=Qe.find(p=>p.value===Number(x)))==null?void 0:k.label)??x});return j.length===1?`Every ${j[0]==="Mon"?"Monday":j[0]} ${me({hour:h,minute:d})} ${n}`:`${j.join(", ")} ${me({hour:h,minute:d})} ${n}`}return t.cron}function Me(t){const n=fe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,u,S,b]=r,d=Number(a),h=Number(l);return u!=="*"||S!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&b==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:b==="*"&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:h,minute:d,customCron:t.cron}:b!=null&&/^\d(?:,\d)*$/.test(b)&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:h,minute:d,weekdays:b.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(h)?n.hour:h,minute:Number.isNaN(d)?n.minute:d}}function $t(t,n=Date.now()){return _t(t,{fallback:"Never",nowMs:n})}var Bt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Ut=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),Gt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Ht({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:u,agentPickerDisabled:S=!1,onBuildAgent:b}){const d=Se(t),h=ce({cron:d,timezone:t.timezone}),j=Lt(t.timezone),x=(i,y)=>{n({...t,[i]:y})},k=i=>{const y=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:y})},p=i=>{const z=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:z.length>0?z:[i]})};return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent"}),e.jsx(qe,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:u,disabled:S||l==null,onBuildAgent:b})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Name"}),e.jsx("input",{value:t.name,onChange:i=>x("name",i.target.value),placeholder:"harness-daily-digest",className:ye("h-8"),required:!0})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Task"}),e.jsx("textarea",{value:t.task,onChange:i=>x("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ye("resize-y py-2"),required:!0})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Frequency"}),e.jsx("div",{className:"rounded-t-lg border border-border p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid grid-cols-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Bt.map(i=>{const y=t.recurrence===i.value;return e.jsx("button",{type:"button",className:B("rounded-md border px-2 py-2 text-sm font-medium transition-colors",y?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-transparent text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":y,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>x("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!we(t.customCron),className:B(ye("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),we(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):null,t.recurrence==="weekly"?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-2 text-sm font-medium",children:"Days"}),e.jsx("div",{className:"flex gap-2",children:Qe.map(i=>{const y=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:B("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",y?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-border text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":y,onClick:()=>p(i.value),children:i.label},i.value)})})]}):null,e.jsxs("div",{className:"flex gap-4",children:[t.recurrence==="daily"||t.recurrence==="weekly"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Hour"}),e.jsx(xe,{"aria-label":"Hour",value:String(t.hour),options:Ut,onValueChange:i=>x("hour",Number(i))})]}):null,t.recurrence!=="custom"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Minute"}),e.jsx(xe,{"aria-label":"Minute",value:String(t.minute),options:Gt,onValueChange:i=>x("minute",Number(i))})]}):null,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Timezone"}),e.jsx(xe,{"aria-label":"Timezone",value:t.timezone,options:j,onValueChange:i=>x("timezone",i),menuClassName:"w-full min-w-0"})]})]})]})}),e.jsx("div",{className:"rounded-b-lg border border-t-0 border-border bg-primary-button-bg/10 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:h||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function qt(t){return t.startsWith("manual-")}function Vt(t){return t==="failed"?"failed":"success"}function Ze(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Je(t){return qt(t)?"Manual test":"Cron"}function Wt(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function ke(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":It(n)}function Kt({run:t}){return e.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Ze(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Je(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",ke(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",ke(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Qt={success:"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",failed:"border-red-600/30 bg-red-500/10 text-red-700 dark:border-red-400/35 dark:bg-red-500/15 dark:text-red-300"};function Xe({run:t,onOpenSession:n}){const r=Vt(t.status),a=ke(t.triggeredAt??t.scheduledFor),l=`${Ze(t.status)} run at ${a}`,u=B("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Qt[r]),S=e.jsx(R,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(We,{content:e.jsx(Kt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:B(u,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:S}):e.jsx("span",{className:u,"aria-label":l,children:S})})}function et({status:t}){const n=t==="active";return e.jsx(rt,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Yt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Zt({connector:t,onConnected:n}){return Dt()==null?null:e.jsx(Ft,{connector:t,onConnected:n})}function ie({label:t,children:n}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border px-3 py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-text-secondary shrink-0 text-[10px] font-semibold tracking-wide uppercase",children:t}),e.jsx("div",{className:"min-w-0 text-right text-sm text-text-primary",children:n})]})}function Jt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=Te(),u=Ce(),{connectors:S,ensureLoaded:b,refreshConnectors:d,loading:h,error:j}=Pt(),[x,k]=o.useState(!1),[p,i]=o.useState(null),y=ce({cron:t.cron,timezone:t.timezone}),z=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),u==null||u.showSuccess({title:"Test run started"})}catch(m){u==null||u.showError(m)}finally{k(!1)}};return o.useEffect(()=>{b()},[b]),o.useEffect(()=>{j!=null&&(u==null||u.showError(j))},[j,u]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ie,{label:"Agent",children:n}),e.jsx(ie,{label:"Name",children:t.name}),e.jsx(ie,{label:"Status",children:e.jsx(et,{status:t.status})}),e.jsx(ie,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ie,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:y}),e.jsx("code",{className:"text-text-secondary font-mono text-xs",children:t.cron})]})}),e.jsx("div",{className:"flex justify-end px-3 py-2.5",children:e.jsxs($.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),r.length===0?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"No MCP connectors configured for this agent."}):e.jsx("ul",{className:"divide-y divide-border",children:r.map(m=>{const C=Yt(S,m.name),U=(C==null?void 0:C.authenticated)===!0,q=C==null&&!h;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:B("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",U?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:U?e.jsx(R,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),U?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):q?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):C!=null&&C.authenticated===!1?e.jsx(Zt,{connector:C,onConnected:d}):h?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.name)})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Test Run"}),e.jsxs($.Primary,{type:"button",disabled:x,size:"small",onClick:()=>void z(),children:[e.jsx(R,{name:x?"loader":"play",className:B("size-3.5",x&&"animate-spin")}),"Run Test"]})]}),p==null?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"Run a one-off test using the schedule task. This does not change the cron pending run."}):e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3",children:[e.jsx(Xe,{run:p}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Je(p.name)}),e.jsx("p",{className:"text-text-secondary",children:$t(p.triggeredAt??p.scheduledFor)})]})]})]})]})}function Xt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:u}){const S=Te(),b=Ue(),d=He(),h=Ce(),j=Ge(),[x,k]=o.useState(fe),[p,i]=o.useState(l),[y,z]=o.useState(null),[m,C]=o.useState({kind:"form"}),[U,q]=o.useState(!1),[re,Y]=o.useState(!1),[A,_]=o.useState(null),L=o.useRef(p);L.current=p;const Z=m.kind==="form"?m.saved:m.schedule,N=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,O=m.kind==="form"&&m.saved!=null,T=r==="create"&&m.kind==="form"&&m.saved==null,{allows:J}=ve({resourceType:"agent",resourceIds:p.length===0?[]:[p]});o.useEffect(()=>{if(!t){k(fe()),i(l),z(null),_(null),C({kind:"form"}),Y(!1);return}if(r==="edit"&&a!=null){k(Me({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),z(null),C({kind:"form"});return}k(fe()),i(l),z(null),C({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const v=l;return zt({server:b,agentKey:v}).then(w=>{f||w==null||L.current===v&&(z(w),i(Ve(w)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,b]);const G=(y==null?void 0:y.name)??(Z==null?void 0:Z.agentName)??(a==null?void 0:a.agentName)??(p.length>0?p:""),ge=o.useMemo(()=>{var v;return(((v=y==null?void 0:y.agentSpec)==null?void 0:v.mcpServers)??[]).map(At).filter(w=>w!=null).map(w=>({name:w}))},[y]),le=o.useMemo(()=>{const f=Se(x);return x.name.trim().length>0&&x.task.trim().length>0&&we(f)&&p.length>0&&(!T||J(p,"USE"))},[p,J,x,T]),V=f=>{C({kind:"test",schedule:f}),k(Me({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!le)return;const v=Se(x);q(!0),_(null);try{if(N&&a!=null){await S.updateSchedule({id:a.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:a.status}),j(Q.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),u==null||u(),n(!1);return}if(O&&m.kind==="form"&&m.saved!=null){const I=await S.updateSchedule({id:m.saved.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.EDITED,{schedule_id:I.id,agent_id:I.agentId}),u==null||u(),V(I),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:I.cron,timezone:I.timezone})});return}const w=await S.createSchedule({agentId:p,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.CREATED,{schedule_id:w.id,agent_id:p}),u==null||u(),V(w),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:w.cron,timezone:w.timezone})})}catch(w){const I=w instanceof Error?w.message:"Failed to save schedule";_(I)}finally{q(!1)}},ee=async()=>{if(m.kind==="test"){Y(!0),_(null);try{await S.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),u==null||u(),h==null||h.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const v=f instanceof Error?f.message:"Failed to activate schedule";_(v),h==null||h.showError(f)}finally{Y(!1)}}},te=m.kind==="test"?"Test Schedule":N||O?"Edit Schedule":"New Schedule",M=m.kind==="test"?`Recurring unattended runs of ${G}.`:N||O?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let se;return m.kind==="test"?se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsx($.Secondary,{type:"button",className:"w-full",disabled:re,onClick:()=>void ee(),children:"Activate Schedule"})]}):se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx($.Secondary,{type:"button",onClick:()=>n(!1),disabled:U,children:"Cancel"}),e.jsx($.Primary,{type:"submit",form:"schedule-form",disabled:!le||U,children:"Save"})]})]}),e.jsx(Rt,{open:t,onOpenChange:n,title:te,description:M,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(R,{name:m.kind==="test"||N||O?"calendar":"calendar-plus",className:"size-5"})}),footer:se,children:m.kind==="test"?e.jsx(Jt,{schedule:m.schedule,agentName:G,mcpMounts:ge,onEditConfiguration:()=>{_(null),C({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Ht,{values:x,onChange:k,agentId:p,agentLabel:G,onAgentIdChange:N||O?void 0:f=>{i(f),f.length===0&&z(null)},onAgentPicked:z,agentPickerDisabled:N||O,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function $e(t){return e.jsx(Et,{children:e.jsx(Xt,{...t})})}function es({runs:t,onOpenSession:n}){const r=Wt(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Xe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var ts=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Be=[10,25];function he(t){return Math.min(Math.max(t,1),25)}function oe(t){const n=Ee(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all",scheduleId:n.scheduleId}}function ss(t){const n=Ee(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function ns({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:u,onTogglePause:S,onDelete:b}){const d=kt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs($.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(R,{name:n?"loader":"play",className:B("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(Tt,{align:"end",trigger:e.jsx("button",{type:"button",className:Ct({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(R,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:u,children:[e.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:S,children:[e.jsx(R,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(je,{className:"text-failure-bg focus:text-failure-bg",onClick:b,children:[e.jsx(R,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ls({agentId:t}){const n=Te(),r=Ue(),a=Ce(),l=Ge(),u=He(),S=lt(),b=u!=null&&vt({sessions:S}),[d,h]=o.useState([]),{allows:j}=ve({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[x,k]=o.useState({}),[p,i]=o.useState(!1),[y,z]=o.useState(()=>new Set),[m,C]=o.useState({}),[U,q]=o.useState(!0),[re,Y]=o.useState(null),[A,_]=o.useState(()=>oe(window.location.search).nameQuery),[L,Z]=o.useState(()=>oe(window.location.search).statusFilter),[N,O]=o.useState(()=>t??oe(window.location.search).agentFilter),[T,J]=o.useState(()=>oe(window.location.search).scheduleId),G=t??(N==="all"?null:N),{allows:ge}=ve({resourceType:"agent",resourceIds:G==null?[]:[G]}),le=r.permissions==null||G==null||ge(G,"USE"),[V,X]=o.useState(()=>ss(t)),[ee,te]=o.useState(null),[M,se]=o.useState(()=>he(yt)),[f,v]=o.useState(void 0),[w,I]=o.useState(void 0),[ne,P]=o.useState(void 0),tt=({run:s,schedule:c})=>{if(!b||u==null||s.sessionId==null)return;l(Q.Schedule.RUN_SESSION_OPENED,{schedule_id:c.id,agent_id:c.agentId});const g=St(s.triggeredAt??s.scheduledFor);wt({sessionId:s.sessionId,view:"sessions",...g==null?{}:{timeRange:g}}),u.setSessionsOpen(!0)},H=o.useRef(0),ze=o.useRef(!1),be=o.useCallback(async({rows:s,gen:c})=>{if(s.length===0){c===H.current&&k({});return}i(!0);try{const g=await Promise.allSettled(s.map(E=>n.listScheduleRuns({scheduleId:E.id})));if(c!==H.current)return;k(Object.fromEntries(s.map((E,D)=>{const F=g[D],ue=(F==null?void 0:F.status)==="fulfilled"?F.value:[];return[E.id,ue]})))}finally{c===H.current&&i(!1)}},[n]),ae=o.useCallback(async({token:s,size:c,agentId:g,pinnedScheduleId:E})=>{const D=++H.current;q(!0),Y(null);try{if(E!=null){const ue=await n.getSchedule({id:E});if(D!==H.current)return;h([ue]),I(void 0),P(void 0),be({rows:[ue],gen:D});return}const F=await n.listSchedules({limit:he(c),...s===void 0||s===""?{}:{pageToken:s},...g==="all"?{}:{agentIds:[g]}});if(D!==H.current)return;h(F.data),I(F.nextPageToken),P(F.previousPageToken),be({rows:F.data,gen:D})}catch(F){if(D!==H.current)return;Y(it(F,"Check your connection and try again.")),h([]),k({}),I(void 0),P(void 0)}finally{D===H.current&&q(!1)}},[n,be]),Ae=o.useCallback(s=>{const c=(s==null?void 0:s.size)??M,g=(s==null?void 0:s.agentId)??N;J(null),v(void 0),P(void 0),ae({token:void 0,size:c,agentId:g,pinnedScheduleId:null})},[N,ae,M]);o.useEffect(()=>{Fe({agent:t===void 0&&N!=="all"?N:null,status:L==="all"?null:L,q:A.trim().length===0?null:A,scheduleId:T})},[N,t,L,A,T]),o.useEffect(()=>{t!==void 0&&O(s=>s===t?s:(v(void 0),P(void 0),t))},[t]),o.useEffect(()=>{ze.current||!Ee(window.location.search).isNew||(ze.current=!0,Fe({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const c=oe(window.location.search);_(c.nameQuery),Z(c.statusFilter),J(g=>g===c.scheduleId?g:(v(void 0),P(void 0),c.scheduleId)),O(g=>{const E=t??c.agentFilter;return g===E?g:(v(void 0),P(void 0),E)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{ae({token:f,size:M,agentId:N,pinnedScheduleId:T})},[N,M,f,ae,T]),o.useEffect(()=>{if(T==null||A.trim().length>0)return;const s=d.find(c=>c.id===T);s!=null&&_(s.name)},[A,T,d]);const de=o.useMemo(()=>{if(T!=null)return d;const s=A.trim().toLowerCase();return d.filter(c=>!(L!=="all"&&c.status!==L||s.length>0&&!c.name.toLowerCase().includes(s)))},[d,A,L,T]),Re=ot(d),Ie=ne!=null||w!=null,st=async s=>{if(!j(s.id,"MANAGE"))return;const c=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:c}),l(Q.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:c}),await ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}catch(g){a==null||a.showError(g)}},nt=async s=>{if(j(s.id,"MANAGE")){z(c=>new Set(c).add(s.id));try{if(await n.createScheduleRun({scheduleId:s.id}),l(Q.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"}),T!=null){const g=await n.getSchedule({id:T});h(E=>{const D=E.length===1?E[0]:void 0;return D!=null&&D.id===g.id?[g]:E})}const c=await n.listScheduleRuns({scheduleId:s.id});k(g=>({...g,[s.id]:c}))}catch(c){a==null||a.showError(c)}finally{z(c=>{const g=new Set(c);return g.delete(s.id),g})}}},at=async s=>{if(j(s.id,"DELETE")){te(null);try{await n.deleteSchedule({id:s.id}),l(Q.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Ae()}catch(c){a==null||a.showError(c)}}},Pe=()=>{w!=null&&v(w)},De=()=>{ne==null||ne===""||v(ne)},pe=()=>{T!=null&&(J(null),v(void 0),P(void 0))};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(ct,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(dt,{query:A,setQuery:s=>{_(s),pe()},placeholder:"Search schedules by name"})}),e.jsx(xe,{value:L,onValueChange:s=>{Z(s),pe()},options:ts,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(qe,{value:N,selectedLabel:N==="all"?"All agents":m[N]??N,onValueChange:s=>{O(s),v(void 0),P(void 0),pe()},onAgentPicked:s=>{C(c=>({...c,[Ve(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs($.Primary,{type:"button",disabled:!le,onClick:()=>le&&X({kind:"create",agentId:N!=="all"?N:void 0}),children:[e.jsx(R,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:B("min-h-0 flex-1 overflow-auto px-4 py-4",re!=null?"flex flex-col":void 0),children:U?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,c)=>e.jsx(ut,{className:"h-12 w-full rounded-md"},c))}):re!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Ne,{title:"Couldn't load schedules",description:re,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(Ne,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):de.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Ne,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ie?e.jsx(_e,{pageSize:M,rowCount:0,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(mt,{className:"min-w-240",children:[e.jsx(ht,{children:e.jsxs(Le,{className:"hover:bg-transparent",children:[e.jsx(W,{children:"Schedule Name"}),e.jsx(W,{children:"Task"}),Re?e.jsx(W,{children:"Created by"}):null,e.jsx(W,{children:"Frequency"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Last 5 runs"}),e.jsx(W,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(xt,{children:de.map(s=>{const c=ce({cron:s.cron,timezone:s.timezone}),g=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(Le,{children:[e.jsxs(K,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(R,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:g})]})]}),e.jsx(K,{className:"w-64 max-w-64",children:e.jsx(We,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Re?e.jsx(K,{children:e.jsx(ft,{subject:s.createdBySubject})}):null,e.jsx(K,{children:c}),e.jsx(K,{children:e.jsx(et,{status:s.status})}),e.jsx(K,{children:p?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(es,{runs:x[s.id]??[],...b?{onOpenSession:E=>tt({run:E,schedule:s})}:{}})}),e.jsx(K,{className:"text-right",children:e.jsx(ns,{schedule:s,running:y.has(s.id),canManage:j(s.id,"MANAGE"),canDelete:j(s.id,"DELETE"),onRunNow:()=>void nt(s),onEdit:()=>{j(s.id,"MANAGE")&&X({kind:"edit",schedule:s})},onTogglePause:()=>void st(s),onDelete:()=>{j(s.id,"DELETE")&&te(s)}})})]},s.id)})})]}),(de.length>0||Ie)&&e.jsx(_e,{pageSize:M,rowCount:de.length,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}})]})}),V.kind==="create"?e.jsx($e,{open:!0,mode:"create",initialAgentId:V.agentId??"",onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>Ae()}):null,V.kind==="edit"?e.jsx($e,{open:!0,mode:"edit",schedule:V.schedule,onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>void ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}):null,ee!=null?e.jsxs(gt,{open:!0,onOpenChange:s=>{s||te(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(bt,{children:e.jsxs(pt,{children:[e.jsx(Nt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",ee.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(jt,{children:[e.jsx($.Secondary,{type:"button",onClick:()=>te(null),children:"Cancel"}),e.jsx($.Destructive,{type:"button",disabled:!j(ee.id,"DELETE"),onClick:()=>void at(ee),children:"Delete"})]})]}):null]})}export{ls as SchedulesPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-3RSWQ5WD-BUbTYQmV.js","./chunk-LFIIKLPG-DcaznAz-.js","./index-aDyvsTqL.js","./index-B01pXqvC.css","./ConnectorSettings-E3KBW7HI-Bqrsm5Dp.js","./SkillSettings-XLK6REIA-UZs1mGXm.js","./SandboxSettings-YIEGCYQO-CunudcIx.js","./WebSearchSettings-PKYKXD26-vhZuRM_V.js","./MemorySettings-Y6HNEYIW-O-E_902u.js"])))=>i.map(i=>d[i]);
2
- import{bn as O,ab as D,bz as P,b as L,bA as I,q as A,a9 as M,bB as z,bf as T,r,_ as S,bC as R,j as s,P as B,I as E,a3 as V,c as p,bD as W,bk as n,bi as H}from"./index-aDyvsTqL.js";var q=r.lazy(()=>n(()=>import("./ModelSettings-3RSWQ5WD-BUbTYQmV.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),F=r.lazy(()=>n(()=>import("./ConnectorSettings-E3KBW7HI-Bqrsm5Dp.js"),__vite__mapDeps([4,1,2,3]),import.meta.url)),G=r.lazy(()=>n(()=>import("./SkillSettings-XLK6REIA-UZs1mGXm.js"),__vite__mapDeps([5,1,2,3]),import.meta.url)),K=r.lazy(()=>n(()=>import("./SandboxSettings-YIEGCYQO-CunudcIx.js"),__vite__mapDeps([6,1,2,3]),import.meta.url)),J=r.lazy(()=>n(()=>import("./WebSearchSettings-PKYKXD26-vhZuRM_V.js"),__vite__mapDeps([7,1,2,3]),import.meta.url)),Q=r.lazy(()=>n(()=>import("./MemorySettings-Y6HNEYIW-O-E_902u.js"),__vite__mapDeps([8,2,3]),import.meta.url));function U(){return s.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(H,{size:20,className:"text-text-secondary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]})}var X=({headerStart:k}={})=>{var j;const{settingsOpen:i,settingsSection:a,setSettingsOpen:o}=O(),l=D(),x=P(),h=(j=L())==null?void 0:j.settings,c=I(),m=A(),{refresh:y}=M(),C=z(),N=T(),u=C||N,g=(l==null?void 0:l.skillCatalog)!=null,v=(l==null?void 0:l.sandboxCatalog)!=null,_=(l==null?void 0:l.webSearchCatalog)!=null||x!=null,w=(l==null?void 0:l.memoryCatalog)!=null||x!=null,f=r.useCallback(()=>{m(S.Settings.CLOSED,{section:a}),o(!1)},[a,o,m]);r.useEffect(()=>{if(i)return()=>{y(),c==null||c()}},[i,y,c]),r.useEffect(()=>{if(!i)return;const e=b=>{b.key==="Escape"&&(W()||(b.stopImmediatePropagation(),f()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[f,i]);const d=r.useMemo(()=>{const e=[{id:"models",label:"Models",icon:"cpu",capability:"modelProviders"},{id:"connectors",label:"Connectors",icon:"plug",capability:"mcpServers"}];return g&&e.push({id:"skills",label:"Skills",icon:"lightbulb",capability:"skills"}),v&&e.push({id:"sandbox",label:"Sandbox providers",icon:"cube",capability:"sandboxProviders"}),_&&e.push({id:"web-search",label:"Web search",icon:"search",capability:"webSearch"}),w&&e.push({id:"memory",label:"Memory",icon:"brain",capability:"memoryProviders"}),e.filter(b=>R({settings:h,section:b.capability}))},[g,v,_,w,h]),t=d.find(e=>e.id===a);return r.useEffect(()=>{const e=d[0];t!==void 0||e===void 0||o(i,e.id)},[t,d,i,o]),!i||!l?null:s.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden bg-primary-bg",children:[s.jsx(B,{title:"Settings",start:k??s.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:V({variant:"ghost",size:"icon"}),onClick:f,children:s.jsx(E,{name:"arrow-left"})})}),s.jsxs("div",{className:p("flex min-h-0 min-w-0 flex-1 flex-col",!u&&"md:flex-row"),children:[s.jsx("nav",{"aria-label":"Settings sections",className:p("flex w-full min-w-0 gap-1 border-b border-border bg-secondary-bg/40 p-2",u?"overflow-x-auto":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:d.map(e=>s.jsxs("button",{type:"button","aria-current":a===e.id?"page":void 0,...u?{title:e.label}:{},className:p("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",u?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",a===e.id?"bg-primary-button-bg/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{m(S.Settings.SECTION_CHANGED,{section:e.id}),o(!0,e.id)},children:[s.jsx(E,{name:e.icon,className:"h-4 w-4 shrink-0"}),u?s.jsx("span",{className:"truncate",children:e.label}):e.label]},e.id))}),s.jsx("section",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-hidden px-4 py-4 sm:px-6",children:s.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full min-w-0 max-w-210 flex-col",children:s.jsxs(r.Suspense,{fallback:s.jsx(U,{}),children:[(t==null?void 0:t.id)==="models"?s.jsx(q,{}):null,(t==null?void 0:t.id)==="connectors"?s.jsx(F,{}):null,(t==null?void 0:t.id)==="skills"?s.jsx(G,{}):null,(t==null?void 0:t.id)==="sandbox"?s.jsx(K,{}):null,(t==null?void 0:t.id)==="web-search"?s.jsx(J,{}):null,(t==null?void 0:t.id)==="memory"?s.jsx(Q,{}):null]})})})]})]})},Z=X;export{Z as default};
@@ -1 +0,0 @@
1
- import{bn as ce,d as pe,ab as ge,v as ye,bo as fe,bp as he,bq as de,b as me,br as Se,r as a,bs as be,bt as Ae,x as Oe,bu as ve,D as Ne,bv as _,bw as P,bx as ne,by as B}from"./index-aDyvsTqL.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-Bm8RoZbE.js";var $="try_agent_name",k="history_agent_name";function te(t){return t!=null&&t.length>0?t:null}function T(t){const o=new URLSearchParams(t.startsWith("?")?t.slice(1):t),u=te(o.get($));if(u!=null)return{intent:"try-agent",agentName:u};const e=te(o.get(k));return e==null?null:{intent:"history",agentName:e}}function Ce(t,o){t.delete($),t.delete(k),o!=null&&t.set(o.intent==="try-agent"?$:k,o.agentName)}function se(t,o){const u=new URLSearchParams(t.startsWith("?")?t.slice(1):t);Ce(u,o);const e=u.toString();return e.length>0?`?${e}`:""}function re(t){const o=t.sessionAccessError!=null?t.pendingSessionId:t.activeRemoteId??t.pendingSessionId;if(o!=null)return{type:"session",sessionId:o};const{mode:u,agentConfigMode:e}=t;if(u.status==="active"&&u.isMutable&&u.isCreateAgent)return{type:"buildAgent"};if(u.status==="active"&&!u.isMutable&&e!=="SingleAgent"){const p=u.agentName??u.agentId;if(p!=null)return{type:"agent",agentName:p}}return{type:"root"}}function Pe(t){return t.settingsOpen?{type:"settings"}:t.schedulesOpen?{type:"schedules"}:t.environmentsOpen?{type:"environments"}:t.sessionsOpen&&t.sharedSessionId!=null?{type:"sharedSession",sessionId:t.sharedSessionId}:t.sessionsOpen?{type:"sessionsBrowser"}:t.libraryOpen&&t.libraryAgentId!=null?{type:"libraryAgent",agentId:t.libraryAgentId}:t.libraryOpen?{type:"library"}:re(t)}function O(t){return t.type==="root"||t.type==="agent"||t.type==="session"}function Ie(t){return t.type==="sessionsBrowser"||t.type==="sharedSession"}function Le({routes:t,activeRemoteId:o,initialSettingsOpen:u}){var Z,x;const e=ce(),p=pe(),q=ge(),v=ye(),I=fe(),G=he(),K=de(),W=me(),Y=Se(),w=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:W,sessions:v,schedules:G,sandboxEnvironments:K}),[t,q,W,v,G,K]),U=c.settings!=null,ae=[c.settings,c.sessionsBrowser,c.sharedSession,c.libraryAgent,c.schedules,c.environments].join("\0"),D={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,sharedSessionId:e.sharedSessionId,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,environmentsOpen:e.environmentsOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:o,sessionAccessError:e.sessionAccessError,mode:e.mode,agentConfigMode:e.agentConfigMode},g=Pe(D),ie=JSON.stringify(g),S=a.useRef(null),H=a.useRef(null),N=a.useRef(null),R=a.useRef(!1),b=a.useRef(null),[le,oe]=a.useState(0),m=a.useRef(null),L=a.useRef(null),Q=`${e.runtimeKey}\0${e.pendingSessionEpoch}`,M=a.useRef(Q);M.current=Q;const y=a.useRef(null),j=a.useRef(!1),z=a.useRef(!1),J=a.useCallback(()=>{switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.setEnvironmentsOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}},[e]),A=a.useCallback(n=>{const s=b.current;(s==null?void 0:s.type)==="session"&&s.sessionId===n&&(b.current=null,oe(l=>l+1))},[]),V=a.useCallback(n=>{if(L.current=n,p==null){e.openHistorySession({sessionId:n});return}const s=M.current,l=I==null||v==null?Promise.resolve(!0):I.listPermissions({resourceType:"session",resourceIds:[n]}).then(i=>(i.data.permissions[n]??[]).includes("MANAGE")).catch(()=>!0);Promise.all([p.getSession({sessionId:n}),l]).then(([i,f])=>{if(L.current!==n){A(n);return}if(!f){A(n),e.openSharedSession(n);return}e.openHistorySession({sessionId:n,isMutable:i.isMutable,isCreateAgent:Ae(i),...i.agentName!=null?{agentName:i.agentName}:{}})}).catch(i=>{if(L.current!==n){A(n);return}if(M.current!==s){A(n);return}e.openInaccessibleSession({sessionId:n,message:Oe(i,"This session could not be loaded.")})})},[I,A,p,v,e]),d=a.useCallback(n=>{if(n==null){y.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const s=`${n.intent}\0${n.agentName}`,l=e.historyAgentFilter;if((l==null?void 0:l.intent)===n.intent&&l.agentName===n.agentName&&l.agentId!=null){y.current=null;return}y.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(y.current===s){if(i==null){y.current=null,m.current=null,e.setHistoryAgentFilter(null);return}y.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{y.current===s&&(y.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[p,e]),X=a.useCallback(n=>{e.selectLibraryAgent({isMutable:!1,agentName:n}),d({intent:"try-agent",agentName:n})},[d,e]),F=a.useCallback(n=>{switch(n.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"sharedSession":e.openSharedSession(n.sessionId);return;case"libraryAgent":e.openLibraryAgent(n.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"environments":e.setEnvironmentsOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===n.sessionId||o===n.sessionId)return;V(n.sessionId);return;case"agent":e.setLibraryOpen(!1),X(n.agentName);return;case"root":J();return}},[e,o,J,X,V]);return a.useEffect(()=>{if(R.current)return;const n=_({pathname:r.pathname,search:r.search,routes:t});if(!Y&&((n==null?void 0:n.type)==="settings"||(n==null?void 0:n.type)==="environments"))return;R.current=!0;const s=_({pathname:r.pathname,search:r.search,routes:c})??{type:"root"},l=s.type==="agent"?{intent:"try-agent",agentName:s.agentName}:O(s)?T(r.search):null;m.current=l,N.current=s;const i=U&&(u||s.type==="settings");if(s.type==="settings")U&&e.setSettingsOpen(!0);else if(s.type==="library")e.setLibraryOpen(!0);else if(s.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(s.type==="libraryAgent")e.openLibraryAgent(s.agentId);else if(s.type==="schedules")e.setSchedulesOpen(!0);else if(s.type==="environments")e.setEnvironmentsOpen(!0);else{const C=re(D);P(C,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const f=i?{type:"settings"}:s;b.current=P(g,f)?null:f;const h=ne(f,c),E=se(B(f,r.search),l);H.current=f,h!=null&&(h!==r.pathname||E!==r.search)&&(S.current=h!==r.pathname?h:null,w({pathname:h,search:E,hash:r.hash},{replace:!0}))},[Y]),a.useEffect(()=>{if(!R.current)return;if(!j.current){j.current=!0;return}const n=b.current;if(n!=null){if(!P(g,n))return;b.current=null}const s=ne(g,c);if(s==null)return;const i=`${c.basename.endsWith("/")?c.basename.slice(0,-1):c.basename}${r.pathname}`||"/",f=window.location.pathname===i?window.location.search:r.search,h=O(g),E=h?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!h&&e.historyAgentFilter!=null&&(y.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const C=se(B(g,f),E),ee=H.current;if(H.current=g,s===r.pathname&&C===r.search)return;const ue=g.type==="session"&&e.pendingSessionId==null&&ee!=null&&ee.type!=="session";S.current=s!==r.pathname?s:null,w({pathname:s,search:C,hash:r.hash},{replace:ue})},[ie,ae,le,(Z=e.historyAgentFilter)==null?void 0:Z.agentName,(x=e.historyAgentFilter)==null?void 0:x.intent]),a.useEffect(()=>{if(!R.current)return;if(!z.current){z.current=!0;return}if(S.current===r.pathname){S.current=null,N.current=g;return}const n=_({pathname:r.pathname,search:r.search,routes:c});if(n==null){const l=c.root,i=B({type:"root"},r.search);S.current=l,w({pathname:l,search:i,hash:r.hash},{replace:!0}),F({type:"root"}),d(T(i));return}const s=N.current;N.current=n,(s==null||!P(s,n))&&(n.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),n.type!=="library"&&n.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),!Ie(n)&&e.sessionsOpen&&e.setSessionsOpen(!1),n.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),n.type!=="environments"&&e.environmentsOpen&&e.setEnvironmentsOpen(!1),F(n)),n.type!=="agent"&&O(n)?d(T(r.search)):O(n)||d(null)},[r.pathname,r.search]),null}export{Le as ShellRouteSync};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-6WNST3GI-DtS3ib0p.js","./index-aDyvsTqL.js","./index-B01pXqvC.css","./SchedulesPage-OVDMYD6Q-BKu9sdHs.js","./chunk-HWOHXUGH-KXcUS5XW.js","./EnvironmentsPage-BUA2EGXE-CcV5njoc.js","./chunk-LFIIKLPG-DcaznAz-.js"])))=>i.map(i=>d[i]);
2
- import{cI as B,cJ as sn,be as J,j as s,cK as rn,r as m,bU as A,cL as qe,cM as on,cN as Qe,cO as Ze,cP as Je,cQ as et,cR as tt,cS as oe,cT as an,cU as P,cV as cn,cW as ln,cX as dn,cY as un,cZ as mn,c_ as fn,c$ as hn,d0 as pn,d1 as Te,d2 as xn,d3 as gn,d4 as ge,d5 as vn,d6 as bn,d7 as wn,d8 as nt,d9 as ze,da as ve,db as Re,dc as de,dd as Ne,de as Pe,df as Ee,dg as $e,d as Ae,q as st,t as ie,u as T,b$ as yn,w as In,c0 as Me,dh as jn,c2 as rt,c3 as Mn,c1 as Sn,di as Cn,k as ot,I as V,a3 as re,c as W,p as Ln,dj as Tn,dk as Rn,_ as he,bS as pe,dl as we,dm as Nn,bf as De,bB as at,dn as Pn,S as En,a2 as Ge,D as An,dp as it,dq as Dn,dr as _n,ds as On,dt as He,bG as kn,aa as Bn,E as Ue,bh as ct,du as Fn,P as Kn,dv as zn,bi as ye,bj as $n,dw as lt,dx as dt,c8 as Gn,bk as _e,dy as Hn,cF as Un}from"./index-aDyvsTqL.js";import{A as Vn,N as Wn,T as Xn,S as ut}from"./chunk-OXW7TUTC-UBWEIyxU.js";import{C as Yn}from"./chunk-LFIIKLPG-DcaznAz-.js";import{s as qn,u as Qn,S as Zn}from"./chunk-HK4WITDD-DSX_ymmz.js";const Oe=n=>{const e=B(8),{index:t,archived:o,children:r}=n;let i;e[0]!==o||e[1]!==t?(i=sn({source:"threads",query:{type:"index",index:t,archived:o},get:d=>d.threads().item({index:t,archived:o})}),e[0]=o,e[1]=t,e[2]=i):i=e[2];let c;e[3]!==i?(c={threadListItem:i},e[3]=i,e[4]=c):c=e[4];const a=J(c);let u;return e[5]!==a||e[6]!==r?(u=s.jsx(rn,{value:a,children:r}),e[5]=a,e[6]=r,e[7]=u):u=e[7],u},mt=m.memo(n=>{const e=B(6),{index:t,archived:o,components:r}=n,i=o===void 0?!1:o,c=r.ThreadListItem;let a;e[0]!==c?(a=s.jsx(c,{}),e[0]=c,e[1]=a):a=e[1];let u;return e[2]!==i||e[3]!==t||e[4]!==a?(u=s.jsx(Oe,{index:t,archived:i,children:a}),e[2]=i,e[3]=t,e[4]=a,e[5]=u):u=e[5],u},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);mt.displayName="ThreadListPrimitive.ItemByIndex";const Ve=({archived:n,children:e})=>{const t=A(o=>n?o.threads.archivedThreadIds.length:o.threads.threadIds.length);return qe(()=>Array.from({length:t},(o,r)=>s.jsx(Oe,{index:r,archived:n,children:s.jsx(on,{getItemState:i=>i.threads().item({index:r,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},r)),[t,n,e])},ft=n=>{const e=B(8),{archived:t,components:o,children:r}=n,i=t===void 0?!1:t;if(o){const a=o.ThreadListItem;let u;e[0]!==a?(u=()=>s.jsx(a,{}),e[0]=a,e[1]=u):u=e[1];let d;return e[2]!==i||e[3]!==u?(d=s.jsx(Ve,{archived:i,children:u}),e[2]=i,e[3]=u,e[4]=d):d=e[4],d}let c;return e[5]!==i||e[6]!==r?(c=s.jsx(Ve,{archived:i,children:r}),e[5]=i,e[6]=r,e[7]=c):c=e[7],c};ft.displayName="ThreadListPrimitive.Items";const ht=n=>{const e=B(2),{fallback:t}=n,o=A(Jn)||t;let r;return e[0]!==o?(r=s.jsx(s.Fragment,{children:o}),e[0]=o,e[1]=r):r=e[1],r};ht.displayName="ThreadListItemPrimitive.Title";function Jn(n){return n.threadListItem.title}const es=()=>{const n=B(4),e=J();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={archive:o},n[2]=o,n[3]=r):r=n[3],r},ts=()=>{const n=B(4),e=J();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={delete:o},n[2]=o,n[3]=r):r=n[3],r},ns=()=>{const n=B(4),e=J();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={unarchive:o},n[2]=o,n[3]=r):r=n[3],r},ss=()=>{const n=B(4),e=J();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={switchTo:o},n[2]=o,n[3]=r):r=n[3],r},rs=()=>{const n=B(4),e=J();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={switchToNewThread:o},n[2]=o,n[3]=r):r=n[3],r},os=()=>{const n=B(5),e=J(),t=A(as);let o;n[0]!==e?(o=()=>{e.threads().loadMore()},n[0]=e,n[1]=o):o=n[1];const r=o;let i;return n[2]!==t||n[3]!==r?(i={loadMore:r,disabled:t},n[2]=t,n[3]=r,n[4]=i):i=n[4],i};function as(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var is=Object.defineProperty,R=(n,e)=>is(n,"name",{value:e,configurable:!0}),cs=["Enter"," "],ls=["ArrowDown","PageUp","Home"],pt=["ArrowUp","PageDown","End"],ds=[...ls,...pt],be="Menu",[Se,us,ms]=et(be),[ae,xt]=Qe(be,[ms,Ze,Je]),ke=Ze(),gt=Je(),[fs,ue]=ae(be),[hs,Be]=ae(be),ps=R(n=>{const{__scopeMenu:e,open:t=!1,children:o,dir:r,onOpenChange:i,modal:c=!0}=n,a=ke(e),[u,d]=m.useState(null),f=m.useRef(!1),l=gn(i),p=ge(r);return m.useEffect(()=>{const h=R(()=>{f.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},"handleKeyDown"),g=R(()=>f.current=!1,"handlePointer");return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),m.useEffect(()=>{if(!t)return;const h=R(()=>l(!1),"handleBlur");return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)},[t,l]),s.jsx(vn,{...a,children:s.jsx(fs,{scope:e,open:t,onOpenChange:l,content:u,onContentChange:d,children:s.jsx(hs,{scope:e,onClose:m.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:f,dir:p,modal:c,children:o})})})},"Menu"),xs=m.forwardRef(R(function(e,t){const{__scopeMenu:o,...r}=e,i=ke(o);return s.jsx(bn,{...i,...r,ref:t})},"MenuAnchor")),vt="MenuPortal",[gs,vs]=ae(vt,{forceMount:void 0}),bs=R(n=>{const{__scopeMenu:e,forceMount:t,children:o,container:r}=n,i=ue(vt,e);return s.jsx(gs,{scope:e,forceMount:t,children:s.jsx(tt,{present:t||i.open,children:s.jsx(wn,{asChild:!0,container:r,children:o})})})},"MenuPortal"),se="MenuContent",[ws,bt]=ae(se),ys=m.forwardRef(R(function(e,t){const o=vs(se,e.__scopeMenu),{forceMount:r=o.forceMount,...i}=e,c=ue(se,e.__scopeMenu),a=Be(se,e.__scopeMenu);return s.jsx(Se.Provider,{scope:e.__scopeMenu,children:s.jsx(tt,{present:r||c.open,children:s.jsx(Se.Slot,{scope:e.__scopeMenu,children:a.modal?s.jsx(Is,{...i,ref:t}):s.jsx(js,{...i,ref:t})})})})},"MenuContent")),Is=m.forwardRef(R(function(e,t){const o=ue(se,e.__scopeMenu),r=m.useRef(null),i=oe(t,r);return m.useEffect(()=>{const c=r.current;if(c)return an(c)},[]),s.jsx(wt,{...e,ref:i,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentModal")),js=m.forwardRef(R(function(e,t){const o=ue(se,e.__scopeMenu);return s.jsx(wt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentNonModal")),Ms=xn("MenuContent.ScrollLock"),wt=m.forwardRef(R(function(e,t){const{__scopeMenu:o,loop:r=!1,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:a,disableOutsidePointerEvents:u,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:l,onFocusOutside:p,onInteractOutside:h,onDismiss:g,disableOutsideScroll:v,...y}=e,I=ue(se,o),S=Be(se,o),j=ke(o),D=gt(o),N=us(o),[U,F]=m.useState(null),G=m.useRef(null),M=oe(t,G,I.onContentChange),C=m.useRef(0),E=m.useRef(""),_=m.useRef(0),K=m.useRef(null),ee=m.useRef("right"),Q=m.useRef(0),te=v?ln:m.Fragment,Y=v?{as:Ms,allowPinchZoom:!0}:void 0,q=R(x=>{var Z,$;const b=E.current+x,L=N().filter(k=>!k.disabled),z=document.activeElement,w=(Z=L.find(k=>k.ref.current===z))==null?void 0:Z.textValue,ne=L.map(k=>k.textValue),X=St(ne,b,w),H=($=L.find(k=>k.textValue===X))==null?void 0:$.ref.current;R((function k(fe){E.current=fe,window.clearTimeout(C.current),fe!==""&&(C.current=window.setTimeout(()=>k(""),1e3))}),"updateSearch")(b),H&&setTimeout(()=>H.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(C.current),[]),cn();const O=m.useCallback(x=>{var L,z;return ee.current===((L=K.current)==null?void 0:L.side)&&Lt(x,(z=K.current)==null?void 0:z.area)},[]);return s.jsx(ws,{scope:o,searchRef:E,onItemEnter:m.useCallback(x=>{O(x)&&x.preventDefault()},[O]),onItemLeave:m.useCallback(x=>{var b;O(x)||((b=G.current)==null||b.focus(),F(null))},[O]),onTriggerLeave:m.useCallback(x=>{O(x)&&x.preventDefault()},[O]),pointerGraceTimerRef:_,onPointerGraceIntentChange:m.useCallback(x=>{K.current=x},[]),children:s.jsx(te,{...Y,children:s.jsx(dn,{asChild:!0,trapped:i,onMountAutoFocus:P(c,x=>{var b;x.preventDefault(),(b=G.current)==null||b.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:s.jsx(un,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:f,onPointerDownOutside:l,onFocusOutside:p,onInteractOutside:h,onDismiss:g,children:s.jsx(mn,{asChild:!0,...D,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:U,onCurrentTabStopIdChange:F,onEntryFocus:P(d,x=>{S.isUsingKeyboardRef.current||x.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(fn,{role:"menu","aria-orientation":"vertical","data-state":yt(I.open),"data-radix-menu-content":"",dir:S.dir,...j,...y,ref:M,style:{outline:"none",...y.style},onKeyDown:P(y.onKeyDown,x=>{const L=x.target.closest("[data-radix-menu-content]")===x.currentTarget,z=x.ctrlKey||x.altKey||x.metaKey,w=x.key.length===1;L&&(x.key==="Tab"&&x.preventDefault(),!z&&w&&q(x.key));const ne=G.current;if(x.target!==ne||!ds.includes(x.key))return;x.preventDefault();const H=N().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);pt.includes(x.key)&&H.reverse(),jt(H)}),onBlur:P(e.onBlur,x=>{x.currentTarget.contains(x.target)||(window.clearTimeout(C.current),E.current="")}),onPointerMove:P(e.onPointerMove,xe(x=>{const b=x.target,L=Q.current!==x.clientX;if(x.currentTarget.contains(b)&&L){const z=x.clientX>Q.current?"right":"left";ee.current=z,Q.current=x.clientX}}))})})})})})})},"MenuContentImpl")),Ce="MenuItem",We="menu.itemSelect",Ss=m.forwardRef(R(function(e,t){const{disabled:o=!1,onSelect:r,...i}=e,c=m.useRef(null),a=Be(Ce,e.__scopeMenu),u=bt(Ce,e.__scopeMenu),d=oe(t,c),f=m.useRef(!1),l=R(()=>{const p=c.current;if(!o&&p){const h=new CustomEvent(We,{bubbles:!0,cancelable:!0});p.addEventListener(We,g=>r==null?void 0:r(g),{once:!0}),hn(p,h),h.defaultPrevented?f.current=!1:a.onClose()}},"handleSelect");return s.jsx(Cs,{...i,ref:d,disabled:o,onClick:P(e.onClick,l),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:P(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:P(e.onKeyDown,p=>{o||p.target!==p.currentTarget||u.searchRef.current!==""&&p.key===" "||cs.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),Cs=m.forwardRef(R(function(e,t){const{__scopeMenu:o,disabled:r=!1,textValue:i,...c}=e,a=bt(Ce,o),u=gt(o),d=m.useRef(null),f=oe(t,d),[l,p]=m.useState(!1),[h,g]=m.useState("");return m.useEffect(()=>{const v=d.current;v&&g((v.textContent??"").trim())},[c.children]),s.jsx(Se.ItemSlot,{scope:o,disabled:r,textValue:i??h,children:s.jsx(pn,{asChild:!0,...u,focusable:!r,children:s.jsx(Te.div,{role:"menuitem","data-highlighted":l?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...c,ref:f,onPointerMove:P(e.onPointerMove,xe(v=>{r?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,xe(v=>a.onItemLeave(v))),onFocus:P(e.onFocus,()=>p(!0)),onBlur:P(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),Ls="MenuRadioGroup",[Fr,Kr]=ae(Ls,{value:void 0,onValueChange:R(()=>{},"onValueChange")}),Ts="MenuItemIndicator",[zr,$r]=ae(Ts,{checked:!1}),Rs=m.forwardRef(R(function(e,t){const{__scopeMenu:o,...r}=e;return s.jsx(Te.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})},"MenuSeparator")),Ns="MenuSub",[Gr,Hr]=ae(Ns);function yt(n){return n?"open":"closed"}R(yt,"getOpenState");function It(n){return n==="indeterminate"}R(It,"isIndeterminate");function Ps(n){return It(n)?"indeterminate":n?"checked":"unchecked"}R(Ps,"getCheckedState");function jt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}R(jt,"focusFirst");function Mt(n,e){return n.map((t,o)=>n[(e+o)%n.length])}R(Mt,"wrapArray");function St(n,e,t){const r=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let c=Mt(n,Math.max(i,0));r.length===1&&(c=c.filter(d=>d!==t));const u=c.find(d=>d.toLowerCase().startsWith(r.toLowerCase()));return u!==t?u:void 0}R(St,"getNextMatch");function Ct(n,e){const{x:t,y:o}=n;let r=!1;for(let i=0,c=e.length-1;i<e.length;c=i++){const a=e[i],u=e[c],d=a.x,f=a.y,l=u.x,p=u.y;f>o!=p>o&&t<(l-d)*(o-f)/(p-f)+d&&(r=!r)}return r}R(Ct,"isPointInPolygon");function Lt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return Ct(t,e)}R(Lt,"isPointerInGraceArea");function xe(n){return e=>e.pointerType==="mouse"?n(e):void 0}R(xe,"whenMouse");var Es=ps,As=xs,Ds=bs,_s=ys,Os=Ss,ks=Rs,Bs=Object.defineProperty,ce=(n,e)=>Bs(n,"name",{value:e,configurable:!0}),Fe="DropdownMenu",[Fs,Tt]=Qe(Fe,[xt]),le=xt(),[Ks,Rt]=Fs(Fe),Nt=ce(n=>{const{__scopeDropdownMenu:e,children:t,dir:o,open:r,defaultOpen:i,onOpenChange:c,modal:a=!0}=n,u=le(e),d=m.useRef(null),[f,l]=nt({prop:r,defaultProp:i??!1,onChange:c,caller:Fe});return s.jsx(Ks,{scope:e,triggerId:ze(),triggerRef:d,contentId:ze(),open:f,onOpenChange:l,onOpenToggle:m.useCallback(()=>l(p=>!p),[l]),modal:a,children:s.jsx(Es,{...u,open:f,onOpenChange:l,dir:o,modal:a,children:t})})},"DropdownMenu"),zs="DropdownMenuTrigger",Pt=m.forwardRef(ce(function(e,t){const{__scopeDropdownMenu:o,disabled:r=!1,...i}=e,c=Rt(zs,o),a=le(o),u=oe(t,c.triggerRef);return s.jsx(As,{asChild:!0,...a,children:s.jsx(Te.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:u,onPointerDown:P(e.onPointerDown,d=>{!r&&d.button===0&&d.ctrlKey===!1&&(c.onOpenToggle(),c.open||d.preventDefault())}),onKeyDown:P(e.onKeyDown,d=>{r||(["Enter"," "].includes(d.key)&&c.onOpenToggle(),d.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})},"DropdownMenuTrigger")),Et=ce(n=>{const{__scopeDropdownMenu:e,...t}=n,o=le(e);return s.jsx(Ds,{...o,...t})},"DropdownMenuPortal"),$s="DropdownMenuContent",At=m.forwardRef(ce(function(e,t){const{__scopeDropdownMenu:o,...r}=e,i=Rt($s,o),c=le(o),a=m.useRef(!1);return s.jsx(_s,{id:i.contentId,"aria-labelledby":i.triggerId,...c,...r,ref:t,onCloseAutoFocus:P(e.onCloseAutoFocus,u=>{var d;a.current||(d=i.triggerRef.current)==null||d.focus(),a.current=!1,u.preventDefault()}),onInteractOutside:P(e.onInteractOutside,u=>{const d=u.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,l=d.button===2||f;(!i.modal||l)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Dt=m.forwardRef(ce(function(e,t){const{__scopeDropdownMenu:o,...r}=e,i=le(o);return s.jsx(Os,{...i,...r,ref:t})},"DropdownMenuItem")),_t=m.forwardRef(ce(function(e,t){const{__scopeDropdownMenu:o,...r}=e,i=le(o);return s.jsx(ks,{...i,...r,ref:t})},"DropdownMenuSeparator")),Ot=Nt,kt=Pt,Gs=Et,Bt=At,Ft=Dt,Kt=_t;const Hs=Object.freeze(Object.defineProperty({__proto__:null,Content:Bt,DropdownMenu:Nt,DropdownMenuContent:At,DropdownMenuItem:Dt,DropdownMenuPortal:Et,DropdownMenuSeparator:_t,DropdownMenuTrigger:Pt,Item:Ft,Portal:Gs,Root:Ot,Separator:Kt,Trigger:kt,createDropdownMenuScope:Tt},Symbol.toStringTag,{value:"Module"})),Us=ve(kt),Vs=ve(Bt),Ws=ve(Ft),Xs=ve(Kt),zt=m.forwardRef((n,e)=>{const t=B(15);let o,r,i;t[0]!==n?({onClick:r,disabled:o,...i}=n,t[0]=n,t[1]=o,t[2]=r,t[3]=i):(o=t[1],r=t[2],i=t[3]);const c=A(Ys),{switchToNewThread:a}=rs();let u;t[4]!==c?(u=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=u):u=t[5];let d;t[6]!==r||t[7]!==a?(d=P(r,a),t[6]=r,t[7]=a,t[8]=d):d=t[8];let f;return t[9]!==o||t[10]!==e||t[11]!==i||t[12]!==u||t[13]!==d?(f=s.jsx(Re.button,{type:"button",...u,...i,ref:e,disabled:o,onClick:d}),t[9]=o,t[10]=e,t[11]=i,t[12]=u,t[13]=d,t[14]=f):f=t[14],f});zt.displayName="ThreadListPrimitive.New";function Ys(n){return n.threads.newThreadId===n.threads.mainThreadId}const qs=()=>{const{loadMore:n,disabled:e}=os();return e?null:n},Qs=de("ThreadListPrimitive.LoadMore",qs),[Zs,Js]=et("ThreadList"),Le=Zs,$t=Pe(null),er=$t.Provider,Ke=()=>Ne($t),Gt=m.forwardRef((n,e)=>{const t=B(3);let o;return t[0]!==n||t[1]!==e?(o=s.jsx(Le.Provider,{scope:void 0,children:s.jsx(Le.Slot,{scope:void 0,children:s.jsx(Re.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o});Gt.displayName="ThreadListPrimitive.Root";var tr=Ee({ItemByIndex:()=>mt,Items:()=>ft,LoadMore:()=>Qs,New:()=>zt,Root:()=>Gt});const Ht=m.forwardRef((n,e)=>{const t=A(d=>d.threads.mainThreadId===d.threadListItem.id),o=$e(null),r=$e(null),i=qe(()=>({triggerRef:o,moreRef:r}),[]),c=Js(void 0),a=ge(),u=d=>{const f=a==="rtl"?"ArrowLeft":"ArrowRight",l=a==="rtl"?"ArrowRight":"ArrowLeft",p=o.current,h=r.current;if(p&&d.target===p)if(d.key==="ArrowDown"||d.key==="ArrowUp"){const g=c().map(y=>y.ref.current).filter(y=>y!==null),v=g[g.indexOf(p)+(d.key==="ArrowDown"?1:-1)];v&&(v.focus(),d.preventDefault())}else d.key===f&&h&&(h.focus(),d.preventDefault());else h&&d.target===h&&d.key===l&&(p==null||p.focus(),d.preventDefault())};return s.jsx(er,{value:i,children:s.jsx(Re.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:P(n.onKeyDown,u),ref:e})})});Ht.displayName="ThreadListItemPrimitive.Root";const nr=()=>{const{archive:n}=es();return n},sr=de("ThreadListItemPrimitive.Archive",nr),rr=()=>{const{unarchive:n}=ns();return n},or=de("ThreadListItemPrimitive.Unarchive",rr),ar=()=>{const{delete:n}=ts();return n},ir=de("ThreadListItemPrimitive.Delete",ar),cr=()=>{const{switchTo:n}=ss();return n},lr=de("ThreadListItemPrimitive.Trigger",cr),Ut=m.forwardRef((n,e)=>{var i;const t=B(3),o=oe(e,(i=Ke())==null?void 0:i.triggerRef);let r;return t[0]!==n||t[1]!==o?(r=s.jsx(Le.ItemSlot,{scope:void 0,children:s.jsx(lr,{...n,ref:o})}),t[0]=n,t[1]=o,t[2]=r):r=t[2],r});Ut.displayName="ThreadListItemPrimitive.Trigger";var dr=Ee({Archive:()=>sr,Delete:()=>ir,Root:()=>Ht,Title:()=>ht,Trigger:()=>Ut,Unarchive:()=>or});const me=Tt(),Vt=Pe(()=>{}),Wt=()=>Ne(Vt),Xt=Pe(!1),Yt=()=>Ne(Xt),qt=n=>{const e=B(26);let t,o,r,i,c,a,u;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:o,onOpenChange:i,sharedFocusGroup:u,modal:r,...a}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=r,e[4]=i,e[5]=c,e[6]=a,e[7]=u):(t=e[1],o=e[2],r=e[3],i=e[4],c=e[5],a=e[6],u=e[7]);const d=u===void 0?!1:u,f=d?!1:r??!0,l=me(t),p=o??!1;let h;e[8]!==i?(h=i?{onChange:i}:{},e[8]=i,e[9]=h):h=e[9];let g;e[10]!==c||e[11]!==p||e[12]!==h?(g={prop:c,defaultProp:p,caller:"ThreadListItemMorePrimitive.Root",...h},e[10]=c,e[11]=p,e[12]=h,e[13]=g):g=e[13];const[v,y]=nt(g);let I;e[14]!==f||e[15]!==v||e[16]!==a||e[17]!==l||e[18]!==y?(I=s.jsx(Ot,{...l,...a,modal:f,open:v,onOpenChange:y}),e[14]=f,e[15]=v,e[16]=a,e[17]=l,e[18]=y,e[19]=I):I=e[19];let S;e[20]!==y||e[21]!==I?(S=s.jsx(Vt.Provider,{value:y,children:I}),e[20]=y,e[21]=I,e[22]=S):S=e[22];let j;return e[23]!==d||e[24]!==S?(j=s.jsx(Xt.Provider,{value:d,children:S}),e[23]=d,e[24]=S,e[25]=j):j=e[25],j};qt.displayName="ThreadListItemMorePrimitive.Root";const Qt=m.forwardRef((n,e)=>{const t=B(10),{__scopeThreadListItemMore:o,...r}=n,i=me(o),c=Ke(),a=Wt(),u=Yt(),d=oe(e,c==null?void 0:c.moreRef),f=ge()==="rtl"?"ArrowLeft":"ArrowRight",l=Us;let p;t[0]!==f||t[1]!==a||t[2]!==u?(p=v=>{!u||v.key!==f||(v.preventDefault(),a(!0))},t[0]=f,t[1]=a,t[2]=u,t[3]=p):p=t[3];const h=P(r.onKeyDown,p);let g;return t[4]!==l||t[5]!==d||t[6]!==r||t[7]!==i||t[8]!==h?(g=s.jsx(l,{...i,...r,onKeyDown:h,ref:d}),t[4]=l,t[5]=d,t[6]=r,t[7]=i,t[8]=h,t[9]=g):g=t[9],g});Qt.displayName="ThreadListItemMorePrimitive.Trigger";const Zt=m.forwardRef((n,e)=>{const t=B(21),{__scopeThreadListItemMore:o,portalProps:r,sideOffset:i,...c}=n,a=i===void 0?4:i,u=me(o),d=Wt(),f=Ke(),l=Yt(),p=ge()==="rtl"?"ArrowRight":"ArrowLeft",h=Hs,g=Vs;let v;t[0]!==p||t[1]!==(f==null?void 0:f.moreRef)||t[2]!==d||t[3]!==l?(v=N=>{var U;!l||N.key!==p||(N.preventDefault(),d(!1),(U=f==null?void 0:f.moreRef.current)==null||U.focus())},t[0]=p,t[1]=f==null?void 0:f.moreRef,t[2]=d,t[3]=l,t[4]=v):v=t[4];const y=P(c.onKeyDown,v);let I;t[5]!==(f==null?void 0:f.moreRef)||t[6]!==l?(I=()=>{var N;l&&((N=f==null?void 0:f.moreRef.current)==null||N.focus())},t[5]=f==null?void 0:f.moreRef,t[6]=l,t[7]=I):I=t[7];const S=P(c.onEscapeKeyDown,I);let j;t[8]!==g||t[9]!==e||t[10]!==c||t[11]!==u||t[12]!==a||t[13]!==y||t[14]!==S?(j=s.jsx(g,{...u,...c,onKeyDown:y,onEscapeKeyDown:S,ref:e,sideOffset:a}),t[8]=g,t[9]=e,t[10]=c,t[11]=u,t[12]=a,t[13]=y,t[14]=S,t[15]=j):j=t[15];let D;return t[16]!==r||t[17]!==u||t[18]!==h.Portal||t[19]!==j?(D=s.jsx(h.Portal,{...u,...r,children:j}),t[16]=r,t[17]=u,t[18]=h.Portal,t[19]=j,t[20]=D):D=t[20],D});Zt.displayName="ThreadListItemMorePrimitive.Content";const Jt=m.forwardRef((n,e)=>{const t=B(7);let o,r;t[0]!==n?({__scopeThreadListItemMore:o,...r}=n,t[0]=n,t[1]=o,t[2]=r):(o=t[1],r=t[2]);const i=me(o);let c;return t[3]!==e||t[4]!==r||t[5]!==i?(c=s.jsx(Ws,{...i,...r,ref:e}),t[3]=e,t[4]=r,t[5]=i,t[6]=c):c=t[6],c});Jt.displayName="ThreadListItemMorePrimitive.Item";const en=m.forwardRef((n,e)=>{const t=B(7);let o,r;t[0]!==n?({__scopeThreadListItemMore:o,...r}=n,t[0]=n,t[1]=o,t[2]=r):(o=t[1],r=t[2]);const i=me(o);let c;return t[3]!==e||t[4]!==r||t[5]!==i?(c=s.jsx(Xs,{...i,...r,ref:e}),t[3]=e,t[4]=r,t[5]=i,t[6]=c):c=t[6],c});en.displayName="ThreadListItemMorePrimitive.Separator";var Ie=Ee({Content:()=>Zt,Item:()=>Jt,Root:()=>qt,Separator:()=>en,Trigger:()=>Qt});function ur(){const n=ie(),e=Ae(),t=De(),o=at(),r=t||o,[i,c]=m.useState(!1),[a,u]=m.useState(""),[d,f]=m.useState(null),l=m.useRef(null),p=m.useRef(null),h=m.useId(),g=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,v=(n==null?void 0:n.historyAgentFilter)??null;m.useEffect(()=>{i||u("")},[i]);const{agents:y,isInitialLoading:I,isSearching:S,loadingMore:j,hasMore:D,listRef:N,sentinelRef:U}=Pn({enabled:i&&g,query:a});if(m.useLayoutEffect(()=>{if(!i||r){f(null);return}const M=()=>{var E;const C=(E=l.current)==null?void 0:E.getBoundingClientRect();C&&f({top:C.top,left:C.right+4})};return M(),window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[i,r]),m.useEffect(()=>{if(!i||r)return;const M=C=>{var _,K;const E=C.target;(_=l.current)!=null&&_.contains(E)||(K=p.current)!=null&&K.contains(E)||c(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[i,r]),!g)return null;const F=M=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(M),c(!1)},G=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-1",onMouseDown:M=>M.stopPropagation(),children:[s.jsx(En,{query:a,setQuery:u,placeholder:"Search agents"}),S?s.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),s.jsxs("div",{ref:N,className:W("mt-1 overflow-y-auto",r?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[a.trim()===""?s.jsxs(Ge,{className:W("justify-between",v==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>F(null),children:["All chats",v==null?s.jsx(V,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,I?s.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):y.length===0?s.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:a.trim()?`No agents match "${a.trim()}".`:"No agents yet."}):s.jsxs(s.Fragment,{children:[y.map(M=>{const C=An(M),E=(v==null?void 0:v.agentId)===C;return s.jsxs(Ge,{className:W("justify-between gap-2 text-left",E&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>F({agentId:C,agentName:M.name,intent:"history"}),children:[s.jsx("span",{className:"min-w-0 truncate",children:M.name}),E?s.jsx(V,{name:"check",className:"size-3.5 shrink-0"}):null]},C)}),D?s.jsx("div",{ref:U,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:j?s.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return s.jsxs("div",{className:"relative shrink-0",children:[s.jsxs("button",{ref:l,type:"button","aria-label":v!=null?`Filter chat history by agent (${v.agentName})`:"Filter chat history by agent","aria-haspopup":r?"dialog":"menu","aria-expanded":i,"aria-controls":i?h:void 0,title:"Filter by agent",className:re({variant:"ghost",size:"icon",className:W("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",v!=null&&"text-text-primary")}),onClick:()=>c(M=>!M),children:[s.jsx(V,{name:"funnel",className:"size-3.5"}),v!=null?s.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),r&&i?s.jsx(it,{open:!0,onOpenChange:c,id:h,"aria-label":"Filter agents",children:s.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:G})}):null,!r&&i&&d!=null?Dn.createPortal(s.jsx("div",{ref:p,id:h,role:"menu","aria-label":"Filter agents",style:{top:d.top,left:d.left},className:"aui-popup-enter font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:G}),_n(l.current)):null]})}function mr({open:n,initialTitle:e,saving:t=!1,onOpenChange:o,onSave:r}){const[i,c]=m.useState(e),a=m.useRef(null);m.useEffect(()=>{n&&c(e)},[n,e]),m.useEffect(()=>{if(!n)return;const h=a.current;h!=null&&(h.focus(),h.select())},[n]);const u=i.trim(),f=u.length>0&&u.length<=He&&!t,l=()=>{f&&r(u)},p=h=>{t||o(h)};return s.jsx(kn,{open:n,onOpenChange:p,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(Ue.Secondary,{type:"button",disabled:t,onClick:()=>p(!1),children:"Cancel"}),s.jsx(Ue.Primary,{type:"button",disabled:!f,onClick:l,children:"Save"})]}),children:s.jsx("div",{className:"px-5 py-4",children:s.jsx("input",{ref:a,"aria-label":"Session title",value:i,readOnly:t,maxLength:He,className:Bn("h-9"),onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),l())}})})})}var fr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",hr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function pr({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:o,onRename:r,onDelete:i}){const c=T("PermissionGuard"),a=at(),u=De(),[d,f]=m.useState(!1),[l,p]=m.useState(),h=u||a,g=m.useCallback(S=>{const j=S==null?void 0:S.closest(".aui-theme-root");p(j instanceof HTMLElement?j:void 0)},[]),v=re({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),y=n?s.jsx(c,{allowed:!e,children:s.jsxs("button",{type:"button",className:fr,disabled:e,onClick:()=>{e||(f(!1),r())},children:[s.jsx(V,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,I=t?s.jsx(c,{allowed:!o,children:s.jsxs("button",{type:"button",className:hr,disabled:o,onClick:()=>{o||(f(!1),i())},children:[s.jsx(V,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return h?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":d,className:v,onClick:()=>f(!0),children:s.jsx(V,{name:"ellipsis",className:"size-3.5"})}),d?s.jsx(it,{open:!0,onOpenChange:f,"aria-label":"Session actions",children:s.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[y,I]})}):null]}):s.jsxs(Ie.Root,{sharedFocusGroup:!0,children:[s.jsx(Ie.Trigger,{ref:g,"aria-label":"Session actions",title:"Session actions",className:v,children:s.jsx(V,{name:"ellipsis",className:"size-3.5"})}),s.jsxs(Ie.Content,{portalProps:{container:l},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[y,I]})]})}function xr({selectionRef:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:o,canManageResource:r,canDeleteResource:i}){const c=J(),a=ie(),u=Ae(),d=m.useRef(a==null?void 0:a.runtimeKey);d.current=a==null?void 0:a.runtimeKey;const f=st(),l=Ln(),p=T("ThreadListRow"),h=A(b=>b.threadListItem.id),g=A(b=>b.threadListItem.remoteId),v=A(b=>b.threadListItem.title),y=A(b=>b.threadListItem.lastMessageAt),I=A(b=>b.threadListItem.custom),S=A(b=>b.threads.mainThreadId),j=Tn(I),D=Me(I),N=Rn(y,rt(I)),U=t&&g!=null,F=o&&g!=null,G=U||F,M=g!=null&&!r(g),C=g!=null&&!i(g),E=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0||(a==null?void 0:a.environmentsOpen)===!0,[_,K]=m.useState(!1),[ee,Q]=m.useState(!1),[te,Y]=m.useState(!1),q=v??"New Chat",O=async b=>{if(b===(v??"").trim()){K(!1);return}Q(!0);try{await c.threadListItem().rename(b),f(he.Session.RENAMED,pe(void 0,{sessionId:g,agentName:j})),K(!1)}catch(L){l==null||l.showError(L)}finally{Q(!1)}},x=({sessionMutable:b,rowAgentName:L})=>{const z=!b&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(L==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===L||a.mode.agentId===L),w=On({sessionMutable:b,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:g,pendingSessionId:a==null?void 0:a.pendingSessionId});if((z||w)&&g!=null&&(a==null?void 0:a.sessionAccessError)==null){Promise.resolve(c.threads().switchToThread(h)).catch(()=>{});return}if(g!=null){a==null||a.openHistorySession({sessionId:g,isMutable:b,...L!=null?{agentName:L}:{}});return}Promise.resolve(c.threads().switchToThread(h)).catch(()=>{})};return s.jsxs(dr.Root,{className:"min-w-0",children:[s.jsx(p,{title:q,active:h===S&&!E,agentName:j,...D==null?{}:{lastTurnStatus:D},...N==null?{}:{lastMessageAt:N},onSelect:()=>{f(he.Session.SELECTED,pe({is_mutable:we(I)},{sessionId:g,agentName:j}));const b=++n.current,L=a==null?void 0:a.runtimeKey;if(e==null||e(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1),a==null||a.setEnvironmentsOpen(!1),g!=null&&u!=null&&Nn(I)===void 0&&j==null){u.getSession({sessionId:g}).then(z=>({sessionMutable:z.isMutable,rowAgentName:z.agentName??void 0}),()=>({sessionMutable:we(I),rowAgentName:j})).then(z=>{n.current===b&&d.current===L&&x(z)});return}x({sessionMutable:we(I),rowAgentName:j})},actions:G?s.jsx(pr,{canRename:U,renameDisabled:M,canDelete:F,deleteDisabled:C,onRename:()=>K(!0),onDelete:()=>Y(!0)}):void 0}),te?s.jsx(Yn,{title:"Delete chat",description:`“${q}” will be permanently deleted. This cannot be undone.`,confirmLabel:"Delete",onCancel:()=>Y(!1),onConfirm:()=>{Y(!1),Promise.resolve(c.threadListItem().delete()).then(()=>{f(he.Session.DELETED,pe(void 0,{sessionId:g,agentName:j}))},b=>{l==null||l.showError(b)})}}):null,s.jsx(mr,{open:_,initialTitle:v??"",saving:ee,onOpenChange:K,onSave:b=>{O(b)}})]})}function gr(n){const e=A(o=>o.threads.threadIds),t=A(o=>o.threads.threadItems);return m.useMemo(()=>{const o=Cn({threadIds:e,threadItems:t});if(n==="default")return o;const r=new Map;for(const i of t)r.set(i.id,i),i.remoteId!=null&&r.set(i.remoteId,i);return o.filter(i=>{const c=e[i];if(c===void 0)return!1;const a=r.get(c);return(a==null?void 0:a.remoteId)!=null})},[e,t,n])}function vr(n){return n==="recent-history"||n==="mobile-drawer"}function br({selectionRef:n,indices:e,onThreadOpen:t,canRenameSession:o,canDeleteSession:r,canManageResource:i,canDeleteResource:c}){const a=A(u=>u.threads.threadIds);return s.jsx(s.Fragment,{children:e.map(u=>{const d=a[u]??String(u);return s.jsx(Oe,{index:u,archived:!1,children:s.jsx(xr,{selectionRef:n,onThreadOpen:t,canRenameSession:o,canDeleteSession:r,canManageResource:i,canDeleteResource:c})},d)})})}var wr="aui_thread-list-viewport",yr=80;function Ir({children:n,viewportRef:e,hideScrollbar:t,onCollapse:o}){var d;const r=ie(),i=A(f=>f.threadListItem.remoteId),c=(d=r==null?void 0:r.historyAgentFilter)==null?void 0:d.intent,a=(r==null?void 0:r.isLibraryEnabled)===!0&&c!=="try-agent"&&(c==="history"||r.mode.status!=="active"||r.mode.isMutable||r.pendingSessionId!=null||i!=null),u=(r==null?void 0:r.historyAgentFilter)==null?"Chat History":`Chats for ${r.historyAgentFilter.agentName}`;return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:u}),a?s.jsx(ur,{}):null,o!=null?s.jsx(ot,{content:"Close chat history",side:"right",children:s.jsx("button",{type:"button","aria-label":"Close chat history","aria-expanded":!0,className:re({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text"}),onClick:o,children:s.jsx(V,{name:"panel-left-close",className:"size-3.5"})})}):null]}),s.jsx("div",{ref:e,"data-slot":wr,className:W("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function tn({onThreadOpen:n,onCollapseRecentHistory:e,variant:t="default"}={}){const o=J(),r=Ae(),i=st(),c=A(w=>w.threads.isLoading),a=A(w=>w.threads.isLoadingMore),u=A(w=>w.threads.hasMore),d=A(w=>w.threads.threadIds),f=A(w=>w.threads.threadItems),l=ie(),p=T("ThreadListShell"),h=T("ThreadListNewButton"),g=T("AgentsLibraryButton"),v=T("SessionsBrowserButton"),y=T("SchedulesButton"),I=T("EnvironmentsButton"),S=T("ThreadListRowSkeleton"),j=T("ThreadListEmptyState"),D=gr(t),N=m.useRef(null),U=m.useRef(u),F=m.useRef(o),G=m.useRef(0),M=yn(),C=m.useRef(M);U.current=u,F.current=o,C.current=M;const E=(l==null?void 0:l.isNewChatEnabled)!==!1,_=(l==null?void 0:l.mode.status)==="idle",K=vr(t),ee=t==="mobile-drawer",Q=typeof(r==null?void 0:r.renameSession)=="function",te=typeof(r==null?void 0:r.deleteSession)=="function",Y=m.useMemo(()=>f.flatMap(w=>w.remoteId==null?[]:[w.remoteId]),[f]),{allows:q}=In({resourceType:"session",resourceIds:Y}),O=m.useMemo(()=>_||c||r==null?null:qn(f.map(w=>Me(w.custom))),[_,c,r,f]),x=l==null?void 0:l.listSessionsAgentId;Qn({intervalMs:O,poll:m.useCallback(async()=>{if(r==null)return;const w=C.current;try{const ne=await r.listSessions({createdByMe:!0,limit:Zn,startTimestamp:jn(),...x==null||x.length===0?{}:{agentId:x}}),X=new Map(ne.data.map($=>{var k;return[$.id,{status:(k=$.lastTurnDetails)==null?void 0:k.state.status,updatedAt:$.updatedAt}]})),H=F.current.threads().getState(),Z=H.mainThreadId;for(const $ of H.threadItems){if($.id===Z&&(w||C.current)||$.remoteId==null||!X.has($.remoteId))continue;const k=X.get($.remoteId);if(k==null)continue;const fe=Me($.custom),nn=rt($.custom)??$.lastMessageAt;k.status===fe&&!Mn(k.updatedAt,nn)||F.current.threads().item({id:$.id}).updateCustom(Sn($.custom,k.status??null,k.updatedAt))}}catch{}},[x,r])}),m.useEffect(()=>{if(_||c||a)return;const w=N.current;if(!w)return;let ne=!1;const X=()=>{if(ne||!U.current||w.clientHeight<=0)return;const Z=w.scrollHeight-w.scrollTop-w.clientHeight;w.scrollHeight>w.clientHeight&&Z>yr||F.current.threads().loadMore()};w.addEventListener("scroll",X,{passive:!0});const H=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>X());return H?H.observe(w):window.addEventListener("resize",X),X(),()=>{ne=!0,w.removeEventListener("scroll",X),H==null||H.disconnect(),H||window.removeEventListener("resize",X)}},[u,_,c,a,d.length]);const b=()=>{if(i(he.Session.NEW,pe({is_composer_enabled:(l==null?void 0:l.isComposerEnabled)===!0},{...(l==null?void 0:l.mode.status)==="active"?{agentId:l.mode.agentId,agentName:l.mode.agentName}:{}})),n==null||n(),l==null||l.setLibraryOpen(!1),l==null||l.setSessionsOpen(!1),l!=null&&l.isComposerEnabled){l.openDraft();return}l==null||l.setSettingsOpen(!1),l==null||l.setSchedulesOpen(!1),l==null||l.setEnvironmentsOpen(!1),Promise.resolve(o.threads().switchToNewThread()).catch(()=>{})};let L;_?L=s.jsx(j,{message:K?"No recent chats":void 0}):c?L=s.jsx(S,{}):D.length===0?L=s.jsx(j,{message:K?"No recent chats":void 0}):L=s.jsx(tr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:s.jsx(br,{selectionRef:G,indices:D,onThreadOpen:n,canRenameSession:Q,canDeleteSession:te,canManageResource:w=>q(w,"MANAGE"),canDeleteResource:w=>q(w,"DELETE")})});const z=t==="recent-history"?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[E?s.jsx(h,{onClick:b}):null,s.jsx("div",{className:"contents",onClick:()=>{ee&&(n==null||n())},children:s.jsx(g,{})}),ee?null:s.jsxs(s.Fragment,{children:[s.jsx(v,{}),s.jsx(y,{}),s.jsx(I,{})]})]});return s.jsx(p,{header:z,children:s.jsxs(Ir,{viewportRef:N,hideScrollbar:K,onCollapse:t==="recent-history"?e:void 0,children:[L,!_&&u?s.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var jr=m.lazy(()=>_e(()=>import("./SettingsBuilder-6WNST3GI-DtS3ib0p.js"),__vite__mapDeps([0,1,2]),import.meta.url)),Mr=m.lazy(()=>_e(()=>import("./SchedulesPage-OVDMYD6Q-BKu9sdHs.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),Sr=m.lazy(()=>_e(()=>import("./EnvironmentsPage-BUA2EGXE-CcV5njoc.js"),__vite__mapDeps([5,6,1,2,4]),import.meta.url).then(n=>({default:n.EnvironmentsPage}))),Cr="h-5 w-5 max-w-40 shrink-0 object-contain",Lr="h-5 max-w-40 shrink-0 object-contain",Tr="w-20",Rr="w-80",je="aui-recent-chat-history",Xe=W(Un,"text-sidebar-text"),Ye="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function Nr({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function Pr({collapsed:n,onCollapsedChange:e}){return Gn().presentation==="full"?null:n?s.jsx("aside",{id:je,"aria-label":"Recent chats",className:"hidden min-h-0 w-12 shrink-0 flex-col border-r border-border bg-sidebar-bg md:flex",children:s.jsx("div",{className:"flex w-full items-start justify-center p-2",children:s.jsx(ot,{content:"Open chat history",side:"right",children:s.jsx("button",{type:"button","aria-label":"Open chat history","aria-controls":je,"aria-expanded":!1,className:re({variant:"ghost",size:"icon",className:"size-7 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text"}),onClick:()=>e(!1),children:s.jsx(V,{name:"panel-left-open",className:"size-3.5"})})})})}):s.jsx("aside",{id:je,"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:s.jsx(tn,{variant:"recent-history",onCollapseRecentHistory:()=>e(!0)})})}function Er(){var h;const n=J(),e=ie(),t=T("AgentsLibraryButton"),o=T("SessionsBrowserButton"),r=T("SchedulesButton"),i=T("EnvironmentsButton"),c=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0||(e==null?void 0:e.environmentsOpen)===!0,u=e==null?void 0:e.mode,d=!a&&(u==null?void 0:u.status)==="active"&&!u.isCreateAgent&&((h=e==null?void 0:e.historyAgentFilter)==null?void 0:h.intent)!=="try-agent",f=!a&&u!=null&&ct(u),l=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[c?s.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":d?"page":void 0,className:re({variant:"ghost",className:W(Xe,d&&Ye)}),onClick:l,children:[s.jsx(V,{name:"square-pen",size:14}),s.jsx("span",{className:"text-center",children:"New Chat"})]}):null,c&&(e!=null&&e.isComposerEnabled)?s.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":f?"page":void 0,className:re({variant:"ghost",className:W(Xe,f&&Ye)}),onClick:p,children:[s.jsx(V,{name:"agent-2",size:14}),s.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,s.jsx(t,{compact:!0}),s.jsx(o,{compact:!0}),s.jsx(r,{compact:!0}),s.jsx(i,{compact:!0})]})}function Ar({className:n,railRef:e,...t}){const o=lt(),r=dt(o),i=T("BrandLogo"),c=T("UserAvatar");return s.jsxs("aside",{ref:e,className:W(Tr,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",n),...t,children:[s.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:s.jsx(i,{variant:r.collapsedVariant,className:Cr})}),s.jsx(Er,{}),s.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[s.jsx(ut,{labeled:!0,className:"flex-col"}),s.jsx(c,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function Dr({drawerRef:n,onClose:e}){const t=lt(),o=dt(t),r=Hn(),i=T("BrandLogo"),c=T("UserAvatar");return s.jsxs("aside",{ref:n,role:"dialog","aria-label":"Navigation",tabIndex:-1,className:W(Rr,"absolute inset-y-0 left-0 z-10 flex min-h-0 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden"),children:[s.jsxs("div",{className:"flex h-14 w-full shrink-0 items-center gap-2 border-b border-border px-3 text-text-primary",children:[s.jsx(i,{variant:o.expandedVariant,className:Lr}),o.showTitle&&r!=null?s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:r}):s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx("button",{type:"button","aria-label":"Close navigation",className:re({variant:"ghost",size:"icon"}),onClick:e,children:s.jsx(V,{name:"xmark"})})]}),s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(tn,{variant:"mobile-drawer",onThreadOpen:e})}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-around gap-1 border-t border-border p-2 text-sidebar-text",children:[s.jsx(ut,{labeled:!0,onAction:e,className:"contents"}),s.jsx(c,{labeled:!0})]})]})}function Ur({className:n}){const e=ie(),t=De(),o=T("AgentDetailsPage"),r=T("AgentsLibrary"),i=T("SessionsPage"),c=T("ShareChatButton"),a=T("ResetAgentBuilderButton"),u=T("ClearChatButton"),d=T("SaveAgentButton"),f=T("SelectAgentEmptyState"),[l,p]=m.useState(!1),[h,g]=m.useState(!1),v=m.useRef(null),y=m.useRef(null),I=m.useRef(null),S=m.useRef(!1),j=(e==null?void 0:e.mode.status)==="idle",D=(e==null?void 0:e.settingsOpen)===!0,N=(e==null?void 0:e.libraryOpen)===!0,U=N&&(e==null?void 0:e.libraryAgentId)==null,F=(e==null?void 0:e.sessionsOpen)===!0,G=(e==null?void 0:e.schedulesOpen)===!0,M=(e==null?void 0:e.environmentsOpen)===!0,C=D||N||F||G||M,E=e!=null&&ct(e.mode),_=t&&(F||G||M||E&&!D&&!N),K=E&&!C&&!t,ee=Nr({overlayOpen:C,mode:e==null?void 0:e.mode}),Q=Fn(),te=t&&(D||U),Y=()=>p(!1),q=s.jsx("button",{ref:v,type:"button","aria-label":"Navigation","aria-expanded":l,className:W(re({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>p(!0),children:s.jsx(V,{name:"panel-left"})});return m.useEffect(()=>{if(!l)return;const O=x=>{x.key==="Escape"&&(x.stopImmediatePropagation(),p(!1))};return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[l]),m.useEffect(()=>{var x,b;const O=I.current;if(l){S.current=!0,O&&(O.inert=!0),(x=y.current)==null||x.focus();return}S.current&&(O&&(O.inert=!1),(b=v.current)==null||b.focus(),S.current=!1)},[l]),s.jsxs("div",{className:W("relative flex h-full min-h-0 w-full min-w-0",n),children:[s.jsx(Ar,{className:"hidden md:flex"}),K?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:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:s.jsx(Vn,{})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[te?null:s.jsx(Kn,{className:W("bg-topbar-bg",(C||j||!Q||_)&&"md:hidden"),start:q,title:!C&&!_?s.jsx(Wn,{}):null,end:!C&&!_?s.jsxs(s.Fragment,{children:[s.jsx(a,{}),s.jsx(c,{}),s.jsx(u,{}),s.jsx(d,{})]}):null}),s.jsx(zn,{children:s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[ee?s.jsx(Pr,{collapsed:h,onCollapsedChange:g}):null,s.jsx("div",{ref:I,className:"min-h-0 min-w-0 flex-1",children:D?s.jsx(m.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(ye,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(jr,{...te?{headerStart:q}:{}})}):_?s.jsx($n,{}):F?s.jsx(i,{}):N&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(o,{agentId:e.libraryAgentId},e.libraryAgentId):N?s.jsx(r,{onSelectAgent:Y,...te?{headerStart:q}:{}}):G?s.jsx(m.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(ye,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(Mr,{})}):M?s.jsx(m.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(ye,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(Sr,{})}):j?s.jsx(f,{}):s.jsx(Xn,{})})]})})]}),l?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"Close navigation backdrop",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:Y}),s.jsx(Dr,{drawerRef:y,onClose:Y})]}):null]})}export{Ur as SidebarLayout};
@@ -1 +0,0 @@
1
- import{C as J}from"./chunk-LFIIKLPG-DcaznAz-.js";import{bE as V,p as W,q as X,r as l,x as U,j as e,S as Y,E,I as G,bG as Z,aa as k,_ as z}from"./index-aDyvsTqL.js";var ee=({open:s,onOpenChange:c,onImport:d,busy:p=!1,error:y})=>{const[i,N]=l.useState(""),[m,C]=l.useState(""),[n,j]=l.useState(""),[u,x]=l.useState(""),[b,h]=l.useState(""),o=()=>{N(""),C(""),j(""),x(""),h("")},v=()=>{o(),c(!1)},f=async a=>{if(a.preventDefault(),!(!i.trim()||!m.trim()||!n.trim()||!u.trim()||!b.trim()||p))try{await d({name:i.trim(),description:m.trim(),repoURL:n.trim(),path:u.trim(),ref:b.trim()}),v()}catch{}},L=!!(i.trim()&&m.trim()&&n.trim()&&u.trim()&&b.trim())&&!p;return e.jsx(Z,{open:s,onOpenChange:a=>{a||v()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary",children:e.jsx(G,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:a=>void f(a),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:i,onChange:a=>{N(a.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:m,onChange:a=>{C(a.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:k("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:n,onChange:a=>{j(a.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:u,onChange:a=>{x(a.target.value)},placeholder:"skills/release-notes",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:b,onChange:a=>{h(a.target.value)},placeholder:"main",required:!0,className:k("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[y?e.jsx("p",{className:"text-failure-bg text-sm",children:y}):null,e.jsx(E.Primary,{type:"submit",disabled:!L,className:"w-full",children:"Import"})]})]})})})},te=ee,B=(s,c,d)=>!s||c.toLowerCase().includes(s)||d.toLowerCase().includes(s),se=s=>"catalogId"in s;function le(s){return typeof s=="object"&&s!==null&&Reflect.get(s,"statusCode")===424}var ae=()=>{const{skillCatalog:s}=V(),c=W(),d=X(),[p,y]=l.useState(""),[i,N]=l.useState([]),[m,C]=l.useState([]),[n,j]=l.useState(!0),[u,x]=l.useState(null),[b,h]=l.useState(null),[o,v]=l.useState(!1),[f,L]=l.useState(!1),[a,q]=l.useState(!1),[D,F]=l.useState(null),[P,I]=l.useState(null),M=l.useCallback(async()=>{if(s){j(!0),x(null);try{const[t,r]=await Promise.all([s.listSkills(),s.getSkillCatalog()]);N(t),C(r)}catch(t){x(U(t,"Failed to load skills"))}finally{j(!1)}}},[s]);l.useEffect(()=>{M()},[M]);const S=p.trim().toLowerCase(),w=l.useMemo(()=>i.filter(t=>B(S,t.name,t.description)),[i,S]),R=l.useMemo(()=>{const t=new Set(i.flatMap(r=>se(r)?[r.catalogId]:[]));return m.filter(r=>!t.has(r.id)&&B(S,r.name,r.description))},[m,i,S]),_=async(t,r=x)=>{v(!0),x(null);try{await t(),await M()}catch(g){throw le(g)&&L(!0),r(U(g,"Request failed")),g}finally{v(!1)}};if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const T=t=>{_(async()=>{await s.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})}).catch(()=>{})},K=()=>{o||(F(null),I(null))},$=t=>{const r=s.deleteSkill;r&&(I(null),_(async()=>{await r({id:t.id}),d(z.Settings.SKILL_DELETED,{skill_name:t.name}),F(null)},I).catch(()=>{}))},H=async t=>{h(null),await _(async()=>{await s.createSkill(t)},h),setTimeout(()=>{c==null||c.showSuccess({title:`${t.name} imported`}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})},0)},O=({key:t,name:r,description:g,action:Q})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(G,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),g?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:g}):null]}),Q]},t),A=w.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import custom skills from GitHub."}),u?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:u}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Y,{query:p,setQuery:y,placeholder:"Search skills"})}),e.jsxs(E.Secondary,{type:"button",className:"shrink-0",disabled:o||f,onClick:()=>{h(null),q(!0)},children:[e.jsx(G,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[n?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!n&&w.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",w.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:w.map(t=>O({key:t.id,name:t.name,description:t.description,action:s.deleteSkill?e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Remove ${t.name}`,onClick:()=>{I(null),F(t)},children:"Remove"}):null}))})]}):null,!n&&R.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>O({key:t.id,name:t.name,description:t.description,action:e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Enable ${t.name}`,onClick:()=>{T(t)},children:"Enable"})}))})]}):null,!n&&!A?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:S?`No skills match “${p.trim()}”.`:"No skills yet."}):null]})]}),D?e.jsx(J,{title:"Remove skill?",description:`“${D.name}” will no longer be available to your agents.`,busy:o,error:P,onCancel:K,onConfirm:()=>{$(D)}}):null,e.jsx(te,{open:a,onOpenChange:t=>{q(t),t||h(null)},onImport:H,busy:o||f,error:b})]})},ne=ae;export{ne as default};
@@ -1 +0,0 @@
1
- import{C as Z}from"./chunk-LFIIKLPG-DcaznAz-.js";import{ab as ee,b as ae,br as te,bz as se,p as re,q as ne,r as s,x as C,j as e,ao as le,I as F,E as B,_ as O,bG as ie,aa as ce}from"./index-aDyvsTqL.js";var oe=ce("h-11 shadow-sm"),de=({open:m,onOpenChange:p,onSave:k,title:l,description:n,requireApiKey:d=!0,busy:E=!1,error:r})=>{const[i,g]=s.useState(""),x=()=>{g("")};s.useEffect(()=>{m&&g("")},[m]);const w=c=>{c||x(),p(c)},v=i.trim(),y=!d||!!v,u=async c=>{if(c.preventDefault(),!(!y||E))try{await k({apiKey:v}),x(),p(!1)}catch{}};return e.jsx(ie,{open:m,onOpenChange:w,title:l,description:n,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:u,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"web-search-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",d?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"web-search-api-key",type:"password",required:d,value:i,onChange:c=>{g(c.target.value)},placeholder:d?"Parallel API key":"Leave blank to keep existing",autoFocus:!0,className:oe})]})}),e.jsxs("div",{className:"mt-6 space-y-3",children:[r?e.jsx("p",{className:"text-failure-bg text-sm",children:r}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!y||E,className:"w-full shrink-0",children:"Save"})]})]})})},ue=de,he=()=>{var U,V;const m=ee(),p=(U=ae())==null?void 0:U.settings,k=te(),l=se(),n=re(),d=ne(),r=k&&((V=p==null?void 0:p.webSearch)==null?void 0:V.manageProviders)!==!1?m==null?void 0:m.webSearchCatalog:void 0,[i,g]=s.useState(null),[x,w]=s.useState(!1),[v,y]=s.useState(!1),[u,c]=s.useState([]),[P,R]=s.useState([]),[$,A]=s.useState(!0),[D,b]=s.useState(null),[G,f]=s.useState(null),[T,K]=s.useState(!1),[o,j]=s.useState(null),[h,S]=s.useState(null),W=s.useCallback(async({quiet:a=!1}={})=>{if(!r){c([]),R([]),A(!1);return}a||A(!0),b(null);try{const[t,N]=await Promise.all([r.listWebSearchProviders(),r.getWebSearchProviderCatalog()]);c(t),R(N)}catch(t){b(C(t,"Failed to load web search providers"))}finally{a||A(!1)}},[r]);s.useEffect(()=>{W()},[W]),s.useEffect(()=>{if(!l)return;let a=!1;return l.getConfiguration().then(t=>{a||g(t.webSearch.enabled)}).catch(t=>{a||b(C(t,"Failed to load the web search setting"))}),()=>{a=!0}},[l]);const L=async a=>{if(l){w(!0),b(null);try{const t=await l.updateConfiguration({webSearch:{enabled:a}});g(t.webSearch.enabled),n==null||n.showSuccess({title:t.webSearch.enabled?"Web search turned on":"Web search turned off"}),d(O.Settings.WEB_SEARCH_TENANT_TOGGLED,{enabled:t.webSearch.enabled})}catch(t){b(C(t,"Failed to save the web search setting"))}finally{w(!1)}}},_=u.length>0,I=s.useMemo(()=>{if(_)return[];const a=new Set(u.map(t=>t.catalogId));return P.filter(t=>!a.has(t.id))},[P,u,_]),H=l==null||i!==null,q=r!=null&&H&&i!==!1;if(r==null&&l==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Web search provider catalog is not available."});const M=async(a,t=b)=>{K(!0),b(null);try{await a(),await W({quiet:!0})}catch(N){throw t(C(N,"Request failed")),N}finally{K(!1)}},Y=async a=>{!o||!r||(f(null),await M(async()=>{await r.createWebSearchProvider({catalogId:o.id,name:o.name,type:o.type,apiKey:a.apiKey})},f),j(null),setTimeout(()=>{n==null||n.showSuccess({title:`${o.name} configured`}),d(O.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:o.name,mode:"create"})},0))},J=async a=>{!h||!r||(f(null),await M(async()=>{await r.updateWebSearchProvider({id:h.id,...a.apiKey?{apiKey:a.apiKey}:{}})},f),S(null),setTimeout(()=>{n==null||n.showSuccess({title:`${h.name} updated`}),d(O.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:h.name,mode:"update"})},0))},Q=o!=null||h!=null,z=h!=null,X=h?`Update ${h.name}`:o?`Configure ${o.name}`:"Configure web search provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Web search"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Let agents search the web and fetch page content."}),D?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:D}):null,i!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow web search"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:i?"New chats may use web search. Chats already using it keep it.":"New chats cannot use web search. Chats already using it keep it."})]}),e.jsx(le,{checked:i,disabled:x,"aria-label":"Allow web search",onCheckedChange:a=>{if(a){L(!0);return}y(!0)}})]}):null,i===!1?e.jsxs("p",{className:"mt-3 text-sm text-text-secondary",children:["Turn this back on whenever you want. Nothing is deleted while web search is off",r==null?".":", and provider setup comes back with it."]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:q?$?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading web search providers…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can search the web. Only one can be active at a time."}),u.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",u.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:u.map(a=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:a.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:T,onClick:()=>{f(null),j(null),S(a)},children:"Update"})]})]},a.id))})]}):null,_?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",I.length]}),I.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:P.length>0?"All catalog providers are configured.":"No web search providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:I.map(a=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:a.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsx(B.Secondary,{type:"button",disabled:T,onClick:()=>{f(null),S(null),j(a)},children:"Configure"})]},a.id))})]})]}):null}),v?e.jsx(Z,{title:"Turn off web search?",description:"Existing chats, agents, and schedules that already use web search keep access. New chats and agents created after this do not. You can turn this back on later.",confirmLabel:"Turn off",busy:x,onCancel:()=>{x||y(!1)},onConfirm:()=>{x||L(!1).finally(()=>y(!1))}}):null,e.jsx(ue,{open:Q,onOpenChange:a=>{a||(f(null),j(null),S(null))},onSave:z?J:Y,title:X,description:z?"Update this web search provider. Leave API key blank to keep the existing key.":"Configure this web search provider. API key is never stored in the catalog.",requireApiKey:!z,busy:T,error:G})]})},be=he;export{be as default};
@@ -1 +0,0 @@
1
- import{S as d}from"./chunk-HED32BFK-BfnKrlUJ.js";import{u as x,bm as f,r,j as e,bl as p,I as b,a3 as h,c as v}from"./index-aDyvsTqL.js";import"./chunk-OXW7TUTC-UBWEIyxU.js";function j({className:u}){const m=x("BrandLogo"),{open:a,setOpen:n}=f(),l=r.useRef(null),s=r.useRef(null),i=r.useRef(!1);return r.useEffect(()=>{if(!a)return;const t=o=>{var c;o.key==="Escape"&&!((c=s.current)!=null&&c.querySelector("dialog[open]"))&&n(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a,n]),r.useEffect(()=>{var t,o;if(a){i.current=!0,(t=s.current)==null||t.focus();return}i.current&&((o=l.current)==null||o.focus(),i.current=!1)},[a]),e.jsxs("div",{className:v("pointer-events-none relative h-full min-h-0 w-full",u),children:[a?e.jsx("div",{ref:s,"data-aui-compact-layout":!0,className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[calc(5.25rem+env(safe-area-inset-bottom,0px))] z-[19] flex h-[min(560px,calc(100%-6.5rem-env(safe-area-inset-bottom,0px)))] max-h-[calc(100%-6.5rem)] w-[min(380px,calc(100%-2.5rem))] flex-col overflow-hidden rounded-xl border border-border bg-primary-bg shadow-[0_16px_48px_color-mix(in_oklab,var(--shadow-color)_14%,transparent)] outline-none",role:"dialog","aria-modal":!0,"aria-label":"Chat",tabIndex:-1,children:e.jsx(p,{children:e.jsx(d,{threadHeaderEnd:e.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:h({variant:"ghost",size:"icon"}),onClick:()=>n(!1),children:e.jsx(b,{name:"xmark"})})})})}):null,e.jsx("button",{ref:l,type:"button",className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[max(1.25rem,env(safe-area-inset-bottom,0px))] z-20 flex size-14 cursor-pointer items-center justify-center rounded-full text-sm font-medium shadow-[0_8px_24px_color-mix(in_oklab,var(--primary-button-bg)_45%,transparent)]",style:{backgroundColor:"var(--primary-button-bg)",color:"var(--primary-button-text)"},"aria-expanded":a,"aria-label":a?"Close chat":"Open chat",onClick:()=>n(t=>!t),children:a?e.jsx("span",{"aria-hidden":!0,className:"text-xl leading-none",children:"×"}):e.jsx(m,{variant:"icon",className:"size-6"})})]})}export{j as WidgetLayout};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-6WNST3GI-DtS3ib0p.js","./index-aDyvsTqL.js","./index-B01pXqvC.css","./SchedulesPage-OVDMYD6Q-BKu9sdHs.js","./chunk-HWOHXUGH-KXcUS5XW.js","./EnvironmentsPage-BUA2EGXE-CcV5njoc.js","./chunk-LFIIKLPG-DcaznAz-.js"])))=>i.map(i=>d[i]);
2
- import{be as _,t as B,u as t,bg as L,r as a,j as s,bi as c,P as k,I as l,a3 as d,c as z,bk as u}from"./index-aDyvsTqL.js";import{N as I,T,S as D,A as R}from"./chunk-OXW7TUTC-UBWEIyxU.js";var V=a.lazy(()=>u(()=>import("./SettingsBuilder-6WNST3GI-DtS3ib0p.js"),__vite__mapDeps([0,1,2]),import.meta.url)),F=a.lazy(()=>u(()=>import("./SchedulesPage-OVDMYD6Q-BKu9sdHs.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),H=a.lazy(()=>u(()=>import("./EnvironmentsPage-BUA2EGXE-CcV5njoc.js"),__vite__mapDeps([5,6,1,2,4]),import.meta.url).then(n=>({default:n.EnvironmentsPage})));function M({className:n,threadHeaderEnd:j}){const r=_(),e=B(),f=t("ClearChatButton"),g=t("ResetAgentBuilderButton"),b=t("AgentDetailsPage"),v=t("AgentsLibrary"),h=t("SessionsPage"),N=t("ShareChatButton"),y=t("SaveAgentButton"),A=t("SelectAgentEmptyState"),S=t("UserAvatar"),i=(e==null?void 0:e.mode.status)==="idle",C=(e==null?void 0:e.settingsOpen)===!0,o=(e==null?void 0:e.libraryOpen)===!0,O=(e==null?void 0:e.sessionsOpen)===!0,m=(e==null?void 0:e.schedulesOpen)===!0,x=(e==null?void 0:e.environmentsOpen)===!0,w=L(),p=(e==null?void 0:e.isNewChatEnabled)!==!1;a.useEffect(()=>{i||Promise.resolve(r.threads().switchToNewThread()).catch(()=>{})},[r,i]);const 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),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(r.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:z("relative flex h-full min-h-0 flex-col",n),children:[C?s.jsx("div",{className:"min-h-0 flex-1",children: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(c,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(V,{})})}):O?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(h,{})}):o&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(b,{agentId:e.libraryAgentId},e.libraryAgentId)}):o?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(v,{})}):m?s.jsx("div",{className:"min-h-0 flex-1",children: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(c,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(F,{})})}):x?s.jsx("div",{className:"min-h-0 flex-1",children: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(c,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(H,{})})}):s.jsxs(s.Fragment,{children:[s.jsx(k,{start:s.jsxs(s.Fragment,{children:[p&&!w?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:d({variant:"ghost",size:"icon"}),onClick:E,children:s.jsx(l,{name:"square-pen"})}):null,p&&(e!=null&&e.isComposerEnabled)?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:d({variant:"ghost",size:"icon"}),onClick:P,children:s.jsx(l,{name:"agent-2"})}):null]}),title:s.jsx(I,{}),end:s.jsxs(s.Fragment,{children:[s.jsx(g,{}),s.jsx(N,{}),s.jsx(f,{}),s.jsx(y,{}),j]})}),s.jsx("div",{className:"min-h-0 flex-1",children:i?s.jsx(A,{}):s.jsx(T,{})})]}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-between border-t border-border px-2 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o||m||x?s.jsxs("button",{type:"button",className:d({variant:"ghost",size:"small"}),onClick:()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setEnvironmentsOpen(!1)},children:[s.jsx(l,{name:"arrow-left"}),"Back to chat"]}):null,s.jsx(S,{})]}),s.jsx(D,{},"shell-actions")]}),e!=null&&e.agentConfigOpen?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-0 z-20 border-l border-border shadow-xl",children:s.jsx(R,{showClose:!0})}):null]})}export{M as S};
@@ -1 +0,0 @@
1
- import{r as o}from"./index-aDyvsTqL.js";function f({intervalMs:t,poll:e}){const i=o.useRef(e);i.current=e,o.useEffect(()=>{if(t==null)return;let s=!1,n;const a=()=>{s||document.hidden||i.current()},r=()=>{n!=null&&window.clearInterval(n),n=window.setInterval(a,t)},u=()=>{if(document.hidden){n!=null&&(window.clearInterval(n),n=void 0);return}a(),r()};return a(),document.hidden||r(),document.addEventListener("visibilitychange",u),()=>{s=!0,n!=null&&window.clearInterval(n),document.removeEventListener("visibilitychange",u)}},[t])}var I=20,c=5e3;function S(t){for(const e of t)if(e==="running"||e==="paused")return c;return null}function A(t,e){const i=t.lastTurnDetails,s=e.lastTurnDetails,n=(i==null?void 0:i.id)===(s==null?void 0:s.id)&&(i==null?void 0:i.state.status)===(s==null?void 0:s.state.status);return n&&t.lastActivityAt===e.lastActivityAt?t:n?{...t,lastActivityAt:e.lastActivityAt}:{...t,lastActivityAt:e.lastActivityAt,lastTurnDetails:s}}function v({current:t,firstPage:e,mergeItem:i}){if(e.length===0)return t;const s=new Map(e.map(r=>[r.id,r]));let n=!1;const a=t.map(r=>{const u=s.get(r.id);if(u==null)return r;const l=i(r,u);return l!==r&&(n=!0),l});return n?a:t}export{I as S,A as a,v as m,S as s,f as u};
@@ -1 +0,0 @@
1
- import{j as e,R as m,U as u,V as h,W as j,X as p,E as n}from"./index-aDyvsTqL.js";function g(a){return a.replace(/\?$/,"").replace(/^Remove /i,"Can't remove ")}var f=({title:a,description:o,confirmLabel:c="Remove",busy:i=!1,error:l=null,onCancel:t,onConfirm:d})=>{const s=l!=null&&l!=="",r=s?g(a):a;return e.jsxs(m,{open:!0,onOpenChange:x=>{x||t()},"aria-label":r,className:"max-w-md",children:[e.jsx(u,{children:e.jsxs(h,{children:[e.jsx(j,{children:r}),s?e.jsx("p",{role:"alert",className:"text-sm text-failure-bg",children:l}):e.jsx("p",{className:"text-sm text-text-secondary",children:o})]})}),e.jsx(p,{children:s?e.jsx(n.Secondary,{type:"button",onClick:t,children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(n.Secondary,{type:"button",disabled:i,onClick:t,children:"Cancel"}),e.jsx(n.Destructive,{type:"button",disabled:i,onClick:d,children:c})]})})]})},C=f;export{C};