flowent 0.0.5 → 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,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{c as r,d as i,dt as a,l as o,q as s,u as c}from"./ui-vendor-UazN8rcv.js";import{B as l,G as u,J as d,K as f,Q as p,U as m,X as h,Y as g,q as _,rt as v,s as y,tt as b}from"./index-Biio-CoI.js";import{a as x,c as S,i as C,n as w,o as T,r as E,t as D}from"./PageScaffold-DteOA8V7.js";import{a as O,i as k,n as A,r as j,t as M}from"./select-D9SwnlXF.js";import{n as N,r as ee,t as P}from"./triState-DgLlKdRR.js";import{i as F,t as I}from"./modelParams-DcEhGnu0.js";async function L(){return l(`/api/settings/bootstrap`,{errorMessage:`Failed to fetch settings bootstrap`})}async function R(e){return l(`/api/settings`,{method:`POST`,body:e,errorMessage:`Failed to save settings`,map:e=>{if(!e)throw Error(`Failed to save settings`);return{settings:e.settings,reauthRequired:e.reauth_required===!0}}})}var z=e(t(),1),B=n(),V=c,H=z.forwardRef(({className:e,...t},n)=>(0,B.jsx)(o,{ref:n,className:v(`inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground`,e),...t}));H.displayName=o.displayName;var U=z.forwardRef(({className:e,...t},n)=>(0,B.jsx)(i,{ref:n,className:v(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow`,e),...t}));U.displayName=i.displayName;var W=z.forwardRef(({className:e,...t},n)=>(0,B.jsx)(r,{ref:n,className:v(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));W.displayName=r.displayName;var G=1024;function K(e){let t=[],n=new Set;for(let r of e){let e=r.trim();if(!e)continue;let i=e.replace(/\/+$/u,``)||`/`;n.has(i)||(n.add(i),t.push(i))}return t}function q(e,t){return e.find(e=>e.id===t)??null}function J(e,t){return e.find(e=>e.name===t)??null}function Y(e){return e?.models??[]}function X(e,t){return t?e.find(e=>e.model===t)??null:null}function Z(e,t){return e.model.context_window_tokens??t?.context_window_tokens??e.model.resolved_context_window_tokens??null}function Q(e,t){return{input_image:e.model.input_image??t?.input_image??e.model.capabilities?.input_image??!1,output_image:e.model.output_image??t?.output_image??e.model.capabilities?.output_image??!1,structured_output:e.model.structured_output??t?.structured_output??e.model.capabilities?.structured_output??!1}}function te(e,t){if(!e)return null;let n=t.max_output_tokens??1024;return Math.max(1,e-n-G)}function ne(e,t){return e!==null&&t!==null&&e>=t?`Automatic Compact token limit must stay below the known safe input window`:null}function re(e,t){let n=t&&(t.newCode||t.confirmCode)?{new_code:t.newCode,confirm_code:t.confirmCode}:void 0;return{...n?{access:n}:{},working_dir:e.working_dir.trim(),assistant:{role_name:e.assistant.role_name,allow_network:e.assistant.allow_network,write_dirs:K(e.assistant.write_dirs)},leader:e.leader,model:{active_provider_id:e.model.active_provider_id,active_model:e.model.active_model,input_image:e.model.input_image,output_image:e.model.output_image,structured_output:e.model.structured_output,context_window_tokens:e.model.context_window_tokens,timeout_ms:e.model.timeout_ms,retry_policy:e.model.retry_policy,max_retries:e.model.max_retries,retry_initial_delay_seconds:e.model.retry_initial_delay_seconds,retry_max_delay_seconds:e.model.retry_max_delay_seconds,retry_backoff_cap_retries:e.model.retry_backoff_cap_retries,auto_compact_token_limit:e.model.auto_compact_token_limit,params:e.model.params}}}var ie=[{value:`no_retry`,label:`No retry`},{value:`limited`,label:`Limited`},{value:`unlimited`,label:`Unlimited`}];function ae({accessDraftError:e,onSave:t,saving:n,settings:r}){return(0,B.jsx)(E,{title:`Settings`,actions:(0,B.jsxs)(b,{type:`button`,size:`sm`,onClick:t,disabled:n||!!e||!r.working_dir.trim(),className:`text-[13px]`,children:[(0,B.jsx)(a,{className:`size-4`}),n?`Saving...`:`Save Changes`]}),className:`mb-8`})}function oe({accessDraft:e,accessDraftError:t,onAccessDraftChange:n}){let r=!!(e.newCode.trim()||e.confirmCode.trim());return(0,B.jsxs)(D,{title:`Access Configuration`,className:`mt-8 first:mt-0`,children:[(0,B.jsx)(T,{label:`New Access Code`,children:(0,B.jsxs)(`div`,{className:`space-y-2 w-full max-w-lg`,children:[(0,B.jsx)(d,{id:`new-access-code`,value:e.newCode,onChange:e=>n(t=>({...t,newCode:e.target.value})),placeholder:`Leave empty to keep`,showLabel:`Show new access code`,hideLabel:`Hide new access code`,buttonSize:`default`}),r?(0,B.jsx)(`p`,{className:g,children:`Saving signs you out; use the new code to return.`}):null]})}),(0,B.jsx)(T,{label:`Confirm Access Code`,children:(0,B.jsxs)(`div`,{className:`space-y-2 w-full max-w-lg`,children:[(0,B.jsx)(d,{id:`confirm-access-code`,value:e.confirmCode,onChange:e=>n(t=>({...t,confirmCode:e.target.value})),placeholder:`Repeat the new access code`,showLabel:`Show confirmed access code`,hideLabel:`Hide confirmed access code`,buttonSize:`default`}),t?(0,B.jsx)(`p`,{className:v(`text-destructive font-medium pt-1`,g),children:t}):null]})})]})}function $({onSettingsChange:e,settings:t}){return(0,B.jsxs)(D,{title:`Path Configuration`,className:`mt-10`,children:[(0,B.jsx)(T,{label:`App Data Directory`,children:(0,B.jsxs)(`div`,{className:`space-y-2 max-w-lg`,children:[(0,B.jsx)(u,{"aria-label":`App Data Directory`,value:t.app_data_dir,readOnly:!0,mono:!0}),(0,B.jsx)(`p`,{className:g,children:`Read-only while Flowent is running.`})]})}),(0,B.jsx)(T,{label:`Working Directory`,children:(0,B.jsxs)(`div`,{className:`space-y-2 max-w-lg`,children:[(0,B.jsx)(u,{"aria-label":`Working Directory`,value:t.working_dir,onChange:t=>e(e=>({...e,working_dir:t.target.value})),placeholder:`/workspace/project`,mono:!0}),(0,B.jsx)(`p`,{className:g,children:`Changing this does not expand saved allowed folders.`}),(0,B.jsx)(`div`,{className:v(`space-y-2`,g),children:t.working_dir.trim()?null:(0,B.jsx)(`p`,{className:`text-destructive`,children:`Working Directory must not be empty.`})})]})})]})}function se({assistantRole:e,onSettingsChange:t,roles:n,settings:r}){return(0,B.jsxs)(D,{title:`Assistant Configuration`,children:[(0,B.jsx)(x,{label:`Assistant Role`,children:(0,B.jsxs)(`div`,{className:`w-full`,children:[(0,B.jsxs)(M,{value:r.assistant.role_name,onValueChange:e=>t(t=>({...t,assistant:{...t.assistant,role_name:e}})),children:[(0,B.jsx)(k,{className:p,children:(0,B.jsx)(O,{placeholder:`Select a role`})}),(0,B.jsx)(A,{children:n.map(e=>(0,B.jsx)(j,{value:e.name,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start`,children:[(0,B.jsx)(`span`,{children:e.name}),(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.description})]})},e.name))})]}),e?(0,B.jsx)(`div`,{"data-testid":`assistant-role-guidance`,className:v(`mt-2`,g),children:(0,B.jsx)(`p`,{children:e.description})}):null]})}),(0,B.jsx)(x,{label:`Network Access`,children:(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(f,{checked:r.assistant.allow_network,label:`Network Access`,onCheckedChange:e=>t(t=>({...t,assistant:{...t.assistant,allow_network:e}})),showStateText:!0}),r.assistant.allow_network?null:(0,B.jsx)(`p`,{className:g,children:`Assistant cannot connect to the web.`})]})}),(0,B.jsx)(T,{label:`Write Directories`,children:(0,B.jsxs)(`div`,{className:`space-y-2 max-w-xl`,children:[(0,B.jsx)(_,{"aria-label":`Write Dirs`,value:r.assistant.write_dirs.join(`
2
- `),onChange:e=>t(t=>({...t,assistant:{...t.assistant,write_dirs:e.target.value.split(`
3
- `)}})),rows:4,spellCheck:!1,placeholder:`/workspace/output`,className:`min-h-[108px]`,mono:!0}),(0,B.jsx)(`p`,{className:g,children:`One absolute folder path per line.`})]})})]})}function ce({leaderRole:e,onSettingsChange:t,roles:n,settings:r}){return(0,B.jsx)(D,{title:`Leader Configuration`,className:`mt-10`,children:(0,B.jsx)(x,{label:`Leader Role`,children:(0,B.jsxs)(`div`,{className:`w-full`,children:[(0,B.jsxs)(M,{value:r.leader.role_name,onValueChange:e=>t(t=>({...t,leader:{role_name:e}})),children:[(0,B.jsx)(k,{className:p,children:(0,B.jsx)(O,{placeholder:`Select a role`})}),(0,B.jsx)(A,{children:n.map(e=>(0,B.jsx)(j,{value:e.name,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start`,children:[(0,B.jsx)(`span`,{children:e.name}),(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.description})]})},e.name))})]}),e?(0,B.jsx)(`p`,{className:v(`mt-2`,g),children:e.description}):null]})})})}function le({activeProvider:e,activeProviderModels:t,availableActiveProviderModels:n,effectiveContextWindowTokens:r,effectiveModelCapabilities:i,knownSafeInputTokens:a,onSettingsChange:o,providers:s,settings:c}){return(0,B.jsxs)(D,{title:`Model Configuration`,className:`mt-10`,children:[(0,B.jsxs)(x,{label:`Active Provider`,children:[(0,B.jsxs)(M,{value:c.model.active_provider_id,onValueChange:e=>{o(t=>({...t,model:{...t.model,active_provider_id:e,active_model:``}}))},children:[(0,B.jsx)(k,{className:p,children:(0,B.jsx)(O,{placeholder:`Select a provider`})}),(0,B.jsx)(A,{children:s.map(e=>(0,B.jsxs)(j,{value:e.id,children:[e.name,` (`,ee(e.type),`)`]},e.id))})]}),e?(0,B.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Using `,e.name,` (`,e.base_url,`)`]}):null]}),(0,B.jsxs)(x,{label:`Model`,children:[(0,B.jsxs)(`div`,{className:`space-y-3`,children:[c.model.active_provider_id?t.length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:h,children:`Provider Models`}),(0,B.jsxs)(M,{value:n.some(e=>e.model===c.model.active_model)?c.model.active_model:void 0,onValueChange:e=>o(t=>({...t,model:{...t.model,active_model:e}})),children:[(0,B.jsx)(k,{className:p,children:(0,B.jsx)(O,{placeholder:`Select a provider model`})}),(0,B.jsx)(A,{children:n.map(e=>(0,B.jsx)(j,{value:e.model,children:e.model},e.model))})]})]}):(0,B.jsx)(`p`,{className:g,children:`No saved provider models.`}):null,(0,B.jsx)(u,{value:c.model.active_model,onChange:e=>o(t=>({...t,model:{...t.model,active_model:e.target.value}})),placeholder:c.model.active_provider_id?`Enter model ID manually`:`Select a provider first`})]}),c.model.active_model?(0,B.jsxs)(`div`,{className:v(`mt-2 space-y-1`,g),children:[(0,B.jsxs)(`p`,{children:[`Context window:`,` `,r?r.toLocaleString():`Not resolved`]}),(0,B.jsxs)(`p`,{children:[`Capabilities: input_image=`,i.input_image?`true`:`false`,`, output_image=`,i.output_image?`true`:`false`,`, structured_output=`,i.structured_output?`true`:`false`]})]}):null]}),(0,B.jsx)(T,{label:`Model Metadata Overrides`,children:(0,B.jsx)(`div`,{className:`space-y-3 w-full`,children:(0,B.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{htmlFor:`model-context-window`,className:h,children:`Context Window`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{id:`model-context-window`,"aria-label":`Context Window`,inputMode:`numeric`,pattern:`[0-9]*`,value:c.model.context_window_tokens===null?``:String(c.model.context_window_tokens),onChange:e=>{let t=e.target.value.trim();/^\d*$/.test(t)&&(t&&Number.parseInt(t,10)<=0||o(e=>({...e,model:{...e.model,context_window_tokens:t?Number.parseInt(t,10):null}})))},placeholder:`Auto`,mono:!0}),(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`tokens`})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{className:h,children:`Input Image`}),(0,B.jsxs)(M,{value:N(c.model.input_image),onValueChange:e=>o(t=>({...t,model:{...t.model,input_image:P(e)}})),children:[(0,B.jsx)(k,{"aria-label":`Input Image`,className:p,children:(0,B.jsx)(O,{placeholder:`Auto`})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(j,{value:`auto`,children:`Auto`}),(0,B.jsx)(j,{value:`enabled`,children:`Enabled`}),(0,B.jsx)(j,{value:`disabled`,children:`Disabled`})]})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{className:h,children:`Output Image`}),(0,B.jsxs)(M,{value:N(c.model.output_image),onValueChange:e=>o(t=>({...t,model:{...t.model,output_image:P(e)}})),children:[(0,B.jsx)(k,{"aria-label":`Output Image`,className:p,children:(0,B.jsx)(O,{placeholder:`Auto`})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(j,{value:`auto`,children:`Auto`}),(0,B.jsx)(j,{value:`enabled`,children:`Enabled`}),(0,B.jsx)(j,{value:`disabled`,children:`Disabled`})]})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{className:h,children:`Structured Output`}),(0,B.jsxs)(M,{value:N(c.model.structured_output??null),onValueChange:e=>o(t=>({...t,model:{...t.model,structured_output:P(e)}})),children:[(0,B.jsx)(k,{"aria-label":`Structured Output`,className:p,children:(0,B.jsx)(O,{placeholder:`Auto`})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(j,{value:`auto`,children:`Auto`}),(0,B.jsx)(j,{value:`enabled`,children:`Enabled`}),(0,B.jsx)(j,{value:`disabled`,children:`Disabled`})]})]})]})]})})}),(0,B.jsx)(T,{label:`Default Model Parameters`,children:(0,B.jsx)(`div`,{className:`rounded-xl border border-border bg-card/30 p-5`,children:(0,B.jsx)(F,{className:`w-full`,value:I(c.model.params),onChange:e=>o(t=>({...t,model:{...t.model,params:e}})),emptyLabel:`Not set`,numberPlaceholder:`Not set`,reasoningDisableLabel:null})})}),(0,B.jsx)(x,{label:`Request Timeout`,children:(0,B.jsx)(`div`,{className:`space-y-2 w-full max-w-xs`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{"aria-label":`Request Timeout`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(c.model.timeout_ms),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);!Number.isSafeInteger(n)||n<=0||o(e=>({...e,model:{...e.model,timeout_ms:n}}))},mono:!0}),(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`ms`})]})})}),(0,B.jsx)(T,{label:`Retry Strategy`,children:(0,B.jsxs)(C,{className:`max-w-3xl`,children:[(0,B.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[1fr_2fr]`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{className:h,children:`Policy`}),(0,B.jsxs)(M,{value:c.model.retry_policy,onValueChange:e=>o(t=>({...t,model:{...t.model,retry_policy:e}})),children:[(0,B.jsx)(k,{className:p,children:(0,B.jsx)(O,{placeholder:`Select a retry policy`})}),(0,B.jsx)(A,{children:ie.map(e=>(0,B.jsx)(j,{value:e.value,children:e.label},e.value))})]})]}),c.model.retry_policy===`limited`?(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{htmlFor:`retry-attempts`,className:h,children:`Max Attempts`}),(0,B.jsx)(u,{id:`retry-attempts`,"aria-label":`Retry Attempts`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(c.model.max_retries),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);!Number.isSafeInteger(n)||n<=0||o(e=>({...e,model:{...e.model,max_retries:n}}))},mono:!0})]}):(0,B.jsx)(`div`,{})]}),(0,B.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3 mt-2 border-t border-border/40 pt-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{htmlFor:`retry-initial-delay`,className:h,children:`Initial Delay`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{id:`retry-initial-delay`,"aria-label":`Initial Delay`,inputMode:`decimal`,value:String(c.model.retry_initial_delay_seconds),onChange:e=>{let t=e.target.value.trim();if(!/^\d+(\.\d+)?$/.test(t))return;let n=Number.parseFloat(t);!Number.isFinite(n)||n<=0||o(e=>({...e,model:{...e.model,retry_initial_delay_seconds:n}}))},mono:!0}),(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`s`})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{htmlFor:`retry-max-delay`,className:h,children:`Max Delay`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{id:`retry-max-delay`,"aria-label":`Max Delay`,inputMode:`decimal`,value:String(c.model.retry_max_delay_seconds),onChange:e=>{let t=e.target.value.trim();if(!/^\d+(\.\d+)?$/.test(t))return;let n=Number.parseFloat(t);!Number.isFinite(n)||n<=0||o(e=>({...e,model:{...e.model,retry_max_delay_seconds:n}}))},mono:!0}),(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`s`})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{htmlFor:`retry-backoff-cap-retries`,className:h,children:`Cap Retries`}),(0,B.jsx)(u,{id:`retry-backoff-cap-retries`,"aria-label":`Cap Retries`,inputMode:`numeric`,pattern:`[0-9]*`,value:String(c.model.retry_backoff_cap_retries),onChange:e=>{let t=e.target.value.trim();if(!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);!Number.isSafeInteger(n)||n<=0||o(e=>({...e,model:{...e.model,retry_backoff_cap_retries:n}}))},mono:!0})]})]})]})}),(0,B.jsx)(T,{label:`Automatic Compact`,children:(0,B.jsxs)(`div`,{className:`space-y-3 w-full max-w-sm`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`label`,{htmlFor:`auto-compact-token-limit`,className:h,children:`Token Limit`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{id:`auto-compact-token-limit`,"aria-label":`Automatic Compact Token Limit`,inputMode:`numeric`,pattern:`[0-9]*`,value:c.model.auto_compact_token_limit===null?``:String(c.model.auto_compact_token_limit),onChange:e=>{let t=e.target.value.trim();/^\d*$/.test(t)&&(t&&Number.parseInt(t,10)<=0||o(e=>({...e,model:{...e.model,auto_compact_token_limit:t?Number.parseInt(t,10):null}})))},placeholder:`Disabled`,mono:!0}),(0,B.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:`tokens`})]})]}),a===null?c.model.auto_compact_token_limit===null?null:(0,B.jsx)(`p`,{className:`text-[11px] leading-relaxed text-graph-status-idle`,children:`The current model window is not resolved, so this token limit can be saved but cannot be fully validated yet.`}):(0,B.jsxs)(`p`,{className:g,children:[`Known safe input window: `,a.toLocaleString(),` `,`tokens.`,c.model.auto_compact_token_limit!==null&&c.model.auto_compact_token_limit>=a?` Save is blocked until the token limit is lower than this window.`:null]})]})})]})}function ue({appVersion:e}){return(0,B.jsx)(`div`,{className:`mt-12 flex flex-col items-center pt-2 pb-6 text-center`,children:(0,B.jsxs)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`Flowent Agent Studio v`,e??`—`]})})}function de(){let{requireReauth:e}=m(),{data:t,isLoading:n,mutate:r}=S(`settingsBootstrap`,()=>L()),[i,a]=(0,z.useState)(null),[o,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)({newCode:``,confirmCode:``}),d=(0,z.useMemo)(()=>t?.providers??[],[t?.providers]),f=(0,z.useMemo)(()=>t?.roles??[],[t?.roles]),p=t?.version??null;(0,z.useEffect)(()=>{t?.settings&&!i&&a(t.settings)},[t?.settings,i]);let h=i??t?.settings??null,g=(0,z.useCallback)(e=>{a(n=>{let r=n??t?.settings??null;return r?e(r):n})},[t?.settings]),_=(0,z.useCallback)(e=>{u(t=>e(t))},[]),v=(0,z.useMemo)(()=>h?q(d,h.model.active_provider_id):null,[d,h]),y=(0,z.useMemo)(()=>h?J(f,h.assistant.role_name):null,[f,h]),b=(0,z.useMemo)(()=>Y(v),[v]),x=b,C=(0,z.useMemo)(()=>h?X(b,h.model.active_model):null,[b,h]),w=(0,z.useMemo)(()=>h?Z(h,C):null,[C,h]),T=(0,z.useMemo)(()=>h?Q(h,C):{input_image:!1,output_image:!1,structured_output:!1},[C,h]),E=(0,z.useMemo)(()=>h?te(w,h.model.params):null,[w,h]),D=(0,z.useMemo)(()=>h?J(f,h.leader.role_name):null,[f,h]),O=(0,z.useMemo)(()=>!l.newCode&&!l.confirmCode?null:l.newCode.trim()?l.confirmCode===l.newCode?null:`Confirm Access Code must exactly match New Access Code.`:`New Access Code must not be empty.`,[l.confirmCode,l.newCode]);return{accessDraft:l,accessDraftError:O,activeProvider:v,activeProviderModels:b,availableActiveProviderModels:x,appVersion:p,assistantRole:y,effectiveContextWindowTokens:w,effectiveModelCapabilities:T,handleSave:(0,z.useCallback)(async()=>{if(!h)return;if(O){s.error(O);return}if(!h.working_dir.trim()){s.error(`Working Directory must not be empty`);return}if(h.model.retry_max_delay_seconds<h.model.retry_initial_delay_seconds){s.error(`Max Delay must be greater than or equal to Initial Delay`);return}let t=ne(h.model.auto_compact_token_limit,E);if(t){s.error(t);return}c(!0);try{let t=await R(re(h,l)),n=t.settings;if(a(n),u({newCode:``,confirmCode:``}),r(e=>e&&{...e,settings:n},!1),t.reauthRequired){s.success(`Access code updated. Sign in again with the new code.`),e();return}s.success(`Settings saved`)}catch(e){s.error(e instanceof Error?e.message:`Failed to save settings`)}finally{c(!1)}},[l,O,E,r,e,h]),knownSafeInputTokens:E,leaderRole:D,loading:n,providers:d,roles:f,saving:o,settings:h,updateAccessDraft:_,updateSettings:g}}function fe(){let{accessDraft:e,accessDraftError:t,activeProvider:n,activeProviderModels:r,availableActiveProviderModels:i,appVersion:a,assistantRole:o,effectiveContextWindowTokens:s,effectiveModelCapabilities:c,handleSave:l,knownSafeInputTokens:u,leaderRole:d,loading:f,providers:p,roles:m,saving:h,settings:g,updateAccessDraft:_,updateSettings:v}=de();return f||!g?(0,B.jsx)(y,{label:`Loading settings...`,textClassName:`text-[13px]`}):(0,B.jsx)(w,{children:(0,B.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto pr-2 scrollbar-none pb-20`,children:(0,B.jsxs)(`div`,{className:`mx-auto max-w-[680px] pb-10 pt-6`,children:[(0,B.jsx)(ae,{accessDraftError:t,onSave:()=>{l()},saving:h,settings:g}),(0,B.jsxs)(V,{defaultValue:`model`,className:`w-full`,children:[(0,B.jsx)(H,{className:`mb-8 w-full justify-start h-auto flex-wrap bg-transparent p-0 gap-6 border-b border-border/40 rounded-none`,children:[`model`,`assistant`,`leader`,`access`,`path`].map(e=>(0,B.jsx)(U,{value:e,className:`data-[state=active]:bg-transparent data-[state=active]:shadow-none bg-transparent border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-foreground text-muted-foreground rounded-none px-1 pb-2.5 pt-2 hover:text-foreground transition-colors`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,B.jsx)(W,{value:`model`,className:`mt-0`,children:(0,B.jsx)(le,{activeProvider:n,activeProviderModels:r,availableActiveProviderModels:i,effectiveContextWindowTokens:s,effectiveModelCapabilities:c,knownSafeInputTokens:u,onSettingsChange:v,providers:p,settings:g})}),(0,B.jsx)(W,{value:`assistant`,className:`mt-0`,children:(0,B.jsx)(se,{assistantRole:o,onSettingsChange:v,roles:m,settings:g})}),(0,B.jsx)(W,{value:`leader`,className:`mt-0`,children:(0,B.jsx)(ce,{leaderRole:d,onSettingsChange:v,roles:m,settings:g})}),(0,B.jsx)(W,{value:`access`,className:`mt-0`,children:(0,B.jsx)(oe,{accessDraft:e,accessDraftError:t,onAccessDraftChange:_})}),(0,B.jsx)(W,{value:`path`,className:`mt-0`,children:(0,B.jsx)($,{onSettingsChange:v,settings:g})})]}),(0,B.jsx)(ue,{appVersion:a})]})})})}export{fe as SettingsPage};
@@ -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,Gt as i,Ht as a,It as o,J as s,Nt as c,Pt as l,Q as u,Ut as d,Vt as f,Wt as p,X as m,Y as h,Zt as g,at as _,ct as v,nt as y,ot as b,sn as x,ut as S,vt as C,zt as w}from"./ui-vendor-UazN8rcv.js";import{B as T,et as E,ot as D,rt as O,tt as k,y as A}from"./index-Biio-CoI.js";import{i as j,l as M,o as N,s as P,t as F}from"./surface-Bzr1FRG4.js";import{c as I,n as L,r as R}from"./PageScaffold-DteOA8V7.js";async function z(){return T(`/api/tools`,{errorMessage:`Failed to fetch tools`,fallback:[],map:e=>e?.tools??[]})}var B=e(t(),1),V=n(),H={send:v,idle:g,sleep:g,todo:c,contacts:r,list_tools:h,list_roles:m,list_workflows:o,exec:y,read:d,edit:p,fetch:w,create_workflow:a,create_agent:f,connect:l,set_permissions:_,manage_providers:C,manage_roles:u,manage_settings:b,manage_prompts:i};function U(e){let t=e.trim();return t.length<=96?t:`${t.slice(0,93).trimEnd()}...`}function W({expanded:e,onToggle:t,tool:n}){let r=H[n.name]??h;return(0,V.jsxs)(P,{as:`div`,padding:`md`,onClick:t,className:O(`group cursor-pointer transition-colors duration-300 hover:border-ring/25 hover:bg-accent/20 hover:shadow-sm`,e&&`border-border bg-accent/20 shadow-sm`),children:[(0,V.jsx)(j,{icon:r,size:`sm`,className:`mb-4 transition-colors group-hover:bg-accent/40`}),(0,V.jsx)(`code`,{className:`block text-[13px] font-mono font-medium text-foreground`,children:n.name}),(0,V.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground/75`,children:n.source===`mcp`?`MCP · ${n.server_name??`unknown`}`:`Builtin`}),(0,V.jsx)(`p`,{className:`mt-2 line-clamp-1 text-[12px] leading-relaxed text-muted-foreground`,children:U(n.description)}),(0,V.jsx)(D,{initial:!1,children:e?(0,V.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.22,1,.36,1]},className:`overflow-hidden`,onClick:e=>e.stopPropagation(),children:(0,V.jsxs)(`div`,{className:`mt-4 border-t border-border pt-4`,children:[n.source===`mcp`?(0,V.jsxs)(`div`,{className:`mb-4 space-y-2 text-[11px] text-muted-foreground`,children:[(0,V.jsxs)(`div`,{children:[`Raw Tool Name`,` `,(0,V.jsx)(`code`,{className:`font-mono text-foreground/82`,children:n.tool_name??`unknown`})]}),(0,V.jsxs)(`div`,{children:[`Fully Qualified ID`,` `,(0,V.jsx)(`code`,{className:`font-mono text-foreground/82`,children:n.fully_qualified_id??n.name})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n.read_only_hint?(0,V.jsx)(M,{tone:`primary`,children:`readOnly`}):null,n.destructive_hint?(0,V.jsx)(M,{tone:`danger`,children:`destructive`}):null,n.open_world_hint?(0,V.jsx)(M,{tone:`idle`,children:`openWorld`}):null]})]}):null,(0,V.jsx)(`p`,{className:`mb-2 text-[10px] font-medium text-muted-foreground/75`,children:`Parameters`}),(0,V.jsx)(F,{className:`max-h-48 p-3.5 text-foreground/70`,children:JSON.stringify(n.parameters??{},null,2)})]})}):null})]})}function G(){let{data:e=[],isLoading:t}=I(`tools`,z),n=A(),[r,i]=(0,B.useState)(new Set),[a,o]=(0,B.useState)(``),c=a.trim().toLowerCase(),l=(0,B.useMemo)(()=>c?e.filter(e=>[e.name,e.description,e.server_name??``,e.source??``].join(` `).toLowerCase().includes(c)):e,[c,e]),u=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,V.jsx)(L,{children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col px-8 pt-6`,children:[(0,V.jsx)(R,{title:`Tools`}),(0,V.jsxs)(`div`,{className:`mb-6 mt-6 flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,V.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,V.jsx)(E,{value:a,onChange:e=>o(e.target.value),placeholder:`Search tools`,className:`h-9 rounded-full bg-background/45 pl-9 pr-9 text-[13px]`}),a?(0,V.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Clear search`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-full text-muted-foreground hover:bg-accent/35 hover:text-foreground`,onClick:()=>o(``),children:(0,V.jsx)(s,{className:`size-3.5`})}):null]}),(0,V.jsxs)(M,{tone:`neutral`,className:`h-5 text-[11px]`,children:[l.length,` tools`]})]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2 scrollbar-none`,children:t?(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-3`,children:[...[,,,,,,]].map((e,t)=>(0,V.jsx)(P,{as:`div`,className:`h-36 animate-pulse bg-accent/20`},t))}):e.length===0?(0,V.jsx)(x.div,{initial:{opacity:0},animate:{opacity:1},className:`flex h-full flex-col items-center justify-center text-center`,children:(0,V.jsx)(N,{icon:h,title:`No tools available`,action:(0,V.jsx)(k,{type:`button`,size:`sm`,onClick:()=>n?.setCurrentPage(`mcp`),children:`Open MCP`}),className:`border-transparent bg-transparent`})}):l.length===0?(0,V.jsx)(x.div,{initial:{opacity:0},animate:{opacity:1},className:`flex h-full flex-col items-center justify-center text-center`,children:(0,V.jsx)(N,{icon:S,title:`No tools found`,action:(0,V.jsxs)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(``),children:[(0,V.jsx)(s,{className:`size-4`}),`Clear Search`]}),className:`border-transparent bg-transparent`})}):(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-3 pb-8`,children:l.map((e,t)=>(0,V.jsx)(x.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:t*.03},children:(0,V.jsx)(W,{tool:e,expanded:r.has(e.name),onToggle:()=>u(e.name)})},e.name))})})]})})}export{G as ToolsPage};
@@ -1 +0,0 @@
1
- import{l as e}from"./graph-vendor-DRq_-6fV.js";import{J as t}from"./ui-vendor-UazN8rcv.js";import{rt as n,tt as r}from"./index-Biio-CoI.js";import{a as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./dialog-BOvHIBrg.js";var d=e();function f({open:e,onOpenChange:f,title:p,children:m,footer:h,className:g}){return(0,d.jsx)(u,{open:e,onOpenChange:f,children:(0,d.jsx)(c,{className:n(`flex max-h-[calc(100svh-2rem)] flex-col p-0`,g),children:(0,d.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden p-6`,children:[(0,d.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-gradient-to-b from-foreground/[0.04] to-transparent opacity-50`}),(0,d.jsx)(o,{asChild:!0,children:(0,d.jsx)(r,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close dialog`,className:`absolute right-4 top-4 z-20 size-7 rounded-md bg-accent/45 text-muted-foreground hover:bg-accent/65 hover:text-accent-foreground`,children:(0,d.jsx)(t,{className:`size-3.5`})})}),(0,d.jsxs)(s,{className:`relative z-10 shrink-0 pr-8`,children:[(0,d.jsx)(l,{className:`text-[1.1rem] font-medium text-foreground`,children:p}),(0,d.jsx)(a,{className:`sr-only`,children:p})]}),(0,d.jsx)(`div`,{className:`relative z-10 mt-6 min-h-0 flex-1 space-y-4 overflow-y-auto pr-1 scrollbar-none`,"data-testid":`workspace-command-dialog-body`,children:m}),(0,d.jsx)(i,{className:`relative z-10 mt-6 shrink-0 border-t border-border pt-4`,children:h})]})})})}function p({label:e,hint:t,children:n}){return(0,d.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,d.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,d.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:e}),t?(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}):null]}),n]})}function m({children:e}){return(0,d.jsx)(`div`,{className:`rounded-lg border border-border bg-accent/35 px-3.5 py-2.5 text-xs text-muted-foreground`,children:e})}export{p as n,m as r,f as t};
@@ -1,3 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{a as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./graph-vendor-DRq_-6fV.js";import{B as d,Bt as f,Dt as p,Ft as m,G as h,J as g,Kt as _,L as v,U as y,V as b,Yt as x,Z as S,_t as C,dt as w,et as T,gt as ee,ht as te,mt as E,nn as ne,q as D,sn as O,t as k,tt as A,ut as j,z as M}from"./ui-vendor-UazN8rcv.js";import{r as re}from"./roles-BbIEIMeG.js";import{a as N,c as ie,d as P,f as ae,i as F,l as I,n as oe,o as L,p as R,r as se,s as ce,t as le,u as z}from"./WorkspacePanels-BZxBw8M5.js";import{$ as B,A as V,C as ue,D as de,E as H,K as fe,M as pe,N as me,O as he,T as U,_ as ge,d as _e,et as W,f as ve,g as ye,h as be,it as xe,j as Se,k as Ce,l as we,m as Te,o as Ee,ot as De,p as Oe,rt as G,t as ke,tt as K,u as Ae,v as je,w as Me}from"./index-Biio-CoI.js";import{a as Ne,i as q,n as J,r as Pe,t as Fe}from"./select-D9SwnlXF.js";import"./dialog-BOvHIBrg.js";import{n as Y,r as Ie,t as Le}from"./WorkspaceCommandDialog-DRS6wiD6.js";import{a as Re,c as ze,i as Be,n as X,o as Z,r as Ve,s as He,t as Ue}from"./alert-dialog-DIBUCmqM.js";var Q=e(n(),1),We=1,Ge=.9,Ke=.8,qe=.17,Je=.1,Ye=.999,Xe=.9999,Ze=.99,Qe=/[\\\/_+.#"@\[\(\{&]/,$e=/[\\\/_+.#"@\[\(\{&]/g,et=/[\s-]/,tt=/[\s-]/g;function nt(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?We:Ze;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=nt(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=We:Qe.test(e.charAt(l-1))?(d*=Ke,p=e.slice(i,l-1).match($e),p&&i>0&&(d*=Ye**+p.length)):et.test(e.charAt(l-1))?(d*=Ge,m=e.slice(i,l-1).match(tt),m&&i>0&&(d*=Ye**+m.length)):(d*=qe,i>0&&(d*=Ye**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Xe)),(d<Je&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=nt(e,t,n,r,l+1,a+2,o),f*Je>d&&(d=f*Je)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function rt(e){return e.toLowerCase().replace(tt,` `)}function it(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,nt(e,t,rt(e),rt(t),0,0,{})}var at=`[cmdk-group=""]`,ot=`[cmdk-group-items=""]`,st=`[cmdk-group-heading=""]`,ct=`[cmdk-item=""]`,lt=`${ct}:not([aria-disabled="true"])`,ut=`cmdk-item-select`,dt=`data-value`,ft=(e,t,n)=>it(e,t,n),pt=Q.createContext(void 0),mt=()=>Q.useContext(pt),ht=Q.createContext(void 0),gt=()=>Q.useContext(ht),_t=Q.createContext(void 0),vt=Q.forwardRef((e,t)=>{let n=Mt(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Mt(()=>new Set),i=Mt(()=>new Map),a=Mt(()=>new Map),o=Mt(()=>new Set),s=At(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=y(),b=y(),x=y(),S=Q.useRef(null),C=Ft();jt(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),jt(()=>{C(6,D)},[]);let w=Q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)ne(),te(),C(1,E);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=O()?.id,w.emit()}),r||C(5,D),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=Q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,ee(t,r)),C(2,()=>{te(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{ne(),te(),n.current.value||E(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=O();C(4,()=>{ne(),t?.getAttribute(`id`)===e&&E(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:x,labelId:b,listInnerRef:S}),[]);function ee(e,t){let r=s.current?.filter??ft;return e?r(e,n.current.search,t):0}function te(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;A().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(ot);t?t.appendChild(e.parentElement===t?e:e.closest(`${ot} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ot} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${at}[${dt}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function E(){let e=A().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(dt);w.setState(`value`,e||void 0)}function ne(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=ee(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function D(){var e;let t=O();t&&(t.parentElement?.firstChild===t&&((e=t.closest(at)?.querySelector(st))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function O(){return S.current?.querySelector(`${ct}[aria-selected="true"]`)}function A(){return Array.from(S.current?.querySelectorAll(lt)||[])}function j(e){let t=A()[e];t&&w.setState(`value`,t.getAttribute(dt))}function M(e){var t;let n=O(),r=A(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(dt))}function re(e){let t=O()?.closest(at),n;for(;t&&!n;)t=e>0?Ot(t,at):kt(t,at),n=t?.querySelector(lt);n?w.setState(`value`,n.getAttribute(dt)):M(e)}let N=()=>j(A().length-1),ie=e=>{e.preventDefault(),e.metaKey?N():e.altKey?re(1):M(1)},P=e=>{e.preventDefault(),e.metaKey?j(0):e.altKey?re(-1):M(-1)};return Q.createElement(k.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ie(e);break;case`ArrowDown`:ie(e);break;case`p`:case`k`:g&&e.ctrlKey&&P(e);break;case`ArrowUp`:P(e);break;case`Home`:e.preventDefault(),j(0);break;case`End`:e.preventDefault(),N();break;case`Enter`:{e.preventDefault();let t=O();if(t){let e=new Event(ut);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:Rt},c),Lt(e,e=>Q.createElement(ht.Provider,{value:w},Q.createElement(pt.Provider,{value:T},e))))}),yt=Q.forwardRef((e,t)=>{let n=y(),r=Q.useRef(null),i=Q.useContext(_t),a=mt(),o=At(e),s=o.current?.forceMount??i?.forceMount;jt(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Pt(n,r,[e.value,e.children,r],e.keywords),l=gt(),u=Nt(e=>e.value&&e.value===c.current),d=Nt(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(ut,f),()=>t.removeEventListener(ut,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:g,onSelect:_,forceMount:v,keywords:b,...x}=e;return Q.createElement(k.div,{ref:h(r,t),...x,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),bt=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=y(),s=Q.useRef(null),c=Q.useRef(null),l=y(),u=mt(),d=Nt(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);jt(()=>u.group(o),[]),Pt(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(k.div,{ref:h(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Lt(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(_t.Provider,{value:f},e))))}),xt=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=Nt(e=>!e.search);return!n&&!a?null:Q.createElement(k.div,{ref:h(i,t),...r,"cmdk-separator":``,role:`separator`})}),St=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=gt(),o=Nt(e=>e.search),s=Nt(e=>e.selectedItemId),c=mt();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(k.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Ct=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=Nt(e=>e.selectedItemId),c=mt();return Q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Q.createElement(k.div,{ref:h(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Lt(e,e=>Q.createElement(`div`,{ref:h(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),wt=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(b,{open:n,onOpenChange:r},Q.createElement(d,{container:o},Q.createElement(M,{"cmdk-overlay":``,className:i}),Q.createElement(v,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(vt,{ref:t,...s}))))}),Tt=Q.forwardRef((e,t)=>Nt(e=>e.filtered.count===0)?Q.createElement(k.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Et=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(k.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Lt(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),Dt=Object.assign(vt,{List:Ct,Item:yt,Input:St,Group:bt,Separator:xt,Dialog:wt,Empty:Tt,Loading:Et});function Ot(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function kt(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function At(e){let t=Q.useRef(e);return jt(()=>{t.current=e}),t}var jt=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Mt(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function Nt(e){let t=gt(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function Pt(e,t,n,r=[]){let i=Q.useRef(),a=mt();return jt(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(dt,s),i.current=s}),i}var Ft=()=>{let[e,t]=Q.useState(),n=Mt(()=>new Map);return jt(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function It(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Lt({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(It(t),{ref:t.ref},n(t.props.children)):n(t)}var Rt={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=i();function zt({className:e,...t}){return(0,$.jsx)(Dt,{"data-slot":`command`,className:G(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function Bt({className:e,...t}){return(0,$.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,$.jsx)(j,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(Dt.Input,{"data-slot":`command-input`,className:G(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function Vt({className:e,...t}){return(0,$.jsx)(Dt.List,{"data-slot":`command-list`,className:G(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function Ht({...e}){return(0,$.jsx)(Dt.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function Ut({className:e,...t}){return(0,$.jsx)(Dt.Group,{"data-slot":`command-group`,className:G(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Wt({className:e,...t}){return(0,$.jsx)(Dt.Item,{"data-slot":`command-item`,className:G(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function Gt({roles:e,loadingRoles:t,selectedRoleName:n,onRoleNameChange:r,className:i}){let a=(0,Q.useMemo)(()=>e.find(e=>e.name===n)??null,[e,n]),o=!!n&&!t&&!a;return(0,$.jsxs)(`div`,{className:G(`grid min-h-0 gap-3 md:grid-cols-[minmax(0,1fr)_16rem]`,i),children:[(0,$.jsxs)(zt,{className:`min-h-[17rem] rounded-xl border border-border bg-background/35`,children:[(0,$.jsx)(Bt,{"aria-label":`Search roles`,placeholder:`Search roles...`,disabled:t||e.length===0}),(0,$.jsx)(Vt,{className:`max-h-[18rem]`,children:t?(0,$.jsx)(`div`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`Loading roles...`}):e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`No roles available.`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{children:`No matching roles.`}),(0,$.jsx)(Ut,{heading:`Roles`,children:e.map(e=>{let t=n===e.name;return(0,$.jsxs)(Wt,{value:`${e.name} ${e.description}`,onSelect:()=>r(e.name),className:G(`items-start gap-3 rounded-md px-3 py-2.5`,t&&`bg-accent/60 text-accent-foreground`),children:[(0,$.jsx)(`span`,{className:G(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,t?`border-primary bg-primary text-primary-foreground`:`border-border text-transparent`),children:(0,$.jsx)(ne,{className:`size-3`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-[13px] font-medium text-foreground`,children:e.name}),(0,$.jsx)(`span`,{className:`mt-1 line-clamp-2 block text-[12px] leading-relaxed text-muted-foreground`,children:e.description})]})]},e.name)})})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-[10rem] rounded-xl border border-border bg-card/35 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] font-medium text-muted-foreground`,children:[(0,$.jsx)(S,{className:`size-4`}),`Selected role`]}),a?(0,$.jsxs)(`div`,{className:`mt-4 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-[15px] font-semibold text-foreground`,children:a.name}),a.is_builtin?(0,$.jsx)(R,{variant:`outline`,className:`h-5 shrink-0`,children:`Built-in`}):null]}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-5 text-[12px] leading-relaxed text-muted-foreground`,children:a.description})]}):(0,$.jsx)(`p`,{className:`mt-4 text-[13px] leading-relaxed text-muted-foreground`,children:o?`Selected role is not available.`:`Choose a role to continue.`})]})]})}var Kt=`bg-background/40 text-foreground shadow-xs placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50`;function qt({allowNetwork:e,onAllowNetworkChange:t,onOpenChange:n,onSubmit:r,onTitleChange:i,onWriteDirsChange:a,open:o,pending:s,title:c,writeDirs:l}){return(0,$.jsxs)(Le,{open:o,onOpenChange:n,title:`Create Workflow`,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`outline`,onClick:()=>n(!1),disabled:s,children:`Cancel`}),(0,$.jsx)(K,{onClick:r,disabled:!c.trim()||s,children:s?`Creating...`:`Create Workflow`})]}),children:[(0,$.jsx)(Y,{label:`Title`,hint:`Shown in the workflow strip`,children:(0,$.jsx)(W,{autoFocus:!0,"aria-label":`Workflow title`,value:c,onChange:e=>i(e.target.value),placeholder:`Release checklist`,className:G(`h-10 rounded-md`,Kt)})}),(0,$.jsx)(Y,{label:`Network Access`,hint:`Allow this workflow to reach external services`,children:(0,$.jsx)(fe,{checked:e,label:`Network Access`,onCheckedChange:t})}),(0,$.jsx)(Y,{label:`Writable Folders`,hint:`One absolute folder path per line`,children:(0,$.jsx)(B,{value:l,"aria-label":`Writable folders`,onChange:e=>a(e.target.value),placeholder:`/workspace/output
2
- /workspace/cache`,className:G(`min-h-[80px] rounded-md font-mono text-[13px]`,Kt)})})]})}var Jt={agent:`Agent`,trigger:`Trigger`,llm:`Model`,code:`Code`,if:`If`,merge:`Merge`};function Yt({activeTabTitle:e,nodeName:t,nodeType:n,roles:r,loadingRoles:i,onNodeNameChange:a,onNodeTypeChange:o,onOpenChange:s,onRoleNameChange:c,onSubmit:l,open:u,pending:d,selectedRoleName:f,submitDisabled:p}){return(0,$.jsxs)(Le,{open:u,onOpenChange:s,title:`Add Node`,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`outline`,onClick:()=>s(!1),disabled:d,children:`Cancel`}),(0,$.jsx)(K,{onClick:l,disabled:p,children:d?`Adding...`:`Add Node`})]}),children:[(0,$.jsxs)(Ie,{children:[`Adding a node to`,` `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e??`No active workflow`})]}),(0,$.jsx)(Y,{label:`Node Type`,hint:`Required`,children:(0,$.jsxs)(Fe,{value:n,onValueChange:e=>o(e),children:[(0,$.jsx)(q,{"aria-label":`Node Type`,className:G(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Kt),children:(0,$.jsx)(Ne,{placeholder:`Choose node type`})}),(0,$.jsx)(J,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:Object.entries(Jt).map(([e,t])=>(0,$.jsx)(Pe,{value:e,children:t},e))})]})}),n===`agent`?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:`Role`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Required`})]}),(0,$.jsx)(Gt,{roles:r,loadingRoles:i,selectedRoleName:f,onRoleNameChange:c})]}):null,(0,$.jsx)(Y,{label:`Display Name`,hint:`Optional`,children:(0,$.jsx)(W,{value:t,"aria-label":`Node display name`,onChange:e=>a(e.target.value),placeholder:n===`agent`?`Docs Worker`:`${Jt[n]} Node`,className:G(`h-10 rounded-md`,Kt)})})]})}function Xt({activeTabTitle:e,nodeOptions:t,onFromNodeChange:n,onFromPortChange:r,onOpenChange:i,onSubmit:a,onToNodeChange:o,onToPortChange:s,open:c,pending:l,fromNodeId:u,fromPortKey:d,toNodeId:f,toPortKey:p,fromPortOptions:m,toPortOptions:h}){return(0,$.jsxs)(Le,{open:c,onOpenChange:i,title:`Connect Ports`,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`outline`,onClick:()=>i(!1),disabled:l,children:`Cancel`}),(0,$.jsx)(K,{onClick:a,disabled:!u||!d||!f||!p||l,children:l?`Connecting...`:`Create Edge`})]}),children:[(0,$.jsx)(Ie,{children:e?(0,$.jsxs)($.Fragment,{children:[`Workflow`,` `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e}),` `,`· `,t.length,` nodes available`]}):`No active workflow`}),(0,$.jsx)(Y,{label:`From Node`,hint:`Source node`,children:(0,$.jsxs)(Fe,{value:u,onValueChange:n,children:[(0,$.jsx)(q,{"aria-label":`From Node`,className:G(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Kt),children:(0,$.jsx)(Ne,{placeholder:`Choose source node`})}),(0,$.jsx)(J,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:t.map(e=>(0,$.jsx)(Pe,{value:e.id,children:e.label},e.id))})]})}),(0,$.jsx)(Y,{label:`From Port`,hint:`Output port`,children:(0,$.jsxs)(Fe,{value:d,onValueChange:r,children:[(0,$.jsx)(q,{"aria-label":`From Port`,className:G(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Kt),children:(0,$.jsx)(Ne,{placeholder:`Choose output port`})}),(0,$.jsx)(J,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:m.map(e=>(0,$.jsx)(Pe,{value:e.key,children:e.label},e.key))})]})}),(0,$.jsx)(Y,{label:`To Node`,hint:`Target node`,children:(0,$.jsxs)(Fe,{value:f,onValueChange:o,children:[(0,$.jsx)(q,{"aria-label":`To Node`,className:G(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Kt),children:(0,$.jsx)(Ne,{placeholder:`Choose target node`})}),(0,$.jsx)(J,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:t.filter(e=>e.id!==u).map(e=>(0,$.jsx)(Pe,{value:e.id,children:e.label},e.id))})]})}),(0,$.jsx)(Y,{label:`To Port`,hint:`Input port`,children:(0,$.jsxs)(Fe,{value:p,onValueChange:s,children:[(0,$.jsx)(q,{"aria-label":`To Port`,className:G(`h-10 rounded-md data-[placeholder]:text-muted-foreground`,Kt),children:(0,$.jsx)(Ne,{placeholder:`Choose input port`})}),(0,$.jsx)(J,{className:`rounded-md border-border bg-popover text-popover-foreground`,children:h.map(e=>(0,$.jsx)(Pe,{value:e.key,children:e.label},e.key))})]})})]})}function Zt({onDelete:e,onOpenChange:t,open:n,pending:r,target:i}){return(0,$.jsx)(Ue,{open:n,onOpenChange:t,children:(0,$.jsxs)(Be,{className:`max-w-[30rem]`,children:[(0,$.jsxs)(He,{className:`gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-xl border border-border bg-accent/45 text-foreground shadow-xs`,children:(0,$.jsx)(A,{className:`size-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Destructive Action`}),(0,$.jsx)(ze,{className:`mt-1 text-foreground`,children:`Delete workflow?`})]})]}),(0,$.jsx)(Re,{className:`text-muted-foreground`,children:i?(0,$.jsxs)($.Fragment,{children:[`Remove`,` `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title}),` `,`and clean up its persisted workflow graph.`,typeof i.nodeCount==`number`?` ${i.nodeCount} node${i.nodeCount===1?``:`s`} will be removed with it.`:``]}):`This action cannot be undone.`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ve,{asChild:!0,children:(0,$.jsx)(K,{variant:`outline`,children:`Cancel`})}),(0,$.jsx)(X,{asChild:!0,children:(0,$.jsx)(K,{variant:`destructive`,onClick:e,disabled:r,children:r?`Deleting...`:`Delete Workflow`})})]})]})})}var Qt=(0,Q.memo)(function(e){let{sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:o,targetPosition:s,id:l,data:u}=e,[d]=c({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:s}),f=u??{},p=!!f.active,m=!!f.leaving,h=f.flowDirection===`reverse`?-1:1,g=f.selected===!0,_=h===1?`48`:`0`,v=h===1?`0`:`48`;return(0,$.jsxs)(O.g,{className:`agent-graph-edge-shell`,initial:{opacity:0},animate:{opacity:+!m},transition:{duration:m?.2:.3,ease:`easeInOut`},children:[(0,$.jsx)(a,{id:l,path:d,style:{stroke:p?`var(--graph-edge-active)`:g?`var(--graph-selection)`:`var(--graph-edge)`,strokeWidth:p?2.5:g?2.4:1.5,transition:`stroke 300ms ease, stroke-width 300ms ease, opacity 300ms ease`}}),g&&!p?(0,$.jsx)(O.path,{d,fill:`none`,stroke:`var(--graph-selection)`,strokeWidth:`7`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{opacity:0},animate:{opacity:.16},transition:{duration:.18}}):null,p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O.path,{d,fill:`none`,stroke:`var(--graph-edge-active)`,strokeWidth:`8`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{opacity:0},animate:{opacity:[.1,.3,.1]},transition:{duration:2,repeat:1/0,ease:`easeInOut`}}),(0,$.jsx)(O.path,{d,fill:`none`,stroke:`url(#agent-graph-edge-flow)`,strokeWidth:`3.5`,strokeLinecap:`round`,strokeDasharray:`12 12`,opacity:`0.8`,filter:`url(#agent-graph-edge-glow)`,initial:{opacity:0},animate:{opacity:.8},transition:{duration:.4},children:(0,$.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:_,to:v,dur:`0.8s`,repeatCount:`indefinite`})}),(0,$.jsx)(O.path,{d,fill:`none`,stroke:`var(--graph-edge-active)`,strokeWidth:`5`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{pathLength:.15,pathOffset:h===1?-.2:1.2,opacity:0},animate:{pathOffset:h===1?1.2:-.2,opacity:[0,1,1,0]},transition:{duration:1.5,ease:`easeInOut`,repeat:1/0,repeatType:`loop`,times:[0,.1,.9,1]}}),(0,$.jsx)(O.path,{d,fill:`none`,stroke:`var(--graph-attention)`,strokeWidth:`2.5`,strokeLinecap:`round`,filter:`url(#agent-graph-edge-glow)`,initial:{pathLength:.08,pathOffset:h===1?-.23:1.23,opacity:0},animate:{pathOffset:h===1?1.17:-.17,opacity:[0,.9,.9,0]},transition:{duration:1.5,ease:`easeInOut`,repeat:1/0,repeatType:`loop`,times:[0,.1,.9,1],delay:.03}})]})]})}),$t=.3,en=.05,tn=`rounded-md border border-border bg-popover px-3 py-1 text-[11px] font-medium text-popover-foreground shadow-sm`,nn=`__node-body-source`,rn=`__node-body-target`;function an(e){return e.kind===`standalone`?`Add Agent`:e.kind===`between`?`Insert Agent Between`:`Add Agent After`}function on(e){if(`clientX`in e)return{x:e.clientX,y:e.clientY};let t=e.changedTouches[0]??e.touches[0];return t?{x:t.clientX,y:t.clientY}:null}var sn={running:`border-graph-status-running/28`,idle:`border-graph-node-border`,sleeping:`border-graph-status-sleeping/26`,initializing:`border-border border-dashed`,error:`border-graph-status-error/28 border-double`,terminated:`border-border/70`};function cn(e,t=!1){return e===`assistant`?`rounded-sm border-graph-node-border bg-accent/60 text-foreground`:G(`rounded-sm border-graph-node-border bg-surface-3`,t?`text-primary`:`text-foreground/80`)}var ln=(0,Q.memo)(function({data:e}){let{label:t,node_type:n,is_leader:r,state:i,latestTodo:a,selected:c,toolCall:l,canConnect:u,showConnectionEntryHint:d,connectionState:f,inputPorts:p,outputPorts:m}=e,h=!!e.leaving,g=I[n],_=(0,Q.useRef)(null),v=(e,t)=>{if(!_.current)return;let n=_.current.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,a=e-r,o=t-i,s=Math.sqrt(a*a+o*o),c=Math.max(0,1-s/240),l=Math.atan2(o,a)*180/Math.PI+90;_.current.style.setProperty(`--mouse-angle`,`${l}deg`),_.current.style.setProperty(`--mouse-intensity`,c.toString())},y=()=>{_.current&&(_.current.style.setProperty(`--mouse-angle`,`135deg`),_.current.style.setProperty(`--mouse-intensity`,`0`))},b=!!l,x=i===`running`,S=b?`border-graph-attention/70`:sn[i],C=c?`ring-1 ring-graph-selection/25 border-graph-selection/80`:G(S,`hover:border-graph-node-border-hover`),w=f===`source`?`ring-2 ring-graph-selection/35 border-graph-selection/90`:f===`valid-target`?`border-graph-selection/55 shadow-[0_0_0_1px_var(--graph-glow)]`:f===`invalid-target`?`opacity-45`:``,T=d||f===`source`,ee=u&&f===null,te=u&&(f===`valid-target`||f===`invalid-target`),E=f===`source`?`border-graph-selection/75 bg-graph-selection/14 shadow-[0_0_0_1px_var(--graph-glow),0_0_24px_var(--graph-glow)]`:f===`valid-target`?`border-graph-selection/45 bg-graph-selection/10 shadow-[0_0_0_1px_var(--graph-glow),0_0_18px_var(--graph-glow)]`:f===`invalid-target`?`border-graph-node-border bg-graph-node-bg/50`:`border-graph-node-border bg-graph-node-bg/72`;return(0,$.jsxs)(O.div,{ref:_,initial:{opacity:0,scale:.92,filter:`blur(6px) grayscale(0%)`},animate:{opacity:h?0:i===`terminated`?.4:1,scale:h?.9:1,y:h?8:0,filter:h?`blur(8px) grayscale(100%)`:i===`terminated`?`blur(0px) grayscale(100%)`:`blur(0px) grayscale(0%)`},transition:{duration:h?.28:.35,ease:[.23,1,.32,1]},onMouseEnter:e=>v(e.clientX,e.clientY),onMouseMove:e=>v(e.clientX,e.clientY),onMouseLeave:y,className:G(`relative isolate flex h-14 w-max min-w-[100px] max-w-[300px] items-center gap-2 overflow-visible rounded-[10px] border px-2.5 py-2.5`,`shadow-[0_10px_24px_var(--shell-scrim)]`,`bg-graph-node-bg`,`transition-[border-color] duration-300`,h&&`pointer-events-none`,C,w),style:{"--mouse-angle":`135deg`,"--mouse-intensity":`0`},children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:G(`agent-state-ring`,P[i])}),(0,$.jsx)(`div`,{"aria-hidden":`true`,className:G(`agent-loading-border`,x&&`agent-loading-border-active`)}),p.map((e,t)=>(0,$.jsx)(s,{id:e.key,type:`target`,position:o.Left,isConnectable:u,isConnectableEnd:u,className:G(`!z-10 !h-[72%] !w-5 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0 after:absolute after:-inset-3 after:content-['']`),style:{top:`${(t+1)*100/(p.length+1)}%`}},`input-${e.key}`)),m.map((e,t)=>(0,$.jsx)(s,{id:e.key,type:`source`,position:o.Right,isConnectable:u,isConnectableStart:u,className:G(`!z-10 !h-[72%] !w-5 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0 after:absolute after:-inset-3 after:content-['']`),style:{top:`${(t+1)*100/(m.length+1)}%`}},`output-${e.key}`)),(0,$.jsx)(s,{id:nn,type:`source`,position:o.Right,isConnectable:u,isConnectableStart:u,isConnectableEnd:!1,className:G(`!absolute !h-full !w-full !border-0 !bg-transparent !opacity-0`,ee?`!z-30 !pointer-events-auto`:`!z-0 !pointer-events-none`),style:{left:0,top:0,right:`auto`,bottom:`auto`,transform:`none`}}),(0,$.jsx)(s,{id:rn,type:`target`,position:o.Left,isConnectable:u,isConnectableStart:!1,isConnectableEnd:u,className:G(`!absolute !h-full !w-full !border-0 !bg-transparent !opacity-0`,te?`!z-30 !pointer-events-auto`:`!z-0 !pointer-events-none`),style:{left:0,top:0,right:`auto`,bottom:`auto`,transform:`none`}}),T?[(0,$.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`connection-entry-left`,className:G(`pointer-events-none absolute top-1/2 z-10 h-[72%] w-2.5 -translate-y-1/2 rounded-full border transition-[opacity,transform,box-shadow] duration-150`,`-left-1.5`,E)},`left-entry`),(0,$.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`connection-entry-right`,className:G(`pointer-events-none absolute top-1/2 z-10 h-[72%] w-2.5 -translate-y-1/2 rounded-full border transition-[opacity,transform,box-shadow] duration-150`,`-right-1.5`,E)},`right-entry`)]:null,(0,$.jsx)(`div`,{className:G(`relative z-10 flex size-8 shrink-0 items-center justify-center border`,cn(n,r)),children:(0,$.jsx)(g,{className:`size-4.5`})}),(0,$.jsxs)(`div`,{className:`relative z-10 flex min-w-0 flex-1 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[13px] font-semibold text-foreground -translate-y-[0.7px]`,title:a??void 0,children:t}),(0,$.jsx)(`div`,{className:`relative flex items-center pr-0.5`,title:b?`Active`:i,children:(0,$.jsxs)(`span`,{className:`relative flex size-2.5`,children:[(x||b)&&(0,$.jsx)(`span`,{className:G(`absolute inline-flex size-full animate-ping rounded-full opacity-40`,b?`bg-graph-attention`:z[i])}),(0,$.jsx)(`span`,{className:G(`relative inline-flex size-2.5 rounded-full border border-card shadow-sm`,b?`bg-graph-attention`:z[i])})]})})]}),b&&(0,$.jsx)(O.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:`absolute -bottom-6 left-1/2 z-20 -translate-x-1/2 whitespace-nowrap`,children:(0,$.jsx)(`span`,{className:`rounded-sm border border-graph-attention/24 bg-surface-2/92 px-1.5 py-0.5 text-[9px] font-mono text-graph-attention-text shadow-lg backdrop-blur-sm`,children:l})})]})}),un=e(u(),1);function dn({children:e}){return typeof document>`u`||!document.body?null:(0,un.createPortal)(e,document.body)}function fn({x:e,y:t,items:n,onClose:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>({left:e,top:t}));return(0,Q.useEffect)(()=>{let n=i.current;if(!n)return;let r=requestAnimationFrame(()=>{let r=n.getBoundingClientRect(),i=window.innerWidth-8-r.width,a=window.innerHeight-8-r.height,s=Math.max(8,Math.min(e,i)),c=Math.max(8,Math.min(t,a));o(e=>e.left===s&&e.top===c?e:{left:s,top:c})});return()=>cancelAnimationFrame(r)},[e,t,n.length]),(0,Q.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[r]),(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),n.length===0?null:(0,$.jsx)(dn,{children:(0,$.jsx)(O.div,{ref:i,initial:{opacity:0,scale:.96,y:-4},animate:{opacity:1,scale:1,y:0},transition:{duration:.12,ease:`easeOut`},className:`fixed z-[200] min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-md`,style:{left:a.left,top:a.top},children:n.map((e,t)=>e===`divider`?(0,$.jsx)(`div`,{className:`my-1 border-t border-border`},t):(0,$.jsx)(K,{type:`button`,variant:`ghost`,disabled:e.disabled,onClick:()=>{e.disabled||(e.onClick(),r())},className:`h-auto w-full justify-start rounded-none px-3 py-1.5 text-left text-[11px] hover:text-inherit disabled:opacity-40 ${e.danger?`text-graph-status-error/90 hover:bg-destructive/10 hover:text-graph-status-error`:`text-popover-foreground/90 hover:bg-accent/30 hover:text-popover-foreground`}`,children:e.label},t))})})}var pn=/^[il1.,!|:;]$/,mn=/^[fjrt\-[\]()]$/,hn=/^[wmMWOQ@]$/,gn=/^[A-Z]$/;function _n(e){let t=Array.from(e).reduce((e,t)=>t===` `?e+4:t.charCodeAt(0)>255?e+13:pn.test(t)?e+4:mn.test(t)?e+5.5:hn.test(t)?e+10.5:gn.test(t)?e+8.5:e+7,0);return Math.max(100,Math.min(300,t+76))}function vn(e){return!e||e===`__node-body-source`}function yn(e){return!e||e===`__node-body-target`}function bn(e){return e instanceof Element?e.closest(`.react-flow__node`)?.getAttribute(`data-id`)??null:null}function xn(e){return e instanceof Element&&!!e.closest(`.react-flow__pane`)}function Sn(e){if(typeof document>`u`||typeof document.elementFromPoint!=`function`)return null;let t=on(e);return t?document.elementFromPoint(t.x,t.y):null}function Cn(e){return`${e.key} · ${e.type}`}function wn(e,t){let[n,r]=(0,Q.useState)(e),[i,a]=(0,Q.useState)(t),o=(0,Q.useRef)(new Map),s=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{r(t=>{let n=new Set(e.map(e=>e.id)),i=new Map(t.map(e=>[e.id,e])),a=e.map(e=>{let t=o.current.get(e.id);t&&(clearTimeout(t),o.current.delete(e.id));let n=i.get(e.id);return{...n,...e,className:G(e.className,`agent-graph-node-present`),data:{...n?.data??{},...e.data??{},leaving:!1}}});for(let e of t)if(!n.has(e.id)){if(!o.current.has(e.id)){let t=setTimeout(()=>{r(t=>t.filter(t=>t.id!==e.id)),o.current.delete(e.id)},320);o.current.set(e.id,t)}a.push({...e,className:G(e.className,`agent-graph-node-leaving`),data:{...e.data??{},leaving:!0}})}return a})},[e]),(0,Q.useEffect)(()=>{a(e=>{let n=new Set;for(let e=0;e<t.length;e++)n.add(t[e].id);let r=new Map;for(let t=0;t<e.length;t++)r.set(e[t].id,e[t]);let i=t.map(e=>{let t=s.current.get(e.id);t&&(clearTimeout(t),s.current.delete(e.id));let n=r.get(e.id);return{...n,...e,data:{...n?.data??{},...e.data??{},leaving:!1}}});for(let t of e)if(!n.has(t.id)){if(!s.current.has(t.id)){let e=setTimeout(()=>{a(e=>e.filter(e=>e.id!==t.id)),s.current.delete(t.id)},220);s.current.set(t.id,e)}i.push({...t,data:{...t.data??{},leaving:!0}})}return i})},[t]),(0,Q.useEffect)(()=>{let e=o.current,t=s.current;return()=>{for(let t of e.values())clearTimeout(t);for(let e of t.values())clearTimeout(e)}},[]),{nodes:n,edges:i}}function Tn({roles:e=[],loadingRoles:t=!1,onConnectModeChange:n,onCreateConnection:r=async()=>void 0,onDeleteConnection:i=async()=>void 0,onCreateStandaloneAgent:a=async()=>void 0,onCreateLinkedAgent:o=async()=>void 0,onDeleteAgent:s=async()=>void 0,onInsertAgentBetween:c=async()=>void 0,readOnly:l=!1}){let{agents:u}=ye(),{tabs:d}=ge(),{activeToolCalls:f}=Oe(),{activeTabId:p,selectedAgentId:m,selectAgent:h}=je(),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[ee,te]=(0,Q.useState)(!1),[E,ne]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(1),[A,j]=(0,Q.useState)(null),[M,re]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(null),[ae,F]=(0,Q.useState)(null),[I,oe]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(!1),le=(0,Q.useRef)(!1),z=(0,Q.useRef)(null),B=(0,Q.useRef)(``),V=(0,Q.useRef)(new Map),[ue,de]=(0,Q.useState)(0),[H,fe]=(0,Q.useState)({key:``,positions:new Map}),pe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),[U,_e]=(0,Q.useState)(null),W=p?d.get(p)??null:null,ve=(0,Q.useMemo)(()=>W?.definition.nodes??[],[W?.definition.nodes]),be=(0,Q.useMemo)(()=>W?.definition.edges??[],[W?.definition.edges]),xe=(0,Q.useMemo)(()=>new Map(ve.map(e=>[e.id,e])),[ve]),Se=(0,Q.useCallback)((e,t,n)=>{B.current=``,console.error(t,n);let r=V.current.get(e)??0;r>=1||(V.current.set(e,r+1),de(e=>e+1))},[]);(0,Q.useEffect)(()=>{let e=new Worker(new URL(`/assets/layout.worker-jMHqAFbP.js`,``+import.meta.url),{type:`module`}),t=V.current;return e.onerror=e=>{let t=B.current;t&&Se(t,`AgentGraph layout worker error`,e)},e.onmessageerror=e=>{let t=B.current;t&&Se(t,`AgentGraph layout worker message error`,e)},e.onmessage=e=>{let{positions:t,key:n,error:r}=e.data;if(n!==B.current)return;if(r||!t){Se(n,`AgentGraph layout worker rejected request`,r);return}V.current.delete(n);let i=new Map;for(let e of t)i.set(e.id,e.position);fe({key:n,positions:i})},z.current=e,()=>{B.current=``,t.clear(),z.current=null,e.terminate()}},[Se]),(0,Q.useEffect)(()=>{n?.(M)},[M,n]),(0,Q.useEffect)(()=>{l&&(re(!1),P(null),F(null),oe(null),R(!1),x(null),y(null))},[l]);let Ce=(0,Q.useCallback)(e=>{!Number.isFinite(e)||e<=0||k(e)},[]),we=(0,Q.useCallback)(e=>{e&&Ce(e.getZoom())},[Ce]),Te=(0,Q.useCallback)(async e=>{if(!E)return!1;try{let t=await E.fitView(e);return we(E),t}catch{return!1}},[E,we]),Ee=(0,Q.useCallback)(e=>{ne(e),we(e)},[we]),De=(0,Q.useCallback)((e,t)=>{Ce(t.zoom)},[Ce]),G=(0,Q.useCallback)(()=>{l||re(e=>!e)},[l]),ke=(0,Q.useMemo)(()=>new Map(Array.from(u.entries())),[u]),K=(0,Q.useCallback)(e=>{let t=xe.get(e);return t?{id:t.id,node_type:t.type,tab_id:p,is_leader:!1,state:`idle`,connections:be.filter(e=>e.from_node_id===t.id).map(e=>e.to_node_id),name:typeof t.config.name==`string`?t.config.name:null,todos:[],role_name:typeof t.config.role_name==`string`?t.config.role_name:null,config:t.config,inputs:t.inputs,outputs:t.outputs}:null},[p,be,xe]),Ae=(0,Q.useCallback)(e=>ke.get(e)??K(e),[K,ke]),Me=(0,Q.useMemo)(()=>ve.flatMap(e=>{let t=ke.get(e.id);if(t)return[t];let n=K(e.id);return n?[n]:[]}),[K,ke,ve]),Ne=(0,Q.useCallback)(e=>{let t=xe.get(e);return t?ie({name:typeof t.config.name==`string`?t.config.name:null,roleName:typeof t.config.role_name==`string`?t.config.role_name:null,nodeType:t.type,isLeader:!1}):e.slice(0,8)},[xe]),q=(0,Q.useCallback)((e,t,n={})=>{if(e===t)return[];let r=xe.get(e),i=xe.get(t);if(!r||!i)return[];let a=n.sourcePortKey?r.outputs.filter(e=>e.key===n.sourcePortKey):r.outputs,o=n.targetPortKey?i.inputs.filter(e=>e.key===n.targetPortKey):i.inputs,s=[];for(let n of a)for(let r of o)n.type===r.type&&(!r.multiple&&be.some(e=>e.to_node_id===t&&e.to_port_key===r.key)||be.some(i=>i.from_node_id===e&&i.from_port_key===n.key&&i.to_node_id===t&&i.to_port_key===r.key)||s.push({sourcePortKey:n.key,sourcePortLabel:Cn(n),targetPortKey:r.key,targetPortLabel:Cn(r),type:n.type}));return s},[be,xe]),J=(0,Q.useCallback)((e,t)=>q(e,t).length>0,[q]),Pe=ae??N,Fe=(0,Q.useMemo)(()=>{let e=new Map;for(let t of ve){let n=ke.get(t.id)??null,r=ie({name:typeof t.config.name==`string`?t.config.name:null,roleName:typeof t.config.role_name==`string`?t.config.role_name:null,nodeType:t.type,isLeader:!1});e.set(t.id,{label:r,width:_n(r),node_type:t.type,is_leader:!1,state:n?.state??`idle`,shortId:t.id.slice(0,8),name:typeof t.config.name==`string`?t.config.name:null,role_name:typeof t.config.role_name==`string`?t.config.role_name:null,latestTodo:n?.todos[n.todos.length-1]?.text??null,selected:t.id===m&&A===null,toolCall:n?f.get(t.id)??null:null,leaving:!1,canConnect:!!p&&!l,showConnectionEntryHint:M||!!Pe,connectionState:Pe===t.id?`source`:Pe?J(Pe,t.id)?`valid-target`:`invalid-target`:null,inputPorts:t.inputs,outputPorts:t.outputs})}return e},[p,f,Pe,M,J,l,ke,m,A,ve]),{rawNodes:Y,baseEdges:Ie,structureKey:Le}=(0,Q.useMemo)(()=>({rawNodes:ve.flatMap(e=>{let t=Fe.get(e.id);return t?[{id:e.id,type:`agent`,position:{x:0,y:0},width:t.width,height:56,data:t,className:`agent-graph-node-shell`}]:[]}),baseEdges:be.map(e=>({id:e.id,source:e.from_node_id,sourceHandle:e.from_port_key,target:e.to_node_id,targetHandle:e.to_port_key,type:`animated`,data:{sourcePortKey:e.from_port_key,targetPortKey:e.to_port_key}})),structureKey:`${p??`unassigned`}:${ve.map(e=>`${e.id}:${e.type}:${JSON.stringify(e.config)}`).sort().join(`|`)}:${be.map(e=>`${e.id}:${e.from_node_id}:${e.from_port_key}:${e.to_node_id}:${e.to_port_key}:${e.kind}`).sort().join(`|`)}`}),[p,Fe,be,ve]);(0,Q.useEffect)(()=>{if(Y.length===0){B.current=``,V.current.clear();return}if(H.key===Le||B.current===Le)return;let e=z.current;e&&(e.postMessage({nodes:Y,edges:Ie,key:Le}),B.current=Le)},[Ie,ue,H.key,Y,Le]);let Re=(0,Q.useMemo)(()=>{let e=H.positions;return{nodes:Y.map(t=>({...t,position:e.get(t.id)??{x:0,y:0}})),edges:Ie.map(e=>({...e,data:{active:!1,flowDirection:null,leaving:!1,selected:e.id===A},animated:!1})),structureKey:Le}},[Ie,H.positions,Y,A,Le]),{nodes:ze,edges:Be}=wn(Re.nodes,Re.edges),X=(0,Q.useCallback)(()=>{x(null),C(``),T(``),te(!1)},[]),Z=(0,Q.useCallback)(()=>{oe(null),R(!1)},[]),Ve=(0,Q.useCallback)(e=>{x(e),C(``),T(``),te(!1),oe(null),R(!1),y(null),_(null)},[]),He=(0,Q.useCallback)(()=>{se.current=null,ce.current=!1,F(null)},[]),Ue=(0,Q.useCallback)((e,t,n,i)=>r(e,t,n,i.sourcePortKey,i.targetPortKey).then(()=>{re(!1),P(null),F(null),oe(null),R(!1),j(null)}).catch(e=>{R(!1),D.error(e instanceof Error?e.message:`Failed to connect nodes`)}),[r]),We=(0,Q.useCallback)((e,t,n={})=>{if(!p)return;if(l){D.error(`Deactivate workflow before editing`);return}if(e===t)return;let r=q(e,t,n);if(r.length===0){D.error(`This connection is not available`);return}if(r.length===1){Ue(p,e,t,r[0]);return}oe({tabId:p,sourceNodeId:e,sourceNodeLabel:Ne(e),targetNodeId:t,targetNodeLabel:Ne(t),choices:r}),x(null),C(``),T(``),te(!1),P(null),F(null),re(!1),j(null),y(null),_(null)},[p,Ue,q,Ne,l]),Ge=(0,Q.useCallback)((e,t)=>{if(N&&p){if(t.id===N)return;We(N,t.id);return}j(null),Ae(t.id)?h(t.id):h(null)},[p,Ae,We,h,N]),Ke=(0,Q.useCallback)((e,t)=>{if(!ke.has(t.id))return;let n=e;_({agentId:t.id,x:n.clientX,y:n.clientY})},[ke]),qe=(0,Q.useCallback)((e,t)=>{if(!ke.has(t.id))return;let n=e;_({agentId:t.id,x:n.clientX,y:n.clientY})},[ke]),Je=(0,Q.useCallback)(()=>{_(null)},[]),Ye=(0,Q.useCallback)(()=>{if(le.current){le.current=!1;return}j(null),_(null),y(null),P(null),F(null),Z(),X(),h(null)},[Z,X,h]),Xe=(0,Q.useCallback)(e=>{e.preventDefault();let t=e;j(null),_(null),P(null),F(null),Z(),X(),h(null),y({kind:`pane`,x:t.clientX,y:t.clientY})},[Z,X,h]),Ze=(0,Q.useCallback)((e,t)=>{let n=Ae(t.id),r=e;if(r.preventDefault(),r.stopPropagation(),!n||!p){y(null);return}h(t.id),j(null),P(null),F(null),Z(),_(null),X(),y({kind:`node`,x:r.clientX,y:r.clientY,agentId:t.id})},[p,Z,X,Ae,h]),Qe=(0,Q.useCallback)(e=>{if(!p||!e.source||!e.target)return;if(l){D.error(`Deactivate workflow before editing`);return}ce.current=!0;let t={};vn(e.sourceHandle)||(t.sourcePortKey=e.sourceHandle??void 0),yn(e.targetHandle)||(t.targetPortKey=e.targetHandle??void 0),We(e.source,e.target,t)},[p,l,We]),$e=(0,Q.useCallback)((e,t)=>{if(l||t?.handleType===`target`)return;let n=t?.nodeId??bn(e.target);!n||!xe.has(n)||t?.handleId&&!vn(t.handleId)||(se.current=n,ce.current=!1,F(n),P(null),oe(null),R(!1),y(null),_(null))},[l,xe]),et=(0,Q.useCallback)(e=>{let t=se.current,n=ce.current;if(He(),!t||n||!e||l){M||re(!1);return}let r=Sn(e),i=bn(e.target)??bn(r);if(i){We(t,i);return}if(xn(e.target)||xn(r)){let n=on(e);n&&(le.current=!0,Ve({kind:`linked`,x:n.x,y:n.y,anchorNodeId:t}))}M||re(!1)},[He,M,Ve,l,We]),tt=(0,Q.useCallback)((e,t)=>{j(t.id),_(null),y(null),P(null),F(null),Z(),X(),h(null)},[Z,X,h]),nt=(0,Q.useCallback)((e,t)=>{let n=e;n.preventDefault(),n.stopPropagation(),j(t.id),_(null),P(null),F(null),Z(),X(),h(null),y({kind:`edge`,x:n.clientX,y:n.clientY,sourceId:t.source,targetId:t.target,sourcePortKey:t.sourceHandle,targetPortKey:t.targetHandle})},[Z,X,h]),rt=(0,Q.useCallback)(()=>{y(null)},[]),it=(0,Q.useMemo)(()=>{if(!v)return[];if(v.kind===`node`){let e=Ae(v.agentId);return!e||!p?[]:l?[{label:`Clear Selection`,onClick:()=>{h(null)}}]:[{label:`Add Agent After`,onClick:()=>{Ve({kind:`linked`,x:v.x,y:v.y,anchorNodeId:e.id})}},{label:`Connect to...`,onClick:()=>{x(null),C(``),T(``),Z(),re(!1),P(e.id),F(null),j(null),h(e.id)}},`divider`,{label:`Delete Node`,danger:!0,onClick:()=>{s({tabId:p,node:e,tabAgents:Me}).catch(e=>{D.error(e instanceof Error?e.message:`Failed to delete agent`)})}}]}return v.kind===`edge`?!p||l?[]:[{label:`Insert Agent Between`,onClick:()=>{Ve({kind:`between`,x:v.x,y:v.y,sourceNodeId:v.sourceId,targetNodeId:v.targetId})}},{label:`Delete Edge`,danger:!0,onClick:()=>{i(p,v.sourceId,v.targetId,v.sourcePortKey??void 0,v.targetPortKey??void 0).catch(e=>{D.error(e instanceof Error?e.message:`Failed to delete edge`)})}}]:[{label:`Add Agent`,disabled:!p||l,onClick:()=>{Ve({kind:`standalone`,x:v.x,y:v.y})}}]},[p,v,s,i,Ve,l,Z,Ae,h,Me]),at=(0,Q.useCallback)(()=>{if(!p||!b||!w||ee)return;let e=S.trim()||void 0;te(!0),(b.kind===`standalone`?a({tabId:p,roleName:w,name:e}):b.kind===`linked`?o({tabId:p,anchorNodeId:b.anchorNodeId,roleName:w,name:e}):c({tabId:p,sourceNodeId:b.sourceNodeId,targetNodeId:b.targetNodeId,roleName:w,name:e})).then(()=>{X(),j(null),P(null)}).catch(e=>{te(!1),D.error(e instanceof Error?e.message:`Failed to add agent`)})},[p,X,o,a,c,b,S,w,ee]),ot=(0,Q.useCallback)(e=>{!I||L||(R(!0),Ue(I.tabId,I.sourceNodeId,I.targetNodeId,e))},[I,Ue,L]),st=g?ke.get(g.agentId)??null:null,ct=g&&g.agentId?f.get(g.agentId)??null:null;(0,Q.useEffect)(()=>{if(!g||!st)return;let e=requestAnimationFrame(()=>{let e=pe.current;if(!e)return;let t=e.getBoundingClientRect();_e(e=>e&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5?e:{width:t.width,height:t.height})});return()=>cancelAnimationFrame(e)},[g,st]),(0,Q.useEffect)(()=>{if(!E||ze.length===0||he.current===Re.structureKey)return;let e=he.current===null;he.current=Re.structureKey;let t=requestAnimationFrame(()=>{Te({padding:$t,maxZoom:1,duration:e?0:250})});return()=>cancelAnimationFrame(t)},[ze.length,Te,E,Re.structureKey]),(0,Q.useEffect)(()=>{if(!E||!me.current||ze.length===0)return;let e=0,t=new ResizeObserver(()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{Te({padding:$t,maxZoom:1,duration:250})})});return t.observe(me.current),()=>{cancelAnimationFrame(e),t.disconnect()}},[ze.length,Te,E]);let lt=(0,Q.useMemo)(()=>{if(!g||typeof window>`u`)return;let e=U?.width??280,t=U?.height??120,n=window.innerWidth-8-e,r=window.innerHeight-8-t;return{left:Math.max(8,Math.min(g.x+12,n)),top:Math.max(8,Math.min(g.y+12,r))}},[g,U]),ut=(0,Q.useMemo)(()=>d.size===0?{title:`No workflows yet`}:W?null:{title:`Select a workflow`},[W,d.size]);return{activeTabId:p,animatedEdges:Be,animatedNodes:ze,availableRoles:e,closeConnectionChoice:Z,closeContextMenu:rt,closeQuickCreate:X,connectHintLabel:N?`Choose target node`:M?`Connect nodes`:null,connectionChoice:I,containerRef:me,contextMenu:v,contextMenuItems:it,emptyState:ut,enterConnectMode:G,handleFlowInit:Ee,handleViewportMove:De,isValidConnection:(0,Q.useCallback)(e=>{if(l||!e.source||!e.target||e.source===e.target)return!1;let t={};return vn(e.sourceHandle)||(t.sourcePortKey=e.sourceHandle??void 0),yn(e.targetHandle)||(t.targetPortKey=e.targetHandle??void 0),q(e.source,e.target,t).length>0},[q,l]),loadingRoles:t,onConnect:Qe,onConnectEnd:et,onConnectStart:$e,onEdgeClick:tt,onEdgeContextMenu:nt,onNodeClick:Ge,onNodeContextMenu:Ze,onNodeMouseEnter:Ke,onNodeMouseLeave:Je,onNodeMouseMove:qe,onPaneClick:Ye,onPaneContextMenu:Xe,quickCreate:b,quickCreateName:S,quickCreateRoleName:w,readOnly:l,setQuickCreateName:C,setQuickCreateRoleName:T,submitConnectionChoice:ot,submittingConnectionChoice:L,submitQuickCreate:at,submittingQuickCreate:ee,tooltip:g,tooltipAgent:st,tooltipRef:pe,tooltipStyle:lt,tooltipToolCall:ct,viewportZoom:O}}var En={running:`border-graph-status-running/18 bg-graph-status-running/[0.12] text-graph-status-running`,idle:`border-graph-status-idle/12 bg-graph-status-idle/[0.06] text-graph-status-idle/78`,sleeping:`border-graph-status-sleeping/18 bg-graph-status-sleeping/[0.12] text-graph-status-sleeping`,initializing:`border-graph-status-initializing/16 bg-graph-status-initializing/[0.08] text-graph-status-initializing/84`,error:`border-graph-status-error/20 bg-graph-status-error/[0.09] text-graph-status-error`,terminated:`border-border bg-accent/35 text-muted-foreground`};function Dn({agent:e,agentId:t,activeToolCall:n,style:r,tooltipRef:i}){let a=e?ie({name:e.name,roleName:e.role_name,nodeType:e.node_type,isLeader:e.is_leader}):null;return(0,$.jsx)(dn,{children:(0,$.jsx)(De,{children:e&&t&&a?(0,$.jsxs)(O.div,{ref:i,initial:{opacity:0,y:4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:2,scale:.98},transition:{duration:.15},className:`pointer-events-none fixed z-[100] max-w-[320px] rounded-md border border-border bg-popover px-2 py-1 text-popover-foreground shadow-md`,style:r,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium`,children:a}),(0,$.jsx)(R,{variant:`outline`,className:`text-[10px] ${En[e.state]}`,children:e.state.toUpperCase()}),e.role_name?(0,$.jsx)(R,{variant:`outline`,className:`text-[10px]`,children:e.role_name}):null,e.is_leader?(0,$.jsx)(R,{variant:`outline`,className:`border-accent bg-accent/45 text-[10px] text-accent-foreground`,children:`Leader`}):null]}),(0,$.jsxs)(`div`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-2 gap-y-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`ID`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:t.slice(0,8)}),(0,$.jsx)(`span`,{children:`Connections`}),(0,$.jsx)(`span`,{className:`text-foreground/80`,children:e.connections.length}),(0,$.jsx)(`span`,{children:`Workflow`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:e.tab_id?.slice(0,8)??`—`}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:`Tool`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:n})]}):null]}),(0,$.jsxs)(`div`,{className:`mt-1.5 space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Todos`}),e.todos.length===0?(0,$.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`No todos`}):(0,$.jsxs)(`div`,{className:`space-y-1`,children:[e.todos.slice(Math.max(e.todos.length-3,0)).reverse().map(e=>(0,$.jsx)(`div`,{className:`text-[11px] leading-relaxed text-foreground/85`,children:e.text},`${t}-${e.text}`)),e.todos.length>3?(0,$.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[`+`,e.todos.length-3,` more`]}):null]})]})]}):null})})}var On={agent:ln},kn={animated:Qt},An=(0,Q.forwardRef)(function(e,n){let{activeTabId:i,animatedEdges:a,animatedNodes:o,availableRoles:s,closeContextMenu:c,closeConnectionChoice:u,closeQuickCreate:d,connectHintLabel:f,connectionChoice:m,containerRef:h,contextMenu:g,contextMenuItems:_,emptyState:v,enterConnectMode:y,handleFlowInit:b,handleViewportMove:x,isValidConnection:S,loadingRoles:C,onConnect:w,onConnectEnd:T,onConnectStart:ee,onEdgeClick:te,onEdgeContextMenu:E,onNodeClick:ne,onNodeContextMenu:D,onNodeMouseEnter:O,onNodeMouseLeave:k,onNodeMouseMove:A,onPaneClick:j,onPaneContextMenu:M,quickCreate:re,quickCreateName:N,quickCreateRoleName:ie,readOnly:P,setQuickCreateName:ae,setQuickCreateRoleName:F,submitConnectionChoice:I,submittingConnectionChoice:oe,submitQuickCreate:L,submittingQuickCreate:R,tooltip:se,tooltipAgent:ce,tooltipRef:le,tooltipStyle:z,tooltipToolCall:B,viewportZoom:V}=Tn(e);return(0,Q.useImperativeHandle)(n,()=>({enterConnectMode:y}),[y]),(0,$.jsxs)(`div`,{ref:h,className:`relative flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`relative flex-1 overflow-hidden`,children:v?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-[22rem] rounded-xl border border-border bg-surface-overlay/60 px-5 py-5 text-center shadow-md backdrop-blur-sm`,children:[(0,$.jsx)(`div`,{className:`mx-auto flex size-10 items-center justify-center rounded-lg border border-border bg-accent/35 text-muted-foreground`,children:(0,$.jsx)(p,{className:`size-4.5`})}),(0,$.jsx)(`p`,{className:`mt-3.5 text-[18px] font-semibold leading-tight text-foreground`,children:v.title})]})}):(0,$.jsxs)(r,{nodes:o,edges:a,nodeTypes:On,edgeTypes:kn,colorMode:`dark`,onInit:b,onNodeClick:ne,onNodeMouseEnter:O,onNodeMouseMove:A,onNodeMouseLeave:k,onPaneClick:j,onPaneContextMenu:M,onNodeContextMenu:D,onEdgeClick:te,onEdgeContextMenu:E,onConnect:w,onConnectStart:ee,onConnectEnd:T,onMove:x,isValidConnection:S,connectionMode:t.Strict,connectOnClick:!1,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!!i&&!P,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,minZoom:en,maxZoom:6,className:`bg-graph-bg`,children:[(0,$.jsx)(l,{color:`var(--graph-grid)`,gap:28,size:.72}),(0,$.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,children:(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`linearGradient`,{id:`agent-graph-edge-flow`,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--graph-edge)`,stopOpacity:`0.2`}),(0,$.jsx)(`stop`,{offset:`50%`,stopColor:`var(--graph-edge-active)`,stopOpacity:`0.94`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--graph-edge)`,stopOpacity:`0.2`})]}),(0,$.jsxs)(`radialGradient`,{id:`agent-graph-edge-pulse`,cx:`50%`,cy:`50%`,r:`50%`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--graph-edge-active)`,stopOpacity:`1`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--graph-edge-active)`,stopOpacity:`0.2`})]}),(0,$.jsx)(`filter`,{id:`agent-graph-edge-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:(0,$.jsx)(`feGaussianBlur`,{stdDeviation:`2.6`})})]})})]})}),o.length>0?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-4 left-4 z-30`,children:(0,$.jsx)(`div`,{className:tn,"data-testid":`agent-graph-zoom-indicator`,children:xe(V)})}):null,f?(0,$.jsx)(`div`,{className:`pointer-events-none absolute right-4 top-4 z-30`,children:(0,$.jsx)(`div`,{className:tn,children:f})}):null,(0,$.jsx)(Dn,{agent:ce,agentId:se?.agentId??null,activeToolCall:B,style:z,tooltipRef:le}),g?(0,$.jsx)(fn,{x:g.x,y:g.y,items:_,onClose:c}):null,re?(0,$.jsx)(Mn,{displayName:N,roles:s,loadingRoles:C,onClose:d,onDisplayNameChange:ae,onSelectRole:F,onSubmit:L,selectedRoleName:ie,submitting:R,title:an(re)}):null,m?(0,$.jsx)(jn,{state:m,onClose:u,onSelect:I,submitting:oe}):null]})});function jn({state:e,submitting:t,onClose:n,onSelect:r}){return(0,$.jsxs)(Le,{open:!0,onOpenChange:e=>{e||n()},title:`Choose Connection`,className:`max-w-[34rem]`,footer:(0,$.jsx)(K,{type:`button`,variant:`outline`,onClick:n,disabled:t,children:`Cancel`}),children:[(0,$.jsxs)(Ie,{children:[`Choose how`,` `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.sourceNodeLabel}),` `,`should connect to`,` `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.targetNodeLabel}),`.`]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.choices.map(e=>(0,$.jsxs)(K,{type:`button`,variant:`outline`,className:`h-auto w-full justify-between gap-4 rounded-md border-border bg-background/40 px-3 py-2.5 text-left hover:bg-accent/45`,disabled:t,onClick:()=>r(e),children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`block truncate text-[13px] font-semibold text-foreground`,children:[e.sourcePortLabel,` -> `,e.targetPortLabel]}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-muted-foreground`,children:e.type})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] text-muted-foreground`,children:t?`Connecting...`:`Connect`})]},`${e.sourcePortKey}->${e.targetPortKey}`))})]})}function Mn({title:e,selectedRoleName:t,displayName:n,roles:r,loadingRoles:i,submitting:a,onSelectRole:o,onDisplayNameChange:s,onSubmit:c,onClose:l}){return(0,$.jsxs)(Le,{open:!0,onOpenChange:e=>{e||l()},title:e,className:`max-w-[44rem]`,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,onClick:l,disabled:a,children:`Cancel`}),(0,$.jsx)(K,{type:`button`,disabled:!t||a,onClick:c,children:a?`Saving...`:e})]}),children:[(0,$.jsx)(Ie,{children:`Choose a role and set how this agent appears in the workflow.`}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:`Role`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Required`})]}),(0,$.jsx)(Gt,{roles:r,loadingRoles:i,selectedRoleName:t,onRoleNameChange:o})]}),(0,$.jsx)(Y,{label:`Display Name`,hint:`Optional`,children:(0,$.jsx)(W,{"aria-label":`Display Name`,value:n,onChange:e=>s(e.target.value),placeholder:`Optional display name`,className:`h-10 rounded-md bg-background/40 text-foreground shadow-xs placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50`})})]})}function Nn({activeTabId:e,connected:t,definitionDraft:n,editorMode:r,graphConnectMode:i,graphHistory:a,graphRef:o,isCompactWorkspace:s,isDragging:c,leaderDetailVisible:l,leaderNode:u,leaderPanelRunning:d,loadingRoles:p,onCloseLeaderDetails:h,onConnectModeChange:v,onCreateNode:y,onCreateTab:b,onDefinitionDraftChange:S,onDeleteTab:ne,onDuplicateTab:D,onEditorModeChange:k,onOpenLeaderDetails:A,onOpenConnectDialog:j,onSaveDefinition:M,onToggleActivation:re,panelVisible:ie,pendingAction:P,resolvedPanelWidth:ae,roles:I,selectAgent:R,selectedAgent:z,setActiveTabId:V,startDrag:ue,tabs:de,togglePanel:H,workflowNodeOptions:fe,workspaceRef:pe,workflowLocked:me}){let he=()=>l&&u?(0,$.jsx)(le,{agent:u,onClose:h}):e?(0,$.jsx)(se,{onOpenDetails:A}):(0,$.jsx)(ce,{}),U=e?de.get(e)??null:null;return(0,$.jsxs)(`div`,{ref:pe,className:`relative isolate flex h-full overflow-hidden rounded-xl border border-border bg-surface-overlay shadow-md [contain:paint]`,children:[(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,$.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`relative z-30 border-b border-border bg-background/45 backdrop-blur-md`,children:(0,$.jsxs)(`div`,{className:`pointer-events-auto relative z-10 flex items-center gap-1.5 overflow-x-auto px-3 py-2.5 pr-14 scrollbar-none`,children:[Array.from(de.values()).map(t=>(0,$.jsxs)(`div`,{className:`group relative min-w-[120px] max-w-[220px] shrink-0`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>V(t.id),onAuxClick:e=>{e.button===1&&(e.preventDefault(),ne(t.id,t.title,t.node_count))},className:G(`relative h-8 w-full justify-start rounded-md border-b-2 px-3 pr-12 text-left text-[13px] font-medium transition-[color,border-color,background-color] duration-200`,e===t.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:bg-accent/25 hover:text-foreground`),children:(0,$.jsx)(`div`,{className:`truncate leading-tight`,children:t.title})}),e===t.id?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,title:`Duplicate workflow`,"aria-label":`Duplicate ${t.title}`,onClick:e=>{e.stopPropagation(),D()},className:`absolute right-6 top-1/2 z-20 size-5 -translate-y-1/2 rounded-sm p-1 text-foreground/70 transition-all duration-200 hover:bg-accent/45 hover:text-foreground`,children:(0,$.jsx)(x,{className:`size-3`})}):null,(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,title:`Delete workflow`,"aria-label":`Delete ${t.title}`,onClick:e=>{e.stopPropagation(),ne(t.id,t.title,t.node_count)},className:G(`absolute right-1.5 top-1/2 z-20 size-5 -translate-y-1/2 rounded-sm p-1 transition-all duration-200 hover:bg-accent/45 hover:text-foreground`,e===t.id?`text-foreground/70 opacity-100`:`text-muted-foreground/60 opacity-0 group-hover:opacity-100`),children:(0,$.jsx)(g,{className:`size-3`})})]},t.id)),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Create workflow`,onClick:b,className:`shrink-0 rounded-md text-muted-foreground transition-all duration-200 hover:bg-accent/45 hover:text-foreground`,children:(0,$.jsx)(C,{className:`size-4`})})]})}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-0`,style:{background:`radial-gradient(circle at 14% 10%, var(--shell-spotlight-primary), transparent 24%), linear-gradient(180deg, color-mix(in srgb, var(--foreground) 1%, transparent), transparent 22%)`}}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-10 w-12 bg-gradient-to-l from-background/28 to-transparent`}),(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[r===`graph`?(0,$.jsx)(An,{ref:o,loadingRoles:p,onConnectModeChange:v,onCreateConnection:a.createConnection,onCreateLinkedAgent:a.createLinkedAgent,onCreateStandaloneAgent:a.createStandaloneAgent,onDeleteAgent:a.deleteAgent,onDeleteConnection:a.deleteConnection,onInsertAgentBetween:a.insertAgentBetween,onOpenConnectDialog:j,readOnly:me,roles:I}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-[11px] font-semibold text-muted-foreground`,children:`Workflow JSON`}),(0,$.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Review the graph structure and saved workflow settings.`})]}),(0,$.jsxs)(K,{onClick:M,disabled:!e||me||P===`save-definition`,children:[(0,$.jsx)(w,{className:`mr-1 size-4`}),P===`save-definition`?`Saving...`:`Save JSON`]})]}),(0,$.jsx)(B,{value:n,onChange:e=>S(e.target.value),readOnly:me,className:`h-full min-h-0 w-full resize-none rounded-xl border border-border bg-background/40 p-4 font-mono text-[12px] leading-6 text-foreground outline-none transition-[border-color,box-shadow] focus:border-ring focus:ring-[3px] focus:ring-ring/50`,spellCheck:!1})]}),(0,$.jsxs)(`div`,{className:G(`absolute top-4 z-40 flex max-w-[calc(100%-2.5rem)] flex-wrap items-center gap-1.5`,s?`left-14`:`left-4`),children:[(0,$.jsxs)(oe,{tone:`primary`,children:[(0,$.jsx)(te,{className:G(`size-3.5 shrink-0`,t?`text-graph-status-idle/88`:`text-graph-status-initializing/38`)}),(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:t?`Live`:`Reconnecting`})]}),U?(0,$.jsxs)(oe,{children:[U.node_count??U.definition.nodes.length,` `,`nodes`]}):null]}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 bottom-4 z-40 flex justify-center`,children:(0,$.jsxs)(`div`,{"data-testid":`workspace-toolbar`,className:`pointer-events-auto inline-flex max-w-full items-center overflow-x-auto rounded-xl border border-border bg-surface-overlay/92 p-0.5 shadow-sm scrollbar-none`,children:[(0,$.jsxs)(N,{disabled:!e||me||!a.canUndo(e),onClick:()=>{a.undo(e)},children:[(0,$.jsx)(T,{className:`size-4 opacity-70`}),`Undo`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e||me||!a.canRedo(e),onClick:()=>{a.redo(e)},children:[(0,$.jsx)(E,{className:`size-4 opacity-70`}),`Redo`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e||P===`activate-workflow`||P===`deactivate-workflow`,active:me,onClick:re,children:[(0,$.jsx)(ee,{className:`size-4 opacity-70`}),me?`Deactivate`:`Activate`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e,active:r===`graph`,onClick:()=>k(`graph`),children:[(0,$.jsx)(f,{className:`size-4 opacity-70`}),`Graph`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e,active:r===`json`,onClick:()=>k(`json`),children:[(0,$.jsx)(_,{className:`size-4 opacity-70`}),`JSON`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e||me,onClick:y,children:[(0,$.jsx)(C,{className:`size-4 opacity-70`}),`Add Node`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e||me||fe.length<2,active:i,onClick:j,children:[(0,$.jsx)(m,{className:`size-4 opacity-70`}),`Connect Ports`]}),(0,$.jsx)(L,{}),(0,$.jsxs)(N,{disabled:!e,onClick:D,children:[(0,$.jsx)(x,{className:`size-4 opacity-70`}),`Duplicate`]})]})})]}),(0,$.jsx)(`div`,{className:`absolute bottom-4 right-4 z-30 sm:bottom-5 sm:right-5`,children:(0,$.jsx)(F,{expanded:ie,onClick:H})})]}),(0,$.jsx)(De,{initial:!1,children:ie?s?[(0,$.jsx)(Ee,{type:`button`,variant:`ghost`,"aria-label":`Close workspace panel`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:`absolute inset-0 z-10 h-auto w-auto rounded-none border-0 bg-background/40 p-0 shadow-none backdrop-blur-[1px] hover:bg-background/40 focus-visible:ring-0`,onClick:H},`workspace-panel-backdrop`),(0,$.jsxs)(O.aside,{initial:{opacity:0,x:18},animate:{opacity:1,x:0},exit:{opacity:0,x:18},transition:{duration:.22,ease:[.16,1,.3,1]},className:`absolute inset-y-2.5 right-2.5 z-20 shrink-0 overflow-hidden rounded-xl border border-border bg-surface-overlay shadow-md`,style:{width:`${ae}px`},children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:G(`pointer-events-none absolute inset-0 z-20 border transition-[opacity,border-color,box-shadow] duration-300`,!z&&d?`animate-pulse border-ring/25 opacity-100 shadow-lg shadow-ring/10`:`border-transparent opacity-0`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,$.jsx)(O.div,{animate:{opacity:+!z,x:z?-8:0},transition:{duration:.15},className:G(`absolute inset-0 flex h-full flex-col`,z&&`pointer-events-none`),"aria-hidden":z?!0:void 0,children:he()}),(0,$.jsx)(De,{children:z?(0,$.jsx)(O.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.15},className:`absolute inset-0 flex h-full flex-col bg-background/42`,children:(0,$.jsx)(le,{agent:z,onClose:()=>R(null)})},z.id):null})]})})]},`workspace-panel-sheet`)]:(0,$.jsxs)(O.aside,{initial:{width:0,opacity:0},animate:{width:ae,opacity:1},exit:{width:0,opacity:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:`relative z-20 shrink-0 border-l border-border bg-surface-overlay shadow-md`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:G(`pointer-events-none absolute inset-0 z-20 border transition-[opacity,border-color,box-shadow] duration-300`,!z&&d?`animate-pulse border-ring/25 opacity-100 shadow-lg shadow-ring/10`:`border-transparent opacity-0`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`var(--shell-surface-sweep)`}}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-px`,style:{background:`var(--shell-hairline)`}}),(0,$.jsx)(we,{position:`left`,isDragging:c,onMouseDown:ue}),(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,style:{width:`${ae}px`},children:(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,$.jsx)(O.div,{animate:{opacity:+!z,x:z?-8:0},transition:{duration:.15},className:G(`absolute inset-0 flex h-full flex-col`,z&&`pointer-events-none`),"aria-hidden":z?!0:void 0,children:he()}),(0,$.jsx)(De,{children:z?(0,$.jsx)(O.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.15},className:`absolute inset-0 flex h-full flex-col bg-background/42`,children:(0,$.jsx)(le,{agent:z,onClose:()=>R(null)})},z.id):null})]})})]},`workspace-panel-docked`):null})]})}function Pn(e){return{undo:[...e?.undo??[]],redo:[...e?.redo??[]]}}function Fn(e){let t=e?.trim()??``;return t.length>0?t:void 0}function In(){let e=(0,Q.useRef)(new Map),[t,n]=(0,Q.useState)(0),r=(0,Q.useCallback)(()=>{n(e=>e+1)},[]),i=(0,Q.useCallback)((t,n)=>{let i=Pn(e.current.get(t));i.undo.push(n),i.redo=[],e.current.set(t,i),r()},[r]),a=(0,Q.useCallback)(async({tabId:e,nodeType:t=`agent`,roleName:n,name:r})=>{let a=Fn(r),o=(await H(e,{node_type:t,role_name:n,name:a})).id;return i(e,{undo:async()=>{await V(e,o)},redo:async()=>{o=(await H(e,{node_type:t,role_name:n,name:a})).id}}),o},[i]),o=(0,Q.useCallback)(async({tabId:e,anchorNodeId:t,roleName:n,name:r})=>{let a=Fn(r),o=(await H(e,{node_type:`agent`,role_name:n,name:a})).id;try{await U(e,{fromNodeId:t,toNodeId:o})}catch(t){throw await V(e,o).catch(()=>void 0),t}return i(e,{undo:async()=>{await V(e,o)},redo:async()=>{o=(await H(e,{node_type:`agent`,role_name:n,name:a})).id,await U(e,{fromNodeId:t,toNodeId:o})}}),o},[i]),s=(0,Q.useCallback)(async(e,t,n,r=`out`,a=`in`)=>{let o=await U(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a});i(e,{undo:async()=>{await Ce(e,{edgeId:o.id})},redo:async()=>{await U(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a})}})},[i]),c=(0,Q.useCallback)(async(e,t,n,r=`out`,a=`in`)=>{await Ce(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a}),i(e,{undo:async()=>{await U(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a})},redo:async()=>{await Ce(e,{fromNodeId:t,fromPortKey:r,toNodeId:n,toPortKey:a})}})},[i]),l=(0,Q.useCallback)(async({tabId:e,node:t,tabAgents:n})=>{let r=Array.from(new Set([...t.connections].filter(e=>n.some(t=>t.id===e)))),a=Fn(t.name),o=t.role_name?.trim()??``,s=t.id;await V(e,s),i(e,{undo:async()=>{s=(await H(e,{node_type:t.node_type,role_name:o||void 0,name:a})).id;for(let t of r)await U(e,{fromNodeId:t,toNodeId:s})},redo:async()=>{await V(e,s)}})},[i]),u=(0,Q.useCallback)(async({tabId:e,sourceNodeId:t,targetNodeId:n,roleName:r,name:a})=>{let o=Fn(a),s=null;await Ce(e,{fromNodeId:t,toNodeId:n});try{s=(await H(e,{node_type:`agent`,role_name:r,name:o})).id,await U(e,{fromNodeId:t,toNodeId:s}),await U(e,{fromNodeId:s,toNodeId:n})}catch(r){throw s&&await V(e,s).catch(()=>void 0),await U(e,{fromNodeId:t,toNodeId:n}).catch(()=>void 0),r}return i(e,{undo:async()=>{s&&(await V(e,s),await U(e,{fromNodeId:t,toNodeId:n}))},redo:async()=>{await Ce(e,{fromNodeId:t,toNodeId:n}),s=(await H(e,{node_type:`agent`,role_name:r,name:o})).id,await U(e,{fromNodeId:t,toNodeId:s}),await U(e,{fromNodeId:s,toNodeId:n})}}),s},[i]),d=(0,Q.useCallback)(t=>!!(t&&(e.current.get(t)?.undo.length??0)>0),[]),f=(0,Q.useCallback)(t=>!!(t&&(e.current.get(t)?.redo.length??0)>0),[]),p=(0,Q.useCallback)(async t=>{if(!t)return!1;let n=Pn(e.current.get(t)),i=n.undo.pop();return i?(await i.undo(),n.redo.push(i),e.current.set(t,n),r(),!0):!1},[r]),m=(0,Q.useCallback)(async t=>{if(!t)return!1;let n=Pn(e.current.get(t)),i=n.redo.pop();return i?(await i.redo(),n.undo.push(i),e.current.set(t,n),r(),!0):!1},[r]);return(0,Q.useMemo)(()=>({canRedo:f,canUndo:d,createConnection:s,createLinkedAgent:o,createStandaloneAgent:e=>a({tabId:e.tabId,nodeType:`agent`,roleName:e.roleName,name:e.name}),createStandaloneNode:a,deleteAgent:l,deleteConnection:c,insertAgentBetween:u,redo:m,revision:t,undo:p}),[f,d,s,o,a,c,l,u,m,t,p])}var Ln=`workspace-panel-width`,Rn=296,zn=300,Bn=960,Vn=.34,Hn=448,Un=300;function Wn(e){return`${e.key} · ${e.type}`}function Gn(){let{agents:e}=ye(),{tabs:t}=ge(),{connected:n}=Te(),{activeToolCalls:r}=Oe(),{streamingDeltas:i}=be(),{activeTabId:a,selectedAgentId:o,selectAgent:s,setActiveTabId:c}=je(),[l,u]=(0,Q.useState)(!0),[d,f]=(0,Q.useState)(`chat`),[p,m]=(0,Q.useState)(`graph`),h=ke(`(max-width: 1180px)`),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(``),[ee,te]=(0,Q.useState)([]),[E,ne]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(`agent`),[A,j]=(0,Q.useState)(`Worker`),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(``),[I,oe]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(``),[se,ce]=(0,Q.useState)(``),[le,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(JSON.stringify(ue,null,2)),H=(0,Q.useRef)(null),fe=(0,Q.useRef)(null),U=(0,Q.useRef)(null),W=In(),[xe,Ce]=(0,Q.useState)(!1),[we,Ee]=ve(Ln,Hn,Rn,Bn),De=(0,Q.useCallback)(e=>{let t=U.current?.clientWidth??(typeof window>`u`?e:window.innerWidth),n=Math.max(Rn,t-zn);Ee(Math.min(e,n))},[Ee]),{isDragging:G,startDrag:K}=_e(we,De,`left`);(0,Q.useLayoutEffect)(()=>{if(Ae(Ln))return;let e=U.current?.clientWidth;e&&De(e*Vn)},[De]),(0,Q.useEffect)(()=>{let e=U.current;if(!e)return;let t=new ResizeObserver(()=>{De(we)});return t.observe(e),()=>{t.disconnect()}},[we,De]),(0,Q.useEffect)(()=>{let e=H.current;H.current=h,e!==null&&!e&&h&&u(!1)},[h]),(0,Q.useEffect)(()=>{let e=!1;return ne(!0),re().then(t=>{e||te(t)}).catch(()=>{e||D.error(`Failed to load roles`)}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[]);let Ne=o?e.get(o)??null:null,q=a?t.get(a)??null:null,J=(q?.activation_state??`inactive`)===`active`,Pe=(0,Q.useMemo)(()=>Array.from(e.values()).filter(e=>e.node_type!==`assistant`&&e.tab_id===a),[a,e]),Fe=(0,Q.useMemo)(()=>Pe.filter(e=>!e.is_leader),[Pe]),Y=(0,Q.useMemo)(()=>q?.definition.nodes??[],[q?.definition.nodes]),Ie=(0,Q.useMemo)(()=>Y.map(e=>({id:e.id,label:ie({name:typeof e.config.name==`string`?e.config.name:null,roleName:typeof e.config.role_name==`string`?e.config.role_name:null,nodeType:e.type,isLeader:!1})})),[Y]),Le=(0,Q.useMemo)(()=>Y.find(e=>e.id===P)??null,[P,Y]),Re=(0,Q.useMemo)(()=>Y.find(e=>e.id===L)??null,[L,Y]),ze=(0,Q.useMemo)(()=>(Le?.outputs??[]).map(e=>({key:e.key,label:Wn(e)})),[Le]),Be=(0,Q.useMemo)(()=>(Re?.inputs??[]).map(e=>({key:e.key,label:Wn(e)})),[Re]),X=(0,Q.useMemo)(()=>ee.find(e=>e.name===A)??null,[A,ee]),Z=l||!!Ne,Ve=(0,Q.useMemo)(()=>{if(!h)return we;let e=U.current?.clientWidth??(typeof window>`u`?we:window.innerWidth);return Math.min(we,Math.max(Un,e-24))},[h,we]),He=(0,Q.useMemo)(()=>ae(e,q),[q,e]),Ue=He?.id??q?.leader_id??null,We=d===`detail`&&He!==null,Ge=(0,Q.useMemo)(()=>{let e=Ue?i.get(Ue)??[]:[];return n&&!!(Ue&&(He?.state===`running`||He?.state===`sleeping`||r.has(Ue)||e.length>0))},[r,n,Ue,He,i]);(0,Q.useEffect)(()=>{Ne&&Ne.tab_id!==null&&Ne.tab_id!==a&&s(null)},[a,s,Ne]),(0,Q.useEffect)(()=>{V(JSON.stringify(q?.definition??ue,null,2))},[q?.definition]),(0,Q.useEffect)(()=>{ze.some(e=>e.key===I)||oe(ze[0]?.key??``)},[I,ze]),(0,Q.useEffect)(()=>{Be.some(e=>e.key===se)||ce(Be[0]?.key??``)},[se,Be]),(0,Q.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`z`)return;let t=e.target;if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t?.isContentEditable||g!==null)){if(e.preventDefault(),e.shiftKey){if(J)return;W.redo(a).catch(()=>void 0);return}J||W.undo(a).catch(()=>void 0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,a,W,J]);let Ke=(0,Q.useCallback)(()=>{u(!0),f(`detail`)},[]),qe=(0,Q.useCallback)(()=>{f(`chat`)},[]),Je=(0,Q.useCallback)(()=>{if(Z){o&&s(null),u(!1);return}u(!0)},[Z,s,o]),Ye=(0,Q.useCallback)(()=>{x(``),C(!1),T(``),_(`create-tab`)},[]),Xe=(0,Q.useCallback)(async()=>{let e=b.trim();if(e){y(`create-tab`);try{c((await de(e,S,w.split(`
3
- `).map(e=>e.trim()).filter(Boolean))).id),_(null),x(``),C(!1),T(``)}catch(e){D.error(e instanceof Error?e.message:`Failed to create workflow`)}finally{y(null)}}},[S,b,w,c]),Ze=(0,Q.useCallback)(async()=>{if(!a){D.error(`Create or select a workflow first`);return}y(`duplicate-tab`);try{c((await pe(a)).id)}catch(e){D.error(e instanceof Error?e.message:`Failed to duplicate workflow`)}finally{y(null)}},[a,c]),Qe=(0,Q.useCallback)(async()=>{if(!a){D.error(`Create or select a workflow first`);return}y(J?`deactivate-workflow`:`activate-workflow`);try{J?(await he(a),D.success(`Workflow deactivated`)):(await Me(a),D.success(`Workflow activated`))}catch(e){D.error(e instanceof Error?e.message:J?`Failed to deactivate workflow`:`Failed to activate workflow`)}finally{y(null)}},[a,J]),$e=(0,Q.useCallback)(()=>{if(!a){D.error(`Create or select a workflow first`);return}if(J){D.error(`Deactivate workflow before editing`);return}k(`agent`),j(`Worker`),N(``),_(`create-node`)},[a,J]),et=(0,Q.useCallback)(async()=>{if(!a)return;if(J){D.error(`Deactivate workflow before editing`);return}let e=M.trim()||void 0;y(`create-node`);try{if(O===`agent`){let t=X?.name??``;if(!t)return;await W.createStandaloneNode({tabId:a,nodeType:`agent`,roleName:t,name:e})}else await W.createStandaloneNode({tabId:a,nodeType:O,name:e});_(null),k(`agent`),j(`Worker`),N(``)}catch(e){D.error(e instanceof Error?e.message:`Failed to create node`)}finally{y(null)}},[a,M,O,W,X?.name,J]),tt=(0,Q.useCallback)((e,t,n)=>{z({id:e,title:t,nodeCount:n})},[]),nt=(0,Q.useCallback)(async()=>{if(le){y(`delete-tab`);try{await Se(le.id),z(null)}catch(e){D.error(e instanceof Error?e.message:`Failed to delete workflow`)}finally{y(null)}}},[le]),rt=(0,Q.useCallback)(()=>{if(!a){D.error(`Create or select a workflow first`);return}if(J){D.error(`Deactivate workflow before editing`);return}if(Ie.length<2){D.error(`Add at least two nodes before creating an edge`);return}let e=Ie[0]?.id??``,t=Ie.find(t=>t.id!==e)?.id??``;!e||!t||(F(e),R(t),_(`connect-ports`))},[a,J,Ie]);return{activeDialog:g,activeTab:q,activeTabId:a,connected:n,connectSourceId:P,connectSourcePortKey:I,connectTargetId:L,connectTargetPortKey:se,createNodeName:M,createNodeRoleName:A,createNodeType:O,createTabAllowNetwork:S,createTabTitle:b,createTabWriteDirs:w,definitionDraft:B,deleteTabTarget:le,editorMode:p,graphConnectMode:xe,graphHistory:W,graphRef:fe,handleCloseLeaderDetails:qe,handleConnectPorts:(0,Q.useCallback)(async()=>{if(!(!a||!P||!I||!L||!se)){if(J){D.error(`Deactivate workflow before editing`);return}y(`connect-ports`);try{await W.createConnection(a,P,L,I,se),_(null)}catch(e){D.error(e instanceof Error?e.message:`Failed to connect ports`)}finally{y(null)}}},[a,P,I,L,se,W,J]),handleCreateNode:et,handleCreateTab:Xe,handleDeleteTab:nt,handleDuplicateTab:Ze,handleOpenLeaderDetails:Ke,handleSaveDefinition:(0,Q.useCallback)(async()=>{if(!a)return;if(J){D.error(`Deactivate workflow before editing`);return}let e;try{e=JSON.parse(B)}catch{D.error(`Workflow JSON is invalid`);return}if(!e||typeof e!=`object`){D.error(`Workflow JSON must be an object`);return}y(`save-definition`);try{await me(a,e),D.success(`Workflow JSON saved`)}catch(e){D.error(e instanceof Error?e.message:`Failed to save workflow definition`)}finally{y(null)}},[a,B,J]),handleToggleActivation:Qe,isCompactWorkspace:h,isDragging:G,leaderDetailVisible:We,leaderNode:He,leaderPanelRunning:Ge,loadingRoles:E,openConnectDialog:rt,openCreateNodeDialog:$e,openCreateTabDialog:Ye,panelVisible:Z,pendingAction:v,regularTabAgents:Fe,requestDeleteTab:tt,resolvedPanelWidth:Ve,roles:ee,selectAgent:s,selectedAgent:Ne,selectedCreateNodeRole:X,setActiveDialog:_,setActiveTabId:c,setConnectSourceId:F,setConnectSourcePortKey:oe,setConnectTargetId:R,setConnectTargetPortKey:ce,setCreateNodeName:N,setCreateNodeRoleName:j,setCreateNodeType:k,setCreateTabAllowNetwork:C,setCreateTabTitle:x,setCreateTabWriteDirs:T,setDefinitionDraft:V,setDeleteTabTarget:z,setEditorMode:m,setGraphConnectMode:Ce,sourcePortOptions:ze,startDrag:K,tabs:t,targetPortOptions:Be,togglePanel:Je,workflowNodeOptions:Ie,workspaceRef:U,workflowLocked:J}}function Kn(){let{activeDialog:e,activeTab:t,activeTabId:n,connected:r,connectSourceId:i,connectSourcePortKey:a,connectTargetId:o,connectTargetPortKey:s,createNodeName:c,createNodeRoleName:l,createNodeType:u,createTabAllowNetwork:d,createTabTitle:f,createTabWriteDirs:p,definitionDraft:m,deleteTabTarget:h,editorMode:g,graphConnectMode:_,graphHistory:v,graphRef:y,handleCloseLeaderDetails:b,handleConnectPorts:x,handleCreateNode:S,handleCreateTab:C,handleDeleteTab:w,handleDuplicateTab:T,handleOpenLeaderDetails:ee,handleSaveDefinition:te,handleToggleActivation:E,isCompactWorkspace:ne,isDragging:D,leaderDetailVisible:O,leaderNode:k,leaderPanelRunning:A,loadingRoles:j,openConnectDialog:M,openCreateNodeDialog:re,openCreateTabDialog:N,panelVisible:ie,pendingAction:P,regularTabAgents:ae,requestDeleteTab:F,resolvedPanelWidth:I,roles:oe,selectAgent:L,selectedAgent:R,selectedCreateNodeRole:se,setActiveDialog:ce,setActiveTabId:le,setConnectSourceId:z,setConnectSourcePortKey:B,setConnectTargetId:V,setConnectTargetPortKey:ue,setCreateNodeName:de,setCreateNodeRoleName:H,setCreateNodeType:fe,setCreateTabAllowNetwork:pe,setCreateTabTitle:me,setCreateTabWriteDirs:he,setDefinitionDraft:U,setDeleteTabTarget:ge,setEditorMode:_e,setGraphConnectMode:W,sourcePortOptions:ve,startDrag:ye,tabs:be,targetPortOptions:xe,togglePanel:Se,workflowNodeOptions:Ce,workspaceRef:we,workflowLocked:Te}=Gn();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nn,{activeTabId:n,connected:r,definitionDraft:m,editorMode:g,graphConnectMode:_,graphHistory:v,graphRef:y,isCompactWorkspace:ne,isDragging:D,leaderDetailVisible:O,leaderNode:k,leaderPanelRunning:A,loadingRoles:j,onCloseLeaderDetails:b,onConnectModeChange:W,onCreateNode:re,onCreateTab:N,onDefinitionDraftChange:U,onDeleteTab:F,onDuplicateTab:T,onEditorModeChange:_e,onOpenLeaderDetails:ee,onOpenConnectDialog:M,onSaveDefinition:te,onToggleActivation:E,panelVisible:ie,pendingAction:P,regularTabAgents:ae,resolvedPanelWidth:I,roles:oe,selectAgent:L,selectedAgent:R,setActiveTabId:le,startDrag:ye,tabs:be,togglePanel:Se,workflowNodeOptions:Ce,sourcePortOptions:ve,targetPortOptions:xe,workspaceRef:we,workflowLocked:Te}),(0,$.jsx)(qt,{open:e===`create-tab`,onOpenChange:e=>{e||ce(null)},pending:P===`create-tab`,title:f,onTitleChange:me,allowNetwork:d,onAllowNetworkChange:pe,writeDirs:p,onWriteDirsChange:he,onSubmit:()=>void C()}),(0,$.jsx)(Yt,{open:e===`create-node`,onOpenChange:e=>{e||ce(null)},pending:P===`create-node`,activeTabTitle:t?.title??null,nodeType:u,onNodeTypeChange:fe,selectedRoleName:l,onRoleNameChange:H,roles:oe,loadingRoles:j,nodeName:c,onNodeNameChange:de,onSubmit:()=>void S(),submitDisabled:!n||P===`create-node`||Te||u===`agent`&&!se}),(0,$.jsx)(Xt,{open:e===`connect-ports`,onOpenChange:e=>{e||ce(null)},pending:P===`connect-ports`,activeTabTitle:t?.title??null,nodeOptions:Ce,fromNodeId:i,fromPortKey:a,toNodeId:o,toPortKey:s,fromPortOptions:ve,toPortOptions:xe,onFromNodeChange:z,onFromPortChange:B,onToNodeChange:V,onToPortChange:ue,onSubmit:()=>void x()}),(0,$.jsx)(Zt,{open:!!h,onOpenChange:e=>{e||ge(null)},pending:P===`delete-tab`,target:h,onDelete:()=>void w()})]})}export{Kn as WorkspacePage};
@@ -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{At as r,Ct as i,J as a,Mt as o,Ot as s,Qt as c,Rt as l,Vt as u,W as d,Xt as f,Y as p,Yt as m,an as h,at as g,bt as _,ct as v,en as y,ft as b,in as x,it as S,lt as C,nn as w,nt as T,q as E,rn as D,rt as O,sn as k,wt as A}from"./ui-vendor-UazN8rcv.js";import{$ as j,B as M,F as N,H as P,I as ee,L as te,R as ne,S as F,_ as re,at as ie,b as ae,c as I,et as L,g as oe,h as se,m as ce,ot as le,p as ue,rt as R,tt as z,v as de,x as B,z as fe}from"./index-Biio-CoI.js";import{n as pe,t as me}from"./markdown-vendor-C9RtvaJh.js";import{n as V}from"./surface-Bzr1FRG4.js";function he(e){return`/api/image-assets/${encodeURIComponent(e)}`}async function ge(e){let t=new FormData;return t.append(`file`,e),M(`/api/image-assets`,{method:`POST`,body:t,errorMessage:`Failed to upload image`})}var H=e(t(),1),U=n();function W({assetId:e,alt:t,mimeType:n,width:r,height:i,compact:a=!1}){let{openImage:o}=P(),s=he(e),c=typeof r==`number`&&r>0&&typeof i==`number`&&i>0?`${r} / ${i}`:void 0,l=`${n||`image asset`}${r&&i?` · ${r}x${i}`:``}`;return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(z,{type:`button`,variant:`ghost`,onClick:()=>o({src:s,alt:t,meta:l,width:r,height:i}),className:R(`group h-auto w-full flex-col items-stretch overflow-hidden rounded-xl border border-border bg-accent/20 p-0 text-left transition-colors hover:bg-accent/30 hover:text-inherit`,a?`max-w-[240px]`:`max-w-[360px]`),children:[(0,U.jsx)(`div`,{style:c?{aspectRatio:c}:void 0,className:R(`relative overflow-hidden bg-background/45`,a?`min-h-[132px]`:`min-h-[180px]`),children:(0,U.jsx)(`img`,{alt:t||`Image`,className:`h-full w-full object-cover`,loading:`lazy`,src:s})}),(0,U.jsxs)(`div`,{className:`space-y-1 px-3 py-2.5`,children:[(0,U.jsx)(`div`,{className:`text-[12px] font-medium text-foreground`,children:t||`Image`}),(0,U.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:l})]})]})})}function _e({content:e,className:t}){return(0,U.jsx)(`div`,{className:R(`min-w-0 max-w-full select-text overflow-hidden break-words [overflow-wrap:anywhere]`,t),children:(0,U.jsx)(pe,{remarkPlugins:[me],components:{p:({children:e})=>(0,U.jsx)(`p`,{className:`mb-1.5 last:mb-0 whitespace-pre-wrap`,children:e}),code:({children:e,className:t})=>t?(0,U.jsx)(`code`,{className:`block font-mono text-[0.9em] text-foreground/80`,children:e}):(0,U.jsx)(`code`,{className:`rounded bg-surface-3 px-1 py-0.5 font-mono text-[0.9em] text-foreground/90 break-all`,children:e}),pre:({children:e})=>(0,U.jsx)(`pre`,{className:`mb-1.5 max-w-full overflow-x-auto rounded bg-surface-1 p-2 text-[0.9em] leading-relaxed`,children:e}),a:({href:e,children:t})=>(0,U.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline hover:text-primary/80`,children:t}),ul:({children:e})=>(0,U.jsx)(`ul`,{className:`mb-1.5 list-disc pl-4 space-y-0.5`,children:e}),ol:({children:e})=>(0,U.jsx)(`ol`,{className:`mb-1.5 list-decimal pl-4 space-y-0.5`,children:e}),li:({children:e})=>(0,U.jsx)(`li`,{className:`leading-relaxed`,children:e}),strong:({children:e})=>(0,U.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,U.jsx)(`em`,{className:`italic text-foreground/80`,children:e}),blockquote:({children:e})=>(0,U.jsx)(`blockquote`,{className:`mb-1.5 border-l-2 border-muted-foreground pl-3 text-muted-foreground italic`,children:e}),table:({children:e})=>(0,U.jsx)(`div`,{className:`mb-1.5 overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:e})}),th:({children:e})=>(0,U.jsx)(`th`,{className:`border border-border bg-surface-2 px-2 py-1 text-left font-semibold text-foreground`,children:e}),td:({children:e})=>(0,U.jsx)(`td`,{className:`border border-border px-2 py-1 text-foreground/80`,children:e}),h1:({children:e})=>(0,U.jsx)(`h1`,{className:`mb-1.5 text-base font-bold text-foreground`,children:e}),h2:({children:e})=>(0,U.jsx)(`h2`,{className:`mb-1.5 text-sm font-bold text-foreground`,children:e}),h3:({children:e})=>(0,U.jsx)(`h3`,{className:`mb-1.5 text-xs font-bold text-foreground/90`,children:e})},children:e})})}function G(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();if(!t||!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{return JSON.stringify(JSON.parse(t),null,4)}catch{return null}}if(typeof e==`object`)try{return JSON.stringify(e,null,4)}catch{return String(e)}return null}function K({content:e,layout:t=`parts-order`,parts:n,streaming:r,markdownClassName:i,preClassName:a}){let o=F(n,e),s=o.some(e=>e.type===`image`),c=B(o,e),l=G(c);if(t===`human-attachments-top`&&s){let e=o.filter(e=>e.type===`text`);return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:o.filter(e=>e.type===`image`).map((e,t)=>(0,U.jsx)(W,{alt:e.alt,assetId:e.asset_id,compact:!0,height:e.height,mimeType:e.mime_type,width:e.width},`${t}-attachment-${e.asset_id}`))}),e.length>0?(0,U.jsx)(K,{content:B(e),markdownClassName:i,preClassName:a,parts:e,streaming:r}):null]})}return l?(0,U.jsx)(`pre`,{className:R(`select-text whitespace-pre-wrap break-words rounded-xl border border-border bg-background/40 px-3.5 py-3 text-[11px] font-mono leading-relaxed text-foreground/80`,a),children:(0,U.jsx)(ve,{text:l,streaming:r})}):o.length>0&&s?(0,U.jsx)(`div`,{className:`space-y-3`,children:o.map((e,t)=>e.type===`text`?(0,U.jsx)(K,{content:e.text,markdownClassName:i,preClassName:a},`${t}-text`):(0,U.jsx)(W,{alt:e.alt,assetId:e.asset_id,height:e.height,mimeType:e.mime_type,width:e.width},`${t}-image-${e.asset_id}`))}):r?(0,U.jsx)(`div`,{className:R(`min-w-0 select-text whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,i),children:(0,U.jsx)(ve,{text:c,streaming:!0})}):(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(_e,{content:c,className:i})})}function ve({text:e,streaming:t}){return(0,U.jsxs)(U.Fragment,{children:[e,t?(0,U.jsx)(`span`,{className:`streaming-cursor`}):null]})}var q=[{name:`/clear`,description:`Clear the current chat.`,usage:`/clear`},{name:`/compact`,description:`Compress this chat for future replies.`,usage:`/compact [focus]`},{name:`/help`,description:`Show available commands and usage.`,usage:`/help`}],ye=/^\/\S*/;function be(e){let t=e.trimStart(),n=e.slice(0,e.length-t.length),r=t.match(ye)?.[0]??`/`;return{leadingWhitespace:n,trimmedStart:t,token:r,suffix:t.slice(r.length)}}function J(e,t){return t<=0?0:Math.min(e,t-1)}function xe(e){let{trimmedStart:t,token:n}=be(e);return t.startsWith(`/`)?{filtered:n===`/`?q:q.filter(e=>e.name.startsWith(n)),isCommandInput:!0,token:n}:{filtered:[],isCommandInput:!1,token:``}}function Y(e,t,n){let r=t.token===n?J(t.index,e.length):0;return{selectedCommand:e[Math.min(r,Math.max(e.length-1,0))]??null,selectedCommandIndex:r}}function Se(e,t,n,r){if(e.length===0)return{index:0,token:n};let{selectedCommandIndex:i}=Y(e,t,n);return{index:(i+r+e.length)%e.length,token:n}}function Ce(e,t){let{trimmedStart:n,token:r}=be(e);return r===t&&(n===t||n.startsWith(`${t} `))}function we(e,t){let{leadingWhitespace:n,suffix:r}=be(e);return r?`${n}${t.name}${r.startsWith(` `)?r:` ${r}`}`:`${n}${t.name} `}function X({busy:e=!1,commandsEnabled:t=!0,disabled:n,images:r=[],imageInputEnabled:i=!0,input:a,onAddImages:o=()=>{},onChange:s,onNavigateHistory:c,onKeyDown:u,onRemoveImage:d=()=>{},onSend:f,onStop:p,overlay:m=!1,placeholder:g,targetLabel:_=`Assistant`,stopping:v=!1,suppressCommandNavigation:y=!1}){let b=(0,H.useRef)(null),x=(0,H.useRef)(null),S=e?v?`Stopping...`:`Stop`:`Send`,C=e?v||!p:n,{filtered:w,isCommandInput:T,token:E}=t?xe(a):{filtered:[],isCommandInput:!1,token:``},[D,k]=(0,H.useState)({index:0,token:``}),[A,M]=(0,H.useState)(null),N=t&&r.length===0&&T&&A!==E,{selectedCommand:P,selectedCommandIndex:ee}=Y(w,D,E);(0,H.useLayoutEffect)(()=>{let e=b.current;if(!e)return;let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,r=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0,a=n+r+i,o=n*8+r+i;e.style.height=`0px`;let s=Math.min(Math.max(e.scrollHeight,a),o);e.style.height=`${s}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`},[a]);let te=e=>{let n=t?xe(e):{isCommandInput:!1,token:``};n.isCommandInput?n.token!==E&&(k({index:0,token:n.token}),A&&A!==n.token&&M(null)):(M(null),k({index:0,token:``})),s(e)},ne=e=>{s(we(a,e)),k({index:0,token:e.name}),M(null),b.current?.focus()},F=()=>{M(null),k({index:0,token:``})};return(0,U.jsxs)(`div`,{className:R(m?`w-full pointer-events-auto`:`border-t border-border p-2.5`),children:[N?(0,U.jsx)(`div`,{role:`listbox`,"aria-label":`Available commands`,className:`pointer-events-auto mb-2 overflow-hidden rounded-xl border border-border bg-surface-overlay shadow-sm`,children:w.length>0?w.map((e,t)=>{let n=t===ee;return(0,U.jsxs)(z,{type:`button`,variant:`ghost`,role:`option`,"aria-selected":n,onMouseDown:t=>{t.preventDefault(),ne(e)},className:R(`h-auto w-full items-start justify-start gap-3 rounded-none px-3 py-2.5 text-left whitespace-normal transition-colors`,n?`bg-accent/60 hover:bg-accent/60`:`hover:bg-accent/35`),children:[(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded-full border border-border bg-accent/45 px-2 py-0.5 font-mono text-[11px] text-foreground`,children:e.name}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block text-[12px] font-medium text-foreground`,children:e.description}),(0,U.jsx)(`span`,{className:`mt-1 block font-mono text-[11px] text-muted-foreground`,children:e.usage})]})]},e.name)}):(0,U.jsx)(`div`,{className:`px-3 py-3 text-[12px] text-muted-foreground`,children:`No matching commands.`})}):null,(0,U.jsxs)(`div`,{className:`rounded-md border border-border bg-background/30 px-2 py-1 shadow-sm transition-[border-color,background-color,box-shadow] duration-200 hover:border-ring/35 focus-within:border-ring/45 focus-within:ring-[3px] focus-within:ring-ring/35`,children:[r.length>0?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2 border-b border-border px-0.5 py-2`,children:r.map(e=>(0,U.jsx)(Ee,{image:e,onRemove:()=>d(e.id)},e.id))}):null,(0,U.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1`,children:[(0,U.jsx)(L,{ref:x,accept:`image/png,image/jpeg,image/gif,image/webp`,className:`hidden`,multiple:!0,onChange:e=>{e.target.files&&e.target.files.length>0&&(F(),o(e.target.files)),e.currentTarget.value=``},type:`file`}),(0,U.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":i?`Add images`:`Current model does not support image input`,disabled:!i,onClick:()=>x.current?.click(),className:R(`shrink-0 rounded-full transition-colors disabled:opacity-35`,i?`bg-accent/55 text-foreground hover:bg-accent`:`bg-accent/20 text-muted-foreground`),children:(0,U.jsx)(l,{className:`size-4`})}),(0,U.jsx)(j,{ref:b,value:a,onChange:e=>te(e.target.value),onKeyDown:e=>{if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&c&&c(e.key===`ArrowUp`?-1:1,{start:e.currentTarget.selectionStart,end:e.currentTarget.selectionEnd})){e.preventDefault();return}if(y&&N&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){u(e);return}if(N){let t=w.length>0&&P&&!Ce(a,P.name)?P:null;if(e.key===`Escape`){e.preventDefault(),M(E);return}if(w.length>0&&e.key===`ArrowDown`){e.preventDefault(),k(Se(w,D,E,1));return}if(w.length>0&&e.key===`ArrowUp`){e.preventDefault(),k(Se(w,D,E,-1));return}if(t&&e.key===`Tab`&&!e.shiftKey){e.preventDefault(),ne(t);return}if(t&&e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ne(t);return}}u(e)},onPaste:e=>{let t=Te(e.clipboardData?.items);t.length===0||!i||(e.preventDefault(),F(),o(t))},placeholder:g??(t?`Do anything`:`Message ${_}`),rows:1,className:R(`min-h-5 w-full resize-none self-center border-0 bg-transparent px-0.5 py-0 text-[13px] leading-5 text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0`,`rounded-sm`,a.length===0&&`truncate`)}),(0,U.jsxs)(z,{type:`button`,variant:e?`destructive`:`default`,size:`sm`,onClick:e?p:f,disabled:C,"aria-label":e?`Stop ${_}`:`Send ${_} message`,className:R(`shrink-0 rounded-full transition-all duration-300 active:scale-[0.96] disabled:opacity-30`,`h-8 gap-1.5 px-3.5`),children:[e?(0,U.jsx)(O,{className:`size-3.5 fill-current`,strokeWidth:2.4}):(0,U.jsx)(h,{className:`size-4`,strokeWidth:2.5}),(0,U.jsx)(`span`,{className:`text-[11px] font-medium`,children:S})]})]})]}),i?null:(0,U.jsx)(`div`,{className:`px-1.5 pt-2 text-[11px] text-muted-foreground`,children:`Current model does not support image input.`})]})}function Te(e){return e?Array.from(e).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).flatMap(e=>{let t=e.getAsFile();return t?[t]:[]}):[]}function Ee({image:e,onRemove:t}){let{openImage:n}=P(),r=e.status===`uploading`?`Uploading...`:e.width&&e.height?`${e.width}x${e.height}`:`Ready`;return(0,U.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border bg-background/35 transition-colors hover:border-ring/35`,children:[(0,U.jsxs)(z,{"aria-label":`Preview ${e.name}`,type:`button`,variant:`ghost`,className:`h-auto w-auto items-start justify-start rounded-none p-0 text-left hover:bg-transparent hover:text-inherit`,onClick:()=>n({src:e.previewUrl,alt:e.name,meta:r,width:e.width,height:e.height}),children:[(0,U.jsx)(`img`,{alt:e.name,className:`h-20 w-20 object-cover`,src:e.previewUrl}),(0,U.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-background/80 px-2 py-1 text-[10px] text-foreground/84`,children:[(0,U.jsx)(`div`,{className:`truncate`,children:e.name}),(0,U.jsx)(`div`,{className:`text-muted-foreground`,children:r})]})]}),(0,U.jsx)(z,{"aria-label":`Remove ${e.name}`,type:`button`,variant:`ghost`,size:`icon-xs`,className:`absolute right-1 top-1 z-10 rounded-full bg-background/72 text-muted-foreground hover:bg-background/90 hover:text-foreground`,onClick:t,children:(0,U.jsx)(a,{className:`size-3.5`})})]})}function Z({text:e,className:t,iconClassName:n,copiedClassName:r}){let[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(null),s=(0,H.useRef)(!0);return(0,H.useEffect)(()=>()=>{s.current=!1,o.current&&clearTimeout(o.current)},[]),(0,U.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{s.current&&(a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{s.current&&a(!1)},1500))})},"aria-label":`Copy`,className:R(`size-5 rounded p-0.5 text-muted-foreground opacity-0 transition-all hover:bg-accent/45 hover:text-foreground group-hover:opacity-100`,t),title:`Copy`,children:i?(0,U.jsx)(w,{className:R(`size-3 text-foreground`,r)}):(0,U.jsx)(m,{className:R(`size-3`,n)})})}var De=(0,H.memo)(function({allowHumanMessageRetry:e=!0,bottomInset:t=0,scrollRef:n,items:r,nodes:i,onRetryHumanMessage:a,onCancelPendingSend:o,onScroll:s,retryImageInputEnabled:c=!0,retryingMessageId:l=null,runningHint:u=null}){let d=r.filter(e=>e.type!==`SystemEntry`);return(0,U.jsx)(`div`,{ref:n,onScroll:s,style:{paddingBottom:`${14+t}px`,scrollPaddingBottom:`${14+t}px`},className:`flex-1 overflow-y-auto px-3 pt-3`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col space-y-2.5`,children:[d.length===0&&!u?(0,U.jsx)(Ve,{}):null,d.map((t,n)=>(0,U.jsx)(`div`,{className:`[content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:(0,U.jsx)(ke,{allowHumanMessageRetry:e,item:t,nodes:i,onRetryHumanMessage:a,onCancelPendingSend:o,retryImageInputEnabled:c,retryingMessageId:l})},Be(t,n))),u?(0,U.jsx)(`div`,{children:(0,U.jsx)(Oe,{label:u.label,toolName:u.toolName})}):null]})})});function Oe({label:e,toolName:t}){return(0,U.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,U.jsxs)(`div`,{className:`inline-flex max-w-full items-center gap-2 rounded-full border border-border bg-accent/25 px-3 py-1.5 text-[11px] text-muted-foreground/82`,children:[(0,U.jsx)(`span`,{className:`flex items-center gap-1.5`,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-muted-foreground/80`,style:{animationDelay:`${e*140}ms`}},e))}),(0,U.jsx)(`span`,{children:e}),t?(0,U.jsx)(`span`,{className:`truncate rounded-full border border-border bg-background/40 px-2 py-0.5 font-mono text-[10px] text-foreground/80`,children:t}):null]})})}var ke=(0,H.memo)(function({allowHumanMessageRetry:e,item:t,nodes:n,onRetryHumanMessage:r,onCancelPendingSend:i,retryImageInputEnabled:a,retryingMessageId:o}){if(t.type===`PendingHumanMessage`)return(0,U.jsx)(je,{content:t.content,parts:t.parts,retrying:!1,pending:!0});if(t.type===`PendingSendMessage`)return(0,U.jsx)(Ae,{content:t.content,onCancel:i?()=>i(t.id):void 0,parts:t.parts,sendFailed:t.send_failed,targetState:t.target_state});switch(t.type){case`ReceivedMessage`:if(F(t.parts,t.content).length===0)return null;if(t.from_id===`human`){let n=F(t.parts,t.content).some(e=>e.type===`image`)&&!a;return(0,U.jsx)(je,{allowRetry:e,content:B(t.parts,t.content),retryDisabled:n,retryDisabledReason:n?`Current model does not support image input`:void 0,messageId:t.message_id??null,onRetry:t.message_id&&r&&!n?()=>r(t.message_id):void 0,parts:t.parts,retrying:o===t.message_id})}return(0,U.jsx)(Ne,{content:B(t.parts,t.content),parts:t.parts,icon:(0,U.jsx)(s,{className:`size-3.5 text-foreground/68`}),label:`From ${I(t.from_id??``,n)}`,tone:`received`,streaming:t.streaming});case`AssistantText`:return F(t.parts,t.content).length===0?null:(0,U.jsx)(Me,{content:B(t.parts,t.content),parts:t.parts,streaming:t.streaming});case`SentMessage`:return F(t.parts,t.content).length===0?null:(0,U.jsx)(Ne,{content:B(t.parts,t.content),parts:t.parts,icon:(0,U.jsx)(v,{className:`size-3.5 text-foreground/58`}),label:`To ${(t.to_id?[t.to_id]:(t.to_ids??[]).filter(e=>!!e)).map(e=>I(e,n)).join(`, `)||`Unknown`}`,tone:`sent`,streaming:t.streaming});case`AssistantThinking`:return(0,U.jsx)(Pe,{item:t});case`ToolCall`:return(0,U.jsx)(Fe,{item:t});case`CommandResultEntry`:return(0,U.jsx)(Ie,{item:t});case`ErrorEntry`:return(0,U.jsx)(Le,{content:t.content??``});default:return null}});function Ae({content:e,onCancel:t,parts:n,sendFailed:r,targetState:i}){let a=r||i===`error`||i===`terminated`,o=a?`Needs attention`:i===`sleeping`?`Waiting for wake-up`:`Waiting to send`;return(0,U.jsx)(`div`,{className:`group mt-2 flex min-w-0 flex-col items-end`,children:(0,U.jsx)(`div`,{className:R(`min-w-0 overflow-hidden px-2.5 py-1.5 text-[13px] [overflow-wrap:anywhere]`,`max-w-[84%] rounded-lg border bg-background/50 text-foreground`,a?`border-destructive/45`:`border-ring/35`),children:(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,U.jsx)(K,{content:e,layout:`human-attachments-top`,markdownClassName:`text-sm text-foreground`,parts:n,preClassName:`text-foreground/90`}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,U.jsxs)(`span`,{className:R(`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium`,a?`border-destructive/35 bg-destructive/10 text-destructive`:`border-ring/25 bg-ring/10 text-foreground/80`),children:[(0,U.jsx)(C,{className:`size-3`}),o]}),t?(0,U.jsx)(z,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,className:`h-auto rounded-full border border-border bg-accent/35 px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-accent/45 hover:text-foreground`,children:`Cancel`}):null]})]})})})}function je({allowRetry:e=!0,content:t,messageId:n,onRetry:r,parts:i,retryDisabled:a,retryDisabledReason:s,retrying:c,pending:l=!1}){let u=e&&!l&&!!n&&(!!r||a);return(0,U.jsxs)(`div`,{className:`group mt-2 flex min-w-0 flex-col items-end`,children:[(0,U.jsx)(`div`,{className:R(`min-w-0 overflow-hidden px-2.5 py-1.5 text-[13px] [overflow-wrap:anywhere]`,`max-w-[84%] rounded-lg border border-border bg-accent/80 text-accent-foreground`,l&&`opacity-80`),children:(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,U.jsx)(K,{content:t,layout:`human-attachments-top`,parts:i,markdownClassName:`text-sm text-accent-foreground`,preClassName:`text-accent-foreground/90`}),l?(0,U.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-accent/70 px-2 py-0.5 text-[10px] font-medium text-accent-foreground`,children:[(0,U.jsx)(o,{className:`size-3 animate-spin`}),`Sending`]}):null]})}),(0,U.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,U.jsx)(Z,{text:t}),u?(0,U.jsxs)(z,{type:`button`,variant:`ghost`,size:`xs`,onClick:r,disabled:c||a,title:s,className:R(`h-auto rounded-full border border-border px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-accent/45 hover:text-foreground disabled:opacity-45`,`bg-accent/35`),children:[c?(0,U.jsx)(o,{className:`size-3 animate-spin`}):(0,U.jsx)(b,{className:`size-3`}),(0,U.jsx)(`span`,{children:c?`Retrying...`:`Retry`})]}):null]})]})}function Me({content:e,parts:t,streaming:n}){return(0,U.jsxs)(`div`,{className:`group min-w-0 w-full`,children:[(0,U.jsx)(K,{content:e,parts:t,streaming:n,markdownClassName:`text-sm text-foreground`,preClassName:`text-foreground/90`}),(0,U.jsx)(`div`,{className:`mt-1 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,U.jsx)(Z,{text:e})})]})}function Ne({content:e,parts:t,icon:n,label:r,tone:i,streaming:a}){let[o,s]=(0,H.useState)(!!a);return(0,U.jsxs)(`div`,{className:R(`min-w-0 w-full px-2 py-1.5`,`border-l border-border pl-3`,i===`received`&&`border-border bg-accent/20`,i===`sent`&&`border-border bg-background/24`),children:[(0,U.jsxs)(`div`,{className:`flex w-full items-center gap-2 text-left`,children:[(0,U.jsxs)(z,{type:`button`,variant:`ghost`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`h-auto min-w-0 flex-1 justify-start gap-2 rounded-md bg-transparent px-0 py-0 text-left text-inherit shadow-none hover:bg-transparent hover:text-inherit focus-visible:ring-2 focus-visible:ring-ring/50`,children:[(0,U.jsx)(`span`,{className:`flex size-5 shrink-0 translate-y-px items-center justify-center text-current`,children:n}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-semibold leading-none text-foreground/88`,children:r}),a?(0,U.jsxs)(`span`,{className:`inline-flex size-5 items-center justify-center`,children:[(0,U.jsxs)(`span`,{className:`relative flex size-2.5 items-center justify-center`,children:[(0,U.jsx)(`span`,{className:`absolute inline-flex size-2.5 animate-ping rounded-full bg-ring/28`}),(0,U.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-ring/82`})]}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Live`})]}):null,(0,U.jsx)(y,{className:R(`size-4 shrink-0 text-muted-foreground transition-transform`,o&&`rotate-90`)})]}),(0,U.jsx)(`span`,{className:`shrink-0`,children:(0,U.jsx)(Z,{text:e})})]}),o?(0,U.jsx)(`div`,{className:`mt-2 min-w-0`,children:(0,U.jsx)(K,{content:e,parts:t,streaming:a,markdownClassName:`text-[12px] text-foreground/78`,preClassName:`text-foreground/74`})}):null]})}function Pe({item:e}){return(0,U.jsx)(Re,{label:`Thinking`,icon:(0,U.jsx)(D,{className:`size-3.5 text-foreground/72`}),streaming:e.streaming,defaultOpen:e.streaming??!1,children:(0,U.jsx)(K,{content:e.content,streaming:e.streaming,markdownClassName:`text-[13px] text-foreground/80`,preClassName:`text-foreground/75`})})}function Fe({item:e}){let t=e.tool_name===`idle`,n=!!e.streaming&&!t,r=G(e.arguments)??``,i=G(e.result);return(0,U.jsx)(Re,{label:ze(e.tool_name),icon:(0,U.jsx)(p,{className:`size-3.5 text-muted-foreground`}),streaming:n,defaultOpen:n,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground/80`,children:`Arguments`}),(0,U.jsx)(`pre`,{className:`select-text whitespace-pre-wrap break-words rounded-xl border border-border bg-background/40 px-3.5 py-3 text-[11px] font-mono leading-relaxed text-foreground/78`,children:r})]}),e.result||!t?(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground/80`,children:`Result`}),e.result?(0,U.jsx)(K,{content:i??e.result,streaming:n,markdownClassName:`text-[12px] leading-relaxed text-foreground/80`,preClassName:`text-foreground/74`}):(0,U.jsx)(`div`,{className:`rounded-xl border border-border bg-accent/15 px-3.5 py-3 text-[12px] italic text-muted-foreground`,children:n?`Running...`:`No result`})]}):null]})})}function Ie({item:e}){return(0,U.jsxs)(`div`,{className:`min-w-0 w-full space-y-3 border-l border-graph-status-running/30 bg-graph-status-running/[0.08] px-3 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(S,{className:`size-4 text-graph-status-running`}),(0,U.jsx)(`span`,{className:`text-[11px] font-medium text-graph-status-running/90`,children:`Command Result`}),e.command_name?(0,U.jsx)(`span`,{className:`rounded-full border border-graph-status-running/14 bg-background/35 px-2 py-0.5 font-mono text-[10px] text-graph-status-running/80`,children:e.command_name}):null,(0,U.jsx)(`span`,{className:`ml-auto`,children:(0,U.jsx)(Z,{text:e.content??``,className:`text-graph-status-running/72 hover:bg-graph-status-running/[0.1] hover:text-graph-status-running`,iconClassName:`text-current`,copiedClassName:`text-graph-status-running`})})]}),(0,U.jsx)(K,{content:e.content,markdownClassName:`text-[13px] text-foreground`,preClassName:`text-foreground/90`})]})}function Le({content:e}){return(0,U.jsxs)(`div`,{className:`min-w-0 w-full space-y-3 border-l-2 border-graph-status-error/40 bg-graph-status-error/[0.1] px-3 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(c,{className:`size-4 text-graph-status-error`}),(0,U.jsx)(`span`,{className:`text-[11px] font-medium text-graph-status-error`,children:`Error`}),(0,U.jsx)(`span`,{className:`ml-auto`,children:(0,U.jsx)(Z,{text:e,className:`text-graph-status-error/72 hover:bg-graph-status-error/[0.1] hover:text-graph-status-error`,iconClassName:`text-current`,copiedClassName:`text-graph-status-error`})})]}),(0,U.jsx)(`p`,{className:`select-text whitespace-pre-wrap break-words text-[13px] leading-relaxed text-graph-status-error/82`,children:e})]})}function Re({label:e,icon:t,streaming:n,defaultOpen:r,children:i}){let[a,o]=(0,H.useState)(r);return(0,U.jsxs)(`div`,{className:`min-w-0 w-full border-l border-border py-1.5 pl-3 transition-all duration-300`,children:[(0,U.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>o(e=>!e),className:`h-auto w-full justify-start gap-2 px-0 py-0 text-left hover:bg-transparent hover:text-inherit`,children:[(0,U.jsx)(`span`,{className:`flex size-5 shrink-0 translate-y-px items-center justify-center text-muted-foreground`,children:t}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(`span`,{className:`block truncate text-[11px] font-medium text-muted-foreground`,children:e})}),n?(0,U.jsxs)(`span`,{className:`ml-auto inline-flex size-5 items-center justify-center`,children:[(0,U.jsxs)(`span`,{className:`relative flex size-2.5 items-center justify-center`,children:[(0,U.jsx)(`span`,{className:`absolute inline-flex size-2.5 animate-ping rounded-full bg-ring/30`}),(0,U.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-ring/82`})]}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Live`})]}):null,(0,U.jsx)(y,{className:R(`size-3.5 shrink-0 text-muted-foreground/70 transition-transform duration-200`,a&&`rotate-90`)})]}),a?(0,U.jsx)(`div`,{className:`mt-3 min-w-0`,children:i}):null]})}function ze(e){return e?e.split(`_`).map(e=>e.length>0?`${e[0].toUpperCase()}${e.slice(1)}`:e).join(` `):`Tool Call`}function Be(e,t){return e.type===`PendingHumanMessage`||e.type===`PendingSendMessage`?e.id:`${e.type}-${e.timestamp}-${e.message_id??``}-${e.tool_call_id??``}-${t}`}function Ve(){return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-4 py-8`,children:(0,U.jsxs)(`div`,{className:`max-w-[220px] space-y-3 text-center`,children:[(0,U.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center`,children:(0,U.jsx)(s,{className:`size-5 text-primary`})}),(0,U.jsx)(`div`,{className:`space-y-1`,children:(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Start a conversation`})})]})})}function He(){let e=(0,H.useRef)(null),[t,n]=(0,H.useState)(0);return(0,H.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{n(Math.ceil(t.getBoundingClientRect().height))};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(()=>{r()});return i.observe(t),()=>{i.disconnect()}},[]),{height:t,ref:e}}function Ue(e){return e.filter(e=>e.type===`SystemEntry`)}function We(e){return e>0xe8d4a51000?e:Math.round(e*1e3)}function Ge(e){let t=``,n=``,r=new Map,i=new Map,a=new Map,o=[];for(let s of e)switch(s.type){case`ContentDelta`:t+=s.text;break;case`ThinkingDelta`:n+=s.text;break;case`ToolResultDelta`:r.set(s.tool_call_id,(r.get(s.tool_call_id)??``)+s.text);break;case`SentMessageDelta`:i.has(s.message_id)||o.push({kind:`sent`,messageId:s.message_id}),i.set(s.message_id,{toId:s.to_id,text:(i.get(s.message_id)?.text??``)+s.text});break;case`ReceivedMessageDelta`:a.has(s.message_id)||o.push({kind:`received`,messageId:s.message_id}),a.set(s.message_id,{fromId:s.from_id,text:(a.get(s.message_id)?.text??``)+s.text});break}return{content:t,thinking:n,toolResults:r,sentMessages:i,receivedMessages:a,messageOrder:o}}function Ke(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function qe(e){let t=We(e.timestamp);switch(e.type){case`ReceivedMessage`:return e.message_id?`${e.type}:${e.message_id}`:[e.type,t,e.from_id??``,B(e.parts,e.content)].join(`:`);case`SentMessage`:return e.message_id?`${e.type}:${e.message_id}`:[e.type,t,e.to_id??e.to_ids?.[0]??``,B(e.parts,e.content)].join(`:`);case`ToolCall`:return e.tool_call_id?`${e.type}:${e.tool_call_id}`:[e.type,t,e.tool_name??``,Ke(e.arguments),e.result??``,e.streaming?`streaming`:`final`].join(`:`);default:return[e.type,t,e.content??``].join(`:`)}}function Je(e,t){return e.type!==`ToolCall`||t.type!==`ToolCall`?!1:e.streaming&&!t.streaming?!0:!e.result&&!!t.result}function Ye(e){let t=[],n=new Map;for(let r of e){let e=qe(r),i=n.get(e);if(i===void 0){n.set(e,t.length),t.push(r);continue}let a=t[i];Je(a,r)&&(t[i]=r)}return t}function Xe({history:e,incremental:t,deltas:n,fetchedAt:r}){let i=Ye(t&&t.length>0?[...e,...t]:[...e]);if(!n||n.length===0)return i;let{content:a,thinking:o,toolResults:s,sentMessages:c,receivedMessages:l,messageOrder:u}=Ge(n),d=r/1e3;if(o&&i.push({type:`AssistantThinking`,content:o,timestamp:d,streaming:!0}),a&&i.push({type:`AssistantText`,content:a,timestamp:d,streaming:!0}),s.size>0)for(let[e,t]of s)for(let n=i.length-1;n>=0;--n){let r=i[n];if(r.type===`ToolCall`&&r.tool_call_id===e&&r.streaming){i[n]={...r,result:t};break}}for(let e of u){if(e.kind===`sent`){let t=c.get(e.messageId);if(!t||i.some(t=>t.type===`SentMessage`&&t.message_id===e.messageId))continue;i.push({type:`SentMessage`,message_id:e.messageId,to_id:t.toId,content:t.text,parts:[{type:`text`,text:t.text}],timestamp:d,streaming:!0});continue}let t=l.get(e.messageId);t&&(i.some(t=>t.type===`ReceivedMessage`&&t.message_id===e.messageId)||i.push({type:`ReceivedMessage`,message_id:e.messageId,from_id:t.fromId,content:t.text,parts:[{type:`text`,text:t.text}],timestamp:d,streaming:!0}))}return i}var Ze=`flowent.chatInputHistory`,Qe=50,$e=new Set,et=new Map,tt=new Map;function nt(e){return`${Ze}.${e}`}function rt(e){return e.trim().length>0}function it(e){if(!e||typeof e!=`object`)return null;let t=typeof e.text==`string`?e.text:null,n=typeof e.timestamp==`number`?e.timestamp:null;return t===null||n===null||!rt(t)?null:{text:t,images:[],timestamp:n}}function at(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(nt(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.map(e=>it(e)).filter(e=>e!==null).slice(-Qe):[]}catch{return[]}}function ot(e,t){if(!(typeof window>`u`))try{let n=t.filter(({text:e})=>rt(e)).map(({text:e,timestamp:t})=>({text:e,timestamp:t}));window.localStorage.setItem(nt(e),JSON.stringify(n))}catch{return}}function st(e){$e.has(e)||(et.set(e,at(e)),$e.add(e))}function ct(e){let t=tt.get(e);if(t)for(let e of t)e()}function lt(e){return st(e),et.get(e)??[]}function ut(e,t){st(e);let n=tt.get(e)??new Set;return n.add(t),tt.set(e,n),()=>{let n=tt.get(e);n?.delete(t),n&&n.size===0&&tt.delete(e)}}function dt(e,t){st(e);let n=[...et.get(e)??[],t].slice(-Qe);et.set(e,n),ot(e,n),ct(e)}var ft=10;function pt(e){return Math.max(0,e.scrollHeight-e.clientHeight)-e.scrollTop<=ft}function mt(){return globalThis.crypto?.randomUUID?.()??`draft-${Date.now()}-${Math.random()}`}function ht(e){return e.status===`ready`&&!!e.assetId}function gt(e){e.previewUrl.startsWith(`blob:`)&&URL.revokeObjectURL(e.previewUrl)}function _t(e){for(let t of e)gt(t)}function vt(e){return e.filter(ht).map(e=>({assetId:e.assetId,mimeType:e.mimeType,width:e.width,height:e.height,name:e.name}))}function yt(e){return e.images.map((t,n)=>({id:`history-${e.timestamp}-${n}`,assetId:t.assetId,previewUrl:he(t.assetId),mimeType:t.mimeType,width:t.width,height:t.height,name:t.name,status:`ready`}))}function bt(e,t){return e.length===t.images.length?t.images.every((t,n)=>{let r=e[n];return!!r&&r?.status===`ready`&&r.assetId===t.assetId&&r.mimeType===t.mimeType&&r.width===t.width&&r.height===t.height&&r.name===t.name}):!1}function xt(e,t){let n=[];e&&n.push({type:`text`,text:e});for(let e of t)n.push({type:`image`,asset_id:e.assetId,mime_type:e.mimeType,width:e.width,height:e.height,alt:e.name});return n}function St(e,t,n){return{id:`pending-${n}-${Math.random().toString(36).slice(2,8)}`,type:`PendingHumanMessage`,from:`human`,content:e,parts:t,timestamp:n,message_id:null}}function Ct(e){return{id:`pending-send-${e.timestamp}-${Math.random().toString(36).slice(2,8)}`,type:`PendingSendMessage`,from:`human`,content:e.content,parts:e.parts,timestamp:e.timestamp,message_id:null,target_id:e.targetId,target_state:e.targetState??null,history_entry:e.historyEntry,history_entry_scope:e.historyScope,send_failed:e.sendFailed}}async function wt(e){return new Promise(t=>{let n=URL.createObjectURL(e),r=new Image;r.onload=()=>{let e=r.naturalWidth,i=r.naturalHeight;URL.revokeObjectURL(n),t(e>0&&i>0?{width:e,height:i}:null)},r.onerror=()=>{URL.revokeObjectURL(n),t(null)},r.src=n})}async function Tt(e){return Promise.all(e.map(async e=>{let t=await wt(e);return{id:mt(),assetId:null,previewUrl:URL.createObjectURL(e),mimeType:e.type||null,width:t?.width??null,height:t?.height??null,name:e.name,status:`uploading`}}))}var Et=(0,H.memo)(function({agentLabel:e=`Agent`,history:t,nodes:n}){return(0,U.jsx)(`div`,{className:`space-y-1.5 p-2.5`,children:t.map((t,r)=>(0,U.jsx)(`div`,{className:`[content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:(0,U.jsx)(jt,{agentLabel:e,entry:t,nodes:n})},`${r}-${t.timestamp}-${t.type}-${t.message_id??``}-${t.tool_call_id??``}`))})});function Q({content:e,markdownClassName:t,preClassName:n,streaming:r}){let i=G(e);return i?(0,U.jsx)(`pre`,{className:R(`select-text text-[11px] whitespace-pre-wrap break-words leading-relaxed`,n),children:(0,U.jsx)(Dt,{text:i,streaming:r})}):r?(0,U.jsx)(`pre`,{className:R(`select-text text-[11px] whitespace-pre-wrap break-words leading-relaxed`,n),children:(0,U.jsx)(Dt,{text:e??``,streaming:!0})}):(0,U.jsx)(_e,{content:e??``,className:R(`text-[11px] leading-relaxed`,t)})}function Dt({text:e,streaming:t}){return(0,U.jsxs)(U.Fragment,{children:[e,t&&(0,U.jsx)(`span`,{className:`streaming-cursor`})]})}function Ot({entry:e,markdownClassName:t,preClassName:n}){let r=F(e.parts,e.content);return r.length===0?null:r.every(e=>e.type===`text`)?(0,U.jsx)(Q,{content:B(r),streaming:e.streaming,markdownClassName:t,preClassName:n}):(0,U.jsx)(`div`,{className:`space-y-2`,children:r.map((e,r)=>e.type===`text`?(0,U.jsx)(Q,{content:e.text,markdownClassName:t,preClassName:n},`${r}-${e.type}`):(0,U.jsx)(W,{alt:e.alt,assetId:e.asset_id,compact:!0,height:e.height,mimeType:e.mime_type,width:e.width},`${r}-${e.type}-${e.asset_id}`))})}function kt(e){return!e.from_output_port_key||!e.to_input_port_key?``:` · ${e.from_output_port_key} to ${e.to_input_port_key}`}function At(e){if(e.value_summary)return e.value_summary;if(e.content)return e.content;if(e.value===void 0)return``;if(typeof e.value==`string`)return e.value;try{return JSON.stringify(e.value)}catch{return String(e.value)}}var jt=(0,H.memo)(function({agentLabel:e,entry:t,nodes:n}){switch(t.type){case`SystemEntry`:return(0,U.jsx)($,{label:`System`,icon:(0,U.jsx)(T,{className:`size-3 text-muted-foreground`}),className:`border-border/40 bg-surface-1/24`,defaultOpen:!1,children:(0,U.jsx)(Q,{content:t.content,markdownClassName:`text-muted-foreground`,preClassName:`text-muted-foreground leading-relaxed`})});case`ReceivedMessage`:return(0,U.jsx)($,{label:`From ${I(t.from_id??``,n)}${kt(t)}`,icon:(0,U.jsx)(s,{className:`size-3 text-foreground/70`}),className:`border-border bg-accent/20`,labelClassName:`text-foreground/70`,actions:(0,U.jsx)(Z,{text:B(t.parts,t.content)}),defaultOpen:t.streaming??!1,children:(0,U.jsx)(Ot,{entry:t,markdownClassName:`text-foreground/90`,preClassName:`text-foreground/90 leading-relaxed`})});case`AssistantThinking`:return(0,U.jsx)($,{label:`Thinking`,icon:(0,U.jsx)(D,{className:`size-3 text-foreground/72`}),className:`border-border bg-surface-1/28`,labelClassName:`text-foreground/72`,defaultOpen:!1,children:(0,U.jsx)(Q,{content:t.content,streaming:t.streaming,markdownClassName:`text-foreground/82`,preClassName:`text-foreground/82 leading-relaxed`})});case`SentMessage`:return(0,U.jsx)($,{label:`To ${(t.to_id==null?(t.to_ids??[]).filter(e=>!!e):[t.to_id]).map(e=>I(e,n)).join(`, `)||`Unknown`}${kt(t)}`,icon:(0,U.jsx)(v,{className:`size-3 text-foreground/58`}),className:`border-border bg-background/24`,labelClassName:`text-foreground/72`,actions:(0,U.jsx)(Z,{text:B(t.parts,t.content)}),defaultOpen:t.streaming??!1,children:(0,U.jsx)(Ot,{entry:t,markdownClassName:`text-foreground/86`,preClassName:`text-foreground/86 leading-relaxed`})});case`PortInboundEntry`:return(0,U.jsx)($,{label:`Input from ${t.source_label||I(t.from_id??``,n)}${kt(t)}`,icon:(0,U.jsx)(u,{className:`size-3 text-foreground/66`}),className:`border-border bg-surface-1/24`,labelClassName:`text-foreground/72`,actions:(0,U.jsx)(Z,{text:At(t)}),defaultOpen:!1,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[t.port_type?(0,U.jsx)(`span`,{className:`inline-flex rounded-md border border-border bg-background/40 px-2 py-0.5 font-mono text-[10px] text-muted-foreground`,children:t.port_type}):null,(0,U.jsx)(Q,{content:At(t),markdownClassName:`text-foreground/86`,preClassName:`text-foreground/86 leading-relaxed`})]})});case`AssistantText`:return(0,U.jsx)($,{label:e,icon:(0,U.jsx)(x,{className:`size-3 text-foreground/84`}),className:`border-border bg-surface-2/62`,labelClassName:`text-foreground/84`,actions:(0,U.jsx)(Z,{text:t.content??``}),defaultOpen:!1,children:(0,U.jsx)(Ot,{entry:t,markdownClassName:`text-foreground/88`,preClassName:`text-foreground/88 leading-relaxed`})});case`ToolCall`:{let e=G(t.arguments)??``,n=G(t.result);return(0,U.jsx)($,{label:t.tool_name??`tool`,icon:(0,U.jsx)(p,{className:`size-3 text-foreground/66`}),className:`border-border bg-surface-1/20`,labelClassName:`text-foreground/72`,defaultOpen:!1,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1`,children:`Arguments`}),(0,U.jsx)(`pre`,{className:`select-text text-[11px] whitespace-pre-wrap break-words leading-relaxed text-foreground/78`,children:e})]}),t.result&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1`,children:`Result`}),(0,U.jsx)(Q,{content:n??t.result,streaming:t.streaming,markdownClassName:`text-muted-foreground`,preClassName:`text-muted-foreground leading-relaxed`})]})]})})}case`ErrorEntry`:return(0,U.jsx)($,{label:`Error`,icon:(0,U.jsx)(c,{className:`size-3 text-graph-status-error/84`}),className:`border-graph-status-error/16 bg-graph-status-error/[0.038]`,labelClassName:`text-graph-status-error/78`,actions:(0,U.jsx)(Z,{text:t.content??``,className:`text-graph-status-error/84 hover:text-graph-status-error/84`,iconClassName:`text-graph-status-error/84`,copiedClassName:`text-graph-status-error/84`}),defaultOpen:!1,children:(0,U.jsx)(Q,{content:t.content,markdownClassName:`text-graph-status-error/84`,preClassName:`text-graph-status-error/84 leading-relaxed`})});default:return null}});function $({actions:e,label:t,labelClassName:n,icon:r,className:i,contentClassName:a,defaultOpen:o=!1,children:s}){let[c,l]=(0,H.useState)(o),u=(0,H.useCallback)(()=>l(e=>!e),[]);return(0,U.jsxs)(`div`,{className:R(`rounded-xl border transition-colors hover:bg-accent/20`,i),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 select-none`,children:[(0,U.jsxs)(z,{type:`button`,variant:`ghost`,"aria-expanded":c,onClick:u,className:`h-auto min-w-0 flex-1 justify-start gap-2 rounded-md bg-transparent px-0 py-0 text-left text-inherit shadow-none hover:bg-transparent hover:text-inherit focus-visible:ring-2 focus-visible:ring-ring/50`,children:[(0,U.jsx)(`span`,{className:`shrink-0 flex items-center justify-center`,children:r}),(0,U.jsx)(`span`,{className:R(`min-w-0 flex-1 truncate text-[11px] font-medium`,n||`text-muted-foreground`),children:t}),(0,U.jsx)(y,{className:R(`ml-2 size-3.5 shrink-0 text-muted-foreground/70 transition-transform duration-200`,c&&`rotate-90`)})]}),e?(0,U.jsx)(`span`,{className:`shrink-0 flex items-center leading-none`,children:e}):null]}),(0,U.jsx)(le,{initial:!1,children:c?(0,U.jsx)(k.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.22,1,.36,1]},className:`overflow-hidden`,children:(0,U.jsx)(`div`,{className:R(`px-3 pb-3 pt-1`,a),children:s})}):null})]})}var Mt=ie(`inline-flex h-5 items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function Nt({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,U.jsx)(n?d:`span`,{"data-slot":`badge`,"data-variant":t,className:R(Mt({variant:t}),e),...r})}function Pt(e,t=!1){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(0),{agents:u}=oe(),{agentHistories:d,clearAgentHistory:f,clearHistorySnapshot:p,historyInvalidatedAt:m,historyClearedAt:h,historySnapshots:g,streamingDeltas:_}=se(),v=e?h.get(e)??0:0,y=e?m.get(e)??0:0,b=e?g.get(e)??null:null;return(0,H.useEffect)(()=>{v&&(r(e=>e&&{...e,history:Ue(e.history)}),l(Date.now()))},[v]),(0,H.useEffect)(()=>{!y||!b||(r(e=>e&&{...e,history:b}),l(Date.now()))},[y,b]),(0,H.useEffect)(()=>{if(!e){r(null),a(!1),s(null);return}let n=new AbortController,i=!1;return(async()=>{a(!0),s(null),t||f(e);try{let t=await te(e,n.signal);if(i)return;r(t),l(Date.now()),p(e)}catch(e){if(i||n.signal.aborted)return;r(null),s(e instanceof Error?e.message:`Failed to fetch node detail`)}finally{i||a(!1)}})(),()=>{i=!0,n.abort()}},[e,f,p,y,t]),{detail:(0,H.useMemo)(()=>{if(!n||!e)return null;let t=d.get(e),r=_.get(e),i=Xe({history:b??n.history,incremental:t,deltas:r,fetchedAt:c}),a=e?u.get(e):void 0,o={...n,history:i};return a&&(o.state=a.state,o.todos=a.todos),o},[n,e,d,b,_,u,c]),loading:i,error:o,fetchedAt:c}}function Ft(e,t){return t?.leader_id?e.get(t.leader_id)??null:null}function It(e={}){let{bottomInset:t=0}=e,{agents:n}=oe(),{tabs:r}=re(),{connected:i}=ce(),{agentHistories:a,clearAgentHistory:o,clearHistorySnapshot:s,historyInvalidatedAt:c,historyClearedAt:l,historySnapshots:u,streamingDeltas:d}=se(),{activeToolCalls:f}=ue(),{activeTabId:p}=de(),m=p?r.get(p)??null:null,h=(0,H.useMemo)(()=>Ft(n,m),[m,n]),g=h?.id??m?.leader_id??null,_=p?`leader:${p}`:`leader:none`,[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(0),[S,C]=(0,H.useState)(``),[w,T]=(0,H.useState)([]),[D,O]=(0,H.useState)(null),[k,A]=(0,H.useState)(!1),[j,M]=(0,H.useState)(!1),[P,ie]=(0,H.useState)(null),[I,L]=(0,H.useState)([]),[le,R]=(0,H.useState)(()=>new Map),z=(0,H.useRef)(null),pe=(0,H.useRef)(!0),me=(0,H.useRef)([]),V=(0,H.useRef)(new Map),he=(0,H.useRef)(new Set),U=h?.capabilities?.input_image??!1,W=g?l.get(g)??0:0,_e=g?c.get(g)??0:0,G=g?u.get(g)??null:null,K=w.some(e=>e.status===`uploading`),ve=w.filter(ht),q=(0,H.useSyncExternalStore)(e=>ut(_,e),()=>lt(_),()=>lt(_)),ye=D===null?null:q[D]??null,be=ye!==null&&S===ye.text&&bt(w,ye),J=h?.state??v?.state??null,xe=(0,H.useCallback)(async e=>{let t=e.pendingMessageTimestamp??Date.now(),n=St(e.content,e.parts,t),r=e.visiblePending??!0;M(!0),r&&L(e=>[...e,n]);try{let i=await ee(e.targetId,{content:e.content,parts:e.parts});return r&&i.status===`command_executed`?L(n=>ae(n,{content:e.content,timestamp:t})):r&&L(e=>e.map(e=>e.id===n.id?{...e,message_id:i.message_id??null}:e)),dt(e.history.scope,e.history.entry),e.restoreDraft&&_t(e.restoreDraft.images),!0}catch(t){return r&&L(e=>e.filter(e=>e.id!==n.id)),e.restoreDraft&&(C(e.restoreDraft.input),T(e.restoreDraft.images),O(e.restoreDraft.historyCursor)),E.error(t instanceof Error?t.message:`Failed to send message`),!1}finally{M(!1)}},[]),Y=(0,H.useCallback)((e,t)=>{O(t),C(e?.text??``),T(e?yt(e):[])},[]),Se=(0,H.useCallback)(e=>{O(null),C(e)},[]);(0,H.useEffect)(()=>{me.current=w},[w]),(0,H.useEffect)(()=>{V.current=le},[le]),(0,H.useEffect)(()=>()=>{_t(me.current)},[]),(0,H.useEffect)(()=>{_t(me.current),C(``),T([]),O(null),L([]),ie(null)},[_]),(0,H.useEffect)(()=>{W&&(L([]),g&&R(e=>{if(!e.has(g))return e;let t=new Map(e);return t.delete(g),t}),y(e=>e&&{...e,history:Ue(e.history)}),x(Date.now()))},[W,g]),(0,H.useEffect)(()=>{!_e||!G||(y(e=>e&&{...e,history:G}),x(Date.now()))},[_e,G]),(0,H.useEffect)(()=>{V.current.size!==0&&R(e=>{let t=null;for(let[r,i]of e){if(i.send_failed)continue;let a=r===g?J:n.get(r)?.state??i.target_state??null;i.target_state!==a&&(t??=new Map(e),t.set(r,{...i,target_state:a}))}return t??e})},[n,g,J,le]),(0,H.useEffect)(()=>{if(!(V.current.size===0||j))for(let[e,t]of V.current)t.send_failed||(e===g?J:n.get(e)?.state??t.target_state??null)!==`idle`||he.current.has(e)||(he.current.add(e),R(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n}),xe({content:t.content,parts:t.parts??[],targetId:e,visiblePending:e===g,history:{scope:t.history_entry_scope,entry:t.history_entry},pendingMessageTimestamp:t.timestamp}).then(n=>{he.current.delete(e),n||R(n=>{let r=new Map(n);return r.set(e,{...t,send_failed:!0,target_state:`error`}),r})}).catch(()=>{he.current.delete(e),R(n=>{let r=new Map(n);return r.set(e,{...t,send_failed:!0,target_state:`error`}),r})}))},[n,g,J,le,j,xe]),(0,H.useEffect)(()=>{if(!i||!g){y(null);return}let e=new AbortController,t=!1;return(async()=>{o(g);try{let n=await te(g,e.signal);if(t||!n)return;y(n),x(Date.now()),s(g)}catch{!t&&!e.signal.aborted&&E.error(`Failed to load Leader history`)}})(),()=>{t=!0,e.abort()}},[o,s,i,W,_e,g]);let Ce=(0,H.useMemo)(()=>g?Xe({history:G??v?.history??[],incremental:a.get(g),deltas:d.get(g),fetchedAt:b||Date.now()}):[],[a,v,b,G,g,d]);(0,H.useEffect)(()=>{if(!g||I.length===0)return;let e=new Set(Ce.filter(e=>e.type===`ReceivedMessage`&&e.from_id===`human`&&typeof e.message_id==`string`).map(e=>e.message_id));e.size!==0&&L(t=>t.filter(t=>!t.message_id||!e.has(t.message_id)))},[g,Ce,I.length]);let we=g?le.get(g)??null:null,X=(0,H.useMemo)(()=>[...Ce,...we?[{...we}]:[],...I.map(e=>({...e}))],[we,Ce,I]),Te=(0,H.useMemo)(()=>{let e=I.length+ +!!we,t=g?d.get(g)??[]:[],n=i&&!!(g&&(e>0||h?.state===`running`||h?.state===`sleeping`||f.has(g)||t.length>0)),r=[...X].map((e,t)=>({item:e,index:t})).reverse().find(({item:e})=>e.type===`PendingHumanMessage`?!0:e.type===`ReceivedMessage`&&e.from_id===`human`&&F(e.parts,e.content).length>0)?.index,a=r===void 0?[]:X.slice(r+1),o=a.some(e=>e.type===`AssistantText`&&F(e.parts,e.content).length>0),s=[...a].reverse().find(e=>e.type===`ToolCall`&&e.streaming===!0),c=(g?f.get(g)??null:null)??s?.tool_name??null;return{running:n,runningHint:n&&r!==void 0&&!o?{label:c?`Running tools...`:`Thinking...`,toolName:c}:null}},[f,i,g,h?.state,we,I.length,d,X]);(0,H.useLayoutEffect)(()=>{let e=z.current;!e||!pe.current||(e.scrollTop=e.scrollHeight)},[t,Te.runningHint?`${Te.runningHint.label}:${Te.runningHint.toolName??``}`:``,X]),(0,H.useLayoutEffect)(()=>{let e=z.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{pe.current&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>{t.disconnect()}},[]);let Ee=e=>{pe.current=pt(e.currentTarget)},Z=async(e={})=>{if(!g)return;let t=S.trim();if(!t&&ve.length===0||K||j)return;let n=xt(t,ve),r=S,i=w,a=D,o=Date.now(),s=t||B(n),c={text:r,images:vt(i),timestamp:o},l=e.deferWhenBusy&&V.current.has(g)&&(J===`error`||J===`terminated`);if(e.deferWhenBusy&&(J===`running`||J===`sleeping`||l)){R(e=>{let t=new Map(e);return t.set(g,Ct({content:s,historyEntry:c,historyScope:_,parts:n,targetId:g,targetState:J,timestamp:o})),t}),O(null),C(``),T([]),_t(i);return}if(J===`error`||J===`terminated`){E.error(`Resolve the current chat before sending`);return}O(null),C(``),T([]),await xe({content:s,parts:n,targetId:g,history:{scope:_,entry:c},pendingMessageTimestamp:o,restoreDraft:{input:r,images:i,historyCursor:a}})},De=(0,H.useCallback)(async e=>{if(O(null),!U){E.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 Tt(t);T(e=>[...e,...n]),await Promise.all(n.map(async(e,n)=>{let r=t[n];if(r)try{let t=await ge(r);T(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){gt(e),T(t=>t.filter(t=>t.id!==e.id)),E.error(t instanceof Error?t.message:`Failed to upload image`)}}))},[U]),Oe=(0,H.useCallback)(e=>{O(null),T(t=>{let n=t.find(t=>t.id===e);return n&&gt(n),t.filter(t=>t.id!==e)})},[]),ke=(0,H.useCallback)((e,t)=>{if(q.length===0)return!1;let n=t.start,r=t.end,i=S.length===0&&w.length===0,a=typeof n==`number`&&typeof r==`number`&&n===r&&(n===0||n===S.length);if(!i&&!(ye!==null&&be&&a))return!1;if(D===null){if(e!==-1)return!1;let t=q.length-1;return Y(q[t]??null,t),!0}if(e===-1){let e=Math.max(D-1,0);return Y(q[e]??null,e),!0}if(D>=q.length-1)return Y(null,null),!0;let o=D+1;return Y(q[o]??null,o),!0},[ye,w,D,S,q,be,Y]),Ae=(0,H.useCallback)(async()=>{if(g&&!(h?.state!==`running`&&h?.state!==`sleeping`)){await ne(g);for(let e=0;e<25;e+=1){let e=await te(g);if(!e)break;if(y(e),x(Date.now()),e.state!==`running`&&e.state!==`sleeping`)return;await new Promise(e=>window.setTimeout(e,120))}throw Error(`Leader did not stop in time`)}},[g,h?.state]),je=async()=>{if(!(!g||k)){A(!0);try{await N(g),L([]),R(e=>{if(!e.has(g))return e;let t=new Map(e);return t.delete(g),t}),o(g);let e=await te(g);e&&(y(e),x(Date.now()),s(g))}catch(e){E.error(e instanceof Error?e.message:`Failed to clear chat`)}finally{A(!1)}}},Me=(0,H.useCallback)(async e=>{if(!(!g||!e||P)){ie(e);try{try{await Ae(),await fe(g,e)}catch(e){E.error(e instanceof Error?e.message:`Failed to retry Leader message`);return}o(g);try{let e=await te(g);e&&(y(e),x(Date.now()),s(g))}catch{return}}finally{ie(null)}}},[o,s,g,P,Ae]);return{activeTab:m,addImages:De,cancelPendingSend:(0,H.useCallback)(e=>{R(t=>{let n=Array.from(t.entries()).find(([,t])=>t.id===e);if(!n)return t;let r=new Map(t);return r.delete(n[0]),r})},[]),connected:i,clearChat:je,clearing:k,draftImages:w,handleKeyDown:e=>{if(e.key===`Tab`&&!e.shiftKey){(S.trim()||ve.length>0)&&(e.preventDefault(),Z({deferWhenBusy:!0}));return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Z())},hasUploadingImages:K,input:S,isBrowsingInputHistory:be,leaderActivity:Te,leaderNode:h,navigateInputHistory:ke,onMessagesScroll:Ee,removeImage:Oe,retryMessage:Me,retryingMessageId:P,scrollRef:z,sendMessage:Z,sending:j,setInput:Se,stopLeader:Ae,supportsInputImage:U,timelineItems:X}}var Lt={assistant:g,agent:x,trigger:_,llm:S,code:f,if:u,merge:r};function Rt({name:e,roleName:t,nodeType:n,isLeader:r=!1}){return e??t??(n===`assistant`?`Assistant`:n===`trigger`?`Trigger`:n===`llm`?`Model`:n===`code`?`Code`:n===`if`?`If`:n===`merge`?`Merge`:r?`Leader`:`Agent`)}var zt={running:`bg-graph-status-running`,idle:`bg-graph-status-idle`,sleeping:`bg-graph-status-sleeping`,initializing:`bg-graph-status-initializing`,error:`bg-graph-status-error`,terminated:`bg-graph-status-terminated`},Bt={running:`agent-state-ring-running`,idle:`agent-state-ring-idle`,sleeping:`agent-state-ring-sleeping`,initializing:`agent-state-ring-initializing`,error:`agent-state-ring-error`,terminated:`agent-state-ring-terminated`},Vt=`rounded-md bg-accent/45 px-2 py-1 text-xs text-foreground`,Ht={running:`border-graph-status-running/18 bg-graph-status-running/[0.12] text-graph-status-running`,idle:`border-graph-status-idle/12 bg-graph-status-idle/[0.06] text-graph-status-idle/78`,sleeping:`border-graph-status-sleeping/18 bg-graph-status-sleeping/[0.12] text-graph-status-sleeping`,initializing:`border-graph-status-initializing/16 bg-graph-status-initializing/[0.08] text-graph-status-initializing/84`,error:`border-graph-status-error/20 bg-graph-status-error/[0.09] text-graph-status-error`,terminated:`border-border bg-accent/35 text-muted-foreground`};function Ut({children:e,disabled:t=!1,active:n=!1,onClick:r}){return(0,U.jsx)(z,{type:`button`,variant:`ghost`,size:`xs`,onClick:r,disabled:t,className:R(`flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md border border-transparent bg-transparent px-3 py-1.75 text-[11px] font-medium text-muted-foreground transition-[background-color,border-color,color] duration-150 hover:border-border hover:bg-accent/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:border-transparent disabled:text-muted-foreground/50 disabled:hover:bg-transparent`,n&&`border-border bg-accent/70 text-foreground`),children:e})}function Wt(){return(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-border`})}function Gt({children:e,tone:t=`default`}){return(0,U.jsx)(`div`,{className:R(`pointer-events-auto relative isolate flex items-center gap-1.5 rounded-full border border-border bg-surface-overlay/80 px-2.5 py-1 text-[11px] font-medium text-muted-foreground backdrop-blur-sm`,t===`primary`?`border-border bg-accent/60 text-foreground`:``),children:e})}function Kt({agent:e,onClose:t}){let[n,r]=(0,H.useState)(!1),{agents:i}=oe(),{tabs:o}=re(),s=e.node_type!==`assistant`&&e.node_type!==`agent`,{detail:c,error:l,loading:u}=Pt(s?null:e.id,e.node_type===`assistant`),d=c?.state??e.state,f=c?.is_leader??e.is_leader,p=c?.contacts??[],m=c?.connections??e.connections,h=c?.todos??e.todos,g=c?.history??[],_=c?.role_name??e.role_name,v=c?.tools??[],y=c?.write_dirs??[],b=c?.allow_network??!1,x=c?.tab_id??e.tab_id??null,S=x?o.get(x)??null:null,C=e.node_type===`assistant`,w=c?.workflow_permissions??null,T=C?b:S?.allow_network??w?.allow_network??b??!1,D=C?y:S?.write_dirs??w?.write_dirs??y,O=C?`Permissions`:`Workflow Permissions`,k=Rt({name:e.name,roleName:e.role_name,nodeType:e.node_type,isLeader:e.is_leader}),A=Lt[e.node_type],j=m.map(e=>{let t=i.get(e);return{id:e,label:t?Rt({name:t.name,roleName:t.role_name,nodeType:t.node_type,isLeader:t.is_leader}):e.slice(0,8)}}),M=p.filter(qt),N=p.filter(e=>!qt(e)).map(e=>{let t=typeof e==`string`?e:e.id;return{id:t,label:Jt(e,i.get(t))}}),P=M.length>0?`reachable paths`:`reachable contacts`;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3.5 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex size-7 items-center justify-center rounded-md bg-primary/8`,children:(0,U.jsx)(A,{className:`size-3.5 text-primary`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold`,children:k}),f?(0,U.jsx)(`span`,{className:`rounded-full border border-accent bg-accent/45 px-2 py-0.5 text-[10px] font-semibold text-accent-foreground`,children:`Leader`}):null,(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-accent/35 px-2 py-0.5 font-mono text-[10px] text-muted-foreground/78`,children:e.id.slice(0,8)})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[d===`running`||d===`sleeping`?(0,U.jsx)(z,{type:`button`,size:`sm`,variant:`destructive`,disabled:n,onClick:()=>{r(!0),ne(e.id).catch(()=>{E.error(`Failed to interrupt node`)}).finally(()=>{r(!1)})},children:n?`Interrupting...`:`Interrupt`}):null,(0,U.jsx)($t,{title:`Close details`,onClick:t,children:(0,U.jsx)(a,{className:`size-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3.5`,children:(0,U.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-3.5 border-b border-border pb-3.5 sm:grid-cols-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Status`}),(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsx)(Nt,{variant:`outline`,className:Ht[d],children:d.toUpperCase()})})]}),(0,U.jsxs)(`div`,{className:`min-w-0 sm:border-l sm:border-border sm:pl-3.5`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Contacts`}),(0,U.jsxs)(`p`,{className:`mt-2 select-text text-sm text-foreground`,children:[p.length,` `,P]})]}),(0,U.jsxs)(`div`,{className:`min-w-0 sm:border-l sm:border-border sm:pl-3.5`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Workflow`}),(0,U.jsx)(`p`,{className:`mt-2 select-text text-sm text-foreground`,children:S?.title??x?.slice(0,8)??`None`})]})]}),(0,U.jsx)(V,{title:`Workflow Context`,children:x?(0,U.jsxs)(`div`,{className:`grid gap-3 text-sm sm:grid-cols-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`ID`}),(0,U.jsx)(`p`,{className:`mt-1 select-text font-mono text-[11px] text-foreground`,children:x??`None`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Title`}),(0,U.jsx)(`p`,{className:`mt-1 select-text text-foreground`,children:S?.title??`Unknown`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Role`}),(0,U.jsx)(`p`,{className:`mt-1 select-text text-foreground`,children:_??`None`})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No workflow metadata`})}),s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(V,{title:`Workflow Permissions`,children:(0,U.jsx)(en,{allowNetwork:T,writeDirs:D,inherited:!C})}),(0,U.jsx)(V,{title:`Ports`,children:[...e.inputs??[],...e.outputs??[]].length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No ports`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[...e.inputs??[],...e.outputs??[]].map(e=>(0,U.jsxs)(`span`,{className:R(Vt,`select-text`),children:[e.direction===`in`?`Input`:`Output`,` ·`,` `,e.key,` · `,e.type]},`${e.direction}-${e.key}`))})}),(0,U.jsx)(V,{title:`Settings`,children:Object.keys(e.config??{}).length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No settings`}):(0,U.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-border bg-background/40 p-3 text-[11px] leading-5 text-foreground`,children:JSON.stringify(e.config,null,2)})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(V,{title:`Contacts`,children:M.length===0&&N.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No direct contacts`}):M.length>0?(0,U.jsx)(`div`,{className:`space-y-2`,children:M.map(e=>(0,U.jsxs)(`div`,{className:`rounded-md border border-border bg-accent/25 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`min-w-0 select-text truncate text-sm font-medium text-foreground`,children:Jt(e,i.get(e.target_id))}),(0,U.jsx)(Nt,{variant:`outline`,className:`shrink-0 border-border bg-background/40 font-mono text-[10px] text-muted-foreground`,children:e.port_type})]}),(0,U.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`select-text rounded-md bg-background/45 px-1.5 py-0.5 font-mono text-foreground/80`,children:e.from_output_port_key}),(0,U.jsx)(`span`,{"aria-hidden":`true`,children:`to`}),(0,U.jsx)(`span`,{className:`select-text rounded-md bg-background/45 px-1.5 py-0.5 font-mono text-foreground/80`,children:e.to_input_port_key})]})]},e.edge_id))}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:N.map(e=>(0,U.jsx)(`span`,{className:R(Vt,`select-text`),children:e.label},e.id))})}),(0,U.jsx)(V,{title:`Workflow Graph`,children:j.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No graph edges`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:j.map(e=>(0,U.jsx)(`span`,{className:R(Vt,`select-text`),children:e.label},e.id))})}),(0,U.jsx)(V,{title:`Tools`,children:v.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tools configured`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:v.map(e=>(0,U.jsx)(`span`,{className:R(Vt,`select-text font-mono`),children:e},e))})}),(0,U.jsx)(V,{title:O,children:(0,U.jsx)(en,{allowNetwork:T,writeDirs:D,inherited:!C})}),(0,U.jsx)(V,{title:`Todos`,children:(0,U.jsx)(`div`,{className:`space-y-2`,children:h.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No todos`}):h.slice(0,6).map(e=>(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[(0,U.jsx)(`span`,{className:`size-2 rounded-full bg-border`}),(0,U.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:e.text})]},e.text))})}),(0,U.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,U.jsx)(`div`,{className:`px-0 pb-2`,children:(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`History`})}),u?(0,U.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,]].map((e,t)=>(0,U.jsx)(`div`,{className:`h-12 rounded-md skeleton-shimmer`},t))}):l?(0,U.jsx)(`div`,{className:`text-sm text-destructive`,children:l}):g.length===0?(0,U.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No history yet.`}):(0,U.jsx)(Et,{history:g,agentLabel:k,nodes:i})]})]})]})})]})}function qt(e){return typeof e==`object`&&!!e&&`from_output_port_key`in e&&`to_input_port_key`in e}function Jt(e,t){return t?Rt({name:t.name,roleName:t.role_name,nodeType:t.node_type,isLeader:t.is_leader}):typeof e==`string`?e.slice(0,8):Rt({name:e.name,roleName:e.role_name,nodeType:e.node_type,isLeader:e.is_leader})}function Yt({onOpenDetails:e}){let{agents:t}=oe(),[n,r]=(0,H.useState)(!1),{height:i,ref:a}=He(),{activeTab:o,addImages:s=async()=>{},cancelPendingSend:c,clearChat:l,clearing:u=!1,connected:d,draftImages:f=[],handleKeyDown:p,hasUploadingImages:m=!1,input:h,isBrowsingInputHistory:g,leaderActivity:_,leaderNode:v,navigateInputHistory:y,onMessagesScroll:b,removeImage:x=()=>{},retryMessage:S,retryingMessageId:C,scrollRef:w,sending:T,sendMessage:D,setInput:O,stopLeader:k,supportsInputImage:A=!1,timelineItems:j}=It({bottomInset:i});return o?v?(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-b border-border px-3.5 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-[220px] flex-1 items-center gap-2`,children:[(0,U.jsx)(`p`,{className:`shrink-0 text-[14px] font-semibold leading-6`,children:`Workflow chat`}),v.role_name?(0,U.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: `,v.role_name]}):null,(0,U.jsx)(`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:o.title}),(0,U.jsx)(`span`,{className:R(`rounded-full border px-2.5 py-0.5 text-[9px] font-medium transition-colors`,d?`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:d?`Online`:`Connecting...`}),(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-accent/35 px-2 py-0.5 text-[10px] font-medium leading-4 text-muted-foreground/78`,children:o.activation_state===`active`?`Active`:`Inactive`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(z,{type:`button`,size:`sm`,variant:`outline`,disabled:u,onClick:()=>void l(),children:u?`Clearing...`:`Clear Chat`}),(0,U.jsx)(z,{type:`button`,size:`sm`,variant:`outline`,onClick:e,children:`Leader Details`})]})]}),(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(De,{allowHumanMessageRetry:!0,bottomInset:i,items:j,nodes:t,onRetryHumanMessage:e=>void S(e),onCancelPendingSend:c,onScroll:b,retryImageInputEnabled:A,retryingMessageId:C,runningHint:_.runningHint,scrollRef:w}),(0,U.jsx)(`div`,{ref:a,style:{paddingBottom:`calc(10px + env(safe-area-inset-bottom, 0px))`},className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-b from-transparent via-background/70 to-background/95 px-2.5 pt-8`,children:(0,U.jsx)(X,{busy:_.running,commandsEnabled:!0,disabled:!h.trim()&&f.length===0||m||T,images:f,imageInputEnabled:A,input:h,onAddImages:e=>void s(e),onChange:O,onNavigateHistory:y,onKeyDown:p,onRemoveImage:x,onSend:()=>void D(),onStop:()=>{r(!0),k().catch(e=>{E.error(e instanceof Error?e.message:`Failed to interrupt leader`)}).finally(()=>{r(!1)})},overlay:!0,suppressCommandNavigation:g,targetLabel:`this workflow`,stopping:n})})]})]}):(0,U.jsx)(Zt,{}):(0,U.jsx)(Xt,{})}function Xt(){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,U.jsxs)(`div`,{className:`max-w-sm rounded-xl border border-border bg-accent/20 px-5 py-6 text-center`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:`No workflow selected`}),(0,U.jsx)(`p`,{className:`mt-2 text-[12px] leading-6 text-muted-foreground`,children:`Create a workflow or switch to an existing one to open its workflow chat.`})]})})}function Zt(){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,U.jsxs)(`div`,{className:`max-w-sm rounded-xl border border-border bg-accent/20 px-5 py-6 text-center`,children:[(0,U.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:`Loading workflow context`}),(0,U.jsx)(`p`,{className:`mt-2 text-[12px] leading-6 text-muted-foreground`,children:`Restoring the current workflow chat.`})]})})}function Qt({expanded:e,onClick:t,className:n}){let r=e?`Hide panel`:`Show panel`;return(0,U.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,onClick:t,title:r,"aria-label":r,className:R(`pointer-events-auto relative isolate flex size-9 items-center justify-center rounded-md border border-border bg-surface-overlay/80 text-muted-foreground shadow-sm transition-[background-color,color] duration-150 hover:bg-accent/60 hover:text-foreground [contain:paint]`,n),children:(0,U.jsx)(`span`,{className:`flex transition-transform duration-200`,children:e?(0,U.jsx)(A,{className:`size-4`}):(0,U.jsx)(i,{className:`size-4`})})})}function $t({children:e,onClick:t,title:n}){return(0,U.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:t,title:n,"aria-label":n,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors duration-150 hover:bg-accent/45 hover:text-foreground`,children:e})}function en({allowNetwork:e,inherited:t,writeDirs:n}){return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[t?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Set by this workflow.`}):null,(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Network`}),(0,U.jsx)(`p`,{className:`mt-1 select-text text-sm text-foreground`,children:e?`Enabled`:`Disabled`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground`,children:`Writable Folders`}),n.length===0?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`No write access`}):(0,U.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:n.map(e=>(0,U.jsx)(`span`,{className:R(Vt,`select-text font-mono text-[11px]`),children:e},e))})]})]})}export{He as A,yt as C,ut as D,lt as E,X as M,ge as N,Ue as O,_t as S,dt as T,Tt as _,Ut as a,pt as b,Rt as c,Bt as d,Ft as f,Ct as g,St as h,Qt as i,De as j,Xe as k,Lt as l,xt as m,Gt as n,Wt as o,Nt as p,Yt as r,Xt as s,Kt as t,zt as u,bt as v,vt as w,gt as x,ht as y};
@@ -1 +0,0 @@
1
- function e(e,t=`auto`){return typeof e!=`number`||!Number.isFinite(e)?null:t===`milliseconds`?e:t===`seconds`?e*1e3:e>0xe8d4a51000?e:e*1e3}function t(t,n={}){let{fallback:r=`Unknown`,format:i,unit:a=`auto`}=n,o=e(t,a);if(o===null)return r;let s=new Date(o);return i?new Intl.DateTimeFormat(void 0,i).format(s):s.toLocaleString()}export{t};