flowent 0.0.0 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/README.md +70 -10
  2. package/assets/flowent-banner.png +0 -0
  3. package/backend/.python-version +1 -0
  4. package/backend/pyproject.toml +57 -0
  5. package/backend/src/flowent/__init__.py +3 -0
  6. package/backend/src/flowent/__pycache__/__init__.cpython-313.pyc +0 -0
  7. package/backend/src/flowent/__pycache__/_version.cpython-313.pyc +0 -0
  8. package/backend/src/flowent/__pycache__/access.cpython-313.pyc +0 -0
  9. package/backend/src/flowent/__pycache__/agent.cpython-313.pyc +0 -0
  10. package/backend/src/flowent/__pycache__/assistant_commands.cpython-313.pyc +0 -0
  11. package/backend/src/flowent/__pycache__/cli.cpython-313.pyc +0 -0
  12. package/backend/src/flowent/__pycache__/config.cpython-313.pyc +0 -0
  13. package/backend/src/flowent/__pycache__/events.cpython-313.pyc +0 -0
  14. package/backend/src/flowent/__pycache__/graph_runtime.cpython-313.pyc +0 -0
  15. package/backend/src/flowent/__pycache__/graph_service.cpython-313.pyc +0 -0
  16. package/backend/src/flowent/__pycache__/image_assets.cpython-313.pyc +0 -0
  17. package/backend/src/flowent/__pycache__/logging.cpython-313.pyc +0 -0
  18. package/backend/src/flowent/__pycache__/main.cpython-313.pyc +0 -0
  19. package/backend/src/flowent/__pycache__/mcp_service.cpython-313.pyc +0 -0
  20. package/backend/src/flowent/__pycache__/model_metadata.cpython-313.pyc +0 -0
  21. package/backend/src/flowent/__pycache__/network.cpython-313.pyc +0 -0
  22. package/backend/src/flowent/__pycache__/registry.cpython-313.pyc +0 -0
  23. package/backend/src/flowent/__pycache__/role_management.cpython-313.pyc +0 -0
  24. package/backend/src/flowent/__pycache__/runtime.cpython-313.pyc +0 -0
  25. package/backend/src/flowent/__pycache__/sandbox.cpython-313.pyc +0 -0
  26. package/backend/src/flowent/__pycache__/security.cpython-313.pyc +0 -0
  27. package/backend/src/flowent/__pycache__/settings.cpython-313.pyc +0 -0
  28. package/backend/src/flowent/__pycache__/settings_management.cpython-313.pyc +0 -0
  29. package/backend/src/flowent/__pycache__/state_db.cpython-313.pyc +0 -0
  30. package/backend/src/flowent/__pycache__/stats_service.cpython-313.pyc +0 -0
  31. package/backend/src/flowent/__pycache__/workspace_store.cpython-313.pyc +0 -0
  32. package/backend/src/flowent/_version.py +7 -0
  33. package/backend/src/flowent/access.py +247 -0
  34. package/backend/src/flowent/agent.py +2808 -0
  35. package/backend/src/flowent/assistant_commands.py +106 -0
  36. package/backend/src/flowent/channels/__init__.py +3 -0
  37. package/backend/src/flowent/channels/__pycache__/__init__.cpython-313.pyc +0 -0
  38. package/backend/src/flowent/channels/__pycache__/telegram.cpython-313.pyc +0 -0
  39. package/backend/src/flowent/channels/telegram.py +615 -0
  40. package/backend/src/flowent/cli.py +85 -0
  41. package/backend/src/flowent/config.py +14 -0
  42. package/backend/src/flowent/dev.py +3 -0
  43. package/backend/src/flowent/events.py +157 -0
  44. package/backend/src/flowent/graph_runtime.py +60 -0
  45. package/backend/src/flowent/graph_service.py +1346 -0
  46. package/backend/src/flowent/image_assets.py +356 -0
  47. package/backend/src/flowent/logging.py +155 -0
  48. package/backend/src/flowent/main.py +124 -0
  49. package/backend/src/flowent/mcp_service.py +1904 -0
  50. package/backend/src/flowent/model_metadata.py +98 -0
  51. package/backend/src/flowent/models/__init__.py +121 -0
  52. package/backend/src/flowent/models/__pycache__/__init__.cpython-313.pyc +0 -0
  53. package/backend/src/flowent/models/__pycache__/agent.cpython-313.pyc +0 -0
  54. package/backend/src/flowent/models/__pycache__/base.cpython-313.pyc +0 -0
  55. package/backend/src/flowent/models/__pycache__/blueprint.cpython-313.pyc +0 -0
  56. package/backend/src/flowent/models/__pycache__/content.cpython-313.pyc +0 -0
  57. package/backend/src/flowent/models/__pycache__/delta.cpython-313.pyc +0 -0
  58. package/backend/src/flowent/models/__pycache__/event.cpython-313.pyc +0 -0
  59. package/backend/src/flowent/models/__pycache__/graph.cpython-313.pyc +0 -0
  60. package/backend/src/flowent/models/__pycache__/history.cpython-313.pyc +0 -0
  61. package/backend/src/flowent/models/__pycache__/llm.cpython-313.pyc +0 -0
  62. package/backend/src/flowent/models/__pycache__/message.cpython-313.pyc +0 -0
  63. package/backend/src/flowent/models/__pycache__/tab.cpython-313.pyc +0 -0
  64. package/backend/src/flowent/models/__pycache__/todo.cpython-313.pyc +0 -0
  65. package/backend/src/flowent/models/agent.py +33 -0
  66. package/backend/src/flowent/models/base.py +24 -0
  67. package/backend/src/flowent/models/blueprint.py +176 -0
  68. package/backend/src/flowent/models/content.py +164 -0
  69. package/backend/src/flowent/models/delta.py +44 -0
  70. package/backend/src/flowent/models/event.py +51 -0
  71. package/backend/src/flowent/models/graph.py +437 -0
  72. package/backend/src/flowent/models/history.py +214 -0
  73. package/backend/src/flowent/models/llm.py +61 -0
  74. package/backend/src/flowent/models/message.py +27 -0
  75. package/backend/src/flowent/models/tab.py +48 -0
  76. package/backend/src/flowent/models/todo.py +10 -0
  77. package/backend/src/flowent/network.py +146 -0
  78. package/backend/src/flowent/prompts/__init__.py +67 -0
  79. package/backend/src/flowent/prompts/__pycache__/__init__.cpython-313.pyc +0 -0
  80. package/backend/src/flowent/prompts/__pycache__/common.cpython-313.pyc +0 -0
  81. package/backend/src/flowent/prompts/__pycache__/steward.cpython-313.pyc +0 -0
  82. package/backend/src/flowent/prompts/common.py +250 -0
  83. package/backend/src/flowent/prompts/steward.py +64 -0
  84. package/backend/src/flowent/providers/__init__.py +23 -0
  85. package/backend/src/flowent/providers/__pycache__/__init__.cpython-313.pyc +0 -0
  86. package/backend/src/flowent/providers/__pycache__/anthropic.cpython-313.pyc +0 -0
  87. package/backend/src/flowent/providers/__pycache__/base_url.cpython-313.pyc +0 -0
  88. package/backend/src/flowent/providers/__pycache__/configuration.cpython-313.pyc +0 -0
  89. package/backend/src/flowent/providers/__pycache__/content.cpython-313.pyc +0 -0
  90. package/backend/src/flowent/providers/__pycache__/errors.cpython-313.pyc +0 -0
  91. package/backend/src/flowent/providers/__pycache__/gateway.cpython-313.pyc +0 -0
  92. package/backend/src/flowent/providers/__pycache__/headers.cpython-313.pyc +0 -0
  93. package/backend/src/flowent/providers/__pycache__/management.cpython-313.pyc +0 -0
  94. package/backend/src/flowent/providers/__pycache__/openai.cpython-313.pyc +0 -0
  95. package/backend/src/flowent/providers/__pycache__/openai_responses.cpython-313.pyc +0 -0
  96. package/backend/src/flowent/providers/__pycache__/registry.cpython-313.pyc +0 -0
  97. package/backend/src/flowent/providers/__pycache__/sse.cpython-313.pyc +0 -0
  98. package/backend/src/flowent/providers/__pycache__/thinking.cpython-313.pyc +0 -0
  99. package/backend/src/flowent/providers/anthropic.py +468 -0
  100. package/backend/src/flowent/providers/base_url.py +60 -0
  101. package/backend/src/flowent/providers/configuration.py +182 -0
  102. package/backend/src/flowent/providers/content.py +122 -0
  103. package/backend/src/flowent/providers/errors.py +223 -0
  104. package/backend/src/flowent/providers/gateway.py +169 -0
  105. package/backend/src/flowent/providers/gemini.py +447 -0
  106. package/backend/src/flowent/providers/headers.py +20 -0
  107. package/backend/src/flowent/providers/management.py +96 -0
  108. package/backend/src/flowent/providers/ollama.py +293 -0
  109. package/backend/src/flowent/providers/openai.py +422 -0
  110. package/backend/src/flowent/providers/openai_responses.py +655 -0
  111. package/backend/src/flowent/providers/registry.py +144 -0
  112. package/backend/src/flowent/providers/sse.py +31 -0
  113. package/backend/src/flowent/providers/thinking.py +79 -0
  114. package/backend/src/flowent/registry.py +73 -0
  115. package/backend/src/flowent/role_management.py +255 -0
  116. package/backend/src/flowent/routes/__init__.py +30 -0
  117. package/backend/src/flowent/routes/__pycache__/__init__.cpython-313.pyc +0 -0
  118. package/backend/src/flowent/routes/__pycache__/access.cpython-313.pyc +0 -0
  119. package/backend/src/flowent/routes/__pycache__/assistant.cpython-313.pyc +0 -0
  120. package/backend/src/flowent/routes/__pycache__/image_assets.cpython-313.pyc +0 -0
  121. package/backend/src/flowent/routes/__pycache__/mcp.cpython-313.pyc +0 -0
  122. package/backend/src/flowent/routes/__pycache__/meta.cpython-313.pyc +0 -0
  123. package/backend/src/flowent/routes/__pycache__/nodes.cpython-313.pyc +0 -0
  124. package/backend/src/flowent/routes/__pycache__/prompts.cpython-313.pyc +0 -0
  125. package/backend/src/flowent/routes/__pycache__/providers_route.cpython-313.pyc +0 -0
  126. package/backend/src/flowent/routes/__pycache__/roles.cpython-313.pyc +0 -0
  127. package/backend/src/flowent/routes/__pycache__/settings.cpython-313.pyc +0 -0
  128. package/backend/src/flowent/routes/__pycache__/stats.cpython-313.pyc +0 -0
  129. package/backend/src/flowent/routes/__pycache__/tabs.cpython-313.pyc +0 -0
  130. package/backend/src/flowent/routes/__pycache__/ws.cpython-313.pyc +0 -0
  131. package/backend/src/flowent/routes/access.py +48 -0
  132. package/backend/src/flowent/routes/assistant.py +155 -0
  133. package/backend/src/flowent/routes/image_assets.py +33 -0
  134. package/backend/src/flowent/routes/mcp.py +125 -0
  135. package/backend/src/flowent/routes/meta.py +28 -0
  136. package/backend/src/flowent/routes/nodes.py +365 -0
  137. package/backend/src/flowent/routes/prompts.py +46 -0
  138. package/backend/src/flowent/routes/providers_route.py +364 -0
  139. package/backend/src/flowent/routes/roles.py +207 -0
  140. package/backend/src/flowent/routes/settings.py +324 -0
  141. package/backend/src/flowent/routes/stats.py +229 -0
  142. package/backend/src/flowent/routes/tabs.py +292 -0
  143. package/backend/src/flowent/routes/ws.py +33 -0
  144. package/backend/src/flowent/runtime.py +188 -0
  145. package/backend/src/flowent/sandbox.py +45 -0
  146. package/backend/src/flowent/security.py +42 -0
  147. package/backend/src/flowent/settings.py +2467 -0
  148. package/backend/src/flowent/settings_management.py +286 -0
  149. package/backend/src/flowent/state_db.py +120 -0
  150. package/backend/src/flowent/static/assets/AssistantPage-B3Xc08AS.js +1 -0
  151. package/backend/src/flowent/static/assets/ChannelsPage-ByLd28xk.js +1 -0
  152. package/backend/src/flowent/static/assets/HomePage-C0hAx9_l.js +3 -0
  153. package/backend/src/flowent/static/assets/McpPage-DkrYLvBv.js +7 -0
  154. package/backend/src/flowent/static/assets/PageScaffold-D4jO9ooX.js +1 -0
  155. package/backend/src/flowent/static/assets/PromptsPage-DWA7rRJd.js +1 -0
  156. package/backend/src/flowent/static/assets/ProvidersPage-PUWT8seJ.js +3 -0
  157. package/backend/src/flowent/static/assets/RolesPage-CqcclGRw.js +1 -0
  158. package/backend/src/flowent/static/assets/SettingsPage-8tS2cJgX.js +3 -0
  159. package/backend/src/flowent/static/assets/StatsPage-BX9khYzu.js +1 -0
  160. package/backend/src/flowent/static/assets/ToolsPage-9Tl9FdeD.js +1 -0
  161. package/backend/src/flowent/static/assets/WorkspaceCommandDialog-CCXxjDL8.js +1 -0
  162. package/backend/src/flowent/static/assets/WorkspacePanels-aMdJ7ZH7.js +1 -0
  163. package/backend/src/flowent/static/assets/alert-dialog-kFYVQ7oX.js +1 -0
  164. package/backend/src/flowent/static/assets/badge-74-3jsCg.js +1 -0
  165. package/backend/src/flowent/static/assets/constants-XUzFf6i1.js +1 -0
  166. package/backend/src/flowent/static/assets/datetime-m6_O_Ci9.js +1 -0
  167. package/backend/src/flowent/static/assets/dialog-BeGSweF6.js +1 -0
  168. package/backend/src/flowent/static/assets/elk-worker.min-C9JGDOE-.js +6312 -0
  169. package/backend/src/flowent/static/assets/graph-vendor-CHpVij2M.css +1 -0
  170. package/backend/src/flowent/static/assets/graph-vendor-DRq_-6fV.js +7 -0
  171. package/backend/src/flowent/static/assets/index-BHC1Vhy8.css +1 -0
  172. package/backend/src/flowent/static/assets/index-CL1ALZ3r.js +10 -0
  173. package/backend/src/flowent/static/assets/layout.worker-jMHqAFbP.js +24 -0
  174. package/backend/src/flowent/static/assets/markdown-vendor-DVdy_w12.js +29 -0
  175. package/backend/src/flowent/static/assets/modelParams-CaHd0903.js +1 -0
  176. package/backend/src/flowent/static/assets/react-vendor-mEs_JJxa.js +9 -0
  177. package/backend/src/flowent/static/assets/roles-2OLDeTc5.js +1 -0
  178. package/backend/src/flowent/static/assets/rolldown-runtime-BYbx6iT9.js +1 -0
  179. package/backend/src/flowent/static/assets/select-DL_LPeDj.js +1 -0
  180. package/backend/src/flowent/static/assets/shared-CMxbpLeQ.js +1 -0
  181. package/backend/src/flowent/static/assets/triState-DEr3NkXV.js +1 -0
  182. package/backend/src/flowent/static/assets/ui-vendor-Dg9NNnWX.js +51 -0
  183. package/backend/src/flowent/static/index.html +36 -0
  184. package/backend/src/flowent/stats_service.py +218 -0
  185. package/backend/src/flowent/tools/__init__.py +201 -0
  186. package/backend/src/flowent/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  187. package/backend/src/flowent/tools/__pycache__/connect.cpython-313.pyc +0 -0
  188. package/backend/src/flowent/tools/__pycache__/contacts.cpython-313.pyc +0 -0
  189. package/backend/src/flowent/tools/__pycache__/create_agent.cpython-313.pyc +0 -0
  190. package/backend/src/flowent/tools/__pycache__/create_tab.cpython-313.pyc +0 -0
  191. package/backend/src/flowent/tools/__pycache__/delete_tab.cpython-313.pyc +0 -0
  192. package/backend/src/flowent/tools/__pycache__/edit.cpython-313.pyc +0 -0
  193. package/backend/src/flowent/tools/__pycache__/exec.cpython-313.pyc +0 -0
  194. package/backend/src/flowent/tools/__pycache__/fetch.cpython-313.pyc +0 -0
  195. package/backend/src/flowent/tools/__pycache__/idle.cpython-313.pyc +0 -0
  196. package/backend/src/flowent/tools/__pycache__/list_roles.cpython-313.pyc +0 -0
  197. package/backend/src/flowent/tools/__pycache__/list_tabs.cpython-313.pyc +0 -0
  198. package/backend/src/flowent/tools/__pycache__/list_tools.cpython-313.pyc +0 -0
  199. package/backend/src/flowent/tools/__pycache__/manage_prompts.cpython-313.pyc +0 -0
  200. package/backend/src/flowent/tools/__pycache__/manage_providers.cpython-313.pyc +0 -0
  201. package/backend/src/flowent/tools/__pycache__/manage_roles.cpython-313.pyc +0 -0
  202. package/backend/src/flowent/tools/__pycache__/manage_settings.cpython-313.pyc +0 -0
  203. package/backend/src/flowent/tools/__pycache__/mcp.cpython-313.pyc +0 -0
  204. package/backend/src/flowent/tools/__pycache__/read.cpython-313.pyc +0 -0
  205. package/backend/src/flowent/tools/__pycache__/send.cpython-313.pyc +0 -0
  206. package/backend/src/flowent/tools/__pycache__/set_permissions.cpython-313.pyc +0 -0
  207. package/backend/src/flowent/tools/__pycache__/sleep.cpython-313.pyc +0 -0
  208. package/backend/src/flowent/tools/__pycache__/todo.cpython-313.pyc +0 -0
  209. package/backend/src/flowent/tools/connect.py +156 -0
  210. package/backend/src/flowent/tools/contacts.py +22 -0
  211. package/backend/src/flowent/tools/create_agent.py +270 -0
  212. package/backend/src/flowent/tools/create_tab.py +59 -0
  213. package/backend/src/flowent/tools/delete_tab.py +39 -0
  214. package/backend/src/flowent/tools/edit.py +142 -0
  215. package/backend/src/flowent/tools/exec.py +117 -0
  216. package/backend/src/flowent/tools/fetch.py +85 -0
  217. package/backend/src/flowent/tools/idle.py +27 -0
  218. package/backend/src/flowent/tools/list_roles.py +50 -0
  219. package/backend/src/flowent/tools/list_tabs.py +96 -0
  220. package/backend/src/flowent/tools/list_tools.py +24 -0
  221. package/backend/src/flowent/tools/manage_prompts.py +102 -0
  222. package/backend/src/flowent/tools/manage_providers.py +220 -0
  223. package/backend/src/flowent/tools/manage_roles.py +275 -0
  224. package/backend/src/flowent/tools/manage_settings.py +346 -0
  225. package/backend/src/flowent/tools/mcp.py +199 -0
  226. package/backend/src/flowent/tools/read.py +152 -0
  227. package/backend/src/flowent/tools/send.py +50 -0
  228. package/backend/src/flowent/tools/set_permissions.py +84 -0
  229. package/backend/src/flowent/tools/sleep.py +41 -0
  230. package/backend/src/flowent/tools/todo.py +51 -0
  231. package/backend/src/flowent/workspace_store.py +479 -0
  232. package/backend/tests/__init__.py +0 -0
  233. package/backend/tests/__pycache__/__init__.cpython-313.pyc +0 -0
  234. package/backend/tests/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
  235. package/backend/tests/conftest.py +6 -0
  236. package/backend/tests/integration/api/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
  237. package/backend/tests/integration/api/__pycache__/test_access_api.cpython-313-pytest-9.0.3.pyc +0 -0
  238. package/backend/tests/integration/api/__pycache__/test_assistant_api.cpython-313-pytest-9.0.3.pyc +0 -0
  239. package/backend/tests/integration/api/__pycache__/test_frontend_mounting.cpython-313-pytest-9.0.3.pyc +0 -0
  240. package/backend/tests/integration/api/__pycache__/test_mcp_api.cpython-313-pytest-9.0.3.pyc +0 -0
  241. package/backend/tests/integration/api/__pycache__/test_meta_api.cpython-313-pytest-9.0.3.pyc +0 -0
  242. package/backend/tests/integration/api/__pycache__/test_nodes_api.cpython-313-pytest-9.0.3.pyc +0 -0
  243. package/backend/tests/integration/api/__pycache__/test_prompts_api.cpython-313-pytest-9.0.3.pyc +0 -0
  244. package/backend/tests/integration/api/__pycache__/test_roles_api.cpython-313-pytest-9.0.3.pyc +0 -0
  245. package/backend/tests/integration/api/__pycache__/test_tabs_api.cpython-313-pytest-9.0.3.pyc +0 -0
  246. package/backend/tests/integration/api/conftest.py +29 -0
  247. package/backend/tests/integration/api/test_access_api.py +182 -0
  248. package/backend/tests/integration/api/test_assistant_api.py +354 -0
  249. package/backend/tests/integration/api/test_frontend_mounting.py +61 -0
  250. package/backend/tests/integration/api/test_mcp_api.py +116 -0
  251. package/backend/tests/integration/api/test_meta_api.py +33 -0
  252. package/backend/tests/integration/api/test_nodes_api.py +486 -0
  253. package/backend/tests/integration/api/test_prompts_api.py +47 -0
  254. package/backend/tests/integration/api/test_roles_api.py +227 -0
  255. package/backend/tests/integration/api/test_tabs_api.py +501 -0
  256. package/backend/tests/unit/__pycache__/test_access.cpython-313-pytest-9.0.3.pyc +0 -0
  257. package/backend/tests/unit/__pycache__/test_cli.cpython-313-pytest-9.0.3.pyc +0 -0
  258. package/backend/tests/unit/__pycache__/test_graph_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  259. package/backend/tests/unit/__pycache__/test_network.cpython-313-pytest-9.0.3.pyc +0 -0
  260. package/backend/tests/unit/__pycache__/test_state_sqlite_storage.cpython-313-pytest-9.0.3.pyc +0 -0
  261. package/backend/tests/unit/__pycache__/test_workspace_store.cpython-313-pytest-9.0.3.pyc +0 -0
  262. package/backend/tests/unit/agent/__pycache__/test_agent_public_api.cpython-313-pytest-9.0.3.pyc +0 -0
  263. package/backend/tests/unit/agent/__pycache__/test_agent_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  264. package/backend/tests/unit/agent/test_agent_public_api.py +746 -0
  265. package/backend/tests/unit/agent/test_agent_runtime.py +2726 -0
  266. package/backend/tests/unit/channels/__pycache__/test_telegram_channel.cpython-313-pytest-9.0.3.pyc +0 -0
  267. package/backend/tests/unit/channels/test_telegram_channel.py +552 -0
  268. package/backend/tests/unit/logging/__pycache__/test_logging.cpython-313-pytest-9.0.3.pyc +0 -0
  269. package/backend/tests/unit/logging/test_logging.py +132 -0
  270. package/backend/tests/unit/prompts/__pycache__/test_prompts.cpython-313-pytest-9.0.3.pyc +0 -0
  271. package/backend/tests/unit/prompts/test_prompts.py +569 -0
  272. package/backend/tests/unit/providers/__pycache__/test_anthropic_provider.cpython-313-pytest-9.0.3.pyc +0 -0
  273. package/backend/tests/unit/providers/__pycache__/test_errors.cpython-313-pytest-9.0.3.pyc +0 -0
  274. package/backend/tests/unit/providers/__pycache__/test_extract_delta_parts.cpython-313-pytest-9.0.3.pyc +0 -0
  275. package/backend/tests/unit/providers/__pycache__/test_openai_provider.cpython-313-pytest-9.0.3.pyc +0 -0
  276. package/backend/tests/unit/providers/__pycache__/test_openai_responses.cpython-313-pytest-9.0.3.pyc +0 -0
  277. package/backend/tests/unit/providers/__pycache__/test_provider_gateway.cpython-313-pytest-9.0.3.pyc +0 -0
  278. package/backend/tests/unit/providers/__pycache__/test_think_tag_parser.cpython-313-pytest-9.0.3.pyc +0 -0
  279. package/backend/tests/unit/providers/test_anthropic_provider.py +185 -0
  280. package/backend/tests/unit/providers/test_errors.py +68 -0
  281. package/backend/tests/unit/providers/test_extract_delta_parts.py +22 -0
  282. package/backend/tests/unit/providers/test_openai_provider.py +139 -0
  283. package/backend/tests/unit/providers/test_openai_responses.py +402 -0
  284. package/backend/tests/unit/providers/test_provider_gateway.py +359 -0
  285. package/backend/tests/unit/providers/test_think_tag_parser.py +36 -0
  286. package/backend/tests/unit/routes/__pycache__/test_prompts_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  287. package/backend/tests/unit/routes/__pycache__/test_providers_route.cpython-313-pytest-9.0.3.pyc +0 -0
  288. package/backend/tests/unit/routes/__pycache__/test_roles_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  289. package/backend/tests/unit/routes/__pycache__/test_settings_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  290. package/backend/tests/unit/routes/__pycache__/test_stats_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  291. package/backend/tests/unit/routes/test_prompts_routes.py +104 -0
  292. package/backend/tests/unit/routes/test_providers_route.py +368 -0
  293. package/backend/tests/unit/routes/test_roles_routes.py +426 -0
  294. package/backend/tests/unit/routes/test_settings_routes.py +1138 -0
  295. package/backend/tests/unit/routes/test_stats_routes.py +149 -0
  296. package/backend/tests/unit/runtime/__pycache__/test_bootstrap_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  297. package/backend/tests/unit/runtime/test_bootstrap_runtime.py +1012 -0
  298. package/backend/tests/unit/sandbox/__pycache__/test_sandbox_tools.cpython-313-pytest-9.0.3.pyc +0 -0
  299. package/backend/tests/unit/sandbox/test_sandbox_tools.py +78 -0
  300. package/backend/tests/unit/security/__pycache__/test_security.cpython-313-pytest-9.0.3.pyc +0 -0
  301. package/backend/tests/unit/security/test_security.py +110 -0
  302. package/backend/tests/unit/settings/__pycache__/test_settings_roles.cpython-313-pytest-9.0.3.pyc +0 -0
  303. package/backend/tests/unit/settings/test_settings_roles.py +711 -0
  304. package/backend/tests/unit/test_access.py +45 -0
  305. package/backend/tests/unit/test_cli.py +124 -0
  306. package/backend/tests/unit/test_graph_runtime.py +72 -0
  307. package/backend/tests/unit/test_network.py +51 -0
  308. package/backend/tests/unit/test_state_sqlite_storage.py +93 -0
  309. package/backend/tests/unit/test_workspace_store.py +231 -0
  310. package/backend/tests/unit/tools/__pycache__/test_connect_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  311. package/backend/tests/unit/tools/__pycache__/test_create_agent_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  312. package/backend/tests/unit/tools/__pycache__/test_delete_tab_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  313. package/backend/tests/unit/tools/__pycache__/test_edit_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  314. package/backend/tests/unit/tools/__pycache__/test_exec_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  315. package/backend/tests/unit/tools/__pycache__/test_fetch_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  316. package/backend/tests/unit/tools/__pycache__/test_manage_prompts_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  317. package/backend/tests/unit/tools/__pycache__/test_manage_providers_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  318. package/backend/tests/unit/tools/__pycache__/test_manage_roles_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  319. package/backend/tests/unit/tools/__pycache__/test_manage_settings_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  320. package/backend/tests/unit/tools/__pycache__/test_read_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  321. package/backend/tests/unit/tools/__pycache__/test_set_permissions_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  322. package/backend/tests/unit/tools/__pycache__/test_todo_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  323. package/backend/tests/unit/tools/__pycache__/test_tool_registry.cpython-313-pytest-9.0.3.pyc +0 -0
  324. package/backend/tests/unit/tools/test_connect_tool.py +229 -0
  325. package/backend/tests/unit/tools/test_create_agent_tool.py +524 -0
  326. package/backend/tests/unit/tools/test_delete_tab_tool.py +83 -0
  327. package/backend/tests/unit/tools/test_edit_tool.py +115 -0
  328. package/backend/tests/unit/tools/test_exec_tool.py +81 -0
  329. package/backend/tests/unit/tools/test_fetch_tool.py +65 -0
  330. package/backend/tests/unit/tools/test_manage_prompts_tool.py +117 -0
  331. package/backend/tests/unit/tools/test_manage_providers_tool.py +458 -0
  332. package/backend/tests/unit/tools/test_manage_roles_tool.py +411 -0
  333. package/backend/tests/unit/tools/test_manage_settings_tool.py +608 -0
  334. package/backend/tests/unit/tools/test_read_tool.py +33 -0
  335. package/backend/tests/unit/tools/test_set_permissions_tool.py +391 -0
  336. package/backend/tests/unit/tools/test_todo_tool.py +37 -0
  337. package/backend/tests/unit/tools/test_tool_registry.py +91 -0
  338. package/backend/uv.lock +1144 -0
  339. package/bin/flowent.mjs +62 -35
  340. package/dist/frontend/assets/AssistantPage-B3Xc08AS.js +1 -0
  341. package/dist/frontend/assets/ChannelsPage-ByLd28xk.js +1 -0
  342. package/dist/frontend/assets/HomePage-C0hAx9_l.js +3 -0
  343. package/dist/frontend/assets/McpPage-DkrYLvBv.js +7 -0
  344. package/dist/frontend/assets/PageScaffold-D4jO9ooX.js +1 -0
  345. package/dist/frontend/assets/PromptsPage-DWA7rRJd.js +1 -0
  346. package/dist/frontend/assets/ProvidersPage-PUWT8seJ.js +3 -0
  347. package/dist/frontend/assets/RolesPage-CqcclGRw.js +1 -0
  348. package/dist/frontend/assets/SettingsPage-8tS2cJgX.js +3 -0
  349. package/dist/frontend/assets/StatsPage-BX9khYzu.js +1 -0
  350. package/dist/frontend/assets/ToolsPage-9Tl9FdeD.js +1 -0
  351. package/dist/frontend/assets/WorkspaceCommandDialog-CCXxjDL8.js +1 -0
  352. package/dist/frontend/assets/WorkspacePanels-aMdJ7ZH7.js +1 -0
  353. package/dist/frontend/assets/alert-dialog-kFYVQ7oX.js +1 -0
  354. package/dist/frontend/assets/badge-74-3jsCg.js +1 -0
  355. package/dist/frontend/assets/constants-XUzFf6i1.js +1 -0
  356. package/dist/frontend/assets/datetime-m6_O_Ci9.js +1 -0
  357. package/dist/frontend/assets/dialog-BeGSweF6.js +1 -0
  358. package/dist/frontend/assets/elk-worker.min-C9JGDOE-.js +6312 -0
  359. package/dist/frontend/assets/graph-vendor-CHpVij2M.css +1 -0
  360. package/dist/frontend/assets/graph-vendor-DRq_-6fV.js +7 -0
  361. package/dist/frontend/assets/index-BHC1Vhy8.css +1 -0
  362. package/dist/frontend/assets/index-CL1ALZ3r.js +10 -0
  363. package/dist/frontend/assets/layout.worker-jMHqAFbP.js +24 -0
  364. package/dist/frontend/assets/markdown-vendor-DVdy_w12.js +29 -0
  365. package/dist/frontend/assets/modelParams-CaHd0903.js +1 -0
  366. package/dist/frontend/assets/react-vendor-mEs_JJxa.js +9 -0
  367. package/dist/frontend/assets/roles-2OLDeTc5.js +1 -0
  368. package/dist/frontend/assets/rolldown-runtime-BYbx6iT9.js +1 -0
  369. package/dist/frontend/assets/select-DL_LPeDj.js +1 -0
  370. package/dist/frontend/assets/shared-CMxbpLeQ.js +1 -0
  371. package/dist/frontend/assets/triState-DEr3NkXV.js +1 -0
  372. package/dist/frontend/assets/ui-vendor-Dg9NNnWX.js +51 -0
  373. package/dist/frontend/index.html +36 -0
  374. package/package.json +28 -41
  375. package/dist/.next/BUILD_ID +0 -1
  376. package/dist/.next/app-path-routes-manifest.json +0 -6
  377. package/dist/.next/build-manifest.json +0 -20
  378. package/dist/.next/package.json +0 -1
  379. package/dist/.next/prerender-manifest.json +0 -114
  380. package/dist/.next/required-server-files.json +0 -333
  381. package/dist/.next/routes-manifest.json +0 -69
  382. package/dist/.next/server/app/_global-error/page/app-paths-manifest.json +0 -3
  383. package/dist/.next/server/app/_global-error/page/build-manifest.json +0 -16
  384. package/dist/.next/server/app/_global-error/page/next-font-manifest.json +0 -6
  385. package/dist/.next/server/app/_global-error/page/react-loadable-manifest.json +0 -1
  386. package/dist/.next/server/app/_global-error/page/server-reference-manifest.json +0 -4
  387. package/dist/.next/server/app/_global-error/page.js +0 -9
  388. package/dist/.next/server/app/_global-error/page.js.map +0 -5
  389. package/dist/.next/server/app/_global-error/page.js.nft.json +0 -1
  390. package/dist/.next/server/app/_global-error/page_client-reference-manifest.js +0 -3
  391. package/dist/.next/server/app/_global-error.html +0 -1
  392. package/dist/.next/server/app/_global-error.meta +0 -15
  393. package/dist/.next/server/app/_global-error.rsc +0 -14
  394. package/dist/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +0 -5
  395. package/dist/.next/server/app/_global-error.segments/_full.segment.rsc +0 -14
  396. package/dist/.next/server/app/_global-error.segments/_head.segment.rsc +0 -5
  397. package/dist/.next/server/app/_global-error.segments/_index.segment.rsc +0 -5
  398. package/dist/.next/server/app/_global-error.segments/_tree.segment.rsc +0 -1
  399. package/dist/.next/server/app/_not-found/page/app-paths-manifest.json +0 -3
  400. package/dist/.next/server/app/_not-found/page/build-manifest.json +0 -16
  401. package/dist/.next/server/app/_not-found/page/next-font-manifest.json +0 -10
  402. package/dist/.next/server/app/_not-found/page/react-loadable-manifest.json +0 -1
  403. package/dist/.next/server/app/_not-found/page/server-reference-manifest.json +0 -4
  404. package/dist/.next/server/app/_not-found/page.js +0 -13
  405. package/dist/.next/server/app/_not-found/page.js.map +0 -5
  406. package/dist/.next/server/app/_not-found/page.js.nft.json +0 -1
  407. package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +0 -3
  408. package/dist/.next/server/app/_not-found.html +0 -1
  409. package/dist/.next/server/app/_not-found.meta +0 -16
  410. package/dist/.next/server/app/_not-found.rsc +0 -16
  411. package/dist/.next/server/app/_not-found.segments/_full.segment.rsc +0 -16
  412. package/dist/.next/server/app/_not-found.segments/_head.segment.rsc +0 -6
  413. package/dist/.next/server/app/_not-found.segments/_index.segment.rsc +0 -5
  414. package/dist/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +0 -5
  415. package/dist/.next/server/app/_not-found.segments/_not-found.segment.rsc +0 -5
  416. package/dist/.next/server/app/_not-found.segments/_tree.segment.rsc +0 -2
  417. package/dist/.next/server/app/icon.svg/route/app-paths-manifest.json +0 -3
  418. package/dist/.next/server/app/icon.svg/route/build-manifest.json +0 -9
  419. package/dist/.next/server/app/icon.svg/route.js +0 -6
  420. package/dist/.next/server/app/icon.svg/route.js.map +0 -5
  421. package/dist/.next/server/app/icon.svg/route.js.nft.json +0 -1
  422. package/dist/.next/server/app/icon.svg.meta +0 -1
  423. package/dist/.next/server/app/index.html +0 -1
  424. package/dist/.next/server/app/index.meta +0 -14
  425. package/dist/.next/server/app/index.rsc +0 -15
  426. package/dist/.next/server/app/index.segments/__PAGE__.segment.rsc +0 -5
  427. package/dist/.next/server/app/index.segments/_full.segment.rsc +0 -15
  428. package/dist/.next/server/app/index.segments/_head.segment.rsc +0 -6
  429. package/dist/.next/server/app/index.segments/_index.segment.rsc +0 -5
  430. package/dist/.next/server/app/index.segments/_tree.segment.rsc +0 -3
  431. package/dist/.next/server/app/page/app-paths-manifest.json +0 -3
  432. package/dist/.next/server/app/page/build-manifest.json +0 -16
  433. package/dist/.next/server/app/page/next-font-manifest.json +0 -10
  434. package/dist/.next/server/app/page/react-loadable-manifest.json +0 -1
  435. package/dist/.next/server/app/page/server-reference-manifest.json +0 -4
  436. package/dist/.next/server/app/page.js +0 -14
  437. package/dist/.next/server/app/page.js.map +0 -5
  438. package/dist/.next/server/app/page.js.nft.json +0 -1
  439. package/dist/.next/server/app/page_client-reference-manifest.js +0 -3
  440. package/dist/.next/server/app-paths-manifest.json +0 -6
  441. package/dist/.next/server/chunks/[externals]_next_dist_0arv.vj._.js +0 -3
  442. package/dist/.next/server/chunks/[root-of-the-server]__0vcj1q1._.js +0 -13
  443. package/dist/.next/server/chunks/[turbopack]_runtime.js +0 -903
  444. package/dist/.next/server/chunks/_next-internal_server_app_icon_svg_route_actions_0-0ehc~.js +0 -3
  445. package/dist/.next/server/chunks/ssr/05w9_next_dist_0ihu0u9._.js +0 -6
  446. package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_12u3mib._.js +0 -3
  447. package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_builtin_forbidden_04fbe_..js +0 -3
  448. package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_builtin_global-error_0brpl_..js +0 -3
  449. package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_builtin_unauthorized_0~2g66g.js +0 -3
  450. package/dist/.next/server/chunks/ssr/05w9_next_dist_esm_build_templates_app-page_0~cyr1_.js +0 -4
  451. package/dist/.next/server/chunks/ssr/05w9_next_dist_esm_build_templates_app-page_1105emf.js +0 -4
  452. package/dist/.next/server/chunks/ssr/05w9_next_dist_esm_build_templates_app-page_11uhyqv.js +0 -4
  453. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0.t9_75._.js +0 -33
  454. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0c0ud_z._.js +0 -3
  455. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0f9_8d4._.js +0 -3
  456. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0l5ko41._.js +0 -19
  457. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0mn6z7i._.js +0 -3
  458. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0npxxst._.js +0 -33
  459. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0qjhaca._.js +0 -3
  460. package/dist/.next/server/chunks/ssr/[root-of-the-server]__0rwgw3s._.js +0 -3
  461. package/dist/.next/server/chunks/ssr/[turbopack]_runtime.js +0 -903
  462. package/dist/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0k77kol.js +0 -3
  463. package/dist/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0eq97pa.js +0 -3
  464. package/dist/.next/server/chunks/ssr/_next-internal_server_app_page_actions_09-gtaw.js +0 -3
  465. package/dist/.next/server/chunks/ssr/node_modules__pnpm_056~6.6._.js +0 -3
  466. package/dist/.next/server/chunks/ssr/node_modules__pnpm_0~j0k.e._.js +0 -33
  467. package/dist/.next/server/functions-config-manifest.json +0 -4
  468. package/dist/.next/server/middleware-build-manifest.js +0 -20
  469. package/dist/.next/server/middleware-manifest.json +0 -6
  470. package/dist/.next/server/next-font-manifest.js +0 -1
  471. package/dist/.next/server/next-font-manifest.json +0 -13
  472. package/dist/.next/server/pages/404.html +0 -1
  473. package/dist/.next/server/pages/500.html +0 -1
  474. package/dist/.next/server/pages-manifest.json +0 -4
  475. package/dist/.next/server/prefetch-hints.json +0 -1
  476. package/dist/.next/server/server-reference-manifest.js +0 -1
  477. package/dist/.next/server/server-reference-manifest.json +0 -5
  478. package/dist/.next/static/7FFlzRe2eS-D0Lw5oEpmC/_buildManifest.js +0 -11
  479. package/dist/.next/static/7FFlzRe2eS-D0Lw5oEpmC/_clientMiddlewareManifest.js +0 -1
  480. package/dist/.next/static/7FFlzRe2eS-D0Lw5oEpmC/_ssgManifest.js +0 -1
  481. package/dist/.next/static/chunks/01qk2~bgf76vu.js +0 -1
  482. package/dist/.next/static/chunks/03~yq9q893hmn.js +0 -1
  483. package/dist/.next/static/chunks/080queev.r2uy.js +0 -31
  484. package/dist/.next/static/chunks/0v3lyuj75aq50.js +0 -1
  485. package/dist/.next/static/chunks/10b~xdx5c-i7s.js +0 -5
  486. package/dist/.next/static/chunks/15~9l5n.~r-.4.css +0 -2
  487. package/dist/.next/static/chunks/turbopack-0m-970~qvs7sc.js +0 -1
  488. package/dist/.next/static/media/7178b3e590c64307-s.11.cyxs5p-0z~.woff2 +0 -0
  489. package/dist/.next/static/media/8a480f0b521d4e75-s.06d3mdzz5bre_.woff2 +0 -0
  490. package/dist/.next/static/media/caa3a2e1cccd8315-s.p.16t1db8_9y2o~.woff2 +0 -0
  491. package/dist/package.json +0 -87
  492. package/dist/server.js +0 -38
  493. /package/{dist/.next/server/app/icon.svg.body → backend/src/flowent/static/favicon.svg} +0 -0
  494. /package/dist/{.next/static/media/icon.0.r~afrtrocz9.svg → frontend/favicon.svg} +0 -0
@@ -0,0 +1,7 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{R as r,W as i,it as a,st as o,tt as ee,z as te}from"./ui-vendor-Dg9NNnWX.js";import{a as s,n as c,t as l}from"./shared-CMxbpLeQ.js";import{J as u,K as d,q as f,z as p}from"./index-CL1ALZ3r.js";import{a as m,n as ne,o as re,t as ie}from"./PageScaffold-D4jO9ooX.js";import{t as h}from"./datetime-m6_O_Ci9.js";import{a as g,i as ae,n as _,r as v,t as y}from"./select-DL_LPeDj.js";import{n as b,t as x}from"./WorkspaceCommandDialog-CCXxjDL8.js";async function oe(){return l(`/api/mcp`,{method:`GET`,errorMessage:`Failed to fetch MCP state`})}async function se(){return l(`/api/mcp/refresh`,{method:`POST`,errorMessage:`Failed to refresh MCP servers`,fallback:[],map:e=>e?.servers??[]})}async function ce(e){return l(`/api/mcp/servers`,{method:`POST`,body:e,errorMessage:`Failed to create MCP server`,map:e=>{if(!e)throw Error(`Failed to create MCP server`);return e.snapshot}})}async function le(e,t){return l(`/api/mcp/servers/${e}`,{method:`PATCH`,body:t,errorMessage:`Failed to update MCP server`,map:e=>{if(!e)throw Error(`Failed to update MCP server`);return e.snapshot}})}async function ue(e){await c(`/api/mcp/servers/${e}`,{method:`DELETE`,errorMessage:`Failed to delete MCP server`})}async function de(e){return l(`/api/mcp/servers/${e}/refresh`,{method:`POST`,errorMessage:`Failed to refresh MCP server`,map:e=>{if(!e)throw Error(`Failed to refresh MCP server`);return e.snapshot}})}async function S(e){return l(`/api/mcp/servers/${e}/login`,{method:`POST`,errorMessage:`Failed to login MCP server`,map:e=>{if(!e)throw Error(`Failed to login MCP server`);return e.snapshot}})}async function C(e){await c(`/api/mcp/servers/${e}/logout`,{method:`POST`,errorMessage:`Failed to logout MCP server`})}async function fe(e,t,n={}){return l(`/api/mcp/servers/${e}/prompt-preview`,{method:`POST`,body:{name:t,arguments:n},errorMessage:`Failed to preview MCP prompt`,map:e=>{if(!e)throw Error(`Failed to preview MCP prompt`);return e.preview}})}var w=n(),pe=`border-border bg-accent/20 text-foreground hover:bg-accent/35`;function T(e){return e.split(`
2
+ `).map(e=>e.trim()).filter(Boolean)}function E(e){return e.join(`
3
+ `)}function D(e){let t={};for(let n of e.split(`
4
+ `)){let e=n.trim();if(!e)continue;let r=e.indexOf(`:`);if(r<0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&(t[i]=a)}return t}function O(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`
5
+ `)}function me({checked:e,disabled:t,label:n,onChange:r}){return(0,w.jsxs)(`label`,{className:`flex items-center justify-between gap-4 rounded-xl border border-border bg-card/20 px-4 py-3 text-sm${t?` opacity-50`:``}`,children:[(0,w.jsx)(`span`,{className:`text-foreground/85`,children:n}),(0,w.jsx)(p,{checked:e,disabled:t,label:n,onCheckedChange:r})]})}function k({draft:e,onChange:t,onOpenChange:n,onSubmit:r,open:i,pending:a,title:o}){return(0,w.jsxs)(x,{open:i,onOpenChange:n,title:o,footer:(0,w.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-3`,children:[(0,w.jsx)(u,{type:`button`,variant:`outline`,className:pe,onClick:()=>n(!1),children:`Cancel`}),(0,w.jsx)(u,{type:`button`,disabled:a,onClick:r,children:a?`Saving...`:`Save Server`})]}),className:`max-w-3xl`,children:[(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`Name`,children:(0,w.jsx)(f,{value:e.name,onChange:n=>t({...e,name:n.target.value}),placeholder:`filesystem`})}),(0,w.jsx)(b,{label:`Transport`,children:(0,w.jsxs)(y,{value:e.transport,onValueChange:n=>t({...e,transport:n}),children:[(0,w.jsx)(ae,{className:`h-8 w-full rounded-md bg-background/50 text-sm text-foreground`,children:(0,w.jsx)(g,{placeholder:`Select transport`})}),(0,w.jsxs)(_,{className:`rounded-xl bg-popover text-popover-foreground`,children:[(0,w.jsx)(v,{value:`stdio`,children:`stdio`}),(0,w.jsx)(v,{value:`streamable_http`,children:`streamable_http`})]})]})})]}),(0,w.jsx)(b,{label:`Launcher Command`,hint:`optional`,children:(0,w.jsx)(f,{value:e.launcher,onChange:n=>t({...e,launcher:n.target.value}),placeholder:e.transport===`streamable_http`?`https://mcp.example.com`:`npx @playwright/mcp@latest`})}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(me,{checked:e.enabled,label:`Enabled`,onChange:n=>t({...e,enabled:n})}),(0,w.jsx)(me,{checked:e.required,label:`Required`,onChange:n=>t({...e,required:n})})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`Startup Timeout`,hint:`seconds`,children:(0,w.jsx)(f,{type:`number`,value:String(e.startup_timeout_sec),onChange:n=>t({...e,startup_timeout_sec:Number(n.target.value)||10})})}),(0,w.jsx)(b,{label:`Tool Timeout`,hint:`seconds`,children:(0,w.jsx)(f,{type:`number`,value:String(e.tool_timeout_sec),onChange:n=>t({...e,tool_timeout_sec:Number(n.target.value)||30})})})]}),e.transport===`stdio`?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(b,{label:`Command`,children:(0,w.jsx)(f,{value:e.command,onChange:n=>t({...e,command:n.target.value}),placeholder:`npx`})}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`Args`,hint:`one per line`,children:(0,w.jsx)(d,{rows:5,value:E(e.args),onChange:n=>t({...e,args:T(n.target.value)})})}),(0,w.jsx)(b,{label:`Env Vars`,hint:`one env var name per line`,children:(0,w.jsx)(d,{rows:5,value:E(e.env_vars),onChange:n=>t({...e,env_vars:T(n.target.value)})})})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`Env`,hint:`KEY: value`,children:(0,w.jsx)(d,{rows:5,value:O(e.env),onChange:n=>t({...e,env:D(n.target.value)})})}),(0,w.jsx)(b,{label:`Cwd`,children:(0,w.jsx)(f,{value:e.cwd,onChange:n=>t({...e,cwd:n.target.value}),placeholder:`/workspace/tools`})})]})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(b,{label:`URL`,children:(0,w.jsx)(f,{value:e.url,onChange:n=>t({...e,url:n.target.value}),placeholder:`https://mcp.example.com`})}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`Bearer Token Env Var`,children:(0,w.jsx)(f,{value:e.bearer_token_env_var,onChange:n=>t({...e,bearer_token_env_var:n.target.value}),placeholder:`MCP_TOKEN`})}),(0,w.jsx)(b,{label:`OAuth Resource`,children:(0,w.jsx)(f,{value:e.oauth_resource,onChange:n=>t({...e,oauth_resource:n.target.value}),placeholder:`https://mcp.example.com`})})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`HTTP Headers`,hint:`Header: value`,children:(0,w.jsx)(d,{rows:5,value:O(e.http_headers),onChange:n=>t({...e,http_headers:D(n.target.value)})})}),(0,w.jsx)(b,{label:`Env HTTP Headers`,hint:`one env var name per line`,children:(0,w.jsx)(d,{rows:5,value:E(e.env_http_headers),onChange:n=>t({...e,env_http_headers:T(n.target.value)})})})]}),(0,w.jsx)(b,{label:`Scopes`,hint:`one scope per line`,children:(0,w.jsx)(d,{rows:4,value:E(e.scopes),onChange:n=>t({...e,scopes:T(n.target.value)})})})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsx)(b,{label:`Enabled Tools`,hint:`one raw tool name per line`,children:(0,w.jsx)(d,{rows:4,value:E(e.enabled_tools),onChange:n=>t({...e,enabled_tools:T(n.target.value)})})}),(0,w.jsx)(b,{label:`Disabled Tools`,hint:`one raw tool name per line`,children:(0,w.jsx)(d,{rows:4,value:E(e.disabled_tools),onChange:n=>t({...e,disabled_tools:T(n.target.value)})})})]})]})}var A=`text-[12px] font-medium text-muted-foreground/80`,he=`text-[12px] font-medium text-muted-foreground/80`,j=`rounded-xl border border-border bg-card/20 px-4 py-4`,ge=`min-h-[44px] whitespace-pre-wrap break-all rounded-xl border border-border bg-background/40 px-4 py-3 text-[12px] leading-6 text-foreground/80`,_e=`inline-flex h-8 items-center rounded-full border px-3 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,M=`inline-flex h-8 -mb-px items-center border-b-2 px-1 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`;function N({label:e,value:t}){return(0,w.jsxs)(`div`,{className:j,children:[(0,w.jsx)(`p`,{className:he,children:e}),(0,w.jsx)(`p`,{className:`mt-2 text-[26px] font-medium text-foreground`,children:t})]})}function P({active:e,label:t,onClick:n,variant:r=`pill`}){return(0,w.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,className:s(r===`pill`?_e:M,r===`pill`?e?`border-border bg-card/30 text-foreground`:`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25 hover:text-foreground`:e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:t})}function F({label:e,value:t,mono:n=!1}){return(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(`p`,{className:A,children:e}),(0,w.jsx)(`pre`,{className:s(ge,n&&`font-mono text-[11px]`),children:t})]})}var I=[`overview`,`capabilities`,`activity`],L=[`tools`,`resources`,`resource_templates`,`prompts`],R=[{value:`all`,label:`All`},{value:`connected`,label:`Connected`},{value:`auth_required`,label:`Auth Required`},{value:`error`,label:`Error`},{value:`disabled`,label:`Disabled`},{value:`connecting`,label:`Connecting`}],z=[{value:`all`,label:`All`},{value:`refresh`,label:`Refresh`},{value:`auth`,label:`Auth`},{value:`tool`,label:`Tool`},{value:`resource`,label:`Resource`},{value:`prompt`,label:`Prompt`}],B={name:``,transport:`stdio`,enabled:!0,required:!1,startup_timeout_sec:10,tool_timeout_sec:30,enabled_tools:[],disabled_tools:[],scopes:[],oauth_resource:``,launcher:``,command:``,args:[],env:{},env_vars:[],cwd:``,url:``,bearer_token_env_var:``,http_headers:{},env_http_headers:[]};function ve(e){return h(e,{fallback:`Never`})}function V(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function H(e){switch(e){case`unsupported`:return`Unsupported`;case`not_logged_in`:return`Not logged in`;case`logging_in`:return`Logging in`;case`connected`:return`Connected`;case`error`:return`Error`;default:return V(e)}}function ye(e){return h(e,{fallback:`Never`,format:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}})}function U(e){switch(e){case`disabled`:return`Disabled`;case`connecting`:return`Connecting`;case`connected`:return`Connected`;case`auth_required`:return`Auth required`;case`error`:return`Error`;default:return e}}function W(e){switch(e){case`connected`:return`border-graph-status-running/18 bg-graph-status-running/[0.12] text-graph-status-running`;case`auth_required`:return`border-graph-status-idle/18 bg-graph-status-idle/[0.12] text-graph-status-idle`;case`error`:return`border-destructive/30 bg-destructive/10 text-destructive`;case`disabled`:return`border-border bg-accent/20 text-muted-foreground`;default:return`border-primary/20 bg-primary/[0.1] text-primary`}}function be(e){switch(e){case`success`:return`border-graph-status-running/18 bg-graph-status-running/[0.12] text-graph-status-running`;case`rejected`:return`border-graph-status-idle/18 bg-graph-status-idle/[0.12] text-graph-status-idle`;default:return`border-destructive/30 bg-destructive/10 text-destructive`}}function xe(e){let t=e.snapshot.capability_counts;return`${t.tools} tools · ${t.resources} resources · ${t.prompts} prompts`}function G(e){return e.visibility.active?`Global`:null}function Se(e){return e.length<2?e:e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1):e}function Ce(e){return(e.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>Se(e))}function K(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function we(e){return K((e.startsWith(`@`)?e.replace(/@[^/@]+$/u,``):e.replace(/@[^/]+$/u,``)).split(`/`).filter(Boolean).join(`-`))}function Te(e){try{let t=new URL(e);return K(t.hostname.replace(/^www\./u,``).split(`.`).filter(e=>e&&![`mcp`,`api`].includes(e))[0]??t.hostname)}catch{return``}}function Ee(e,t){if(/^https?:\/\//u.test(e))return Te(e);let n=t[0]??``,r=n===`pnpm`||n===`yarn`?2:n===`npm`?3:1,i=t.slice(r).find(e=>e&&!e.startsWith(`-`));if(i){let e=we(i);if(e)return e}return n?K(n.split(`/`).pop()??n):``}function De(e,t){let n=e.trim(),r=K(t);if(!n)return{draft:null,error:`Enter a launcher command or URL.`};if(!r)return{draft:null,error:`Quick Add needs a valid server name.`};if(/^https?:\/\//u.test(n))try{let e=new URL(n).toString();return{draft:{...B,name:r,transport:`streamable_http`,launcher:n,url:e},error:null}}catch{return{draft:null,error:`Quick Add URL is not valid.`}}let i=Ce(n);return i.length===0?{draft:null,error:`Quick Add needs a single-line launcher command.`}:{draft:{...B,name:r,transport:`stdio`,launcher:n,command:i[0],args:i.slice(1)},error:null}}function Oe(e){return e.config.transport===`streamable_http`?e.config.url.trim()||`No URL configured`:[e.config.command,...e.config.args].filter(Boolean).join(` `)}function ke(e){return{config:e,snapshot:{server_name:e.name,transport:e.transport,status:`connecting`,auth_status:e.transport===`stdio`?`unsupported`:`not_logged_in`,last_auth_result:null,last_refresh_at:null,last_refresh_result:`never`,last_error:null,tools:[],resources:[],resource_templates:[],prompts:[],capability_counts:{tools:0,resources:0,resource_templates:0,prompts:0}},visibility:{scope:`global`,active:!1},activity:[]}}function Ae(e){return e.config.enabled_tools.length>0?`Enabled tools limited to ${e.config.enabled_tools.length} entries`:e.config.disabled_tools.length>0?`${e.config.disabled_tools.length} tools excluded`:`All discovered tools remain available`}function je(e){return e.config.transport===`stdio`?`Auth N/A`:e.snapshot.auth_status===`connected`?`Logout`:`Login`}function Me(e){return e.config.transport===`stdio`}function q(e,t=`Not set`){return typeof e==`string`&&e.trim()||t}function J(e,t=`None`){return e.length===0?t:e.join(`
6
+ `)}function Ne(e,t=`None`){let n=Object.keys(e);return n.length===0?t:n.join(`
7
+ `)}function Pe(e){if(e.action===`login`||e.action===`logout`)return!0;if(e.action!==`refresh`)return!1;let t=`${e.summary} ${e.target??``}`.toLowerCase();return[`auth`,`authentication`,`oauth`,`token`,`bearer`,`login`,`logged out`,`env var`].some(e=>t.includes(e))}function Fe(e){if(Pe(e))return`auth`;switch(e.action){case`refresh`:return`refresh`;case`login`:case`logout`:return`auth`;case`tool_call`:return`tool`;case`resource_read`:return`resource`;case`prompt_get`:return`prompt`;default:return`all`}}function Ie(e){switch(Fe(e)){case`refresh`:return`Refresh`;case`auth`:return`Auth`;case`tool`:return`Tool`;case`resource`:return`Resource`;case`prompt`:return`Prompt`;default:return V(e.action)}}function Le(e,t){return!(t!==`all`&&e.snapshot.status!==t)}function Re(e,t=`Not set`){return e.trim()?e:t}function ze(e){return Object.fromEntries((e?.arguments??[]).map(e=>e.name).filter(e=>typeof e==`string`&&e.length>0).map(e=>[e,``]))}var Y=e(t(),1);function Be(){let{data:e,error:t,isLoading:n,mutate:i}=re(`mcp-state`,oe),[a,o]=(0,Y.useState)(null),[ee,te]=(0,Y.useState)(`overview`),[s,c]=(0,Y.useState)(`tools`),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(B),[ne,ie]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),[ae,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(`{}`),[w,pe]=(0,Y.useState)(`all`),[T,E]=(0,Y.useState)(`all`),[D,O]=(0,Y.useState)(``),[me,k]=(0,Y.useState)(``),[A,he]=(0,Y.useState)(!1),[j,ge]=(0,Y.useState)(!1),[_e,M]=(0,Y.useState)(null),N=(0,Y.useMemo)(()=>Ce(D.trim()),[D]),P=(0,Y.useMemo)(()=>Ee(D.trim(),N),[D,N]),F=A?me:P,I=(0,Y.useMemo)(()=>De(D,F),[D,F]),L=(0,Y.useMemo)(()=>{let t=e?.servers??[];return!j||I.draft===null||t.some(e=>e.config.name===I.draft?.name)?t:[ke(I.draft),...t]},[e,I.draft,j]),R=(0,Y.useMemo)(()=>L.filter(e=>Le(e,w)),[w,L]),z=(0,Y.useMemo)(()=>R.find(e=>e.config.name===a)??R[0]??null,[R,a]);(0,Y.useEffect)(()=>{R.length>0&&!R.some(e=>e.config.name===a)&&o(R[0]?.config.name??null)},[R,a]),(0,Y.useEffect)(()=>{g(null),_(null),y(!1),x(`{}`),E(`all`)},[z?.config.name]),(0,Y.useEffect)(()=>{A||k(P)},[A,P]);let ve=(0,Y.useMemo)(()=>({configured:L.length,connected:L.filter(e=>e.snapshot.status===`connected`).length,authRequired:L.filter(e=>e.snapshot.status===`auth_required`).length,error:L.filter(e=>e.snapshot.status===`error`).length}),[L]),V=(0,Y.useMemo)(()=>z?.snapshot.prompts.find(e=>e.name===h)??null,[h,z]),H=(0,Y.useMemo)(()=>z?z.activity.filter(e=>T===`all`?!0:Fe(e)===T):[],[T,z]),ye=()=>{f(null),m(B),u(!0)},U=e=>{f(e.config.name),m(e.config),u(!0)},W=e=>{O(e),M(null)},be=e=>{he(!0),k(e),M(null)},xe=()=>{document.getElementById(`mcp-quick-add-input`)?.focus()},G=()=>{pe(`all`)},Se=async()=>{try{await se(),await i(),r.success(`MCP servers refreshed`)}catch(e){r.error(e instanceof Error?e.message:`Failed to refresh MCP servers`)}},K=async()=>{ie(!0);try{d?await le(d,p):await ce(p),await i(),o(p.name.trim()),u(!1),r.success(`MCP server saved`)}catch(e){r.error(e instanceof Error?e.message:`Failed to save MCP server`)}finally{ie(!1)}},we=async()=>{if(I.error||I.draft===null){M(I.error??`Quick Add is not ready yet.`);return}ge(!0),M(null),o(I.draft.name);try{await ce(I.draft),await i(),o(I.draft.name),O(``),k(``),he(!1),r.success(`MCP server added`)}catch(e){await i(),o(I.draft.name),M(e instanceof Error?e.message:`Failed to add MCP server`),r.error(e instanceof Error?e.message:`Failed to add MCP server`)}finally{ge(!1)}},Te=async e=>{try{await ue(e),await i(),r.success(`MCP server removed`)}catch(e){r.error(e instanceof Error?e.message:`Failed to remove MCP server`)}},Oe=async e=>{try{await le(e.config.name,{...e.config,enabled:!e.config.enabled}),await i()}catch(e){r.error(e instanceof Error?e.message:`Failed to update MCP server`)}},Ae=async e=>{try{await de(e),await i(),r.success(`Server refreshed`)}catch(e){r.error(e instanceof Error?e.message:`Failed to refresh server`)}},je=async e=>{try{await S(e),await i(),r.success(`Server refreshed after login`)}catch(e){r.error(e instanceof Error?e.message:`Failed to login MCP server`)}},Me=async e=>{try{await C(e),await i(),r.success(`Logout request sent`)}catch(e){r.error(e instanceof Error?e.message:`Failed to logout MCP server`)}},q=async(e,t,n={})=>{y(!0);try{_(await fe(e,t,n))}catch(e){_({error:e instanceof Error?e.message:`Failed to preview prompt`})}finally{y(!1)}};return{error:t,isLoading:n,servers:L,filteredServers:R,selectedServer:z,summaryCounts:ve,filteredActivity:H,detailTab:ee,setDetailTab:te,capabilityTab:s,setCapabilityTab:c,serverStatusFilter:w,setServerStatusFilter:pe,activityFilter:T,setActivityFilter:E,selectedServerName:a,setSelectedServerName:o,clearServerFilters:G,focusQuickAdd:xe,dialog:{draft:p,editingServerName:d,open:l,pending:ne,setDraft:m,setOpen:u,openCreateDialog:ye,openEditDialog:U,saveServer:K},quickAdd:{error:_e,input:D,nameValue:F,parse:I,pending:j,setInput:W,setName:be,submit:we},promptPreviewState:{argumentsText:b,loading:v,preview:ae,selectedPrompt:V,selectedPromptName:h,setArgumentsText:e=>{x(e)},previewCurrent:()=>{if(!(!z||!h))try{let e=JSON.parse(b);q(z.config.name,h,e)}catch{_({error:`Arguments must be valid JSON`})}},selectPrompt:(e,t)=>{g(t);let n=ze(z?.snapshot.prompts.find(e=>e.name===t)??null);x(JSON.stringify(n,null,2)),q(e,t,n)}},actions:{deleteServer:Te,login:je,logout:Me,refreshAll:Se,refreshServer:Ae,toggleEnabled:Oe}}}var X=`bg-card/20`,Z=`text-[13px] text-muted-foreground`,Ve=`rounded-xl border border-border bg-card/20 px-4 py-3`,Q=`mt-4 max-h-48 overflow-auto rounded-xl border border-border bg-background/55 p-3 text-[11px] text-foreground/70`,$=`border-border bg-accent/20 text-foreground hover:bg-accent/35`,He=`border-destructive/30 bg-destructive/10 text-destructive hover:bg-destructive/18`,Ue=`rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.14em]`,We=`flex size-14 items-center justify-center rounded-xl border border-border bg-accent/20 text-muted-foreground`;function Ge(){let{actions:e,activityFilter:t,capabilityTab:n,clearServerFilters:r,detailTab:c,dialog:l,error:p,filteredActivity:re,filteredServers:h,focusQuickAdd:g,isLoading:ae,promptPreviewState:_,quickAdd:v,selectedServer:y,serverStatusFilter:x,servers:oe,setActivityFilter:se,setCapabilityTab:ce,setDetailTab:le,setSelectedServerName:ue,setServerStatusFilter:de,summaryCounts:S}=Be(),C=(0,w.jsx)(m,{className:s(`mt-4`,X),children:(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:A,children:`Quick Add`}),(0,w.jsxs)(`p`,{className:`mt-2 max-w-3xl text-[13px] leading-6 text-muted-foreground`,children:[`Paste a single-line launcher such as`,` `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`npx @playwright/mcp@latest`}),` `,`or a single`,` `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`streamable_http`}),` `,`URL. Connected servers become visible to every agent automatically.`]})]}),v.parse.draft?(0,w.jsx)(`span`,{className:s(`rounded-full border px-2.5 py-1 text-[10px] font-medium`,W(v.parse.draft.transport===`streamable_http`?`connected`:`connecting`)),children:v.parse.draft.transport===`streamable_http`?`URL`:`Launcher`}):null]}),(0,w.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(260px,0.6fr)]`,children:[(0,w.jsx)(b,{label:`Launcher or URL`,children:(0,w.jsx)(f,{id:`mcp-quick-add-input`,value:v.input,onChange:e=>v.setInput(e.target.value),placeholder:`npx @playwright/mcp@latest`})}),(0,w.jsx)(b,{label:`Name`,children:(0,w.jsx)(f,{value:v.nameValue,onChange:e=>v.setName(e.target.value),placeholder:`playwright-mcp`})})]}),v.parse.draft?(0,w.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-3`,children:[(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Transport`}),(0,w.jsx)(`p`,{className:`mt-2 text-[14px] font-medium text-foreground`,children:v.parse.draft.transport})]}),(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Parsed Name`}),(0,w.jsx)(`p`,{className:`mt-2 text-[14px] font-medium text-foreground`,children:v.parse.draft.name})]}),(0,w.jsxs)(m,{className:s(`xl:col-span-1`,X),children:[(0,w.jsx)(`p`,{className:A,children:`Parsed Result`}),(0,w.jsx)(`p`,{className:`mt-2 break-all font-mono text-[12px] text-foreground/80`,children:v.parse.draft.transport===`streamable_http`?v.parse.draft.url:[v.parse.draft.command,...v.parse.draft.args].join(` `)})]})]}):null,v.error||v.input.trim()&&v.parse.error?(0,w.jsx)(`p`,{className:`text-[13px] text-destructive`,children:v.error??v.parse.error}):(0,w.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`Package-runner launchers download and start in one path. If first startup is slow, the server will stay visible as Connecting until refresh finishes.`}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(u,{type:`button`,disabled:v.pending||v.parse.draft===null,onClick:()=>void v.submit(),children:v.pending?`Adding...`:`Quick Add`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:$,onClick:l.openCreateDialog,children:`Advanced Add`})]})]})});return(0,w.jsxs)(ie,{children:[(0,w.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-8 py-6`,children:[(0,w.jsx)(ne,{title:`MCP`,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(u,{type:`button`,variant:`outline`,className:$,onClick:e.refreshAll,children:[(0,w.jsx)(a,{className:`mr-2 size-4`}),`Refresh`]}),(0,w.jsxs)(u,{type:`button`,variant:`outline`,className:$,onClick:g,children:[(0,w.jsx)(o,{className:`mr-2 size-4`}),`Quick Add`]}),(0,w.jsxs)(u,{type:`button`,onClick:l.openCreateDialog,children:[(0,w.jsx)(o,{className:`mr-2 size-4`}),`Advanced Add`]})]})}),(0,w.jsx)(`div`,{className:`mt-6 min-h-0 flex-1 overflow-hidden`,children:ae?(0,w.jsxs)(`div`,{className:`grid h-full gap-5 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,w.jsxs)(`div`,{className:`space-y-3`,children:[Array.from({length:5}).map((e,t)=>(0,w.jsx)(`div`,{className:`h-24 rounded-xl border border-border bg-card/20 skeleton-shimmer`},t)),(0,w.jsx)(`p`,{className:`px-2 text-[13px] text-muted-foreground`,children:`Loading MCP servers...`})]}),(0,w.jsx)(`div`,{className:`rounded-xl border border-border bg-card/20 skeleton-shimmer`})]}):p?(0,w.jsx)(m,{className:`flex h-full items-center justify-center text-center text-muted-foreground`,children:`Failed to load MCP state.`}):oe.length===0?(0,w.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[C,(0,w.jsxs)(m,{className:`mt-4 flex h-full flex-col items-center justify-center text-center`,children:[(0,w.jsx)(`div`,{className:We,children:(0,w.jsx)(i,{className:`size-6`})}),(0,w.jsx)(`h2`,{className:`mt-5 text-[16px] font-medium text-foreground`,children:`No MCP servers`})]})]}):(0,w.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,w.jsx)(m,{children:(0,w.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,w.jsx)(N,{label:`Configured`,value:S.configured}),(0,w.jsx)(N,{label:`Connected`,value:S.connected}),(0,w.jsx)(N,{label:`Auth Required`,value:S.authRequired}),(0,w.jsx)(N,{label:`Error`,value:S.error})]})}),C,(0,w.jsx)(m,{className:`mt-4`,children:(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:R.map(e=>(0,w.jsx)(P,{active:x===e.value,label:e.label,onClick:()=>de(e.value)},e.value))})}),(0,w.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-hidden`,children:h.length===0?(0,w.jsxs)(m,{className:`flex h-full flex-col items-center justify-center text-center`,children:[(0,w.jsx)(`div`,{className:We,children:(0,w.jsx)(ee,{className:`size-6`})}),(0,w.jsx)(`h2`,{className:`mt-5 text-[16px] font-medium text-foreground`,children:`No matching MCP servers`}),(0,w.jsx)(`p`,{className:`mt-2 max-w-lg text-[13px] leading-6 text-muted-foreground`,children:`Choose another status filter to see matching servers again.`}),(0,w.jsxs)(u,{type:`button`,variant:`outline`,className:s(`mt-5`,$),onClick:r,children:[(0,w.jsx)(te,{className:`mr-2 size-4`}),`Show All Servers`]})]}):(0,w.jsxs)(`div`,{className:`grid h-full gap-5 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,w.jsx)(`div`,{className:`min-h-0 overflow-y-auto pr-1 scrollbar-none`,children:(0,w.jsx)(`div`,{className:`space-y-3`,children:h.map(t=>{let n=y?.config.name===t.config.name,r=G(t);return(0,w.jsx)(`div`,{className:s(`rounded-xl border p-4 transition-colors`,n?`border-border bg-accent/20`:`border-border bg-card/20 hover:bg-accent/20`),children:(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,w.jsxs)(u,{type:`button`,variant:`ghost`,onClick:()=>ue(t.config.name),className:`h-auto min-w-0 flex-1 justify-start p-0 text-left hover:bg-transparent hover:text-inherit`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:t.config.name}),t.config.required?(0,w.jsx)(`span`,{className:`rounded-full border border-graph-status-idle/18 bg-graph-status-idle/[0.12] px-2 py-0.5 text-[10px] font-medium text-graph-status-idle`,children:`required`}):null,r?(0,w.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/[0.1] px-2 py-0.5 text-[10px] font-medium text-primary`,children:r}):null]}),(0,w.jsxs)(`div`,{className:`mt-3 grid gap-1.5 text-[12px] text-muted-foreground`,children:[(0,w.jsxs)(`p`,{children:[`Transport `,t.config.transport]}),(0,w.jsxs)(`p`,{children:[`Status`,` `,U(t.snapshot.status)]}),(0,w.jsxs)(`p`,{children:[`Auth`,` `,H(t.snapshot.auth_status)]}),(0,w.jsx)(`p`,{children:xe(t)}),r?(0,w.jsx)(`p`,{children:r}):null]}),t.snapshot.last_error?(0,w.jsx)(`p`,{className:`mt-3 line-clamp-2 text-[12px] leading-5 text-destructive`,children:t.snapshot.last_error}):null]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,w.jsx)(`span`,{className:s(`rounded-full border px-2.5 py-1 text-[10px] font-medium`,W(t.snapshot.status)),children:U(t.snapshot.status)}),(0,w.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:[(0,w.jsx)(u,{type:`button`,variant:`outline`,className:s(`h-7 px-2 text-[11px]`,$),onClick:()=>e.toggleEnabled(t),children:t.config.enabled?`Disable`:`Enable`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,disabled:Me(t),className:s(`h-7 px-2 text-[11px]`,$),onClick:()=>t.snapshot.auth_status===`connected`?e.logout(t.config.name):e.login(t.config.name),children:je(t)}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:s(`h-7 px-2 text-[11px]`,$),onClick:()=>l.openEditDialog(t),children:`Edit`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:s(`h-7 px-2 text-[11px]`,$),onClick:()=>e.refreshServer(t.config.name),children:`Refresh`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:s(`h-7 px-2 text-[11px]`,He),onClick:()=>e.deleteServer(t.config.name),children:`Remove`})]})]})]})},t.config.name)})})}),(0,w.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:y?(0,w.jsxs)(m,{className:`flex h-full min-h-0 flex-col`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4 border-b border-border pb-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`h2`,{className:`text-[18px] font-medium text-foreground`,children:y.config.name}),(0,w.jsx)(`span`,{className:s(Ue,W(y.snapshot.status)),children:U(y.snapshot.status)}),G(y)?(0,w.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/[0.1] px-2.5 py-1 text-[10px] font-medium text-primary`,children:G(y)}):null]}),(0,w.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[y.config.transport,` · Auth`,` `,H(y.snapshot.auth_status)]}),y.snapshot.last_error?(0,w.jsx)(`p`,{className:`mt-2 max-w-3xl text-[13px] leading-6 text-destructive`,children:y.snapshot.last_error}):null]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(u,{type:`button`,variant:`outline`,className:$,onClick:()=>e.toggleEnabled(y),children:y.config.enabled?`Disable`:`Enable`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,disabled:Me(y),className:$,onClick:()=>y.snapshot.auth_status===`connected`?e.logout(y.config.name):e.login(y.config.name),children:je(y)}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:$,onClick:()=>l.openEditDialog(y),children:`Edit`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:$,onClick:()=>e.refreshServer(y.config.name),children:`Refresh`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:He,onClick:()=>e.deleteServer(y.config.name),children:`Remove`})]})]}),(0,w.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 border-b border-border`,children:I.map(e=>(0,w.jsx)(P,{active:c===e,label:V(e),onClick:()=>le(e),variant:`tab`},e))}),(0,w.jsxs)(`div`,{className:`mt-5 min-h-0 flex-1 overflow-y-auto pr-1 scrollbar-none`,children:[c===`overview`?(0,w.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Status`}),(0,w.jsx)(`p`,{className:`mt-3 text-[22px] font-medium text-foreground`,children:U(y.snapshot.status)}),(0,w.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Auth`,` `,H(y.snapshot.auth_status)]})]}),(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Visibility`}),(0,w.jsx)(`p`,{className:`mt-3 text-[22px] font-medium text-foreground`,children:G(y)??`Pending`}),(0,w.jsx)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:`Connected servers become available to all agents without per-tab setup.`})]}),(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Last Refresh`}),(0,w.jsx)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:ve(y.snapshot.last_refresh_at)}),(0,w.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Result`,` `,V(y.snapshot.last_refresh_result)]})]}),(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Timeouts`}),(0,w.jsxs)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:[`Startup`,` `,y.config.startup_timeout_sec,`s`]}),(0,w.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Tool`,` `,y.config.tool_timeout_sec,`s`]})]}),(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Tool Filters`}),(0,w.jsx)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:Ae(y)}),(0,w.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Enabled`,` `,y.config.enabled_tools.length,` · `,`Disabled`,` `,y.config.disabled_tools.length]})]}),(0,w.jsxs)(m,{className:s(`xl:col-span-2`,X),children:[(0,w.jsx)(`p`,{className:A,children:`Capability Summary`}),(0,w.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:Object.entries(y.snapshot.capability_counts).map(([e,t])=>(0,w.jsxs)(`div`,{className:Ve,children:[(0,w.jsx)(`p`,{className:A,children:e.replaceAll(`_`,` `)}),(0,w.jsx)(`p`,{className:`mt-2 text-xl font-medium text-foreground`,children:t})]},e))})]}),y.config.launcher?(0,w.jsx)(m,{className:s(`xl:col-span-2`,X),children:(0,w.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,w.jsx)(F,{label:`Original Launcher`,value:q(y.config.launcher),mono:!0}),(0,w.jsx)(F,{label:`Parsed Result`,value:Oe(y),mono:!0})]})}):null,y.config.transport===`stdio`?(0,w.jsx)(m,{className:s(`xl:col-span-2`,X),children:(0,w.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,w.jsx)(F,{label:`Command`,value:q(y.config.command),mono:!0}),(0,w.jsx)(F,{label:`Cwd`,value:q(y.config.cwd),mono:!0}),(0,w.jsx)(F,{label:`Args`,value:J(y.config.args),mono:!0}),(0,w.jsx)(F,{label:`Env Vars`,value:J(y.config.env_vars),mono:!0})]})}):(0,w.jsxs)(m,{className:s(`xl:col-span-2`,X),children:[(0,w.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,w.jsx)(F,{label:`URL`,value:q(y.config.url),mono:!0}),(0,w.jsx)(F,{label:`OAuth Resource`,value:q(y.config.oauth_resource),mono:!0}),(0,w.jsx)(F,{label:`Bearer Token Env Var`,value:q(y.config.bearer_token_env_var),mono:!0}),(0,w.jsx)(F,{label:`Scopes`,value:J(y.config.scopes),mono:!0}),(0,w.jsx)(F,{label:`HTTP Headers`,value:Ne(y.config.http_headers),mono:!0}),(0,w.jsx)(F,{label:`Env HTTP Headers`,value:J(y.config.env_http_headers),mono:!0})]}),(0,w.jsxs)(`div`,{className:s(`mt-4`,Ve),children:[(0,w.jsx)(`p`,{className:A,children:`Recent Auth Result`}),(0,w.jsx)(`p`,{className:`mt-2 text-[14px] font-medium text-foreground`,children:Re(y.snapshot.last_auth_result??``,`No login action yet`)}),(0,w.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Current auth status`,` `,H(y.snapshot.auth_status)]})]})]})]}):null,c===`capabilities`?(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsx)(`div`,{className:`flex flex-wrap gap-4 border-b border-border`,children:L.map(e=>(0,w.jsx)(P,{active:n===e,label:e===`resource_templates`?`Resource Templates`:V(e),onClick:()=>ce(e),variant:`tab`},e))}),n===`tools`?(0,w.jsx)(`div`,{className:`space-y-3`,children:y.snapshot.tools.length===0?(0,w.jsx)(m,{className:s(X,Z),children:`No tools discovered.`}):y.snapshot.tools.map(e=>(0,w.jsxs)(m,{className:X,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`font-mono text-[13px] text-foreground`,children:e.tool_name}),e.title?(0,w.jsx)(`p`,{className:`mt-2 text-[13px] text-foreground/70`,children:e.title}):null,(0,w.jsx)(`p`,{className:`mt-1 text-[12px] text-muted-foreground`,children:e.fully_qualified_id})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[10px]`,children:[e.read_only_hint?(0,w.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/[0.1] px-2 py-1 text-primary`,children:`readOnly`}):null,e.destructive_hint?(0,w.jsx)(`span`,{className:`rounded-full border border-destructive/30 bg-destructive/10 px-2 py-1 text-destructive`,children:`destructive`}):null,e.open_world_hint?(0,w.jsx)(`span`,{className:`rounded-full border border-graph-status-idle/18 bg-graph-status-idle/[0.12] px-2 py-1 text-graph-status-idle`,children:`openWorld`}):null]})]}),e.description?(0,w.jsx)(`p`,{className:`mt-3 text-[13px] leading-6 text-muted-foreground`,children:e.description}):null,(0,w.jsx)(`pre`,{className:Q,children:JSON.stringify(e.parameters??{},null,2)})]},e.fully_qualified_id))}):null,n===`resources`?(0,w.jsx)(`div`,{className:`space-y-3`,children:y.snapshot.resources.length===0?(0,w.jsx)(m,{className:s(X,Z),children:`No resources discovered.`}):y.snapshot.resources.map(e=>(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:e.name}),(0,w.jsx)(`p`,{className:`mt-1 font-mono text-[12px] text-muted-foreground`,children:e.uri}),(0,w.jsx)(`p`,{className:`mt-3 text-[13px] text-foreground/70`,children:e.mime_type??`Unknown MIME`}),e.description?(0,w.jsx)(`p`,{className:`mt-2 text-[13px] leading-6 text-muted-foreground`,children:e.description}):null]},e.uri))}):null,n===`resource_templates`?(0,w.jsx)(`div`,{className:`space-y-3`,children:y.snapshot.resource_templates.length===0?(0,w.jsx)(m,{className:s(X,Z),children:`No resource templates discovered.`}):y.snapshot.resource_templates.map(e=>(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:e.name}),(0,w.jsx)(`p`,{className:`mt-1 font-mono text-[12px] text-muted-foreground`,children:e.uri_template}),e.description?(0,w.jsx)(`p`,{className:`mt-3 text-[13px] leading-6 text-muted-foreground`,children:e.description}):null]},e.uri_template))}):null,n===`prompts`?(0,w.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]`,children:[(0,w.jsx)(`div`,{className:`space-y-3`,children:y.snapshot.prompts.length===0?(0,w.jsx)(m,{className:s(X,Z),children:`No prompts discovered.`}):y.snapshot.prompts.map(e=>(0,w.jsxs)(u,{type:`button`,variant:`ghost`,onClick:()=>_.selectPrompt(y.config.name,e.name),className:s(`h-auto w-full flex-col items-stretch rounded-xl border border-border bg-card/20 p-5 text-left transition-colors hover:text-inherit`,_.selectedPromptName===e.name?`border-border bg-accent/20`:`hover:bg-accent/20`),children:[(0,w.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:e.name}),e.description?(0,w.jsx)(`p`,{className:`mt-2 text-[13px] leading-6 text-muted-foreground`,children:e.description}):null,(0,w.jsx)(`pre`,{className:Q,children:JSON.stringify(e.arguments??[],null,2)})]},e.name))}),(0,w.jsxs)(m,{className:X,children:[(0,w.jsx)(`p`,{className:A,children:`Prompt Preview`}),_.selectedPromptName?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:_.selectedPromptName}),(0,w.jsx)(`p`,{className:`mt-4 text-[11px] text-muted-foreground/80`,children:`Arguments`}),(0,w.jsx)(d,{value:_.argumentsText,onChange:e=>_.setArgumentsText(e.target.value),className:`mt-2 min-h-[120px] bg-background/50 font-mono text-[11px] text-foreground/80`}),(0,w.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,w.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`Edit argument JSON, then refresh the preview.`}),(0,w.jsx)(u,{type:`button`,variant:`outline`,className:$,onClick:_.previewCurrent,children:`Preview`})]}),_.selectedPrompt?.arguments?.length?(0,w.jsx)(`pre`,{className:s(Q,`max-h-40`),children:JSON.stringify(_.selectedPrompt.arguments,null,2)}):null,(0,w.jsx)(`pre`,{className:s(Q,`max-h-[420px]`),children:_.loading?`Loading preview...`:JSON.stringify(_.preview??{},null,2)})]}):(0,w.jsx)(`p`,{className:`mt-4 text-[13px] leading-6 text-muted-foreground`,children:`Select a prompt to preview its parameter structure and template result.`})]})]}):null]}):null,c===`activity`?(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.map(e=>(0,w.jsx)(P,{active:t===e.value,label:e.label,onClick:()=>se(e.value)},e.value))}),re.length===0?(0,w.jsx)(m,{className:s(X,Z),children:y.activity.length===0?`No recent MCP activity.`:`No activity matches the current filter.`}):re.map(e=>(0,w.jsxs)(m,{className:X,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`rounded-full border border-border bg-accent/20 px-2.5 py-1 text-[10px] font-medium text-muted-foreground`,children:Ie(e)}),(0,w.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:V(e.action)})]}),(0,w.jsx)(`p`,{className:`mt-2 text-[12px] text-muted-foreground`,children:ve(e.started_at)})]}),(0,w.jsx)(`span`,{className:s(Ue,be(e.result)),children:e.result})]}),(0,w.jsx)(`p`,{className:`mt-3 text-[13px] leading-6 text-muted-foreground`,children:e.summary}),(0,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-4 text-[12px] text-muted-foreground`,children:[e.actor_node_id?(0,w.jsxs)(`span`,{children:[`Node`,` `,e.actor_node_id.slice(0,8)]}):null,e.tab_id?(0,w.jsxs)(`span`,{children:[`Workflow `,e.tab_id.slice(0,8)]}):null,e.tool_name?(0,w.jsxs)(`span`,{children:[`Tool `,e.tool_name]}):null,e.target?(0,w.jsxs)(`span`,{children:[`Target `,e.target]}):null,(0,w.jsxs)(`span`,{children:[Math.round(e.duration_ms),` ms`]}),(0,w.jsx)(`span`,{children:ye(e.ended_at)})]})]},e.id))]}):null]})]}):(0,w.jsx)(m,{className:`flex h-full items-center justify-center text-center text-muted-foreground`,children:`Select an MCP server to inspect details.`})})]})})]})})]}),(0,w.jsx)(k,{draft:l.draft,onChange:l.setDraft,open:l.open,pending:l.pending,title:l.editingServerName?`Edit MCP Server`:`Advanced Add MCP Server`,onOpenChange:l.setOpen,onSubmit:l.saveServer})]})}export{Ge as McpPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{c as t,d as n,l as r}from"./graph-vendor-DRq_-6fV.js";import{Dt as i}from"./ui-vendor-Dg9NNnWX.js";import{a}from"./shared-CMxbpLeQ.js";import{a as o,i as s,n as c,r as l}from"./index-CL1ALZ3r.js";var u=e(n(),1),d=t(),f=Object.prototype.hasOwnProperty;function p(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&p(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(f.call(e,n)&&++r&&!f.call(t,n)||!(n in t)||!p(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var m=new WeakMap,h=()=>{},g=void 0,_=Object,v=e=>e===g,y=e=>typeof e==`function`,b=(e,t)=>({...e,...t}),ee=e=>y(e.then),x={},S={},C=`undefined`,w=typeof window!=C,T=typeof document!=C,E=w&&`Deno`in window,D=()=>w&&typeof window.requestAnimationFrame!=C,te=(e,t)=>{let n=m.get(e);return[()=>!v(t)&&e.get(t)||x,r=>{if(!v(t)){let i=e.get(t);t in S||(S[t]=i),n[5](t,b(i,r),i||x)}},n[6],()=>!v(t)&&t in S?S[t]:!v(t)&&e.get(t)||x]},O=!0,k=()=>O,[A,j]=w&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[h,h],M=()=>{let e=T&&document.visibilityState;return v(e)||e!==`hidden`},N=e=>(T&&document.addEventListener(`visibilitychange`,e),A(`focus`,e),()=>{T&&document.removeEventListener(`visibilitychange`,e),j(`focus`,e)}),P=e=>{let t=()=>{O=!0,e()},n=()=>{O=!1};return A(`online`,t),A(`offline`,n),()=>{j(`online`,t),j(`offline`,n)}},F={isOnline:k,isVisible:M},ne={initFocus:N,initReconnect:P},re=!u.useId,I=!w||E,ie=e=>D()?window.requestAnimationFrame(e):setTimeout(e,1),L=I?u.useEffect:u.useLayoutEffect,R=typeof navigator<`u`&&navigator.connection,z=!I&&R&&([`slow-2g`,`2g`].includes(R.effectiveType)||R.saveData),B=new WeakMap,V=e=>_.prototype.toString.call(e),H=(e,t)=>e===`[object ${t}]`,ae=0,U=e=>{let t=typeof e,n=V(e),r=H(n,`Date`),i=H(n,`RegExp`),a=H(n,`Object`),o,s;if(_(e)===e&&!r&&!i){if(o=B.get(e),o)return o;if(o=++ae+`~`,B.set(e,o),Array.isArray(e)){for(o=`@`,s=0;s<e.length;s++)o+=U(e[s])+`,`;B.set(e,o)}if(a){o=`#`;let t=_.keys(e).sort();for(;!v(s=t.pop());)v(e[s])||(o+=s+`:`+U(e[s])+`,`);B.set(e,o)}}else o=r?e.toJSON():t==`symbol`?e.toString():t==`string`?JSON.stringify(e):``+e;return o},oe=e=>{if(y(e))try{e=e()}catch{e=``}let t=e;return e=typeof e==`string`?e:(Array.isArray(e)?e.length:e)?U(e):``,[e,t]},se=0,ce=()=>++se;async function le(...e){let[t,n,r,i]=e,a=b({populateCache:!0,throwOnError:!0},typeof i==`boolean`?{revalidate:i}:i||{}),o=a.populateCache,s=a.rollbackOnError,c=a.optimisticData,l=e=>typeof s==`function`?s(e):s!==!1,u=a.throwOnError;if(y(n)){let e=n,r=[],i=t.keys();for(let n of i)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&r.push(n);return Promise.all(r.map(d))}return d(n);async function d(n){let[i]=oe(n);if(!i)return;let[s,d]=te(t,i),[f,p,h,_]=m.get(t),b=()=>{let e=f[i];return(y(a.revalidate)?a.revalidate(s().data,n):a.revalidate!==!1)&&(delete h[i],delete _[i],e&&e[0])?e[0](2).then(()=>s().data):s().data};if(e.length<3)return b();let x=r,S,C=!1,w=ce();p[i]=[w,0];let T=!v(c),E=s(),D=E.data,O=E._c,k=v(O)?D:O;if(T&&(c=y(c)?c(k,D):c,d({data:c,_c:k})),y(x))try{x=x(k)}catch(e){S=e,C=!0}if(x&&ee(x))if(x=await x.catch(e=>{S=e,C=!0}),w!==p[i][0]){if(C)throw S;return x}else C&&T&&l(S)&&(o=!0,d({data:k,_c:g}));if(o&&(C||(y(o)?d({data:o(x,k),error:g,_c:g}):d({data:x,error:g,_c:g}))),p[i][1]=ce(),Promise.resolve(b()).then(()=>{d({_c:g})}),C){if(u)throw S;return}return x}}var W=(e,t)=>{for(let n in e)e[n][0]&&e[n][0](t)},G=(e,t)=>{if(!m.has(e)){let n=b(ne,t),r=Object.create(null),i=le.bind(g,e),a=h,o=Object.create(null),s=(e,t)=>{let n=o[e]||[];return o[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},c=(t,n,r)=>{e.set(t,n);let i=o[t];if(i)for(let e of i)e(n,r)},l=()=>{if(!m.has(e)&&(m.set(e,[r,Object.create(null),Object.create(null),Object.create(null),i,c,s]),!I)){let t=n.initFocus(setTimeout.bind(g,W.bind(g,r,0))),i=n.initReconnect(setTimeout.bind(g,W.bind(g,r,1)));a=()=>{t&&t(),i&&i(),m.delete(e)}}};return l(),[e,i,l,a]}return[e,m.get(e)[4]]},K=(e,t,n,r,i)=>{let a=n.errorRetryCount,o=i.retryCount,s=~~((Math.random()+.5)*(1<<(o<8?o:8)))*n.errorRetryInterval;!v(a)&&o>a||setTimeout(r,s,i)},q=p,[J,Y]=G(new Map),X=b({onLoadingSlow:h,onSuccess:h,onError:h,onErrorRetry:K,onDiscarded:h,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:z?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:z?5e3:3e3,compare:q,isPaused:()=>!1,cache:J,mutate:Y,fallback:{}},F),ue=(e,t)=>{let n=b(e,t);if(t){let{use:r,fallback:i}=e,{use:a,fallback:o}=t;r&&a&&(n.use=r.concat(a)),i&&o&&(n.fallback=b(i,o))}return n},Z=(0,u.createContext)({}),de=e=>{let{value:t}=e,n=(0,u.useContext)(Z),r=y(t),i=(0,u.useMemo)(()=>r?t(n):t,[r,n,t]),a=(0,u.useMemo)(()=>r?i:ue(n,i),[r,n,i]),o=i&&i.provider,s=(0,u.useRef)(g);o&&!s.current&&(s.current=G(o(a.cache||J),i));let c=s.current;return c&&(a.cache=c[0],a.mutate=c[1]),L(()=>{if(c)return c[2]&&c[2](),c[3]},[]),(0,u.createElement)(Z.Provider,b(e,{value:a}))},fe=w&&window.__SWR_DEVTOOLS_USE__,pe=fe?window.__SWR_DEVTOOLS_USE__:[],Q=()=>{fe&&(window.__SWR_DEVTOOLS_REACT__=u.default)},me=e=>y(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],he=()=>{let e=(0,u.useContext)(Z);return(0,u.useMemo)(()=>b(X,e),[e])},ge=pe.concat(e=>(t,n,r)=>e(t,n&&((...e)=>{let[r]=oe(t),[,,,i]=m.get(J);if(r.startsWith(`$inf$`))return n(...e);let a=i[r];return v(a)?n(...e):(delete i[r],a)}),r)),_e=e=>function(...t){let n=he(),[r,i,a]=me(t),o=ue(n,a),s=e,{use:c}=o,l=(c||[]).concat(ge);for(let e=l.length;e--;)s=l[e](s);return s(r,i||o.fetcher||null,o)},ve=(e,t,n)=>{let r=t[e]||(t[e]=[]);return r.push(n),()=>{let e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}};Q();var ye=u.use||(e=>{switch(e.status){case`pending`:throw e;case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:throw e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t}),e}}),be={dedupe:!0},xe=Promise.resolve(g),Se=()=>h,Ce=(e,t,n)=>{let{cache:r,compare:i,suspense:a,fallbackData:o,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:l,refreshWhenHidden:f,refreshWhenOffline:p,keepPreviousData:h,strictServerPrefetchWarning:_}=n,[x,S,C,w]=m.get(r),[T,E]=oe(e),D=(0,u.useRef)(!1),O=(0,u.useRef)(!1),k=(0,u.useRef)(T),A=(0,u.useRef)(t),j=(0,u.useRef)(n),M=()=>j.current,N=()=>M().isVisible()&&M().isOnline(),[P,F,ne,R]=te(r,T),z=(0,u.useRef)({}).current,B=v(o)?v(n.fallback)?g:n.fallback[T]:o,V=(e,t)=>{for(let n in z){let r=n;if(r===`data`){if(!i(e[r],t[r])&&(!v(e[r])||!i(J,t[r])))return!1}else if(t[r]!==e[r])return!1}return!0},H=!D.current,ae=(0,u.useMemo)(()=>{let e=P(),n=R(),r=e=>{let n=b(e);return delete n._k,!(!T||!t||M().isPaused())&&(H&&!v(s)?s:v(v(B)?n.data:B)||c)?{isValidating:!0,isLoading:!0,...n}:n},i=r(e),a=e===n?i:r(n),o=i;return[()=>{let e=r(P());return V(e,o)?(o.data=e.data,o.isLoading=e.isLoading,o.isValidating=e.isValidating,o.error=e.error,o):(o=e,e)},()=>a]},[r,T]),U=(0,d.useSyncExternalStore)((0,u.useCallback)(e=>ne(T,(t,n)=>{V(n,t)||e()}),[r,T]),ae[0],ae[1]),se=x[T]&&x[T].length>0,W=U.data,G=v(W)?B&&ee(B)?ye(B):B:W,K=U.error,q=(0,u.useRef)(G),J=h?v(W)?v(q.current)?G:q.current:W:G,Y=T&&v(G),X=(0,u.useRef)(null);!I&&(0,d.useSyncExternalStore)(Se,()=>(X.current=!1,X),()=>(X.current=!0,X));let ue=X.current;_&&ue&&!a&&Y&&console.warn(`Missing pre-initiated data for serialized key "${T}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);let Z=!T||!t||M().isPaused()||se&&!v(K)?!1:H&&!v(s)?s:a?v(G)?!1:c:v(G)||c,de=H&&Z,fe=v(U.isValidating)?de:U.isValidating,pe=v(U.isLoading)?de:U.isLoading,Q=(0,u.useCallback)(async e=>{let t=A.current;if(!T||!t||O.current||M().isPaused())return!1;let r,a,o=!0,s=e||{},c=!C[T]||!s.dedupe,l=()=>re?!O.current&&T===k.current&&D.current:T===k.current,u={isValidating:!1,isLoading:!1},d=()=>{F(u)},f=()=>{let e=C[T];e&&e[1]===a&&delete C[T]},p={isValidating:!0};v(P().data)&&(p.isLoading=!0);try{if(c&&(F(p),n.loadingTimeout&&v(P().data)&&setTimeout(()=>{o&&l()&&M().onLoadingSlow(T,n)},n.loadingTimeout),C[T]=[t(E),ce()]),[r,a]=C[T],r=await r,c&&setTimeout(f,n.dedupingInterval),!C[T]||C[T][1]!==a)return c&&l()&&M().onDiscarded(T),!1;u.error=g;let e=S[T];if(!v(e)&&(a<=e[0]||a<=e[1]||e[1]===0))return d(),c&&l()&&M().onDiscarded(T),!1;let s=P().data;u.data=i(s,r)?s:r,c&&l()&&M().onSuccess(r,T,n)}catch(e){f();let t=M(),{shouldRetryOnError:n}=t;t.isPaused()||(u.error=e,c&&l()&&(t.onError(e,T,t),(n===!0||y(n)&&n(e))&&(!M().revalidateOnFocus||!M().revalidateOnReconnect||N())&&t.onErrorRetry(e,T,t,e=>{let t=x[T];t&&t[0]&&t[0](3,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0})))}return o=!1,d(),!0},[T,r]),me=(0,u.useCallback)((...e)=>le(r,k.current,...e),[]);if(L(()=>{A.current=t,j.current=n,v(W)||(q.current=W)}),L(()=>{if(!T)return;let e=Q.bind(g,be),t=0;M().revalidateOnFocus&&(t=Date.now()+M().focusThrottleInterval);let n=ve(T,x,(n,r={})=>{if(n==0){let n=Date.now();M().revalidateOnFocus&&n>t&&N()&&(t=n+M().focusThrottleInterval,e())}else if(n==1)M().revalidateOnReconnect&&N()&&e();else if(n==2)return Q();else if(n==3)return Q(r)});return O.current=!1,k.current=T,D.current=!0,F({_k:E}),Z&&(C[T]||(v(G)||I?e():ie(e))),()=>{O.current=!0,n()}},[T]),L(()=>{let e;function t(){let t=y(l)?l(P().data):l;t&&e!==-1&&(e=setTimeout(n,t))}function n(){!P().error&&(f||M().isVisible())&&(p||M().isOnline())?Q(be).then(t):t()}return t(),()=>{e&&=(clearTimeout(e),-1)}},[l,f,p,T]),(0,u.useDebugValue)(J),a){if(!re&&I&&Y)throw Error(`Fallback data is required when using Suspense in SSR.`);Y&&(A.current=t,j.current=n,O.current=!1);let e=w[T];if(ye(!v(e)&&Y?me(e):xe),!v(K)&&Y)throw K;let r=Y?Q(be):xe;!v(J)&&Y&&(r.status=`fulfilled`,r.value=!0),ye(r)}return{mutate:me,get data(){return z.data=!0,J},get error(){return z.error=!0,K},get isValidating(){return z.isValidating=!0,fe},get isLoading(){return z.isLoading=!0,pe}}};_.defineProperty(de,`defaultValue`,{value:X});var we=_e(Ce),$=r();function Te({children:e,className:t}){return(0,$.jsx)(`div`,{className:a(`flex h-full flex-col min-h-0 overflow-hidden`,t),children:e})}function Ee({children:e,className:t}){return(0,$.jsx)(`section`,{className:a(`rounded-xl bg-card/[0.18] p-5 ring-1 ring-white/[0.04]`,t),children:e})}function De({actions:e,className:t,hint:n,title:r}){return(0,$.jsx)(`div`,{className:a(`border-b border-border/70 pb-4`,t),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`h1`,{className:`text-[28px] font-medium tracking-[-0.04em] text-foreground`,children:r}),n?(0,$.jsx)(s,{delayDuration:150,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(o,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-full border border-border/70 bg-card/20 text-muted-foreground transition-colors hover:bg-accent/35 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,"aria-label":`${r} details`,children:(0,$.jsx)(i,{className:`size-3.5`})})}),(0,$.jsx)(l,{side:`right`,className:`max-w-xs px-3 py-2`,children:n})]})}):null]}),e?(0,$.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:e}):null]})})}function Oe({title:e}){return(0,$.jsx)(`div`,{className:`mb-2.5 px-1`,children:(0,$.jsx)(`h2`,{className:`text-[13px] font-semibold text-foreground/85`,children:e})})}function ke({label:e,children:t,valueClassName:n}){return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border/50 px-4 py-4 last:border-b-0 md:flex-row md:items-start md:justify-between md:gap-4 transition-colors hover:bg-muted/30`,children:[(0,$.jsx)(`div`,{className:`min-w-0 shrink-0 md:w-[35%] pt-0.5`,children:(0,$.jsx)(`label`,{className:`block text-[13px] font-medium text-foreground`,children:e})}),(0,$.jsx)(`div`,{className:a(`w-full min-w-0 flex-1 md:w-[65%] flex md:justify-end`,n),children:(0,$.jsx)(`div`,{className:`w-full md:max-w-md space-y-3`,children:t})})]})}export{Ee as a,ke as i,De as n,we as o,Oe as r,Te as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{R as r,nt as i}from"./ui-vendor-Dg9NNnWX.js";import{t as a}from"./shared-CMxbpLeQ.js";import{B as o,J as s,o as c}from"./index-CL1ALZ3r.js";import{n as l,o as u,t as d}from"./PageScaffold-D4jO9ooX.js";async function f(){return a(`/api/prompts`,{errorMessage:`Failed to fetch prompts`})}async function p(e){return a(`/api/prompts`,{method:`PUT`,body:e,errorMessage:`Failed to save prompts`})}var m=e(t(),1),h=n(),g=`rounded-full border border-border bg-accent/30 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,_=`relative flex min-h-0 flex-1 rounded-xl border border-border bg-card/30 p-1`,v=`min-h-0 w-full flex-1 resize-none select-text rounded-md bg-transparent p-3 font-mono text-[13px] leading-relaxed text-foreground placeholder:text-muted-foreground transition-colors focus:bg-background/35 focus:outline-none scrollbar-none`;function y(){let{data:e,isLoading:t,mutate:n}=u(`promptSettings`,f),[a,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(!1);(0,m.useEffect)(()=>{e&&(y(e.custom_prompt),x(e.custom_post_prompt))},[e]);let w=async()=>{C(!0);try{n(await p({custom_prompt:a,custom_post_prompt:b}),!1),r.success(`Prompts saved`)}catch{r.error(`Failed to save prompts`)}finally{C(!1)}};return t?(0,h.jsx)(c,{label:`Loading prompts...`,textClassName:`text-[13px]`}):(0,h.jsx)(d,{children:(0,h.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-[800px] flex-col px-4 pb-10 pt-6`,children:[(0,h.jsx)(l,{title:`Prompts`,hint:`Custom Prompt is appended to the global system prompt layer. Custom Post Prompt is appended after the built-in runtime post prompt.`,actions:(0,h.jsxs)(s,{type:`button`,onClick:()=>void w(),disabled:S,size:`sm`,className:`text-[13px]`,children:[(0,h.jsx)(i,{className:`size-4`}),S?`Saving...`:`Save Changes`]})}),(0,h.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-8 pt-6`,children:[(0,h.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between px-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:`Custom Prompt`}),(0,h.jsxs)(`span`,{className:g,children:[a.length,` chars`]})]}),(0,h.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`Appended to every node's system prompt`})]}),(0,h.jsx)(`div`,{className:_,children:(0,h.jsx)(o,{"aria-label":`Custom Prompt`,value:a,onChange:e=>y(e.target.value),placeholder:`Add a custom prompt appended to every agent's system prompt...`,className:v,mono:!0})})]}),(0,h.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between px-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:`Custom Post Prompt`}),(0,h.jsxs)(`span`,{className:g,children:[b.length,` chars`]})]}),(0,h.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`Added after the built-in runtime post prompt`})]}),(0,h.jsx)(`div`,{className:_,children:(0,h.jsx)(o,{"aria-label":`Custom Post Prompt`,value:b,onChange:e=>x(e.target.value),placeholder:`Add custom runtime instructions appended after the built-in post prompt...`,className:v,mono:!0})})]})]})]})})}export{y as PromptsPage};
@@ -0,0 +1,3 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{$ as r,R as i,Xt as a,dt as o,it as s,q as c,rn as l,st as u,ut as d}from"./ui-vendor-Dg9NNnWX.js";import{a as f,n as p,t as m}from"./shared-CMxbpLeQ.js";import{B as h,G as g,J as _,L as v,R as y,V as b,c as x,d as ee,u as te}from"./index-CL1ALZ3r.js";import{i as S,n as C,o as ne,r as w,t as re}from"./PageScaffold-D4jO9ooX.js";import{a as T,i as E,n as D,r as O,t as k}from"./select-DL_LPeDj.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as ie,t as ae}from"./alert-dialog-kFYVQ7oX.js";import{a as I,i as L,o as R,r as z,s as B,t as V}from"./dialog-BeGSweF6.js";import{i as oe,n as H,r as se,t as U}from"./triState-DEr3NkXV.js";async function ce(){return m(`/api/providers`,{errorMessage:`Failed to fetch providers`,fallback:[],map:e=>e?.providers??[]})}async function le(e){return m(`/api/providers`,{method:`POST`,body:e,errorMessage:`Failed to create provider`})}async function ue(e,t){return m(`/api/providers/${e}`,{method:`PUT`,body:t,errorMessage:`Failed to update provider`})}async function de(e){await p(`/api/providers/${e}`,{method:`DELETE`,errorMessage:`Failed to delete provider`})}async function fe(e){return m(`/api/providers/models`,{method:`POST`,body:e,errorMessage:`Failed to fetch provider models`,fallback:[],map:e=>e?.models??[]})}async function W(e){return m(`/api/providers/models/test`,{method:`POST`,body:e,errorMessage:`Failed to test provider model`})}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pe(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function me(e){if(!e.trim())return{headers:{},error:null};let t;try{t=JSON.parse(e)}catch{return{headers:{},error:`Headers must be valid JSON`}}if(!G(t))return{headers:{},error:`Headers must be a JSON object`};let n={};for(let[e,r]of Object.entries(t)){if(typeof r!=`string`)return{headers:{},error:`Headers values must all be strings`};n[e]=r}return{headers:n,error:null}}function K(e){return e?{name:e.name,type:e.type,base_url:e.base_url,api_key:e.api_key,headers_text:pe(e.headers),retry_429_delay_seconds:e.retry_429_delay_seconds,models:e.models.map(e=>({...e}))}:{name:``,type:`openai_compatible`,base_url:``,api_key:``,headers_text:``,retry_429_delay_seconds:0,models:[]}}function q(e){return{model:e?.model??``,context_window_tokens:e?.context_window_tokens===null||e?.context_window_tokens===void 0?``:String(e.context_window_tokens),input_image:H(e?.input_image??null),output_image:H(e?.output_image??null),source:e?.source??`manual`}}function J(e){return JSON.stringify({name:e.name,type:e.type,base_url:e.base_url,api_key:e.api_key,headers_text:e.headers_text,retry_429_delay_seconds:e.retry_429_delay_seconds,models:e.models})}function Y(e,t){return{name:e.name,type:e.type,base_url:e.base_url,api_key:e.api_key,headers:t,retry_429_delay_seconds:e.retry_429_delay_seconds,models:e.models}}function X(e,t,n){return{provider_id:n,name:e.name,type:e.type,base_url:e.base_url,api_key:e.api_key,headers:t,retry_429_delay_seconds:e.retry_429_delay_seconds}}function he(e,t){let n=new Map(e.map(e=>[e.model,e])),r=new Map(t.map(e=>[e.model,e])),i=[];for(let t of e){let e=r.get(t.model);if(!e){i.push(t);continue}if(t.source===`manual`){i.push({...t,context_window_tokens:t.context_window_tokens??e.context_window_tokens,input_image:t.input_image??e.input_image,output_image:t.output_image??e.output_image}),r.delete(t.model);continue}i.push(e),r.delete(t.model)}for(let e of t)n.has(e.model)||i.push(e);return i}function ge(e){let t=[];return e.context_window_tokens!==null&&t.push(`${e.context_window_tokens.toLocaleString()} tokens`),e.input_image!==null&&t.push(`input_image=${e.input_image?`true`:`false`}`),e.output_image!==null&&t.push(`output_image=${e.output_image?`true`:`false`}`),t.length>0?t.join(` · `):`No capability metadata`}function Z(e){let t=new Set;for(let n of e){let e=n.model.trim();if(t.has(e))return e;t.add(e)}return null}function _e(e){return e.model.trim()?e.context_window_tokens&&!/^\d+$/.test(e.context_window_tokens)?`Context Window must be a positive integer`:null:`Model ID is required`}function ve(e){return{model:e.model.trim(),source:e.source,context_window_tokens:e.context_window_tokens?Number.parseInt(e.context_window_tokens,10):null,input_image:U(e.input_image),output_image:U(e.output_image)}}var Q=n();function ye({draft:e,onClose:t,onDraftChange:n,onSave:r,state:i}){return(0,Q.jsx)(V,{open:i!==null,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(z,{children:[(0,Q.jsxs)(R,{children:[(0,Q.jsx)(B,{children:i?.mode===`edit`?`Edit Model`:`Add Model`}),(0,Q.jsx)(L,{className:`sr-only`,children:i?.mode===`edit`?`Edit Model`:`Add Model`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Model ID`}),(0,Q.jsx)(y,{"aria-label":`Model ID`,value:e.model,onChange:t=>n({...e,model:t.target.value}),placeholder:`gpt-5`,mono:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Source`}),(0,Q.jsx)(`div`,{className:`rounded-md border border-border bg-card/30 px-3 py-2 text-[13px] text-foreground/80`,children:e.source===`manual`?`Manual`:`Discovered`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Context Window`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(y,{"aria-label":`Context Window`,inputMode:`numeric`,pattern:`[0-9]*`,value:e.context_window_tokens,onChange:t=>{let r=t.target.value.trim();/^\d*$/.test(r)&&n({...e,context_window_tokens:r})},placeholder:`Optional`,mono:!0}),(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`tokens`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Input Image`}),(0,Q.jsxs)(k,{value:e.input_image,onValueChange:t=>n({...e,input_image:t}),children:[(0,Q.jsx)(E,{className:g,children:(0,Q.jsx)(T,{})}),(0,Q.jsxs)(D,{className:`rounded-xl border-border bg-popover`,children:[(0,Q.jsx)(O,{value:`auto`,children:`Auto`}),(0,Q.jsx)(O,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(O,{value:`disabled`,children:`Disabled`})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Output Image`}),(0,Q.jsxs)(k,{value:e.output_image,onValueChange:t=>n({...e,output_image:t}),children:[(0,Q.jsx)(E,{className:g,children:(0,Q.jsx)(T,{})}),(0,Q.jsxs)(D,{className:`rounded-xl border-border bg-popover`,children:[(0,Q.jsx)(O,{value:`auto`,children:`Auto`}),(0,Q.jsx)(O,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(O,{value:`disabled`,children:`Disabled`})]})]})]})]})]}),(0,Q.jsxs)(I,{className:`px-5 pb-5`,children:[(0,Q.jsx)(_,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,Q.jsx)(_,{onClick:r,children:i?.mode===`edit`?`Save Model`:`Add Model`})]})]})})}function be({isDragging:e,loading:t,onCreate:n,onDelete:i,onRefresh:a,onResizeStart:o,onSelect:d,panelWidth:p,providers:m,selectedId:h}){return(0,Q.jsxs)(`div`,{style:{width:`${p}px`},className:`relative flex shrink-0 flex-col border-r border-border bg-card/20 pt-8 pl-8`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80`,children:`Providers`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(v,{onClick:a,disabled:t,className:`size-7`,children:(0,Q.jsx)(s,{className:f(`size-3.5`,t&&`animate-spin`)})}),(0,Q.jsx)(v,{onClick:n,className:`size-7`,children:(0,Q.jsx)(u,{className:`size-3.5`})})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4`,children:t?(0,Q.jsx)(`div`,{className:`space-y-1`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(`div`,{className:`h-10 w-full animate-pulse rounded-lg bg-accent/20`},t))}):m.length===0?(0,Q.jsxs)(l.div,{initial:{opacity:0},animate:{opacity:1},className:`py-10 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`No providers`}),(0,Q.jsxs)(_,{type:`button`,size:`sm`,onClick:n,className:`mt-4`,children:[(0,Q.jsx)(u,{className:`size-3`}),`Add your first provider`]})]}):(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:m.map((e,t)=>(0,Q.jsxs)(l.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},transition:{delay:t*.03},role:`button`,tabIndex:0,onClick:()=>d(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d(e))},className:f(`group relative flex w-full items-center justify-between rounded-lg px-3 py-2.5 transition-all`,h===e.id?`bg-accent/55 text-foreground`:`text-muted-foreground hover:bg-accent/30 hover:text-foreground`),children:[(0,Q.jsx)(`div`,{className:f(`absolute inset-y-1 left-0 w-px rounded-full bg-ring/60 transition-opacity`,h===e.id?`opacity-100`:`opacity-0`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 pl-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:se(e.type)})]}),(0,Q.jsx)(v,{onClick:t=>{t.stopPropagation(),i(e)},className:`size-6 shrink-0 border-transparent bg-transparent opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,children:(0,Q.jsx)(c,{className:`size-3`})})]},e.id))})}),(0,Q.jsx)(x,{position:`right`,isDragging:e,onMouseDown:o})]})}var $=e(t(),1),xe={openai_compatible:`/v1`,openai_responses:`/v1`,anthropic:`/v1`,gemini:`/v1beta`},Se={openai_compatible:`/chat/completions`,openai_responses:`/responses`,anthropic:`/messages`,gemini:`/models/{model}:streamGenerateContent`},Ce=Array.from(new Set(Object.values(xe))).sort((e,t)=>t.length-e.length);function we(e){return e.trim().toLowerCase()}function Te(e){return e.trim().replace(/\/+$/,``)}function Ee(e,t){let n=we(e),r=xe[n],i=Te(t);if(!r||!i)return{resolvedBaseUrl:null,error:null};let a=i.toLowerCase();for(let e of Ce)if(a.endsWith(e))return e===r?{resolvedBaseUrl:i,error:null}:{resolvedBaseUrl:null,error:`Base URL suffix '${e}' does not match type '${n}' (expected '${r}')`};return{resolvedBaseUrl:`${i}${r}`,error:null}}function De(e,t){let n=we(e),r=Se[n],{resolvedBaseUrl:i,error:a}=Ee(n,t);return a?{previewUrl:null,error:a}:!i||!r?{previewUrl:null,error:null}:{previewUrl:`${i}${r}`,error:null}}function Oe(){let[e,t]=(0,$.useState)(null),[n,r]=(0,$.useState)(!1),[a,o]=(0,$.useState)(K()),[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(null),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(null),[_,v]=(0,$.useState)(q()),[y,b]=(0,$.useState)({}),{data:x=[],isLoading:S,mutate:C}=ne(`providers`,ce,{onSuccess:n=>{!e||n.find(t=>t.id===e)||(t(null),r(!1),o(K()),b({}),f(!1))}}),[w,re]=ee(`providers-panel-width`,300,200,500),{isDragging:T,startDrag:E}=te(w,re,`right`),D=(0,$.useMemo)(()=>x.find(t=>t.id===e),[x,e]),O=(0,$.useMemo)(()=>De(a.type,a.base_url),[a.base_url,a.type]),k=(0,$.useMemo)(()=>me(a.headers_text),[a.headers_text]),A=(0,$.useMemo)(()=>{let e=n?K():K(D);return J(a)!==J(e)},[a,n,D]),j=(0,$.useCallback)(async()=>{await C()},[C]),M=(0,$.useCallback)(e=>{t(e.id),r(!1),o(K(e)),b({}),g(null),f(!1)},[]),N=(0,$.useCallback)(()=>{r(!0),t(null),o(K()),b({}),g(null),f(!1)},[]),P=(0,$.useCallback)(()=>{n?(r(!1),o(K())):o(K(D)),b({}),g(null),f(!1)},[n,D]),F=(0,$.useCallback)(async()=>{if(!a.name.trim()){i.error(`Provider name is required`);return}if(!a.base_url.trim()){i.error(`Provider base URL is required`);return}if(O.error){i.error(O.error);return}if(k.error){i.error(k.error);return}let s=Z(a.models);if(s){i.error(`Model ID '${s}' is duplicated`);return}let l=Y(a,k.headers);c(!0);try{if(n){let e=await le(l);C([...x,e],!1),r(!1),t(e.id),o(K(e)),i.success(`Provider created`)}else if(e){let t=await ue(e,l);C(x.map(n=>n.id===e?t:n),!1),o(K(t)),i.success(`Provider updated`)}b({}),f(!1)}catch{i.error(n?`Failed to create provider`:`Failed to update provider`)}finally{c(!1)}},[a,O.error,n,C,k.error,k.headers,x,e]),ie=(0,$.useCallback)(async()=>{if(!l)return;let n=l.id;u(null),f(!1);try{await de(n),C(x.filter(e=>e.id!==n),!1),e===n&&(t(null),o(K())),b({}),i.success(`Provider deleted`)}catch{i.error(`Failed to delete provider`)}},[C,l,x,e]),ae=(0,$.useCallback)(()=>{g({mode:`create`,originalModel:null}),v(q())},[]),I=(0,$.useCallback)(e=>{g({mode:`edit`,originalModel:e.model}),v(q(e))},[]),L=(0,$.useCallback)(()=>{g(null),v(q())},[]),R=(0,$.useCallback)(()=>{let e=_e(_);if(e){i.error(e);return}let t=_.model.trim();if(a.models.some(e=>e.model===t&&e.model!==h?.originalModel)){i.error(`Model ID '${t}' already exists in this provider`);return}let n=ve(_);o(e=>h?.mode===`edit`&&h.originalModel?{...e,models:e.models.map(e=>e.model===h.originalModel?n:e)}:{...e,models:[...e.models,n]}),b(e=>{let n={...e};return h?.originalModel&&h.originalModel!==t&&delete n[h.originalModel],n}),L()},[L,a.models,_,h]),z=(0,$.useCallback)(e=>{o(t=>({...t,models:t.models.filter(t=>t.model!==e)})),b(t=>{let n={...t};return delete n[e],n})},[]),B=(0,$.useCallback)(()=>{a.models.length!==0&&f(!0)},[a.models.length]);return{cancelClearModels:(0,$.useCallback)(()=>{f(!1)},[]),clearModelsConfirmOpen:d,draft:a,endpointPreview:O,fetchingModels:p,handleCancel:P,handleClearModels:(0,$.useCallback)(()=>{o(e=>({...e,models:[]})),b({}),f(!1)},[]),handleCreateNew:N,handleDelete:ie,handleDeleteModel:z,handleFetchModels:(0,$.useCallback)(async()=>{if(!a.type.trim()||!a.base_url.trim()){i.error(`Provider type and base URL are required before fetching models`);return}if(O.error){i.error(O.error);return}if(k.error){i.error(k.error);return}m(!0);try{let t=await fe(X(a,k.headers,e??void 0));o(e=>({...e,models:he(e.models,t)})),i.success(`Provider models fetched`)}catch(e){i.error(e instanceof Error?e.message:`Failed to fetch provider models`)}finally{m(!1)}},[a,O.error,k.error,k.headers,e]),handleSave:F,handleSaveModel:R,handleSelect:M,handleTestModel:(0,$.useCallback)(async t=>{if(O.error){i.error(O.error);return}if(k.error){i.error(k.error);return}b(e=>({...e,[t.model]:{state:`running`}}));try{let n=await W({...X(a,k.headers,e??void 0),model:t.model});b(e=>({...e,[t.model]:n.ok?{state:`success`,duration_ms:n.duration_ms??0}:{state:`error`,error_summary:n.error_summary??`Provider test failed`}}))}catch(e){b(n=>({...n,[t.model]:{state:`error`,error_summary:e instanceof Error?e.message:`Provider test failed`}}))}},[a,O.error,k.error,k.headers,e]),hasChanges:A,isCreating:n,isDragging:T,loading:S,modelEditorDraft:_,modelEditorState:h,modelTestStates:y,openCreateModelDialog:ae,openEditModelDialog:I,panelWidth:w,parsedHeaders:k,providerToDelete:l,providers:x,refreshProviders:j,requestClearModels:B,saving:s,selectedId:e,selectedProvider:D,setDraft:o,setModelEditorDraft:v,setProviderToDelete:u,startDrag:E,closeModelDialog:L}}function ke(){let{cancelClearModels:e,clearModelsConfirmOpen:t,draft:n,endpointPreview:i,fetchingModels:p,handleCancel:m,handleClearModels:v,handleCreateNew:x,handleDelete:ee,handleDeleteModel:te,handleFetchModels:ne,handleSave:I,handleSaveModel:L,handleSelect:R,handleTestModel:z,hasChanges:B,isCreating:V,isDragging:H,loading:se,modelEditorDraft:U,modelEditorState:ce,modelTestStates:le,openCreateModelDialog:ue,openEditModelDialog:de,panelWidth:fe,parsedHeaders:W,providerToDelete:G,providers:pe,refreshProviders:me,requestClearModels:K,saving:q,selectedId:J,selectedProvider:Y,setDraft:X,setModelEditorDraft:he,setProviderToDelete:Z,startDrag:_e,closeModelDialog:ve}=Oe();return(0,Q.jsx)(re,{className:`overflow-hidden px-4 pt-6 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsx)(C,{title:`Providers`}),(0,Q.jsxs)(`div`,{className:`mt-6 flex min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-card/[0.14]`,children:[(0,Q.jsx)(be,{isDragging:H,loading:se,onCreate:x,onDelete:Z,onRefresh:()=>{me()},onResizeStart:_e,onSelect:R,panelWidth:fe,providers:pe,selectedId:J}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 overflow-y-auto bg-transparent`,children:V||Y?(0,Q.jsxs)(`div`,{className:`flex min-h-full flex-col px-8 py-8 md:px-12 md:py-10`,children:[(0,Q.jsxs)(`div`,{className:`mb-8 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-xl font-medium text-foreground`,children:V?`New Provider`:Y?.name}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:V?`Configure a new provider and its model catalog`:`ID: ${Y?.id}`})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:B?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:m,disabled:q,children:`Cancel`}),(0,Q.jsxs)(_,{type:`button`,size:`sm`,onClick:()=>void I(),disabled:q,children:[(0,Q.jsx)(a,{className:`size-3.5`}),q?`Saving...`:`Save`]})]}):null})]}),(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-[720px] flex-1`,children:[(0,Q.jsx)(w,{title:`Identity`}),(0,Q.jsxs)(`div`,{className:`mb-10 border border-dashed border-border rounded-lg bg-card/30`,children:[(0,Q.jsx)(S,{label:`Name`,children:(0,Q.jsx)(y,{value:n.name,onChange:e=>X({...n,name:e.target.value}),placeholder:`e.g., OpenAI Production`})}),(0,Q.jsx)(S,{label:`Type`,children:(0,Q.jsxs)(k,{value:n.type,onValueChange:e=>X({...n,type:e}),children:[(0,Q.jsx)(E,{className:g,children:(0,Q.jsx)(T,{})}),(0,Q.jsx)(D,{className:`rounded-xl border-border bg-popover`,children:oe.map(e=>(0,Q.jsx)(O,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})})]}),(0,Q.jsxs)(`div`,{className:`border-t border-border pt-8`,children:[(0,Q.jsx)(w,{title:`Endpoint & Auth`}),(0,Q.jsxs)(`div`,{className:`border border-dashed border-border rounded-lg bg-card/30`,children:[(0,Q.jsx)(S,{label:`Base URL`,children:(0,Q.jsx)(y,{value:n.base_url,onChange:e=>X({...n,base_url:e.target.value}),placeholder:`https://api.openai.com/v1`})}),(0,Q.jsx)(S,{label:`Request Preview`,children:(0,Q.jsx)(`div`,{className:f(`w-full select-text rounded-md border px-3 py-2 text-[12px]`,i.error?`border-destructive/20 bg-destructive/8 text-destructive`:`border-border bg-card/30 text-foreground/80`),children:i.error?i.error:i.previewUrl?(0,Q.jsx)(`code`,{className:`select-text font-mono`,children:i.previewUrl}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Enter a base URL to preview`})})}),(0,Q.jsx)(S,{label:`API Key`,children:(0,Q.jsx)(b,{value:n.api_key,onChange:e=>X({...n,api_key:e.target.value}),placeholder:`sk-...`,mono:!0,showLabel:`Show API key`,hideLabel:`Hide API key`})}),(0,Q.jsx)(S,{label:`Headers`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(h,{value:n.headers_text,onChange:e=>X({...n,headers_text:e.target.value}),placeholder:`{
2
+ "Authorization": "Bearer ..."
3
+ }`,spellCheck:!1,className:f(`min-h-[140px]`,W.error?`border-destructive/30 text-destructive focus-visible:border-destructive/50 focus-visible:ring-destructive/20`:``),mono:!0}),W.error?(0,Q.jsx)(`p`,{className:`text-[11px] text-destructive`,children:W.error}):null]})}),(0,Q.jsx)(S,{label:`429 Retry Delay`,children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(y,{"aria-label":`429 Retry Delay`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(n.retry_429_delay_seconds),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let r=Number.parseInt(t,10);!Number.isSafeInteger(r)||r<0||X({...n,retry_429_delay_seconds:r})},mono:!0}),(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`s`})]})})})]})]}),(0,Q.jsxs)(`div`,{className:`border-t border-border pt-8`,children:[(0,Q.jsx)(w,{title:`Models`}),(0,Q.jsxs)(`div`,{className:`space-y-4 rounded-xl border border-border bg-card/30 p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/80`,children:[n.models.length,` model`,n.models.length===1?``:`s`]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Fetch discovered models or maintain manual entries in this draft before saving.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,disabled:p,onClick:()=>void ne(),children:[(0,Q.jsx)(s,{className:f(`size-3.5`,p&&`animate-spin`)}),`Fetch Models`]}),(0,Q.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:ue,children:[(0,Q.jsx)(u,{className:`size-3.5`}),`Add Model`]}),(0,Q.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,disabled:n.models.length===0||p,onClick:K,children:[(0,Q.jsx)(c,{className:`size-3.5`}),`Clear Models`]})]})]}),n.models.length===0?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/35 px-4 py-5 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/80`,children:`No models in this provider draft`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:`Fetch models from the current draft connection, or add a manual entry.`})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.models.map(e=>{let t=le[e.model];return(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/35 px-4 py-3`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate select-text font-mono text-[13px] text-foreground/85`,children:e.model}),(0,Q.jsx)(`span`,{className:f(`rounded-full border px-2 py-0.5 text-[10px] font-medium`,e.source===`manual`?`border-graph-status-idle/20 bg-graph-status-idle/[0.12] text-graph-status-idle`:`border-graph-status-running/20 bg-graph-status-running/[0.12] text-graph-status-running`),children:e.source===`manual`?`Manual`:`Discovered`})]}),(0,Q.jsx)(`p`,{className:`mt-1 select-text text-[11px] leading-relaxed text-muted-foreground`,children:ge(e)}),t?.state===`running`?(0,Q.jsx)(`p`,{className:`mt-2 select-text text-[11px] text-muted-foreground`,children:`Testing this model against the current draft provider...`}):null,t?.state===`success`?(0,Q.jsxs)(`p`,{className:`mt-2 select-text text-[11px] text-graph-status-running`,children:[`Test succeeded in`,` `,t.duration_ms,`ms`]}):null,t?.state===`error`?(0,Q.jsx)(`p`,{className:`mt-2 select-text text-[11px] text-destructive`,children:t.error_summary}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,disabled:t?.state===`running`,onClick:()=>void z(e),children:[(0,Q.jsx)(d,{className:`size-3.5`}),`Test`]}),(0,Q.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>de(e),children:[(0,Q.jsx)(o,{className:`size-3.5`}),`Edit`]}),(0,Q.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>te(e.model),children:[(0,Q.jsx)(c,{className:`size-3.5`}),`Delete`]})]})]})},e.model)})})]})]}),!V&&Y?(0,Q.jsx)(`div`,{className:`border-t border-border pt-8`,children:(0,Q.jsx)(`div`,{className:`border border-dashed border-border rounded-lg bg-card/30`,children:(0,Q.jsx)(S,{label:`Provider ID`,children:(0,Q.jsx)(`div`,{className:`select-text rounded-md border border-border bg-card/30 px-3 py-2 font-mono text-[12px] text-foreground/80`,children:Y.id})})})}):null]})]}):(0,Q.jsxs)(l.div,{initial:{opacity:0},animate:{opacity:1},className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl border border-border bg-accent/20 shadow-sm`,children:(0,Q.jsx)(r,{className:`size-5 text-muted-foreground`})}),(0,Q.jsx)(`h3`,{className:`mt-5 text-[15px] font-medium text-foreground`,children:`No Provider Selected`}),(0,Q.jsx)(`p`,{className:`mt-1.5 max-w-sm text-[13px] text-muted-foreground`,children:`Select a provider from the sidebar to edit its connection fields, model catalog, and model tests.`})]})})]}),(0,Q.jsx)(ye,{draft:U,onClose:ve,onDraftChange:he,onSave:L,state:ce}),(0,Q.jsx)(ae,{open:t,onOpenChange:t=>{t||e()},children:(0,Q.jsxs)(M,{children:[(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(j,{children:`Clear all models?`}),(0,Q.jsx)(A,{children:`This removes every model from this provider, including discovered and manual entries. Save the provider to keep the cleared list.`})]}),(0,Q.jsxs)(P,{children:[(0,Q.jsx)(F,{asChild:!0,children:(0,Q.jsx)(_,{type:`button`,variant:`ghost`,children:`Cancel`})}),(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(_,{type:`button`,variant:`destructive`,onClick:v,children:`Clear Models`})})]})]})}),(0,Q.jsx)(ae,{open:G!==null,onOpenChange:e=>{e||Z(null)},children:(0,Q.jsxs)(M,{children:[(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(j,{children:`Delete provider?`}),(0,Q.jsx)(A,{children:G?`This will permanently remove ${G.name}.`:`This will permanently remove the selected provider.`})]}),(0,Q.jsxs)(P,{children:[(0,Q.jsx)(F,{asChild:!0,children:(0,Q.jsx)(_,{variant:`ghost`,children:`Cancel`})}),(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(_,{variant:`destructive`,onClick:()=>void ee(),children:`Delete`})})]})]})})]})})}export{ke as ProvidersPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{H as r,R as i,ft as a,it as o,q as s,rn as c,st as l,z as u,zt as d}from"./ui-vendor-Dg9NNnWX.js";import{a as f}from"./shared-CMxbpLeQ.js";import{a as p,i as ee,n as m,t as h}from"./roles-2OLDeTc5.js";import{B as g,G as _,J as v,L as y,R as b,W as x,o as S}from"./index-CL1ALZ3r.js";import{t as C}from"./badge-74-3jsCg.js";import{i as w,n as te,o as T,r as E,t as D}from"./PageScaffold-D4jO9ooX.js";import{a as O,i as k,n as A,r as j,t as M}from"./select-DL_LPeDj.js";import{a as N,c as P,i as F,n as I,o as L,r as R,s as z,t as B}from"./alert-dialog-kFYVQ7oX.js";import{i as V,n as H,r as U,t as W}from"./modelParams-CaHd0903.js";var G=e(t(),1),K=new Set([`idle`,`sleep`,`todo`,`contacts`]);function q(){return{name:``,description:``,system_prompt:``,model:null,model_params:null,included_tools:[],excluded_tools:[]}}function J(e){return e?{name:e.name,description:e.description,system_prompt:e.system_prompt,model:e.model?{provider_id:e.model.provider_id,model:e.model.model}:null,model_params:e.model_params?W(e.model_params):null,included_tools:[...e.included_tools],excluded_tools:[...e.excluded_tools]}:q()}function ne(e){return e.filter(e=>!K.has(e.name))}function re(e){return Object.fromEntries(e.map(e=>[e.id,e]))}function Y(e,t){return e.included_tools.includes(t)?`included`:e.excluded_tools.includes(t)?`excluded`:`allowed`}function X(e,t){let n=Y(e,t);return n===`allowed`?{...e,included_tools:[...e.included_tools,t],excluded_tools:e.excluded_tools.filter(e=>e!==t)}:n===`included`?{...e,included_tools:e.included_tools.filter(e=>e!==t),excluded_tools:[...e.excluded_tools,t]}:{...e,included_tools:e.included_tools.filter(e=>e!==t),excluded_tools:e.excluded_tools.filter(e=>e!==t)}}function Z(e){return e.length===0?null:{provider_id:e[0]?.id??``,model:``}}function Q(e){let{activeRoleName:t,draft:n,roles:r}=e,i=n.name.trim();if(!i)return`Role name is required`;if(!n.description.trim())return`Role description is required`;if(!n.system_prompt.trim())return`System prompt is required`;if(n.model){if(!n.model.provider_id.trim())return`Provider is required for a role model override`;if(!n.model.model.trim())return`Model is required for a role model override`}return r.some(e=>e.name===i&&e.name!==t)?`Role name already exists`:null}function ie(e){return{name:e.name.trim(),description:e.description.trim(),system_prompt:e.system_prompt,model:e.model?{provider_id:e.model.provider_id.trim(),model:e.model.model.trim()}:null,model_params:U(e.model_params),included_tools:e.included_tools,excluded_tools:e.excluded_tools}}function ae(e){return e===`view`}function oe(e,t){return e!==`create`&&e!==null&&t?.is_builtin===!0}function se(e,t){return e===`create`?`New Role`:t?.is_builtin?`Built-in`:`Custom`}function ce(e,t){return e===`create`?`Create Role`:t?.is_builtin?`Role Details`:t?.name??`Role Details`}function le(e,t){return!(t||!e.name.trim()||!e.description.trim()||!e.system_prompt.trim())}function ue(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(null),[a,o]=(0,G.useState)(q()),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),{data:d,isLoading:f,mutate:g}=T(`rolesBootstrap`,ee),_=(0,G.useMemo)(()=>d?.roles??[],[d?.roles]),v=(0,G.useMemo)(()=>d?.tools??[],[d?.tools]),y=(0,G.useMemo)(()=>d?.providers??[],[d?.providers]),b=(0,G.useMemo)(()=>ne(v),[v]),x=(0,G.useMemo)(()=>re(y),[y]),S=(0,G.useMemo)(()=>n?_.find(e=>e.name===n)??null:null,[n,_]),C=a.model?.provider_id??``,w=(0,G.useMemo)(()=>C?x[C]?.models??[]:[],[C,x]),te=e!==null,E=ae(e),D=oe(e,S),O=se(e,S),k=ce(e,S),A=le(a,s),j=(0,G.useCallback)(e=>{g({roles:e,tools:v,providers:y},!1)},[g,y,v]),M=(0,G.useCallback)(async()=>{await g()},[g]),N=(0,G.useCallback)(()=>{t(null),r(null),o(q())},[]),P=(0,G.useCallback)(()=>{t(`create`),r(null),o(q())},[]),F=(0,G.useCallback)(e=>{t(`view`),r(e.name),o(J(e))},[]),I=(0,G.useCallback)(e=>{t(`edit`),r(e.name),o(J(e))},[]),L=(0,G.useCallback)(e=>{o(t=>e(t))},[]),R=(0,G.useCallback)(e=>{if(!e){L(e=>({...e,model:null}));return}if(y.length===0){i.error(`Create a provider before setting a role model`);return}L(e=>({...e,model:e.model??Z(y)}))},[y,L]),z=(0,G.useCallback)(e=>{L(t=>({...t,model:t.model?{provider_id:e,model:``}:null}))},[L]),B=(0,G.useCallback)(e=>{L(t=>({...t,model_params:e?W(t.model_params):null}))},[L]),V=(0,G.useCallback)(async()=>{let t=Q({activeRoleName:n,draft:a,roles:_});if(t){i.error(t);return}c(!0);try{let t=ie(a);if(e===`edit`&&n){let e=await p(n,S?.is_builtin?{model:t.model,model_params:t.model_params}:t);j(_.map(t=>t.name===n?e:t)),i.success(`Role updated`)}else j([await h(t),..._]),i.success(`Role created`);N()}catch(e){i.error(e instanceof Error?e.message:`Failed to save role`)}finally{c(!1)}},[S,n,N,a,e,_,j]),H=(0,G.useCallback)(e=>{u(e)},[]),U=(0,G.useCallback)(()=>{u(null)},[]),K=(0,G.useCallback)(async()=>{if(!l)return;let e=l.name;u(null);try{await m(e),j(_.filter(t=>t.name!==e)),n===e&&N(),i.success(`Role deleted`)}catch(e){i.error(e instanceof Error?e.message:`Failed to delete role`)}},[n,N,l,_,j]);return{activeRole:S,activeRoleName:n,availableActiveProviderModelOptions:w,canSave:A,configurableTools:b,draft:a,isPanelOpen:te,isReadOnly:E,loading:f,lockBuiltinFields:D,panelEyebrow:O,panelMode:e,panelTitle:k,providers:y,providersById:x,refreshRoles:M,roleToDelete:l,roles:_,saving:s,actions:{clearRoleToDelete:U,closePanel:N,cycleRoleToolState:(0,G.useCallback)(e=>{L(t=>X(t,e))},[L]),handleDelete:K,handleModelModeChange:R,handleModelParamsModeChange:B,handleProviderChange:z,handleSave:V,openCreate:P,openEdit:I,openView:F,requestDeleteRole:H,updateDraft:L},getToolState:e=>Y(a,e)}}var $=n();function de(){let{activeRole:e,availableActiveProviderModelOptions:t,canSave:n,configurableTools:i,draft:p,getToolState:ee,isPanelOpen:m,isReadOnly:h,loading:T,lockBuiltinFields:U,panelEyebrow:G,panelMode:K,panelTitle:q,providers:J,providersById:ne,refreshRoles:re,roleToDelete:Y,roles:X,saving:Z,actions:Q}=ue();return T&&!m?(0,$.jsx)(S,{label:`Loading roles...`}):(0,$.jsxs)(D,{className:`px-4 pt-6 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(te,{title:`Roles`,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(v,{type:`button`,variant:`outline`,size:`icon-sm`,onClick:()=>void re(),disabled:T,className:`bg-accent/20 text-muted-foreground hover:bg-accent/45 hover:text-foreground`,children:(0,$.jsx)(o,{className:f(`size-4`,T&&`animate-spin`)})}),(0,$.jsxs)(v,{type:`button`,size:`sm`,onClick:Q.openCreate,disabled:m,children:[(0,$.jsx)(l,{className:`size-4`}),`New Role`]})]})}),(0,$.jsx)(`div`,{className:`mt-6 min-h-0 flex-1`,children:m?(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none`,children:(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl pb-10`,children:[(0,$.jsxs)(`div`,{className:`mb-8 flex items-center justify-between rounded-xl border border-border bg-card/30 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(C,{variant:`secondary`,className:`rounded-full border border-border/70 bg-accent/20 px-2.5 py-0.5 text-[11px] font-medium text-muted-foreground`,children:G}),(0,$.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:q})]}),(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:Q.closePanel,className:`text-muted-foreground hover:bg-accent/45 hover:text-foreground`,children:(0,$.jsx)(u,{className:`size-3.5`})})]}),(0,$.jsxs)(`section`,{className:`mb-10`,children:[(0,$.jsx)(E,{title:`Identity`}),(0,$.jsxs)(`div`,{className:`border border-dashed border-border rounded-lg bg-card/30`,children:[(0,$.jsx)(w,{label:`Role Name`,children:(0,$.jsx)(b,{value:p.name,onChange:e=>Q.updateDraft(t=>({...t,name:e.target.value})),readOnly:h||U,placeholder:`e.g., Code Reviewer`,className:f(h||U?x:``)})}),(0,$.jsx)(w,{label:`Description`,children:(0,$.jsx)(g,{value:p.description,onChange:e=>Q.updateDraft(t=>({...t,description:e.target.value})),readOnly:h||U,placeholder:`Briefly explain what this role is best suited for`,rows:3,className:f(`resize-y`,h||U?x:``)})}),(0,$.jsx)(w,{label:`System Prompt`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(g,{value:p.system_prompt,onChange:e=>Q.updateDraft(t=>({...t,system_prompt:e.target.value})),readOnly:h||U,placeholder:`You are a helpful assistant that...`,rows:12,className:f(`resize-y`,h||U?x:``),mono:!0}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:h?e?.is_builtin?`This built-in role can be inspected. Use Edit to adjust only its model configuration.`:`This role is in read-only view. Use Edit to modify it.`:U?`Built-in role prompt and tool configuration are fixed. Only model configuration can be changed.`:`This prompt defines how agents with this role will behave.`})]})})]})]}),(0,$.jsxs)(`section`,{className:`mb-10 border-t border-border pt-8`,children:[(0,$.jsx)(E,{title:`Model Configuration`}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,disabled:h,onClick:()=>Q.handleModelModeChange(!1),className:f(`h-8 rounded-md border px-3 text-[13px] font-medium transition-colors`,p.model===null?`border-border bg-accent/45 text-foreground`:`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25`,h&&`cursor-default`),children:`Use Settings Default`}),(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,disabled:h,onClick:()=>Q.handleModelModeChange(!0),className:f(`h-8 rounded-md border px-3 text-[13px] font-medium transition-colors`,p.model===null?`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25`:`border-border bg-accent/45 text-foreground`,h&&`cursor-default`),children:`Set Role Override`})]}),p.model?(0,$.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 p-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Provider`}),(0,$.jsxs)(M,{value:p.model.provider_id||void 0,onValueChange:Q.handleProviderChange,disabled:h,children:[(0,$.jsx)(k,{className:_,children:(0,$.jsx)(O,{placeholder:`Select a provider`})}),(0,$.jsx)(A,{className:`rounded-xl border-border bg-popover`,children:J.map(e=>(0,$.jsx)(j,{value:e.id,className:`text-[13px]`,children:e.name},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Provider Models`}),(0,$.jsxs)(M,{value:t.some(e=>e.model===p.model?.model)?p.model?.model:void 0,onValueChange:e=>Q.updateDraft(t=>({...t,model:t.model?{...t.model,model:e}:null})),disabled:h||!p.model.provider_id||t.length===0,children:[(0,$.jsx)(k,{className:_,children:(0,$.jsx)(O,{placeholder:t.length>0?`Pick a provider model`:`No saved provider models`})}),(0,$.jsx)(A,{className:`max-h-[300px] rounded-xl border-border bg-popover`,children:t.map(e=>(0,$.jsx)(j,{value:e.model,className:`text-[13px]`,children:e.model},e.model))})]}),t.length===0?(0,$.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:`No saved provider models. Manage this provider catalog in Providers.`}):null]}),(0,$.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,$.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Model ID`}),(0,$.jsx)(b,{value:p.model.model,onChange:e=>Q.updateDraft(t=>({...t,model:t.model?{...t.model,model:e.target.value}:null})),readOnly:h,placeholder:`e.g., gpt-4o-mini`,className:f(h?x:``),mono:!0}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Catalog or manual ID`})]})]})}):(0,$.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This role follows the default provider and model from Settings.`})]})]}),(0,$.jsxs)(`section`,{className:`mb-10 border-t border-border pt-8`,children:[(0,$.jsx)(E,{title:`Model Parameters`}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,disabled:h,onClick:()=>Q.handleModelParamsModeChange(!1),className:f(`h-8 rounded-md border px-3 text-[13px] font-medium transition-colors`,H(p.model_params)?`border-border bg-accent/45 text-foreground`:`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25`,h&&`cursor-default`),children:`Use Settings Default`}),(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,disabled:h,onClick:()=>Q.handleModelParamsModeChange(!0),className:f(`h-8 rounded-md border px-3 text-[13px] font-medium transition-colors`,H(p.model_params)?`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25`:`border-border bg-accent/45 text-foreground`,h&&`cursor-default`),children:`Set Parameter Overrides`})]}),H(p.model_params)?(0,$.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This role inherits the default model parameters from Settings.`}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 p-5`,children:(0,$.jsx)(V,{value:W(p.model_params),onChange:e=>Q.updateDraft(t=>({...t,model_params:e})),disabled:h,emptyLabel:`Inherit settings default`,numberPlaceholder:`Inherit settings default`,reasoningDisableLabel:`Disable`,helperText:`These canonical parameters override Settings only for this role. Unsupported fields are ignored by the resolved provider.`})})]})]}),(0,$.jsxs)(`section`,{className:`mb-10 border-t border-border pt-8`,children:[(0,$.jsx)(E,{title:`Tool Configuration`}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card/30`,children:i.map(e=>{let t=ee(e.name);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b border-border px-5 py-4 last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,title:e.description,children:[(0,$.jsx)(`p`,{className:`font-mono text-[13px] text-foreground/80`,children:e.name}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-[12px] text-muted-foreground`,children:e.description})]}),(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>Q.cycleRoleToolState(e.name),disabled:h||U,className:f(`shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors`,t===`included`&&`bg-accent/50 text-foreground`,t===`excluded`&&`bg-transparent text-muted-foreground line-through`,t===`allowed`&&`bg-accent/20 text-muted-foreground hover:bg-accent/35`,(h||U)&&`cursor-default hover:bg-inherit opacity-60`),children:t===`allowed`?`Allowed`:t===`included`?`Included`:`Excluded`})]},e.name)})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border pt-6`,children:[(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,onClick:Q.closePanel,disabled:Z,children:`Cancel`}),h?null:(0,$.jsx)(v,{type:`button`,size:`sm`,onClick:()=>void Q.handleSave(),disabled:!n,children:Z?`Saving...`:K===`create`?`Create Role`:`Save Changes`}),h&&e&&!e.is_builtin?(0,$.jsx)(v,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>Q.openEdit(e),children:`Edit Role`}):null]})]})}):X.length===0?(0,$.jsxs)(c.div,{initial:{opacity:0},animate:{opacity:1},className:`flex h-full flex-col items-center justify-center text-center`,children:[(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl border border-border bg-accent/20 shadow-sm`,children:(0,$.jsx)(r,{className:`size-5 text-muted-foreground`})}),(0,$.jsx)(`h3`,{className:`mt-5 text-[15px] font-medium text-foreground`,children:`No Roles Created`}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-sm text-[13px] text-muted-foreground`,children:`Roles define agent behavior. Create your first role to get started.`})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-5xl`,children:[(0,$.jsxs)(`div`,{className:`mb-2 grid grid-cols-[260px_1fr_120px_100px] gap-4 px-4 pb-3`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Name`}),(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Model`}),(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Tools`}),(0,$.jsx)(`span`,{})]}),(0,$.jsx)(`div`,{className:`space-y-1`,children:X.map((t,n)=>{let r=t.model?ne[t.model.provider_id]?.name??t.model.provider_id:null,i=t.included_tools.length,o=t.excluded_tools.length,l=i===0&&o===0?`Default`:`${i>0?`+${i}`:``}${i>0&&o>0?` `:``}${o>0?`-${o}`:``}`;return(0,$.jsxs)(c.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:n*.03},className:f(`group grid grid-cols-[220px_1fr_100px_80px] items-center gap-4 rounded-xl px-4 py-3.5 transition-colors`,e?.name===t.name?`bg-accent/25`:`hover:bg-accent/15`),children:[(0,$.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.name}),t.is_builtin?(0,$.jsx)(`span`,{className:`shrink-0 rounded-full border border-border bg-accent/25 px-1.5 py-0.5 text-[9px] text-muted-foreground`,children:`Built-in`}):null]}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[12px] leading-relaxed text-muted-foreground`,children:t.description})]}),(0,$.jsx)(`div`,{className:`min-w-0 pr-2`,children:(0,$.jsx)(`span`,{className:`block truncate text-[13px] text-muted-foreground`,children:t.model?`${r} / ${t.model.model}`:`Settings default`})}),(0,$.jsx)(`div`,{className:`pr-2`,children:(0,$.jsx)(`span`,{className:`text-[13px] font-mono text-muted-foreground`,children:l})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[(0,$.jsx)(y,{onClick:()=>Q.openView(t),"aria-label":`View ${t.name}`,title:`View ${t.name}`,className:`size-7`,children:(0,$.jsx)(d,{className:`size-3.5`})}),(0,$.jsx)(y,{onClick:()=>Q.openEdit(t),"aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,className:`size-7`,children:(0,$.jsx)(a,{className:`size-3.5`})}),t.is_builtin?null:(0,$.jsx)(y,{onClick:()=>Q.requestDeleteRole(t),"aria-label":`Delete ${t.name}`,title:`Delete ${t.name}`,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,$.jsx)(s,{className:`size-3.5`})})]})]},t.name)})})]})})})]}),(0,$.jsx)(B,{open:Y!==null,onOpenChange:e=>{e||Q.clearRoleToDelete()},children:(0,$.jsxs)(F,{children:[(0,$.jsxs)(z,{children:[(0,$.jsx)(P,{children:`Delete role?`}),(0,$.jsx)(N,{children:Y?`This will permanently remove ${Y.name}.`:`This will permanently remove the selected role.`})]}),(0,$.jsxs)(L,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(v,{variant:`ghost`,children:`Cancel`})}),(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(v,{variant:`destructive`,onClick:()=>void Q.handleDelete(),children:`Delete`})})]})]})})]})}export{de as RolesPage};
@@ -0,0 +1,3 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{R as r,nt as i}from"./ui-vendor-Dg9NNnWX.js";import{a,t as o}from"./shared-CMxbpLeQ.js";import{B as s,G as c,H as l,J as u,R as d,U as f,V as p,f as m,o as h,z as g}from"./index-CL1ALZ3r.js";import{i as _,n as v,o as y,r as b,t as x}from"./PageScaffold-D4jO9ooX.js";import{a as S,i as C,n as w,r as T,t as E}from"./select-DL_LPeDj.js";import{n as D,r as O,t as k}from"./triState-DEr3NkXV.js";import{i as A,t as j}from"./modelParams-CaHd0903.js";async function M(){return o(`/api/settings/bootstrap`,{errorMessage:`Failed to fetch settings bootstrap`})}async function ee(e){return o(`/api/settings`,{method:`POST`,body:e,errorMessage:`Failed to save settings`,map:e=>{if(!e)throw Error(`Failed to save settings`);return{settings:e.settings,reauthRequired:e.reauth_required===!0}}})}var N=1024;function P(e){let t=[],n=new Set;for(let r of e){let e=r.trim();if(!e)continue;let i=e.replace(/\/+$/u,``)||`/`;n.has(i)||(n.add(i),t.push(i))}return t}function F(e,t){return e.find(e=>e.id===t)??null}function I(e,t){return e.find(e=>e.name===t)??null}function L(e){return e?.models??[]}function R(e,t){return t?e.find(e=>e.model===t)??null:null}function z(e,t){return e.model.context_window_tokens??t?.context_window_tokens??e.model.resolved_context_window_tokens??null}function B(e,t){return{input_image:e.model.input_image??t?.input_image??e.model.capabilities?.input_image??!1,output_image:e.model.output_image??t?.output_image??e.model.capabilities?.output_image??!1}}function V(e,t){if(!e)return null;let n=t.max_output_tokens??1024;return Math.max(1,e-n-N)}function H(e,t){return e!==null&&t!==null&&e>=t?`Automatic Compact token limit must stay below the known safe input window`:null}function U(e,t){let n=t&&(t.newCode||t.confirmCode)?{new_code:t.newCode,confirm_code:t.confirmCode}:void 0;return{...n?{access:n}:{},working_dir:e.working_dir.trim(),assistant:{role_name:e.assistant.role_name,allow_network:e.assistant.allow_network,write_dirs:P(e.assistant.write_dirs)},leader:e.leader,model:{active_provider_id:e.model.active_provider_id,active_model:e.model.active_model,input_image:e.model.input_image,output_image:e.model.output_image,context_window_tokens:e.model.context_window_tokens,timeout_ms:e.model.timeout_ms,retry_policy:e.model.retry_policy,max_retries:e.model.max_retries,retry_initial_delay_seconds:e.model.retry_initial_delay_seconds,retry_max_delay_seconds:e.model.retry_max_delay_seconds,retry_backoff_cap_retries:e.model.retry_backoff_cap_retries,auto_compact_token_limit:e.model.auto_compact_token_limit,params:e.model.params}}}var W=n(),G=[{value:`no_retry`,label:`No retry`},{value:`limited`,label:`Limited`},{value:`unlimited`,label:`Unlimited`}];function K({accessDraftError:e,onSave:t,saving:n,settings:r}){return(0,W.jsx)(v,{title:`Settings`,actions:(0,W.jsxs)(u,{type:`button`,size:`sm`,onClick:t,disabled:n||!!e||!r.working_dir.trim(),className:`text-[13px]`,children:[(0,W.jsx)(i,{className:`size-4`}),n?`Saving...`:`Save Changes`]}),className:`mb-8`})}function q({accessDraft:e,accessDraftError:t,onAccessDraftChange:n}){return(0,W.jsxs)(`section`,{className:`mt-8 first:mt-0`,children:[(0,W.jsx)(b,{title:`Access Configuration`}),(0,W.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface-2 shadow-sm overflow-hidden`,children:[(0,W.jsx)(_,{label:`New Access Code`,children:(0,W.jsx)(`div`,{className:`space-y-2 w-full`,children:(0,W.jsx)(p,{id:`new-access-code`,value:e.newCode,onChange:e=>n(t=>({...t,newCode:e.target.value})),placeholder:`Leave empty to keep`,showLabel:`Show new access code`,hideLabel:`Hide new access code`,buttonSize:`default`})})}),(0,W.jsx)(_,{label:`Confirm Access Code`,children:(0,W.jsxs)(`div`,{className:`space-y-2 w-full`,children:[(0,W.jsx)(p,{id:`confirm-access-code`,value:e.confirmCode,onChange:e=>n(t=>({...t,confirmCode:e.target.value})),placeholder:`Repeat the new access code`,showLabel:`Show confirmed access code`,hideLabel:`Hide confirmed access code`,buttonSize:`default`}),t?(0,W.jsx)(`p`,{className:a(`text-destructive font-medium pt-1`,l),children:t}):null]})})]})]})}function J({onSettingsChange:e,settings:t}){return(0,W.jsxs)(`section`,{className:`mt-10`,children:[(0,W.jsx)(b,{title:`Path Configuration`}),(0,W.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface-2 shadow-sm overflow-hidden`,children:[(0,W.jsx)(_,{label:`App Data Directory`,children:(0,W.jsx)(`div`,{className:`space-y-2`,children:(0,W.jsx)(d,{"aria-label":`App Data Directory`,value:t.app_data_dir,readOnly:!0,mono:!0})})}),(0,W.jsx)(_,{label:`Working Directory`,children:(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(d,{"aria-label":`Working Directory`,value:t.working_dir,onChange:t=>e(e=>({...e,working_dir:t.target.value})),placeholder:`/workspace/project`,mono:!0}),(0,W.jsx)(`div`,{className:a(`space-y-2`,l),children:t.working_dir.trim()?null:(0,W.jsx)(`p`,{className:`text-destructive`,children:`Working Directory must not be empty.`})})]})})]})]})}function Y({assistantRole:e,onSettingsChange:t,roles:n,settings:r}){return(0,W.jsxs)(`section`,{className:`mt-10`,children:[(0,W.jsx)(b,{title:`Assistant Configuration`}),(0,W.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface-2 shadow-sm overflow-hidden`,children:[(0,W.jsxs)(_,{label:`Assistant Role`,children:[(0,W.jsxs)(E,{value:r.assistant.role_name,onValueChange:e=>t(t=>({...t,assistant:{...t.assistant,role_name:e}})),children:[(0,W.jsx)(C,{className:c,children:(0,W.jsx)(S,{placeholder:`Select a role`})}),(0,W.jsx)(w,{children:n.map(e=>(0,W.jsx)(T,{value:e.name,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start`,children:[(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.description})]})},e.name))})]}),e?(0,W.jsx)(`div`,{"data-testid":`assistant-role-guidance`,className:a(`mt-2`,l),children:(0,W.jsx)(`p`,{children:e.description})}):null]}),(0,W.jsx)(_,{label:`Network Access`,children:(0,W.jsx)(`div`,{className:`space-y-2`,children:(0,W.jsx)(g,{checked:r.assistant.allow_network,label:`Network Access`,onCheckedChange:e=>t(t=>({...t,assistant:{...t.assistant,allow_network:e}})),showStateText:!0})})}),(0,W.jsx)(_,{label:`Write Dirs`,children:(0,W.jsx)(`div`,{className:`space-y-2`,children:(0,W.jsx)(s,{"aria-label":`Write Dirs`,value:r.assistant.write_dirs.join(`
2
+ `),onChange:e=>t(t=>({...t,assistant:{...t.assistant,write_dirs:e.target.value.split(`
3
+ `)}})),rows:4,spellCheck:!1,placeholder:`/workspace/output`,className:`min-h-[108px]`,mono:!0})})})]})]})}function X({leaderRole:e,onSettingsChange:t,roles:n,settings:r}){return(0,W.jsxs)(`section`,{className:`mt-10`,children:[(0,W.jsx)(b,{title:`Leader Configuration`}),(0,W.jsx)(`div`,{className:`rounded-xl border border-border bg-surface-2 shadow-sm overflow-hidden`,children:(0,W.jsxs)(_,{label:`Leader Role`,children:[(0,W.jsxs)(E,{value:r.leader.role_name,onValueChange:e=>t(t=>({...t,leader:{role_name:e}})),children:[(0,W.jsx)(C,{className:c,children:(0,W.jsx)(S,{placeholder:`Select a role`})}),(0,W.jsx)(w,{children:n.map(e=>(0,W.jsx)(T,{value:e.name,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start`,children:[(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.description})]})},e.name))})]}),e?(0,W.jsx)(`p`,{className:a(`mt-2`,l),children:e.description}):null]})})]})}function Z({activeProvider:e,activeProviderModels:t,availableActiveProviderModels:n,effectiveContextWindowTokens:r,effectiveModelCapabilities:i,knownSafeInputTokens:o,onSettingsChange:s,providers:u,settings:p}){return(0,W.jsxs)(`section`,{className:`mt-10`,children:[(0,W.jsx)(b,{title:`Model Configuration`}),(0,W.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface-2 shadow-sm overflow-hidden`,children:[(0,W.jsxs)(_,{label:`Active Provider`,children:[(0,W.jsxs)(E,{value:p.model.active_provider_id,onValueChange:e=>{s(t=>({...t,model:{...t.model,active_provider_id:e,active_model:``}}))},children:[(0,W.jsx)(C,{className:c,children:(0,W.jsx)(S,{placeholder:`Select a provider`})}),(0,W.jsx)(w,{children:u.map(e=>(0,W.jsxs)(T,{value:e.id,children:[e.name,` (`,O(e.type),`)`]},e.id))})]}),e?(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Using `,e.name,` (`,e.base_url,`)`]}):null]}),(0,W.jsxs)(_,{label:`Model`,children:[(0,W.jsxs)(`div`,{className:`space-y-3`,children:[p.model.active_provider_id?t.length>0?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:f,children:`Provider Models`}),(0,W.jsxs)(E,{value:n.some(e=>e.model===p.model.active_model)?p.model.active_model:void 0,onValueChange:e=>s(t=>({...t,model:{...t.model,active_model:e}})),children:[(0,W.jsx)(C,{className:c,children:(0,W.jsx)(S,{placeholder:`Select a provider model`})}),(0,W.jsx)(w,{children:n.map(e=>(0,W.jsx)(T,{value:e.model,children:e.model},e.model))})]})]}):(0,W.jsx)(`p`,{className:l,children:`No saved provider models.`}):null,(0,W.jsx)(d,{value:p.model.active_model,onChange:e=>s(t=>({...t,model:{...t.model,active_model:e.target.value}})),placeholder:p.model.active_provider_id?`Enter model ID manually`:`Select a provider first`})]}),p.model.active_model?(0,W.jsxs)(`div`,{className:a(`mt-2 space-y-1`,l),children:[(0,W.jsxs)(`p`,{children:[`Context window:`,` `,r?r.toLocaleString():`Not resolved`]}),(0,W.jsxs)(`p`,{children:[`Capabilities: input_image=`,i.input_image?`true`:`false`,`, output_image=`,i.output_image?`true`:`false`]})]}):null]}),(0,W.jsx)(_,{label:`Model Metadata Overrides`,children:(0,W.jsx)(`div`,{className:`space-y-3`,children:(0,W.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`model-context-window`,className:f,children:`Context Window`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(d,{id:`model-context-window`,"aria-label":`Context Window`,inputMode:`numeric`,pattern:`[0-9]*`,value:p.model.context_window_tokens===null?``:String(p.model.context_window_tokens),onChange:e=>{let t=e.target.value.trim();/^\d*$/.test(t)&&(t&&Number.parseInt(t,10)<=0||s(e=>({...e,model:{...e.model,context_window_tokens:t?Number.parseInt(t,10):null}})))},placeholder:`Auto`,mono:!0}),(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`tokens`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{className:f,children:`Input Image`}),(0,W.jsxs)(E,{value:D(p.model.input_image),onValueChange:e=>s(t=>({...t,model:{...t.model,input_image:k(e)}})),children:[(0,W.jsx)(C,{"aria-label":`Input Image`,className:c,children:(0,W.jsx)(S,{placeholder:`Auto`})}),(0,W.jsxs)(w,{children:[(0,W.jsx)(T,{value:`auto`,children:`Auto`}),(0,W.jsx)(T,{value:`enabled`,children:`Enabled`}),(0,W.jsx)(T,{value:`disabled`,children:`Disabled`})]})]})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{className:f,children:`Output Image`}),(0,W.jsxs)(E,{value:D(p.model.output_image),onValueChange:e=>s(t=>({...t,model:{...t.model,output_image:k(e)}})),children:[(0,W.jsx)(C,{"aria-label":`Output Image`,className:c,children:(0,W.jsx)(S,{placeholder:`Auto`})}),(0,W.jsxs)(w,{children:[(0,W.jsx)(T,{value:`auto`,children:`Auto`}),(0,W.jsx)(T,{value:`enabled`,children:`Enabled`}),(0,W.jsx)(T,{value:`disabled`,children:`Disabled`})]})]})]})]})})}),(0,W.jsx)(_,{label:`Default Model Parameters`,valueClassName:`w-full md:w-80`,children:(0,W.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 p-5`,children:(0,W.jsx)(A,{className:`w-full`,value:j(p.model.params),onChange:e=>s(t=>({...t,model:{...t.model,params:e}})),emptyLabel:`Not set`,numberPlaceholder:`Not set`,reasoningDisableLabel:null,helperText:`Empty fields are omitted from outgoing provider requests. Reasoning effort and verbosity are mainly effective on reasoning-capable providers such as OpenAI Responses with GPT-5 family models.`})})}),(0,W.jsx)(_,{label:`Request Timeout`,children:(0,W.jsx)(`div`,{className:`space-y-2`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(d,{"aria-label":`Request Timeout`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(p.model.timeout_ms),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);!Number.isSafeInteger(n)||n<=0||s(e=>({...e,model:{...e.model,timeout_ms:n}}))},mono:!0}),(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`ms`})]})})}),(0,W.jsx)(_,{label:`Retry Policy`,children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(E,{value:p.model.retry_policy,onValueChange:e=>s(t=>({...t,model:{...t.model,retry_policy:e}})),children:[(0,W.jsx)(C,{className:c,children:(0,W.jsx)(S,{placeholder:`Select a retry policy`})}),(0,W.jsx)(w,{children:G.map(e=>(0,W.jsx)(T,{value:e.value,children:e.label},e.value))})]}),p.model.retry_policy===`limited`?(0,W.jsx)(`div`,{className:`space-y-2`,children:(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`retry-attempts`,className:f,children:`Retry Attempts`}),(0,W.jsx)(d,{id:`retry-attempts`,"aria-label":`Retry Attempts`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(p.model.max_retries),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);!Number.isSafeInteger(n)||n<=0||s(e=>({...e,model:{...e.model,max_retries:n}}))},mono:!0})]})}):null]})}),(0,W.jsx)(_,{label:`Retry Backoff`,children:(0,W.jsx)(`div`,{className:`space-y-3`,children:(0,W.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`retry-initial-delay`,className:f,children:`Initial Delay`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(d,{id:`retry-initial-delay`,"aria-label":`Initial Delay`,inputMode:`decimal`,value:String(p.model.retry_initial_delay_seconds),onChange:e=>{let t=e.target.value.trim();if(!/^\d+(\.\d+)?$/.test(t))return;let n=Number.parseFloat(t);!Number.isFinite(n)||n<=0||s(e=>({...e,model:{...e.model,retry_initial_delay_seconds:n}}))},mono:!0}),(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`s`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`retry-max-delay`,className:f,children:`Max Delay`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(d,{id:`retry-max-delay`,"aria-label":`Max Delay`,inputMode:`decimal`,value:String(p.model.retry_max_delay_seconds),onChange:e=>{let t=e.target.value.trim();if(!/^\d+(\.\d+)?$/.test(t))return;let n=Number.parseFloat(t);!Number.isFinite(n)||n<=0||s(e=>({...e,model:{...e.model,retry_max_delay_seconds:n}}))},mono:!0}),(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`s`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`retry-backoff-cap-retries`,className:f,children:`Cap Retries`}),(0,W.jsx)(d,{id:`retry-backoff-cap-retries`,"aria-label":`Cap Retries`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(p.model.retry_backoff_cap_retries),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);!Number.isSafeInteger(n)||n<=0||s(e=>({...e,model:{...e.model,retry_backoff_cap_retries:n}}))},mono:!0})]})]})})}),(0,W.jsx)(_,{label:`Automatic Compact`,children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`auto-compact-token-limit`,className:f,children:`Token Limit`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(d,{id:`auto-compact-token-limit`,"aria-label":`Automatic Compact Token Limit`,inputMode:`numeric`,pattern:`[0-9]*`,value:p.model.auto_compact_token_limit===null?``:String(p.model.auto_compact_token_limit),onChange:e=>{let t=e.target.value.trim();/^\d*$/.test(t)&&(t&&Number.parseInt(t,10)<=0||s(e=>({...e,model:{...e.model,auto_compact_token_limit:t?Number.parseInt(t,10):null}})))},placeholder:`Disabled`,mono:!0}),(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`tokens`})]})]}),o===null?p.model.auto_compact_token_limit===null?null:(0,W.jsx)(`p`,{className:`text-[11px] leading-relaxed text-graph-status-idle`,children:`The current model window is not resolved, so this token limit can be saved but cannot be fully validated yet.`}):(0,W.jsxs)(`p`,{className:l,children:[`Known safe input window: `,o.toLocaleString(),` `,`tokens.`,p.model.auto_compact_token_limit!==null&&p.model.auto_compact_token_limit>=o?` Save is blocked until the token limit is lower than this window.`:null]})]})})]})]})}function Q({appVersion:e}){return(0,W.jsxs)(`div`,{className:`mt-12 flex flex-col items-center pt-2 pb-6 text-center`,children:[(0,W.jsxs)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`Flowent Agent Studio v`,e??`—`]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted-foreground/80`,children:`A multi-agent collaboration framework.`})]})}var $=e(t(),1);function te(){let{requireReauth:e}=m(),{data:t,isLoading:n,mutate:i}=y(`settingsBootstrap`,()=>M()),[a,o]=(0,$.useState)(null),[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)({newCode:``,confirmCode:``}),d=(0,$.useMemo)(()=>t?.providers??[],[t?.providers]),f=(0,$.useMemo)(()=>t?.roles??[],[t?.roles]),p=t?.version??null;(0,$.useEffect)(()=>{t?.settings&&!a&&o(t.settings)},[t?.settings,a]);let h=a??t?.settings??null,g=(0,$.useCallback)(e=>{o(n=>{let r=n??t?.settings??null;return r?e(r):n})},[t?.settings]),_=(0,$.useCallback)(e=>{u(t=>e(t))},[]),v=(0,$.useMemo)(()=>h?F(d,h.model.active_provider_id):null,[d,h]),b=(0,$.useMemo)(()=>h?I(f,h.assistant.role_name):null,[f,h]),x=(0,$.useMemo)(()=>L(v),[v]),S=x,C=(0,$.useMemo)(()=>h?R(x,h.model.active_model):null,[x,h]),w=(0,$.useMemo)(()=>h?z(h,C):null,[C,h]),T=(0,$.useMemo)(()=>h?B(h,C):{input_image:!1,output_image:!1},[C,h]),E=(0,$.useMemo)(()=>h?V(w,h.model.params):null,[w,h]),D=(0,$.useMemo)(()=>h?I(f,h.leader.role_name):null,[f,h]),O=(0,$.useMemo)(()=>!l.newCode&&!l.confirmCode?null:l.newCode.trim()?l.confirmCode===l.newCode?null:`Confirm Access Code must exactly match New Access Code.`:`New Access Code must not be empty.`,[l.confirmCode,l.newCode]);return{accessDraft:l,accessDraftError:O,activeProvider:v,activeProviderModels:x,availableActiveProviderModels:S,appVersion:p,assistantRole:b,effectiveContextWindowTokens:w,effectiveModelCapabilities:T,handleSave:(0,$.useCallback)(async()=>{if(!h)return;if(O){r.error(O);return}if(!h.working_dir.trim()){r.error(`Working Directory must not be empty`);return}if(h.model.retry_max_delay_seconds<h.model.retry_initial_delay_seconds){r.error(`Max Delay must be greater than or equal to Initial Delay`);return}let t=H(h.model.auto_compact_token_limit,E);if(t){r.error(t);return}c(!0);try{let t=await ee(U(h,l)),n=t.settings;if(o(n),u({newCode:``,confirmCode:``}),i(e=>e&&{...e,settings:n},!1),t.reauthRequired){r.success(`Access code updated. Sign in again with the new code.`),e();return}r.success(`Settings saved`)}catch(e){r.error(e instanceof Error?e.message:`Failed to save settings`)}finally{c(!1)}},[l,O,E,i,e,h]),knownSafeInputTokens:E,leaderRole:D,loading:n,providers:d,roles:f,saving:s,settings:h,updateAccessDraft:_,updateSettings:g}}function ne(){let{accessDraft:e,accessDraftError:t,activeProvider:n,activeProviderModels:r,availableActiveProviderModels:i,appVersion:a,assistantRole:o,effectiveContextWindowTokens:s,effectiveModelCapabilities:c,handleSave:l,knownSafeInputTokens:u,leaderRole:d,loading:f,providers:p,roles:m,saving:g,settings:_,updateAccessDraft:v,updateSettings:y}=te();return f||!_?(0,W.jsx)(h,{label:`Loading settings...`,textClassName:`text-[13px]`}):(0,W.jsx)(x,{children:(0,W.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-[680px] pb-10 pt-6`,children:[(0,W.jsx)(K,{accessDraftError:t,onSave:()=>{l()},saving:g,settings:_}),(0,W.jsx)(q,{accessDraft:e,accessDraftError:t,onAccessDraftChange:v}),(0,W.jsx)(J,{onSettingsChange:y,settings:_}),(0,W.jsx)(Y,{assistantRole:o,onSettingsChange:y,roles:m,settings:_}),(0,W.jsx)(X,{leaderRole:d,onSettingsChange:y,roles:m,settings:_}),(0,W.jsx)(Z,{activeProvider:n,activeProviderModels:r,availableActiveProviderModels:i,effectiveContextWindowTokens:s,effectiveModelCapabilities:c,knownSafeInputTokens:u,onSettingsChange:y,providers:p,settings:_}),(0,W.jsx)(Q,{appVersion:a})]})})})}export{ne as SettingsPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{$ as r,Et as i,Gt as a,It as o,K as s,Mt as c,Qt as l,V as u,Vt as d,X as f,en as p,it as m}from"./ui-vendor-Dg9NNnWX.js";import{a as h,t as g}from"./shared-CMxbpLeQ.js";import{J as _}from"./index-CL1ALZ3r.js";import{r as ee}from"./constants-XUzFf6i1.js";import{a as v,n as te,o as y,t as ne}from"./PageScaffold-D4jO9ooX.js";import{t as b}from"./datetime-m6_O_Ci9.js";import{a as x,i as S,n as C,r as w,t as T}from"./select-DL_LPeDj.js";async function E(e){return g(`/api/stats?range=${encodeURIComponent(e)}`,{method:`GET`,errorMessage:`Failed to fetch stats`,map:t=>({requested_at:typeof t?.requested_at==`number`?t.requested_at:0,range:t?.range===`1h`||t?.range===`24h`||t?.range===`7d`||t?.range===`30d`?t.range:e,tabs:Array.isArray(t?.workflows)?t.workflows:[],nodes:Array.isArray(t?.nodes)?t.nodes.map(e=>({...e,tab_id:typeof e.workflow_id==`string`?e.workflow_id:null,tab_title:typeof e.workflow_title==`string`?e.workflow_title:null})):[],requests:Array.isArray(t?.requests)?t.requests.map(e=>({...e,tab_id:typeof e.workflow_id==`string`?e.workflow_id:null,tab_title:typeof e.workflow_title==`string`?e.workflow_title:null})):[],compacts:Array.isArray(t?.compacts)?t.compacts.map(e=>({...e,tab_id:typeof e.workflow_id==`string`?e.workflow_id:null,tab_title:typeof e.workflow_title==`string`?e.workflow_title:null})):[],mcp_activity:Array.isArray(t?.mcp_activity)?t.mcp_activity.map(e=>({...e,tab_id:typeof e.workflow_id==`string`?e.workflow_id:null})):[]})})}var D=e(t(),1),O={"1h":3600,"24h":1440*60,"7d":10080*60,"30d":720*60*60},k={"1h":12,"24h":24,"7d":28,"30d":30};function A(e){return typeof e!=`number`||!Number.isFinite(e)?null:e>0xe8d4a51000?e:e*1e3}function j(e,t){return t||e||`Unknown provider`}function M(e){return e||`Unknown model`}function N(e){return e||`Unknown workflow`}function P(e){return e||`Unknown agent`}function F(e,t){return!(t.providerId&&e.provider_id!==t.providerId||t.model&&(e.model||null)!==t.model||t.tabId&&(e.tab_id||null)!==t.tabId||t.agentId&&(e.node_id||null)!==t.agentId)}function I(e,t){return!(t.providerId&&(e.provider_id||null)!==t.providerId||t.model&&(e.model||null)!==t.model||t.tabId&&(e.tab_id||null)!==t.tabId||t.agentId&&e.id!==t.agentId)}function L(e){return e.reduce((e,t)=>e+(typeof t==`number`?t:0),0)}function R(e){return e.length===0?null:e.reduce((e,t)=>e+t,0)/e.length}function z(e){let t=0,n=0;for(let r of e)typeof r.cacheRead==`number`&&typeof r.inputTokens==`number`&&r.inputTokens>0&&(t+=r.cacheRead,n+=r.inputTokens);return n<=0?null:Math.max(0,Math.min(1,t/n))}function B(e){let t=e.map(e=>e.duration_ms),n=e.filter(e=>e.result===`success`);return{requestCount:e.length,errorCount:e.filter(e=>e.result===`error`).length,totalTokens:L(n.map(e=>e.normalized_usage?.total_tokens??null)),avgLatencyMs:R(t),retryCount:e.reduce((e,t)=>e+t.retry_count,0),cacheRead:L(n.map(e=>e.normalized_usage?.cache_read_tokens??null)),cacheWrite:L(n.map(e=>e.normalized_usage?.cache_write_tokens??null)),cacheHitRate:z(n.map(e=>({cacheRead:e.normalized_usage?.cache_read_tokens??null,inputTokens:e.normalized_usage?.input_tokens??null}))),lastActivityAt:e.length>0?Math.max(...e.map(e=>A(e.ended_at)??0)):null}}function V(e,t){let n=new Date(e);return t===`1h`||t===`24h`?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString([],{month:`numeric`,day:`numeric`})}function H(e){return[...e.entries()].sort((e,t)=>e[1].localeCompare(t[1])).map(([e,t])=>({value:e,label:t}))}function U(e){let t=new Map,n=new Map,r=new Map,i=new Map;for(let a of e.nodes)a.provider_id&&t.set(a.provider_id,j(a.provider_id,a.provider_name)),a.model&&n.set(a.model,M(a.model)),a.tab_id&&r.set(a.tab_id,N(a.tab_title)),i.set(a.id,P(a.label));for(let a of e.requests)a.provider_id&&t.set(a.provider_id,j(a.provider_id,a.provider_name)),a.model&&n.set(a.model,M(a.model)),a.tab_id&&r.set(a.tab_id,N(a.tab_title)),i.set(a.node_id,P(a.node_label));for(let a of e.compacts)a.provider_id&&t.set(a.provider_id,j(a.provider_id,a.provider_name)),a.model&&n.set(a.model,M(a.model)),a.tab_id&&r.set(a.tab_id,N(a.tab_title)),i.set(a.node_id,P(a.node_label));return{providers:H(t),models:H(n),tabs:H(r),agents:H(i)}}function re(e,t){let n=e.requests.filter(e=>F(e,t)),r=e.compacts.filter(e=>F(e,t)),i=e.nodes.filter(e=>I(e,t)),a=new Set(i.map(e=>e.tab_id).filter(e=>typeof e==`string`&&e.length>0));return{requests:n,compacts:r,nodes:i,tabs:e.tabs.filter(e=>t.tabId?e.id===t.tabId:t.agentId||t.providerId||t.model?a.has(e.id):!0)}}function ie(e,t,n){let r=n.nodes.filter(e=>e.state===`running`).length,i=n.tabs.length,a=B(n.requests),o=n.requests.some(e=>e.normalized_usage?.cache_read_tokens!=null||e.normalized_usage?.cache_write_tokens!=null),s=t.providerId||t.model||t.tabId||t.agentId?n:re(e,t);return{activeTabs:t.providerId||t.model||t.tabId||t.agentId?i:s.tabs.length,runningAgents:t.providerId||t.model||t.tabId||t.agentId?r:s.nodes.filter(e=>e.state===`running`).length,llmRequests:a.requestCount,totalTokens:a.totalTokens,errorRate:a.requestCount>0?a.errorCount/a.requestCount:null,avgLatencyMs:a.avgLatencyMs,cacheRead:a.cacheRead,cacheWrite:a.cacheWrite,cacheHitRate:a.cacheHitRate,hasCacheUsage:o}}function ae(e,t,n,r){let i=A(r)??Date.now(),a=k[e],o=O[e]*1e3,s=Math.max(1,Math.ceil(o/a)),c=i-o,l=Array.from({length:a},(t,n)=>{let r=c+n*s;return{startMs:r,endMs:r+s,label:V(r,e),requestCount:0,errorCount:0,totalTokens:0,avgLatencyMs:null,compactCount:0,manualCompactCount:0,autoCompactCount:0,cacheRead:0,cacheWrite:0,cacheHitRate:null}}),u=new Map,d=new Map,f=e=>e===null||e<c||e>i?null:Math.min(a-1,Math.max(0,Math.floor((e-c)/s)));for(let e of t){let t=f(A(e.ended_at));if(t===null)continue;let n=l[t];if(n.requestCount+=1,e.result===`error`&&(n.errorCount+=1),e.result===`success`){n.totalTokens+=e.normalized_usage?.total_tokens??0,n.cacheRead+=e.normalized_usage?.cache_read_tokens??0,n.cacheWrite+=e.normalized_usage?.cache_write_tokens??0;let r=d.get(t)??[];r.push({cacheRead:e.normalized_usage?.cache_read_tokens??null,inputTokens:e.normalized_usage?.input_tokens??null}),d.set(t,r)}let r=u.get(t)??[];r.push(e.duration_ms),u.set(t,r)}for(let e of n){let t=f(A(e.ended_at));if(t===null)continue;let n=l[t];n.compactCount+=1,e.trigger_type===`manual`?n.manualCompactCount+=1:n.autoCompactCount+=1}for(let e=0;e<l.length;e+=1){let t=l[e];t.avgLatencyMs=R(u.get(e)??[]),t.cacheHitRate=z(d.get(e)??[])}return l}function oe(e){let t=new Map;for(let n of e){let e=n.provider_id||`unknown-provider`,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>{let n=new Map;for(let e of t){let t=e.model||`Unknown model`,r=n.get(t)??[];r.push(e),n.set(t,r)}let r=B(t),i=[...n.entries()].map(([t,n])=>{let r=B(n);return{key:`${e}:${t}`,model:M(n[0]?.model??null),requestCount:r.requestCount,errorCount:r.errorCount,totalTokens:r.totalTokens,avgLatencyMs:r.avgLatencyMs,retryCount:r.retryCount,cacheRead:r.cacheRead,cacheWrite:r.cacheWrite,cacheHitRate:r.cacheHitRate,lastActivityAt:r.lastActivityAt}}).sort((e,t)=>t.requestCount-e.requestCount);return{key:e,providerLabel:j(t[0]?.provider_id??null,t[0]?.provider_name??null),requestCount:r.requestCount,errorCount:r.errorCount,totalTokens:r.totalTokens,avgLatencyMs:r.avgLatencyMs,retryCount:r.retryCount,cacheRead:r.cacheRead,cacheWrite:r.cacheWrite,cacheHitRate:r.cacheHitRate,lastActivityAt:r.lastActivityAt,models:i}}).sort((e,t)=>t.requestCount-e.requestCount)}function se(e,t,n){return n===`tokens`?t.totalTokens-e.totalTokens:n===`errors`?t.errorCount-e.errorCount:n===`latency`?(t.avgLatencyMs??-1)-(e.avgLatencyMs??-1):n===`cache_hit_rate`?(t.cacheHitRate??-1)-(e.cacheHitRate??-1):t.requestCount-e.requestCount}function ce(e,t,n,r,i){let a=new Map;for(let t of e){let e=t.tab_id||`unknown-tab`,n=a.get(e)??[];n.push(t),a.set(e,n)}let o=new Map;for(let e of t){let t=e.tab_id||`unknown-tab`;o.set(t,(o.get(t)??0)+1)}let s=new Map;for(let e of n)!e.tab_id||e.state!==`running`||s.set(e.tab_id,(s.get(e.tab_id)??0)+1);return[...new Set([...r.map(e=>e.id),...a.keys(),...o.keys()])].map(e=>{let t=r.find(t=>t.id===e)??null,n=B(a.get(e)??[]);return{key:e,tabId:t?.id??null,tabTitle:N(t?.title??a.get(e)?.[0]?.tab_title??null),requestCount:n.requestCount,errorCount:n.errorCount,totalTokens:n.totalTokens,avgLatencyMs:n.avgLatencyMs,compactCount:o.get(e)??0,runningAgents:s.get(e)??0,cacheRead:n.cacheRead,cacheWrite:n.cacheWrite,cacheHitRate:n.cacheHitRate}}).sort((e,t)=>se(e,t,i))}function le(e,t,n){let r=new Map;for(let t of e){let e=r.get(t.node_id)??[];e.push(t),r.set(t.node_id,e)}let i=new Map(t.map(e=>[e.id,e]));return[...new Set([...i.keys(),...r.keys()])].map(e=>{let t=i.get(e)??null,n=B(r.get(e)??[]);return{key:e,nodeId:e,agentLabel:P(t?.label??r.get(e)?.[0]?.node_label??null),roleName:t?.role_name??r.get(e)?.[0]?.role_name??null,tabTitle:N(t?.tab_title??r.get(e)?.[0]?.tab_title??null),requestCount:n.requestCount,errorCount:n.errorCount,totalTokens:n.totalTokens,avgLatencyMs:n.avgLatencyMs,cacheRead:n.cacheRead,cacheWrite:n.cacheWrite,cacheHitRate:n.cacheHitRate,state:t?.state??null}}).sort((e,t)=>se(e,t,n))}function ue(e,t){let n=[];for(let t of e){if(t.result===`error`){n.push({key:t.id,kind:`request_error`,endedAt:A(t.ended_at)??0,tabTitle:N(t.tab_title),agentLabel:P(t.node_label),providerLabel:j(t.provider_id,t.provider_name),modelLabel:M(t.model),result:t.result,retryCount:t.retry_count,errorSummary:t.error_summary??null,request:t});continue}t.retry_count>0&&n.push({key:t.id,kind:`request_retry`,endedAt:A(t.ended_at)??0,tabTitle:N(t.tab_title),agentLabel:P(t.node_label),providerLabel:j(t.provider_id,t.provider_name),modelLabel:M(t.model),result:t.result,retryCount:t.retry_count,errorSummary:t.error_summary??null,request:t})}for(let e of t)n.push({key:e.id,kind:`compact`,endedAt:A(e.ended_at)??0,tabTitle:N(e.tab_title),agentLabel:P(e.node_label),providerLabel:j(e.provider_id,e.provider_name),modelLabel:M(e.model),result:e.result,compact:e});return n.sort((e,t)=>t.endedAt-e.endedAt)}function de(e,t){return t===`tokens`?e.totalTokens:t===`errors`?e.errorCount:t===`latency`?e.avgLatencyMs:t===`compacts`?e.compactCount:t===`cache_read`?e.cacheRead:t===`cache_write`?e.cacheWrite:t===`cache_hit_rate`?e.cacheHitRate:e.requestCount}var fe={providerId:null,model:null,tabId:null,agentId:null},pe=`requests`,me=`requests`,he=[{value:`1h`,label:`1h`},{value:`24h`,label:`24h`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`}],W=`__all__`,ge=[{value:`requests`,label:`Requests`},{value:`tokens`,label:`Tokens`},{value:`errors`,label:`Errors`},{value:`latency`,label:`Latency`},{value:`compacts`,label:`Compacts`},{value:`cache_read`,label:`Cache Read`},{value:`cache_write`,label:`Cache Write`},{value:`cache_hit_rate`,label:`Cache Hit Rate`}],_e=[{value:`requests`,label:`Requests`},{value:`tokens`,label:`Tokens`},{value:`errors`,label:`Errors`},{value:`latency`,label:`Latency`},{value:`cache_hit_rate`,label:`Cache Hit Rate`}],G=`h-8 rounded-md bg-background/50 text-foreground`,K=`text-[10px] font-medium text-muted-foreground/80`;function q(e,t){return!!(t&&e.some(e=>e.value===t))}function J(e){return b(e,{fallback:`Unknown`})}function Y(e){return typeof e!=`number`||!Number.isFinite(e)?`N/A`:e.toLocaleString()}function X(e){return typeof e!=`number`||!Number.isFinite(e)?`N/A`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function Z(e){return typeof e!=`number`||!Number.isFinite(e)?`Unavailable`:`${(e*100).toFixed(1)}%`}function ve(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.requestCount>0||n.compactCount>0)return t}return Math.max(e.length-1,0)}function ye(e){return{requested_at:Date.now(),range:e,tabs:[],nodes:[],requests:[],compacts:[]}}function be(e,t){return{providerId:q(t.providers,e.providerId)?e.providerId:null,model:q(t.models,e.model)?e.model:null,tabId:q(t.tabs,e.tabId)?e.tabId:null,agentId:q(t.agents,e.agentId)?e.agentId:null}}function xe(e){return e.requests.length>0||e.compacts.length>0||e.nodes.some(e=>[`running`,`sleeping`,`initializing`,`error`].includes(e.state))}function Se(){let[e,t]=(0,D.useState)(`24h`),[n,r]=(0,D.useState)({...fe}),[i,a]=(0,D.useState)(pe),[o,s]=(0,D.useState)(me),[c,l]=(0,D.useState)(null),{data:u,error:d,isLoading:f,mutate:p}=y([`stats`,e],([,e])=>E(e),{keepPreviousData:!0}),m=u??ye(e),h=(0,D.useMemo)(()=>U(m),[m]),g=(0,D.useMemo)(()=>be(n,h),[h,n]),_=(0,D.useMemo)(()=>re(m,g),[g,m]);return{range:e,metric:i,sortKey:o,expandedEventId:c,filterOptions:h,effectiveFilters:g,overview:(0,D.useMemo)(()=>ie(m,g,_),[g,_,m]),buckets:(0,D.useMemo)(()=>ae(m.range,_.requests,_.compacts,m.requested_at),[_.compacts,_.requests,m.range,m.requested_at]),providerGroups:(0,D.useMemo)(()=>oe(_.requests),[_.requests]),tabGroups:(0,D.useMemo)(()=>ce(_.requests,_.compacts,_.nodes,_.tabs,o),[_.compacts,_.nodes,_.requests,_.tabs,o]),agentGroups:(0,D.useMemo)(()=>le(_.requests,_.nodes,o),[_.nodes,_.requests,o]),recentEvents:(0,D.useMemo)(()=>ue(_.requests,_.compacts),[_.compacts,_.requests]),hasVisibleStats:(0,D.useMemo)(()=>xe(_),[_]),isLoading:f,isInitialLoading:f&&!u,hasBlockingError:!!(d&&!u),hasRecoverableError:!!(d&&u),errorMessage:d instanceof Error?d.message:`Unknown error`,refresh:(0,D.useCallback)(async()=>{await p()},[p]),handleRangeChange:(0,D.useCallback)(e=>{t(e)},[]),handleMetricChange:(0,D.useCallback)(e=>{a(e)},[]),handleSortKeyChange:(0,D.useCallback)(e=>{s(e)},[]),handleFilterChange:(0,D.useCallback)((e,t)=>{r(n=>({...n,[e]:t===`__all__`?null:t}))},[]),toggleExpandedEvent:(0,D.useCallback)(e=>{l(t=>t===e?null:e)},[])}}var Q=n();function Ce(){return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsx)(v,{children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-24 rounded-full skeleton-shimmer`}),(0,Q.jsx)(`div`,{className:`h-8 w-52 rounded-full skeleton-shimmer`})]}),(0,Q.jsx)(`div`,{className:`h-9 w-32 rounded-full skeleton-shimmer`})]})}),(0,Q.jsx)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Q.jsxs)(v,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-20 rounded-full skeleton-shimmer`}),(0,Q.jsx)(`div`,{className:`h-8 w-28 rounded-full skeleton-shimmer`}),(0,Q.jsx)(`div`,{className:`h-3 w-32 rounded-full skeleton-shimmer`})]},t))}),(0,Q.jsxs)(v,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-28 rounded-full skeleton-shimmer`}),(0,Q.jsx)(`div`,{className:`h-[220px] rounded-xl skeleton-shimmer`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading stats...`})]})]})}function we(){return(0,Q.jsxs)(v,{className:`flex min-h-[280px] flex-col items-center justify-center text-center`,children:[(0,Q.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl border border-border bg-accent/20 text-muted-foreground`,children:(0,Q.jsx)(l,{className:`size-5`})}),(0,Q.jsx)(`h2`,{className:`mt-5 text-xl font-medium text-foreground`,children:`No stats yet`})]})}function Te({message:e,onRetry:t}){return(0,Q.jsxs)(v,{className:`flex min-h-[280px] flex-col items-center justify-center text-center`,children:[(0,Q.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl border border-destructive/20 bg-destructive/10 text-destructive`,children:(0,Q.jsx)(s,{className:`size-5`})}),(0,Q.jsx)(`h2`,{className:`mt-5 text-xl font-medium text-foreground`,children:`Failed to load stats`}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-xl text-[13px] leading-6 text-muted-foreground`,children:e}),(0,Q.jsx)(_,{type:`button`,variant:`outline`,className:`mt-5 border-border bg-accent/20 text-foreground hover:bg-accent/35`,onClick:t,children:`Retry`})]})}function Ee({title:e,value:t,icon:n,accentClassName:r}){return(0,Q.jsxs)(v,{className:`flex flex-col gap-4 py-4 min-h-[140px] justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:h(`flex size-8 items-center justify-center rounded-md bg-accent/20 text-muted-foreground`,r),children:(0,Q.jsx)(n,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`div`,{className:`text-2xl font-semibold leading-none tracking-tight`,children:t})})]})}function De({buckets:e,metric:t}){let[n,r]=(0,D.useState)(()=>ve(e));if((0,D.useEffect)(()=>{r(ve(e))},[e]),e.length===0)return(0,Q.jsx)(`div`,{className:`flex h-[220px] items-center justify-center rounded-xl border border-border bg-card/30 text-[13px] text-muted-foreground`,children:`No trend data in the selected range.`});let i=e.map(e=>de(e,t)??0),a=t===`cache_hit_rate`?1:Math.max(1,...i,...e.map(e=>e.compactCount)),o=e[Math.min(n,e.length-1)]??e[0],s=1e3;s-36;let c=964/e.length;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-border bg-card/30 px-4 py-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:ge.find(e=>e.value===t)?.label}),(0,Q.jsxs)(`p`,{className:`mt-2 text-sm text-foreground`,children:[J(o.startMs),` to`,` `,J(o.endMs)]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-5 gap-y-2 text-[12px] text-muted-foreground sm:grid-cols-4`,children:[(0,Q.jsxs)(`span`,{children:[`Requests `,Y(o.requestCount)]}),(0,Q.jsxs)(`span`,{children:[`Failures `,Y(o.errorCount)]}),(0,Q.jsxs)(`span`,{children:[`Tokens `,Y(o.totalTokens)]}),(0,Q.jsxs)(`span`,{children:[`Compacts`,` `,Y(o.manualCompactCount+o.autoCompactCount)]}),(0,Q.jsxs)(`span`,{children:[`Cache Read `,Y(o.cacheRead)]}),(0,Q.jsxs)(`span`,{children:[`Cache Write `,Y(o.cacheWrite)]}),(0,Q.jsxs)(`span`,{children:[`Avg Latency `,X(o.avgLatencyMs)]}),(0,Q.jsxs)(`span`,{children:[`Hit Rate `,Z(o.cacheHitRate)]})]})]}),(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-card/25 p-4`,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 ${s} 220`,className:`h-[220px] w-full`,children:[Array.from({length:5}).map((e,t)=>{let n=20+146/4*t;return(0,Q.jsx)(`line`,{x1:18,y1:n,x2:s-18,y2:n,stroke:`var(--graph-grid)`,strokeWidth:`1`},t)}),e.map((e,n)=>{let r=de(e,t)??0,i=e.manualCompactCount+e.autoCompactCount,o=t===`compacts`?i/a*146:r/a*146,s=18+n*c+c*.15,l=166-o;if(t===`compacts`){let t=a>0?e.manualCompactCount/a*146:0,n=a>0?e.autoCompactCount/a*146:0;return(0,Q.jsxs)(`g`,{children:[(0,Q.jsx)(`rect`,{x:s,y:166-n,width:Math.max(8,c*.7),height:Math.max(n,e.autoCompactCount>0?2:0),rx:`8`,fill:`var(--primary)`,fillOpacity:`0.78`}),(0,Q.jsx)(`rect`,{x:s,y:166-n-t,width:Math.max(8,c*.7),height:Math.max(t,e.manualCompactCount>0?2:0),rx:`8`,fill:`var(--graph-status-idle)`,fillOpacity:`0.78`})]},e.startMs)}let u=t===`errors`?`var(--graph-status-error)`:t===`latency`?`var(--graph-status-idle)`:t===`cache_hit_rate`?`var(--graph-status-running)`:t===`cache_read`||t===`cache_write`?`var(--primary)`:`var(--foreground)`;return(0,Q.jsx)(`rect`,{x:s,y:l,width:Math.max(8,c*.7),height:Math.max(o,r>0?2:0),rx:`10`,fill:u,fillOpacity:t===`errors`?`0.82`:`0.78`},e.startMs)}),e.map((e,t)=>{let i=18+t*c;return(0,Q.jsxs)(`g`,{children:[n===t?(0,Q.jsx)(`rect`,{x:i,y:12,width:c,height:162,rx:`14`,fill:`var(--accent)`,fillOpacity:`0.35`}):null,(0,Q.jsx)(`rect`,{x:i,y:10,width:c,height:168,fill:`transparent`,onMouseEnter:()=>r(t)})]},`${e.startMs}-overlay`)}),e.map((t,n)=>n===0||n===e.length-1||n%Math.max(1,Math.floor(e.length/6))===0?(0,Q.jsx)(`text`,{x:18+n*c+c*.5,y:208,textAnchor:`middle`,fill:`var(--muted-foreground)`,fillOpacity:`0.8`,fontSize:`10`,children:t.label},`${t.startMs}-label`):null)]})})]})}function $({title:e,action:t}){return(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:e})}),t]})}function Oe({event:e}){if(e.kind===`compact`)return(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-xl border border-border bg-card/30 p-4 text-[12px] text-muted-foreground sm:grid-cols-2`,children:[(0,Q.jsxs)(`span`,{children:[`Trigger `,e.compact.trigger_type]}),(0,Q.jsxs)(`span`,{children:[`Duration `,X(e.compact.duration_ms)]}),(0,Q.jsxs)(`span`,{children:[`Result `,e.compact.result]}),(0,Q.jsxs)(`span`,{children:[`Error `,e.compact.error_summary||`None`]})]});let t=e.request.normalized_usage;return(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-card/30 p-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 text-[12px] text-muted-foreground sm:grid-cols-3`,children:[(0,Q.jsxs)(`span`,{children:[`Duration `,X(e.request.duration_ms)]}),(0,Q.jsxs)(`span`,{children:[`Retries `,Y(e.request.retry_count)]}),(0,Q.jsxs)(`span`,{children:[`Result `,e.request.result]}),(0,Q.jsxs)(`span`,{children:[`Input `,Y(t?.input_tokens??null)]}),(0,Q.jsxs)(`span`,{children:[`Output `,Y(t?.output_tokens??null)]}),(0,Q.jsxs)(`span`,{children:[`Total `,Y(t?.total_tokens??null)]}),(0,Q.jsxs)(`span`,{children:[`Cache Read `,Y(t?.cache_read_tokens??null)]}),(0,Q.jsxs)(`span`,{children:[`Cache Write `,Y(t?.cache_write_tokens??null)]}),(0,Q.jsxs)(`span`,{children:[`Cache Hit Rate`,` `,Z(typeof t?.cache_read_tokens==`number`&&typeof t?.input_tokens==`number`&&t.input_tokens>0?t.cache_read_tokens/t.input_tokens:null)]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Normalized Usage`}),(0,Q.jsx)(`pre`,{className:`max-h-[240px] overflow-auto rounded-xl border border-border bg-background/50 p-4 text-[11px] leading-6 text-foreground/75`,children:JSON.stringify(e.request.normalized_usage??null,null,2)})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Raw Usage`}),(0,Q.jsx)(`pre`,{className:`max-h-[240px] overflow-auto rounded-xl border border-border bg-background/50 p-4 text-[11px] leading-6 text-foreground/75`,children:JSON.stringify(e.request.raw_usage??null,null,2)})]})]})]})}function ke(){let{range:e,metric:t,sortKey:n,expandedEventId:l,filterOptions:g,effectiveFilters:y,overview:b,buckets:E,providerGroups:D,tabGroups:O,agentGroups:k,recentEvents:A,hasVisibleStats:j,isLoading:M,isInitialLoading:N,hasBlockingError:P,hasRecoverableError:F,errorMessage:I,refresh:L,handleRangeChange:R,handleMetricChange:z,handleSortKeyChange:B,handleFilterChange:V,toggleExpandedEvent:H}=Se(),U=[{title:`Active Workflows`,value:Y(b.activeTabs),icon:i},{title:`Running Agents`,value:Y(b.runningAgents),icon:p},{title:`LLM Requests`,value:Y(b.llmRequests),icon:f},{title:`Total Tokens`,value:Y(b.totalTokens),icon:u},{title:`Error Rate`,value:Z(b.errorRate),icon:o,accentClassName:`text-destructive`},{title:`Avg Latency`,value:X(b.avgLatencyMs),icon:a,accentClassName:`text-graph-status-idle`},...b.hasCacheUsage?[{title:`Cache Read`,value:Y(b.cacheRead),icon:d,accentClassName:`text-graph-status-running`},{title:`Cache Write`,value:Y(b.cacheWrite),icon:r,accentClassName:`text-primary`},{title:`Cache Hit Rate`,value:Z(b.cacheHitRate),icon:c,accentClassName:`text-graph-status-running`}]:[]];return(0,Q.jsx)(ne,{className:`min-h-0`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-border px-6 py-5`,children:[(0,Q.jsx)(te,{title:`Stats`,hint:`Review system-wide runtime observability here instead of a single task conversation.`,actions:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:K,children:`Range`}),(0,Q.jsxs)(T,{value:e,onValueChange:R,children:[(0,Q.jsx)(S,{className:`w-[120px] ${G}`,children:(0,Q.jsx)(x,{placeholder:`Range`})}),(0,Q.jsx)(C,{children:he.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(_,{type:`button`,variant:`outline`,className:`mt-5 border-border bg-accent/20 text-foreground hover:bg-accent/35`,onClick:()=>void L(),children:[(0,Q.jsx)(m,{className:h(`size-4`,M&&`animate-spin`)}),`Refresh`]})]}),className:`border-b-0 pb-0`}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`span`,{className:K,children:`Provider`}),(0,Q.jsxs)(T,{value:y.providerId??`__all__`,onValueChange:e=>V(`providerId`,e),children:[(0,Q.jsx)(S,{className:`w-full ${G}`,children:(0,Q.jsx)(x,{placeholder:`All Providers`})}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(w,{value:W,children:`All Providers`}),g.providers.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`span`,{className:K,children:`Model`}),(0,Q.jsxs)(T,{value:y.model??`__all__`,onValueChange:e=>V(`model`,e),children:[(0,Q.jsx)(S,{className:`w-full ${G}`,children:(0,Q.jsx)(x,{placeholder:`All Models`})}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(w,{value:W,children:`All Models`}),g.models.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`span`,{className:K,children:`Workflow`}),(0,Q.jsxs)(T,{value:y.tabId??`__all__`,onValueChange:e=>V(`tabId`,e),children:[(0,Q.jsx)(S,{className:`w-full ${G}`,children:(0,Q.jsx)(x,{placeholder:`All Workflows`})}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(w,{value:W,children:`All Workflows`}),g.tabs.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`span`,{className:K,children:`Agent`}),(0,Q.jsxs)(T,{value:y.agentId??`__all__`,onValueChange:e=>V(`agentId`,e),children:[(0,Q.jsx)(S,{className:`w-full ${G}`,children:(0,Q.jsx)(x,{placeholder:`All Agents`})}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(w,{value:W,children:`All Agents`}),g.agents.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))]})]})]})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:N?(0,Q.jsx)(Ce,{}):P?(0,Q.jsx)(Te,{message:I,onRetry:()=>void L()}):j?(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[F?(0,Q.jsx)(v,{className:`border-destructive/12 bg-destructive/6`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-xl border border-destructive/16 bg-destructive/10 text-destructive`,children:(0,Q.jsx)(s,{className:`size-4`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Stats refresh failed`}),(0,Q.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`Showing the last successful response. Retry when ready.`})]})]}),(0,Q.jsx)(_,{type:`button`,variant:`outline`,className:`border-border bg-accent/20 text-foreground hover:bg-accent/35`,onClick:()=>void L(),children:`Retry`})]})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:U.map(e=>(0,Q.jsx)(Ee,{title:e.title,value:e.value,icon:e.icon,accentClassName:e.accentClassName},e.title))}),(0,Q.jsxs)(v,{className:`overflow-hidden`,children:[(0,Q.jsx)($,{title:`Trend`,action:(0,Q.jsxs)(T,{value:t,onValueChange:z,children:[(0,Q.jsx)(S,{className:`w-[180px] ${G}`,children:(0,Q.jsx)(x,{placeholder:`Metric`})}),(0,Q.jsx)(C,{children:ge.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))})]})}),(0,Q.jsx)(De,{buckets:E,metric:t})]}),(0,Q.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,children:[(0,Q.jsxs)(v,{className:`overflow-hidden`,children:[(0,Q.jsx)($,{title:`By Provider / Model`}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:D.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 px-4 py-6 text-[13px] text-muted-foreground`,children:`No request data matches the current scope.`}):D.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-xl border border-border bg-card/30 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:e.providerLabel}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[12px] text-muted-foreground`,children:[`Requests `,Y(e.requestCount),` `,`· Errors `,Y(e.errorCount),` · Tokens `,Y(e.totalTokens),` · Avg `,X(e.avgLatencyMs),` · Retries `,Y(e.retryCount)]})]}),(0,Q.jsxs)(`div`,{className:`text-right text-[12px] text-muted-foreground`,children:[(0,Q.jsxs)(`p`,{children:[`Cache Read `,Y(e.cacheRead)]}),(0,Q.jsxs)(`p`,{children:[`Cache Write `,Y(e.cacheWrite)]}),(0,Q.jsxs)(`p`,{children:[`Hit Rate `,Z(e.cacheHitRate)]})]})]}),(0,Q.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.models.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-border bg-accent/15 px-3.5 py-3 text-[12px] text-muted-foreground md:grid-cols-[minmax(0,1.2fr)_repeat(6,minmax(0,0.8fr))]`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.model}),(0,Q.jsxs)(`span`,{children:[`Req `,Y(e.requestCount)]}),(0,Q.jsxs)(`span`,{children:[`Err `,Y(e.errorCount)]}),(0,Q.jsxs)(`span`,{children:[`Tok `,Y(e.totalTokens)]}),(0,Q.jsxs)(`span`,{children:[`Avg `,X(e.avgLatencyMs)]}),(0,Q.jsxs)(`span`,{children:[`Cache `,Y(e.cacheRead)]}),(0,Q.jsxs)(`span`,{children:[`Hit `,Z(e.cacheHitRate)]})]},e.key))})]},e.key))})]}),(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(v,{className:`overflow-hidden`,children:[(0,Q.jsx)($,{title:`By Workflow / Agent`,action:(0,Q.jsxs)(T,{value:n,onValueChange:B,children:[(0,Q.jsx)(S,{className:`w-[170px] ${G}`,children:(0,Q.jsx)(x,{placeholder:`Sort`})}),(0,Q.jsx)(C,{children:_e.map(e=>(0,Q.jsx)(w,{value:e.value,children:e.label},e.value))})]})}),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground/80`,children:`Tabs`}),O.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 px-4 py-6 text-[13px] text-muted-foreground`,children:`No matching tab aggregates.`}):O.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-border bg-card/30 px-4 py-3 text-[12px] text-muted-foreground md:grid-cols-[minmax(0,1.15fr)_repeat(6,minmax(0,0.75fr))]`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.tabTitle}),(0,Q.jsxs)(`span`,{children:[`Req `,Y(e.requestCount)]}),(0,Q.jsxs)(`span`,{children:[`Err `,Y(e.errorCount)]}),(0,Q.jsxs)(`span`,{children:[`Tok `,Y(e.totalTokens)]}),(0,Q.jsxs)(`span`,{children:[`Cmp `,Y(e.compactCount)]}),(0,Q.jsxs)(`span`,{children:[`Run `,Y(e.runningAgents)]}),(0,Q.jsxs)(`span`,{children:[`Hit `,Z(e.cacheHitRate)]})]},e.key))]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground/80`,children:`Agents`}),k.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 px-4 py-6 text-[13px] text-muted-foreground`,children:`No matching agent aggregates.`}):k.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-border bg-card/30 px-4 py-3 text-[12px] text-muted-foreground md:grid-cols-[minmax(0,1.1fr)_minmax(0,0.8fr)_repeat(5,minmax(0,0.72fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-medium text-foreground`,children:e.agentLabel}),(0,Q.jsxs)(`p`,{className:`truncate text-[11px] text-muted-foreground/80`,children:[e.roleName||`No role`,` ·`,` `,e.tabTitle]})]}),(0,Q.jsx)(`span`,{className:h(`inline-flex h-fit w-fit rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.12em]`,e.state?ee[e.state]:`border-border bg-accent/25 text-muted-foreground`),children:e.state||`unknown`}),(0,Q.jsxs)(`span`,{children:[`Req `,Y(e.requestCount)]}),(0,Q.jsxs)(`span`,{children:[`Err `,Y(e.errorCount)]}),(0,Q.jsxs)(`span`,{children:[`Tok `,Y(e.totalTokens)]}),(0,Q.jsxs)(`span`,{children:[`Avg `,X(e.avgLatencyMs)]}),(0,Q.jsxs)(`span`,{children:[`Cache `,Y(e.cacheRead)]}),(0,Q.jsxs)(`span`,{children:[`Hit `,Z(e.cacheHitRate)]})]},e.key))]})]})]})})]}),(0,Q.jsxs)(v,{className:`overflow-hidden`,children:[(0,Q.jsx)($,{title:`Recent Events`}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:A.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 px-4 py-6 text-[13px] text-muted-foreground`,children:`No recent events match the current scope.`}):A.map(e=>{let t=l===e.key,n=``;return n=e.kind===`compact`?`${e.compact.trigger_type} compact ${e.compact.result}`:e.kind===`request_error`?`Request failed${e.retryCount>0?` after ${e.retryCount} retries`:``}`:`Retried ${e.retryCount} time${e.retryCount===1?``:`s`}`,(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(_,{type:`button`,variant:`ghost`,className:`grid h-auto w-full gap-3 rounded-xl border border-border bg-card/30 px-4 py-3 text-left text-[12px] text-muted-foreground hover:bg-accent/20 hover:text-inherit md:grid-cols-[minmax(0,1fr)_minmax(0,1.05fr)_minmax(0,1.2fr)_minmax(0,1.2fr)_minmax(0,1.25fr)]`,onClick:()=>H(e.key),children:[(0,Q.jsx)(`span`,{className:`text-foreground/85`,children:J(e.endedAt)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.tabTitle}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.agentLabel}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[e.providerLabel,` / `,e.modelLabel]}),(0,Q.jsx)(`span`,{className:h(`truncate`,e.kind===`request_error`?`text-destructive`:e.kind===`compact`?`text-graph-status-idle`:`text-graph-status-running`),children:n})]}),t?(0,Q.jsx)(Oe,{event:e}):null]},e.key)})})]})]}):(0,Q.jsx)(we,{})})]})})}export{ke as StatsPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{B as r,Ct as i,Ft as a,H as o,J as s,Lt as c,Nt as l,Pt as u,Q as d,St as f,Tt as p,U as m,Wt as h,Z as g,_t as _,ct as v,et as y,jt as b,kt as x,rn as S}from"./ui-vendor-Dg9NNnWX.js";import{a as C,t as w}from"./shared-CMxbpLeQ.js";import{Z as T}from"./index-CL1ALZ3r.js";import{n as E,o as D,t as O}from"./PageScaffold-D4jO9ooX.js";async function k(){return w(`/api/tools`,{errorMessage:`Failed to fetch tools`,fallback:[],map:e=>e?.tools??[]})}var A=e(t(),1),j=n(),M=`inline-flex h-5 shrink-0 items-center rounded-full border border-border bg-accent/20 px-2.5 text-[11px] font-medium text-muted-foreground`,N={send:y,idle:h,sleep:h,todo:f,contacts:_,list_tools:r,list_roles:o,list_workflows:p,exec:s,read:u,edit:a,fetch:x,create_workflow:l,create_agent:b,connect:i,set_permissions:g,manage_providers:v,manage_roles:m,manage_settings:d,manage_prompts:c};function P({expanded:e,onToggle:t,tool:n}){let i=N[n.name]??r;return(0,j.jsxs)(`div`,{onClick:t,title:n.description,className:C(`group cursor-pointer rounded-xl border border-border bg-card/30 p-5 shadow-none transition-colors duration-300 hover:border-ring/25 hover:bg-accent/20 hover:shadow-sm`,e&&`border-border bg-accent/20 shadow-sm`),children:[(0,j.jsx)(`div`,{className:`mb-4 flex size-10 items-center justify-center rounded-xl border border-border bg-accent/25 transition-colors group-hover:bg-accent/40`,children:(0,j.jsx)(i,{className:`size-4.5 text-foreground/80`})}),(0,j.jsx)(`code`,{className:`block text-[13px] font-mono font-medium text-foreground`,children:n.name}),(0,j.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground/75`,children:n.source===`mcp`?`MCP · ${n.server_name??`unknown`}`:`Builtin`}),(0,j.jsx)(`p`,{className:`mt-2 text-[12px] leading-relaxed text-muted-foreground`,children:n.description}),(0,j.jsx)(T,{initial:!1,children:e?(0,j.jsx)(S.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.22,1,.36,1]},className:`overflow-hidden`,onClick:e=>e.stopPropagation(),children:(0,j.jsxs)(`div`,{className:`mt-4 border-t border-border pt-4`,children:[n.source===`mcp`?(0,j.jsxs)(`div`,{className:`mb-4 space-y-2 text-[11px] text-muted-foreground`,children:[(0,j.jsxs)(`div`,{children:[`Raw Tool Name`,` `,(0,j.jsx)(`code`,{className:`font-mono text-foreground/82`,children:n.tool_name??`unknown`})]}),(0,j.jsxs)(`div`,{children:[`Fully Qualified ID`,` `,(0,j.jsx)(`code`,{className:`font-mono text-foreground/82`,children:n.fully_qualified_id??n.name})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n.read_only_hint?(0,j.jsx)(`span`,{className:`rounded-full border border-primary/15 bg-primary/10 px-2 py-1 text-[10px] text-primary`,children:`readOnly`}):null,n.destructive_hint?(0,j.jsx)(`span`,{className:`rounded-full border border-destructive/20 bg-destructive/10 px-2 py-1 text-[10px] text-destructive`,children:`destructive`}):null,n.open_world_hint?(0,j.jsx)(`span`,{className:`rounded-full border border-graph-status-idle/20 bg-graph-status-idle/[0.12] px-2 py-1 text-[10px] text-graph-status-idle`,children:`openWorld`}):null]})]}):null,(0,j.jsx)(`p`,{className:`mb-2 text-[10px] font-medium text-muted-foreground/75`,children:`Parameters`}),(0,j.jsx)(`pre`,{className:`max-h-48 select-text overflow-auto rounded-xl border border-border bg-background/50 p-3.5 text-[11px] font-mono text-foreground/70 scrollbar-none`,children:JSON.stringify(n.parameters??{},null,2)})]})}):null})]})}function F(){let{data:e=[],isLoading:t}=D(`tools`,k),[n,i]=(0,A.useState)(new Set),a=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,j.jsx)(O,{children:(0,j.jsxs)(`div`,{className:`flex h-full flex-col px-8 pt-6`,children:[(0,j.jsx)(E,{title:`Tools`}),(0,j.jsxs)(`div`,{className:`mb-6 mt-6 flex items-center justify-between gap-4`,children:[(0,j.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Built-in and connected MCP tools appear here.`}),(0,j.jsxs)(`span`,{className:M,children:[e.length,` tools`]})]}),(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2 scrollbar-none`,children:t?(0,j.jsx)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-3`,children:[...[,,,,,,]].map((e,t)=>(0,j.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-border bg-accent/20`},t))}):e.length===0?(0,j.jsxs)(S.div,{initial:{opacity:0},animate:{opacity:1},className:`flex h-full flex-col items-center justify-center text-center`,children:[(0,j.jsx)(`div`,{className:`flex size-14 items-center justify-center rounded-xl border border-border bg-accent/20 shadow-sm`,children:(0,j.jsx)(r,{className:`size-6 text-muted-foreground`})}),(0,j.jsx)(`h3`,{className:`mt-5 text-[15px] font-medium text-foreground`,children:`No Tools Available`}),(0,j.jsx)(`p`,{className:`mt-1.5 text-[13px] text-muted-foreground`,children:`Connect an MCP server to expand this catalog.`})]}):(0,j.jsx)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-3 pb-8`,children:e.map((e,t)=>(0,j.jsx)(S.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:t*.03},children:(0,j.jsx)(P,{tool:e,expanded:n.has(e.name),onToggle:()=>a(e.name)})},e.name))})})]})})}export{F as ToolsPage};
@@ -0,0 +1 @@
1
+ import{l as e}from"./graph-vendor-DRq_-6fV.js";import{z as t}from"./ui-vendor-Dg9NNnWX.js";import{a as n}from"./shared-CMxbpLeQ.js";import{J as r}from"./index-CL1ALZ3r.js";import{a as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./dialog-BeGSweF6.js";var d=e();function f({open:e,onOpenChange:f,title:p,children:m,footer:h,className:g}){return(0,d.jsx)(u,{open:e,onOpenChange:f,children:(0,d.jsx)(c,{className:n(`flex max-h-[calc(100svh-2rem)] flex-col p-0`,g),children:(0,d.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden p-6`,children:[(0,d.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-gradient-to-b from-foreground/[0.04] to-transparent opacity-50`}),(0,d.jsx)(o,{asChild:!0,children:(0,d.jsx)(r,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close dialog`,className:`absolute right-4 top-4 z-20 size-7 rounded-md bg-accent/45 text-muted-foreground hover:bg-accent/65 hover:text-accent-foreground`,children:(0,d.jsx)(t,{className:`size-3.5`})})}),(0,d.jsxs)(s,{className:`relative z-10 shrink-0 pr-8`,children:[(0,d.jsx)(l,{className:`text-[1.1rem] font-medium text-foreground`,children:p}),(0,d.jsx)(a,{className:`sr-only`,children:p})]}),(0,d.jsx)(`div`,{className:`relative z-10 mt-6 min-h-0 flex-1 space-y-4 overflow-y-auto pr-1 scrollbar-none`,"data-testid":`workspace-command-dialog-body`,children:m}),(0,d.jsx)(i,{className:`relative z-10 mt-6 shrink-0 border-t border-border pt-4`,children:h})]})})})}function p({label:e,hint:t,children:n}){return(0,d.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,d.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,d.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:e}),t?(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}):null]}),n]})}function m({children:e}){return(0,d.jsx)(`div`,{className:`rounded-lg border border-border bg-accent/35 px-3.5 py-2.5 text-xs text-muted-foreground`,children:e})}export{p as n,m as r,f as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{d as t,l as n}from"./graph-vendor-DRq_-6fV.js";import{$t as r,B as i,Ht as a,J as o,Jt as s,Kt as c,Ot as l,R as u,V as d,X as f,Xt as p,Y as m,Z as h,en as g,et as _,mt as v,pt as y,rn as b,rt as x,tn as S,vt as C,xt as w,z as T}from"./ui-vendor-Dg9NNnWX.js";import{a as E,t as D}from"./shared-CMxbpLeQ.js";import{F as O,I as k,J as A,K as ee,M as j,N as M,P as N,Z as P,_ as F,b as I,g as L,h as te,m as ne,p as re,q as ie,s as R,v as ae,x as z}from"./index-CL1ALZ3r.js";import{n as B,t as oe}from"./markdown-vendor-DVdy_w12.js";import{t as se}from"./badge-74-3jsCg.js";import{t as V}from"./constants-XUzFf6i1.js";function ce(e){return`/api/image-assets/${encodeURIComponent(e)}`}async function le(e){let t=new FormData;return t.append(`file`,e),D(`/api/image-assets`,{method:`POST`,body:t,errorMessage:`Failed to upload image`})}var H=e(t(),1),U=n();function ue({assetId:e,alt:t,mimeType:n,width:r,height:i,compact:a=!1}){let{openImage:o}=k(),s=ce(e),c=typeof r==`number`&&r>0&&typeof i==`number`&&i>0?`${r} / ${i}`:void 0,l=`${n||`image asset`}${r&&i?` · ${r}x${i}`:``}`;return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(A,{type:`button`,variant:`ghost`,onClick:()=>o({src:s,alt:t,meta:l,width:r,height:i}),className:E(`group h-auto w-full flex-col items-stretch overflow-hidden rounded-xl border border-border bg-accent/20 p-0 text-left transition-colors hover:bg-accent/30 hover:text-inherit`,a?`max-w-[240px]`:`max-w-[360px]`),children:[(0,U.jsx)(`div`,{style:c?{aspectRatio:c}:void 0,className:E(`relative overflow-hidden bg-background/45`,a?`min-h-[132px]`:`min-h-[180px]`),children:(0,U.jsx)(`img`,{alt:t||`Image`,className:`h-full w-full object-cover`,loading:`lazy`,src:s})}),(0,U.jsxs)(`div`,{className:`space-y-1 px-3 py-2.5`,children:[(0,U.jsx)(`div`,{className:`text-[12px] font-medium text-foreground`,children:t||`Image`}),(0,U.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:l})]})]})})}function W({content:e,className:t}){return(0,U.jsx)(`div`,{className:E(`min-w-0 max-w-full select-text overflow-hidden break-words [overflow-wrap:anywhere]`,t),children:(0,U.jsx)(B,{remarkPlugins:[oe],components:{p:({children:e})=>(0,U.jsx)(`p`,{className:`mb-1.5 last:mb-0 whitespace-pre-wrap`,children:e}),code:({children:e,className:t})=>t?(0,U.jsx)(`code`,{className:`block font-mono text-[0.9em] text-foreground/80`,children:e}):(0,U.jsx)(`code`,{className:`rounded bg-surface-3 px-1 py-0.5 font-mono text-[0.9em] text-foreground/90 break-all`,children:e}),pre:({children:e})=>(0,U.jsx)(`pre`,{className:`mb-1.5 max-w-full overflow-x-auto rounded bg-surface-1 p-2 text-[0.9em] leading-relaxed`,children:e}),a:({href:e,children:t})=>(0,U.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline hover:text-primary/80`,children:t}),ul:({children:e})=>(0,U.jsx)(`ul`,{className:`mb-1.5 list-disc pl-4 space-y-0.5`,children:e}),ol:({children:e})=>(0,U.jsx)(`ol`,{className:`mb-1.5 list-decimal pl-4 space-y-0.5`,children:e}),li:({children:e})=>(0,U.jsx)(`li`,{className:`leading-relaxed`,children:e}),strong:({children:e})=>(0,U.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,U.jsx)(`em`,{className:`italic text-foreground/80`,children:e}),blockquote:({children:e})=>(0,U.jsx)(`blockquote`,{className:`mb-1.5 border-l-2 border-muted-foreground pl-3 text-muted-foreground italic`,children:e}),table:({children:e})=>(0,U.jsx)(`div`,{className:`mb-1.5 overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:e})}),th:({children:e})=>(0,U.jsx)(`th`,{className:`border border-border bg-surface-2 px-2 py-1 text-left font-semibold text-foreground`,children:e}),td:({children:e})=>(0,U.jsx)(`td`,{className:`border border-border px-2 py-1 text-foreground/80`,children:e}),h1:({children:e})=>(0,U.jsx)(`h1`,{className:`mb-1.5 text-base font-bold text-foreground`,children:e}),h2:({children:e})=>(0,U.jsx)(`h2`,{className:`mb-1.5 text-sm font-bold text-foreground`,children:e}),h3:({children:e})=>(0,U.jsx)(`h3`,{className:`mb-1.5 text-xs font-bold text-foreground/90`,children:e})},children:e})})}function G(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();if(!t||!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{return JSON.stringify(JSON.parse(t),null,4)}catch{return null}}if(typeof e==`object`)try{return JSON.stringify(e,null,4)}catch{return String(e)}return null}function K({content:e,layout:t=`parts-order`,parts:n,streaming:r,markdownClassName:i,preClassName:a}){let o=z(n,e),s=o.some(e=>e.type===`image`),c=I(o,e),l=G(c);if(t===`human-attachments-top`&&s){let e=o.filter(e=>e.type===`text`);return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:o.filter(e=>e.type===`image`).map((e,t)=>(0,U.jsx)(ue,{alt:e.alt,assetId:e.asset_id,compact:!0,height:e.height,mimeType:e.mime_type,width:e.width},`${t}-attachment-${e.asset_id}`))}),e.length>0?(0,U.jsx)(K,{content:I(e),markdownClassName:i,preClassName:a,parts:e,streaming:r}):null]})}return l?(0,U.jsx)(`pre`,{className:E(`select-text whitespace-pre-wrap break-words rounded-xl border border-border bg-background/40 px-3.5 py-3 text-[11px] font-mono leading-relaxed text-foreground/80`,a),children:(0,U.jsx)(q,{text:l,streaming:r})}):o.length>0&&s?(0,U.jsx)(`div`,{className:`space-y-3`,children:o.map((e,t)=>e.type===`text`?(0,U.jsx)(K,{content:e.text,markdownClassName:i,preClassName:a},`${t}-text`):(0,U.jsx)(ue,{alt:e.alt,assetId:e.asset_id,height:e.height,mimeType:e.mime_type,width:e.width},`${t}-image-${e.asset_id}`))}):r?(0,U.jsx)(`div`,{className:E(`min-w-0 select-text whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,i),children:(0,U.jsx)(q,{text:c,streaming:!0})}):(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(W,{content:c,className:i})})}function q({text:e,streaming:t}){return(0,U.jsxs)(U.Fragment,{children:[e,t?(0,U.jsx)(`span`,{className:`streaming-cursor`}):null]})}var J=[{name:`/clear`,description:`Clear the current Assistant chat history.`,usage:`/clear`},{name:`/compact`,description:`Compact the current execution context.`,usage:`/compact [focus]`},{name:`/help`,description:`Show the built-in Assistant commands and usage.`,usage:`/help`}],de=/^\/\S*/;function Y(e){let t=e.trimStart(),n=e.slice(0,e.length-t.length),r=t.match(de)?.[0]??`/`;return{leadingWhitespace:n,trimmedStart:t,token:r,suffix:t.slice(r.length)}}function fe(e,t){return t<=0?0:Math.min(e,t-1)}function pe(e){let{trimmedStart:t,token:n}=Y(e);return t.startsWith(`/`)?{filtered:n===`/`?J:J.filter(e=>e.name.startsWith(n)),isCommandInput:!0,token:n}:{filtered:[],isCommandInput:!1,token:``}}function X(e,t,n){let r=t.token===n?fe(t.index,e.length):0;return{selectedCommand:e[Math.min(r,Math.max(e.length-1,0))]??null,selectedCommandIndex:r}}function me(e,t,n,r){if(e.length===0)return{index:0,token:n};let{selectedCommandIndex:i}=X(e,t,n);return{index:(i+r+e.length)%e.length,token:n}}function he(e,t){let{trimmedStart:n,token:r}=Y(e);return r===t&&(n===t||n.startsWith(`${t} `))}function ge(e,t){let{leadingWhitespace:n,suffix:r}=Y(e);return r?`${n}${t.name}${r.startsWith(` `)?r:` ${r}`}`:`${n}${t.name} `}function _e({busy:e=!1,commandsEnabled:t=!0,disabled:n,images:r=[],imageInputEnabled:i=!0,input:a,onAddImages:o=()=>{},onChange:s,onNavigateHistory:c,onKeyDown:u,onRemoveImage:d=()=>{},onSend:f,onStop:p,overlay:h=!1,targetLabel:g=`Assistant`,stopping:_=!1,suppressCommandNavigation:v=!1,variant:y}){let b=y===`workspace`,x=y===`page`,C=(0,H.useRef)(null),w=(0,H.useRef)(null),T=e?_?`Stopping...`:`Stop`:`Send`,D=e?_||!p:n,{filtered:O,isCommandInput:k,token:j}=t?pe(a):{filtered:[],isCommandInput:!1,token:``},[M,N]=(0,H.useState)({index:0,token:``}),[P,F]=(0,H.useState)(null),I=t&&r.length===0&&k&&P!==j,{selectedCommand:L,selectedCommandIndex:te}=X(O,M,j);(0,H.useLayoutEffect)(()=>{let e=C.current;if(!e)return;let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,r=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0,a=n+r+i,o=n*(b?8:7)+r+i;e.style.height=`0px`;let s=Math.min(Math.max(e.scrollHeight,a),o);e.style.height=`${s}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`},[a,b]);let ne=e=>{let n=t?pe(e):{isCommandInput:!1,token:``};n.isCommandInput?n.token!==j&&(N({index:0,token:n.token}),P&&P!==n.token&&F(null)):(F(null),N({index:0,token:``})),s(e)},re=e=>{s(ge(a,e)),N({index:0,token:e.name}),F(null),C.current?.focus()},R=()=>{F(null),N({index:0,token:``})};return(0,U.jsxs)(`div`,{className:E(h?`w-full pointer-events-auto`:E(`border-t border-border`,b?`p-2.5`:`px-3.5 py-2.5`)),children:[I?(0,U.jsx)(`div`,{role:`listbox`,"aria-label":`Assistant commands`,className:E(`pointer-events-auto mb-2 overflow-hidden rounded-xl border`,b?`border-border bg-surface-overlay shadow-sm`:`border-border bg-popover shadow-sm`),children:O.length>0?O.map((e,t)=>{let n=t===te;return(0,U.jsxs)(A,{type:`button`,variant:`ghost`,role:`option`,"aria-selected":n,onMouseDown:t=>{t.preventDefault(),re(e)},className:E(`h-auto w-full items-start justify-start gap-3 rounded-none px-3 py-2.5 text-left whitespace-normal transition-colors`,n?`bg-accent/60 hover:bg-accent/60`:`hover:bg-accent/35`),children:[(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded-full border border-border bg-accent/45 px-2 py-0.5 font-mono text-[11px] text-foreground`,children:e.name}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block text-[12px] font-medium text-foreground`,children:e.description}),(0,U.jsx)(`span`,{className:`mt-1 block font-mono text-[11px] text-muted-foreground`,children:e.usage})]})]},e.name)}):(0,U.jsx)(`div`,{className:`px-3 py-3 text-[12px] text-muted-foreground`,children:`No matching commands.`})}):null,(0,U.jsxs)(`div`,{className:E(`border transition-[border-color,background-color,box-shadow] duration-200`,b?`rounded-md border-border bg-background/30 px-2 py-1 shadow-sm hover:border-ring/35 focus-within:border-ring/45 focus-within:ring-[3px] focus-within:ring-ring/35`:x?`rounded-[20px] border-border bg-surface-2 px-3 py-2 shadow-sm hover:border-ring/30 focus-within:border-ring/40 focus-within:ring-[3px] focus-within:ring-ring/30`:`rounded-md border-border bg-surface-2/90 px-2 py-1 shadow-sm hover:border-ring/30 focus-within:border-ring/40 focus-within:ring-[3px] focus-within:ring-ring/30`),children:[r.length>0?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2 border-b border-border px-0.5 py-2`,children:r.map(e=>(0,U.jsx)(ye,{image:e,onRemove:()=>d(e.id)},e.id))}):null,(0,U.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1`,children:[(0,U.jsx)(ie,{ref:w,accept:`image/png,image/jpeg,image/gif,image/webp`,className:`hidden`,multiple:!0,onChange:e=>{e.target.files&&e.target.files.length>0&&(R(),o(e.target.files)),e.currentTarget.value=``},type:`file`}),(0,U.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":i?`Add images`:`Current model does not support image input`,disabled:!i,onClick:()=>w.current?.click(),className:E(`shrink-0 rounded-full transition-colors disabled:opacity-35`,i?`bg-accent/55 text-foreground hover:bg-accent`:`bg-accent/20 text-muted-foreground`),children:(0,U.jsx)(l,{className:`size-4`})}),(0,U.jsx)(ee,{ref:C,value:a,onChange:e=>ne(e.target.value),onKeyDown:e=>{if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&c&&c(e.key===`ArrowUp`?-1:1,{start:e.currentTarget.selectionStart,end:e.currentTarget.selectionEnd})){e.preventDefault();return}if(v&&I&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){u(e);return}if(I){let t=O.length>0&&L&&!he(a,L.name)?L:null;if(e.key===`Escape`){e.preventDefault(),F(j);return}if(O.length>0&&e.key===`ArrowDown`){e.preventDefault(),N(me(O,M,j,1));return}if(O.length>0&&e.key===`ArrowUp`){e.preventDefault(),N(me(O,M,j,-1));return}if(t&&e.key===`Tab`&&!e.shiftKey){e.preventDefault(),re(t);return}if(t&&e.key===`Enter`&&!e.shiftKey){e.preventDefault(),re(t);return}}u(e)},onPaste:e=>{let t=ve(e.clipboardData?.items);t.length===0||!i||(e.preventDefault(),R(),o(t))},placeholder:t?`Message ${g} or type / for commands`:`Message ${g}`,rows:1,className:E(`min-h-5 w-full resize-none self-center border-0 bg-transparent px-0.5 py-0 text-[13px] leading-5 text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0`,`rounded-sm`)}),(0,U.jsxs)(A,{type:`button`,variant:b&&!e?`default`:`ghost`,size:b?`sm`:`icon-sm`,onClick:e?p:f,disabled:D,"aria-label":e?`Stop ${g}`:`Send ${g} message`,className:E(`shrink-0 rounded-full transition-all duration-300 active:scale-[0.96] disabled:opacity-30`,b?`h-8 gap-1.5 px-3.5`:`bg-accent/70 p-0 text-foreground hover:bg-accent`,e?`bg-destructive/18 text-destructive hover:bg-destructive/24`:b?`bg-primary text-primary-foreground hover:bg-primary/90`:``),children:[e?(0,U.jsx)(m,{className:`size-3.5 fill-current`,strokeWidth:2.4}):(0,U.jsx)(S,{className:`size-4`,strokeWidth:2.5}),b?(0,U.jsx)(`span`,{className:`text-[11px] font-medium`,children:T}):null]})]})]}),i?null:(0,U.jsx)(`div`,{className:`px-1.5 pt-2 text-[11px] text-muted-foreground`,children:`Current model does not support image input.`})]})}function ve(e){return e?Array.from(e).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).flatMap(e=>{let t=e.getAsFile();return t?[t]:[]}):[]}function ye({image:e,onRemove:t}){let{openImage:n}=k(),r=e.status===`uploading`?`Uploading...`:e.width&&e.height?`${e.width}x${e.height}`:`Ready`;return(0,U.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border bg-background/35 transition-colors hover:border-ring/35`,children:[(0,U.jsxs)(A,{"aria-label":`Preview ${e.name}`,type:`button`,variant:`ghost`,className:`h-auto w-auto items-start justify-start rounded-none p-0 text-left hover:bg-transparent hover:text-inherit`,onClick:()=>n({src:e.previewUrl,alt:e.name,meta:r,width:e.width,height:e.height}),children:[(0,U.jsx)(`img`,{alt:e.name,className:`h-20 w-20 object-cover`,src:e.previewUrl}),(0,U.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-background/80 px-2 py-1 text-[10px] text-foreground/84`,children:[(0,U.jsx)(`div`,{className:`truncate`,children:e.name}),(0,U.jsx)(`div`,{className:`text-muted-foreground`,children:r})]})]}),(0,U.jsx)(A,{"aria-label":`Remove ${e.name}`,type:`button`,variant:`ghost`,size:`icon-xs`,className:`absolute right-1 top-1 z-10 rounded-full bg-background/72 text-muted-foreground hover:bg-background/90 hover:text-foreground`,onClick:t,children:(0,U.jsx)(T,{className:`size-3.5`})})]})}function Z({text:e,className:t,iconClassName:n,copiedClassName:r}){let[i,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(!0);return(0,H.useEffect)(()=>()=>{c.current=!1,s.current&&clearTimeout(s.current)},[]),(0,U.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{c.current&&(o(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{c.current&&o(!1)},1500))})},"aria-label":`Copy`,className:E(`size-5 rounded p-0.5 text-muted-foreground opacity-0 transition-all hover:bg-accent/45 hover:text-foreground group-hover:opacity-100`,t),title:`Copy`,children:i?(0,U.jsx)(p,{className:E(`size-3 text-foreground`,r)}):(0,U.jsx)(a,{className:E(`size-3`,n)})})}var be=(0,H.memo)(function({allowHumanMessageRetry:e=!0,bottomInset:t=0,scrollRef:n,items:r,nodes:i,onRetryHumanMessage:a,onScroll:o,retryImageInputEnabled:s=!0,retryingMessageId:c=null,runningHint:l=null,variant:u}){let d=u===`workspace`,f=u===`floating`,p=u===`page`,m=d?14:16,h=r.filter(e=>e.type!==`SystemEntry`&&e.type!==`StateEntry`);return(0,U.jsxs)(`div`,{ref:n,onScroll:o,style:{paddingBottom:`${m+t}px`,scrollPaddingBottom:`${m+t}px`},className:E(`flex-1 space-y-2.5 overflow-y-auto`,d?`px-3 pt-3`:`px-3.5 pt-3.5`,p?`px-4 pt-6 space-y-6`:``),children:[h.length===0&&!l&&(d?(0,U.jsx)(Ne,{}):(0,U.jsx)(Pe,{floating:f,page:p})),h.map((t,n)=>(0,U.jsx)(`div`,{className:E(`[content-visibility:auto] [contain-intrinsic-size:auto_100px]`,p?`mx-auto w-full max-w-3xl`:``),children:(0,U.jsx)(Se,{allowHumanMessageRetry:e,item:t,nodes:i,onRetryHumanMessage:a,retryImageInputEnabled:s,retryingMessageId:c,variant:u})},Me(t,n))),l?(0,U.jsx)(`div`,{className:E(p?`mx-auto w-full max-w-3xl`:``),children:(0,U.jsx)(xe,{label:l.label,toolName:l.toolName,variant:u})}):null]})});function xe({label:e,toolName:t,variant:n}){return(0,U.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,U.jsxs)(`div`,{className:E(`inline-flex max-w-full items-center gap-2 rounded-full border px-3 py-1.5 text-[11px] text-muted-foreground/82`,n===`workspace`?`border-border bg-accent/25`:`border-border bg-accent/20`),children:[(0,U.jsx)(`span`,{className:`flex items-center gap-1.5`,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-muted-foreground/80`,style:{animationDelay:`${e*140}ms`}},e))}),(0,U.jsx)(`span`,{children:e}),t?(0,U.jsx)(`span`,{className:`truncate rounded-full border border-border bg-background/40 px-2 py-0.5 font-mono text-[10px] text-foreground/80`,children:t}):null]})})}var Se=(0,H.memo)(function({allowHumanMessageRetry:e,item:t,nodes:n,onRetryHumanMessage:r,retryImageInputEnabled:i,retryingMessageId:a,variant:o}){if(t.type===`PendingHumanMessage`)return(0,U.jsx)(Ce,{content:t.content,parts:t.parts,retrying:!1,variant:o,pending:!0});switch(t.type){case`ReceivedMessage`:if(z(t.parts,t.content).length===0)return null;if(t.from_id===`human`){let n=z(t.parts,t.content).some(e=>e.type===`image`)&&!i;return(0,U.jsx)(Ce,{allowRetry:e,content:I(t.parts,t.content),retryDisabled:n,retryDisabledReason:n?`Current model does not support image input`:void 0,messageId:t.message_id??null,onRetry:t.message_id&&r&&!n?()=>r(t.message_id):void 0,parts:t.parts,retrying:a===t.message_id,variant:o})}return(0,U.jsx)(Te,{content:I(t.parts,t.content),parts:t.parts,icon:(0,U.jsx)(C,{className:`size-3.5 text-foreground/68`}),label:`From ${R(t.from_id??``,n)}`,tone:`received`,streaming:t.streaming,variant:o});case`AssistantText`:return z(t.parts,t.content).length===0?null:(0,U.jsx)(we,{content:I(t.parts,t.content),parts:t.parts,streaming:t.streaming});case`SentMessage`:return z(t.parts,t.content).length===0?null:(0,U.jsx)(Te,{content:I(t.parts,t.content),parts:t.parts,icon:(0,U.jsx)(_,{className:`size-3.5 text-foreground/58`}),label:`To ${(t.to_id?[t.to_id]:(t.to_ids??[]).filter(e=>!!e)).map(e=>R(e,n)).join(`, `)||`Unknown`}`,tone:`sent`,streaming:t.streaming,variant:o});case`AssistantThinking`:return(0,U.jsx)(Ee,{item:t,variant:o});case`ToolCall`:return(0,U.jsx)(De,{item:t,variant:o});case`CommandResultEntry`:return(0,U.jsx)(Oe,{item:t,variant:o});case`ErrorEntry`:return(0,U.jsx)(ke,{content:t.content??``,variant:o});default:return null}});function Ce({allowRetry:e=!0,content:t,messageId:n,onRetry:r,parts:i,retryDisabled:a,retryDisabledReason:o,retrying:s,variant:c,pending:l=!1}){let u=c===`workspace`,d=e&&!l&&!!n&&(!!r||a);return(0,U.jsxs)(`div`,{className:`group mt-2 flex min-w-0 flex-col items-end`,children:[(0,U.jsx)(`div`,{className:E(`min-w-0 overflow-hidden px-2.5 py-1.5 text-[13px] [overflow-wrap:anywhere]`,u?`max-w-[84%] rounded-lg border border-border bg-accent/80 text-accent-foreground`:`max-w-[80%] rounded-lg border border-border bg-accent/65 text-accent-foreground`,l&&`opacity-80`),children:(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,U.jsx)(K,{content:t,layout:`human-attachments-top`,parts:i,markdownClassName:`text-sm text-accent-foreground`,preClassName:`text-accent-foreground/90`}),l?(0,U.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-accent/70 px-2 py-0.5 text-[10px] font-medium text-accent-foreground`,children:[(0,U.jsx)(w,{className:`size-3 animate-spin`}),`Sending`]}):null]})}),(0,U.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,U.jsx)(Z,{text:t}),d?(0,U.jsxs)(A,{type:`button`,variant:`ghost`,size:`xs`,onClick:r,disabled:s||a,title:o,className:E(`h-auto rounded-full border border-border px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-accent/45 hover:text-foreground disabled:opacity-45`,u?`bg-accent/35`:`bg-accent/25`),children:[s?(0,U.jsx)(w,{className:`size-3 animate-spin`}):(0,U.jsx)(x,{className:`size-3`}),(0,U.jsx)(`span`,{children:s?`Retrying...`:`Retry`})]}):null]})]})}function we({content:e,parts:t,streaming:n}){return(0,U.jsxs)(`div`,{className:`group min-w-0 w-full`,children:[(0,U.jsx)(K,{content:e,parts:t,streaming:n,markdownClassName:`text-sm text-foreground`,preClassName:`text-foreground/90`}),(0,U.jsx)(`div`,{className:`mt-1 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,U.jsx)(Z,{text:e})})]})}function Te({content:e,parts:t,icon:n,label:r,tone:i,streaming:a,variant:o}){let c=o===`workspace`,[l,u]=(0,H.useState)(!!a);return(0,U.jsxs)(`div`,{className:E(`min-w-0 w-full px-2 py-1.5`,c?`border-l border-border pl-3`:`rounded-lg`,i===`received`&&`border-border bg-accent/20`,i===`sent`&&`border-border bg-background/24`),children:[(0,U.jsxs)(`div`,{"aria-expanded":l,role:`button`,tabIndex:0,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},className:`flex w-full items-center gap-2 text-left`,children:[(0,U.jsx)(`span`,{className:`flex size-5 shrink-0 translate-y-px items-center justify-center text-current`,children:n}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-semibold leading-none text-foreground/88`,children:r}),(0,U.jsx)(`span`,{className:`ml-auto`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)(Z,{text:e})}),a?(0,U.jsxs)(`span`,{className:`inline-flex size-5 items-center justify-center`,children:[(0,U.jsxs)(`span`,{className:`relative flex size-2.5 items-center justify-center`,children:[(0,U.jsx)(`span`,{className:`absolute inline-flex size-2.5 animate-ping rounded-full bg-ring/28`}),(0,U.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-ring/82`})]}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Live`})]}):null,(0,U.jsx)(s,{className:E(`size-4 shrink-0 text-muted-foreground transition-transform`,l&&`rotate-90`)})]}),l?(0,U.jsx)(`div`,{className:`mt-2 min-w-0`,children:(0,U.jsx)(K,{content:e,parts:t,streaming:a,markdownClassName:`text-[12px] text-foreground/78`,preClassName:`text-foreground/74`})}):null]})}function Ee({item:e,variant:t}){return(0,U.jsx)(Ae,{label:`Thinking`,icon:(0,U.jsx)(r,{className:`size-3.5 text-foreground/72`}),tone:`thinking`,streaming:e.streaming,variant:t,defaultOpen:e.streaming??!1,children:(0,U.jsx)(K,{content:e.content,streaming:e.streaming,markdownClassName:`text-[13px] text-foreground/80`,preClassName:`text-foreground/75`})})}function De({item:e,variant:t}){let n=e.tool_name===`idle`,r=!!e.streaming&&!n,a=G(e.arguments)??``,o=G(e.result);return(0,U.jsx)(Ae,{label:je(e.tool_name),icon:(0,U.jsx)(i,{className:`size-3.5 text-muted-foreground`}),tone:`tool`,streaming:r,variant:t,defaultOpen:r,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground/80`,children:`Arguments`}),(0,U.jsx)(`pre`,{className:`select-text whitespace-pre-wrap break-words rounded-xl border border-border bg-background/40 px-3.5 py-3 text-[11px] font-mono leading-relaxed text-foreground/78`,children:a})]}),e.result||!n?(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground/80`,children:`Result`}),e.result?(0,U.jsx)(K,{content:o??e.result,streaming:r,markdownClassName:`text-[12px] leading-relaxed text-foreground/80`,preClassName:`text-foreground/74`}):(0,U.jsx)(`div`,{className:`rounded-xl border border-border bg-accent/15 px-3.5 py-3 text-[12px] italic text-muted-foreground`,children:r?`Running...`:`No result`})]}):null]})})}function Oe({item:e,variant:t}){return(0,U.jsxs)(`div`,{className:E(`min-w-0 w-full space-y-3 px-3 py-2.5`,t===`workspace`?`border-l border-graph-status-running/30 bg-graph-status-running/[0.08]`:`rounded-xl border border-graph-status-running/18 bg-graph-status-running/[0.06]`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(f,{className:`size-4 text-graph-status-running`}),(0,U.jsx)(`span`,{className:`text-[11px] font-medium text-graph-status-running/90`,children:`Command Result`}),e.command_name?(0,U.jsx)(`span`,{className:`rounded-full border border-graph-status-running/14 bg-background/35 px-2 py-0.5 font-mono text-[10px] text-graph-status-running/80`,children:e.command_name}):null,(0,U.jsx)(`span`,{className:`ml-auto`,children:(0,U.jsx)(Z,{text:e.content??``,className:`text-graph-status-running/72 hover:bg-graph-status-running/[0.1] hover:text-graph-status-running`,iconClassName:`text-current`,copiedClassName:`text-graph-status-running`})})]}),(0,U.jsx)(K,{content:e.content,markdownClassName:`text-[13px] text-foreground`,preClassName:`text-foreground/90`})]})}function ke({content:e,variant:t}){return(0,U.jsxs)(`div`,{className:E(`min-w-0 w-full space-y-3 px-3 py-2.5`,t===`workspace`?`border-l-2 border-graph-status-error/40 bg-graph-status-error/[0.1]`:`rounded-xl border border-graph-status-error/20 bg-graph-status-error/[0.05]`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(c,{className:`size-4 text-graph-status-error`}),(0,U.jsx)(`span`,{className:`text-[11px] font-medium text-graph-status-error`,children:`Error`}),(0,U.jsx)(`span`,{className:`ml-auto`,children:(0,U.jsx)(Z,{text:e,className:`text-graph-status-error/72 hover:bg-graph-status-error/[0.1] hover:text-graph-status-error`,iconClassName:`text-current`,copiedClassName:`text-graph-status-error`})})]}),(0,U.jsx)(`p`,{className:`select-text whitespace-pre-wrap break-words text-[13px] leading-relaxed text-graph-status-error/82`,children:e})]})}function Ae({label:e,icon:t,tone:n,streaming:r,variant:i,defaultOpen:a,children:o}){let[c,l]=(0,H.useState)(a),u=i===`workspace`;return(0,U.jsxs)(`div`,{className:E(`min-w-0 w-full transition-all duration-300`,u?`border-l border-border pl-3 py-1.5`:`rounded-xl border border-border bg-accent/10 px-3 py-2`,n===`thinking`&&!u&&`hover:bg-accent/20`,n===`tool`&&!u&&`hover:bg-accent/20`),children:[(0,U.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>l(e=>!e),className:`h-auto w-full justify-start gap-2 px-0 py-0 text-left hover:bg-transparent hover:text-inherit`,children:[(0,U.jsx)(`span`,{className:`flex size-5 shrink-0 translate-y-px items-center justify-center text-muted-foreground`,children:t}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(`span`,{className:`block truncate text-[11px] font-medium text-muted-foreground`,children:e})}),r?(0,U.jsxs)(`span`,{className:`ml-auto inline-flex size-5 items-center justify-center`,children:[(0,U.jsxs)(`span`,{className:`relative flex size-2.5 items-center justify-center`,children:[(0,U.jsx)(`span`,{className:`absolute inline-flex size-2.5 animate-ping rounded-full bg-ring/30`}),(0,U.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-ring/82`})]}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Live`})]}):null,(0,U.jsx)(s,{className:E(`size-3.5 shrink-0 text-muted-foreground/70 transition-transform duration-200`,c&&`rotate-90`)})]}),c?(0,U.jsx)(`div`,{className:`mt-3 min-w-0`,children:o}):null]})}function je(e){return e?e.split(`_`).map(e=>e.length>0?`${e[0].toUpperCase()}${e.slice(1)}`:e).join(` `):`Tool Call`}function Me(e,t){return e.type===`PendingHumanMessage`?e.id:`${e.type}-${e.timestamp}-${e.message_id??``}-${e.tool_call_id??``}-${t}`}function Ne(){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,U.jsxs)(`div`,{className:`max-w-[220px] space-y-3 text-center`,children:[(0,U.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center`,children:(0,U.jsx)(C,{className:`size-5 text-primary`})}),(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Start a conversation`}),(0,U.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Ask the Assistant to plan tasks, summarize progress, or coordinate next steps.`})]})]})})}function Pe({floating:e,page:t}){return(0,U.jsx)(`div`,{className:E(`flex h-full items-center justify-center`,t?`pb-[10vh]`:``),children:(0,U.jsxs)(`div`,{className:E(`space-y-2 text-center`,t?`max-w-md`:`max-w-[260px]`),children:[(0,U.jsx)(f,{className:E(`mx-auto`,t?`size-7 mb-4 text-muted-foreground/50`:`size-5`,e&&!t?`text-foreground/72`:`text-muted-foreground`)}),(0,U.jsx)(`p`,{className:E(`text-muted-foreground`,t?`text-base`:`text-sm`),children:`Ask the Assistant to plan tasks, summarize progress, or coordinate next steps.`})]})})}function Fe(){let e=(0,H.useRef)(null),[t,n]=(0,H.useState)(0);return(0,H.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{n(Math.ceil(t.getBoundingClientRect().height))};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(()=>{r()});return i.observe(t),()=>{i.disconnect()}},[]),{height:t,ref:e}}function Ie(e){return e.filter(e=>e.type===`SystemEntry`||e.type===`StateEntry`)}function Le(e){return e>0xe8d4a51000?e:Math.round(e*1e3)}function Re(e){let t=``,n=``,r=new Map,i=new Map,a=new Map,o=[];for(let s of e)switch(s.type){case`ContentDelta`:t+=s.text;break;case`ThinkingDelta`:n+=s.text;break;case`ToolResultDelta`:r.set(s.tool_call_id,(r.get(s.tool_call_id)??``)+s.text);break;case`SentMessageDelta`:i.has(s.message_id)||o.push({kind:`sent`,messageId:s.message_id}),i.set(s.message_id,{toId:s.to_id,text:(i.get(s.message_id)?.text??``)+s.text});break;case`ReceivedMessageDelta`:a.has(s.message_id)||o.push({kind:`received`,messageId:s.message_id}),a.set(s.message_id,{fromId:s.from_id,text:(a.get(s.message_id)?.text??``)+s.text});break}return{content:t,thinking:n,toolResults:r,sentMessages:i,receivedMessages:a,messageOrder:o}}function ze(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Be(e){let t=Le(e.timestamp);switch(e.type){case`ReceivedMessage`:return e.message_id?`${e.type}:${e.message_id}`:[e.type,t,e.from_id??``,I(e.parts,e.content)].join(`:`);case`SentMessage`:return e.message_id?`${e.type}:${e.message_id}`:[e.type,t,e.to_id??e.to_ids?.[0]??``,I(e.parts,e.content)].join(`:`);case`ToolCall`:return e.tool_call_id?`${e.type}:${e.tool_call_id}`:[e.type,t,e.tool_name??``,ze(e.arguments),e.result??``,e.streaming?`streaming`:`final`].join(`:`);case`StateEntry`:return[e.type,t,e.state??``,e.reason??``].join(`:`);default:return[e.type,t,e.content??``].join(`:`)}}function Ve(e,t){return e.type!==`ToolCall`||t.type!==`ToolCall`?!1:e.streaming&&!t.streaming?!0:!e.result&&!!t.result}function He(e){let t=[],n=new Map;for(let r of e){let e=Be(r),i=n.get(e);if(i===void 0){n.set(e,t.length),t.push(r);continue}let a=t[i];Ve(a,r)&&(t[i]=r)}return t}function Ue({history:e,incremental:t,deltas:n,fetchedAt:r}){let i=He(t&&t.length>0?[...e,...t]:[...e]);if(!n||n.length===0)return i;let{content:a,thinking:o,toolResults:s,sentMessages:c,receivedMessages:l,messageOrder:u}=Re(n),d=r/1e3;if(o&&i.push({type:`AssistantThinking`,content:o,timestamp:d,streaming:!0}),a&&i.push({type:`AssistantText`,content:a,timestamp:d,streaming:!0}),s.size>0)for(let[e,t]of s)for(let n=i.length-1;n>=0;--n){let r=i[n];if(r.type===`ToolCall`&&r.tool_call_id===e&&r.streaming){i[n]={...r,result:t};break}}for(let e of u){if(e.kind===`sent`){let t=c.get(e.messageId);if(!t||i.some(t=>t.type===`SentMessage`&&t.message_id===e.messageId))continue;i.push({type:`SentMessage`,message_id:e.messageId,to_id:t.toId,content:t.text,parts:[{type:`text`,text:t.text}],timestamp:d,streaming:!0});continue}let t=l.get(e.messageId);t&&(i.some(t=>t.type===`ReceivedMessage`&&t.message_id===e.messageId)||i.push({type:`ReceivedMessage`,message_id:e.messageId,from_id:t.fromId,content:t.text,parts:[{type:`text`,text:t.text}],timestamp:d,streaming:!0}))}return i}var We=`flowent.chatInputHistory`,Ge=50,Ke=new Set,qe=new Map,Je=new Map;function Ye(e){return`${We}.${e}`}function Xe(e){return e.trim().length>0}function Ze(e){if(!e||typeof e!=`object`)return null;let t=typeof e.text==`string`?e.text:null,n=typeof e.timestamp==`number`?e.timestamp:null;return t===null||n===null||!Xe(t)?null:{text:t,images:[],timestamp:n}}function Qe(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(Ye(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.map(e=>Ze(e)).filter(e=>e!==null).slice(-Ge):[]}catch{return[]}}function $e(e,t){if(!(typeof window>`u`))try{let n=t.filter(({text:e})=>Xe(e)).map(({text:e,timestamp:t})=>({text:e,timestamp:t}));window.localStorage.setItem(Ye(e),JSON.stringify(n))}catch{return}}function et(e){Ke.has(e)||(qe.set(e,Qe(e)),Ke.add(e))}function tt(e){let t=Je.get(e);if(t)for(let e of t)e()}function nt(e){return et(e),qe.get(e)??[]}function rt(e,t){et(e);let n=Je.get(e)??new Set;return n.add(t),Je.set(e,n),()=>{let n=Je.get(e);n?.delete(t),n&&n.size===0&&Je.delete(e)}}function it(e,t){et(e);let n=[...qe.get(e)??[],t].slice(-Ge);qe.set(e,n),$e(e,n),tt(e)}var at=10;function ot(e){return Math.max(0,e.scrollHeight-e.clientHeight)-e.scrollTop<=at}function st(){return globalThis.crypto?.randomUUID?.()??`draft-${Date.now()}-${Math.random()}`}function ct(e){return e.status===`ready`&&!!e.assetId}function lt(e){e.previewUrl.startsWith(`blob:`)&&URL.revokeObjectURL(e.previewUrl)}function ut(e){for(let t of e)lt(t)}function dt(e){return e.filter(ct).map(e=>({assetId:e.assetId,mimeType:e.mimeType,width:e.width,height:e.height,name:e.name}))}function ft(e){return e.images.map((t,n)=>({id:`history-${e.timestamp}-${n}`,assetId:t.assetId,previewUrl:ce(t.assetId),mimeType:t.mimeType,width:t.width,height:t.height,name:t.name,status:`ready`}))}function pt(e,t){return e.length===t.images.length?t.images.every((t,n)=>{let r=e[n];return!!r&&r?.status===`ready`&&r.assetId===t.assetId&&r.mimeType===t.mimeType&&r.width===t.width&&r.height===t.height&&r.name===t.name}):!1}function mt(e,t){let n=[];e&&n.push({type:`text`,text:e});for(let e of t)n.push({type:`image`,asset_id:e.assetId,mime_type:e.mimeType,width:e.width,height:e.height,alt:e.name});return n}function ht(e,t,n){return{id:`pending-${n}-${Math.random().toString(36).slice(2,8)}`,type:`PendingHumanMessage`,from:`human`,content:e,parts:t,timestamp:n,message_id:null}}async function gt(e){return new Promise(t=>{let n=URL.createObjectURL(e),r=new Image;r.onload=()=>{let e=r.naturalWidth,i=r.naturalHeight;URL.revokeObjectURL(n),t(e>0&&i>0?{width:e,height:i}:null)},r.onerror=()=>{URL.revokeObjectURL(n),t(null)},r.src=n})}async function _t(e){return Promise.all(e.map(async e=>{let t=await gt(e);return{id:st(),assetId:null,previewUrl:URL.createObjectURL(e),mimeType:e.type||null,width:t?.width??null,height:t?.height??null,name:e.name,status:`uploading`}}))}var vt=(0,H.memo)(function({agentLabel:e=`Agent`,history:t,nodes:n}){return(0,U.jsx)(`div`,{className:`space-y-1.5 p-2.5`,children:t.map((t,r)=>(0,U.jsx)(`div`,{className:`[content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:(0,U.jsx)(St,{agentLabel:e,entry:t,nodes:n})},`${r}-${t.timestamp}-${t.type}-${t.message_id??``}-${t.tool_call_id??``}`))})});function yt({content:e,markdownClassName:t,preClassName:n,streaming:r}){let i=G(e);return i?(0,U.jsx)(`pre`,{className:E(`select-text text-[11px] whitespace-pre-wrap break-words leading-relaxed`,n),children:(0,U.jsx)(bt,{text:i,streaming:r})}):r?(0,U.jsx)(`pre`,{className:E(`select-text text-[11px] whitespace-pre-wrap break-words leading-relaxed`,n),children:(0,U.jsx)(bt,{text:e??``,streaming:!0})}):(0,U.jsx)(W,{content:e??``,className:E(`text-[11px] leading-relaxed`,t)})}function bt({text:e,streaming:t}){return(0,U.jsxs)(U.Fragment,{children:[e,t&&(0,U.jsx)(`span`,{className:`streaming-cursor`})]})}function xt({entry:e,markdownClassName:t,preClassName:n}){let r=z(e.parts,e.content);return r.length===0?null:r.every(e=>e.type===`text`)?(0,U.jsx)(yt,{content:I(r),streaming:e.streaming,markdownClassName:t,preClassName:n}):(0,U.jsx)(`div`,{className:`space-y-2`,children:r.map((e,r)=>e.type===`text`?(0,U.jsx)(yt,{content:e.text,markdownClassName:t,preClassName:n},`${r}-${e.type}`):(0,U.jsx)(ue,{alt:e.alt,assetId:e.asset_id,compact:!0,height:e.height,mimeType:e.mime_type,width:e.width},`${r}-${e.type}-${e.asset_id}`))})}var St=(0,H.memo)(function({agentLabel:e,entry:t,nodes:n}){switch(t.type){case`SystemEntry`:return(0,U.jsx)(Q,{label:`System`,icon:(0,U.jsx)(o,{className:`size-3 text-muted-foreground`}),className:`border-border/40 bg-surface-1/24`,defaultOpen:!1,children:(0,U.jsx)(yt,{content:t.content,markdownClassName:`text-muted-foreground`,preClassName:`text-muted-foreground leading-relaxed`})});case`ReceivedMessage`:return(0,U.jsx)(Q,{label:`From ${R(t.from_id??``,n)}`,icon:(0,U.jsx)(C,{className:`size-3 text-foreground/70`}),className:`border-border bg-accent/20`,labelClassName:`text-foreground/70`,actions:(0,U.jsx)(Z,{text:I(t.parts,t.content)}),defaultOpen:t.streaming??!1,children:(0,U.jsx)(xt,{entry:t,markdownClassName:`text-foreground/90`,preClassName:`text-foreground/90 leading-relaxed`})});case`AssistantThinking`:return(0,U.jsx)(Q,{label:`Thinking`,icon:(0,U.jsx)(r,{className:`size-3 text-foreground/72`}),className:`border-border bg-surface-1/28`,labelClassName:`text-foreground/72`,defaultOpen:!1,children:(0,U.jsx)(yt,{content:t.content,streaming:t.streaming,markdownClassName:`text-foreground/82`,preClassName:`text-foreground/82 leading-relaxed`})});case`StateEntry`:return(0,U.jsx)(Q,{label:t.state?`State ${t.state.toUpperCase()}`:`State`,icon:(0,U.jsx)(d,{className:`size-3 text-foreground/62`}),className:`border-border bg-background/28`,labelClassName:`text-foreground/72`,defaultOpen:!1,children:(0,U.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-foreground/84`,children:[(0,U.jsx)(`p`,{className:`select-text font-mono uppercase tracking-[0.08em] text-foreground/78`,children:t.state??`unknown`}),t.reason?(0,U.jsx)(`p`,{className:`select-text text-muted-foreground`,children:t.reason}):null]})});case`SentMessage`:return(0,U.jsx)(Q,{label:`To ${(t.to_id==null?(t.to_ids??[]).filter(e=>!!e):[t.to_id]).map(e=>R(e,n)).join(`, `)||`Unknown`}`,icon:(0,U.jsx)(_,{className:`size-3 text-foreground/58`}),className:`border-border bg-background/24`,labelClassName:`text-foreground/72`,actions:(0,U.jsx)(Z,{text:I(t.parts,t.content)}),defaultOpen:t.streaming??!1,children:(0,U.jsx)(xt,{entry:t,markdownClassName:`text-foreground/86`,preClassName:`text-foreground/86 leading-relaxed`})});case`AssistantText`:return(0,U.jsx)(Q,{label:e,icon:(0,U.jsx)(g,{className:`size-3 text-foreground/84`}),className:`border-border bg-surface-2/62`,labelClassName:`text-foreground/84`,actions:(0,U.jsx)(Z,{text:t.content??``}),defaultOpen:!1,children:(0,U.jsx)(xt,{entry:t,markdownClassName:`text-foreground/88`,preClassName:`text-foreground/88 leading-relaxed`})});case`ToolCall`:{let e=G(t.arguments)??``,n=G(t.result);return(0,U.jsx)(Q,{label:t.tool_name??`tool`,icon:(0,U.jsx)(i,{className:`size-3 text-foreground/66`}),className:`border-border bg-surface-1/20`,labelClassName:`text-foreground/72`,defaultOpen:!1,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1`,children:`Arguments`}),(0,U.jsx)(`pre`,{className:`select-text text-[11px] whitespace-pre-wrap break-words leading-relaxed text-foreground/78`,children:e})]}),t.result&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1`,children:`Result`}),(0,U.jsx)(yt,{content:n??t.result,streaming:t.streaming,markdownClassName:`text-muted-foreground`,preClassName:`text-muted-foreground leading-relaxed`})]})]})})}case`ErrorEntry`:return(0,U.jsx)(Q,{label:`Error`,icon:(0,U.jsx)(c,{className:`size-3 text-graph-status-error/84`}),className:`border-graph-status-error/16 bg-graph-status-error/[0.038]`,labelClassName:`text-graph-status-error/78`,actions:(0,U.jsx)(Z,{text:t.content??``,className:`text-graph-status-error/84 hover:text-graph-status-error/84`,iconClassName:`text-graph-status-error/84`,copiedClassName:`text-graph-status-error/84`}),defaultOpen:!1,children:(0,U.jsx)(yt,{content:t.content,markdownClassName:`text-graph-status-error/84`,preClassName:`text-graph-status-error/84 leading-relaxed`})});default:return null}});function Q({actions:e,label:t,labelClassName:n,icon:r,className:i,contentClassName:a,defaultOpen:o=!1,children:c}){let[l,u]=(0,H.useState)(o),d=(0,H.useCallback)(()=>u(e=>!e),[]);return(0,U.jsxs)(`div`,{className:E(`rounded-xl border transition-colors hover:bg-accent/20`,i),children:[(0,U.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-2 px-3 py-2 select-none`,onClick:d,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())},role:`button`,tabIndex:0,"aria-expanded":l,children:[(0,U.jsx)(`span`,{className:`shrink-0 flex items-center justify-center`,children:r}),(0,U.jsx)(`span`,{className:E(`flex-1 truncate text-[11px] font-medium`,n||`text-muted-foreground`),children:t}),e?(0,U.jsx)(`span`,{className:`ml-auto shrink-0 flex items-center leading-none`,onClick:e=>e.stopPropagation(),children:e}):null,(0,U.jsx)(s,{className:E(`ml-2 size-3.5 shrink-0 text-muted-foreground/70 transition-transform duration-200`,l&&`rotate-90`)})]}),(0,U.jsx)(P,{initial:!1,children:l?(0,U.jsx)(b.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.22,1,.36,1]},className:`overflow-hidden`,children:(0,U.jsx)(`div`,{className:E(`px-3 pb-3 pt-1`,a),children:c})}):null})]})}function Ct(e,t=!1){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(0),{agents:u}=L(),{agentHistories:d,clearAgentHistory:f,clearHistorySnapshot:p,historyInvalidatedAt:m,historyClearedAt:h,historySnapshots:g,streamingDeltas:_}=te(),v=e?h.get(e)??0:0,y=e?m.get(e)??0:0,b=e?g.get(e)??null:null;return(0,H.useEffect)(()=>{v&&(r(e=>e&&{...e,history:Ie(e.history)}),l(Date.now()))},[v]),(0,H.useEffect)(()=>{!y||!b||(r(e=>e&&{...e,history:b}),l(Date.now()))},[y,b]),(0,H.useEffect)(()=>{if(!e){r(null),a(!1),s(null);return}let n=new AbortController,i=!1;return(async()=>{a(!0),s(null),t||f(e);try{let t=await M(e,n.signal);if(i)return;r(t),l(Date.now()),p(e)}catch(e){if(i||n.signal.aborted)return;r(null),s(e instanceof Error?e.message:`Failed to fetch node detail`)}finally{i||a(!1)}})(),()=>{i=!0,n.abort()}},[e,f,p,y,t]),{detail:(0,H.useMemo)(()=>{if(!n||!e)return null;let t=d.get(e),r=_.get(e),i=Ue({history:b??n.history,incremental:t,deltas:r,fetchedAt:c}),a=e?u.get(e):void 0,o={...n,history:i};return a&&(o.state=a.state,o.todos=a.todos),o},[n,e,d,b,_,u,c]),loading:i,error:o,fetchedAt:c}}function wt(e,t){return t?.leader_id?e.get(t.leader_id)??null:null}function Tt(e={}){let{bottomInset:t=0}=e,{agents:n}=L(),{tabs:r}=F(),{connected:i}=ne(),{agentHistories:a,clearAgentHistory:o,clearHistorySnapshot:s,historyInvalidatedAt:c,historyClearedAt:l,historySnapshots:d,streamingDeltas:f}=te(),{activeToolCalls:p}=re(),{activeTabId:m}=ae(),h=m?r.get(m)??null:null,g=(0,H.useMemo)(()=>wt(n,h),[h,n]),_=g?.id??h?.leader_id??null,v=m?`leader:${m}`:`leader:none`,[y,b]=(0,H.useState)(null),[x,S]=(0,H.useState)(0),[C,w]=(0,H.useState)(``),[T,E]=(0,H.useState)([]),[D,k]=(0,H.useState)(null),[A,ee]=(0,H.useState)(!1),[P,ie]=(0,H.useState)(null),[R,B]=(0,H.useState)([]),oe=(0,H.useRef)(null),se=(0,H.useRef)(!0),V=(0,H.useRef)([]),ce=g?.capabilities?.input_image??!1,U=_?l.get(_)??0:0,ue=_?c.get(_)??0:0,W=_?d.get(_)??null:null,G=T.some(e=>e.status===`uploading`),K=T.filter(ct),q=(0,H.useSyncExternalStore)(e=>rt(v,e),()=>nt(v),()=>nt(v)),J=D===null?null:q[D]??null,de=J!==null&&C===J.text&&pt(T,J),Y=(0,H.useCallback)((e,t)=>{k(t),w(e?.text??``),E(e?ft(e):[])},[]),fe=(0,H.useCallback)(e=>{k(null),w(e)},[]);(0,H.useEffect)(()=>{V.current=T},[T]),(0,H.useEffect)(()=>()=>{ut(V.current)},[]),(0,H.useEffect)(()=>{ut(V.current),w(``),E([]),k(null),B([]),ie(null)},[v]),(0,H.useEffect)(()=>{U&&(b(e=>e&&{...e,history:e.history.filter(e=>e.type===`SystemEntry`||e.type===`StateEntry`)}),S(Date.now()))},[U]),(0,H.useEffect)(()=>{!ue||!W||(b(e=>e&&{...e,history:W}),S(Date.now()))},[ue,W]),(0,H.useEffect)(()=>{if(!i||!_){b(null);return}let e=new AbortController,t=!1;return(async()=>{o(_);try{let n=await M(_,e.signal);if(t||!n)return;b(n),S(Date.now()),s(_)}catch{!t&&!e.signal.aborted&&u.error(`Failed to load Leader history`)}})(),()=>{t=!0,e.abort()}},[o,s,i,U,ue,_]);let pe=(0,H.useMemo)(()=>_?Ue({history:W??y?.history??[],incremental:a.get(_),deltas:f.get(_),fetchedAt:x||Date.now()}):[],[a,y,x,W,_,f]);(0,H.useEffect)(()=>{if(!_||R.length===0)return;let e=new Set(pe.filter(e=>e.type===`ReceivedMessage`&&e.from_id===`human`&&typeof e.message_id==`string`).map(e=>e.message_id));e.size!==0&&B(t=>t.filter(t=>!t.message_id||!e.has(t.message_id)))},[_,pe,R.length]);let X=(0,H.useMemo)(()=>[...pe,...R.map(e=>({...e}))],[pe,R]),me=(0,H.useMemo)(()=>{let e=R.length,t=_?f.get(_)??[]:[],n=i&&!!(_&&(e>0||g?.state===`running`||g?.state===`sleeping`||p.has(_)||t.length>0)),r=[...X].map((e,t)=>({item:e,index:t})).reverse().find(({item:e})=>e.type===`PendingHumanMessage`?!0:e.type===`ReceivedMessage`&&e.from_id===`human`&&z(e.parts,e.content).length>0)?.index,a=r===void 0?[]:X.slice(r+1),o=a.some(e=>e.type===`AssistantText`&&z(e.parts,e.content).length>0),s=[...a].reverse().find(e=>e.type===`ToolCall`&&e.streaming===!0),c=(_?p.get(_)??null:null)??s?.tool_name??null;return{running:n,runningHint:n&&r!==void 0&&!o?{label:c?`Running tools...`:`Thinking...`,toolName:c}:null}},[p,i,_,g?.state,R.length,f,X]);(0,H.useLayoutEffect)(()=>{let e=oe.current;!e||!se.current||(e.scrollTop=e.scrollHeight)},[t,me.runningHint?`${me.runningHint.label}:${me.runningHint.toolName??``}`:``,X]),(0,H.useLayoutEffect)(()=>{let e=oe.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{se.current&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>{t.disconnect()}},[]);let he=e=>{se.current=ot(e.currentTarget)},ge=async()=>{if(!_)return;let e=C.trim();if(!e&&K.length===0||G||A)return;let t=mt(e,K),n=C,r=T,i=D,a=Date.now(),o=ht(e||I(t),t,a);ee(!0),B(e=>[...e,o]),k(null),w(``),E([]);try{let i=await j(_,{content:e||I(t),parts:t});B(e=>e.map(e=>e.id===o.id?{...e,message_id:i.message_id??null}:e)),it(v,{text:n,images:dt(r),timestamp:a}),ut(r)}catch(e){B(e=>e.filter(e=>e.id!==o.id)),w(n),E(r),k(i),u.error(e instanceof Error?e.message:`Failed to send message`)}finally{ee(!1)}},_e=(0,H.useCallback)(async e=>{if(k(null),!ce){u.error(`Current model does not support image input`);return}let t=Array.from(e).filter(e=>e.type.startsWith(`image/`));if(t.length===0)return;let n=await _t(t);E(e=>[...e,...n]),await Promise.all(n.map(async(e,n)=>{let r=t[n];if(r)try{let t=await le(r);E(n=>n.map(n=>n.id===e.id?{...n,assetId:t.id,mimeType:t.mime_type,width:typeof t.width==`number`?t.width:n.width,height:typeof t.height==`number`?t.height:n.height,status:`ready`}:n))}catch(t){lt(e),E(t=>t.filter(t=>t.id!==e.id)),u.error(t instanceof Error?t.message:`Failed to upload image`)}}))},[ce]),ve=(0,H.useCallback)(e=>{k(null),E(t=>{let n=t.find(t=>t.id===e);return n&&lt(n),t.filter(t=>t.id!==e)})},[]),ye=(0,H.useCallback)((e,t)=>{if(q.length===0)return!1;let n=t.start,r=t.end,i=C.length===0&&T.length===0,a=typeof n==`number`&&typeof r==`number`&&n===r&&(n===0||n===C.length);if(!i&&!(J!==null&&de&&a))return!1;if(D===null){if(e!==-1)return!1;let t=q.length-1;return Y(q[t]??null,t),!0}if(e===-1){let e=Math.max(D-1,0);return Y(q[e]??null,e),!0}if(D>=q.length-1)return Y(null,null),!0;let o=D+1;return Y(q[o]??null,o),!0},[J,T,D,C,q,de,Y]),Z=(0,H.useCallback)(async()=>{if(_&&!(g?.state!==`running`&&g?.state!==`sleeping`)){await N(_);for(let e=0;e<25;e+=1){let e=await M(_);if(!e)break;if(b(e),S(Date.now()),e.state!==`running`&&e.state!==`sleeping`)return;await new Promise(e=>window.setTimeout(e,120))}throw Error(`Leader did not stop in time`)}},[_,g?.state]);return{activeTab:h,addImages:_e,connected:i,draftImages:T,handleKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ge())},hasUploadingImages:G,input:C,isBrowsingInputHistory:de,leaderActivity:me,leaderNode:g,navigateInputHistory:ye,onMessagesScroll:he,removeImage:ve,retryMessage:(0,H.useCallback)(async e=>{if(!(!_||!e||P)){ie(e);try{try{await Z(),await O(_,e)}catch(e){u.error(e instanceof Error?e.message:`Failed to retry Leader message`);return}o(_);try{let e=await M(_);e&&(b(e),S(Date.now()),s(_))}catch{return}}finally{ie(null)}}},[o,s,_,P,Z]),retryingMessageId:P,scrollRef:oe,sendMessage:ge,sending:A,setInput:fe,stopLeader:Z,supportsInputImage:ce,timelineItems:X}}var Et=`rounded-md bg-accent/45 px-2 py-1 text-xs text-foreground`,Dt={running:`border-graph-status-running/18 bg-graph-status-running/[0.12] text-graph-status-running`,idle:`border-graph-status-idle/12 bg-graph-status-idle/[0.06] text-graph-status-idle/78`,sleeping:`border-graph-status-sleeping/18 bg-graph-status-sleeping/[0.12] text-graph-status-sleeping`,initializing:`border-graph-status-initializing/16 bg-graph-status-initializing/[0.08] text-graph-status-initializing/84`,error:`border-graph-status-error/20 bg-graph-status-error/[0.09] text-graph-status-error`,terminated:`border-border bg-accent/35 text-muted-foreground`};function Ot({children:e,disabled:t=!1,active:n=!1,onClick:r}){return(0,U.jsx)(A,{type:`button`,variant:`ghost`,size:`xs`,onClick:r,disabled:t,className:E(`flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md border border-transparent bg-transparent px-3 py-1.75 text-[11px] font-medium text-muted-foreground transition-[background-color,border-color,color] duration-150 hover:border-border hover:bg-accent/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:border-transparent disabled:text-muted-foreground/50 disabled:hover:bg-transparent`,n&&`border-border bg-accent/70 text-foreground`),children:e})}function kt(){return(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-border`})}function At({children:e,tone:t=`default`}){return(0,U.jsx)(`div`,{className:E(`pointer-events-auto relative isolate flex items-center gap-1.5 rounded-full border border-border bg-surface-overlay/80 px-2.5 py-1 text-[11px] font-medium text-muted-foreground backdrop-blur-sm`,t===`primary`?`border-border bg-accent/60 text-foreground`:``),children:e})}function jt({agent:e,onClose:t}){let[n,r]=(0,H.useState)(!1),{agents:i}=L(),{tabs:a}=F(),{detail:o,error:s,loading:c}=Ct(e.id,e.node_type===`assistant`),l=o?.state??e.state,d=o?.is_leader??e.is_leader,f=o?.contacts??[],p=o?.connections??e.connections,m=o?.todos??e.todos,_=o?.history??[],v=o?.role_name??e.role_name,y=o?.tools??[],b=o?.write_dirs??[],x=o?.allow_network??!1,S=o?.tab_id??e.tab_id??null,C=S?a.get(S)??null:null,w=_.filter(e=>e.type===`StateEntry`),D=_.filter(e=>e.type!==`StateEntry`),O=V({name:e.name,roleName:e.role_name,nodeType:e.node_type,isLeader:e.is_leader}),k=p.map(e=>{let t=i.get(e);return{id:e,label:t?V({name:t.name,roleName:t.role_name,nodeType:t.node_type,isLeader:t.is_leader}):e.slice(0,8)}}),ee=f.map(e=>{let t=i.get(e);return{id:e,label:t?V({name:t.name,roleName:t.role_name,nodeType:t.node_type,isLeader:t.is_leader}):e.slice(0,8)}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3.5 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex size-7 items-center justify-center rounded-md bg-primary/8`,children:e.node_type===`assistant`?(0,U.jsx)(h,{className:`size-3.5 text-primary`}):(0,U.jsx)(g,{className:`size-3.5 text-primary`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold`,children:O}),d?(0,U.jsx)(`span`,{className:`rounded-full border border-accent bg-accent/45 px-2 py-0.5 text-[10px] font-semibold text-accent-foreground`,children:`Leader`}):null,(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-accent/35 px-2 py-0.5 font-mono text-[10px] text-muted-foreground/78`,children:e.id.slice(0,8)})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[l===`running`||l===`sleeping`?(0,U.jsx)(A,{type:`button`,size:`sm`,variant:`destructive`,disabled:n,onClick:()=>{r(!0),N(e.id).catch(()=>{u.error(`Failed to interrupt node`)}).finally(()=>{r(!1)})},children:n?`Interrupting...`:`Interrupt`}):null,(0,U.jsx)(It,{title:`Close details`,onClick:t,children:(0,U.jsx)(T,{className:`size-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3.5`,children:(0,U.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-3.5 border-b border-border pb-3.5 sm:grid-cols-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Status`}),(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsx)(se,{variant:`outline`,className:Dt[l],children:l.toUpperCase()})})]}),(0,U.jsxs)(`div`,{className:`min-w-0 sm:border-l sm:border-border sm:pl-3.5`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Contacts`}),(0,U.jsxs)(`p`,{className:`mt-2 select-text text-sm text-foreground`,children:[f.length,` reachable nodes`]})]}),(0,U.jsxs)(`div`,{className:`min-w-0 sm:border-l sm:border-border sm:pl-3.5`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Workflow`}),(0,U.jsx)(`p`,{className:`mt-2 select-text text-sm text-foreground`,children:C?.title??S?.slice(0,8)??`None`})]})]}),(0,U.jsx)($,{title:`Workflow Context`,children:S?(0,U.jsxs)(`div`,{className:`grid gap-3 text-sm sm:grid-cols-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`ID`}),(0,U.jsx)(`p`,{className:`mt-1 select-text font-mono text-[11px] text-foreground`,children:S??`None`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Title`}),(0,U.jsx)(`p`,{className:`mt-1 select-text text-foreground`,children:C?.title??`Unknown`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Role`}),(0,U.jsx)(`p`,{className:`mt-1 select-text text-foreground`,children:v??`None`})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No workflow metadata`})}),(0,U.jsx)($,{title:`State Timeline`,children:w.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No state changes yet`}):(0,U.jsx)(`div`,{className:`space-y-2`,children:w.slice(-6).reverse().map(e=>(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border bg-accent/25 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(se,{variant:`outline`,className:Dt[e.state??l],children:(e.state??l).toUpperCase()}),e.reason?(0,U.jsx)(`p`,{className:`mt-1 select-text text-xs text-muted-foreground/78`,children:e.reason}):null]}),(0,U.jsx)(`span`,{className:`shrink-0 select-text font-mono text-[10px] text-muted-foreground/64`,children:Lt(e.timestamp)})]},`${e.timestamp}-${e.state??`unknown`}`))})}),(0,U.jsx)($,{title:`Contacts`,children:ee.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No direct contacts`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ee.map(e=>(0,U.jsx)(`span`,{className:E(Et,`select-text`),children:e.label},e.id))})}),(0,U.jsx)($,{title:`Agent Graph`,children:k.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No graph edges`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>(0,U.jsx)(`span`,{className:E(Et,`select-text`),children:e.label},e.id))})}),(0,U.jsx)($,{title:`Tools`,children:y.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tools configured`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:y.map(e=>(0,U.jsx)(`span`,{className:E(Et,`select-text font-mono`),children:e},e))})}),(0,U.jsx)($,{title:`Permissions`,children:(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Network`}),(0,U.jsx)(`p`,{className:`mt-1 select-text text-sm text-foreground`,children:x?`Enabled`:`Disabled`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Write Dirs`}),b.length===0?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`No write access`}):(0,U.jsx)(`div`,{className:`mt-2 space-y-1`,children:b.map(e=>(0,U.jsx)(`p`,{className:E(Et,`select-text font-mono text-[11px]`),children:e},e))})]})]})}),(0,U.jsx)($,{title:`Todos`,children:(0,U.jsx)(`div`,{className:`space-y-2`,children:m.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No todos`}):m.slice(0,6).map(e=>(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-border`}),(0,U.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:e.text})]},e.text))})}),(0,U.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,U.jsx)(`div`,{className:`px-0 pb-2`,children:(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`History`})}),c?(0,U.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,]].map((e,t)=>(0,U.jsx)(`div`,{className:`h-12 rounded-md skeleton-shimmer`},t))}):s?(0,U.jsx)(`div`,{className:`text-sm text-destructive`,children:s}):D.length===0?(0,U.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No history yet.`}):(0,U.jsx)(vt,{history:D,agentLabel:O,nodes:i})]})]})})]})}function Mt({onOpenDetails:e}){let{agents:t}=L(),[n,r]=(0,H.useState)(!1),{height:i,ref:a}=Fe(),{activeTab:o,addImages:s=async()=>{},connected:c,draftImages:l=[],handleKeyDown:d,hasUploadingImages:f=!1,input:p,isBrowsingInputHistory:m,leaderActivity:h,leaderNode:g,navigateInputHistory:_,onMessagesScroll:v,removeImage:y=()=>{},retryMessage:b,retryingMessageId:x,scrollRef:S,sending:C,sendMessage:w,setInput:T,stopLeader:E,supportsInputImage:D=!1,timelineItems:O}=Tt({bottomInset:i});return o?g?(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-border px-3.5 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold`,children:`Leader`}),(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-accent/35 px-2 py-0.5 text-[10px] font-medium text-muted-foreground/78`,children:o.title}),g.role_name?(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-accent/35 px-2 py-0.5 text-[10px] font-medium text-muted-foreground/78`,children:g.role_name}):null,(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground/72`,children:c?`Online`:`Connecting...`})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,U.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,onClick:e,children:`Leader Details`})})]}),(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(be,{allowHumanMessageRetry:!0,bottomInset:i,items:O,nodes:t,onRetryHumanMessage:e=>void b(e),onScroll:v,retryImageInputEnabled:D,retryingMessageId:x,runningHint:h.runningHint,scrollRef:S,variant:`workspace`}),(0,U.jsx)(`div`,{ref:a,style:{paddingBottom:`calc(10px + env(safe-area-inset-bottom, 0px))`},className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-b from-transparent via-background/70 to-background/95 px-2.5 pt-8`,children:(0,U.jsx)(_e,{busy:h.running,commandsEnabled:!1,disabled:!p.trim()&&l.length===0||f||C,images:l,imageInputEnabled:D,input:p,onAddImages:e=>void s(e),onChange:T,onNavigateHistory:_,onKeyDown:d,onRemoveImage:y,onSend:()=>void w(),onStop:()=>{r(!0),E().catch(e=>{u.error(e instanceof Error?e.message:`Failed to interrupt leader`)}).finally(()=>{r(!1)})},overlay:!0,suppressCommandNavigation:m,targetLabel:`Leader`,stopping:n,variant:`workspace`})})]})]}):(0,U.jsx)(Pt,{}):(0,U.jsx)(Nt,{})}function Nt(){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,U.jsxs)(`div`,{className:`max-w-sm rounded-xl border border-border bg-accent/20 px-5 py-6 text-center`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:`No workflow selected`}),(0,U.jsx)(`p`,{className:`mt-2 text-[12px] leading-6 text-muted-foreground`,children:`Create a workflow or switch to an existing one to open its Leader panel.`})]})})}function Pt(){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,U.jsxs)(`div`,{className:`max-w-sm rounded-xl border border-border bg-accent/20 px-5 py-6 text-center`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:`Loading workflow context`}),(0,U.jsx)(`p`,{className:`mt-2 text-[12px] leading-6 text-muted-foreground`,children:`Restoring the current workflow Leader panel.`})]})})}function Ft({expanded:e,onClick:t,className:n}){let r=e?`Hide panel`:`Show panel`;return(0,U.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,onClick:t,title:r,"aria-label":r,className:E(`pointer-events-auto relative isolate flex size-9 items-center justify-center rounded-md border border-border bg-surface-overlay/80 text-muted-foreground shadow-sm transition-[background-color,color] duration-150 hover:bg-accent/60 hover:text-foreground [contain:paint]`,n),children:(0,U.jsx)(`span`,{className:`flex transition-transform duration-200`,children:e?(0,U.jsx)(v,{className:`size-4`}):(0,U.jsx)(y,{className:`size-4`})})})}function It({children:e,onClick:t,title:n}){return(0,U.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:t,title:n,"aria-label":n,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors duration-150 hover:bg-accent/45 hover:text-foreground`,children:e})}function $({title:e,children:t}){return(0,U.jsxs)(`section`,{className:`border-t border-border pt-3.5`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:e}),(0,U.jsx)(`div`,{className:`mt-2`,children:t})]})}function Lt(e){return e?new Date(e*1e3).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`—`}export{Ue as C,le as D,_e as E,Ie as S,be as T,ft as _,Ot as a,nt as b,wt as c,_t as d,pt as f,ut as g,lt as h,Ft as i,mt as l,ot as m,At as n,kt as o,ct as p,Mt as r,Nt as s,jt as t,ht as u,dt as v,Fe as w,rt as x,it as y};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-BYbx6iT9.js";import{d as e,l as t}from"./graph-vendor-DRq_-6fV.js";import{C as n,D as r,E as i,O as a,S as o,T as s,w as c,x as l}from"./ui-vendor-Dg9NNnWX.js";import{a as u}from"./shared-CMxbpLeQ.js";import{Y as d}from"./index-CL1ALZ3r.js";e();var f=t();function p({...e}){return(0,f.jsx)(r,{"data-slot":`alert-dialog`,...e})}function m({...e}){return(0,f.jsx)(i,{"data-slot":`alert-dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(s,{"data-slot":`alert-dialog-overlay`,className:u(`bg-background/88 fixed inset-0 z-50`,`data-[state=open]:animate-in data-[state=closed]:animate-out`,`data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t})}function g({className:e,...t}){return(0,f.jsxs)(m,{children:[(0,f.jsx)(h,{}),(0,f.jsx)(n,{"data-slot":`alert-dialog-content`,className:u(`fixed top-1/2 left-1/2 z-50 w-full max-w-[calc(100%-2rem)] sm:max-w-lg -translate-x-1/2 -translate-y-1/2 grid gap-4 rounded-xl border border-border bg-popover text-popover-foreground p-6 shadow-lg`,`data-[state=open]:animate-in data-[state=closed]:animate-out`,`data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,`data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,e),...t})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:u(`flex flex-col gap-2 text-left`,e),...t})}function v({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:u(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function y({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`alert-dialog-title`,className:u(`text-lg font-semibold`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(c,{"data-slot":`alert-dialog-description`,className:u(`text-sm text-muted-foreground`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(l,{"data-slot":`alert-dialog-action`,className:u(d(),e),...t})}function S({className:e,...t}){return(0,f.jsx)(o,{"data-slot":`alert-dialog-cancel`,className:u(d({variant:`outline`}),e),...t})}export{b as a,y as c,g as i,x as n,v as o,S as r,_ as s,p as t};