flowent 0.0.6 → 0.0.7

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 (265) hide show
  1. package/README.md +1 -1
  2. package/backend/README.md +1 -1
  3. package/backend/pyproject.toml +1 -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__/model_metadata.cpython-313.pyc +0 -0
  18. package/backend/src/flowent/__pycache__/network.cpython-313.pyc +0 -0
  19. package/backend/src/flowent/__pycache__/observability_service.cpython-313.pyc +0 -0
  20. package/backend/src/flowent/__pycache__/registry.cpython-313.pyc +0 -0
  21. package/backend/src/flowent/__pycache__/role_management.cpython-313.pyc +0 -0
  22. package/backend/src/flowent/__pycache__/runtime.cpython-313.pyc +0 -0
  23. package/backend/src/flowent/__pycache__/sandbox.cpython-313.pyc +0 -0
  24. package/backend/src/flowent/__pycache__/security.cpython-313.pyc +0 -0
  25. package/backend/src/flowent/__pycache__/settings.cpython-313.pyc +0 -0
  26. package/backend/src/flowent/__pycache__/settings_management.cpython-313.pyc +0 -0
  27. package/backend/src/flowent/__pycache__/state_db.cpython-313.pyc +0 -0
  28. package/backend/src/flowent/__pycache__/workspace_store.cpython-313.pyc +0 -0
  29. package/backend/src/flowent/agent.py +91 -8
  30. package/backend/src/flowent/channels/__pycache__/__init__.cpython-313.pyc +0 -0
  31. package/backend/src/flowent/channels/__pycache__/telegram.cpython-313.pyc +0 -0
  32. package/backend/src/flowent/graph_service.py +3 -110
  33. package/backend/src/flowent/models/__pycache__/__init__.cpython-313.pyc +0 -0
  34. package/backend/src/flowent/models/__pycache__/agent.cpython-313.pyc +0 -0
  35. package/backend/src/flowent/models/__pycache__/base.cpython-313.pyc +0 -0
  36. package/backend/src/flowent/models/__pycache__/blueprint.cpython-313.pyc +0 -0
  37. package/backend/src/flowent/models/__pycache__/content.cpython-313.pyc +0 -0
  38. package/backend/src/flowent/models/__pycache__/delta.cpython-313.pyc +0 -0
  39. package/backend/src/flowent/models/__pycache__/event.cpython-313.pyc +0 -0
  40. package/backend/src/flowent/models/__pycache__/graph.cpython-313.pyc +0 -0
  41. package/backend/src/flowent/models/__pycache__/history.cpython-313.pyc +0 -0
  42. package/backend/src/flowent/models/__pycache__/llm.cpython-313.pyc +0 -0
  43. package/backend/src/flowent/models/__pycache__/message.cpython-313.pyc +0 -0
  44. package/backend/src/flowent/models/__pycache__/tab.cpython-313.pyc +0 -0
  45. package/backend/src/flowent/models/__pycache__/todo.cpython-313.pyc +0 -0
  46. package/backend/src/flowent/prompts/__pycache__/__init__.cpython-313.pyc +0 -0
  47. package/backend/src/flowent/prompts/__pycache__/common.cpython-313.pyc +0 -0
  48. package/backend/src/flowent/prompts/__pycache__/steward.cpython-313.pyc +0 -0
  49. package/backend/src/flowent/providers/__pycache__/__init__.cpython-313.pyc +0 -0
  50. package/backend/src/flowent/providers/__pycache__/anthropic.cpython-313.pyc +0 -0
  51. package/backend/src/flowent/providers/__pycache__/base_url.cpython-313.pyc +0 -0
  52. package/backend/src/flowent/providers/__pycache__/configuration.cpython-313.pyc +0 -0
  53. package/backend/src/flowent/providers/__pycache__/content.cpython-313.pyc +0 -0
  54. package/backend/src/flowent/providers/__pycache__/errors.cpython-313.pyc +0 -0
  55. package/backend/src/flowent/providers/__pycache__/gateway.cpython-313.pyc +0 -0
  56. package/backend/src/flowent/providers/__pycache__/headers.cpython-313.pyc +0 -0
  57. package/backend/src/flowent/providers/__pycache__/management.cpython-313.pyc +0 -0
  58. package/backend/src/flowent/providers/__pycache__/openai.cpython-313.pyc +0 -0
  59. package/backend/src/flowent/providers/__pycache__/openai_responses.cpython-313.pyc +0 -0
  60. package/backend/src/flowent/providers/__pycache__/registry.cpython-313.pyc +0 -0
  61. package/backend/src/flowent/providers/__pycache__/sse.cpython-313.pyc +0 -0
  62. package/backend/src/flowent/providers/__pycache__/thinking.cpython-313.pyc +0 -0
  63. package/backend/src/flowent/role_management.py +9 -6
  64. package/backend/src/flowent/routes/__init__.py +0 -2
  65. package/backend/src/flowent/routes/__pycache__/__init__.cpython-313.pyc +0 -0
  66. package/backend/src/flowent/routes/__pycache__/access.cpython-313.pyc +0 -0
  67. package/backend/src/flowent/routes/__pycache__/assistant.cpython-313.pyc +0 -0
  68. package/backend/src/flowent/routes/__pycache__/image_assets.cpython-313.pyc +0 -0
  69. package/backend/src/flowent/routes/__pycache__/meta.cpython-313.pyc +0 -0
  70. package/backend/src/flowent/routes/__pycache__/nodes.cpython-313.pyc +0 -0
  71. package/backend/src/flowent/routes/__pycache__/prompts.cpython-313.pyc +0 -0
  72. package/backend/src/flowent/routes/__pycache__/providers_route.cpython-313.pyc +0 -0
  73. package/backend/src/flowent/routes/__pycache__/roles.cpython-313.pyc +0 -0
  74. package/backend/src/flowent/routes/__pycache__/settings.cpython-313.pyc +0 -0
  75. package/backend/src/flowent/routes/__pycache__/tabs.cpython-313.pyc +0 -0
  76. package/backend/src/flowent/routes/__pycache__/ws.cpython-313.pyc +0 -0
  77. package/backend/src/flowent/routes/assistant.py +3 -0
  78. package/backend/src/flowent/routes/nodes.py +11 -1
  79. package/backend/src/flowent/routes/settings.py +169 -118
  80. package/backend/src/flowent/routes/tabs.py +0 -12
  81. package/backend/src/flowent/runtime.py +0 -5
  82. package/backend/src/flowent/security.py +1 -21
  83. package/backend/src/flowent/settings.py +15 -421
  84. package/backend/src/flowent/settings_management.py +260 -164
  85. package/backend/src/flowent/state_db.py +2 -14
  86. package/backend/src/flowent/static/assets/AssistantPage-BW7XAd9I.js +1 -0
  87. package/backend/src/flowent/static/assets/ChannelsPage-tCJHgt6m.js +1 -0
  88. package/backend/src/flowent/static/assets/{PageScaffold-DteOA8V7.js → PageScaffold-f6g2l7XN.js} +1 -1
  89. package/backend/src/flowent/static/assets/PromptsPage-C3Sxn2D7.js +1 -0
  90. package/backend/src/flowent/static/assets/ProvidersPage-BfmdXmNt.js +3 -0
  91. package/backend/src/flowent/static/assets/RolesPage-DET8wO4r.js +1 -0
  92. package/backend/src/flowent/static/assets/SettingsPage-D-g3deMm.js +3 -0
  93. package/backend/src/flowent/static/assets/ToolsPage-CDmtE2g4.js +1 -0
  94. package/backend/src/flowent/static/assets/WorkspacePage-AZsJ0sD0.js +3 -0
  95. package/backend/src/flowent/static/assets/WorkspacePanels-CteCjolX.js +1 -0
  96. package/backend/src/flowent/static/assets/{alert-dialog-DIBUCmqM.js → alert-dialog-Duorp_S-.js} +1 -1
  97. package/backend/src/flowent/static/assets/{dialog-BOvHIBrg.js → dialog-C3ixjGjN.js} +1 -1
  98. package/backend/src/flowent/static/assets/index--o_0fv0N.css +1 -0
  99. package/backend/src/flowent/static/assets/index-C9HuekJm.js +10 -0
  100. package/backend/src/flowent/static/assets/{modelParams-DcEhGnu0.js → modelParams-DmnF2hwR.js} +1 -1
  101. package/backend/src/flowent/static/assets/providerTypes-DT3Ahwl_.js +1 -0
  102. package/backend/src/flowent/static/assets/roles-CuRT_chR.js +1 -0
  103. package/{dist/frontend/assets/select-D9SwnlXF.js → backend/src/flowent/static/assets/select-DCfeNu-F.js} +1 -1
  104. package/backend/src/flowent/static/assets/surface-pWwG5ogx.js +1 -0
  105. package/backend/src/flowent/static/assets/{ui-vendor-UazN8rcv.js → ui-vendor-C5pJa8N7.js} +15 -15
  106. package/backend/src/flowent/static/assets/useAppRoute-FgSHBKhV.js +1 -0
  107. package/backend/src/flowent/static/index.html +3 -3
  108. package/backend/src/flowent/tools/__init__.py +2 -101
  109. package/backend/src/flowent/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  110. package/backend/src/flowent/tools/__pycache__/connect.cpython-313.pyc +0 -0
  111. package/backend/src/flowent/tools/__pycache__/contacts.cpython-313.pyc +0 -0
  112. package/backend/src/flowent/tools/__pycache__/create_agent.cpython-313.pyc +0 -0
  113. package/backend/src/flowent/tools/__pycache__/create_tab.cpython-313.pyc +0 -0
  114. package/backend/src/flowent/tools/__pycache__/delete_tab.cpython-313.pyc +0 -0
  115. package/backend/src/flowent/tools/__pycache__/edit.cpython-313.pyc +0 -0
  116. package/backend/src/flowent/tools/__pycache__/exec.cpython-313.pyc +0 -0
  117. package/backend/src/flowent/tools/__pycache__/fetch.cpython-313.pyc +0 -0
  118. package/backend/src/flowent/tools/__pycache__/idle.cpython-313.pyc +0 -0
  119. package/backend/src/flowent/tools/__pycache__/list_roles.cpython-313.pyc +0 -0
  120. package/backend/src/flowent/tools/__pycache__/list_tabs.cpython-313.pyc +0 -0
  121. package/backend/src/flowent/tools/__pycache__/list_tools.cpython-313.pyc +0 -0
  122. package/backend/src/flowent/tools/__pycache__/manage_prompts.cpython-313.pyc +0 -0
  123. package/backend/src/flowent/tools/__pycache__/manage_providers.cpython-313.pyc +0 -0
  124. package/backend/src/flowent/tools/__pycache__/manage_roles.cpython-313.pyc +0 -0
  125. package/backend/src/flowent/tools/__pycache__/manage_settings.cpython-313.pyc +0 -0
  126. package/backend/src/flowent/tools/__pycache__/read.cpython-313.pyc +0 -0
  127. package/backend/src/flowent/tools/__pycache__/send.cpython-313.pyc +0 -0
  128. package/backend/src/flowent/tools/__pycache__/set_permissions.cpython-313.pyc +0 -0
  129. package/backend/src/flowent/tools/__pycache__/sleep.cpython-313.pyc +0 -0
  130. package/backend/src/flowent/tools/__pycache__/todo.cpython-313.pyc +0 -0
  131. package/backend/src/flowent/tools/list_roles.py +2 -9
  132. package/backend/src/flowent/tools/manage_settings.py +134 -172
  133. package/backend/tests/__pycache__/__init__.cpython-313.pyc +0 -0
  134. package/backend/tests/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
  135. package/backend/tests/integration/api/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
  136. package/backend/tests/integration/api/__pycache__/test_access_api.cpython-313-pytest-9.0.3.pyc +0 -0
  137. package/backend/tests/integration/api/__pycache__/test_assistant_api.cpython-313-pytest-9.0.3.pyc +0 -0
  138. package/backend/tests/integration/api/__pycache__/test_frontend_mounting.cpython-313-pytest-9.0.3.pyc +0 -0
  139. package/backend/tests/integration/api/__pycache__/test_meta_api.cpython-313-pytest-9.0.3.pyc +0 -0
  140. package/backend/tests/integration/api/__pycache__/test_nodes_api.cpython-313-pytest-9.0.3.pyc +0 -0
  141. package/backend/tests/integration/api/__pycache__/test_prompts_api.cpython-313-pytest-9.0.3.pyc +0 -0
  142. package/backend/tests/integration/api/__pycache__/test_roles_api.cpython-313-pytest-9.0.3.pyc +0 -0
  143. package/backend/tests/integration/api/__pycache__/test_tabs_api.cpython-313-pytest-9.0.3.pyc +0 -0
  144. package/backend/tests/integration/api/test_assistant_api.py +68 -0
  145. package/backend/tests/integration/api/test_meta_api.py +0 -1
  146. package/backend/tests/integration/api/test_nodes_api.py +73 -8
  147. package/backend/tests/integration/api/test_tabs_api.py +0 -114
  148. package/backend/tests/unit/__pycache__/test_access.cpython-313-pytest-9.0.3.pyc +0 -0
  149. package/backend/tests/unit/__pycache__/test_cli.cpython-313-pytest-9.0.3.pyc +0 -0
  150. package/backend/tests/unit/__pycache__/test_graph_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  151. package/backend/tests/unit/__pycache__/test_network.cpython-313-pytest-9.0.3.pyc +0 -0
  152. package/backend/tests/unit/__pycache__/test_state_sqlite_storage.cpython-313-pytest-9.0.3.pyc +0 -0
  153. package/backend/tests/unit/__pycache__/test_workspace_store.cpython-313-pytest-9.0.3.pyc +0 -0
  154. package/backend/tests/unit/agent/__pycache__/test_agent_public_api.cpython-313-pytest-9.0.3.pyc +0 -0
  155. package/backend/tests/unit/agent/__pycache__/test_agent_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  156. package/backend/tests/unit/agent/test_agent_public_api.py +0 -15
  157. package/backend/tests/unit/agent/test_agent_runtime.py +148 -2
  158. package/backend/tests/unit/channels/__pycache__/test_telegram_channel.cpython-313-pytest-9.0.3.pyc +0 -0
  159. package/backend/tests/unit/logging/__pycache__/test_logging.cpython-313-pytest-9.0.3.pyc +0 -0
  160. package/backend/tests/unit/prompts/__pycache__/test_prompts.cpython-313-pytest-9.0.3.pyc +0 -0
  161. package/backend/tests/unit/providers/__pycache__/test_anthropic_provider.cpython-313-pytest-9.0.3.pyc +0 -0
  162. package/backend/tests/unit/providers/__pycache__/test_errors.cpython-313-pytest-9.0.3.pyc +0 -0
  163. package/backend/tests/unit/providers/__pycache__/test_extract_delta_parts.cpython-313-pytest-9.0.3.pyc +0 -0
  164. package/backend/tests/unit/providers/__pycache__/test_openai_provider.cpython-313-pytest-9.0.3.pyc +0 -0
  165. package/backend/tests/unit/providers/__pycache__/test_openai_responses.cpython-313-pytest-9.0.3.pyc +0 -0
  166. package/backend/tests/unit/providers/__pycache__/test_provider_gateway.cpython-313-pytest-9.0.3.pyc +0 -0
  167. package/backend/tests/unit/providers/__pycache__/test_think_tag_parser.cpython-313-pytest-9.0.3.pyc +0 -0
  168. package/backend/tests/unit/routes/__pycache__/test_prompts_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  169. package/backend/tests/unit/routes/__pycache__/test_providers_route.cpython-313-pytest-9.0.3.pyc +0 -0
  170. package/backend/tests/unit/routes/__pycache__/test_roles_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  171. package/backend/tests/unit/routes/__pycache__/test_settings_routes.cpython-313-pytest-9.0.3.pyc +0 -0
  172. package/backend/tests/unit/routes/test_prompts_routes.py +0 -22
  173. package/backend/tests/unit/routes/test_roles_routes.py +6 -2
  174. package/backend/tests/unit/routes/test_settings_routes.py +0 -19
  175. package/backend/tests/unit/runtime/__pycache__/test_bootstrap_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
  176. package/backend/tests/unit/sandbox/__pycache__/test_sandbox_tools.cpython-313-pytest-9.0.3.pyc +0 -0
  177. package/backend/tests/unit/security/__pycache__/test_security.cpython-313-pytest-9.0.3.pyc +0 -0
  178. package/backend/tests/unit/settings/__pycache__/test_settings_roles.cpython-313-pytest-9.0.3.pyc +0 -0
  179. package/backend/tests/unit/settings/test_settings_roles.py +3 -51
  180. package/backend/tests/unit/test_cli.py +0 -22
  181. package/backend/tests/unit/test_state_sqlite_storage.py +27 -99
  182. package/backend/tests/unit/test_workspace_store.py +0 -3
  183. package/backend/tests/unit/tools/__pycache__/test_connect_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  184. package/backend/tests/unit/tools/__pycache__/test_create_agent_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  185. package/backend/tests/unit/tools/__pycache__/test_delete_tab_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  186. package/backend/tests/unit/tools/__pycache__/test_edit_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  187. package/backend/tests/unit/tools/__pycache__/test_exec_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  188. package/backend/tests/unit/tools/__pycache__/test_fetch_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  189. package/backend/tests/unit/tools/__pycache__/test_manage_prompts_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  190. package/backend/tests/unit/tools/__pycache__/test_manage_providers_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  191. package/backend/tests/unit/tools/__pycache__/test_manage_roles_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  192. package/backend/tests/unit/tools/__pycache__/test_manage_settings_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  193. package/backend/tests/unit/tools/__pycache__/test_read_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  194. package/backend/tests/unit/tools/__pycache__/test_set_permissions_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  195. package/backend/tests/unit/tools/__pycache__/test_todo_tool.cpython-313-pytest-9.0.3.pyc +0 -0
  196. package/backend/tests/unit/tools/__pycache__/test_tool_registry.cpython-313-pytest-9.0.3.pyc +0 -0
  197. package/backend/tests/unit/tools/test_create_agent_tool.py +0 -32
  198. package/backend/tests/unit/tools/test_manage_prompts_tool.py +5 -30
  199. package/backend/tests/unit/tools/test_tool_registry.py +45 -40
  200. package/backend/uv.lock +1 -1
  201. package/dist/frontend/assets/AssistantPage-BW7XAd9I.js +1 -0
  202. package/dist/frontend/assets/ChannelsPage-tCJHgt6m.js +1 -0
  203. package/dist/frontend/assets/{PageScaffold-DteOA8V7.js → PageScaffold-f6g2l7XN.js} +1 -1
  204. package/dist/frontend/assets/PromptsPage-C3Sxn2D7.js +1 -0
  205. package/dist/frontend/assets/ProvidersPage-BfmdXmNt.js +3 -0
  206. package/dist/frontend/assets/RolesPage-DET8wO4r.js +1 -0
  207. package/dist/frontend/assets/SettingsPage-D-g3deMm.js +3 -0
  208. package/dist/frontend/assets/ToolsPage-CDmtE2g4.js +1 -0
  209. package/dist/frontend/assets/WorkspacePage-AZsJ0sD0.js +3 -0
  210. package/dist/frontend/assets/WorkspacePanels-CteCjolX.js +1 -0
  211. package/dist/frontend/assets/{alert-dialog-DIBUCmqM.js → alert-dialog-Duorp_S-.js} +1 -1
  212. package/dist/frontend/assets/{dialog-BOvHIBrg.js → dialog-C3ixjGjN.js} +1 -1
  213. package/dist/frontend/assets/index--o_0fv0N.css +1 -0
  214. package/dist/frontend/assets/index-C9HuekJm.js +10 -0
  215. package/dist/frontend/assets/{modelParams-DcEhGnu0.js → modelParams-DmnF2hwR.js} +1 -1
  216. package/dist/frontend/assets/providerTypes-DT3Ahwl_.js +1 -0
  217. package/dist/frontend/assets/roles-CuRT_chR.js +1 -0
  218. package/{backend/src/flowent/static/assets/select-D9SwnlXF.js → dist/frontend/assets/select-DCfeNu-F.js} +1 -1
  219. package/dist/frontend/assets/surface-pWwG5ogx.js +1 -0
  220. package/dist/frontend/assets/{ui-vendor-UazN8rcv.js → ui-vendor-C5pJa8N7.js} +15 -15
  221. package/dist/frontend/assets/useAppRoute-FgSHBKhV.js +1 -0
  222. package/dist/frontend/index.html +3 -3
  223. package/package.json +1 -1
  224. package/backend/src/flowent/__pycache__/mcp_service.cpython-313.pyc +0 -0
  225. package/backend/src/flowent/mcp_service.py +0 -1918
  226. package/backend/src/flowent/routes/__pycache__/mcp.cpython-313.pyc +0 -0
  227. package/backend/src/flowent/routes/mcp.py +0 -125
  228. package/backend/src/flowent/static/assets/AssistantPage-VBohhz4d.js +0 -1
  229. package/backend/src/flowent/static/assets/ChannelsPage-CIydPZA_.js +0 -1
  230. package/backend/src/flowent/static/assets/McpPage-CHPm2TPY.js +0 -7
  231. package/backend/src/flowent/static/assets/PromptsPage-CSmJ3sZg.js +0 -1
  232. package/backend/src/flowent/static/assets/ProvidersPage-sl2jeG4e.js +0 -3
  233. package/backend/src/flowent/static/assets/RolesPage-DCe7W6Km.js +0 -1
  234. package/backend/src/flowent/static/assets/SettingsPage-Bix9e63E.js +0 -3
  235. package/backend/src/flowent/static/assets/ToolsPage-favNkj5C.js +0 -1
  236. package/backend/src/flowent/static/assets/WorkspaceCommandDialog-DRS6wiD6.js +0 -1
  237. package/backend/src/flowent/static/assets/WorkspacePage-KuaDjt_D.js +0 -3
  238. package/backend/src/flowent/static/assets/WorkspacePanels-BZxBw8M5.js +0 -1
  239. package/backend/src/flowent/static/assets/datetime-eJqd0V2S.js +0 -1
  240. package/backend/src/flowent/static/assets/index-Biio-CoI.js +0 -10
  241. package/backend/src/flowent/static/assets/index-CmQvO7sl.css +0 -1
  242. package/backend/src/flowent/static/assets/roles-BbIEIMeG.js +0 -1
  243. package/backend/src/flowent/static/assets/surface-Bzr1FRG4.js +0 -1
  244. package/backend/src/flowent/static/assets/triState-DgLlKdRR.js +0 -1
  245. package/backend/src/flowent/tools/__pycache__/mcp.cpython-313.pyc +0 -0
  246. package/backend/src/flowent/tools/mcp.py +0 -199
  247. package/backend/tests/integration/api/__pycache__/test_mcp_api.cpython-313-pytest-9.0.3.pyc +0 -0
  248. package/backend/tests/integration/api/test_mcp_api.py +0 -116
  249. package/dist/frontend/assets/AssistantPage-VBohhz4d.js +0 -1
  250. package/dist/frontend/assets/ChannelsPage-CIydPZA_.js +0 -1
  251. package/dist/frontend/assets/McpPage-CHPm2TPY.js +0 -7
  252. package/dist/frontend/assets/PromptsPage-CSmJ3sZg.js +0 -1
  253. package/dist/frontend/assets/ProvidersPage-sl2jeG4e.js +0 -3
  254. package/dist/frontend/assets/RolesPage-DCe7W6Km.js +0 -1
  255. package/dist/frontend/assets/SettingsPage-Bix9e63E.js +0 -3
  256. package/dist/frontend/assets/ToolsPage-favNkj5C.js +0 -1
  257. package/dist/frontend/assets/WorkspaceCommandDialog-DRS6wiD6.js +0 -1
  258. package/dist/frontend/assets/WorkspacePage-KuaDjt_D.js +0 -3
  259. package/dist/frontend/assets/WorkspacePanels-BZxBw8M5.js +0 -1
  260. package/dist/frontend/assets/datetime-eJqd0V2S.js +0 -1
  261. package/dist/frontend/assets/index-Biio-CoI.js +0 -10
  262. package/dist/frontend/assets/index-CmQvO7sl.css +0 -1
  263. package/dist/frontend/assets/roles-BbIEIMeG.js +0 -1
  264. package/dist/frontend/assets/surface-Bzr1FRG4.js +0 -1
  265. package/dist/frontend/assets/triState-DgLlKdRR.js +0 -1
@@ -1,199 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import json
4
- from typing import TYPE_CHECKING, Any, ClassVar
5
-
6
- from flowent.mcp_service import MCPToolDescriptor, mcp_service
7
- from flowent.tools import Tool
8
-
9
- if TYPE_CHECKING:
10
- from flowent.agent import Agent
11
-
12
-
13
- class DynamicMCPTool(Tool):
14
- agent_visible = True
15
- llm_visible = True
16
- parameters: ClassVar[dict[str, Any]] = {
17
- "type": "object",
18
- "properties": {},
19
- "required": [],
20
- }
21
-
22
- def __init__(self, descriptor: MCPToolDescriptor) -> None:
23
- self._descriptor = descriptor
24
- self.name = descriptor.fully_qualified_id
25
- self.description = descriptor.description or f"MCP tool {descriptor.tool_name}"
26
- self._parameters = descriptor.input_schema or {
27
- "type": "object",
28
- "properties": {},
29
- "required": [],
30
- }
31
-
32
- def to_schema(self) -> dict[str, Any]:
33
- return {
34
- "type": "function",
35
- "function": {
36
- "name": self.name,
37
- "description": self.description,
38
- "parameters": self._parameters,
39
- },
40
- }
41
-
42
- def execute(self, agent: Agent, args: dict[str, Any], **_kwargs: Any) -> str:
43
- result = mcp_service.call_agent_tool(
44
- agent,
45
- fully_qualified_id=self._descriptor.fully_qualified_id,
46
- arguments=args,
47
- )
48
- return json.dumps(result, ensure_ascii=False)
49
-
50
-
51
- class ListMCPResourcesTool(Tool):
52
- name = "list_mcp_resources"
53
- description = "List MCP resources visible in the current execution boundary."
54
- parameters: ClassVar[dict[str, Any]] = {
55
- "type": "object",
56
- "properties": {
57
- "server_name": {
58
- "type": "string",
59
- "description": "Optional globally available MCP server name filter",
60
- }
61
- },
62
- "required": [],
63
- }
64
-
65
- def execute(self, agent: Agent, args: dict[str, Any], **_kwargs: Any) -> str:
66
- server_name = args.get("server_name")
67
- resources = mcp_service.list_agent_resources(
68
- agent,
69
- server_name=server_name
70
- if isinstance(server_name, str) and server_name.strip()
71
- else None,
72
- )
73
- return json.dumps(resources, ensure_ascii=False)
74
-
75
-
76
- class ListMCPResourceTemplatesTool(Tool):
77
- name = "list_mcp_resource_templates"
78
- description = (
79
- "List MCP resource templates visible in the current execution boundary."
80
- )
81
- parameters: ClassVar[dict[str, Any]] = {
82
- "type": "object",
83
- "properties": {
84
- "server_name": {
85
- "type": "string",
86
- "description": "Optional globally available MCP server name filter",
87
- }
88
- },
89
- "required": [],
90
- }
91
-
92
- def execute(self, agent: Agent, args: dict[str, Any], **_kwargs: Any) -> str:
93
- server_name = args.get("server_name")
94
- templates = mcp_service.list_agent_resource_templates(
95
- agent,
96
- server_name=server_name
97
- if isinstance(server_name, str) and server_name.strip()
98
- else None,
99
- )
100
- return json.dumps(templates, ensure_ascii=False)
101
-
102
-
103
- class ReadMCPResourceTool(Tool):
104
- name = "read_mcp_resource"
105
- description = "Read an MCP resource from a globally available server."
106
- parameters: ClassVar[dict[str, Any]] = {
107
- "type": "object",
108
- "properties": {
109
- "server_name": {
110
- "type": "string",
111
- "description": "Globally available MCP server name",
112
- },
113
- "uri": {
114
- "type": "string",
115
- "description": "Target MCP resource URI",
116
- },
117
- },
118
- "required": ["server_name", "uri"],
119
- }
120
-
121
- def execute(self, agent: Agent, args: dict[str, Any], **_kwargs: Any) -> str:
122
- server_name = args.get("server_name")
123
- uri = args.get("uri")
124
- if not isinstance(server_name, str) or not server_name.strip():
125
- return json.dumps({"error": "server_name is required"})
126
- if not isinstance(uri, str) or not uri.strip():
127
- return json.dumps({"error": "uri is required"})
128
- result = mcp_service.read_agent_resource(
129
- agent,
130
- server_name=server_name.strip(),
131
- uri=uri.strip(),
132
- )
133
- return json.dumps(result, ensure_ascii=False)
134
-
135
-
136
- class ListMCPPromptsTool(Tool):
137
- name = "list_mcp_prompts"
138
- description = "List MCP prompts visible in the current execution boundary."
139
- parameters: ClassVar[dict[str, Any]] = {
140
- "type": "object",
141
- "properties": {
142
- "server_name": {
143
- "type": "string",
144
- "description": "Optional globally available MCP server name filter",
145
- }
146
- },
147
- "required": [],
148
- }
149
-
150
- def execute(self, agent: Agent, args: dict[str, Any], **_kwargs: Any) -> str:
151
- server_name = args.get("server_name")
152
- prompts = mcp_service.list_agent_prompts(
153
- agent,
154
- server_name=server_name
155
- if isinstance(server_name, str) and server_name.strip()
156
- else None,
157
- )
158
- return json.dumps(prompts, ensure_ascii=False)
159
-
160
-
161
- class GetMCPPromptTool(Tool):
162
- name = "get_mcp_prompt"
163
- description = "Get an MCP prompt from a globally available server."
164
- parameters: ClassVar[dict[str, Any]] = {
165
- "type": "object",
166
- "properties": {
167
- "server_name": {
168
- "type": "string",
169
- "description": "Globally available MCP server name",
170
- },
171
- "name": {
172
- "type": "string",
173
- "description": "Prompt name",
174
- },
175
- "arguments": {
176
- "type": "object",
177
- "description": "Optional prompt arguments",
178
- },
179
- },
180
- "required": ["server_name", "name"],
181
- }
182
-
183
- def execute(self, agent: Agent, args: dict[str, Any], **_kwargs: Any) -> str:
184
- server_name = args.get("server_name")
185
- name = args.get("name")
186
- arguments = args.get("arguments")
187
- if not isinstance(server_name, str) or not server_name.strip():
188
- return json.dumps({"error": "server_name is required"})
189
- if not isinstance(name, str) or not name.strip():
190
- return json.dumps({"error": "name is required"})
191
- if arguments is not None and not isinstance(arguments, dict):
192
- return json.dumps({"error": "arguments must be an object"})
193
- result = mcp_service.get_agent_prompt(
194
- agent,
195
- server_name=server_name.strip(),
196
- name=name.strip(),
197
- arguments=arguments if isinstance(arguments, dict) else None,
198
- )
199
- return json.dumps(result, ensure_ascii=False)
@@ -1,116 +0,0 @@
1
- from fastapi.testclient import TestClient
2
-
3
-
4
- def test_mcp_api_returns_only_external_server_state(client: TestClient, monkeypatch):
5
- monkeypatch.setattr(
6
- "flowent.routes.mcp.mcp_service.list_server_payloads",
7
- lambda: [
8
- {
9
- "config": {
10
- "name": "filesystem",
11
- "transport": "stdio",
12
- "enabled": True,
13
- "required": False,
14
- "startup_timeout_sec": 10,
15
- "tool_timeout_sec": 30,
16
- "enabled_tools": [],
17
- "disabled_tools": [],
18
- "scopes": [],
19
- "oauth_resource": "",
20
- "launcher": "",
21
- "command": "npx",
22
- "args": ["-y", "demo-mcp"],
23
- "env": {},
24
- "env_vars": [],
25
- "cwd": "",
26
- "url": "",
27
- "bearer_token_env_var": "",
28
- "http_headers": {},
29
- "env_http_headers": [],
30
- },
31
- "snapshot": {
32
- "server_name": "filesystem",
33
- "transport": "stdio",
34
- "status": "connected",
35
- "auth_status": "unsupported",
36
- "last_auth_result": None,
37
- "last_refresh_at": 1710000000,
38
- "last_refresh_result": "success",
39
- "last_error": None,
40
- "tools": [],
41
- "resources": [],
42
- "resource_templates": [],
43
- "prompts": [],
44
- "capability_counts": {
45
- "tools": 0,
46
- "resources": 0,
47
- "resource_templates": 0,
48
- "prompts": 0,
49
- },
50
- },
51
- "visibility": {
52
- "scope": "global",
53
- "active": True,
54
- },
55
- "activity": [],
56
- }
57
- ],
58
- )
59
-
60
- response = client.get("/api/mcp")
61
-
62
- assert response.status_code == 200
63
- assert response.json() == {
64
- "servers": [
65
- {
66
- "config": {
67
- "name": "filesystem",
68
- "transport": "stdio",
69
- "enabled": True,
70
- "required": False,
71
- "startup_timeout_sec": 10,
72
- "tool_timeout_sec": 30,
73
- "enabled_tools": [],
74
- "disabled_tools": [],
75
- "scopes": [],
76
- "oauth_resource": "",
77
- "launcher": "",
78
- "command": "npx",
79
- "args": ["-y", "demo-mcp"],
80
- "env": {},
81
- "env_vars": [],
82
- "cwd": "",
83
- "url": "",
84
- "bearer_token_env_var": "",
85
- "http_headers": {},
86
- "env_http_headers": [],
87
- },
88
- "snapshot": {
89
- "server_name": "filesystem",
90
- "transport": "stdio",
91
- "status": "connected",
92
- "auth_status": "unsupported",
93
- "last_auth_result": None,
94
- "last_refresh_at": 1710000000,
95
- "last_refresh_result": "success",
96
- "last_error": None,
97
- "tools": [],
98
- "resources": [],
99
- "resource_templates": [],
100
- "prompts": [],
101
- "capability_counts": {
102
- "tools": 0,
103
- "resources": 0,
104
- "resource_templates": 0,
105
- "prompts": 0,
106
- },
107
- },
108
- "visibility": {
109
- "scope": "global",
110
- "active": True,
111
- },
112
- "activity": [],
113
- }
114
- ],
115
- }
116
- assert "flowent_server" not in response.json()
@@ -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{q as r}from"./ui-vendor-UazN8rcv.js";import{A as i,C as a,D as o,E as s,M as c,N as l,O as u,S as d,T as ee,_ as te,b as ne,g as re,h as ie,j as ae,k as oe,m as f,t as p,v as se,w as ce,x as m,y as le}from"./WorkspacePanels-BZxBw8M5.js";import{B as h,L as g,P as ue,R as _,S as v,b as y,g as b,h as x,m as de,p as fe,rt as S,tt as C,x as pe}from"./index-Biio-CoI.js";async function me(e){return h(`/api/assistant/message`,{method:`POST`,body:e,errorMessage:`Failed to send Assistant message`})}async function he(e){return h(`/api/assistant/messages/${e}/retry`,{method:`POST`,errorMessage:`Failed to retry Assistant message`})}var w=e(t(),1);function T(e){for(let t of e.values())if(t.node_type===`assistant`)return t;return null}function ge(e){return T(e)?.id??null}var E=`assistant`;function _e(){return s(E)}function ve(e){return o(E,e)}function ye(e){ee(E,e)}function D(e={}){let{bottomInset:t=0}=e,{agents:n}=b(),{connected:i}=de(),{agentHistories:o,clearAgentHistory:s,clearHistorySnapshot:c,historyInvalidatedAt:ee,historyClearedAt:ae,historySnapshots:p,streamingDeltas:h}=x(),{activeToolCalls:S}=fe(),[C,T]=(0,w.useState)(null),[E,D]=(0,w.useState)(0),[O,k]=(0,w.useState)(``),[A,j]=(0,w.useState)([]),[M,N]=(0,w.useState)(null),[be,xe]=(0,w.useState)(!1),[Se,Ce]=(0,w.useState)(null),[P,we]=(0,w.useState)(!1),[F,I]=(0,w.useState)([]),[L,R]=(0,w.useState)(null),z=(0,w.useRef)(null),B=(0,w.useRef)(!0),Te=(0,w.useRef)([]),V=(0,w.useRef)(null),H=(0,w.useRef)(!1),U=(0,w.useMemo)(()=>ge(n),[n]),W=(0,w.useMemo)(()=>U?n.get(U)??null:null,[n,U]),Ee=W?.capabilities?.input_image??!1,De=U?ae.get(U)??0:0,Oe=U?ee.get(U)??0:0,G=U?p.get(U)??null:null,ke=A.some(e=>e.status===`uploading`),Ae=A.filter(le),K=(0,w.useSyncExternalStore)(ve,_e,_e),q=M===null?null:K[M]??null,je=q!==null&&O===q.text&&se(A,q),J=W?.state??C?.state??null,Me=(0,w.useCallback)(async e=>{let t=e.pendingMessageTimestamp??Date.now(),n=ie(e.content,e.parts,t);we(!0),I(e=>[...e,n]);try{let n=await me({content:e.content,parts:e.parts});return n.status===`command_executed`?I(n=>y(n,{content:e.content,timestamp:t})):n.message_id&&I(r=>r.map(r=>r.timestamp===t&&r.content===e.content?{...r,message_id:n.message_id}:r)),ye(e.history),e.restoreDraft&&d(e.restoreDraft.images),!0}catch(n){return I(n=>y(n,{content:e.content,timestamp:t})),e.restoreDraft&&(k(e.restoreDraft.input),j(e.restoreDraft.images),N(e.restoreDraft.historyCursor)),r.error(n instanceof Error?n.message:`Failed to send message`),!1}finally{we(!1)}},[]),Y=(0,w.useCallback)((e,t)=>{N(t),k(e?.text??``),j(e?a(e):[])},[]),Ne=(0,w.useCallback)(e=>{N(null),k(e)},[]);(0,w.useEffect)(()=>{Te.current=A},[A]),(0,w.useEffect)(()=>{V.current=L},[L]),(0,w.useEffect)(()=>()=>{d(Te.current)},[]),(0,w.useEffect)(()=>{De&&(I([]),R(null),T(e=>e&&{...e,history:u(e.history)}),D(Date.now()))},[De]),(0,w.useEffect)(()=>{Oe&&(I([]),G&&(T(e=>e&&{...e,history:G}),D(Date.now())))},[Oe,G]),(0,w.useEffect)(()=>{let e=V.current;!e||e.send_failed||e.target_id!==U||J!==e.target_state&&R({...e,target_state:J})},[U,J]),(0,w.useEffect)(()=>{let e=V.current;!e||e.send_failed||!U||e.target_id!==U||J!==`idle`||P||H.current||(H.current=!0,R(null),Me({content:e.content,parts:e.parts??[],history:e.history_entry,pendingMessageTimestamp:e.timestamp}).then(t=>{H.current=!1,t||R({...e,send_failed:!0,target_state:`error`})}).catch(()=>{H.current=!1,R({...e,send_failed:!0,target_state:`error`})}))},[U,J,P,Me]),(0,w.useEffect)(()=>{if(!i||!U){T(null);return}let e=new AbortController,t=!1;return(async()=>{s(U);try{let n=await g(U,e.signal);if(t||!n)return;T(n),D(Date.now()),c(U)}catch{!t&&!e.signal.aborted&&r.error(`Failed to load Assistant history`)}})(),()=>{t=!0,e.abort()}},[De,Oe,U,s,c,i]);let X=(0,w.useMemo)(()=>U?oe({history:G??C?.history??[],incremental:o.get(U),deltas:h.get(U),fetchedAt:E||Date.now()}):[],[o,G,C,E,h,U]);(0,w.useEffect)(()=>{if(!U||F.length===0)return;let e=X.filter(e=>e.type===`ReceivedMessage`&&e.from_id===`human`&&(!!e.content||!!e.message_id||!!e.parts?.length));e.length!==0&&I(t=>e.reduce((e,t)=>y(e,{content:t.content??pe(t.parts,t.content),messageId:t.message_id}),t))},[U,X,F.length]);let Z=(0,w.useMemo)(()=>[...X,...L?[{...L}]:[],...F.map(e=>({...e}))],[X,F,L]),Q=(0,w.useMemo)(()=>{let e=F.length+ +!!L,t=U?h.get(U)??[]:[],n=i&&(e>0||W?.state===`running`||W?.state===`sleeping`||S.has(U??``)||t.length>0),r=[...Z].map((e,t)=>({item:e,index:t})).reverse().find(({item:e})=>e.type===`PendingHumanMessage`?!0:e.type===`ReceivedMessage`&&e.from_id===`human`&&v(e.parts,e.content).length>0)?.index,a=r===void 0?[]:Z.slice(r+1),o=a.some(e=>e.type===`AssistantText`&&v(e.parts,e.content).length>0),s=[...a].reverse().find(e=>e.type===`ToolCall`&&e.streaming===!0),c=(U?S.get(U)??null:null)??s?.tool_name??null;return{running:n,runningHint:n&&r!==void 0&&!o?{label:c?`Running tools...`:`Thinking...`,toolName:c}:null}},[S,U,W?.state,i,F.length,L,h,Z]);(0,w.useLayoutEffect)(()=>{let e=z.current;!e||!B.current||(e.scrollTop=e.scrollHeight)},[t,Q.runningHint?`${Q.runningHint.label}:${Q.runningHint.toolName??``}`:``,Z]),(0,w.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 Pe=e=>{B.current=ne(e.currentTarget)},$=async(e={})=>{let t=O.trim();if(!t&&Ae.length===0||ke||P)return;let n=f(t,Ae),i=O,a=A,o=M,s=Date.now(),c=t||pe(n),l={text:i,images:ce(a),timestamp:s},u=e.deferWhenBusy&&U&&V.current?.target_id===U&&(J===`error`||J===`terminated`);if(e.deferWhenBusy&&U&&(J===`running`||J===`sleeping`||u)){R(re({content:c,historyEntry:l,historyScope:`assistant`,parts:n,targetId:U,targetState:J,timestamp:s})),N(null),k(``),j([]),d(a);return}if(J===`error`||J===`terminated`){r.error(`Resolve the current chat before sending`);return}N(null),k(``),j([]),await Me({content:c,parts:n,history:l,pendingMessageTimestamp:s,restoreDraft:{input:i,images:a,historyCursor:o}})},Fe=(0,w.useCallback)(async e=>{if(N(null),!Ee){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 te(t);j(e=>[...e,...n]),await Promise.all(n.map(async(e,n)=>{let i=t[n];if(i)try{let t=await l(i);j(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){m(e),j(t=>t.filter(t=>t.id!==e.id)),r.error(t instanceof Error?t.message:`Failed to upload image`)}}))},[Ee]),Ie=(0,w.useCallback)(e=>{N(null),j(t=>{let n=t.find(t=>t.id===e);return n&&m(n),t.filter(t=>t.id!==e)})},[]),Le=(0,w.useCallback)((e,t)=>{if(K.length===0)return!1;let n=t.start,r=t.end,i=O.length===0&&A.length===0,a=typeof n==`number`&&typeof r==`number`&&n===r&&(n===0||n===O.length);if(!i&&!(q!==null&&je&&a))return!1;if(M===null){if(e!==-1)return!1;let t=K.length-1;return Y(K[t]??null,t),!0}if(e===-1){let e=Math.max(M-1,0);return Y(K[e]??null,e),!0}if(M>=K.length-1)return Y(null,null),!0;let o=M+1;return Y(K[o]??null,o),!0},[q,A,M,O,K,je,Y]),Re=async()=>{if(!(!U||be)){xe(!0);try{await ue(U),I([]),R(null),s(U),T(await g(U)),D(Date.now()),c(U)}catch(e){r.error(e instanceof Error?e.message:`Failed to clear assistant chat`)}finally{xe(!1)}}},ze=(0,w.useCallback)(async()=>{if(U&&!(W?.state!==`running`&&W?.state!==`sleeping`)){await _(U);for(let e=0;e<25;e+=1){let e=await g(U);if(!e)break;if(T(e),D(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`)}},[U,W?.state]),Be=async e=>{if(!(!U||!e||Se)){Ce(e);try{try{await ze(),await he(e)}catch(e){r.error(e instanceof Error?e.message:`Failed to retry Assistant message`);return}s(U);try{let e=await g(U);e&&(T(e),D(Date.now()),c(U))}catch{return}}finally{Ce(null)}}},Ve=(0,w.useCallback)(async()=>{if(!U)return;await _(U),I([]),s(U);let e=await g(U);e&&(T(e),D(Date.now()),c(U))},[U,s,c]);return{addImages:Fe,connected:i,draftImages:A,handleKeyDown:e=>{if(e.key===`Tab`&&!e.shiftKey){(O.trim()||Ae.length>0)&&(e.preventDefault(),$({deferWhenBusy:!0}));return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$())},hasUploadingImages:ke,input:O,isBrowsingInputHistory:je,navigateInputHistory:Le,onMessagesScroll:Pe,removeImage:Ie,retryMessage:Be,retryingMessageId:Se,scrollRef:z,clearing:be,sending:P,clearChat:Re,cancelPendingSend:(0,w.useCallback)(e=>{R(t=>t?.id===e?null:t)},[]),sendMessage:$,setInput:Ne,stopAssistant:Ve,supportsInputImage:Ee,timelineItems:Z,assistantActivity:Q}}var O=n();function k({onOpenDetails:e}){let{agents:t}=b(),[n,a]=(0,w.useState)(!1),{height:o,ref:s}=i(),{addImages:l=async()=>{},assistantActivity:u={running:!1,runningHint:null},clearChat:d,cancelPendingSend:ee,clearing:te=!1,connected:ne,draftImages:re=[],handleKeyDown:ie,hasUploadingImages:oe=!1,input:f,isBrowsingInputHistory:p,navigateInputHistory:se,onMessagesScroll:ce,removeImage:m=()=>{},retryMessage:le,retryingMessageId:h,scrollRef:g,sending:ue,sendMessage:_,setInput:v,stopAssistant:y,supportsInputImage:x=!1,timelineItems:de}=D({bottomInset:o}),fe=Array.from(t.values()).find(e=>e.node_type===`assistant`)?.role_name??null;return(0,O.jsxs)(`div`,{className:S(`relative flex h-full flex-col overflow-hidden bg-surface-overlay text-foreground`),children:[(0,O.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,O.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,O.jsx)(`div`,{"aria-hidden":`true`,className:S(`pointer-events-none absolute inset-0 z-20 border transition-[opacity,border-color,box-shadow] duration-300`,u.running?`animate-pulse shadow-lg shadow-ring/5`:`opacity-0`,u.running&&`border-ring/25 opacity-100 shadow-ring/10`)}),(0,O.jsx)(A,{connected:ne,onClearChat:()=>void d(),onOpenDetails:e,roleName:fe,clearing:te}),(0,O.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,O.jsx)(ae,{allowHumanMessageRetry:!0,bottomInset:o,items:de,nodes:t,onRetryHumanMessage:e=>void le(e),onCancelPendingSend:ee,onScroll:ce,retryImageInputEnabled:x,retryingMessageId:h,runningHint:u.runningHint,scrollRef:g}),(0,O.jsx)(`div`,{ref:s,style:{paddingBottom:`calc(10px + env(safe-area-inset-bottom, 0px))`},className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-b from-transparent via-background/70 to-background/95 px-2.5 pt-8`,children:(0,O.jsx)(`div`,{className:`mx-auto w-full max-w-3xl`,children:(0,O.jsx)(c,{busy:u.running,disabled:!f.trim()&&re.length===0||oe||ue,commandsEnabled:!0,images:re,imageInputEnabled:x,input:f,onAddImages:e=>void l(e),onChange:v,onNavigateHistory:se,onKeyDown:ie,onRemoveImage:m,onSend:()=>void _(),onStop:()=>{a(!0),y().catch(e=>{r.error(e instanceof Error?e.message:`Failed to stop Assistant`)}).finally(()=>{a(!1)})},overlay:!0,stopping:n,suppressCommandNavigation:p,targetLabel:`Assistant`})})})]})]})}function A({clearing:e,connected:t,onClearChat:n,onOpenDetails:r,roleName:i}){return(0,O.jsxs)(`div`,{className:`relative z-10 flex flex-wrap items-center gap-2.5 border-b border-border px-3.5 py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-[220px] flex-1 items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`shrink-0 text-[14px] font-semibold leading-6 text-foreground`,children:`Assistant`}),i?(0,O.jsxs)(`span`,{className:`min-w-0 truncate rounded-full border border-border bg-accent/35 px-2 py-0.5 text-[10px] font-medium leading-4 text-muted-foreground/78`,children:[`Role: `,i]}):null,(0,O.jsx)(j,{connected:t})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(C,{type:`button`,size:`sm`,variant:`outline`,disabled:e,onClick:n,children:e?`Clearing...`:`Clear Chat`}),(0,O.jsx)(C,{type:`button`,size:`sm`,variant:`outline`,disabled:!r,onClick:r,children:`Assistant Details`})]})]})}function j({connected:e}){return(0,O.jsx)(`span`,{className:S(`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 M(){let{agents:e}=b(),t=T(e),[n,r]=(0,w.useState)(!1);return(0,O.jsx)(`div`,{className:`flex h-full flex-col min-h-0`,children:n&&t?(0,O.jsx)(`div`,{className:`h-full overflow-hidden p-6`,children:(0,O.jsx)(`div`,{className:`h-full overflow-hidden rounded-xl border border-border bg-surface-overlay/90 shadow-md`,children:(0,O.jsx)(p,{agent:t,onClose:()=>r(!1)})})}):(0,O.jsx)(k,{onOpenDetails:t?()=>r(!0):void 0})})}export{M 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{dt as r,nn as i,q as a,tt as o}from"./ui-vendor-UazN8rcv.js";import{B as s,J as c,s as l,tt as u}from"./index-Biio-CoI.js";import{l as d,s as f}from"./surface-Bzr1FRG4.js";import{c as p,n as m,r as h,s as g}from"./PageScaffold-DteOA8V7.js";import{t as _}from"./datetime-eJqd0V2S.js";async function v(){return s(`/api/settings/telegram`,{errorMessage:`Failed to fetch Telegram settings`})}async function y(e){return s(`/api/settings/telegram`,{method:`PATCH`,body:e,errorMessage:`Failed to save Telegram settings`})}async function b(e){return s(`/api/settings/telegram/approve/${e}`,{method:`POST`,errorMessage:`Failed to approve Telegram chat`})}async function x(e){return s(`/api/settings/telegram/pending/${e}`,{method:`DELETE`,errorMessage:`Failed to remove pending Telegram chat`})}async function S(e){return s(`/api/settings/telegram/chat/${e}`,{method:`DELETE`,errorMessage:`Failed to remove Telegram chat`})}var C=e(t(),1),w=n();function T(e){return e?_(e,{fallback:`—`,unit:`seconds`}):`—`}function E(e){return e.display_name.trim()?e.display_name.trim():e.username?.trim()?`@${e.username.trim()}`:`Unknown chat`}function D(){let{data:e,isLoading:t,mutate:n}=p(`telegramSettings`,v),[s,_]=(0,C.useState)(!1),[D,O]=(0,C.useState)(``),[k,A]=(0,C.useState)(!1),j=(0,C.useMemo)(()=>!!e?.bot_token,[e?.bot_token]),M=async()=>{if(e){_(!0);try{let e={};k&&(e.bot_token=D.trim()),n((await y(e)).telegram,!1),O(``),A(!1),a.success(`Telegram settings saved`)}catch{a.error(`Failed to save Telegram settings`)}finally{_(!1)}}},N=async e=>{try{n((await b(e)).telegram,!1),a.success(`Telegram chat approved`)}catch{a.error(`Failed to approve Telegram chat`)}},P=async e=>{try{n((await x(e)).telegram,!1),a.success(`Pending Telegram chat removed`)}catch{a.error(`Failed to remove pending Telegram chat`)}},F=async e=>{try{n((await S(e)).telegram,!1),a.success(`Approved Telegram chat removed`)}catch{a.error(`Failed to remove approved Telegram chat`)}};return t||!e?(0,w.jsx)(l,{label:`Loading channels...`,textClassName:`text-[13px]`}):(0,w.jsx)(m,{children:(0,w.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none pt-6`,children:(0,w.jsxs)(`div`,{className:`mx-auto max-w-[680px] pb-10`,children:[(0,w.jsx)(h,{title:`Channels`}),(0,w.jsxs)(g,{className:`mt-6 space-y-8`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,w.jsx)(`div`,{children:(0,w.jsx)(`h2`,{className:`text-lg font-medium text-foreground`,children:`Telegram`})}),(0,w.jsx)(d,{tone:j?`running`:`idle`,children:j?`Configured`:`Not configured`})]}),(0,w.jsxs)(`section`,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Bot Token`}),(0,w.jsx)(d,{tone:j?`running`:`idle`,children:j?`Saved`:`Missing`})]}),(0,w.jsxs)(`div`,{className:`mt-3`,children:[(0,w.jsx)(c,{value:D,onChange:e=>{O(e.target.value),A(!0)},placeholder:e.bot_token||`Enter Telegram bot token`,mono:!0,showLabel:`Show Telegram bot token`,hideLabel:`Hide Telegram bot token`}),j&&!k?(0,w.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:`Leave empty to keep the current token.`}):null]})]}),(0,w.jsxs)(`section`,{className:`border-t border-border pt-8`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Pending Private Chats`}),(0,w.jsxs)(d,{tone:`muted`,className:`px-2 py-0.5`,children:[e.pending_chats.length,` waiting`]})]}),e.pending_chats.length===0?(0,w.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`No pending chats.`}):(0,w.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.pending_chats.map(e=>(0,w.jsx)(f,{as:`div`,padding:`sm`,className:`px-4 py-3.5 transition-colors hover:bg-accent/20`,children:(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:E(e)}),(0,w.jsxs)(`div`,{className:`mt-1 flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`font-mono`,children:[`ID: `,e.chat_id]}),e.username?(0,w.jsxs)(`span`,{children:[`@`,e.username]}):null,(0,w.jsxs)(`span`,{children:[`First seen: `,T(e.first_seen_at)]})]})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,w.jsxs)(u,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>void N(e.chat_id),children:[(0,w.jsx)(i,{className:`size-3.5`}),`Approve`]}),(0,w.jsx)(u,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void P(e.chat_id),className:`text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,w.jsx)(o,{className:`size-3.5`})})]})]})},e.chat_id))})]}),(0,w.jsxs)(`section`,{className:`border-t border-border pt-8`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Approved Private Chats`}),(0,w.jsxs)(d,{tone:`muted`,className:`px-2 py-0.5`,children:[e.approved_chats.length,` active`]})]}),e.approved_chats.length===0?(0,w.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`No approved chats yet.`}):(0,w.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.approved_chats.map(e=>(0,w.jsx)(f,{as:`div`,padding:`sm`,className:`group px-4 py-3.5 transition-colors hover:bg-accent/20`,children:(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:E(e)}),(0,w.jsxs)(`div`,{className:`mt-1 flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`font-mono`,children:[`ID: `,e.chat_id]}),e.username?(0,w.jsxs)(`span`,{children:[`@`,e.username]}):null,(0,w.jsxs)(`span`,{children:[`Approved: `,T(e.approved_at)]})]})]}),(0,w.jsx)(u,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void F(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,w.jsx)(o,{className:`size-3.5`})})]})},e.chat_id))})]}),(0,w.jsx)(`div`,{className:`flex justify-end border-t border-border pt-6`,children:(0,w.jsxs)(u,{type:`button`,size:`sm`,onClick:()=>void M(),disabled:s,className:`text-[13px]`,children:[(0,w.jsx)(r,{className:`size-4`}),s?`Saving...`:`Save Changes`]})})]})]})})})}export{D as ChannelsPage};
@@ -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{$ as r,J as i,_t as a,pt as ee,q as o,ut as s}from"./ui-vendor-UazN8rcv.js";import{$ as c,B as l,K as u,V as d,et as f,rt as p,tt as m}from"./index-Biio-CoI.js";import{a as h,c as te,l as g,o as _,r as v,s as y,t as b,u as ne}from"./surface-Bzr1FRG4.js";import{c as re,n as x,r as ie,s as S}from"./PageScaffold-DteOA8V7.js";import{t as C}from"./datetime-eJqd0V2S.js";import{a as ae,i as w,n as oe,r as T,t as se}from"./select-D9SwnlXF.js";import{n as E,t as ce}from"./WorkspaceCommandDialog-DRS6wiD6.js";async function le(){return l(`/api/mcp`,{method:`GET`,errorMessage:`Failed to fetch MCP state`})}async function ue(){return l(`/api/mcp/refresh`,{method:`POST`,errorMessage:`Failed to refresh MCP servers`,fallback:[],map:e=>e?.servers??[]})}async function de(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 fe(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 pe(e){await d(`/api/mcp/servers/${e}`,{method:`DELETE`,errorMessage:`Failed to delete MCP server`})}async function me(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 he(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 ge(e){await d(`/api/mcp/servers/${e}/logout`,{method:`POST`,errorMessage:`Failed to logout MCP server`})}async function _e(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 D=n(),ve=`border-border/70 bg-background/45 hover:border-ring/35 hover:bg-accent/65`;function O(e){return e.split(`
2
- `).map(e=>e.trim()).filter(Boolean)}function k(e){return e.join(`
3
- `)}function ye(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 A(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`
5
- `)}function j({checked:e,disabled:t,label:n,onChange:r}){return(0,D.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,D.jsx)(`span`,{className:`text-foreground/85`,children:n}),(0,D.jsx)(u,{checked:e,disabled:t,label:n,onCheckedChange:r})]})}function be({draft:e,onChange:t,onOpenChange:n,onSubmit:r,open:i,pending:a,title:ee}){return(0,D.jsxs)(ce,{open:i,onOpenChange:n,title:ee,footer:(0,D.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-3`,children:[(0,D.jsx)(m,{type:`button`,variant:`outline`,className:ve,onClick:()=>n(!1),children:`Cancel`}),(0,D.jsx)(m,{type:`button`,disabled:a,onClick:r,children:a?`Saving...`:`Save Server`})]}),className:`max-w-3xl`,children:[(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`Name`,children:(0,D.jsx)(f,{value:e.name,onChange:n=>t({...e,name:n.target.value}),placeholder:`filesystem`})}),(0,D.jsx)(E,{label:`Transport`,children:(0,D.jsxs)(se,{value:e.transport,onValueChange:n=>t({...e,transport:n}),children:[(0,D.jsx)(w,{className:`h-8 w-full rounded-md bg-background/50 text-sm text-foreground`,children:(0,D.jsx)(ae,{placeholder:`Select transport`})}),(0,D.jsxs)(oe,{className:`rounded-xl bg-popover text-popover-foreground`,children:[(0,D.jsx)(T,{value:`stdio`,children:`stdio`}),(0,D.jsx)(T,{value:`streamable_http`,children:`streamable_http`})]})]})})]}),(0,D.jsx)(E,{label:`Launcher Command`,hint:`optional`,children:(0,D.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,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(j,{checked:e.enabled,label:`Enabled`,onChange:n=>t({...e,enabled:n})}),(0,D.jsx)(j,{checked:e.required,label:`Required`,onChange:n=>t({...e,required:n})})]}),(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`Startup Timeout`,hint:`seconds`,children:(0,D.jsx)(f,{type:`number`,value:String(e.startup_timeout_sec),onChange:n=>t({...e,startup_timeout_sec:Number(n.target.value)||10})})}),(0,D.jsx)(E,{label:`Tool Timeout`,hint:`seconds`,children:(0,D.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,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(E,{label:`Command`,children:(0,D.jsx)(f,{value:e.command,onChange:n=>t({...e,command:n.target.value}),placeholder:`npx`})}),(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`Args`,hint:`one per line`,children:(0,D.jsx)(c,{rows:5,value:k(e.args),onChange:n=>t({...e,args:O(n.target.value)})})}),(0,D.jsx)(E,{label:`Env Vars`,hint:`one env var name per line`,children:(0,D.jsx)(c,{rows:5,value:k(e.env_vars),onChange:n=>t({...e,env_vars:O(n.target.value)})})})]}),(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`Env`,hint:`KEY: value`,children:(0,D.jsx)(c,{rows:5,value:A(e.env),onChange:n=>t({...e,env:ye(n.target.value)})})}),(0,D.jsx)(E,{label:`Cwd`,children:(0,D.jsx)(f,{value:e.cwd,onChange:n=>t({...e,cwd:n.target.value}),placeholder:`/workspace/tools`})})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(E,{label:`URL`,children:(0,D.jsx)(f,{value:e.url,onChange:n=>t({...e,url:n.target.value}),placeholder:`https://mcp.example.com`})}),(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`Bearer Token Env Var`,children:(0,D.jsx)(f,{value:e.bearer_token_env_var,onChange:n=>t({...e,bearer_token_env_var:n.target.value}),placeholder:`MCP_TOKEN`})}),(0,D.jsx)(E,{label:`OAuth Resource`,children:(0,D.jsx)(f,{value:e.oauth_resource,onChange:n=>t({...e,oauth_resource:n.target.value}),placeholder:`https://mcp.example.com`})})]}),(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`HTTP Headers`,hint:`Header: value`,children:(0,D.jsx)(c,{rows:5,value:A(e.http_headers),onChange:n=>t({...e,http_headers:ye(n.target.value)})})}),(0,D.jsx)(E,{label:`Env HTTP Headers`,hint:`one env var name per line`,children:(0,D.jsx)(c,{rows:5,value:k(e.env_http_headers),onChange:n=>t({...e,env_http_headers:O(n.target.value)})})})]}),(0,D.jsx)(E,{label:`Scopes`,hint:`one scope per line`,children:(0,D.jsx)(c,{rows:4,value:k(e.scopes),onChange:n=>t({...e,scopes:O(n.target.value)})})})]}),(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(E,{label:`Enabled Tools`,hint:`one raw tool name per line`,children:(0,D.jsx)(c,{rows:4,value:k(e.enabled_tools),onChange:n=>t({...e,enabled_tools:O(n.target.value)})})}),(0,D.jsx)(E,{label:`Disabled Tools`,hint:`one raw tool name per line`,children:(0,D.jsx)(c,{rows:4,value:k(e.disabled_tools),onChange:n=>t({...e,disabled_tools:O(n.target.value)})})})]})]})}var M=e(t(),1),N=[`overview`,`capabilities`,`activity`],P=[`tools`,`resources`,`resource_templates`,`prompts`],F=[{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`}],I=[{value:`all`,label:`All`},{value:`refresh`,label:`Refresh`},{value:`auth`,label:`Auth`},{value:`tool`,label:`Tool`},{value:`resource`,label:`Resource`},{value:`prompt`,label:`Prompt`}],L={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 R(e){return C(e,{fallback:`Never`})}function z(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function B(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 z(e)}}function xe(e){return C(e,{fallback:`Never`,format:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}})}function V(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 H(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 Se(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 Ce(e){let t=e.snapshot.capability_counts;return`${t.tools} tools · ${t.resources} resources · ${t.prompts} prompts`}function U(e){return e.visibility.active?`Global`:null}function we(e){return e.length<2?e:e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1):e}function Te(e){return(e.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>we(e))}function W(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function Ee(e){return W((e.startsWith(`@`)?e.replace(/@[^/@]+$/u,``):e.replace(/@[^/]+$/u,``)).split(`/`).filter(Boolean).join(`-`))}function De(e){try{let t=new URL(e);return W(t.hostname.replace(/^www\./u,``).split(`.`).filter(e=>e&&![`mcp`,`api`].includes(e))[0]??t.hostname)}catch{return``}}function Oe(e,t){if(/^https?:\/\//u.test(e))return De(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=Ee(i);if(e)return e}return n?W(n.split(`/`).pop()??n):``}function ke(e,t){let n=e.trim(),r=W(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:{...L,name:r,transport:`streamable_http`,launcher:n,url:e},error:null}}catch{return{draft:null,error:`Quick Add URL is not valid.`}}let i=Te(n);return i.length===0?{draft:null,error:`Quick Add needs a single-line launcher command.`}:{draft:{...L,name:r,transport:`stdio`,launcher:n,command:i[0],args:i.slice(1)},error:null}}function Ae(e){return e.config.transport===`streamable_http`?e.config.url.trim()||`No URL configured`:[e.config.command,...e.config.args].filter(Boolean).join(` `)}function je(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 Me(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 Ne(e){return e.config.transport===`stdio`?`Auth N/A`:e.snapshot.auth_status===`connected`?`Logout`:`Login`}function Pe(e){return e.config.transport===`stdio`}function G(e,t=`Not set`){return typeof e==`string`&&e.trim()||t}function K(e,t=`None`){return e.length===0?t:e.join(`
6
- `)}function Fe(e,t=`None`){let n=Object.keys(e);return n.length===0?t:n.join(`
7
- `)}function Ie(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 Le(e){if(Ie(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 Re(e){switch(Le(e)){case`refresh`:return`Refresh`;case`auth`:return`Auth`;case`tool`:return`Tool`;case`resource`:return`Resource`;case`prompt`:return`Prompt`;default:return z(e.action)}}function ze(e,t){return!(t!==`all`&&e.snapshot.status!==t)}function Be(e,t=`Not set`){return e.trim()?e:t}function Ve(e){return Object.fromEntries((e?.arguments??[]).map(e=>e.name).filter(e=>typeof e==`string`&&e.length>0).map(e=>[e,``]))}function He(){let{data:e,error:t,isLoading:n,mutate:r}=re(`mcp-state`,le),[i,a]=(0,M.useState)(null),[ee,s]=(0,M.useState)(`overview`),[c,l]=(0,M.useState)(`tools`),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null),[m,h]=(0,M.useState)(L),[te,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(null),[y,b]=(0,M.useState)(null),[ne,x]=(0,M.useState)(!1),[ie,S]=(0,M.useState)(`{}`),[C,ae]=(0,M.useState)(`all`),[w,oe]=(0,M.useState)(`all`),[T,se]=(0,M.useState)(``),[E,ce]=(0,M.useState)(``),[D,ve]=(0,M.useState)(!1),[O,k]=(0,M.useState)(!1),[ye,A]=(0,M.useState)(null),j=(0,M.useMemo)(()=>Te(T.trim()),[T]),be=(0,M.useMemo)(()=>Oe(T.trim(),j),[T,j]),N=D?E:be,P=(0,M.useMemo)(()=>ke(T,N),[T,N]),F=(0,M.useMemo)(()=>{let t=e?.servers??[];return!O||P.draft===null||t.some(e=>e.config.name===P.draft?.name)?t:[je(P.draft),...t]},[e,P.draft,O]),I=(0,M.useMemo)(()=>F.filter(e=>ze(e,C)),[C,F]),R=(0,M.useMemo)(()=>I.find(e=>e.config.name===i)??I[0]??null,[I,i]);(0,M.useEffect)(()=>{I.length>0&&!I.some(e=>e.config.name===i)&&a(I[0]?.config.name??null)},[I,i]),(0,M.useEffect)(()=>{v(null),b(null),x(!1),S(`{}`),oe(`all`)},[R?.config.name]),(0,M.useEffect)(()=>{D||ce(be)},[D,be]);let z=(0,M.useMemo)(()=>({configured:F.length,connected:F.filter(e=>e.snapshot.status===`connected`).length,authRequired:F.filter(e=>e.snapshot.status===`auth_required`).length,error:F.filter(e=>e.snapshot.status===`error`).length}),[F]),B=(0,M.useMemo)(()=>R?.snapshot.prompts.find(e=>e.name===_)??null,[_,R]),xe=(0,M.useMemo)(()=>R?R.activity.filter(e=>w===`all`?!0:Le(e)===w):[],[w,R]),V=()=>{p(null),h(L),d(!0)},H=e=>{p(e.config.name),h(e.config),d(!0)},Se=e=>{se(e),A(null)},Ce=e=>{ve(!0),ce(e),A(null)},U=()=>{document.getElementById(`mcp-quick-add-input`)?.focus()},we=()=>{ae(`all`)},W=async()=>{try{await ue(),await r(),o.success(`MCP servers refreshed`)}catch(e){o.error(e instanceof Error?e.message:`Failed to refresh MCP servers`)}},Ee=async()=>{g(!0);try{f?await fe(f,m):await de(m),await r(),a(m.name.trim()),d(!1),o.success(`MCP server saved`)}catch(e){o.error(e instanceof Error?e.message:`Failed to save MCP server`)}finally{g(!1)}},De=async()=>{if(P.error||P.draft===null){A(P.error??`Quick Add is not ready yet.`);return}k(!0),A(null),a(P.draft.name);try{await de(P.draft),await r(),a(P.draft.name),se(``),ce(``),ve(!1),o.success(`MCP server added`)}catch(e){await r(),a(P.draft.name),A(e instanceof Error?e.message:`Failed to add MCP server`),o.error(e instanceof Error?e.message:`Failed to add MCP server`)}finally{k(!1)}},Ae=async e=>{try{await pe(e),await r(),o.success(`MCP server removed`)}catch(e){o.error(e instanceof Error?e.message:`Failed to remove MCP server`)}},Me=async e=>{try{await fe(e.config.name,{...e.config,enabled:!e.config.enabled}),await r()}catch(e){o.error(e instanceof Error?e.message:`Failed to update MCP server`)}},Ne=async e=>{try{await me(e),await r(),o.success(`Server refreshed`)}catch(e){o.error(e instanceof Error?e.message:`Failed to refresh server`)}},Pe=async e=>{try{await he(e),await r(),o.success(`Server refreshed after login`)}catch(e){o.error(e instanceof Error?e.message:`Failed to login MCP server`)}},G=async e=>{try{await ge(e),await r(),o.success(`Logout request sent`)}catch(e){o.error(e instanceof Error?e.message:`Failed to logout MCP server`)}},K=async(e,t,n={})=>{x(!0);try{b(await _e(e,t,n))}catch(e){b({error:e instanceof Error?e.message:`Failed to preview prompt`})}finally{x(!1)}};return{error:t,isLoading:n,servers:F,filteredServers:I,selectedServer:R,summaryCounts:z,filteredActivity:xe,detailTab:ee,setDetailTab:s,capabilityTab:c,setCapabilityTab:l,serverStatusFilter:C,setServerStatusFilter:ae,activityFilter:w,setActivityFilter:oe,selectedServerName:i,setSelectedServerName:a,clearServerFilters:we,focusQuickAdd:U,dialog:{draft:m,editingServerName:f,open:u,pending:te,setDraft:h,setOpen:d,openCreateDialog:V,openEditDialog:H,saveServer:Ee},quickAdd:{error:ye,input:T,nameValue:N,parse:P,pending:O,setInput:Se,setName:Ce,submit:De},promptPreviewState:{argumentsText:ie,loading:ne,preview:y,selectedPrompt:B,selectedPromptName:_,setArgumentsText:e=>{S(e)},previewCurrent:()=>{if(!(!R||!_))try{let e=JSON.parse(ie);K(R.config.name,_,e)}catch{b({error:`Arguments must be valid JSON`})}},selectPrompt:(e,t)=>{v(t);let n=Ve(R?.snapshot.prompts.find(e=>e.name===t)??null);S(JSON.stringify(n,null,2)),K(e,t,n)}},actions:{deleteServer:Ae,login:Pe,logout:G,refreshAll:W,refreshServer:Ne,toggleEnabled:Me}}}function q({label:e,value:t}){return(0,D.jsx)(h,{label:e,value:t,className:`min-h-0 px-4`})}function Ue({active:e,label:t,onClick:n,variant:r=`pill`}){return(0,D.jsx)(v,{active:e,label:t,onClick:n,variant:r})}function J({label:e,value:t,mono:n=!1}){return(0,D.jsx)(te,{label:e,value:t,mono:n})}var Y=`bg-card/20`,X=`text-[13px] text-muted-foreground`,Z=ne,Q=`border-border/70 bg-background/45 hover:border-ring/35 hover:bg-accent/65`,We=`border-graph-status-error/35 bg-graph-status-error/10 text-graph-status-error hover:bg-graph-status-error/18`,Ge=`mt-4 max-h-48 bg-background/55 p-3 text-foreground/70`,$=`mt-2 line-clamp-1 text-[13px] leading-6 text-muted-foreground`;function Ke(){return(0,D.jsxs)(`div`,{className:`grid h-full gap-5 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,D.jsxs)(`div`,{className:`space-y-3`,children:[Array.from({length:5}).map((e,t)=>(0,D.jsx)(`div`,{className:`h-24 rounded-xl border border-border bg-card/20 skeleton-shimmer`},t)),(0,D.jsx)(`p`,{className:`px-2 text-[13px] text-muted-foreground`,children:`Loading MCP servers...`})]}),(0,D.jsx)(`div`,{className:`rounded-xl border border-border bg-card/20 skeleton-shimmer`})]})}function qe(){return(0,D.jsx)(S,{className:`flex h-full items-center justify-center text-center text-muted-foreground`,children:`Failed to load MCP state.`})}function Je({quickAdd:e,dialog:t}){return(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,D.jsx)(Ye,{quickAdd:e,dialog:t}),(0,D.jsx)(_,{icon:r,title:`No MCP servers`,minHeightClassName:`h-full`,className:`mt-4`})]})}function Ye({dialog:e,quickAdd:t}){return(0,D.jsx)(S,{className:p(`mt-4`,Y),children:(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,D.jsx)(`div`,{children:(0,D.jsx)(`p`,{className:Z,children:`Quick Add`})}),t.parse.draft?(0,D.jsx)(g,{className:p(H(t.parse.draft.transport===`streamable_http`?`connected`:`connecting`)),children:t.parse.draft.transport===`streamable_http`?`URL`:`Launcher`}):null]}),(0,D.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(260px,0.6fr)]`,children:[(0,D.jsx)(E,{label:`Launcher or URL`,children:(0,D.jsx)(f,{id:`mcp-quick-add-input`,value:t.input,onChange:e=>t.setInput(e.target.value),placeholder:`npx @playwright/mcp@latest`})}),(0,D.jsx)(E,{label:`Name`,children:(0,D.jsx)(f,{value:t.nameValue,onChange:e=>t.setName(e.target.value),placeholder:`playwright-mcp`})})]}),t.parse.draft?(0,D.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-3`,children:[(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Transport`}),(0,D.jsx)(`p`,{className:`mt-2 text-[14px] font-medium text-foreground`,children:t.parse.draft.transport})]}),(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Parsed Name`}),(0,D.jsx)(`p`,{className:`mt-2 text-[14px] font-medium text-foreground`,children:t.parse.draft.name})]}),(0,D.jsxs)(S,{className:p(`xl:col-span-1`,Y),children:[(0,D.jsx)(`p`,{className:Z,children:`Parsed Result`}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono text-[12px] text-foreground/80`,children:t.parse.draft.transport===`streamable_http`?t.parse.draft.url:[t.parse.draft.command,...t.parse.draft.args].join(` `)})]})]}):null,t.error||t.input.trim()&&t.parse.error?(0,D.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error??t.parse.error}):null,(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(m,{type:`button`,disabled:t.pending||t.parse.draft===null,onClick:()=>void t.submit(),children:t.pending?`Adding...`:`Quick Add`}),(0,D.jsx)(m,{type:`button`,variant:`outline`,className:Q,onClick:e.openCreateDialog,children:`Advanced Add`})]})]})})}function Xe(e){return(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,D.jsx)(Ze,{summaryCounts:e.summaryCounts}),(0,D.jsx)(Ye,{quickAdd:e.quickAdd,dialog:e.dialog}),(0,D.jsx)(Qe,{serverStatusFilter:e.serverStatusFilter,onServerStatusFilterChange:e.onServerStatusFilterChange}),(0,D.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-hidden`,children:e.filteredServers.length===0?(0,D.jsx)(_,{icon:s,title:`No matching MCP servers`,minHeightClassName:`h-full`,action:(0,D.jsxs)(m,{type:`button`,variant:`outline`,className:Q,onClick:e.clearServerFilters,children:[(0,D.jsx)(i,{className:`mr-2 size-4`}),`Show All Servers`]})}):(0,D.jsxs)(`div`,{className:`grid h-full gap-5 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,D.jsx)($e,{actions:e.actions,dialog:e.dialog,filteredServers:e.filteredServers,onSelectServer:e.onSelectServer,selectedServer:e.selectedServer}),(0,D.jsx)(tt,{actions:e.actions,activityFilter:e.activityFilter,capabilityTab:e.capabilityTab,dialog:e.dialog,detailTab:e.detailTab,filteredActivity:e.filteredActivity,onActivityFilterChange:e.onActivityFilterChange,onCapabilityTabChange:e.onCapabilityTabChange,onDetailTabChange:e.onDetailTabChange,onFocusQuickAdd:e.onFocusQuickAdd,promptPreviewState:e.promptPreviewState,selectedServer:e.selectedServer})]})})]})}function Ze({summaryCounts:e}){return(0,D.jsx)(S,{children:(0,D.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,D.jsx)(q,{label:`Configured`,value:e.configured}),(0,D.jsx)(q,{label:`Connected`,value:e.connected}),(0,D.jsx)(q,{label:`Auth Required`,value:e.authRequired}),(0,D.jsx)(q,{label:`Error`,value:e.error})]})})}function Qe({onServerStatusFilterChange:e,serverStatusFilter:t}){return(0,D.jsx)(S,{className:`mt-4`,children:(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:F.map(n=>(0,D.jsx)(Ue,{active:t===n.value,label:n.label,onClick:()=>e(n.value)},n.value))})})}function $e({actions:e,dialog:t,filteredServers:n,onSelectServer:r,selectedServer:i}){return(0,D.jsx)(`div`,{className:`min-h-0 overflow-y-auto pr-1 scrollbar-none`,children:(0,D.jsx)(`div`,{className:`space-y-3`,children:n.map(n=>(0,D.jsx)(et,{actions:e,dialog:t,isSelected:i?.config.name===n.config.name,onSelectServer:r,serverRecord:n},n.config.name))})})}function et({actions:e,dialog:t,isSelected:n,onSelectServer:r,serverRecord:i}){let a=U(i);return(0,D.jsx)(y,{as:`div`,padding:`sm`,className:p(`p-4 transition-colors`,n?`bg-accent/20`:`bg-card/20 hover:bg-accent/20`),children:(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,D.jsxs)(m,{type:`button`,variant:`ghost`,onClick:()=>r(i.config.name),className:`h-auto min-w-0 flex-1 justify-start p-0 text-left hover:bg-transparent hover:text-inherit`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:i.config.name}),i.config.required?(0,D.jsx)(g,{tone:`idle`,className:`px-2 py-0.5`,children:`required`}):null,a?(0,D.jsx)(g,{tone:`primary`,className:`px-2 py-0.5`,children:a}):null]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-1.5 text-[12px] text-muted-foreground`,children:[(0,D.jsxs)(`p`,{children:[`Transport `,i.config.transport]}),(0,D.jsxs)(`p`,{children:[`Status `,V(i.snapshot.status)]}),(0,D.jsxs)(`p`,{children:[`Auth `,B(i.snapshot.auth_status)]}),(0,D.jsx)(`p`,{children:Ce(i)})]}),i.snapshot.last_error?(0,D.jsx)(`p`,{className:`mt-3 line-clamp-2 text-[12px] leading-5 text-destructive`,children:i.snapshot.last_error}):null]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,D.jsx)(g,{className:p(H(i.snapshot.status)),children:V(i.snapshot.status)}),(0,D.jsx)(rt,{actions:e,buttonClassName:`h-7 px-2 text-[11px]`,dialog:t,serverRecord:i})]})]})})}function tt({actions:e,activityFilter:t,capabilityTab:n,dialog:r,detailTab:i,filteredActivity:a,onActivityFilterChange:ee,onCapabilityTabChange:o,onDetailTabChange:s,onFocusQuickAdd:c,promptPreviewState:l,selectedServer:u}){return u?(0,D.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,D.jsxs)(S,{className:`flex h-full min-h-0 flex-col`,children:[(0,D.jsx)(nt,{actions:e,dialog:r,selectedServer:u}),(0,D.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 border-b border-border`,children:N.map(e=>(0,D.jsx)(Ue,{active:i===e,label:z(e),onClick:()=>s(e),variant:`tab`},e))}),(0,D.jsxs)(`div`,{className:`mt-5 min-h-0 flex-1 overflow-y-auto pr-1 scrollbar-none`,children:[i===`overview`?(0,D.jsx)(it,{selectedServer:u}):null,i===`capabilities`?(0,D.jsx)(st,{capabilityTab:n,onCapabilityTabChange:o,promptPreviewState:l,selectedServer:u}):null,i===`activity`?(0,D.jsx)(ft,{activityFilter:t,filteredActivity:a,onActivityFilterChange:ee,selectedServer:u}):null]})]})}):(0,D.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,D.jsx)(_,{title:`Select an MCP server`,action:(0,D.jsx)(m,{type:`button`,size:`sm`,onClick:c,children:`Quick Add`}),minHeightClassName:`h-full`})})}function nt({actions:e,dialog:t,selectedServer:n}){return(0,D.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4 border-b border-border pb-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(`h2`,{className:`text-[18px] font-medium text-foreground`,children:n.config.name}),(0,D.jsx)(g,{uppercase:!0,className:p(H(n.snapshot.status)),children:V(n.snapshot.status)}),U(n)?(0,D.jsx)(g,{tone:`primary`,children:U(n)}):null]}),(0,D.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[n.config.transport,` · Auth`,` `,B(n.snapshot.auth_status)]}),n.snapshot.last_error?(0,D.jsx)(`p`,{className:`mt-2 max-w-3xl text-[13px] leading-6 text-destructive`,children:n.snapshot.last_error}):null]}),(0,D.jsx)(rt,{actions:e,dialog:t,serverRecord:n})]})}function rt({actions:e,buttonClassName:t,dialog:n,serverRecord:r}){return(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(m,{type:`button`,variant:`outline`,className:p(Q,t),onClick:()=>e.toggleEnabled(r),children:r.config.enabled?`Disable`:`Enable`}),(0,D.jsx)(m,{type:`button`,variant:`outline`,disabled:Pe(r),className:p(Q,t),onClick:()=>r.snapshot.auth_status===`connected`?e.logout(r.config.name):e.login(r.config.name),children:Ne(r)}),(0,D.jsx)(m,{type:`button`,variant:`outline`,className:p(Q,t),onClick:()=>n.openEditDialog(r),children:`Edit`}),(0,D.jsx)(m,{type:`button`,variant:`outline`,className:p(Q,t),onClick:()=>e.refreshServer(r.config.name),children:`Refresh`}),(0,D.jsx)(m,{type:`button`,variant:`outline`,className:p(We,t),onClick:()=>e.deleteServer(r.config.name),children:`Remove`})]})}function it({selectedServer:e}){return(0,D.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Status`}),(0,D.jsx)(`p`,{className:`mt-3 text-[22px] font-medium text-foreground`,children:V(e.snapshot.status)}),(0,D.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Auth `,B(e.snapshot.auth_status)]})]}),(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Visibility`}),(0,D.jsx)(`p`,{className:`mt-3 text-[22px] font-medium text-foreground`,children:U(e)??`Pending`})]}),(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Last Refresh`}),(0,D.jsx)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:R(e.snapshot.last_refresh_at)}),(0,D.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Result`,` `,z(e.snapshot.last_refresh_result)]})]}),(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Timeouts`}),(0,D.jsxs)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:[`Startup `,e.config.startup_timeout_sec,`s`]}),(0,D.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Tool `,e.config.tool_timeout_sec,`s`]})]}),(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Tool Filters`}),(0,D.jsx)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:Me(e)}),(0,D.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Enabled `,e.config.enabled_tools.length,` · `,`Disabled `,e.config.disabled_tools.length]})]}),(0,D.jsxs)(S,{className:p(`xl:col-span-2`,Y),children:[(0,D.jsx)(`p`,{className:Z,children:`Capability Summary`}),(0,D.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:Object.entries(e.snapshot.capability_counts).map(([e,t])=>(0,D.jsxs)(y,{as:`div`,padding:`sm`,className:`bg-card/20`,children:[(0,D.jsx)(`p`,{className:Z,children:e.replaceAll(`_`,` `)}),(0,D.jsx)(`p`,{className:`mt-2 text-xl font-medium text-foreground`,children:t})]},e))})]}),e.config.launcher?(0,D.jsx)(S,{className:p(`xl:col-span-2`,Y),children:(0,D.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,D.jsx)(J,{label:`Original Launcher`,value:G(e.config.launcher),mono:!0}),(0,D.jsx)(J,{label:`Parsed Result`,value:Ae(e),mono:!0})]})}):null,e.config.transport===`stdio`?(0,D.jsx)(at,{selectedServer:e}):(0,D.jsx)(ot,{selectedServer:e})]})}function at({selectedServer:e}){return(0,D.jsx)(S,{className:p(`xl:col-span-2`,Y),children:(0,D.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,D.jsx)(J,{label:`Command`,value:G(e.config.command),mono:!0}),(0,D.jsx)(J,{label:`Cwd`,value:G(e.config.cwd),mono:!0}),(0,D.jsx)(J,{label:`Args`,value:K(e.config.args),mono:!0}),(0,D.jsx)(J,{label:`Env Vars`,value:K(e.config.env_vars),mono:!0})]})})}function ot({selectedServer:e}){return(0,D.jsxs)(S,{className:p(`xl:col-span-2`,Y),children:[(0,D.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,D.jsx)(J,{label:`URL`,value:G(e.config.url),mono:!0}),(0,D.jsx)(J,{label:`OAuth Resource`,value:G(e.config.oauth_resource),mono:!0}),(0,D.jsx)(J,{label:`Bearer Token Env Var`,value:G(e.config.bearer_token_env_var),mono:!0}),(0,D.jsx)(J,{label:`Scopes`,value:K(e.config.scopes),mono:!0}),(0,D.jsx)(J,{label:`HTTP Headers`,value:Fe(e.config.http_headers),mono:!0}),(0,D.jsx)(J,{label:`Env HTTP Headers`,value:K(e.config.env_http_headers),mono:!0})]}),(0,D.jsxs)(y,{as:`div`,padding:`sm`,className:`mt-4 bg-card/20`,children:[(0,D.jsx)(`p`,{className:Z,children:`Recent Auth Result`}),(0,D.jsx)(`p`,{className:`mt-2 text-[14px] font-medium text-foreground`,children:Be(e.snapshot.last_auth_result??``,`No login action yet`)}),(0,D.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Current auth status`,` `,B(e.snapshot.auth_status)]})]})]})}function st({capabilityTab:e,onCapabilityTabChange:t,promptPreviewState:n,selectedServer:r}){return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`div`,{className:`flex flex-wrap gap-4 border-b border-border`,children:P.map(n=>(0,D.jsx)(Ue,{active:e===n,label:n===`resource_templates`?`Resource Templates`:z(n),onClick:()=>t(n),variant:`tab`},n))}),e===`tools`?(0,D.jsx)(ct,{selectedServer:r}):null,e===`resources`?(0,D.jsx)(lt,{selectedServer:r}):null,e===`resource_templates`?(0,D.jsx)(ut,{selectedServer:r}):null,e===`prompts`?(0,D.jsx)(dt,{promptPreviewState:n,selectedServer:r}):null]})}function ct({selectedServer:e}){return e.snapshot.tools.length===0?(0,D.jsx)(S,{className:p(Y,X),children:`No tools discovered.`}):(0,D.jsx)(`div`,{className:`space-y-3`,children:e.snapshot.tools.map(e=>(0,D.jsxs)(S,{className:Y,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`font-mono text-[13px] text-foreground`,children:e.tool_name}),e.title?(0,D.jsx)(`p`,{className:`mt-2 text-[13px] text-foreground/70`,children:e.title}):null,(0,D.jsx)(`p`,{className:`mt-1 text-[12px] text-muted-foreground`,children:e.fully_qualified_id})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[10px]`,children:[e.read_only_hint?(0,D.jsx)(g,{tone:`primary`,children:`readOnly`}):null,e.destructive_hint?(0,D.jsx)(g,{tone:`danger`,children:`destructive`}):null,e.open_world_hint?(0,D.jsx)(g,{tone:`idle`,children:`openWorld`}):null]})]}),e.description?(0,D.jsx)(`p`,{className:$,children:e.description}):null,(0,D.jsx)(b,{className:Ge,children:JSON.stringify(e.parameters??{},null,2)})]},e.fully_qualified_id))})}function lt({selectedServer:e}){return e.snapshot.resources.length===0?(0,D.jsx)(S,{className:p(Y,X),children:`No resources discovered.`}):(0,D.jsx)(`div`,{className:`space-y-3`,children:e.snapshot.resources.map(e=>(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:e.name}),(0,D.jsx)(`p`,{className:`mt-1 font-mono text-[12px] text-muted-foreground`,children:e.uri}),(0,D.jsx)(`p`,{className:`mt-3 text-[13px] text-foreground/70`,children:e.mime_type??`Unknown MIME`}),e.description?(0,D.jsx)(`p`,{className:$,children:e.description}):null]},e.uri))})}function ut({selectedServer:e}){return e.snapshot.resource_templates.length===0?(0,D.jsx)(S,{className:p(Y,X),children:`No resource templates discovered.`}):(0,D.jsx)(`div`,{className:`space-y-3`,children:e.snapshot.resource_templates.map(e=>(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:e.name}),(0,D.jsx)(`p`,{className:`mt-1 font-mono text-[12px] text-muted-foreground`,children:e.uri_template}),e.description?(0,D.jsx)(`p`,{className:$,children:e.description}):null]},e.uri_template))})}function dt({promptPreviewState:e,selectedServer:t}){return(0,D.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]`,children:[(0,D.jsx)(`div`,{className:`space-y-3`,children:t.snapshot.prompts.length===0?(0,D.jsx)(S,{className:p(Y,X),children:`No prompts discovered.`}):t.snapshot.prompts.map(n=>(0,D.jsxs)(m,{type:`button`,variant:`ghost`,onClick:()=>e.selectPrompt(t.config.name,n.name),className:p(`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`,e.selectedPromptName===n.name?`border-border bg-accent/20`:`hover:bg-accent/20`),children:[(0,D.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:n.name}),n.description?(0,D.jsx)(`p`,{className:$,children:n.description}):null,(0,D.jsx)(b,{className:Ge,children:JSON.stringify(n.arguments??[],null,2)})]},n.name))}),(0,D.jsxs)(S,{className:Y,children:[(0,D.jsx)(`p`,{className:Z,children:`Prompt Preview`}),e.selectedPromptName?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{className:`mt-3 text-[15px] font-medium text-foreground`,children:e.selectedPromptName}),(0,D.jsx)(`p`,{className:`mt-4 text-[11px] text-muted-foreground/80`,children:`Arguments`}),(0,D.jsx)(c,{value:e.argumentsText,onChange:t=>e.setArgumentsText(t.target.value),className:`mt-2 min-h-[120px] bg-background/50 font-mono text-[11px] text-foreground/80`}),(0,D.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,D.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`Edit argument JSON, then refresh the preview.`}),(0,D.jsx)(m,{type:`button`,variant:`outline`,className:Q,onClick:e.previewCurrent,children:`Preview`})]}),e.selectedPrompt?.arguments?.length?(0,D.jsx)(b,{className:p(Ge,`max-h-40`),children:JSON.stringify(e.selectedPrompt.arguments,null,2)}):null,(0,D.jsx)(b,{className:p(Ge,`max-h-[420px]`),children:e.loading?`Loading preview...`:JSON.stringify(e.preview??{},null,2)})]}):(0,D.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Select a prompt to preview it.`})]})]})}function ft({activityFilter:e,filteredActivity:t,onActivityFilterChange:n,selectedServer:r}){return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:I.map(t=>(0,D.jsx)(Ue,{active:e===t.value,label:t.label,onClick:()=>n(t.value)},t.value))}),t.length===0?(0,D.jsx)(S,{className:p(Y,X),children:r.activity.length===0?`No recent MCP activity.`:`No activity matches the current filter.`}):t.map(e=>(0,D.jsx)(pt,{activityRecord:e},e.id))]})}function pt({activityRecord:e}){return(0,D.jsxs)(S,{className:Y,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(g,{tone:`neutral`,children:Re(e)}),(0,D.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:z(e.action)})]}),(0,D.jsx)(`p`,{className:`mt-2 text-[12px] text-muted-foreground`,children:R(e.started_at)})]}),(0,D.jsx)(g,{uppercase:!0,className:p(Se(e.result)),children:e.result})]}),(0,D.jsx)(`p`,{className:`mt-3 text-[13px] leading-6 text-muted-foreground`,children:e.summary}),(0,D.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-4 text-[12px] text-muted-foreground`,children:[e.actor_node_id?(0,D.jsxs)(`span`,{children:[`Node `,e.actor_node_id.slice(0,8)]}):null,e.tab_id?(0,D.jsxs)(`span`,{children:[`Workflow `,e.tab_id.slice(0,8)]}):null,e.tool_name?(0,D.jsxs)(`span`,{children:[`Tool `,e.tool_name]}):null,e.target?(0,D.jsxs)(`span`,{children:[`Target `,e.target]}):null,(0,D.jsxs)(`span`,{children:[Math.round(e.duration_ms),` ms`]}),(0,D.jsx)(`span`,{children:xe(e.ended_at)})]})]})}function mt(){let{actions:e,activityFilter:t,capabilityTab:n,clearServerFilters:r,detailTab:i,dialog:o,error:s,filteredActivity:c,filteredServers:l,focusQuickAdd:u,isLoading:d,promptPreviewState:f,quickAdd:p,selectedServer:h,serverStatusFilter:te,servers:g,setActivityFilter:_,setCapabilityTab:v,setDetailTab:y,setSelectedServerName:b,setServerStatusFilter:ne,summaryCounts:re}=He();return(0,D.jsxs)(x,{children:[(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-8 py-6`,children:[(0,D.jsx)(ie,{title:`MCP`,actions:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(m,{type:`button`,variant:`outline`,className:Q,onClick:()=>void e.refreshAll(),children:[(0,D.jsx)(ee,{className:`mr-2 size-4`}),`Refresh`]}),(0,D.jsxs)(m,{type:`button`,variant:`outline`,className:Q,onClick:u,children:[(0,D.jsx)(a,{className:`mr-2 size-4`}),`Quick Add`]}),(0,D.jsxs)(m,{type:`button`,onClick:o.openCreateDialog,children:[(0,D.jsx)(a,{className:`mr-2 size-4`}),`Advanced Add`]})]})}),(0,D.jsx)(`div`,{className:`mt-6 min-h-0 flex-1 overflow-hidden`,children:d?(0,D.jsx)(Ke,{}):s?(0,D.jsx)(qe,{}):g.length===0?(0,D.jsx)(Je,{quickAdd:p,dialog:o}):(0,D.jsx)(Xe,{actions:e,activityFilter:t,capabilityTab:n,clearServerFilters:r,detailTab:i,dialog:o,filteredActivity:c,filteredServers:l,onActivityFilterChange:_,onCapabilityTabChange:v,onDetailTabChange:y,onFocusQuickAdd:u,onSelectServer:b,onServerStatusFilterChange:ne,promptPreviewState:f,quickAdd:p,selectedServer:h,serverStatusFilter:te,summaryCounts:re})})]}),(0,D.jsx)(be,{draft:o.draft,onChange:o.setDraft,open:o.open,pending:o.pending,title:o.editingServerName?`Edit MCP Server`:`Advanced Add MCP Server`,onOpenChange:o.setOpen,onSubmit:()=>void o.saveServer()})]})}export{mt as McpPage};
@@ -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{Lt as r,dt as i,q as a}from"./ui-vendor-UazN8rcv.js";import{B as o,a as s,i as c,n as l,q as u,r as d,s as f,tt as p}from"./index-Biio-CoI.js";import{l as m,s as h}from"./surface-Bzr1FRG4.js";import{c as g,n as _,r as v}from"./PageScaffold-DteOA8V7.js";async function y(){return o(`/api/prompts`,{errorMessage:`Failed to fetch prompts`})}async function b(e){return o(`/api/prompts`,{method:`PUT`,body:e,errorMessage:`Failed to save prompts`})}var x=e(t(),1),S=n(),C=`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 w(){let{data:e,isLoading:t,mutate:n}=g(`promptSettings`,y),[r,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(``),[l,d]=(0,x.useState)(!1);(0,x.useEffect)(()=>{e&&(o(e.custom_prompt),c(e.custom_post_prompt))},[e]);let w=async()=>{d(!0);try{n(await b({custom_prompt:r,custom_post_prompt:s}),!1),a.success(`Prompts saved`)}catch{a.error(`Failed to save prompts`)}finally{d(!1)}};return t?(0,S.jsx)(f,{label:`Loading prompts...`,textClassName:`text-[13px]`}):(0,S.jsx)(_,{children:(0,S.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-[800px] flex-col px-4 pb-10 pt-6`,children:[(0,S.jsx)(v,{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,S.jsxs)(p,{type:`button`,onClick:()=>void w(),disabled:l,size:`sm`,className:`text-[13px]`,children:[(0,S.jsx)(i,{className:`size-4`}),l?`Saving...`:`Save Changes`]})}),(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-8 pt-6`,children:[(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,S.jsx)(`div`,{className:`mb-3 flex items-center justify-between px-1`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:`Custom Prompt`}),T(`Custom Prompt details`,`Appended to every node's system prompt.`),(0,S.jsxs)(m,{tone:`neutral`,className:`px-2 py-0.5`,children:[r.length,` chars`]})]})}),(0,S.jsx)(h,{as:`div`,padding:`none`,className:`relative flex min-h-0 flex-1 p-1`,children:(0,S.jsx)(u,{"aria-label":`Custom Prompt`,value:r,onChange:e=>o(e.target.value),placeholder:`Appended to every node's system prompt...`,className:C,mono:!0})})]}),(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,S.jsx)(`div`,{className:`mb-3 flex items-center justify-between px-1`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:`Custom Post Prompt`}),T(`Custom Post Prompt details`,`Appended after the built-in runtime post prompt.`),(0,S.jsxs)(m,{tone:`neutral`,className:`px-2 py-0.5`,children:[s.length,` chars`]})]})}),(0,S.jsx)(h,{as:`div`,padding:`none`,className:`relative flex min-h-0 flex-1 p-1`,children:(0,S.jsx)(u,{"aria-label":`Custom Post Prompt`,value:s,onChange:e=>c(e.target.value),placeholder:`Appended after the built-in runtime post prompt...`,className:C,mono:!0})})]})]})]})})}var T=(e,t)=>(0,S.jsx)(c,{delayDuration:150,children:(0,S.jsxs)(l,{children:[(0,S.jsx)(s,{asChild:!0,children:(0,S.jsx)(p,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":e,className:`rounded-full text-muted-foreground hover:bg-accent/35 hover:text-foreground`,children:(0,S.jsx)(r,{className:`size-3.5`})})}),(0,S.jsx)(d,{className:`max-w-xs`,children:t})]})});export{w 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{_t as r,bt as i,nn as a,pt as o,q as s,sn as c,st as l,tt as u,xt as d}from"./ui-vendor-UazN8rcv.js";import{B as f,G as p,J as m,Q as h,V as g,W as _,d as ee,f as v,l as y,q as te,rt as b,tt as x}from"./index-Biio-CoI.js";import{l as ne,o as S,s as C}from"./surface-Bzr1FRG4.js";import{a as w,c as re,n as ie,r as ae,t as T}from"./PageScaffold-DteOA8V7.js";import{a as E,i as D,n as O,r as k,t as A}from"./select-D9SwnlXF.js";import{a as j,i as M,o as N,r as P,s as F,t as I}from"./dialog-BOvHIBrg.js";import{i as L,n as R,r as z,t as B}from"./triState-DgLlKdRR.js";import{a as oe,c as se,i as ce,n as le,o as ue,r as V,s as H,t as U}from"./alert-dialog-DIBUCmqM.js";async function de(){return f(`/api/providers`,{errorMessage:`Failed to fetch providers`,fallback:[],map:e=>e?.providers??[]})}async function fe(e){return f(`/api/providers`,{method:`POST`,body:e,errorMessage:`Failed to create provider`})}async function pe(e,t){return f(`/api/providers/${e}`,{method:`PUT`,body:t,errorMessage:`Failed to update provider`})}async function me(e){await g(`/api/providers/${e}`,{method:`DELETE`,errorMessage:`Failed to delete provider`})}async function he(e){return f(`/api/providers/models`,{method:`POST`,body:e,errorMessage:`Failed to fetch provider models`,fallback:[],map:e=>e?.models??[]})}async function W(e){return f(`/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 ge(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function _e(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:ge(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:R(e?.input_image??null),output_image:R(e?.output_image??null),structured_output:R(e?.structured_output??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 ve(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,structured_output:t.structured_output??e.structured_output}),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 ye(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`}`),e.structured_output!==null&&e.structured_output!==void 0&&t.push(`structured_output=${e.structured_output?`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 be(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 xe(e){let t=B(e.structured_output??`auto`);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:B(e.input_image),output_image:B(e.output_image),...t===null?{}:{structured_output:t}}}var Q=n();function Se({draft:e,onClose:t,onDraftChange:n,onSave:r,state:i}){return(0,Q.jsx)(I,{open:i!==null,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(P,{children:[(0,Q.jsxs)(N,{children:[(0,Q.jsx)(F,{children:i?.mode===`edit`?`Edit Model`:`Add Model`}),(0,Q.jsx)(M,{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)(p,{"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)(p,{"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-3`,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)(A,{value:e.input_image,onValueChange:t=>n({...e,input_image:t}),children:[(0,Q.jsx)(D,{className:h,children:(0,Q.jsx)(E,{})}),(0,Q.jsxs)(O,{className:`rounded-xl border-border bg-popover`,children:[(0,Q.jsx)(k,{value:`auto`,children:`Auto`}),(0,Q.jsx)(k,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(k,{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)(A,{value:e.output_image,onValueChange:t=>n({...e,output_image:t}),children:[(0,Q.jsx)(D,{className:h,children:(0,Q.jsx)(E,{})}),(0,Q.jsxs)(O,{className:`rounded-xl border-border bg-popover`,children:[(0,Q.jsx)(k,{value:`auto`,children:`Auto`}),(0,Q.jsx)(k,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(k,{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:`Structured Output`}),(0,Q.jsxs)(A,{value:e.structured_output??`auto`,onValueChange:t=>n({...e,structured_output:t}),children:[(0,Q.jsx)(D,{className:h,children:(0,Q.jsx)(E,{})}),(0,Q.jsxs)(O,{className:`rounded-xl border-border bg-popover`,children:[(0,Q.jsx)(k,{value:`auto`,children:`Auto`}),(0,Q.jsx)(k,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(k,{value:`disabled`,children:`Disabled`})]})]})]})]})]}),(0,Q.jsxs)(j,{className:`px-5 pb-5`,children:[(0,Q.jsx)(x,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,Q.jsx)(x,{onClick:r,children:i?.mode===`edit`?`Save Model`:`Add Model`})]})]})})}function Ce({isDragging:e,loading:t,onCreate:n,onDelete:i,onRefresh:a,onResizeStart:s,onSelect:d,panelWidth:f,providers:p,selectedId:m}){return(0,Q.jsxs)(`div`,{style:{width:`${f}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)(l,{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)(_,{onClick:a,disabled:t,className:`size-7`,children:(0,Q.jsx)(o,{className:b(`size-3.5`,t&&`animate-spin`)})}),(0,Q.jsx)(_,{onClick:n,className:`size-7`,children:(0,Q.jsx)(r,{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))}):p.length===0?(0,Q.jsxs)(c.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)(x,{type:`button`,size:`sm`,onClick:n,className:`mt-4`,children:[(0,Q.jsx)(r,{className:`size-3`}),`Add your first provider`]})]}):(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:p.map((e,t)=>(0,Q.jsxs)(c.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},transition:{delay:t*.03},className:b(`group relative flex w-full items-center justify-between rounded-lg transition-all`,m===e.id?`bg-accent/55 text-foreground`:`text-muted-foreground hover:bg-accent/30 hover:text-foreground`),children:[(0,Q.jsx)(`div`,{className:b(`absolute inset-y-1 left-0 w-px rounded-full bg-ring/60 transition-opacity`,m===e.id?`opacity-100`:`opacity-0`)}),(0,Q.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>d(e),className:`h-auto min-w-0 flex-1 justify-start rounded-lg bg-transparent px-3 py-2.5 text-left text-inherit shadow-none hover:bg-transparent hover:text-inherit focus-visible:ring-2 focus-visible:ring-ring/50`,children:(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 pl-2`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:z(e.type)})]})}),(0,Q.jsx)(_,{onClick:()=>{i(e)},className:`mr-2 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)(u,{className:`size-3`})})]},e.id))})}),(0,Q.jsx)(y,{position:`right`,isDragging:e,onMouseDown:s})]})}var $=e(t(),1),we={openai_compatible:`/v1`,openai_responses:`/v1`,anthropic:`/v1`,gemini:`/v1beta`},Te={openai_compatible:`/chat/completions`,openai_responses:`/responses`,anthropic:`/messages`,gemini:`/models/{model}:streamGenerateContent`},Ee=Array.from(new Set(Object.values(we))).sort((e,t)=>t.length-e.length);function De(e){return e.trim().toLowerCase()}function Oe(e){return e.trim().replace(/\/+$/,``)}function ke(e,t){let n=De(e),r=we[n],i=Oe(t);if(!r||!i)return{resolvedBaseUrl:null,error:null};let a=i.toLowerCase();for(let e of Ee)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 Ae(e,t){let n=De(e),r=Te[n],{resolvedBaseUrl:i,error:a}=ke(n,t);return a?{previewUrl:null,error:a}:!i||!r?{previewUrl:null,error:null}:{previewUrl:`${i}${r}`,error:null}}function je(){let[e,t]=(0,$.useState)(null),[n,r]=(0,$.useState)(!1),[i,a]=(0,$.useState)(K()),[o,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(null),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(null),[_,y]=(0,$.useState)(q()),[te,b]=(0,$.useState)({}),{data:x=[],isLoading:ne,mutate:S}=re(`providers`,de,{onSuccess:n=>{!e||n.find(t=>t.id===e)||(t(null),r(!1),a(K()),b({}),f(!1))}}),[C,w]=v(`providers-panel-width`,300,200,500),{isDragging:ie,startDrag:ae}=ee(C,w,`right`),T=(0,$.useMemo)(()=>x.find(t=>t.id===e),[x,e]),E=(0,$.useMemo)(()=>Ae(i.type,i.base_url),[i.base_url,i.type]),D=(0,$.useMemo)(()=>_e(i.headers_text),[i.headers_text]),O=(0,$.useMemo)(()=>{let e=n?K():K(T);return J(i)!==J(e)},[i,n,T]),k=(0,$.useCallback)(async()=>{await S()},[S]),A=(0,$.useCallback)(e=>{t(e.id),r(!1),a(K(e)),b({}),g(null),f(!1)},[]),j=(0,$.useCallback)(()=>{r(!0),t(null),a(K()),b({}),g(null),f(!1)},[]),M=(0,$.useCallback)(()=>{n?(r(!1),a(K())):a(K(T)),b({}),g(null),f(!1)},[n,T]),N=(0,$.useCallback)(async()=>{if(!i.name.trim()){s.error(`Provider name is required`);return}if(!i.base_url.trim()){s.error(`Provider base URL is required`);return}if(E.error){s.error(E.error);return}if(D.error){s.error(D.error);return}let o=Z(i.models);if(o){s.error(`Model ID '${o}' is duplicated`);return}let l=Y(i,D.headers);c(!0);try{if(n){let e=await fe(l);S([...x,e],!1),r(!1),t(e.id),a(K(e)),s.success(`Provider created`)}else if(e){let t=await pe(e,l);S(x.map(n=>n.id===e?t:n),!1),a(K(t)),s.success(`Provider updated`)}b({}),f(!1)}catch{s.error(n?`Failed to create provider`:`Failed to update provider`)}finally{c(!1)}},[i,E.error,n,S,D.error,D.headers,x,e]),P=(0,$.useCallback)(async()=>{if(!l)return;let n=l.id;u(null),f(!1);try{await me(n),S(x.filter(e=>e.id!==n),!1),e===n&&(t(null),a(K())),b({}),s.success(`Provider deleted`)}catch{s.error(`Failed to delete provider`)}},[S,l,x,e]),F=(0,$.useCallback)(()=>{g({mode:`create`,originalModel:null}),y(q())},[]),I=(0,$.useCallback)(e=>{g({mode:`edit`,originalModel:e.model}),y(q(e))},[]),L=(0,$.useCallback)(()=>{g(null),y(q())},[]),R=(0,$.useCallback)(()=>{let e=be(_);if(e){s.error(e);return}let t=_.model.trim();if(i.models.some(e=>e.model===t&&e.model!==h?.originalModel)){s.error(`Model ID '${t}' already exists in this provider`);return}let n=xe(_);a(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,i.models,_,h]),z=(0,$.useCallback)(e=>{a(t=>({...t,models:t.models.filter(t=>t.model!==e)})),b(t=>{let n={...t};return delete n[e],n})},[]),B=(0,$.useCallback)(()=>{i.models.length!==0&&f(!0)},[i.models.length]);return{cancelClearModels:(0,$.useCallback)(()=>{f(!1)},[]),clearModelsConfirmOpen:d,draft:i,endpointPreview:E,fetchingModels:p,handleCancel:M,handleClearModels:(0,$.useCallback)(()=>{a(e=>({...e,models:[]})),b({}),f(!1)},[]),handleCreateNew:j,handleDelete:P,handleDeleteModel:z,handleFetchModels:(0,$.useCallback)(async()=>{if(!i.type.trim()||!i.base_url.trim()){s.error(`Provider type and base URL are required before fetching models`);return}if(E.error){s.error(E.error);return}if(D.error){s.error(D.error);return}m(!0);try{let t=await he(X(i,D.headers,e??void 0));a(e=>({...e,models:ve(e.models,t)})),s.success(`Provider models fetched`)}catch(e){s.error(e instanceof Error?e.message:`Failed to fetch provider models`)}finally{m(!1)}},[i,E.error,D.error,D.headers,e]),handleSave:N,handleSaveModel:R,handleSelect:A,handleTestModel:(0,$.useCallback)(async t=>{if(E.error){s.error(E.error);return}if(D.error){s.error(D.error);return}b(e=>({...e,[t.model]:{state:`running`}}));try{let n=await W({...X(i,D.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`}}))}},[i,E.error,D.error,D.headers,e]),hasChanges:O,isCreating:n,isDragging:ie,loading:ne,modelEditorDraft:_,modelEditorState:h,modelTestStates:te,openCreateModelDialog:F,openEditModelDialog:I,panelWidth:C,parsedHeaders:D,providerToDelete:l,providers:x,refreshProviders:k,requestClearModels:B,saving:o,selectedId:e,selectedProvider:T,setDraft:a,setModelEditorDraft:y,setProviderToDelete:u,startDrag:ae,closeModelDialog:L}}function Me(){let{cancelClearModels:e,clearModelsConfirmOpen:t,draft:n,endpointPreview:s,fetchingModels:f,handleCancel:g,handleClearModels:_,handleCreateNew:ee,handleDelete:v,handleDeleteModel:y,handleFetchModels:re,handleSave:j,handleSaveModel:M,handleSelect:N,handleTestModel:P,hasChanges:F,isCreating:I,isDragging:R,loading:z,modelEditorDraft:B,modelEditorState:de,modelTestStates:fe,openCreateModelDialog:pe,openEditModelDialog:me,panelWidth:he,parsedHeaders:W,providerToDelete:G,providers:ge,refreshProviders:_e,requestClearModels:K,saving:q,selectedId:J,selectedProvider:Y,setDraft:X,setModelEditorDraft:ve,setProviderToDelete:Z,startDrag:be,closeModelDialog:xe}=je();return(0,Q.jsx)(ie,{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)(ae,{title:`Providers`}),(0,Q.jsxs)(C,{as:`div`,padding:`none`,className:`mt-6 flex min-h-0 flex-1 overflow-hidden border-border/60 bg-card/[0.14]`,children:[(0,Q.jsx)(Ce,{isDragging:R,loading:z,onCreate:ee,onDelete:Z,onRefresh:()=>{_e()},onResizeStart:be,onSelect:N,panelWidth:he,providers:ge,selectedId:J}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 overflow-y-auto bg-transparent`,children:I||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:I?`New Provider`:Y?.name}),I?null:(0,Q.jsx)(`p`,{className:`mt-1 select-text font-mono text-[12px] text-muted-foreground`,children:Y?.id})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:F?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(x,{type:`button`,variant:`ghost`,size:`sm`,onClick:g,disabled:q,children:`Cancel`}),(0,Q.jsxs)(x,{type:`button`,size:`sm`,onClick:()=>void j(),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.jsxs)(T,{title:`Identity`,className:`mb-10`,contentClassName:`rounded-lg border-dashed bg-card/30`,children:[(0,Q.jsx)(w,{label:`Name`,children:(0,Q.jsx)(p,{value:n.name,onChange:e=>X({...n,name:e.target.value}),placeholder:`e.g., OpenAI Production`})}),(0,Q.jsx)(w,{label:`Type`,children:(0,Q.jsxs)(A,{value:n.type,onValueChange:e=>X({...n,type:e}),children:[(0,Q.jsx)(D,{className:h,children:(0,Q.jsx)(E,{})}),(0,Q.jsx)(O,{className:`rounded-xl border-border bg-popover`,children:L.map(e=>(0,Q.jsx)(k,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})})]}),(0,Q.jsxs)(T,{title:`Endpoint & Auth`,separated:!0,contentClassName:`rounded-lg border-dashed bg-card/30`,children:[(0,Q.jsx)(w,{label:`Base URL`,children:(0,Q.jsx)(p,{value:n.base_url,onChange:e=>X({...n,base_url:e.target.value}),placeholder:`https://api.openai.com/v1`})}),(0,Q.jsx)(w,{label:`Request Preview`,children:(0,Q.jsx)(`div`,{className:b(`w-full select-text rounded-md border px-3 py-2 text-[12px]`,s.error?`border-destructive/20 bg-destructive/8 text-destructive`:`border-border bg-card/30 text-foreground/80`),children:s.error?s.error:s.previewUrl?(0,Q.jsx)(`code`,{className:`select-text font-mono`,children:s.previewUrl}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Enter a base URL to preview`})})}),(0,Q.jsx)(w,{label:`API Key`,children:(0,Q.jsx)(m,{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)(w,{label:`Headers`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(te,{value:n.headers_text,onChange:e=>X({...n,headers_text:e.target.value}),placeholder:`{
2
- "Authorization": "Bearer ..."
3
- }`,spellCheck:!1,className:b(`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)(w,{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)(p,{"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.jsx)(`div`,{className:`border-t border-border pt-8`,children:(0,Q.jsxs)(T,{title:`Models`,contentClassName:`space-y-4 bg-card/30 p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsx)(`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.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void re(),children:[(0,Q.jsx)(o,{className:b(`size-3.5`,f&&`animate-spin`)}),`Fetch Models`]}),(0,Q.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,onClick:pe,children:[(0,Q.jsx)(r,{className:`size-3.5`}),`Add Model`]}),(0,Q.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,disabled:n.models.length===0||f,onClick:K,children:[(0,Q.jsx)(u,{className:`size-3.5`}),`Clear Models`]})]})]}),n.models.length===0?(0,Q.jsxs)(C,{as:`div`,padding:`sm`,className:`border-dashed bg-background/35 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 or add a manual entry.`})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.models.map(e=>{let t=fe[e.model];return(0,Q.jsx)(C,{as:`div`,padding:`sm`,className:`bg-background/35`,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)(ne,{tone:e.source===`manual`?`idle`:`running`,className:`px-2 py-0.5`,children:e.source===`manual`?`Manual`:`Discovered`})]}),(0,Q.jsx)(`p`,{className:`mt-1 select-text text-[11px] leading-relaxed text-muted-foreground`,children:ye(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)(x,{type:`button`,variant:`ghost`,size:`sm`,disabled:t?.state===`running`,onClick:()=>void P(e),children:[(0,Q.jsx)(i,{className:`size-3.5`}),`Test`]}),(0,Q.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>me(e),children:[(0,Q.jsx)(d,{className:`size-3.5`}),`Edit`]}),(0,Q.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>y(e.model),children:[(0,Q.jsx)(u,{className:`size-3.5`}),`Delete`]})]})]})},e.model)})})]})}),!I&&Y?(0,Q.jsx)(`div`,{className:`border-t border-border pt-8`,children:(0,Q.jsx)(T,{title:`Provider`,contentClassName:`rounded-lg border-dashed bg-card/30`,children:(0,Q.jsx)(w,{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.jsx)(c.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)(S,{icon:l,title:`No provider selected`,className:`border-transparent bg-transparent`})})})]}),(0,Q.jsx)(Se,{draft:B,onClose:xe,onDraftChange:ve,onSave:M,state:de}),(0,Q.jsx)(U,{open:t,onOpenChange:t=>{t||e()},children:(0,Q.jsxs)(ce,{children:[(0,Q.jsxs)(H,{children:[(0,Q.jsx)(se,{children:`Clear all models?`}),(0,Q.jsx)(oe,{children:`This removes every model from this provider, including discovered and manual entries. Save the provider to keep the cleared list.`})]}),(0,Q.jsxs)(ue,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(x,{type:`button`,variant:`ghost`,children:`Cancel`})}),(0,Q.jsx)(le,{asChild:!0,children:(0,Q.jsx)(x,{type:`button`,variant:`destructive`,onClick:_,children:`Clear Models`})})]})]})}),(0,Q.jsx)(U,{open:G!==null,onOpenChange:e=>{e||Z(null)},children:(0,Q.jsxs)(ce,{children:[(0,Q.jsxs)(H,{children:[(0,Q.jsx)(se,{children:`Delete provider?`}),(0,Q.jsx)(oe,{children:G?`This will permanently remove ${G.name}.`:`This will permanently remove the selected provider.`})]}),(0,Q.jsxs)(ue,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(x,{variant:`ghost`,children:`Cancel`})}),(0,Q.jsx)(le,{asChild:!0,children:(0,Q.jsx)(x,{variant:`destructive`,onClick:()=>void v(),children:`Delete`})})]})]})})]})})}export{Me as ProvidersPage};
@@ -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{J as r,Lt as i,St as a,X as o,_t as s,pt as c,q as l,qt as u,sn as d,tt as f}from"./ui-vendor-UazN8rcv.js";import{a as p,i as m,n as h,t as g}from"./roles-BbIEIMeG.js";import{G as _,Q as v,W as y,Z as b,a as x,i as S,n as C,q as w,r as T,rt as E,s as D,tt as O,y as k}from"./index-Biio-CoI.js";import{l as A,o as j,s as M}from"./surface-Bzr1FRG4.js";import{a as N,c as ee,n as P,r as F,t as I}from"./PageScaffold-DteOA8V7.js";import{a as L,i as R,n as z,r as B,t as V}from"./select-D9SwnlXF.js";import{a as H,c as U,i as W,n as G,o as te,r as ne,s as re,t as ie}from"./alert-dialog-DIBUCmqM.js";import{i as ae,n as oe,r as se,t as K}from"./modelParams-DcEhGnu0.js";var q=n();function ce({onConfirmDelete:e,onOpenChange:t,roleToDelete:n}){return(0,q.jsx)(ie,{open:n!==null,onOpenChange:t,children:(0,q.jsxs)(W,{children:[(0,q.jsxs)(re,{children:[(0,q.jsx)(U,{children:`Delete role?`}),(0,q.jsx)(H,{children:n?`This will permanently remove ${n.name}.`:`This will permanently remove the selected role.`})]}),(0,q.jsxs)(te,{children:[(0,q.jsx)(ne,{asChild:!0,children:(0,q.jsx)(O,{variant:`ghost`,children:`Cancel`})}),(0,q.jsx)(G,{asChild:!0,children:(0,q.jsx)(O,{variant:`destructive`,onClick:()=>void e(),children:`Delete`})})]})]})})}function le({activeRole:e,draft:t,isReadOnly:n,onUpdateDraft:r,shouldLockIdentityFields:i}){let a=n||i;return(0,q.jsxs)(I,{title:`Identity`,className:`mb-10`,contentClassName:`rounded-lg border-dashed bg-card/30`,children:[(0,q.jsx)(N,{label:`Role Name`,children:(0,q.jsx)(_,{value:t.name,onChange:e=>r(t=>({...t,name:e.target.value})),readOnly:a,placeholder:`e.g., Code Reviewer`,className:E(a?b:``)})}),(0,q.jsx)(N,{label:`Description`,children:(0,q.jsx)(w,{value:t.description,onChange:e=>r(t=>({...t,description:e.target.value})),readOnly:a,placeholder:`Briefly explain what this role is best suited for`,rows:3,className:E(`resize-y`,a?b:``)})}),(0,q.jsx)(N,{label:`System Prompt`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(w,{value:t.system_prompt,onChange:e=>r(t=>({...t,system_prompt:e.target.value})),readOnly:a,placeholder:`You are a helpful assistant that...`,rows:12,className:E(`resize-y`,a?b:``),mono:!0}),a?(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e?.is_builtin||i?`Built-in role fields are locked.`:`View only.`}):null]})})]})}function J({disabled:e,isDefaultSelected:t,onSelectDefault:n,onSelectOverride:r,overrideLabel:i}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:e,onClick:n,className:E(`h-8 rounded-md border px-3 text-[13px] font-medium transition-colors`,t?`border-border bg-accent/45 text-foreground`:`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25`,e&&`cursor-default`),children:`Use Settings Default`}),(0,q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:e,onClick:r,className:E(`h-8 rounded-md border px-3 text-[13px] font-medium transition-colors`,t?`border-transparent bg-card/20 text-muted-foreground hover:bg-accent/25`:`border-border bg-accent/45 text-foreground`,e&&`cursor-default`),children:i}),t?(0,q.jsx)(A,{tone:`muted`,children:`Settings default`}):null]})}function ue({draft:e,isReadOnly:t,onModelParamsModeChange:n,onUpdateDraft:r}){let i=!oe(e.model_params);return(0,q.jsx)(I,{title:`Model Parameters`,className:`mb-10`,separated:!0,contentClassName:`border-transparent bg-transparent p-0 shadow-none`,children:(0,q.jsxs)(`div`,{className:`space-y-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,q.jsx)(J,{disabled:t,isDefaultSelected:!i,onSelectDefault:()=>n(!1),onSelectOverride:()=>n(!0),overrideLabel:`Set Parameter Overrides`}),i?null:(0,q.jsx)(de,{})]}),i?(0,q.jsx)(M,{children:(0,q.jsx)(ae,{value:K(e.model_params),onChange:e=>r(t=>({...t,model_params:e})),disabled:t,emptyLabel:`Inherit settings default`,numberPlaceholder:`Inherit settings default`,reasoningDisableLabel:`Disable`})}):(0,q.jsx)(A,{tone:`muted`,children:`Settings default`})]})})}function de(){return(0,q.jsx)(S,{delayDuration:150,children:(0,q.jsxs)(C,{children:[(0,q.jsx)(x,{asChild:!0,children:(0,q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`rounded-full text-muted-foreground hover:bg-accent/35 hover:text-foreground`,"aria-label":`Parameter override details`,children:(0,q.jsx)(i,{className:`size-3.5`})})}),(0,q.jsx)(T,{className:`max-w-xs`,children:`Overrides affect this role only. Unsupported fields may be ignored.`})]})})}function fe({availableProviderModels:e,draft:t,isReadOnly:n,onModelModeChange:r,onOpenProvidersPage:i,onProviderChange:a,onUpdateDraft:o,providers:s}){return(0,q.jsx)(I,{title:`Model Configuration`,className:`mb-10`,separated:!0,contentClassName:`border-transparent bg-transparent p-0 shadow-none`,children:(0,q.jsxs)(`div`,{className:`space-y-6`,children:[(0,q.jsx)(J,{disabled:n,isDefaultSelected:t.model===null,onSelectDefault:()=>r(!1),onSelectOverride:()=>r(!0),overrideLabel:`Set Role Override`}),t.model?(0,q.jsx)(M,{children:(0,q.jsxs)(`div`,{className:`grid gap-6 md: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:`Provider`}),(0,q.jsxs)(V,{value:t.model.provider_id||void 0,onValueChange:a,disabled:n,children:[(0,q.jsx)(R,{className:v,children:(0,q.jsx)(L,{placeholder:`Select a provider`})}),(0,q.jsx)(z,{className:`rounded-xl border-border bg-popover`,children:s.map(e=>(0,q.jsx)(B,{value:e.id,className:`text-[13px]`,children:e.name},e.id))})]})]}),(0,q.jsx)(pe,{availableProviderModels:e,draft:t,isReadOnly:n,onOpenProvidersPage:i,onUpdateDraft:o}),(0,q.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Model ID`}),(0,q.jsx)(_,{value:t.model.model,onChange:e=>o(t=>({...t,model:t.model?{...t.model,model:e.target.value}:null})),readOnly:n,placeholder:`e.g., gpt-4o-mini`,className:E(n?b:``),mono:!0}),(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Catalog or manual ID`})]})]})}):(0,q.jsx)(A,{tone:`muted`,children:`Settings default`})]})})}function pe({availableProviderModels:e,draft:t,isReadOnly:n,onOpenProvidersPage:r,onUpdateDraft:i}){let a=e.some(e=>e.model===t.model?.model)?t.model?.model:void 0;return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/80`,children:`Provider Models`}),(0,q.jsxs)(V,{value:a,onValueChange:e=>i(t=>({...t,model:t.model?{...t.model,model:e}:null})),disabled:n||!t.model?.provider_id||e.length===0,children:[(0,q.jsx)(R,{className:v,children:(0,q.jsx)(L,{placeholder:e.length>0?`Pick a provider model`:`No saved provider models`})}),(0,q.jsx)(z,{className:`max-h-[300px] rounded-xl border-border bg-popover`,children:e.map(e=>(0,q.jsx)(B,{value:e.model,className:`text-[13px]`,children:e.model},e.model))})]}),e.length===0?(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`No saved provider models.`}),(0,q.jsx)(O,{type:`button`,variant:`outline`,size:`xs`,onClick:r,children:`Open Providers`})]}):null]})}function me({configurableTools:e,getToolState:t,isReadOnly:n,onToolStateCycle:r,shouldLockIdentityFields:i}){return(0,q.jsx)(I,{title:`Tool Configuration`,className:`mb-10`,separated:!0,contentClassName:`bg-card/30`,children:e.map(e=>(0,q.jsx)(he,{isDisabled:n||i,onToolStateCycle:r,state:t(e.name),tool:e},e.name))})}function he({isDisabled:e,onToolStateCycle:t,state:n,tool:r}){return(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b border-border px-5 py-4 last:border-b-0`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,title:r.description,children:[(0,q.jsx)(`p`,{className:`font-mono text-[13px] text-foreground/80`,children:r.name}),(0,q.jsx)(`p`,{className:`mt-1 truncate text-[12px] text-muted-foreground`,children:r.description})]}),(0,q.jsx)(O,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>t(r.name),disabled:e,className:E(`shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors`,n===`included`&&`bg-accent/50 text-foreground`,n===`excluded`&&`bg-transparent text-muted-foreground line-through`,n===`allowed`&&`bg-accent/20 text-muted-foreground hover:bg-accent/35`,e&&`cursor-default hover:bg-inherit opacity-60`),children:n===`allowed`?`Allowed`:n===`included`?`Included`:`Excluded`})]})}function ge({activeRole:e,availableProviderModels:t,canSave:n,configurableTools:r,draft:i,getToolState:a,isReadOnly:o,onClosePanel:s,onEditRole:c,onModelModeChange:l,onModelParamsModeChange:u,onOpenProvidersPage:d,onProviderChange:f,onSaveRole:p,onToolStateCycle:m,onUpdateDraft:h,panelBadgeLabel:g,panelMode:_,panelTitle:v,providers:y,saving:b,shouldLockIdentityFields:x}){return(0,q.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none`,children:(0,q.jsxs)(`div`,{className:`mx-auto max-w-3xl pb-10`,children:[(0,q.jsx)(_e,{badgeLabel:g,onClosePanel:s,title:v}),(0,q.jsx)(le,{activeRole:e,draft:i,isReadOnly:o,onUpdateDraft:h,shouldLockIdentityFields:x}),(0,q.jsx)(fe,{availableProviderModels:t,draft:i,isReadOnly:o,onModelModeChange:l,onOpenProvidersPage:d,onProviderChange:f,onUpdateDraft:h,providers:y}),(0,q.jsx)(ue,{draft:i,isReadOnly:o,onModelParamsModeChange:u,onUpdateDraft:h}),(0,q.jsx)(me,{configurableTools:r,getToolState:a,isReadOnly:o,onToolStateCycle:m,shouldLockIdentityFields:x}),(0,q.jsx)(ve,{activeRole:e,canSave:n,isReadOnly:o,onClosePanel:s,onEditRole:c,onSaveRole:p,panelMode:_,saving:b})]})})}function _e({badgeLabel:e,onClosePanel:t,title:n}){return(0,q.jsxs)(M,{as:`div`,padding:`sm`,className:`mb-8 flex items-center justify-between px-5 py-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(A,{tone:`neutral`,className:`py-0.5 text-[11px]`,children:e}),(0,q.jsx)(`h2`,{className:`text-[15px] font-medium text-foreground`,children:n})]}),(0,q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:t,className:`text-muted-foreground hover:bg-accent/45 hover:text-foreground`,children:(0,q.jsx)(r,{className:`size-3.5`})})]})}function ve({activeRole:e,canSave:t,isReadOnly:n,onClosePanel:r,onEditRole:i,onSaveRole:a,panelMode:o,saving:s}){return(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border pt-6`,children:[(0,q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:s,children:`Cancel`}),n?null:(0,q.jsx)(O,{type:`button`,size:`sm`,onClick:()=>void a(),disabled:!t,children:s?`Saving...`:o===`create`?`Create Role`:`Save Changes`}),n&&e&&!e.is_builtin?(0,q.jsx)(O,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>i(e),children:`Edit Role`}):null]})}var ye=new Set([`idle`,`sleep`,`todo`,`contacts`]);function Y(){return{name:``,description:``,system_prompt:``,model:null,model_params:null,included_tools:[],excluded_tools:[]}}function X(e){return e?{name:e.name,description:e.description,system_prompt:e.system_prompt,model:e.model?{provider_id:e.model.provider_id,model:e.model.model}:null,model_params:e.model_params?K(e.model_params):null,included_tools:[...e.included_tools],excluded_tools:[...e.excluded_tools]}:Y()}function be(e){return e.filter(e=>!ye.has(e.name))}function xe(e){return Object.fromEntries(e.map(e=>[e.id,e]))}function Z(e,t){return e.included_tools.includes(t)?`included`:e.excluded_tools.includes(t)?`excluded`:`allowed`}function Se(e,t){let n=Z(e,t);return n===`allowed`?{...e,included_tools:[...e.included_tools,t],excluded_tools:e.excluded_tools.filter(e=>e!==t)}:n===`included`?{...e,included_tools:e.included_tools.filter(e=>e!==t),excluded_tools:[...e.excluded_tools,t]}:{...e,included_tools:e.included_tools.filter(e=>e!==t),excluded_tools:e.excluded_tools.filter(e=>e!==t)}}function Ce(e){return e.length===0?null:{provider_id:e[0]?.id??``,model:``}}function we(e){let{activeRoleName:t,draft:n,roles:r}=e,i=n.name.trim();if(!i)return`Role name is required`;if(!n.description.trim())return`Role description is required`;if(!n.system_prompt.trim())return`System prompt is required`;if(n.model){if(!n.model.provider_id.trim())return`Provider is required for a role model override`;if(!n.model.model.trim())return`Model is required for a role model override`}return r.some(e=>e.name===i&&e.name!==t)?`Role name already exists`:null}function Te(e){return{name:e.name.trim(),description:e.description.trim(),system_prompt:e.system_prompt,model:e.model?{provider_id:e.model.provider_id.trim(),model:e.model.model.trim()}:null,model_params:se(e.model_params),included_tools:e.included_tools,excluded_tools:e.excluded_tools}}function Ee(e){return e===`view`}function De(e,t){return e!==`create`&&e!==null&&t?.is_builtin===!0}function Oe(e,t){return e===`create`?`New Role`:t?.is_builtin?`Built-in`:`Custom`}function Q(e,t){return e===`create`?`Create Role`:t?.is_builtin?`Role Details`:t?.name??`Role Details`}function ke(e,t){return!(t||!e.name.trim()||!e.description.trim()||!e.system_prompt.trim())}function Ae(e,t){return e.model?`${t[e.model.provider_id]?.name??e.model.provider_id} / ${e.model.model}`:`Settings default`}function je(e){let t=e.included_tools.length,n=e.excluded_tools.length;return t===0&&n===0?`Default`:[t>0?`+${t}`:null,n>0?`-${n}`:null].filter(Boolean).join(` `)}function Me({activeRole:e,onCreateRole:t,onDeleteRole:n,onEditRole:r,onViewRole:i,providersById:a,roles:c}){return c.length===0?(0,q.jsx)(d.div,{initial:{opacity:0},animate:{opacity:1},className:`flex h-full flex-col items-center justify-center text-center`,children:(0,q.jsx)(j,{icon:o,title:`No roles yet`,action:(0,q.jsxs)(O,{type:`button`,size:`sm`,onClick:t,children:[(0,q.jsx)(s,{className:`size-4`}),`New Role`]}),className:`border-transparent bg-transparent`})}):(0,q.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none`,children:(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-5xl`,children:[(0,q.jsxs)(`div`,{className:`mb-2 grid grid-cols-[260px_1fr_120px_100px] gap-4 px-4 pb-3`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Name`}),(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Model`}),(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Tools`}),(0,q.jsx)(`span`,{})]}),(0,q.jsx)(`div`,{className:`space-y-1`,children:c.map((t,o)=>(0,q.jsx)(Ne,{activeRoleName:e?.name??null,index:o,onDeleteRole:n,onEditRole:r,onViewRole:i,providersById:a,role:t},t.name))})]})})}function Ne({activeRoleName:e,index:t,onDeleteRole:n,onEditRole:r,onViewRole:i,providersById:o,role:s}){return(0,q.jsxs)(d.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:t*.03},className:E(`group grid grid-cols-[220px_1fr_100px_80px] items-center gap-4 rounded-xl px-4 py-3.5 transition-colors`,e===s.name?`bg-accent/25`:`hover:bg-accent/15`),children:[(0,q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:s.name}),s.is_builtin?(0,q.jsx)(A,{tone:`muted`,className:`px-1.5 py-0.5 text-[9px]`,children:`Built-in`}):null]}),(0,q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[12px] leading-relaxed text-muted-foreground`,children:s.description})]}),(0,q.jsx)(`div`,{className:`min-w-0 pr-2`,children:(0,q.jsx)(`span`,{className:`block truncate text-[13px] text-muted-foreground`,children:Ae(s,o)})}),(0,q.jsx)(`div`,{className:`pr-2`,children:(0,q.jsx)(`span`,{className:`font-mono text-[13px] text-muted-foreground`,children:je(s)})}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[(0,q.jsx)(y,{onClick:()=>i(s),"aria-label":`View ${s.name}`,title:`View ${s.name}`,className:`size-7`,children:(0,q.jsx)(u,{className:`size-3.5`})}),(0,q.jsx)(y,{onClick:()=>r(s),"aria-label":`Edit ${s.name}`,title:`Edit ${s.name}`,className:`size-7`,children:(0,q.jsx)(a,{className:`size-3.5`})}),s.is_builtin?null:(0,q.jsx)(y,{onClick:()=>n(s),"aria-label":`Delete ${s.name}`,title:`Delete ${s.name}`,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,q.jsx)(f,{className:`size-3.5`})})]})]})}var $=e(t(),1);function Pe(){let[e,t]=(0,$.useState)(null),[n,r]=(0,$.useState)(null),[i,a]=(0,$.useState)(Y()),[o,s]=(0,$.useState)(!1),[c,u]=(0,$.useState)(null),{data:d,isLoading:f,mutate:_}=ee(`rolesBootstrap`,m),v=(0,$.useMemo)(()=>d?.roles??[],[d?.roles]),y=(0,$.useMemo)(()=>d?.tools??[],[d?.tools]),b=(0,$.useMemo)(()=>d?.providers??[],[d?.providers]),x=(0,$.useMemo)(()=>be(y),[y]),S=(0,$.useMemo)(()=>xe(b),[b]),C=(0,$.useMemo)(()=>n?v.find(e=>e.name===n)??null:null,[n,v]),w=i.model?.provider_id??``,T=(0,$.useMemo)(()=>w?S[w]?.models??[]:[],[w,S]),E=e!==null,D=Ee(e),O=De(e,C),k=Oe(e,C),A=Q(e,C),j=ke(i,o),M=(0,$.useCallback)(e=>{_({roles:e,tools:y,providers:b},!1)},[_,b,y]),N=(0,$.useCallback)(async()=>{await _()},[_]),P=(0,$.useCallback)(()=>{t(null),r(null),a(Y())},[]),F=(0,$.useCallback)(()=>{t(`create`),r(null),a(Y())},[]),I=(0,$.useCallback)(e=>{t(`view`),r(e.name),a(X(e))},[]),L=(0,$.useCallback)(e=>{t(`edit`),r(e.name),a(X(e))},[]),R=(0,$.useCallback)(e=>{a(t=>e(t))},[]),z=(0,$.useCallback)(e=>{if(!e){R(e=>({...e,model:null}));return}if(b.length===0){l.error(`Create a provider before setting a role model`);return}R(e=>({...e,model:e.model??Ce(b)}))},[b,R]),B=(0,$.useCallback)(e=>{R(t=>({...t,model:t.model?{provider_id:e,model:``}:null}))},[R]),V=(0,$.useCallback)(e=>{R(t=>({...t,model_params:e?K(t.model_params):null}))},[R]),H=(0,$.useCallback)(async()=>{let t=we({activeRoleName:n,draft:i,roles:v});if(t){l.error(t);return}s(!0);try{let t=Te(i);if(e===`edit`&&n){let e=await p(n,C?.is_builtin?{model:t.model,model_params:t.model_params}:t);M(v.map(t=>t.name===n?e:t)),l.success(`Role updated`)}else M([await g(t),...v]),l.success(`Role created`);P()}catch(e){l.error(e instanceof Error?e.message:`Failed to save role`)}finally{s(!1)}},[C,n,P,i,e,v,M]),U=(0,$.useCallback)(e=>{u(e)},[]),W=(0,$.useCallback)(()=>{u(null)},[]),G=(0,$.useCallback)(async()=>{if(!c)return;let e=c.name;u(null);try{await h(e),M(v.filter(t=>t.name!==e)),n===e&&P(),l.success(`Role deleted`)}catch(e){l.error(e instanceof Error?e.message:`Failed to delete role`)}},[n,P,c,v,M]);return{activeRole:C,activeRoleName:n,availableActiveProviderModelOptions:T,canSave:j,configurableTools:x,draft:i,isPanelOpen:E,isReadOnly:D,loading:f,panelBadgeLabel:k,panelMode:e,panelTitle:A,providers:b,providersById:S,refreshRoles:N,roleToDelete:c,roles:v,saving:o,shouldLockIdentityFields:O,actions:{clearRoleToDelete:W,closePanel:P,cycleRoleToolState:(0,$.useCallback)(e=>{R(t=>Se(t,e))},[R]),handleDelete:G,handleModelModeChange:z,handleModelParamsModeChange:V,handleProviderChange:B,handleSave:H,openCreate:F,openEdit:L,openView:I,requestDeleteRole:U,updateDraft:R},getToolState:e=>Z(i,e)}}function Fe(){let e=k(),{activeRole:t,availableActiveProviderModelOptions:n,canSave:r,configurableTools:i,draft:a,getToolState:o,isPanelOpen:l,isReadOnly:u,loading:d,panelBadgeLabel:f,panelMode:p,panelTitle:m,providers:h,providersById:g,refreshRoles:_,roleToDelete:v,roles:y,saving:b,shouldLockIdentityFields:x,actions:S}=Pe(),C={...S,openProvidersPage:()=>e?.setCurrentPage(`providers`)};return d&&!l?(0,q.jsx)(D,{label:`Loading roles...`}):(0,q.jsxs)(P,{className:`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)(F,{title:`Roles`,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{type:`button`,variant:`outline`,size:`icon-sm`,onClick:()=>void _(),disabled:d,className:`bg-accent/20 text-muted-foreground hover:bg-accent/45 hover:text-foreground`,children:(0,q.jsx)(c,{className:E(`size-4`,d&&`animate-spin`)})}),(0,q.jsxs)(O,{type:`button`,size:`sm`,onClick:S.openCreate,disabled:l,children:[(0,q.jsx)(s,{className:`size-4`}),`New Role`]})]})}),(0,q.jsx)(`div`,{className:`mt-6 min-h-0 flex-1`,children:l?(0,q.jsx)(ge,{activeRole:t,availableProviderModels:n,canSave:r,configurableTools:i,draft:a,getToolState:o,isReadOnly:u,onClosePanel:S.closePanel,onEditRole:S.openEdit,onModelModeChange:S.handleModelModeChange,onModelParamsModeChange:S.handleModelParamsModeChange,onOpenProvidersPage:C.openProvidersPage,onProviderChange:S.handleProviderChange,onSaveRole:S.handleSave,onToolStateCycle:S.cycleRoleToolState,onUpdateDraft:S.updateDraft,panelBadgeLabel:f,panelMode:p,panelTitle:m,providers:h,saving:b,shouldLockIdentityFields:x}):(0,q.jsx)(Me,{activeRole:t,onCreateRole:S.openCreate,onDeleteRole:S.requestDeleteRole,onEditRole:S.openEdit,onViewRole:S.openView,providersById:g,roles:y})})]}),(0,q.jsx)(ce,{roleToDelete:v,onConfirmDelete:S.handleDelete,onOpenChange:e=>{e||S.clearRoleToDelete()}})]})}export{Fe as RolesPage};