flowent 0.0.4 → 0.0.6

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 (311) hide show
  1. package/README.md +1 -1
  2. package/backend/README.md +74 -0
  3. package/backend/pyproject.toml +2 -1
  4. package/backend/src/flowent/__pycache__/__init__.cpython-313.pyc +0 -0
  5. package/backend/src/flowent/__pycache__/_version.cpython-313.pyc +0 -0
  6. package/backend/src/flowent/__pycache__/access.cpython-313.pyc +0 -0
  7. package/backend/src/flowent/__pycache__/agent.cpython-313.pyc +0 -0
  8. package/backend/src/flowent/__pycache__/assistant_commands.cpython-313.pyc +0 -0
  9. package/backend/src/flowent/__pycache__/cli.cpython-313.pyc +0 -0
  10. package/backend/src/flowent/__pycache__/config.cpython-313.pyc +0 -0
  11. package/backend/src/flowent/__pycache__/events.cpython-313.pyc +0 -0
  12. package/backend/src/flowent/__pycache__/graph_runtime.cpython-313.pyc +0 -0
  13. package/backend/src/flowent/__pycache__/graph_service.cpython-313.pyc +0 -0
  14. package/backend/src/flowent/__pycache__/image_assets.cpython-313.pyc +0 -0
  15. package/backend/src/flowent/__pycache__/logging.cpython-313.pyc +0 -0
  16. package/backend/src/flowent/__pycache__/main.cpython-313.pyc +0 -0
  17. package/backend/src/flowent/__pycache__/mcp_service.cpython-313.pyc +0 -0
  18. package/backend/src/flowent/__pycache__/model_metadata.cpython-313.pyc +0 -0
  19. package/backend/src/flowent/__pycache__/network.cpython-313.pyc +0 -0
  20. package/backend/src/flowent/__pycache__/{stats_service.cpython-313.pyc → observability_service.cpython-313.pyc} +0 -0
  21. package/backend/src/flowent/__pycache__/registry.cpython-313.pyc +0 -0
  22. package/backend/src/flowent/__pycache__/role_management.cpython-313.pyc +0 -0
  23. package/backend/src/flowent/__pycache__/runtime.cpython-313.pyc +0 -0
  24. package/backend/src/flowent/__pycache__/sandbox.cpython-313.pyc +0 -0
  25. package/backend/src/flowent/__pycache__/security.cpython-313.pyc +0 -0
  26. package/backend/src/flowent/__pycache__/settings.cpython-313.pyc +0 -0
  27. package/backend/src/flowent/__pycache__/settings_management.cpython-313.pyc +0 -0
  28. package/backend/src/flowent/__pycache__/state_db.cpython-313.pyc +0 -0
  29. package/backend/src/flowent/__pycache__/workspace_store.cpython-313.pyc +0 -0
  30. package/backend/src/flowent/agent.py +364 -52
  31. package/backend/src/flowent/assistant_commands.py +31 -22
  32. package/backend/src/flowent/channels/__pycache__/__init__.cpython-313.pyc +0 -0
  33. package/backend/src/flowent/channels/__pycache__/telegram.cpython-313.pyc +0 -0
  34. package/backend/src/flowent/channels/telegram.py +4 -4
  35. package/backend/src/flowent/graph_service.py +1307 -145
  36. package/backend/src/flowent/mcp_service.py +21 -7
  37. package/backend/src/flowent/model_metadata.py +4 -0
  38. package/backend/src/flowent/models/__init__.py +6 -2
  39. package/backend/src/flowent/models/__pycache__/__init__.cpython-313.pyc +0 -0
  40. package/backend/src/flowent/models/__pycache__/agent.cpython-313.pyc +0 -0
  41. package/backend/src/flowent/models/__pycache__/base.cpython-313.pyc +0 -0
  42. package/backend/src/flowent/models/__pycache__/blueprint.cpython-313.pyc +0 -0
  43. package/backend/src/flowent/models/__pycache__/content.cpython-313.pyc +0 -0
  44. package/backend/src/flowent/models/__pycache__/delta.cpython-313.pyc +0 -0
  45. package/backend/src/flowent/models/__pycache__/event.cpython-313.pyc +0 -0
  46. package/backend/src/flowent/models/__pycache__/graph.cpython-313.pyc +0 -0
  47. package/backend/src/flowent/models/__pycache__/history.cpython-313.pyc +0 -0
  48. package/backend/src/flowent/models/__pycache__/llm.cpython-313.pyc +0 -0
  49. package/backend/src/flowent/models/__pycache__/message.cpython-313.pyc +0 -0
  50. package/backend/src/flowent/models/__pycache__/tab.cpython-313.pyc +0 -0
  51. package/backend/src/flowent/models/__pycache__/todo.cpython-313.pyc +0 -0
  52. package/backend/src/flowent/models/agent.py +1 -0
  53. package/backend/src/flowent/models/graph.py +44 -9
  54. package/backend/src/flowent/models/history.py +73 -15
  55. package/backend/src/flowent/models/llm.py +1 -0
  56. package/backend/src/flowent/models/message.py +6 -0
  57. package/backend/src/flowent/models/tab.py +38 -1
  58. package/backend/src/flowent/{stats_service.py → observability_service.py} +4 -4
  59. package/backend/src/flowent/prompts/__pycache__/__init__.cpython-313.pyc +0 -0
  60. package/backend/src/flowent/prompts/__pycache__/common.cpython-313.pyc +0 -0
  61. package/backend/src/flowent/prompts/__pycache__/steward.cpython-313.pyc +0 -0
  62. package/backend/src/flowent/prompts/common.py +2 -2
  63. package/backend/src/flowent/prompts/steward.py +2 -2
  64. package/backend/src/flowent/providers/__pycache__/__init__.cpython-313.pyc +0 -0
  65. package/backend/src/flowent/providers/__pycache__/anthropic.cpython-313.pyc +0 -0
  66. package/backend/src/flowent/providers/__pycache__/base_url.cpython-313.pyc +0 -0
  67. package/backend/src/flowent/providers/__pycache__/configuration.cpython-313.pyc +0 -0
  68. package/backend/src/flowent/providers/__pycache__/content.cpython-313.pyc +0 -0
  69. package/backend/src/flowent/providers/__pycache__/errors.cpython-313.pyc +0 -0
  70. package/backend/src/flowent/providers/__pycache__/gateway.cpython-313.pyc +0 -0
  71. package/backend/src/flowent/providers/__pycache__/headers.cpython-313.pyc +0 -0
  72. package/backend/src/flowent/providers/__pycache__/management.cpython-313.pyc +0 -0
  73. package/backend/src/flowent/providers/__pycache__/openai.cpython-313.pyc +0 -0
  74. package/backend/src/flowent/providers/__pycache__/openai_responses.cpython-313.pyc +0 -0
  75. package/backend/src/flowent/providers/__pycache__/registry.cpython-313.pyc +0 -0
  76. package/backend/src/flowent/providers/__pycache__/sse.cpython-313.pyc +0 -0
  77. package/backend/src/flowent/providers/__pycache__/thinking.cpython-313.pyc +0 -0
  78. package/backend/src/flowent/providers/configuration.py +7 -0
  79. package/backend/src/flowent/role_management.py +12 -0
  80. package/backend/src/flowent/routes/__init__.py +0 -2
  81. package/backend/src/flowent/routes/__pycache__/__init__.cpython-313.pyc +0 -0
  82. package/backend/src/flowent/routes/__pycache__/access.cpython-313.pyc +0 -0
  83. package/backend/src/flowent/routes/__pycache__/assistant.cpython-313.pyc +0 -0
  84. package/backend/src/flowent/routes/__pycache__/image_assets.cpython-313.pyc +0 -0
  85. package/backend/src/flowent/routes/__pycache__/mcp.cpython-313.pyc +0 -0
  86. package/backend/src/flowent/routes/__pycache__/meta.cpython-313.pyc +0 -0
  87. package/backend/src/flowent/routes/__pycache__/nodes.cpython-313.pyc +0 -0
  88. package/backend/src/flowent/routes/__pycache__/prompts.cpython-313.pyc +0 -0
  89. package/backend/src/flowent/routes/__pycache__/providers_route.cpython-313.pyc +0 -0
  90. package/backend/src/flowent/routes/__pycache__/roles.cpython-313.pyc +0 -0
  91. package/backend/src/flowent/routes/__pycache__/settings.cpython-313.pyc +0 -0
  92. package/backend/src/flowent/routes/__pycache__/tabs.cpython-313.pyc +0 -0
  93. package/backend/src/flowent/routes/__pycache__/ws.cpython-313.pyc +0 -0
  94. package/backend/src/flowent/routes/assistant.py +4 -4
  95. package/backend/src/flowent/routes/nodes.py +54 -6
  96. package/backend/src/flowent/routes/providers_route.py +1 -0
  97. package/backend/src/flowent/routes/roles.py +1 -1
  98. package/backend/src/flowent/routes/settings.py +4 -0
  99. package/backend/src/flowent/routes/tabs.py +29 -11
  100. package/backend/src/flowent/runtime.py +7 -30
  101. package/backend/src/flowent/security.py +23 -8
  102. package/backend/src/flowent/settings.py +56 -5
  103. package/backend/src/flowent/settings_management.py +12 -0
  104. package/backend/src/flowent/static/assets/AssistantPage-VBohhz4d.js +1 -0
  105. package/backend/src/flowent/static/assets/ChannelsPage-CIydPZA_.js +1 -0
  106. package/backend/src/flowent/static/assets/McpPage-CHPm2TPY.js +7 -0
  107. package/backend/src/flowent/static/assets/PageScaffold-DteOA8V7.js +1 -0
  108. package/backend/src/flowent/static/assets/PromptsPage-CSmJ3sZg.js +1 -0
  109. package/backend/src/flowent/static/assets/ProvidersPage-sl2jeG4e.js +3 -0
  110. package/backend/src/flowent/static/assets/RolesPage-DCe7W6Km.js +1 -0
  111. package/backend/src/flowent/static/assets/SettingsPage-Bix9e63E.js +3 -0
  112. package/backend/src/flowent/static/assets/ToolsPage-favNkj5C.js +1 -0
  113. package/backend/src/flowent/static/assets/WorkspaceCommandDialog-DRS6wiD6.js +1 -0
  114. package/backend/src/flowent/static/assets/WorkspacePage-KuaDjt_D.js +3 -0
  115. package/backend/src/flowent/static/assets/WorkspacePanels-BZxBw8M5.js +1 -0
  116. package/backend/src/flowent/static/assets/alert-dialog-DIBUCmqM.js +1 -0
  117. package/backend/src/flowent/static/assets/{dialog-BeGSweF6.js → dialog-BOvHIBrg.js} +1 -1
  118. package/backend/src/flowent/static/assets/index-Biio-CoI.js +10 -0
  119. package/backend/src/flowent/static/assets/index-CmQvO7sl.css +1 -0
  120. package/backend/src/flowent/static/assets/modelParams-DcEhGnu0.js +1 -0
  121. package/backend/src/flowent/static/assets/roles-BbIEIMeG.js +1 -0
  122. package/backend/src/flowent/static/assets/select-D9SwnlXF.js +1 -0
  123. package/backend/src/flowent/static/assets/surface-Bzr1FRG4.js +1 -0
  124. package/backend/src/flowent/static/assets/{ui-vendor-Dg9NNnWX.js → ui-vendor-UazN8rcv.js} +15 -15
  125. package/backend/src/flowent/static/index.html +3 -4
  126. package/backend/src/flowent/tools/__init__.py +76 -2
  127. package/backend/src/flowent/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  128. package/backend/src/flowent/tools/__pycache__/connect.cpython-313.pyc +0 -0
  129. package/backend/src/flowent/tools/__pycache__/contacts.cpython-313.pyc +0 -0
  130. package/backend/src/flowent/tools/__pycache__/create_agent.cpython-313.pyc +0 -0
  131. package/backend/src/flowent/tools/__pycache__/create_tab.cpython-313.pyc +0 -0
  132. package/backend/src/flowent/tools/__pycache__/delete_tab.cpython-313.pyc +0 -0
  133. package/backend/src/flowent/tools/__pycache__/edit.cpython-313.pyc +0 -0
  134. package/backend/src/flowent/tools/__pycache__/exec.cpython-313.pyc +0 -0
  135. package/backend/src/flowent/tools/__pycache__/fetch.cpython-313.pyc +0 -0
  136. package/backend/src/flowent/tools/__pycache__/idle.cpython-313.pyc +0 -0
  137. package/backend/src/flowent/tools/__pycache__/list_roles.cpython-313.pyc +0 -0
  138. package/backend/src/flowent/tools/__pycache__/list_tabs.cpython-313.pyc +0 -0
  139. package/backend/src/flowent/tools/__pycache__/list_tools.cpython-313.pyc +0 -0
  140. package/backend/src/flowent/tools/__pycache__/manage_prompts.cpython-313.pyc +0 -0
  141. package/backend/src/flowent/tools/__pycache__/manage_providers.cpython-313.pyc +0 -0
  142. package/backend/src/flowent/tools/__pycache__/manage_roles.cpython-313.pyc +0 -0
  143. package/backend/src/flowent/tools/__pycache__/manage_settings.cpython-313.pyc +0 -0
  144. package/backend/src/flowent/tools/__pycache__/mcp.cpython-313.pyc +0 -0
  145. package/backend/src/flowent/tools/__pycache__/read.cpython-313.pyc +0 -0
  146. package/backend/src/flowent/tools/__pycache__/send.cpython-313.pyc +0 -0
  147. package/backend/src/flowent/tools/__pycache__/set_permissions.cpython-313.pyc +0 -0
  148. package/backend/src/flowent/tools/__pycache__/sleep.cpython-313.pyc +0 -0
  149. package/backend/src/flowent/tools/__pycache__/todo.cpython-313.pyc +0 -0
  150. package/backend/src/flowent/tools/connect.py +10 -66
  151. package/backend/src/flowent/tools/contacts.py +1 -1
  152. package/backend/src/flowent/tools/create_agent.py +9 -88
  153. package/backend/src/flowent/tools/create_tab.py +7 -5
  154. package/backend/src/flowent/tools/exec.py +3 -2
  155. package/backend/src/flowent/tools/list_roles.py +29 -4
  156. package/backend/src/flowent/tools/list_tabs.py +4 -0
  157. package/backend/src/flowent/tools/list_tools.py +5 -1
  158. package/backend/src/flowent/tools/manage_settings.py +18 -0
  159. package/backend/src/flowent/tools/send.py +21 -3
  160. package/backend/src/flowent/tools/set_permissions.py +21 -6
  161. package/backend/tests/__pycache__/__init__.cpython-313.pyc +0 -0
  162. package/backend/tests/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
  163. package/backend/tests/integration/api/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
  164. package/backend/tests/integration/api/__pycache__/test_access_api.cpython-313-pytest-9.0.3.pyc +0 -0
  165. package/backend/tests/integration/api/__pycache__/test_assistant_api.cpython-313-pytest-9.0.3.pyc +0 -0
  166. package/backend/tests/integration/api/__pycache__/test_frontend_mounting.cpython-313-pytest-9.0.3.pyc +0 -0
  167. package/backend/tests/integration/api/__pycache__/test_mcp_api.cpython-313-pytest-9.0.3.pyc +0 -0
  168. package/backend/tests/integration/api/__pycache__/test_meta_api.cpython-313-pytest-9.0.3.pyc +0 -0
  169. package/backend/tests/integration/api/__pycache__/test_nodes_api.cpython-313-pytest-9.0.3.pyc +0 -0
  170. package/backend/tests/integration/api/__pycache__/test_prompts_api.cpython-313-pytest-9.0.3.pyc +0 -0
  171. package/backend/tests/integration/api/__pycache__/test_roles_api.cpython-313-pytest-9.0.3.pyc +0 -0
  172. package/backend/tests/integration/api/__pycache__/test_tabs_api.cpython-313-pytest-9.0.3.pyc +0 -0
  173. package/backend/tests/integration/api/test_assistant_api.py +1 -1
  174. package/backend/tests/integration/api/test_nodes_api.py +257 -21
  175. package/backend/tests/integration/api/test_roles_api.py +3 -2
  176. package/backend/tests/integration/api/test_tabs_api.py +312 -11
  177. package/backend/tests/unit/__pycache__/test_access.cpython-313-pytest-9.0.3.pyc +0 -0
  178. package/backend/tests/unit/__pycache__/test_cli.cpython-313-pytest-9.0.3.pyc +0 -0
  179. package/backend/tests/unit/__pycache__/test_graph_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  180. package/backend/tests/unit/__pycache__/test_network.cpython-313-pytest-9.0.3.pyc +0 -0
  181. package/backend/tests/unit/__pycache__/test_state_sqlite_storage.cpython-313-pytest-9.0.3.pyc +0 -0
  182. package/backend/tests/unit/__pycache__/test_workspace_store.cpython-313-pytest-9.0.3.pyc +0 -0
  183. package/backend/tests/unit/agent/__pycache__/test_agent_public_api.cpython-313-pytest-9.0.3.pyc +0 -0
  184. package/backend/tests/unit/agent/__pycache__/test_agent_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  185. package/backend/tests/unit/agent/test_agent_public_api.py +162 -71
  186. package/backend/tests/unit/agent/test_agent_runtime.py +285 -69
  187. package/backend/tests/unit/channels/__pycache__/test_telegram_channel.cpython-313-pytest-9.0.3.pyc +0 -0
  188. package/backend/tests/unit/logging/__pycache__/test_logging.cpython-313-pytest-9.0.3.pyc +0 -0
  189. package/backend/tests/unit/prompts/__pycache__/test_prompts.cpython-313-pytest-9.0.3.pyc +0 -0
  190. package/backend/tests/unit/prompts/test_prompts.py +3 -2
  191. package/backend/tests/unit/providers/__pycache__/test_anthropic_provider.cpython-313-pytest-9.0.3.pyc +0 -0
  192. package/backend/tests/unit/providers/__pycache__/test_errors.cpython-313-pytest-9.0.3.pyc +0 -0
  193. package/backend/tests/unit/providers/__pycache__/test_extract_delta_parts.cpython-313-pytest-9.0.3.pyc +0 -0
  194. package/backend/tests/unit/providers/__pycache__/test_openai_provider.cpython-313-pytest-9.0.3.pyc +0 -0
  195. package/backend/tests/unit/providers/__pycache__/test_openai_responses.cpython-313-pytest-9.0.3.pyc +0 -0
  196. package/backend/tests/unit/providers/__pycache__/test_provider_gateway.cpython-313-pytest-9.0.3.pyc +0 -0
  197. package/backend/tests/unit/providers/__pycache__/test_think_tag_parser.cpython-313-pytest-9.0.3.pyc +0 -0
  198. package/backend/tests/unit/routes/__pycache__/test_prompts_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  199. package/backend/tests/unit/routes/__pycache__/test_providers_route.cpython-313-pytest-9.0.3.pyc +0 -0
  200. package/backend/tests/unit/routes/__pycache__/test_roles_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  201. package/backend/tests/unit/routes/__pycache__/test_settings_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  202. package/backend/tests/unit/routes/test_providers_route.py +2 -0
  203. package/backend/tests/unit/routes/test_roles_routes.py +109 -0
  204. package/backend/tests/unit/routes/test_settings_routes.py +4 -0
  205. package/backend/tests/unit/runtime/__pycache__/test_bootstrap_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  206. package/backend/tests/unit/runtime/test_bootstrap_runtime.py +8 -18
  207. package/backend/tests/unit/sandbox/__pycache__/test_sandbox_tools.cpython-313-pytest-9.0.3.pyc +0 -0
  208. package/backend/tests/unit/security/__pycache__/test_security.cpython-313-pytest-9.0.3.pyc +0 -0
  209. package/backend/tests/unit/security/test_security.py +16 -2
  210. package/backend/tests/unit/settings/__pycache__/test_settings_roles.cpython-313-pytest-9.0.3.pyc +0 -0
  211. package/backend/tests/unit/settings/test_settings_roles.py +40 -0
  212. package/backend/tests/unit/test_state_sqlite_storage.py +67 -1
  213. package/backend/tests/unit/tools/__pycache__/test_connect_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  214. package/backend/tests/unit/tools/__pycache__/test_create_agent_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  215. package/backend/tests/unit/tools/__pycache__/test_delete_tab_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  216. package/backend/tests/unit/tools/__pycache__/test_edit_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  217. package/backend/tests/unit/tools/__pycache__/test_exec_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  218. package/backend/tests/unit/tools/__pycache__/test_fetch_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  219. package/backend/tests/unit/tools/__pycache__/test_manage_prompts_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  220. package/backend/tests/unit/tools/__pycache__/test_manage_providers_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  221. package/backend/tests/unit/tools/__pycache__/test_manage_roles_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  222. package/backend/tests/unit/tools/__pycache__/test_manage_settings_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  223. package/backend/tests/unit/tools/__pycache__/test_read_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  224. package/backend/tests/unit/tools/__pycache__/test_set_permissions_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  225. package/backend/tests/unit/tools/__pycache__/test_todo_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  226. package/backend/tests/unit/tools/__pycache__/test_tool_registry.cpython-313-pytest-9.0.3.pyc +0 -0
  227. package/backend/tests/unit/tools/test_connect_tool.py +2 -3
  228. package/backend/tests/unit/tools/test_create_agent_tool.py +9 -97
  229. package/backend/tests/unit/tools/test_delete_tab_tool.py +33 -0
  230. package/backend/tests/unit/tools/test_manage_providers_tool.py +2 -0
  231. package/backend/tests/unit/tools/test_manage_settings_tool.py +3 -0
  232. package/backend/tests/unit/tools/test_set_permissions_tool.py +216 -12
  233. package/backend/tests/unit/tools/test_tool_registry.py +103 -0
  234. package/backend/uv.lock +1 -1
  235. package/dist/frontend/assets/AssistantPage-VBohhz4d.js +1 -0
  236. package/dist/frontend/assets/ChannelsPage-CIydPZA_.js +1 -0
  237. package/dist/frontend/assets/McpPage-CHPm2TPY.js +7 -0
  238. package/dist/frontend/assets/PageScaffold-DteOA8V7.js +1 -0
  239. package/dist/frontend/assets/PromptsPage-CSmJ3sZg.js +1 -0
  240. package/dist/frontend/assets/ProvidersPage-sl2jeG4e.js +3 -0
  241. package/dist/frontend/assets/RolesPage-DCe7W6Km.js +1 -0
  242. package/dist/frontend/assets/SettingsPage-Bix9e63E.js +3 -0
  243. package/dist/frontend/assets/ToolsPage-favNkj5C.js +1 -0
  244. package/dist/frontend/assets/WorkspaceCommandDialog-DRS6wiD6.js +1 -0
  245. package/dist/frontend/assets/WorkspacePage-KuaDjt_D.js +3 -0
  246. package/dist/frontend/assets/WorkspacePanels-BZxBw8M5.js +1 -0
  247. package/dist/frontend/assets/alert-dialog-DIBUCmqM.js +1 -0
  248. package/dist/frontend/assets/{dialog-BeGSweF6.js → dialog-BOvHIBrg.js} +1 -1
  249. package/dist/frontend/assets/index-Biio-CoI.js +10 -0
  250. package/dist/frontend/assets/index-CmQvO7sl.css +1 -0
  251. package/dist/frontend/assets/modelParams-DcEhGnu0.js +1 -0
  252. package/dist/frontend/assets/roles-BbIEIMeG.js +1 -0
  253. package/dist/frontend/assets/select-D9SwnlXF.js +1 -0
  254. package/dist/frontend/assets/surface-Bzr1FRG4.js +1 -0
  255. package/dist/frontend/assets/{ui-vendor-Dg9NNnWX.js → ui-vendor-UazN8rcv.js} +15 -15
  256. package/dist/frontend/index.html +3 -4
  257. package/package.json +3 -3
  258. package/backend/src/flowent/routes/__pycache__/stats.cpython-313.pyc +0 -0
  259. package/backend/src/flowent/routes/stats.py +0 -229
  260. package/backend/src/flowent/static/assets/AssistantPage-B3Xc08AS.js +0 -1
  261. package/backend/src/flowent/static/assets/ChannelsPage-ByLd28xk.js +0 -1
  262. package/backend/src/flowent/static/assets/HomePage-C0hAx9_l.js +0 -3
  263. package/backend/src/flowent/static/assets/McpPage-DkrYLvBv.js +0 -7
  264. package/backend/src/flowent/static/assets/PageScaffold-D4jO9ooX.js +0 -1
  265. package/backend/src/flowent/static/assets/PromptsPage-DWA7rRJd.js +0 -1
  266. package/backend/src/flowent/static/assets/ProvidersPage-PUWT8seJ.js +0 -3
  267. package/backend/src/flowent/static/assets/RolesPage-CqcclGRw.js +0 -1
  268. package/backend/src/flowent/static/assets/SettingsPage-8tS2cJgX.js +0 -3
  269. package/backend/src/flowent/static/assets/StatsPage-BX9khYzu.js +0 -1
  270. package/backend/src/flowent/static/assets/ToolsPage-9Tl9FdeD.js +0 -1
  271. package/backend/src/flowent/static/assets/WorkspaceCommandDialog-CCXxjDL8.js +0 -1
  272. package/backend/src/flowent/static/assets/WorkspacePanels-aMdJ7ZH7.js +0 -1
  273. package/backend/src/flowent/static/assets/alert-dialog-kFYVQ7oX.js +0 -1
  274. package/backend/src/flowent/static/assets/badge-74-3jsCg.js +0 -1
  275. package/backend/src/flowent/static/assets/constants-XUzFf6i1.js +0 -1
  276. package/backend/src/flowent/static/assets/index-BHC1Vhy8.css +0 -1
  277. package/backend/src/flowent/static/assets/index-CL1ALZ3r.js +0 -10
  278. package/backend/src/flowent/static/assets/modelParams-CaHd0903.js +0 -1
  279. package/backend/src/flowent/static/assets/roles-2OLDeTc5.js +0 -1
  280. package/backend/src/flowent/static/assets/select-DL_LPeDj.js +0 -1
  281. package/backend/src/flowent/static/assets/shared-CMxbpLeQ.js +0 -1
  282. package/backend/tests/unit/routes/__pycache__/test_stats_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  283. package/backend/tests/unit/routes/test_stats_routes.py +0 -149
  284. package/dist/frontend/assets/AssistantPage-B3Xc08AS.js +0 -1
  285. package/dist/frontend/assets/ChannelsPage-ByLd28xk.js +0 -1
  286. package/dist/frontend/assets/HomePage-C0hAx9_l.js +0 -3
  287. package/dist/frontend/assets/McpPage-DkrYLvBv.js +0 -7
  288. package/dist/frontend/assets/PageScaffold-D4jO9ooX.js +0 -1
  289. package/dist/frontend/assets/PromptsPage-DWA7rRJd.js +0 -1
  290. package/dist/frontend/assets/ProvidersPage-PUWT8seJ.js +0 -3
  291. package/dist/frontend/assets/RolesPage-CqcclGRw.js +0 -1
  292. package/dist/frontend/assets/SettingsPage-8tS2cJgX.js +0 -3
  293. package/dist/frontend/assets/StatsPage-BX9khYzu.js +0 -1
  294. package/dist/frontend/assets/ToolsPage-9Tl9FdeD.js +0 -1
  295. package/dist/frontend/assets/WorkspaceCommandDialog-CCXxjDL8.js +0 -1
  296. package/dist/frontend/assets/WorkspacePanels-aMdJ7ZH7.js +0 -1
  297. package/dist/frontend/assets/alert-dialog-kFYVQ7oX.js +0 -1
  298. package/dist/frontend/assets/badge-74-3jsCg.js +0 -1
  299. package/dist/frontend/assets/constants-XUzFf6i1.js +0 -1
  300. package/dist/frontend/assets/index-BHC1Vhy8.css +0 -1
  301. package/dist/frontend/assets/index-CL1ALZ3r.js +0 -10
  302. package/dist/frontend/assets/modelParams-CaHd0903.js +0 -1
  303. package/dist/frontend/assets/roles-2OLDeTc5.js +0 -1
  304. package/dist/frontend/assets/select-DL_LPeDj.js +0 -1
  305. package/dist/frontend/assets/shared-CMxbpLeQ.js +0 -1
  306. /package/backend/src/flowent/static/assets/{datetime-m6_O_Ci9.js → datetime-eJqd0V2S.js} +0 -0
  307. /package/backend/src/flowent/static/assets/{markdown-vendor-DVdy_w12.js → markdown-vendor-C9RtvaJh.js} +0 -0
  308. /package/backend/src/flowent/static/assets/{triState-DEr3NkXV.js → triState-DgLlKdRR.js} +0 -0
  309. /package/dist/frontend/assets/{datetime-m6_O_Ci9.js → datetime-eJqd0V2S.js} +0 -0
  310. /package/dist/frontend/assets/{markdown-vendor-DVdy_w12.js → markdown-vendor-C9RtvaJh.js} +0 -0
  311. /package/dist/frontend/assets/{triState-DEr3NkXV.js → triState-DgLlKdRR.js} +0 -0
@@ -1,149 +0,0 @@
1
- import asyncio
2
-
3
- import pytest
4
- from fastapi import HTTPException
5
-
6
- from flowent.agent import Agent
7
- from flowent.models import AgentState, NodeConfig, NodeType, Tab
8
- from flowent.registry import registry
9
- from flowent.routes.stats import get_stats
10
- from flowent.settings import ModelSettings, ProviderConfig, Settings
11
- from flowent.stats_service import (
12
- CompactRecordInput,
13
- RequestRecordInput,
14
- stats_store,
15
- )
16
- from flowent.workspace_store import workspace_store
17
-
18
-
19
- @pytest.fixture(autouse=True)
20
- def reset_stats_route_state(monkeypatch, tmp_path):
21
- import flowent.settings as settings_module
22
-
23
- settings_file = tmp_path / "settings.json"
24
- settings_file.write_text("{}", encoding="utf-8")
25
- monkeypatch.setattr(settings_module, "_SETTINGS_FILE", settings_file)
26
- monkeypatch.setattr(settings_module, "_cached_settings", None)
27
- registry.reset()
28
- workspace_store.reset_cache()
29
- stats_store.reset()
30
- yield
31
- registry.reset()
32
- workspace_store.reset_cache()
33
- stats_store.reset()
34
- monkeypatch.setattr(settings_module, "_cached_settings", None)
35
-
36
-
37
- def test_get_stats_returns_current_snapshots_and_recent_records(monkeypatch):
38
- settings = Settings(
39
- model=ModelSettings(
40
- active_provider_id="provider-1",
41
- active_model="gpt-5.2",
42
- ),
43
- providers=[
44
- ProviderConfig(
45
- id="provider-1",
46
- name="Primary",
47
- type="openai_responses",
48
- base_url="https://api.example.com/v1",
49
- api_key="secret",
50
- )
51
- ],
52
- )
53
- monkeypatch.setattr("flowent.routes.stats.get_settings", lambda: settings)
54
-
55
- workspace_store.upsert_tab(Tab(id="tab-1", title="Main Task", leader_id="leader-1"))
56
- leader = Agent(
57
- NodeConfig(
58
- node_type=NodeType.AGENT,
59
- role_name="Conductor",
60
- tab_id="tab-1",
61
- name="Leader",
62
- ),
63
- uuid="leader-1",
64
- )
65
- leader.prime_runtime_state(AgentState.RUNNING)
66
- registry.register(leader)
67
-
68
- now = 1_760_000_000.0
69
- monkeypatch.setattr("flowent.routes.stats.time.time", lambda: now)
70
- stats_store.record_request(
71
- RequestRecordInput(
72
- node_id="leader-1",
73
- node_label="Leader",
74
- role_name="Conductor",
75
- tab_id="tab-1",
76
- tab_title="Main Task",
77
- provider_id="provider-1",
78
- provider_name="Primary",
79
- provider_type="openai_responses",
80
- model="gpt-5.2",
81
- started_at=now - 60,
82
- ended_at=now - 58,
83
- retry_count=1,
84
- result="success",
85
- raw_usage={"total_tokens": 120},
86
- )
87
- )
88
- stats_store.record_compact(
89
- CompactRecordInput(
90
- node_id="leader-1",
91
- node_label="Leader",
92
- role_name="Conductor",
93
- tab_id="tab-1",
94
- tab_title="Main Task",
95
- provider_id="provider-1",
96
- provider_name="Primary",
97
- provider_type="openai_responses",
98
- model="gpt-5.2",
99
- trigger_type="auto",
100
- started_at=now - 30,
101
- ended_at=now - 29,
102
- result="success",
103
- )
104
- )
105
- stats_store.record_request(
106
- RequestRecordInput(
107
- node_id="leader-1",
108
- node_label="Leader",
109
- role_name="Conductor",
110
- tab_id="tab-1",
111
- tab_title="Main Task",
112
- provider_id="provider-1",
113
- provider_name="Primary",
114
- provider_type="openai_responses",
115
- model="gpt-5.2",
116
- started_at=now - 40 * 24 * 60 * 60,
117
- ended_at=now - 40 * 24 * 60 * 60 + 1,
118
- retry_count=0,
119
- result="error",
120
- error_summary="too old",
121
- )
122
- )
123
-
124
- result = asyncio.run(get_stats(range="24h"))
125
-
126
- assert result["range"] == "24h"
127
- assert len(result["workflows"]) == 1
128
- assert result["workflows"][0]["title"] == "Main Task"
129
- assert len(result["nodes"]) == 1
130
- assert result["nodes"][0]["id"] == "leader-1"
131
- assert result["nodes"][0]["state"] == "running"
132
- assert result["nodes"][0]["workflow_id"] == "tab-1"
133
- assert result["nodes"][0]["provider_id"] == "provider-1"
134
- assert result["nodes"][0]["model"] == "gpt-5.2"
135
- assert len(result["requests"]) == 1
136
- assert result["requests"][0]["retry_count"] == 1
137
- assert result["requests"][0]["workflow_id"] == "tab-1"
138
- assert result["requests"][0]["raw_usage"] == {"total_tokens": 120}
139
- assert len(result["compacts"]) == 1
140
- assert result["compacts"][0]["trigger_type"] == "auto"
141
- assert result["compacts"][0]["workflow_id"] == "tab-1"
142
-
143
-
144
- def test_get_stats_rejects_invalid_range():
145
- with pytest.raises(HTTPException) as exc:
146
- asyncio.run(get_stats(range="12h"))
147
-
148
- assert exc.value.status_code == 400
149
- assert exc.value.detail == "range must be one of: 1h, 24h, 7d, 30d"
@@ -1 +0,0 @@
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}from"./ui-vendor-Dg9NNnWX.js";import{a as i,t as a}from"./shared-CMxbpLeQ.js";import{C as o,D as s,E as c,S as ee,T as l,_ as te,b as u,d,f as ne,g as f,h as p,l as re,m as ie,p as ae,t as m,u as oe,v as se,w as ce,x as h,y as g}from"./WorkspacePanels-aMdJ7ZH7.js";import{J as _,N as v,P as y,b,g as x,h as S,j as C,m as w,p as le,x as ue,y as T}from"./index-CL1ALZ3r.js";async function de(e){return a(`/api/assistant/message`,{method:`POST`,body:e,errorMessage:`Failed to send Assistant message`})}async function fe(e){return a(`/api/assistant/messages/${e}/retry`,{method:`POST`,errorMessage:`Failed to retry Assistant message`})}var E=e(t(),1);function D(e){for(let t of e.values())if(t.node_type===`assistant`)return t;return null}function pe(e){return D(e)?.id??null}var O=`assistant`;function me(){return u(O)}function he(e){return h(O,e)}function ge(e){g(O,e)}function k(e={}){let{bottomInset:t=0}=e,{agents:n}=x(),{connected:i}=w(),{agentHistories:a,clearAgentHistory:c,clearHistorySnapshot:l,historyInvalidatedAt:u,historyClearedAt:m,historySnapshots:ce,streamingDeltas:h}=S(),{activeToolCalls:g}=le(),[_,D]=(0,E.useState)(null),[O,k]=(0,E.useState)(0),[A,j]=(0,E.useState)(``),[M,N]=(0,E.useState)([]),[P,F]=(0,E.useState)(null),[I,_e]=(0,E.useState)(!1),[ve,ye]=(0,E.useState)(null),[be,xe]=(0,E.useState)(!1),[L,R]=(0,E.useState)([]),z=(0,E.useRef)(null),B=(0,E.useRef)(!0),Se=(0,E.useRef)([]),V=(0,E.useMemo)(()=>pe(n),[n]),H=(0,E.useMemo)(()=>V?n.get(V)??null:null,[n,V]),U=H?.capabilities?.input_image??!1,W=V?m.get(V)??0:0,G=V?u.get(V)??0:0,K=V?ce.get(V)??null:null,Ce=M.some(e=>e.status===`uploading`),we=M.filter(ae),q=(0,E.useSyncExternalStore)(he,me,me),J=P===null?null:q[P]??null,Y=J!==null&&A===J.text&&ne(M,J),X=(0,E.useCallback)((e,t)=>{F(t),j(e?.text??``),N(e?te(e):[])},[]),Te=(0,E.useCallback)(e=>{F(null),j(e)},[]);(0,E.useEffect)(()=>{Se.current=M},[M]),(0,E.useEffect)(()=>()=>{f(Se.current)},[]),(0,E.useEffect)(()=>{W&&(R([]),D(e=>e&&{...e,history:ee(e.history)}),k(Date.now()))},[W]),(0,E.useEffect)(()=>{G&&(R([]),K&&(D(e=>e&&{...e,history:K}),k(Date.now())))},[G,K]),(0,E.useEffect)(()=>{if(!i||!V){D(null);return}let e=new AbortController,t=!1;return(async()=>{c(V);try{let n=await v(V,e.signal);if(t||!n)return;D(n),k(Date.now()),l(V)}catch{!t&&!e.signal.aborted&&r.error(`Failed to load Assistant history`)}})(),()=>{t=!0,e.abort()}},[W,G,V,c,l,i]);let Z=(0,E.useMemo)(()=>V?o({history:K??_?.history??[],incremental:a.get(V),deltas:h.get(V),fetchedAt:O||Date.now()}):[],[a,K,_,O,h,V]);(0,E.useEffect)(()=>{if(!V||L.length===0)return;let e=Z.filter(e=>e.type===`ReceivedMessage`&&e.from_id===`human`&&(!!e.content||!!e.message_id||!!e.parts?.length));e.length!==0&&R(t=>e.reduce((e,t)=>T(e,{content:t.content??b(t.parts,t.content),messageId:t.message_id}),t))},[V,Z,L.length]);let Q=(0,E.useMemo)(()=>[...Z,...L.map(e=>({...e}))],[Z,L]),$=(0,E.useMemo)(()=>{let e=L.length,t=V?h.get(V)??[]:[],n=i&&(e>0||H?.state===`running`||H?.state===`sleeping`||g.has(V??``)||t.length>0),r=[...Q].map((e,t)=>({item:e,index:t})).reverse().find(({item:e})=>e.type===`PendingHumanMessage`?!0:e.type===`ReceivedMessage`&&e.from_id===`human`&&ue(e.parts,e.content).length>0)?.index,a=r===void 0?[]:Q.slice(r+1),o=a.some(e=>e.type===`AssistantText`&&ue(e.parts,e.content).length>0),s=[...a].reverse().find(e=>e.type===`ToolCall`&&e.streaming===!0),c=(V?g.get(V)??null:null)??s?.tool_name??null;return{running:n,runningHint:n&&r!==void 0&&!o?{label:c?`Running tools...`:`Thinking...`,toolName:c}:null}},[g,V,H?.state,i,L.length,h,Q]);(0,E.useLayoutEffect)(()=>{let e=z.current;!e||!B.current||(e.scrollTop=e.scrollHeight)},[t,$.runningHint?`${$.runningHint.label}:${$.runningHint.toolName??``}`:``,Q]),(0,E.useLayoutEffect)(()=>{let e=z.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{B.current&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>{t.disconnect()}},[]);let Ee=e=>{B.current=ie(e.currentTarget)},De=async()=>{let e=A.trim();if(!e&&we.length===0||Ce||be)return;let t=re(e,we),n=A,i=M,a=P,o=Date.now(),s=e||b(t),c=oe(s,t,o);xe(!0),F(null),j(``),N([]),R(e=>[...e,c]);try{let e=await de({content:s,parts:t});e.status===`command_executed`?R(e=>T(e,{content:s,timestamp:o})):e.message_id&&R(t=>t.map(t=>t.timestamp===o&&t.content===s?{...t,message_id:e.message_id}:t)),ge({text:n,images:se(i),timestamp:o}),f(i)}catch(e){R(e=>T(e,{content:s,timestamp:o})),j(n),N(i),F(a),r.error(e instanceof Error?e.message:`Failed to send message`)}finally{xe(!1)}},Oe=(0,E.useCallback)(async e=>{if(F(null),!U){r.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 d(t);N(e=>[...e,...n]),await Promise.all(n.map(async(e,n)=>{let i=t[n];if(i)try{let t=await s(i);N(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){p(e),N(t=>t.filter(t=>t.id!==e.id)),r.error(t instanceof Error?t.message:`Failed to upload image`)}}))},[U]),ke=(0,E.useCallback)(e=>{F(null),N(t=>{let n=t.find(t=>t.id===e);return n&&p(n),t.filter(t=>t.id!==e)})},[]),Ae=(0,E.useCallback)((e,t)=>{if(q.length===0)return!1;let n=t.start,r=t.end,i=A.length===0&&M.length===0,a=typeof n==`number`&&typeof r==`number`&&n===r&&(n===0||n===A.length);if(!i&&!(J!==null&&Y&&a))return!1;if(P===null){if(e!==-1)return!1;let t=q.length-1;return X(q[t]??null,t),!0}if(e===-1){let e=Math.max(P-1,0);return X(q[e]??null,e),!0}if(P>=q.length-1)return X(null,null),!0;let o=P+1;return X(q[o]??null,o),!0},[J,M,P,A,q,Y,X]),je=async()=>{if(!(!V||I)){_e(!0);try{await C(V),R([]),c(V),D(await v(V)),k(Date.now()),l(V)}catch(e){r.error(e instanceof Error?e.message:`Failed to clear assistant chat`)}finally{_e(!1)}}},Me=(0,E.useCallback)(async()=>{if(V&&!(H?.state!==`running`&&H?.state!==`sleeping`)){await y(V);for(let e=0;e<25;e+=1){let e=await v(V);if(!e)break;if(D(e),k(Date.now()),e.state!==`running`&&e.state!==`sleeping`)return;await new Promise(e=>window.setTimeout(e,120))}throw Error(`Assistant did not stop in time`)}},[V,H?.state]);return{addImages:Oe,connected:i,draftImages:M,handleKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),De())},hasUploadingImages:Ce,input:A,isBrowsingInputHistory:Y,navigateInputHistory:Ae,onMessagesScroll:Ee,removeImage:ke,retryMessage:async e=>{if(!(!V||!e||ve)){ye(e);try{try{await Me(),await fe(e)}catch(e){r.error(e instanceof Error?e.message:`Failed to retry Assistant message`);return}c(V);try{let e=await v(V);e&&(D(e),k(Date.now()),l(V))}catch{return}}finally{ye(null)}}},retryingMessageId:ve,scrollRef:z,clearing:I,sending:be,clearChat:je,sendMessage:De,setInput:Te,supportsInputImage:U,timelineItems:Q,assistantActivity:$}}var A=n();function j({onOpenDetails:e,variant:t=`page`}){let{agents:n}=x(),{height:r,ref:a}=ce(),{addImages:o=async()=>{},assistantActivity:s={running:!1},clearChat:ee,clearing:te=!1,connected:u,draftImages:d=[],handleKeyDown:ne,hasUploadingImages:f=!1,input:p,isBrowsingInputHistory:re,navigateInputHistory:ie,onMessagesScroll:ae,removeImage:m=()=>{},retryMessage:oe,retryingMessageId:se,scrollRef:h,sending:g,sendMessage:_,setInput:v,supportsInputImage:y=!1,timelineItems:b}=k({bottomInset:r}),S=t===`floating`,C=t===`page`,w=t,le=Array.from(n.values()).find(e=>e.node_type===`assistant`)?.role_name??null;return(0,A.jsxs)(`div`,{className:i(`relative flex h-full flex-col overflow-hidden text-foreground`,S?`overflow-hidden rounded-xl border border-border bg-surface-2 text-foreground shadow-md`:C?`bg-transparent`:`border-l border-border bg-surface-overlay/94 shadow-sm`),children:[(0,A.jsx)(`div`,{"aria-hidden":`true`,className:i(`pointer-events-none absolute inset-0 transition-[opacity,border-color,box-shadow] duration-300`,s.running?`animate-pulse shadow-lg shadow-ring/5`:`opacity-0`,!C&&`border`,s.running&&!C&&`border-ring/25 opacity-100 shadow-ring/10`)}),(0,A.jsx)(M,{connected:u,floating:S,page:C,onClearChat:()=>void ee(),onOpenDetails:e,roleName:le,clearing:te}),(0,A.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(l,{allowHumanMessageRetry:!0,bottomInset:r,items:b,nodes:n,onRetryHumanMessage:e=>void oe(e),onScroll:ae,retryImageInputEnabled:y,retryingMessageId:se,scrollRef:h,runningHint:s.running?{label:`Assistant is working...`,toolName:null}:null,variant:w}),(0,A.jsx)(`div`,{ref:a,style:{paddingBottom:`calc(14px + env(safe-area-inset-bottom, 0px))`},className:i(`absolute inset-x-0 bottom-0 z-10 px-4`,C?`mx-auto w-full max-w-3xl`:``,S?`bg-gradient-to-b from-transparent via-background/70 to-background/95 pt-8 pointer-events-none`:C?`bg-gradient-to-b from-transparent via-background/90 to-background pt-12 pointer-events-none`:`bg-gradient-to-b from-transparent via-background/80 to-background pt-10 pointer-events-none`),children:(0,A.jsx)(`div`,{className:`pointer-events-auto`,children:(0,A.jsx)(c,{disabled:!p.trim()&&d.length===0||f||g,commandsEnabled:!0,images:d,imageInputEnabled:y,input:p,onAddImages:e=>void o(e),onChange:v,onNavigateHistory:ie,onKeyDown:ne,onRemoveImage:m,onSend:()=>void _(),overlay:!0,suppressCommandNavigation:re,targetLabel:`Assistant`,variant:w})})})]})]})}function M({clearing:e,connected:t,floating:n,page:r,onClearChat:a,onOpenDetails:o,roleName:s}){return(0,A.jsxs)(`div`,{className:i(`relative z-10 flex items-center justify-between px-4 py-3`,n?`border-b border-border bg-accent/20`:r?`bg-transparent`:`border-b border-border bg-background/20`),children:[(0,A.jsxs)(`div`,{className:i(`min-w-0`,r&&`opacity-0 select-none pointer-events-none`),children:[(0,A.jsx)(`div`,{className:`text-[13px] font-medium tracking-wide text-foreground`,children:`Assistant`}),(0,A.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground/78`,children:[s?(0,A.jsxs)(`span`,{className:`rounded-full border border-border bg-accent/35 px-2 py-0.5 text-[10px] font-medium text-muted-foreground/78`,children:[`Role: `,s]}):null,(0,A.jsx)(N,{connected:t})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(_,{type:`button`,size:`sm`,variant:r?`ghost`:`outline`,disabled:e,onClick:a,children:e?`Clearing...`:`Clear Chat`}),(0,A.jsx)(_,{type:`button`,size:`sm`,variant:r?`ghost`:`outline`,disabled:!o,onClick:o,children:`Assistant Details`})]})]})}function N({connected:e}){return(0,A.jsx)(`span`,{className:i(`rounded-full border px-2.5 py-0.5 text-[9px] font-medium transition-colors`,e?`border-graph-status-running/18 bg-graph-status-running/[0.12] text-graph-status-running`:`border-graph-status-idle/18 bg-graph-status-idle/[0.12] text-graph-status-idle`),children:e?`Online`:`Connecting...`})}function P(){let{agents:e}=x(),t=D(e),[n,r]=(0,E.useState)(!1);return(0,A.jsx)(`div`,{className:`flex h-full flex-col min-h-0`,children:n&&t?(0,A.jsx)(`div`,{className:`h-full overflow-hidden p-6`,children:(0,A.jsx)(`div`,{className:`h-full overflow-hidden rounded-xl border border-border bg-surface-overlay/90 shadow-md`,children:(0,A.jsx)(m,{agent:t,onClose:()=>r(!1)})})}):(0,A.jsx)(j,{onOpenDetails:t?()=>r(!0):void 0,variant:`page`})})}export{P as AssistantPage};
@@ -1 +0,0 @@
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,Xt as i,nt as a,q as o}from"./ui-vendor-Dg9NNnWX.js";import{a as s,t as c}from"./shared-CMxbpLeQ.js";import{J as l,V as u,o as d}from"./index-CL1ALZ3r.js";import{a as f,n as p,o as m,t as h}from"./PageScaffold-D4jO9ooX.js";import{t as g}from"./datetime-m6_O_Ci9.js";async function _(){return c(`/api/settings/telegram`,{errorMessage:`Failed to fetch Telegram settings`})}async function v(e){return c(`/api/settings/telegram`,{method:`PATCH`,body:e,errorMessage:`Failed to save Telegram settings`})}async function y(e){return c(`/api/settings/telegram/approve/${e}`,{method:`POST`,errorMessage:`Failed to approve Telegram chat`})}async function b(e){return c(`/api/settings/telegram/pending/${e}`,{method:`DELETE`,errorMessage:`Failed to remove pending Telegram chat`})}async function x(e){return c(`/api/settings/telegram/chat/${e}`,{method:`DELETE`,errorMessage:`Failed to remove Telegram chat`})}var S=e(t(),1),C=n();function w(e){return e?g(e,{fallback:`—`,unit:`seconds`}):`—`}function T(e){return e.display_name.trim()?e.display_name.trim():e.username?.trim()?`@${e.username.trim()}`:`Unknown chat`}function E(){let{data:e,isLoading:t,mutate:n}=m(`telegramSettings`,_),[c,g]=(0,S.useState)(!1),[E,D]=(0,S.useState)(``),[O,k]=(0,S.useState)(!1),A=(0,S.useMemo)(()=>!!e?.bot_token,[e?.bot_token]),j=async()=>{if(e){g(!0);try{let e={};O&&(e.bot_token=E.trim()),n((await v(e)).telegram,!1),D(``),k(!1),r.success(`Telegram settings saved`)}catch{r.error(`Failed to save Telegram settings`)}finally{g(!1)}}},M=async e=>{try{n((await y(e)).telegram,!1),r.success(`Telegram chat approved`)}catch{r.error(`Failed to approve Telegram chat`)}},N=async e=>{try{n((await b(e)).telegram,!1),r.success(`Pending Telegram chat removed`)}catch{r.error(`Failed to remove pending Telegram chat`)}},P=async e=>{try{n((await x(e)).telegram,!1),r.success(`Approved Telegram chat removed`)}catch{r.error(`Failed to remove approved Telegram chat`)}};return t||!e?(0,C.jsx)(d,{label:`Loading channels...`,textClassName:`text-[13px]`}):(0,C.jsx)(h,{children:(0,C.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none pt-6`,children:(0,C.jsxs)(`div`,{className:`mx-auto max-w-[680px] pb-10`,children:[(0,C.jsx)(p,{title:`Channels`}),(0,C.jsxs)(f,{className:`mt-6 space-y-8`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,C.jsx)(`div`,{children:(0,C.jsx)(`h2`,{className:`text-lg font-medium text-foreground`,children:`Telegram`})}),(0,C.jsx)(`div`,{className:s(`rounded-full border px-2.5 py-0.5 text-[10px] font-medium`,A?`border-graph-status-running/20 bg-graph-status-running/[0.12] text-graph-status-running`:`border-graph-status-idle/20 bg-graph-status-idle/[0.12] text-graph-status-idle`),children:A?`Configured`:`Not configured`})]}),(0,C.jsxs)(`section`,{children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Bot Token`}),(0,C.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Leave empty to keep the current token`})]}),(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(u,{value:E,onChange:e=>{D(e.target.value),k(!0)},placeholder:e.bot_token||`Enter Telegram bot token`,mono:!0,showLabel:`Show Telegram bot token`,hideLabel:`Hide Telegram bot token`})})]}),(0,C.jsxs)(`section`,{className:`border-t border-border pt-8`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Pending Private Chats`}),(0,C.jsxs)(`span`,{className:`rounded-full border border-border bg-accent/25 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[e.pending_chats.length,` waiting`]})]}),e.pending_chats.length===0?(0,C.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`No pending chats.`}):(0,C.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.pending_chats.map(e=>(0,C.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 px-4 py-3.5 transition-colors hover:bg-accent/20`,children:(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:T(e)}),(0,C.jsxs)(`div`,{className:`mt-1 flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,C.jsxs)(`span`,{className:`font-mono`,children:[`ID: `,e.chat_id]}),e.username?(0,C.jsxs)(`span`,{children:[`@`,e.username]}):null,(0,C.jsxs)(`span`,{children:[`First seen: `,w(e.first_seen_at)]})]})]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,C.jsxs)(l,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>void M(e.chat_id),className:`border-border bg-accent/20 text-foreground hover:bg-accent/35`,children:[(0,C.jsx)(i,{className:`size-3.5`}),`Approve`]}),(0,C.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void N(e.chat_id),className:`text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,C.jsx)(o,{className:`size-3.5`})})]})]})},e.chat_id))})]}),(0,C.jsxs)(`section`,{className:`border-t border-border pt-8`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Approved Private Chats`}),(0,C.jsxs)(`span`,{className:`rounded-full border border-border bg-accent/25 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[e.approved_chats.length,` active`]})]}),e.approved_chats.length===0?(0,C.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`No approved chats yet.`}):(0,C.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.approved_chats.map(e=>(0,C.jsx)(`div`,{className:`group rounded-xl border border-border bg-card/30 px-4 py-3.5 transition-colors hover:bg-accent/20`,children:(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:T(e)}),(0,C.jsxs)(`div`,{className:`mt-1 flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,C.jsxs)(`span`,{className:`font-mono`,children:[`ID: `,e.chat_id]}),e.username?(0,C.jsxs)(`span`,{children:[`@`,e.username]}):null,(0,C.jsxs)(`span`,{children:[`Approved: `,w(e.approved_at)]})]})]}),(0,C.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void P(e.chat_id),className:`shrink-0 text-muted-foreground opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100 focus:opacity-100`,children:(0,C.jsx)(o,{className:`size-3.5`})})]})},e.chat_id))})]}),(0,C.jsx)(`div`,{className:`flex justify-end border-t border-border pt-6`,children:(0,C.jsxs)(l,{type:`button`,size:`sm`,onClick:()=>void j(),disabled:c,className:`text-[13px]`,children:[(0,C.jsx)(a,{className:`size-4`}),c?`Saving...`:`Save Changes`]})})]})]})})})}export{E as ChannelsPage};
@@ -1,3 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{a as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./graph-vendor-DRq_-6fV.js";import{At as d,G as f,Ht as p,R as m,Rt as h,_t as g,at as _,nt as v,ot as y,q as b,rn as x,st as S,wt as ee,z as C}from"./ui-vendor-Dg9NNnWX.js";import{a as w,o as T}from"./shared-CMxbpLeQ.js";import{r as te}from"./roles-2OLDeTc5.js";import{a as E,c as D,i as ne,n as re,o as O,r as k,s as A,t as j}from"./WorkspacePanels-aMdJ7ZH7.js";import{A as ie,C as M,D as N,E as P,J as F,K as I,O as ae,S as oe,T as se,Z as L,_ as ce,c as le,d as ue,g as de,h as fe,k as R,l as pe,m as me,p as he,q as z,t as B,u as ge,v as _e,w as V,z as H}from"./index-CL1ALZ3r.js";import{t as ve}from"./badge-74-3jsCg.js";import{a as U,i as ye,n as be,t as xe}from"./constants-XUzFf6i1.js";import{a as Se,i as W,n as G,r as K,t as q}from"./select-DL_LPeDj.js";import{a as Ce,c as we,i as Te,n as Ee,o as De,r as Oe,s as ke,t as J}from"./alert-dialog-kFYVQ7oX.js";import{n as Y,r as X,t as Ae}from"./WorkspaceCommandDialog-CCXxjDL8.js";var Z=i(),Q=`bg-background/40 text-foreground shadow-xs placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50`,je=`rounded-xl border border-border bg-card/40 px-4 py-3`,Me=`max-h-56 space-y-2 overflow-y-auto rounded-xl border border-border bg-background/40 p-2 scrollbar-none`,Ne=`w-full rounded-md border px-3 py-2.5 text-left transition-colors`;function Pe({allowNetwork:e,onAllowNetworkChange:t,onOpenChange:n,onSubmit:r,onTitleChange:i,onWriteDirsChange:a,open:o,pending:s,title:c,writeDirs:l}){return(0,Z.jsxs)(Ae,{open:o,onOpenChange:n,title:`Create Workflow`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outline`,onClick:()=>n(!1),disabled:s,children:`Cancel`}),(0,Z.jsx)(F,{onClick:r,disabled:!c.trim()||s,children:s?`Creating...`:`Create Workflow`})]}),children:[(0,Z.jsx)(Y,{label:`Title`,hint:`Shown in the workflow strip`,children:(0,Z.jsx)(z,{autoFocus:!0,"aria-label":`Workflow title`,value:c,onChange:e=>i(e.target.value),placeholder:`Release checklist`,className:w(`h-10 rounded-md`,Q)})}),(0,Z.jsx)(X,{children:`New workflows always start with an empty definition and a bound Leader. MCP servers are provided globally after they connect.`}),(0,Z.jsx)(Y,{label:`Network Access`,hint:`Allow the leader to connect to the internet`,children:(0,Z.jsx)(H,{checked:e,label:`Network Access`,onCheckedChange:t})}),(0,Z.jsx)(Y,{label:`Write Dirs`,hint:`One absolute path per line`,children:(0,Z.jsx)(I,{value:l,"aria-label":`Write directories`,onChange:e=>a(e.target.value),placeholder:`/workspace/output
2
- /workspace/cache`,className:w(`min-h-[80px] rounded-md font-mono text-[13px]`,Q)})})]})}var Fe={agent:`Agent`,trigger:`Trigger`,code:`Code`,if:`If`,merge:`Merge`};function Ie({activeTabTitle:e,nodeName:t,nodeType:n,roles:r,loadingRoles:i,onNodeNameChange:a,onNodeTypeChange:o,onOpenChange:s,onRoleNameChange:c,onSubmit:l,open:u,pending:d,selectedRole:f,selectedRoleName:p,submitDisabled:m}){return(0,Z.jsxs)(Ae,{open:u,onOpenChange:s,title:`Add Node`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outline`,onClick:()=>s(!1),disabled:d,children:`Cancel`}),(0,Z.jsx)(F,{onClick:l,disabled:m,children:d?`Adding...`:`Add Node`})]}),children:[(0,Z.jsxs)(X,{children:[`Adding a node to`,` `,(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:e??`No active workflow`})]}),(0,Z.jsx)(Y,{label:`Node Type`,hint:`Required`,children:(0,Z.jsxs)(q,{value:n,onValueChange:e=>o(e),children:[(0,Z.jsx)(W,{"aria-label":`Node Type`,className:w(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Q),children:(0,Z.jsx)(Se,{placeholder:`Choose node type`})}),(0,Z.jsx)(G,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:Object.entries(Fe).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))})]})}),n===`agent`?(0,Z.jsx)(Y,{label:`Role`,hint:`Required · Leader is managed by the workflow`,children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[f?(0,Z.jsxs)(`div`,{className:je,children:[(0,Z.jsx)(`div`,{className:`text-[13px] font-medium text-foreground`,children:f.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-[12px] leading-relaxed text-muted-foreground`,children:f.description})]}):null,(0,Z.jsx)(`div`,{className:Me,children:i?(0,Z.jsx)(`p`,{className:`px-2 py-3 text-[12px] text-muted-foreground`,children:`Loading roles...`}):r.length===0?(0,Z.jsx)(`p`,{className:`px-2 py-3 text-[12px] text-muted-foreground`,children:`No roles available.`}):r.map(e=>(0,Z.jsxs)(F,{type:`button`,variant:`ghost`,onClick:()=>c(e.name),className:w(Ne,p===e.name?`border-border bg-accent/70`:`border-transparent bg-transparent hover:border-border hover:bg-accent/45`),children:[(0,Z.jsx)(`div`,{className:`text-[13px] font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-[12px] leading-relaxed text-muted-foreground`,children:e.description})]},e.name))})]})}):null,(0,Z.jsx)(Y,{label:`Display Name`,hint:`Optional`,children:(0,Z.jsx)(z,{value:t,"aria-label":`Node display name`,onChange:e=>a(e.target.value),placeholder:n===`agent`?`Docs Worker`:`${Fe[n]} Node`,className:w(`h-10 rounded-md`,Q)})})]})}function Le({activeTabTitle:e,nodeOptions:t,onFromNodeChange:n,onFromPortChange:r,onOpenChange:i,onSubmit:a,onToNodeChange:o,onToPortChange:s,open:c,pending:l,fromNodeId:u,fromPortKey:d,toNodeId:f,toPortKey:p,fromPortOptions:m,toPortOptions:h}){return(0,Z.jsxs)(Ae,{open:c,onOpenChange:i,title:`Connect Ports`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outline`,onClick:()=>i(!1),disabled:l,children:`Cancel`}),(0,Z.jsx)(F,{onClick:a,disabled:!u||!d||!f||!p||l,children:l?`Connecting...`:`Create Edge`})]}),children:[(0,Z.jsx)(X,{children:e?(0,Z.jsxs)(Z.Fragment,{children:[`Workflow`,` `,(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:e}),` `,`· `,t.length,` nodes available`]}):`No active workflow`}),(0,Z.jsx)(Y,{label:`From Node`,hint:`Source node`,children:(0,Z.jsxs)(q,{value:u,onValueChange:n,children:[(0,Z.jsx)(W,{"aria-label":`From Node`,className:w(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Q),children:(0,Z.jsx)(Se,{placeholder:`Choose source node`})}),(0,Z.jsx)(G,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:t.map(e=>(0,Z.jsx)(K,{value:e.id,children:e.label},e.id))})]})}),(0,Z.jsx)(Y,{label:`From Port`,hint:`Output port`,children:(0,Z.jsxs)(q,{value:d,onValueChange:r,children:[(0,Z.jsx)(W,{"aria-label":`From Port`,className:w(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Q),children:(0,Z.jsx)(Se,{placeholder:`Choose output port`})}),(0,Z.jsx)(G,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:m.map(e=>(0,Z.jsx)(K,{value:e.key,children:e.label},e.key))})]})}),(0,Z.jsx)(Y,{label:`To Node`,hint:`Target node`,children:(0,Z.jsxs)(q,{value:f,onValueChange:o,children:[(0,Z.jsx)(W,{"aria-label":`To Node`,className:w(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Q),children:(0,Z.jsx)(Se,{placeholder:`Choose target node`})}),(0,Z.jsx)(G,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:t.filter(e=>e.id!==u).map(e=>(0,Z.jsx)(K,{value:e.id,children:e.label},e.id))})]})}),(0,Z.jsx)(Y,{label:`To Port`,hint:`Input port`,children:(0,Z.jsxs)(q,{value:p,onValueChange:s,children:[(0,Z.jsx)(W,{"aria-label":`To Port`,className:w(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Q),children:(0,Z.jsx)(Se,{placeholder:`Choose input port`})}),(0,Z.jsx)(G,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:h.map(e=>(0,Z.jsx)(K,{value:e.key,children:e.label},e.key))})]})})]})}function Re({onDelete:e,onOpenChange:t,open:n,pending:r,target:i}){return(0,Z.jsx)(J,{open:n,onOpenChange:t,children:(0,Z.jsxs)(Te,{className:`max-w-[30rem]`,children:[(0,Z.jsxs)(ke,{className:`gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-xl border border-border bg-accent/45 text-foreground shadow-xs`,children:(0,Z.jsx)(b,{className:`size-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Destructive Action`}),(0,Z.jsx)(we,{className:`mt-1 text-foreground`,children:`Delete workflow?`})]})]}),(0,Z.jsx)(Ce,{className:`text-muted-foreground`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[`Remove`,` `,(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title}),` `,`and clean up its persisted workflow graph.`,typeof i.nodeCount==`number`?` ${i.nodeCount} node${i.nodeCount===1?``:`s`} will be removed with it.`:``]}):`This action cannot be undone.`})]}),(0,Z.jsxs)(De,{children:[(0,Z.jsx)(Oe,{asChild:!0,children:(0,Z.jsx)(F,{variant:`outline`,children:`Cancel`})}),(0,Z.jsx)(Ee,{asChild:!0,children:(0,Z.jsx)(F,{variant:`destructive`,onClick:e,disabled:r,children:r?`Deleting...`:`Delete Workflow`})})]})]})})}var $=e(n(),1),ze=(0,$.memo)(function(e){let{sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:o,targetPosition:s,id:l,data:u}=e,[d]=c({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:s}),f=u??{},p=!!f.active,m=!!f.leaving,h=f.flowDirection===`reverse`?-1:1,g=f.selected===!0,_=h===1?`48`:`0`,v=h===1?`0`:`48`;return(0,Z.jsxs)(x.g,{className:`agent-graph-edge-shell`,initial:{opacity:0},animate:{opacity:+!m},transition:{duration:m?.2:.3,ease:`easeInOut`},children:[(0,Z.jsx)(a,{id:l,path:d,style:{stroke:p?`var(--graph-edge-active)`:g?`var(--graph-selection)`:`var(--graph-edge)`,strokeWidth:p?2.5:g?2.4:1.5,transition:`stroke 300ms ease, stroke-width 300ms ease, opacity 300ms ease`}}),g&&!p?(0,Z.jsx)(x.path,{d,fill:`none`,stroke:`var(--graph-selection)`,strokeWidth:`7`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{opacity:0},animate:{opacity:.16},transition:{duration:.18}}):null,p&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(x.path,{d,fill:`none`,stroke:`var(--graph-edge-active)`,strokeWidth:`8`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{opacity:0},animate:{opacity:[.1,.3,.1]},transition:{duration:2,repeat:1/0,ease:`easeInOut`}}),(0,Z.jsx)(x.path,{d,fill:`none`,stroke:`url(#agent-graph-edge-flow)`,strokeWidth:`3.5`,strokeLinecap:`round`,strokeDasharray:`12 12`,opacity:`0.8`,filter:`url(#agent-graph-edge-glow)`,initial:{opacity:0},animate:{opacity:.8},transition:{duration:.4},children:(0,Z.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:_,to:v,dur:`0.8s`,repeatCount:`indefinite`})}),(0,Z.jsx)(x.path,{d,fill:`none`,stroke:`var(--graph-edge-active)`,strokeWidth:`5`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{pathLength:.15,pathOffset:h===1?-.2:1.2,opacity:0},animate:{pathOffset:h===1?1.2:-.2,opacity:[0,1,1,0]},transition:{duration:1.5,ease:`easeInOut`,repeat:1/0,repeatType:`loop`,times:[0,.1,.9,1]}}),(0,Z.jsx)(x.path,{d,fill:`none`,stroke:`var(--graph-attention)`,strokeWidth:`2.5`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{pathLength:.08,pathOffset:h===1?-.23:1.23,opacity:0},animate:{pathOffset:h===1?1.17:-.17,opacity:[0,.9,.9,0]},transition:{duration:1.5,ease:`easeInOut`,repeat:1/0,repeatType:`loop`,times:[0,.1,.9,1],delay:.03}})]})]})}),Be={running:`border-graph-status-running/28`,idle:`border-graph-node-border`,sleeping:`border-graph-status-sleeping/26`,initializing:`border-border border-dashed`,error:`border-graph-status-error/28 border-double`,terminated:`border-border/70`};function Ve(e,t=!1){return e===`assistant`?`rounded-sm border-graph-node-border bg-accent/60 text-foreground`:w(`rounded-sm border-graph-node-border bg-surface-3`,t?`text-primary`:`text-foreground/80`)}var He=(0,$.memo)(function({data:e}){let{label:t,node_type:n,is_leader:r,state:i,latestTodo:a,selected:c,toolCall:l,canConnect:u,showConnectionEntryHint:d,connectionState:f,inputPorts:p,outputPorts:m}=e,h=!!e.leaving,g=be[n],_=(0,$.useRef)(null),v=(e,t)=>{if(!_.current)return;let n=_.current.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,a=e-r,o=t-i,s=Math.sqrt(a*a+o*o),c=Math.max(0,1-s/240),l=Math.atan2(o,a)*180/Math.PI+90;_.current.style.setProperty(`--mouse-angle`,`${l}deg`),_.current.style.setProperty(`--mouse-intensity`,c.toString())},y=()=>{_.current&&(_.current.style.setProperty(`--mouse-angle`,`135deg`),_.current.style.setProperty(`--mouse-intensity`,`0`))},b=!!l,S=i===`running`,ee=b?`border-graph-attention/70`:Be[i],C=c?`ring-1 ring-graph-selection/25 border-graph-selection/80`:w(ee,`hover:border-graph-node-border-hover`),T=f===`source`?`ring-2 ring-graph-selection/35 border-graph-selection/90`:f===`valid-target`?`border-graph-selection/55 shadow-[0_0_0_1px_var(--graph-glow)]`:f===`invalid-target`?`opacity-45`:``,te=d||f===`source`,E=f===`source`?`border-graph-selection/75 bg-graph-selection/14 shadow-[0_0_0_1px_var(--graph-glow),0_0_24px_var(--graph-glow)]`:f===`valid-target`?`border-graph-selection/45 bg-graph-selection/10 shadow-[0_0_0_1px_var(--graph-glow),0_0_18px_var(--graph-glow)]`:f===`invalid-target`?`border-graph-node-border bg-graph-node-bg/50`:`border-graph-node-border bg-graph-node-bg/72`;return(0,Z.jsxs)(x.div,{ref:_,initial:{opacity:0,scale:.92,filter:`blur(6px) grayscale(0%)`},animate:{opacity:h?0:i===`terminated`?.4:1,scale:h?.9:1,y:h?8:0,filter:h?`blur(8px) grayscale(100%)`:i===`terminated`?`blur(0px) grayscale(100%)`:`blur(0px) grayscale(0%)`},transition:{duration:h?.28:.35,ease:[.23,1,.32,1]},onMouseEnter:e=>v(e.clientX,e.clientY),onMouseMove:e=>v(e.clientX,e.clientY),onMouseLeave:y,className:w(`relative isolate flex h-14 w-max min-w-[100px] max-w-[300px] items-center gap-2 overflow-visible rounded-[10px] border px-2.5 py-2.5`,`shadow-[0_10px_24px_var(--shell-scrim)]`,`bg-graph-node-bg`,`transition-[border-color] duration-300`,h&&`pointer-events-none`,C,T),style:{"--mouse-angle":`135deg`,"--mouse-intensity":`0`},children:[(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:w(`agent-state-ring`,U[i])}),(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:w(`agent-loading-border`,S&&`agent-loading-border-active`)}),p.map((e,t)=>(0,Z.jsx)(s,{id:e.key,type:`target`,position:o.Left,isConnectable:u,isConnectableEnd:u,className:w(`!z-10 !h-[72%] !w-5 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0 after:absolute after:-inset-3 after:content-['']`),style:{top:`${(t+1)*100/(p.length+1)}%`}},`input-${e.key}`)),m.map((e,t)=>(0,Z.jsx)(s,{id:e.key,type:`source`,position:o.Right,isConnectable:u,isConnectableStart:u,className:w(`!z-10 !h-[72%] !w-5 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0 after:absolute after:-inset-3 after:content-['']`),style:{top:`${(t+1)*100/(m.length+1)}%`}},`output-${e.key}`)),te?[(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`connection-entry-left`,className:w(`pointer-events-none absolute top-1/2 z-10 h-[72%] w-2.5 -translate-y-1/2 rounded-full border transition-[opacity,transform,box-shadow] duration-150`,`-left-1.5`,E)},`left-entry`),(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`connection-entry-right`,className:w(`pointer-events-none absolute top-1/2 z-10 h-[72%] w-2.5 -translate-y-1/2 rounded-full border transition-[opacity,transform,box-shadow] duration-150`,`-right-1.5`,E)},`right-entry`)]:null,(0,Z.jsx)(`div`,{className:w(`relative z-10 flex size-8 shrink-0 items-center justify-center border`,Ve(n,r)),children:(0,Z.jsx)(g,{className:`size-4.5`})}),(0,Z.jsxs)(`div`,{className:`relative z-10 flex min-w-0 flex-1 items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[13px] font-semibold text-foreground -translate-y-[0.7px]`,title:a??void 0,children:t}),(0,Z.jsx)(`div`,{className:`relative flex items-center pr-0.5`,title:b?`Active`:i,children:(0,Z.jsxs)(`span`,{className:`relative flex size-2.5`,children:[(S||b)&&(0,Z.jsx)(`span`,{className:w(`absolute inline-flex size-full animate-ping rounded-full opacity-40`,b?`bg-graph-attention`:ye[i])}),(0,Z.jsx)(`span`,{className:w(`relative inline-flex size-2.5 rounded-full border border-card shadow-sm`,b?`bg-graph-attention`:ye[i])})]})})]}),b&&(0,Z.jsx)(x.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:`absolute -bottom-6 left-1/2 z-20 -translate-x-1/2 whitespace-nowrap`,children:(0,Z.jsx)(`span`,{className:`rounded-sm border border-graph-attention/24 bg-surface-2/92 px-1.5 py-0.5 text-[9px] font-mono text-graph-attention-text shadow-lg backdrop-blur-sm`,children:l})})]})}),Ue=.3,We=.05,Ge=`rounded-md border border-border bg-popover px-3 py-1 text-[11px] font-medium text-popover-foreground shadow-sm`,Ke=`h-8 w-full rounded-md border border-input bg-background/55 px-3 text-[13px] text-foreground shadow-xs placeholder:text-muted-foreground transition-[border-color,box-shadow] focus:border-ring focus:outline-none focus:ring-[3px] focus:ring-ring/50`,qe=`max-h-56 space-y-2 overflow-y-auto rounded-md border border-border bg-background/40 p-2 scrollbar-none`,Je=`w-full rounded-md border px-3 py-2 text-left transition-colors`;function Ye(e){return e.kind===`standalone`?`Add Agent`:e.kind===`between`?`Insert Agent Between`:`Add Agent After`}var Xe=e(u(),1);function Ze({children:e}){return typeof document>`u`||!document.body?null:(0,Xe.createPortal)(e,document.body)}function Qe({x:e,y:t,items:n,onClose:r}){let i=(0,$.useRef)(null),[a,o]=(0,$.useState)(()=>({left:e,top:t}));return(0,$.useEffect)(()=>{let n=i.current;if(!n)return;let r=requestAnimationFrame(()=>{let r=n.getBoundingClientRect(),i=window.innerWidth-8-r.width,a=window.innerHeight-8-r.height,s=Math.max(8,Math.min(e,i)),c=Math.max(8,Math.min(t,a));o(e=>e.left===s&&e.top===c?e:{left:s,top:c})});return()=>cancelAnimationFrame(r)},[e,t,n.length]),(0,$.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[r]),(0,$.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),n.length===0?null:(0,Z.jsx)(Ze,{children:(0,Z.jsx)(x.div,{ref:i,initial:{opacity:0,scale:.96,y:-4},animate:{opacity:1,scale:1,y:0},transition:{duration:.12,ease:`easeOut`},className:`fixed z-[200] min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-md`,style:{left:a.left,top:a.top},children:n.map((e,t)=>e===`divider`?(0,Z.jsx)(`div`,{className:`my-1 border-t border-border`},t):(0,Z.jsx)(F,{type:`button`,variant:`ghost`,disabled:e.disabled,onClick:()=>{e.disabled||(e.onClick(),r())},className:`h-auto w-full justify-start rounded-none px-3 py-1.5 text-left text-[11px] hover:text-inherit disabled:opacity-40 ${e.danger?`text-graph-status-error/90 hover:bg-destructive/10 hover:text-graph-status-error`:`text-popover-foreground/90 hover:bg-accent/30 hover:text-popover-foreground`}`,children:e.label},t))})})}var $e=/^[il1.,!|:;]$/,et=/^[fjrt\-[\]()]$/,tt=/^[wmMWOQ@]$/,nt=/^[A-Z]$/;function rt(e){let t=Array.from(e).reduce((e,t)=>t===` `?e+4:t.charCodeAt(0)>255?e+13:$e.test(t)?e+4:et.test(t)?e+5.5:tt.test(t)?e+10.5:nt.test(t)?e+8.5:e+7,0);return Math.max(100,Math.min(300,t+76))}function it(e,t){let[n,r]=(0,$.useState)(e),[i,a]=(0,$.useState)(t),o=(0,$.useRef)(new Map),s=(0,$.useRef)(new Map);return(0,$.useEffect)(()=>{r(t=>{let n=new Set(e.map(e=>e.id)),i=new Map(t.map(e=>[e.id,e])),a=e.map(e=>{let t=o.current.get(e.id);t&&(clearTimeout(t),o.current.delete(e.id));let n=i.get(e.id);return{...n,...e,className:w(e.className,`agent-graph-node-present`),data:{...n?.data??{},...e.data??{},leaving:!1}}});for(let e of t)if(!n.has(e.id)){if(!o.current.has(e.id)){let t=setTimeout(()=>{r(t=>t.filter(t=>t.id!==e.id)),o.current.delete(e.id)},320);o.current.set(e.id,t)}a.push({...e,className:w(e.className,`agent-graph-node-leaving`),data:{...e.data??{},leaving:!0}})}return a})},[e]),(0,$.useEffect)(()=>{a(e=>{let n=new Set;for(let e=0;e<t.length;e++)n.add(t[e].id);let r=new Map;for(let t=0;t<e.length;t++)r.set(e[t].id,e[t]);let i=t.map(e=>{let t=s.current.get(e.id);t&&(clearTimeout(t),s.current.delete(e.id));let n=r.get(e.id);return{...n,...e,data:{...n?.data??{},...e.data??{},leaving:!1}}});for(let t of e)if(!n.has(t.id)){if(!s.current.has(t.id)){let e=setTimeout(()=>{a(e=>e.filter(e=>e.id!==t.id)),s.current.delete(t.id)},220);s.current.set(t.id,e)}i.push({...t,data:{...t.data??{},leaving:!0}})}return i})},[t]),(0,$.useEffect)(()=>{let e=o.current,t=s.current;return()=>{for(let t of e.values())clearTimeout(t);for(let e of t.values())clearTimeout(e)}},[]),{nodes:n,edges:i}}function at({roles:e=[],loadingRoles:t=!1,onConnectModeChange:n,onCreateConnection:r=async()=>void 0,onDeleteConnection:i=async()=>void 0,onCreateStandaloneAgent:a=async()=>void 0,onCreateLinkedAgent:o=async()=>void 0,onDeleteAgent:s=async()=>void 0,onInsertAgentBetween:c=async()=>void 0,onOpenConnectDialog:l=()=>void 0}){let{agents:u}=de(),{tabs:d}=ce(),{activeToolCalls:f}=he(),{activeTabId:p,selectedAgentId:h,selectAgent:g}=_e(),[_,v]=(0,$.useState)(null),[y,b]=(0,$.useState)(null),[x,S]=(0,$.useState)(null),[ee,C]=(0,$.useState)(``),[w,T]=(0,$.useState)(``),[te,E]=(0,$.useState)(!1),[D,ne]=(0,$.useState)(null),[re,O]=(0,$.useState)(1),[k,A]=(0,$.useState)(null),[j,ie]=(0,$.useState)(!1),[M,N]=(0,$.useState)(null),P=(0,$.useRef)(null),F=(0,$.useRef)(``),I=(0,$.useRef)(new Map),[ae,oe]=(0,$.useState)(0),[se,L]=(0,$.useState)({key:``,positions:new Map}),le=(0,$.useRef)(null),ue=(0,$.useRef)(null),fe=(0,$.useRef)(null),[R,pe]=(0,$.useState)(null),me=p?d.get(p)??null:null,z=(0,$.useMemo)(()=>me?.definition.nodes??[],[me?.definition.nodes]),B=(0,$.useMemo)(()=>me?.definition.edges??[],[me?.definition.edges]),ge=(0,$.useMemo)(()=>new Map(z.map(e=>[e.id,e])),[z]),V=(0,$.useCallback)((e,t,n)=>{F.current=``,console.error(t,n);let r=I.current.get(e)??0;r>=1||(I.current.set(e,r+1),oe(e=>e+1))},[]);(0,$.useEffect)(()=>{let e=new Worker(new URL(`/assets/layout.worker-jMHqAFbP.js`,``+import.meta.url),{type:`module`}),t=I.current;return e.onerror=e=>{let t=F.current;t&&V(t,`AgentGraph layout worker error`,e)},e.onmessageerror=e=>{let t=F.current;t&&V(t,`AgentGraph layout worker message error`,e)},e.onmessage=e=>{let{positions:t,key:n,error:r}=e.data;if(n!==F.current)return;if(r||!t){V(n,`AgentGraph layout worker rejected request`,r);return}I.current.delete(n);let i=new Map;for(let e of t)i.set(e.id,e.position);L({key:n,positions:i})},P.current=e,()=>{F.current=``,t.clear(),P.current=null,e.terminate()}},[V]),(0,$.useEffect)(()=>{n?.(j)},[j,n]);let H=(0,$.useCallback)(e=>{!Number.isFinite(e)||e<=0||O(e)},[]),ve=(0,$.useCallback)(e=>{e&&H(e.getZoom())},[H]),U=(0,$.useCallback)(async e=>{if(!D)return!1;try{let t=await D.fitView(e);return ve(D),t}catch{return!1}},[D,ve]),ye=(0,$.useCallback)(e=>{ne(e),ve(e)},[ve]),be=(0,$.useCallback)((e,t)=>{H(t.zoom)},[H]),Se=(0,$.useCallback)(()=>{ie(e=>!e)},[]),W=(0,$.useMemo)(()=>new Map(Array.from(u.entries())),[u]),G=(0,$.useCallback)(e=>{let t=ge.get(e);return!t||t.type!==`agent`?null:{id:t.id,node_type:`agent`,tab_id:p,is_leader:!1,state:`idle`,connections:B.filter(e=>e.from_node_id===t.id).map(e=>e.to_node_id),name:typeof t.config.name==`string`?t.config.name:null,todos:[],role_name:typeof t.config.role_name==`string`?t.config.role_name:null}},[p,B,ge]),K=(0,$.useCallback)(e=>W.get(e)??G(e),[G,W]),q=(0,$.useMemo)(()=>z.flatMap(e=>{let t=W.get(e.id);if(t)return[t];let n=G(e.id);return n?[n]:[]}),[G,W,z]),Ce=(0,$.useCallback)((e,t)=>{let n=ge.get(e),r=ge.get(t),i=n?.outputs.find(e=>r?.inputs.some(t=>t.kind===e.kind))??n?.outputs[0],a=i&&r?r.inputs.find(e=>e.kind===i.kind)??r.inputs[0]:null;return!i||!a?null:{sourcePortKey:i.key,targetPortKey:a.key}},[ge]),we=(0,$.useCallback)((e,t)=>{if(e===t)return!1;let n=Ce(e,t);return n?!B.some(r=>r.from_node_id===e&&r.from_port_key===n.sourcePortKey&&r.to_node_id===t&&r.to_port_key===n.targetPortKey):!1},[Ce,B]),Te=(0,$.useMemo)(()=>{let e=new Map;for(let t of z){let n=W.get(t.id)??null,r=xe({name:typeof t.config.name==`string`?t.config.name:null,roleName:typeof t.config.role_name==`string`?t.config.role_name:null,nodeType:t.type,isLeader:!1});e.set(t.id,{label:r,width:rt(r),node_type:t.type,is_leader:!1,state:n?.state??`idle`,shortId:t.id.slice(0,8),name:typeof t.config.name==`string`?t.config.name:null,role_name:typeof t.config.role_name==`string`?t.config.role_name:null,latestTodo:n?.todos[n.todos.length-1]?.text??null,selected:t.id===h&&k===null,toolCall:n?f.get(t.id)??null:null,leaving:!1,canConnect:!!p,showConnectionEntryHint:j||!!M,connectionState:M===t.id?`source`:M?we(M,t.id)?`valid-target`:`invalid-target`:null,inputPorts:t.inputs,outputPorts:t.outputs})}return e},[p,f,j,we,W,h,k,M,z]),{rawNodes:Ee,baseEdges:De,structureKey:Oe}=(0,$.useMemo)(()=>({rawNodes:z.flatMap(e=>{let t=Te.get(e.id);return t?[{id:e.id,type:`agent`,position:{x:0,y:0},width:t.width,height:56,data:t,className:`agent-graph-node-shell`}]:[]}),baseEdges:B.map(e=>({id:e.id,source:e.from_node_id,sourceHandle:e.from_port_key,target:e.to_node_id,targetHandle:e.to_port_key,type:`animated`,data:{kind:e.kind}})),structureKey:`${p??`unassigned`}:${z.map(e=>`${e.id}:${e.type}:${JSON.stringify(e.config)}`).sort().join(`|`)}:${B.map(e=>`${e.id}:${e.from_node_id}:${e.from_port_key}:${e.to_node_id}:${e.to_port_key}:${e.kind}`).sort().join(`|`)}`}),[p,Te,B,z]);(0,$.useEffect)(()=>{if(Ee.length===0){F.current=``,I.current.clear();return}if(se.key===Oe||F.current===Oe)return;let e=P.current;e&&(e.postMessage({nodes:Ee,edges:De,key:Oe}),F.current=Oe)},[De,ae,se.key,Ee,Oe]);let ke=(0,$.useMemo)(()=>{let e=se.positions;return{nodes:Ee.map(t=>({...t,position:e.get(t.id)??{x:0,y:0}})),edges:De.map(e=>({...e,data:{active:!1,flowDirection:null,leaving:!1,selected:e.id===k},animated:!1})),structureKey:Oe}},[De,se.positions,Ee,k,Oe]),{nodes:J,edges:Y}=it(ke.nodes,ke.edges),X=(0,$.useCallback)(()=>{S(null),C(``),T(``),E(!1)},[]),Ae=(0,$.useCallback)(e=>{S(e),C(``),T(``),E(!1),b(null),v(null)},[]),Z=(0,$.useCallback)((e,t)=>{if(M&&p){if(t.id===M)return;if(!we(M,t.id)){m.error(`This connection is not available`);return}let e=Ce(M,t.id);if(!e){m.error(`This connection is not available`);return}r(p,M,t.id,e.sourcePortKey,e.targetPortKey).then(()=>{N(null),ie(!1),A(null)}).catch(e=>{m.error(e instanceof Error?e.message:`Failed to connect nodes`)});return}A(null),K(t.id)?g(t.id):g(null)},[p,Ce,we,r,K,g,M]),Q=(0,$.useCallback)((e,t)=>{if(!W.has(t.id))return;let n=e;v({agentId:t.id,x:n.clientX,y:n.clientY})},[W]),je=(0,$.useCallback)((e,t)=>{if(!W.has(t.id))return;let n=e;v({agentId:t.id,x:n.clientX,y:n.clientY})},[W]),Me=(0,$.useCallback)(()=>{v(null)},[]),Ne=(0,$.useCallback)(()=>{A(null),v(null),b(null),N(null),X(),g(null)},[X,g]),Pe=(0,$.useCallback)(e=>{e.preventDefault();let t=e;A(null),v(null),N(null),X(),g(null),b({kind:`pane`,x:t.clientX,y:t.clientY})},[X,g]),Fe=(0,$.useCallback)((e,t)=>{let n=K(t.id),r=e;if(r.preventDefault(),r.stopPropagation(),!n||!p){b(null);return}g(t.id),A(null),N(null),v(null),X(),b({kind:`node`,x:r.clientX,y:r.clientY,agentId:t.id})},[p,X,K,g]),Ie=(0,$.useCallback)(e=>{!p||!e.source||!e.target||r(p,e.source,e.target,e.sourceHandle??`out`,e.targetHandle??`in`).then(()=>{ie(!1),N(null),A(null)}).catch(e=>{m.error(e instanceof Error?e.message:`Failed to connect nodes`)})},[p,r]),Le=(0,$.useCallback)(()=>{},[]),Re=(0,$.useCallback)(()=>{j||ie(!1)},[j]),ze=(0,$.useCallback)((e,t)=>{A(t.id),v(null),b(null),N(null),X(),g(null)},[X,g]),Be=(0,$.useCallback)((e,t)=>{let n=e;n.preventDefault(),n.stopPropagation(),A(t.id),v(null),N(null),X(),g(null),b({kind:`edge`,x:n.clientX,y:n.clientY,sourceId:t.source,targetId:t.target,sourcePortKey:t.sourceHandle,targetPortKey:t.targetHandle})},[X,g]),Ve=(0,$.useCallback)(()=>{b(null)},[]),He=(0,$.useMemo)(()=>{if(!y)return[];if(y.kind===`node`){let e=K(y.agentId);return!e||!p?[]:[{label:`Add Agent After`,onClick:()=>{Ae({kind:`linked`,x:y.x,y:y.y,anchorNodeId:e.id})}},{label:`Connect to...`,onClick:()=>{S(null),C(``),T(``),ie(!1),N(e.id),A(null),g(e.id)}},`divider`,{label:`Delete Agent`,danger:!0,onClick:()=>{s({tabId:p,node:e,tabAgents:q}).catch(e=>{m.error(e instanceof Error?e.message:`Failed to delete agent`)})}}]}return y.kind===`edge`?p?[{label:`Insert Agent Between`,onClick:()=>{Ae({kind:`between`,x:y.x,y:y.y,sourceNodeId:y.sourceId,targetNodeId:y.targetId})}},{label:`Delete Edge`,danger:!0,onClick:()=>{i(p,y.sourceId,y.targetId,y.sourcePortKey??void 0,y.targetPortKey??void 0).catch(e=>{m.error(e instanceof Error?e.message:`Failed to delete edge`)})}}]:[]:[{label:`Add Agent`,disabled:!p,onClick:()=>{Ae({kind:`standalone`,x:y.x,y:y.y})}},{label:`Connect Ports`,disabled:!p||q.length<2,onClick:l},`divider`,{label:`Fit View`,disabled:!D,onClick:()=>{U({padding:Ue,maxZoom:1,duration:350})}},{label:`Clear Selection`,onClick:()=>{A(null),N(null),g(null)}}]},[p,y,U,D,s,i,l,Ae,K,g,q]),We=(0,$.useCallback)(()=>{if(!p||!x||!w||te)return;let e=ee.trim()||void 0;E(!0),(x.kind===`standalone`?a({tabId:p,roleName:w,name:e}):x.kind===`linked`?o({tabId:p,anchorNodeId:x.anchorNodeId,roleName:w,name:e}):c({tabId:p,sourceNodeId:x.sourceNodeId,targetNodeId:x.targetNodeId,roleName:w,name:e})).then(()=>{X(),A(null),N(null)}).catch(e=>{E(!1),m.error(e instanceof Error?e.message:`Failed to add agent`)})},[p,X,o,a,c,x,ee,w,te]),Ge=_?W.get(_.agentId)??null:null,Ke=_&&_.agentId?f.get(_.agentId)??null:null;(0,$.useEffect)(()=>{if(!_||!Ge)return;let e=requestAnimationFrame(()=>{let e=le.current;if(!e)return;let t=e.getBoundingClientRect();pe(e=>e&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5?e:{width:t.width,height:t.height})});return()=>cancelAnimationFrame(e)},[_,Ge]),(0,$.useEffect)(()=>{if(!D||J.length===0||fe.current===ke.structureKey)return;let e=fe.current===null;fe.current=ke.structureKey;let t=requestAnimationFrame(()=>{U({padding:Ue,maxZoom:1,duration:e?0:250})});return()=>cancelAnimationFrame(t)},[J.length,U,D,ke.structureKey]),(0,$.useEffect)(()=>{if(!D||!ue.current||J.length===0)return;let e=0,t=new ResizeObserver(()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{U({padding:Ue,maxZoom:1,duration:250})})});return t.observe(ue.current),()=>{cancelAnimationFrame(e),t.disconnect()}},[J.length,U,D]);let qe=(0,$.useMemo)(()=>{if(!_||typeof window>`u`)return;let e=R?.width??280,t=R?.height??120,n=window.innerWidth-8-e,r=window.innerHeight-8-t;return{left:Math.max(8,Math.min(_.x+12,n)),top:Math.max(8,Math.min(_.y+12,r))}},[_,R]),Je=(0,$.useMemo)(()=>d.size===0?{title:`No workflows yet`}:p?{title:`This workflow is ready for its first node`}:{title:`Select a workflow`},[p,d.size]);return{activeTabId:p,animatedEdges:Y,animatedNodes:J,availableRoles:e,closeContextMenu:Ve,closeQuickCreate:X,connectHintLabel:M?`Choose target Agent`:j?`Connect Ports`:null,containerRef:ue,contextMenu:y,contextMenuItems:He,emptyState:Je,enterConnectMode:Se,handleFlowInit:ye,handleViewportMove:be,isValidConnection:(0,$.useCallback)(e=>!e.source||!e.target||!e.sourceHandle||!e.targetHandle||e.source===e.target?!1:!B.some(t=>t.from_node_id===e.source&&t.from_port_key===e.sourceHandle&&t.to_node_id===e.target&&t.to_port_key===e.targetHandle),[B]),loadingRoles:t,onConnect:Ie,onConnectEnd:Re,onConnectStart:Le,onEdgeClick:ze,onEdgeContextMenu:Be,onNodeClick:Z,onNodeContextMenu:Fe,onNodeMouseEnter:Q,onNodeMouseLeave:Me,onNodeMouseMove:je,onPaneClick:Ne,onPaneContextMenu:Pe,quickCreate:x,quickCreateName:ee,quickCreateRoleName:w,setQuickCreateName:C,setQuickCreateRoleName:T,submitQuickCreate:We,submittingQuickCreate:te,tooltip:_,tooltipAgent:Ge,tooltipRef:le,tooltipStyle:qe,tooltipToolCall:Ke,viewportZoom:re}}var ot={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 st({agent:e,agentId:t,activeToolCall:n,style:r,tooltipRef:i}){let a=e?xe({name:e.name,roleName:e.role_name,nodeType:e.node_type,isLeader:e.is_leader}):null;return(0,Z.jsx)(Ze,{children:(0,Z.jsx)(L,{children:e&&t&&a?(0,Z.jsxs)(x.div,{ref:i,initial:{opacity:0,y:4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:2,scale:.98},transition:{duration:.15},className:`pointer-events-none fixed z-[100] max-w-[320px] rounded-md border border-border bg-popover px-2 py-1 text-popover-foreground shadow-md`,style:r,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium`,children:a}),(0,Z.jsx)(ve,{variant:`outline`,className:`text-[10px] ${ot[e.state]}`,children:e.state.toUpperCase()}),e.role_name?(0,Z.jsx)(ve,{variant:`outline`,className:`text-[10px]`,children:e.role_name}):null,e.is_leader?(0,Z.jsx)(ve,{variant:`outline`,className:`border-accent bg-accent/45 text-[10px] text-accent-foreground`,children:`Leader`}):null]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-2 gap-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`ID`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/80`,children:t.slice(0,8)}),(0,Z.jsx)(`span`,{children:`Connections`}),(0,Z.jsx)(`span`,{className:`text-foreground/80`,children:e.connections.length}),(0,Z.jsx)(`span`,{children:`Workflow`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/80`,children:e.tab_id?.slice(0,8)??`—`}),n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Tool`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/80`,children:n})]}):null]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Todos`}),e.todos.length===0?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`No todos`}):(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[e.todos.slice(Math.max(e.todos.length-3,0)).reverse().map(e=>(0,Z.jsx)(`div`,{className:`text-[11px] leading-relaxed text-foreground/85`,children:e.text},`${t}-${e.text}`)),e.todos.length>3?(0,Z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[`+`,e.todos.length-3,` more`]}):null]})]})]}):null})})}var ct={agent:He},lt={animated:ze},ut=(0,$.forwardRef)(function(e,n){let{activeTabId:i,animatedEdges:a,animatedNodes:o,availableRoles:s,closeContextMenu:c,closeQuickCreate:u,connectHintLabel:d,containerRef:f,contextMenu:p,contextMenuItems:m,emptyState:h,enterConnectMode:_,handleFlowInit:v,handleViewportMove:y,isValidConnection:b,loadingRoles:x,onConnect:S,onConnectEnd:ee,onConnectStart:C,onEdgeClick:w,onEdgeContextMenu:te,onNodeClick:E,onNodeContextMenu:D,onNodeMouseEnter:ne,onNodeMouseLeave:re,onNodeMouseMove:O,onPaneClick:k,onPaneContextMenu:A,quickCreate:j,quickCreateName:ie,quickCreateRoleName:M,setQuickCreateName:N,setQuickCreateRoleName:P,submitQuickCreate:F,submittingQuickCreate:I,tooltip:ae,tooltipAgent:oe,tooltipRef:se,tooltipStyle:L,tooltipToolCall:ce,viewportZoom:le}=at(e);return(0,$.useImperativeHandle)(n,()=>({enterConnectMode:_}),[_]),(0,Z.jsxs)(`div`,{ref:f,className:`relative flex h-full flex-col`,children:[(0,Z.jsx)(`div`,{className:`relative flex-1 overflow-hidden`,children:o.length===0?(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center px-5 py-8`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-[22rem] rounded-xl border border-border bg-surface-overlay/60 px-5 py-5 text-center shadow-md backdrop-blur-sm`,children:[(0,Z.jsx)(`div`,{className:`mx-auto flex size-10 items-center justify-center rounded-lg border border-border bg-accent/35 text-muted-foreground`,children:(0,Z.jsx)(g,{className:`size-4.5`})}),(0,Z.jsx)(`p`,{className:`mt-3.5 text-[18px] font-semibold leading-tight text-foreground`,children:h.title})]})}):(0,Z.jsxs)(r,{nodes:o,edges:a,nodeTypes:ct,edgeTypes:lt,colorMode:`dark`,onInit:v,onNodeClick:E,onNodeMouseEnter:ne,onNodeMouseMove:O,onNodeMouseLeave:re,onPaneClick:k,onPaneContextMenu:A,onNodeContextMenu:D,onEdgeClick:w,onEdgeContextMenu:te,onConnect:S,onConnectStart:C,onConnectEnd:ee,onMove:y,isValidConnection:b,connectionMode:t.Strict,connectOnClick:!1,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!!i,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,minZoom:We,maxZoom:6,className:`bg-graph-bg`,children:[(0,Z.jsx)(l,{color:`var(--graph-grid)`,gap:28,size:.72}),(0,Z.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,children:(0,Z.jsxs)(`defs`,{children:[(0,Z.jsxs)(`linearGradient`,{id:`agent-graph-edge-flow`,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:[(0,Z.jsx)(`stop`,{offset:`0%`,stopColor:`var(--graph-edge)`,stopOpacity:`0.2`}),(0,Z.jsx)(`stop`,{offset:`50%`,stopColor:`var(--graph-edge-active)`,stopOpacity:`0.94`}),(0,Z.jsx)(`stop`,{offset:`100%`,stopColor:`var(--graph-edge)`,stopOpacity:`0.2`})]}),(0,Z.jsxs)(`radialGradient`,{id:`agent-graph-edge-pulse`,cx:`50%`,cy:`50%`,r:`50%`,children:[(0,Z.jsx)(`stop`,{offset:`0%`,stopColor:`var(--graph-edge-active)`,stopOpacity:`1`}),(0,Z.jsx)(`stop`,{offset:`100%`,stopColor:`var(--graph-edge-active)`,stopOpacity:`0.2`})]}),(0,Z.jsx)(`filter`,{id:`agent-graph-edge-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:(0,Z.jsx)(`feGaussianBlur`,{stdDeviation:`2.6`})})]})})]})}),o.length>0?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-4 left-4 z-30`,children:(0,Z.jsx)(`div`,{className:Ge,"data-testid":`agent-graph-zoom-indicator`,children:T(le)})}):null,d?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute right-4 top-4 z-30`,children:(0,Z.jsx)(`div`,{className:Ge,children:d})}):null,(0,Z.jsx)(st,{agent:oe,agentId:ae?.agentId??null,activeToolCall:ce,style:L,tooltipRef:se}),p?(0,Z.jsx)(Qe,{x:p.x,y:p.y,items:m,onClose:c}):null,j?(0,Z.jsx)(dt,{displayName:ie,roles:s,loadingRoles:x,onClose:u,onDisplayNameChange:N,onSelectRole:P,onSubmit:F,selectedRoleName:M,submitting:I,title:Ye(j),x:j.x,y:j.y}):null]})});function dt({x:e,y:t,title:n,selectedRoleName:r,displayName:i,roles:a,loadingRoles:o,submitting:s,onSelectRole:c,onDisplayNameChange:l,onSubmit:u,onClose:d}){let f=(0,$.useRef)(null),[p,m]=(0,$.useState)(()=>({left:e,top:t}));return(0,$.useEffect)(()=>{let n=f.current;if(!n)return;let r=requestAnimationFrame(()=>{let r=n.getBoundingClientRect(),i=window.innerWidth-12-r.width,a=window.innerHeight-12-r.height;m({left:Math.max(12,Math.min(e,i)),top:Math.max(12,Math.min(t,a))})});return()=>cancelAnimationFrame(r)},[o,a.length,n,e,t]),(0,$.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&d()};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[d]),(0,Z.jsx)(Ze,{children:(0,Z.jsxs)(`div`,{ref:f,className:`fixed z-[210] w-[min(24rem,calc(100vw-1.5rem))] rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-md`,style:{left:p.left,top:p.top},children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:n}),(0,Z.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Choose a role and optionally set a display name.`})]}),(0,Z.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:d,className:`flex h-8 items-center rounded-md px-2.5 text-[11px] text-muted-foreground transition-colors hover:bg-accent/35 hover:text-foreground`,children:`Close`})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsx)(`div`,{className:qe,children:o?(0,Z.jsx)(`p`,{className:`px-2 py-3 text-[12px] text-muted-foreground`,children:`Loading roles...`}):a.length===0?(0,Z.jsx)(`p`,{className:`px-2 py-3 text-[12px] text-muted-foreground`,children:`No roles available.`}):a.map(e=>(0,Z.jsxs)(F,{type:`button`,variant:`ghost`,onClick:()=>c(e.name),className:w(Je,r===e.name?`border-border bg-accent/70`:`border-transparent bg-transparent hover:border-border hover:bg-accent/45`),children:[(0,Z.jsx)(`div`,{className:`text-[13px] font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:e.description})]},e.name))}),(0,Z.jsx)(z,{"aria-label":`Display Name`,value:i,onChange:e=>l(e.target.value),placeholder:`Optional display name`,className:Ke})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,Z.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:d,className:`flex h-8 items-center rounded-md px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/35 hover:text-foreground`,children:`Cancel`}),(0,Z.jsx)(F,{type:`button`,size:`sm`,disabled:!r||s,onClick:u,className:`flex h-8 items-center rounded-md bg-primary px-3.5 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,children:s?`Saving...`:n})]})]})})}function ft({activeTabId:e,connected:t,definitionDraft:n,editorMode:r,graphConnectMode:i,graphHistory:a,graphRef:o,isCompactWorkspace:s,isDragging:c,leaderDetailVisible:l,leaderNode:u,leaderPanelRunning:m,loadingRoles:g,onCloseLeaderDetails:b,onConnectModeChange:T,onCreateNode:te,onCreateTab:D,onDefinitionDraftChange:ie,onDeleteTab:M,onDuplicateTab:N,onEditorModeChange:P,onOpenLeaderDetails:I,onOpenConnectDialog:ae,onSaveDefinition:oe,panelVisible:se,pendingAction:ce,resolvedPanelWidth:ue,roles:de,selectAgent:fe,selectedAgent:R,setActiveTabId:pe,startDrag:me,tabs:he,togglePanel:z,workflowNodeOptions:B,workspaceRef:ge}){let _e=()=>l&&u?(0,Z.jsx)(j,{agent:u,onClose:b}):e?(0,Z.jsx)(k,{onOpenDetails:I}):(0,Z.jsx)(A,{}),V=e?he.get(e)??null:null;return(0,Z.jsxs)(`div`,{ref:ge,className:`relative isolate flex h-full overflow-hidden rounded-xl border border-border bg-surface-overlay shadow-md [contain:paint]`,children:[(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,Z.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:`relative z-30 border-b border-border bg-background/45 backdrop-blur-md`,children:(0,Z.jsxs)(`div`,{className:`pointer-events-auto relative z-10 flex items-center gap-1.5 overflow-x-auto px-3 py-2.5 pr-14 scrollbar-none`,children:[Array.from(he.values()).map(t=>(0,Z.jsxs)(`div`,{className:`group relative min-w-[120px] max-w-[220px] shrink-0`,children:[(0,Z.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>pe(t.id),onAuxClick:e=>{e.button===1&&(e.preventDefault(),M(t.id,t.title,t.node_count))},className:w(`relative h-8 w-full justify-start rounded-md border-b-2 px-3 pr-12 text-left text-[13px] font-medium transition-[color,border-color,background-color] duration-200`,e===t.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:bg-accent/25 hover:text-foreground`),children:(0,Z.jsx)(`div`,{className:`truncate leading-tight`,children:t.title})}),e===t.id?(0,Z.jsx)(F,{type:`button`,variant:`ghost`,size:`icon-xs`,title:`Duplicate workflow`,"aria-label":`Duplicate ${t.title}`,onClick:e=>{e.stopPropagation(),N()},className:`absolute right-6 top-1/2 z-20 size-5 -translate-y-1/2 rounded-sm p-1 text-foreground/70 transition-all duration-200 hover:bg-accent/45 hover:text-foreground`,children:(0,Z.jsx)(p,{className:`size-3`})}):null,(0,Z.jsx)(F,{type:`button`,variant:`ghost`,size:`icon-xs`,title:`Delete workflow`,"aria-label":`Delete ${t.title}`,onClick:e=>{e.stopPropagation(),M(t.id,t.title,t.node_count)},className:w(`absolute right-1.5 top-1/2 z-20 size-5 -translate-y-1/2 rounded-sm p-1 transition-all duration-200 hover:bg-accent/45 hover:text-foreground`,e===t.id?`text-foreground/70 opacity-100`:`text-muted-foreground/60 opacity-0 group-hover:opacity-100`),children:(0,Z.jsx)(C,{className:`size-3`})})]},t.id)),(0,Z.jsx)(F,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Create workflow`,onClick:D,className:`shrink-0 rounded-md text-muted-foreground transition-all duration-200 hover:bg-accent/45 hover:text-foreground`,children:(0,Z.jsx)(S,{className:`size-4`})})]})}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-0`,style:{background:`radial-gradient(circle at 14% 10%, var(--shell-spotlight-primary), transparent 24%), linear-gradient(180deg, color-mix(in srgb, var(--foreground) 1%, transparent), transparent 22%)`}}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-10 w-12 bg-gradient-to-l from-background/28 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[r===`graph`?(0,Z.jsx)(ut,{ref:o,loadingRoles:g,onConnectModeChange:T,onCreateConnection:a.createConnection,onCreateLinkedAgent:a.createLinkedAgent,onCreateStandaloneAgent:a.createStandaloneAgent,onDeleteAgent:a.deleteAgent,onDeleteConnection:a.deleteConnection,onInsertAgentBetween:a.insertAgentBetween,onOpenConnectDialog:ae,roles:de}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-[11px] font-semibold text-muted-foreground`,children:`Workflow JSON`}),(0,Z.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Edit the formal definition shared by the graph view.`})]}),(0,Z.jsxs)(F,{onClick:oe,disabled:!e||ce===`save-definition`,children:[(0,Z.jsx)(v,{className:`mr-1 size-4`}),ce===`save-definition`?`Saving...`:`Save JSON`]})]}),(0,Z.jsx)(`textarea`,{value:n,onChange:e=>ie(e.target.value),className:`h-full min-h-0 w-full resize-none rounded-xl border border-border bg-background/40 p-4 font-mono text-[12px] leading-6 text-foreground outline-none transition-[border-color,box-shadow] focus:border-ring focus:ring-[3px] focus:ring-ring/50`,spellCheck:!1})]}),(0,Z.jsxs)(`div`,{className:w(`absolute top-4 z-40 flex max-w-[calc(100%-2.5rem)] flex-wrap items-center gap-1.5`,s?`left-14`:`left-4`),children:[(0,Z.jsxs)(re,{tone:`primary`,children:[(0,Z.jsx)(y,{className:w(`size-3.5 shrink-0`,t?`text-graph-status-idle/88`:`text-graph-status-initializing/38`)}),(0,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:t?`Live`:`Reconnecting`})]}),V?(0,Z.jsxs)(re,{children:[V.node_count??V.definition.nodes.length,` `,`nodes`]}):null]}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 bottom-4 z-40 flex justify-center`,children:(0,Z.jsxs)(`div`,{"data-testid":`workspace-toolbar`,className:`pointer-events-auto inline-flex max-w-full items-center overflow-x-auto rounded-xl border border-border bg-surface-overlay/92 p-0.5 shadow-sm scrollbar-none`,children:[(0,Z.jsxs)(E,{disabled:!e||!a.canUndo(e),onClick:()=>{a.undo(e)},children:[(0,Z.jsx)(f,{className:`size-4 opacity-70`}),`Undo`]}),(0,Z.jsx)(O,{}),(0,Z.jsxs)(E,{disabled:!e||!a.canRedo(e),onClick:()=>{a.redo(e)},children:[(0,Z.jsx)(_,{className:`size-4 opacity-70`}),`Redo`]}),(0,Z.jsx)(O,{}),(0,Z.jsxs)(E,{disabled:!e,active:r===`graph`,onClick:()=>P(`graph`),children:[(0,Z.jsx)(d,{className:`size-4 opacity-70`}),`Graph`]}),(0,Z.jsx)(O,{}),(0,Z.jsxs)(E,{disabled:!e,active:r===`json`,onClick:()=>P(`json`),children:[(0,Z.jsx)(h,{className:`size-4 opacity-70`}),`JSON`]}),(0,Z.jsx)(O,{}),(0,Z.jsxs)(E,{disabled:!e,onClick:te,children:[(0,Z.jsx)(S,{className:`size-4 opacity-70`}),`Add Node`]}),(0,Z.jsx)(O,{}),(0,Z.jsxs)(E,{disabled:!e||B.length<2,active:i,onClick:ae,children:[(0,Z.jsx)(ee,{className:`size-4 opacity-70`}),`Connect Ports`]}),(0,Z.jsx)(O,{}),(0,Z.jsxs)(E,{disabled:!e,onClick:N,children:[(0,Z.jsx)(p,{className:`size-4 opacity-70`}),`Duplicate`]})]})})]}),(0,Z.jsx)(`div`,{className:`absolute bottom-4 right-4 z-30 sm:bottom-5 sm:right-5`,children:(0,Z.jsx)(ne,{expanded:se,onClick:z})})]}),(0,Z.jsx)(L,{initial:!1,children:se?s?[(0,Z.jsx)(x.button,{type:`button`,"aria-label":`Close workspace panel`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:`absolute inset-0 z-10 bg-background/40 backdrop-blur-[1px]`,onClick:z},`workspace-panel-backdrop`),(0,Z.jsxs)(x.aside,{initial:{opacity:0,x:18},animate:{opacity:1,x:0},exit:{opacity:0,x:18},transition:{duration:.22,ease:[.16,1,.3,1]},className:`absolute inset-y-2.5 right-2.5 z-20 shrink-0 overflow-hidden rounded-xl border border-border bg-surface-overlay shadow-md`,style:{width:`${ue}px`},children:[(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:w(`pointer-events-none absolute inset-0 z-20 border transition-[opacity,border-color,box-shadow] duration-300`,!R&&m?`animate-pulse border-ring/25 opacity-100 shadow-lg shadow-ring/10`:`border-transparent opacity-0`)}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,Z.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(x.div,{animate:{opacity:+!R,x:R?-8:0},transition:{duration:.15},className:w(`absolute inset-0 flex h-full flex-col`,R&&`pointer-events-none`),"aria-hidden":R?!0:void 0,children:_e()}),(0,Z.jsx)(L,{children:R?(0,Z.jsx)(x.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.15},className:`absolute inset-0 flex h-full flex-col bg-background/42`,children:(0,Z.jsx)(j,{agent:R,onClose:()=>fe(null)})},R.id):null})]})})]},`workspace-panel-sheet`)]:(0,Z.jsxs)(x.aside,{initial:{width:0,opacity:0},animate:{width:ue,opacity:1},exit:{width:0,opacity:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:`relative z-20 shrink-0 border-l border-border bg-surface-overlay shadow-md`,children:[(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:w(`pointer-events-none absolute inset-0 z-20 border transition-[opacity,border-color,box-shadow] duration-300`,!R&&m?`animate-pulse border-ring/25 opacity-100 shadow-lg shadow-ring/10`:`border-transparent opacity-0`)}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,Z.jsx)(le,{position:`left`,isDragging:c,onMouseDown:me}),(0,Z.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,style:{width:`${ue}px`},children:(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(x.div,{animate:{opacity:+!R,x:R?-8:0},transition:{duration:.15},className:w(`absolute inset-0 flex h-full flex-col`,R&&`pointer-events-none`),"aria-hidden":R?!0:void 0,children:_e()}),(0,Z.jsx)(L,{children:R?(0,Z.jsx)(x.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.15},className:`absolute inset-0 flex h-full flex-col bg-background/42`,children:(0,Z.jsx)(j,{agent:R,onClose:()=>fe(null)})},R.id):null})]})})]},`workspace-panel-docked`):null})]})}function pt(e){return{undo:[...e?.undo??[]],redo:[...e?.redo??[]]}}function mt(e){let t=e?.trim()??``;return t.length>0?t:void 0}function ht(){let e=(0,$.useRef)(new Map),[t,n]=(0,$.useState)(0),r=(0,$.useCallback)(()=>{n(e=>e+1)},[]),i=(0,$.useCallback)((t,n)=>{let i=pt(e.current.get(t));i.undo.push(n),i.redo=[],e.current.set(t,i),r()},[r]),a=(0,$.useCallback)(async({tabId:e,nodeType:t=`agent`,roleName:n,name:r})=>{let a=mt(r),o=(await V(e,{node_type:t,role_name:n,name:a})).id;return i(e,{undo:async()=>{await N(e,o)},redo:async()=>{o=(await V(e,{node_type:t,role_name:n,name:a})).id}}),o},[i]),o=(0,$.useCallback)(async({tabId:e,anchorNodeId:t,roleName:n,name:r})=>{let a=mt(r),o=(await V(e,{node_type:`agent`,role_name:n,name:a})).id;try{await M(e,{fromNodeId:t,toNodeId:o})}catch(t){throw await N(e,o).catch(()=>void 0),t}return i(e,{undo:async()=>{await N(e,o)},redo:async()=>{o=(await V(e,{node_type:`agent`,role_name:n,name:a})).id,await M(e,{fromNodeId:t,toNodeId:o})}}),o},[i]),s=(0,$.useCallback)(async(e,t,n,r=`out`,a=`in`)=>{let o=await M(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a});i(e,{undo:async()=>{await P(e,{edgeId:o.id})},redo:async()=>{await M(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a})}})},[i]),c=(0,$.useCallback)(async(e,t,n,r=`out`,a=`in`)=>{await P(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a}),i(e,{undo:async()=>{await M(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a})},redo:async()=>{await P(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a})}})},[i]),l=(0,$.useCallback)(async({tabId:e,node:t,tabAgents:n})=>{let r=Array.from(new Set([...t.connections].filter(e=>n.some(t=>t.id===e)))),a=mt(t.name),o=t.role_name?.trim()??``,s=t.id;await N(e,s),i(e,{undo:async()=>{s=(await V(e,{node_type:t.node_type,role_name:o||void 0,name:a})).id;for(let t of r)await M(e,{fromNodeId:t,toNodeId:s})},redo:async()=>{await N(e,s)}})},[i]),u=(0,$.useCallback)(async({tabId:e,sourceNodeId:t,targetNodeId:n,roleName:r,name:a})=>{let o=mt(a),s=null;await P(e,{fromNodeId:t,toNodeId:n});try{s=(await V(e,{node_type:`agent`,role_name:r,name:o})).id,await M(e,{fromNodeId:t,toNodeId:s}),await M(e,{fromNodeId:s,toNodeId:n})}catch(r){throw s&&await N(e,s).catch(()=>void 0),await M(e,{fromNodeId:t,toNodeId:n}).catch(()=>void 0),r}return i(e,{undo:async()=>{s&&(await N(e,s),await M(e,{fromNodeId:t,toNodeId:n}))},redo:async()=>{await P(e,{fromNodeId:t,toNodeId:n}),s=(await V(e,{node_type:`agent`,role_name:r,name:o})).id,await M(e,{fromNodeId:t,toNodeId:s}),await M(e,{fromNodeId:s,toNodeId:n})}}),s},[i]),d=(0,$.useCallback)(t=>!!(t&&(e.current.get(t)?.undo.length??0)>0),[]),f=(0,$.useCallback)(t=>!!(t&&(e.current.get(t)?.redo.length??0)>0),[]),p=(0,$.useCallback)(async t=>{if(!t)return!1;let n=pt(e.current.get(t)),i=n.undo.pop();return i?(await i.undo(),n.redo.push(i),e.current.set(t,n),r(),!0):!1},[r]),m=(0,$.useCallback)(async t=>{if(!t)return!1;let n=pt(e.current.get(t)),i=n.redo.pop();return i?(await i.redo(),n.undo.push(i),e.current.set(t,n),r(),!0):!1},[r]);return(0,$.useMemo)(()=>({canRedo:f,canUndo:d,createConnection:s,createLinkedAgent:o,createStandaloneAgent:e=>a({tabId:e.tabId,nodeType:`agent`,roleName:e.roleName,name:e.name}),createStandaloneNode:a,deleteAgent:l,deleteConnection:c,insertAgentBetween:u,redo:m,revision:t,undo:p}),[f,d,s,o,a,c,l,u,m,t,p])}var gt=`workspace-panel-width`,_t=296,vt=300,yt=960,bt=.34,xt=448,St=300;function Ct(e){return`${e.key} · ${e.kind}`}function wt(){let{agents:e}=de(),{tabs:t}=ce(),{connected:n}=me(),{activeToolCalls:r}=he(),{streamingDeltas:i}=fe(),{activeTabId:a,selectedAgentId:o,selectAgent:s,setActiveTabId:c}=_e(),[l,u]=(0,$.useState)(!0),[d,f]=(0,$.useState)(`chat`),[p,h]=(0,$.useState)(`graph`),g=B(`(max-width: 1180px)`),[_,v]=(0,$.useState)(null),[y,b]=(0,$.useState)(null),[x,S]=(0,$.useState)(``),[ee,C]=(0,$.useState)(!1),[w,T]=(0,$.useState)(``),[E,ne]=(0,$.useState)([]),[re,O]=(0,$.useState)(!1),[k,A]=(0,$.useState)(`agent`),[j,M]=(0,$.useState)(`Worker`),[N,P]=(0,$.useState)(``),[F,I]=(0,$.useState)(``),[L,le]=(0,$.useState)(``),[z,V]=(0,$.useState)(``),[H,ve]=(0,$.useState)(``),[U,ye]=(0,$.useState)(null),[be,Se]=(0,$.useState)(JSON.stringify(oe,null,2)),W=(0,$.useRef)(null),G=(0,$.useRef)(null),K=(0,$.useRef)(null),q=ht(),[Ce,we]=(0,$.useState)(!1),[Te,Ee]=ue(gt,xt,_t,yt),De=(0,$.useCallback)(e=>{let t=K.current?.clientWidth??(typeof window>`u`?e:window.innerWidth),n=Math.max(_t,t-vt);Ee(Math.min(e,n))},[Ee]),{isDragging:Oe,startDrag:ke}=ge(Te,De,`left`);(0,$.useLayoutEffect)(()=>{if(pe(gt))return;let e=K.current?.clientWidth;e&&De(e*bt)},[De]),(0,$.useEffect)(()=>{let e=K.current;if(!e)return;let t=new ResizeObserver(()=>{De(Te)});return t.observe(e),()=>{t.disconnect()}},[Te,De]),(0,$.useEffect)(()=>{let e=W.current;W.current=g,e!==null&&!e&&g&&u(!1)},[g]),(0,$.useEffect)(()=>{let e=!1;return O(!0),te().then(t=>{e||ne(t)}).catch(()=>{e||m.error(`Failed to load roles`)}).finally(()=>{e||O(!1)}),()=>{e=!0}},[]);let J=o?e.get(o)??null:null,Y=a?t.get(a)??null:null,X=(0,$.useMemo)(()=>Array.from(e.values()).filter(e=>e.node_type!==`assistant`&&e.tab_id===a),[a,e]),Ae=(0,$.useMemo)(()=>X.filter(e=>!e.is_leader),[X]),Z=(0,$.useMemo)(()=>Y?.definition.nodes??[],[Y?.definition.nodes]),Q=(0,$.useMemo)(()=>Z.map(e=>({id:e.id,label:xe({name:typeof e.config.name==`string`?e.config.name:null,roleName:typeof e.config.role_name==`string`?e.config.role_name:null,nodeType:e.type,isLeader:!1})})),[Z]),je=(0,$.useMemo)(()=>Z.find(e=>e.id===F)??null,[F,Z]),Me=(0,$.useMemo)(()=>Z.find(e=>e.id===z)??null,[z,Z]),Ne=(0,$.useMemo)(()=>(je?.outputs??[]).map(e=>({key:e.key,label:Ct(e)})),[je]),Pe=(0,$.useMemo)(()=>(Me?.inputs??[]).map(e=>({key:e.key,label:Ct(e)})),[Me]),Fe=(0,$.useMemo)(()=>E.find(e=>e.name===j)??null,[j,E]),Ie=l||!!J,Le=(0,$.useMemo)(()=>{if(!g)return Te;let e=K.current?.clientWidth??(typeof window>`u`?Te:window.innerWidth);return Math.min(Te,Math.max(St,e-24))},[g,Te]),Re=(0,$.useMemo)(()=>D(e,Y),[Y,e]),ze=Re?.id??Y?.leader_id??null,Be=d===`detail`&&Re!==null,Ve=(0,$.useMemo)(()=>{let e=ze?i.get(ze)??[]:[];return n&&!!(ze&&(Re?.state===`running`||Re?.state===`sleeping`||r.has(ze)||e.length>0))},[r,n,ze,Re,i]);(0,$.useEffect)(()=>{J&&J.tab_id!==null&&J.tab_id!==a&&s(null)},[a,s,J]),(0,$.useEffect)(()=>{Se(JSON.stringify(Y?.definition??oe,null,2))},[Y?.definition]),(0,$.useEffect)(()=>{Ne.some(e=>e.key===L)||le(Ne[0]?.key??``)},[L,Ne]),(0,$.useEffect)(()=>{Pe.some(e=>e.key===H)||ve(Pe[0]?.key??``)},[H,Pe]),(0,$.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`z`)return;let t=e.target;if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t?.isContentEditable||_!==null)){if(e.preventDefault(),e.shiftKey){q.redo(a).catch(()=>void 0);return}q.undo(a).catch(()=>void 0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,a,q]);let He=(0,$.useCallback)(()=>{u(!0),f(`detail`)},[]),Ue=(0,$.useCallback)(()=>{f(`chat`)},[]),We=(0,$.useCallback)(()=>{if(Ie){o&&s(null),u(!1);return}u(!0)},[Ie,s,o]),Ge=(0,$.useCallback)(()=>{S(``),C(!1),T(``),v(`create-tab`)},[]),Ke=(0,$.useCallback)(async()=>{let e=x.trim();if(e){b(`create-tab`);try{c((await se(e,ee,w.split(`
3
- `).map(e=>e.trim()).filter(Boolean))).id),v(null),S(``),C(!1),T(``)}catch(e){m.error(e instanceof Error?e.message:`Failed to create workflow`)}finally{b(null)}}},[ee,x,w,c]),qe=(0,$.useCallback)(async()=>{if(!a){m.error(`Create or select a workflow first`);return}b(`duplicate-tab`);try{c((await R(a)).id)}catch(e){m.error(e instanceof Error?e.message:`Failed to duplicate workflow`)}finally{b(null)}},[a,c]),Je=(0,$.useCallback)(()=>{if(!a){m.error(`Create or select a workflow first`);return}A(`agent`),M(`Worker`),P(``),v(`create-node`)},[a]),Ye=(0,$.useCallback)(async()=>{if(!a)return;let e=N.trim()||void 0;b(`create-node`);try{if(k===`agent`){let t=Fe?.name??``;if(!t)return;await q.createStandaloneNode({tabId:a,nodeType:`agent`,roleName:t,name:e})}else await q.createStandaloneNode({tabId:a,nodeType:k,name:e});v(null),A(`agent`),M(`Worker`),P(``)}catch(e){m.error(e instanceof Error?e.message:`Failed to create node`)}finally{b(null)}},[a,N,k,q,Fe?.name]),Xe=(0,$.useCallback)((e,t,n)=>{ye({id:e,title:t,nodeCount:n})},[]),Ze=(0,$.useCallback)(async()=>{if(U){b(`delete-tab`);try{await ae(U.id),ye(null)}catch(e){m.error(e instanceof Error?e.message:`Failed to delete workflow`)}finally{b(null)}}},[U]),Qe=(0,$.useCallback)(()=>{if(!a){m.error(`Create or select a workflow first`);return}if(Q.length<2){m.error(`Add at least two nodes before creating an edge`);return}let e=Q[0]?.id??``,t=Q.find(t=>t.id!==e)?.id??``;!e||!t||(I(e),V(t),v(`connect-ports`))},[a,Q]);return{activeDialog:_,activeTab:Y,activeTabId:a,connected:n,connectSourceId:F,connectSourcePortKey:L,connectTargetId:z,connectTargetPortKey:H,createNodeName:N,createNodeRoleName:j,createNodeType:k,createTabAllowNetwork:ee,createTabTitle:x,createTabWriteDirs:w,definitionDraft:be,deleteTabTarget:U,editorMode:p,graphConnectMode:Ce,graphHistory:q,graphRef:G,handleCloseLeaderDetails:Ue,handleConnectPorts:(0,$.useCallback)(async()=>{if(!(!a||!F||!L||!z||!H)){b(`connect-ports`);try{await q.createConnection(a,F,z,L,H),v(null)}catch(e){m.error(e instanceof Error?e.message:`Failed to connect ports`)}finally{b(null)}}},[a,F,L,z,H,q]),handleCreateNode:Ye,handleCreateTab:Ke,handleDeleteTab:Ze,handleDuplicateTab:qe,handleOpenLeaderDetails:He,handleSaveDefinition:(0,$.useCallback)(async()=>{if(!a)return;let e;try{e=JSON.parse(be)}catch{m.error(`Workflow JSON is invalid`);return}if(!e||typeof e!=`object`){m.error(`Workflow JSON must be an object`);return}b(`save-definition`);try{await ie(a,e),m.success(`Workflow JSON saved`)}catch(e){m.error(e instanceof Error?e.message:`Failed to save workflow definition`)}finally{b(null)}},[a,be]),isCompactWorkspace:g,isDragging:Oe,leaderDetailVisible:Be,leaderNode:Re,leaderPanelRunning:Ve,loadingRoles:re,openConnectDialog:Qe,openCreateNodeDialog:Je,openCreateTabDialog:Ge,panelVisible:Ie,pendingAction:y,regularTabAgents:Ae,requestDeleteTab:Xe,resolvedPanelWidth:Le,roles:E,selectAgent:s,selectedAgent:J,selectedCreateNodeRole:Fe,setActiveDialog:v,setActiveTabId:c,setConnectSourceId:I,setConnectSourcePortKey:le,setConnectTargetId:V,setConnectTargetPortKey:ve,setCreateNodeName:P,setCreateNodeRoleName:M,setCreateNodeType:A,setCreateTabAllowNetwork:C,setCreateTabTitle:S,setCreateTabWriteDirs:T,setDefinitionDraft:Se,setDeleteTabTarget:ye,setEditorMode:h,setGraphConnectMode:we,sourcePortOptions:Ne,startDrag:ke,tabs:t,targetPortOptions:Pe,togglePanel:We,workflowNodeOptions:Q,workspaceRef:K}}function Tt(){let{activeDialog:e,activeTab:t,activeTabId:n,connected:r,connectSourceId:i,connectSourcePortKey:a,connectTargetId:o,connectTargetPortKey:s,createNodeName:c,createNodeRoleName:l,createNodeType:u,createTabAllowNetwork:d,createTabTitle:f,createTabWriteDirs:p,definitionDraft:m,deleteTabTarget:h,editorMode:g,graphConnectMode:_,graphHistory:v,graphRef:y,handleCloseLeaderDetails:b,handleConnectPorts:x,handleCreateNode:S,handleCreateTab:ee,handleDeleteTab:C,handleDuplicateTab:w,handleOpenLeaderDetails:T,handleSaveDefinition:te,isCompactWorkspace:E,isDragging:D,leaderDetailVisible:ne,leaderNode:re,leaderPanelRunning:O,loadingRoles:k,openConnectDialog:A,openCreateNodeDialog:j,openCreateTabDialog:ie,panelVisible:M,pendingAction:N,regularTabAgents:P,requestDeleteTab:F,resolvedPanelWidth:I,roles:ae,selectAgent:oe,selectedAgent:se,selectedCreateNodeRole:L,setActiveDialog:ce,setActiveTabId:le,setConnectSourceId:ue,setConnectSourcePortKey:de,setConnectTargetId:fe,setConnectTargetPortKey:R,setCreateNodeName:pe,setCreateNodeRoleName:me,setCreateNodeType:he,setCreateTabAllowNetwork:z,setCreateTabTitle:B,setCreateTabWriteDirs:ge,setDefinitionDraft:_e,setDeleteTabTarget:V,setEditorMode:H,setGraphConnectMode:ve,sourcePortOptions:U,startDrag:ye,tabs:be,targetPortOptions:xe,togglePanel:Se,workflowNodeOptions:W,workspaceRef:G}=wt();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ft,{activeTabId:n,connected:r,definitionDraft:m,editorMode:g,graphConnectMode:_,graphHistory:v,graphRef:y,isCompactWorkspace:E,isDragging:D,leaderDetailVisible:ne,leaderNode:re,leaderPanelRunning:O,loadingRoles:k,onCloseLeaderDetails:b,onConnectModeChange:ve,onCreateNode:j,onCreateTab:ie,onDefinitionDraftChange:_e,onDeleteTab:F,onDuplicateTab:w,onEditorModeChange:H,onOpenLeaderDetails:T,onOpenConnectDialog:A,onSaveDefinition:te,panelVisible:M,pendingAction:N,regularTabAgents:P,resolvedPanelWidth:I,roles:ae,selectAgent:oe,selectedAgent:se,setActiveTabId:le,startDrag:ye,tabs:be,togglePanel:Se,workflowNodeOptions:W,sourcePortOptions:U,targetPortOptions:xe,workspaceRef:G}),(0,Z.jsx)(Pe,{open:e===`create-tab`,onOpenChange:e=>{e||ce(null)},pending:N===`create-tab`,title:f,onTitleChange:B,allowNetwork:d,onAllowNetworkChange:z,writeDirs:p,onWriteDirsChange:ge,onSubmit:()=>void ee()}),(0,Z.jsx)(Ie,{open:e===`create-node`,onOpenChange:e=>{e||ce(null)},pending:N===`create-node`,activeTabTitle:t?.title??null,nodeType:u,onNodeTypeChange:he,selectedRole:L,selectedRoleName:l,onRoleNameChange:me,roles:ae,loadingRoles:k,nodeName:c,onNodeNameChange:pe,onSubmit:()=>void S(),submitDisabled:!n||N===`create-node`||u===`agent`&&!L}),(0,Z.jsx)(Le,{open:e===`connect-ports`,onOpenChange:e=>{e||ce(null)},pending:N===`connect-ports`,activeTabTitle:t?.title??null,nodeOptions:W,fromNodeId:i,fromPortKey:a,toNodeId:o,toPortKey:s,fromPortOptions:U,toPortOptions:xe,onFromNodeChange:ue,onFromPortChange:de,onToNodeChange:fe,onToPortChange:R,onSubmit:()=>void x()}),(0,Z.jsx)(Re,{open:!!h,onOpenChange:e=>{e||V(null)},pending:N===`delete-tab`,target:h,onDelete:()=>void C()})]})}export{Tt as HomePage};
@@ -1,7 +0,0 @@
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};
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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};
@@ -1,3 +0,0 @@
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};