flujo-ai 3.26.0 → 3.28.0

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 (706) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +470 -306
  3. package/.next/app-path-routes-manifest.json +28 -8
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +24 -0
  6. package/.next/react-loadable-manifest.json +31 -18
  7. package/.next/routes-manifest.json +29 -0
  8. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/_not-found.html +1 -1
  10. package/.next/server/app/_not-found.rsc +2 -2
  11. package/.next/server/app/api/approvals/[id]/route.js +1 -1
  12. package/.next/server/app/api/approvals/[id]/route.js.nft.json +1 -1
  13. package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/approvals/route.js +2 -2
  15. package/.next/server/app/api/approvals/route.js.nft.json +1 -1
  16. package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/backup/route.js +1 -1
  18. package/.next/server/app/api/backup/route.js.nft.json +1 -1
  19. package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/bugs/enhance/route.js +3 -3
  22. package/.next/server/app/api/bugs/enhance/route.js.nft.json +1 -1
  23. package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/api/cwd/route.js +1 -1
  25. package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/encryption/secure/route.js +1 -1
  27. package/.next/server/app/api/encryption/secure/route.js.nft.json +1 -1
  28. package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/env/route.js +2 -2
  30. package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/flow/[id]/route.js +1 -1
  32. package/.next/server/app/api/flow/[id]/route.js.nft.json +1 -1
  33. package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/flow/[id]/versions/[versionId]/route.js +1 -0
  35. package/.next/server/app/api/flow/[id]/versions/[versionId]/route.js.nft.json +1 -0
  36. package/.next/server/app/api/flow/[id]/versions/[versionId]/route_client-reference-manifest.js +1 -0
  37. package/.next/server/app/api/flow/[id]/versions/route.js +1 -0
  38. package/.next/server/app/api/flow/[id]/versions/route.js.nft.json +1 -0
  39. package/.next/server/app/api/flow/[id]/versions/route_client-reference-manifest.js +1 -0
  40. package/.next/server/app/api/flow/compile/route.js +1 -1
  41. package/.next/server/app/api/flow/compile/route.js.nft.json +1 -1
  42. package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/flow/generate/route.js +1 -1
  44. package/.next/server/app/api/flow/generate/route.js.nft.json +1 -1
  45. package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/flow/improve/route.js +1 -1
  47. package/.next/server/app/api/flow/improve/route.js.nft.json +1 -1
  48. package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/flow/prompt-renderer/route.js +2 -2
  50. package/.next/server/app/api/flow/prompt-renderer/route.js.nft.json +1 -1
  51. package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/flow/quick-chat/route.js +1 -1
  53. package/.next/server/app/api/flow/quick-chat/route.js.nft.json +1 -1
  54. package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/flow/repair/route.js +1 -1
  56. package/.next/server/app/api/flow/repair/route.js.nft.json +1 -1
  57. package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/flow/route.js +1 -1
  59. package/.next/server/app/api/flow/route.js.nft.json +1 -1
  60. package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/git/route.js +2 -2
  62. package/.next/server/app/api/git/route.js.nft.json +1 -1
  63. package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  64. package/.next/server/app/api/init/route.js +1 -1
  65. package/.next/server/app/api/init/route.js.nft.json +1 -1
  66. package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/mcp/app-sandbox/route.js +1 -0
  71. package/.next/server/app/api/mcp/app-sandbox/route.js.nft.json +1 -0
  72. package/.next/server/app/api/mcp/app-sandbox/route_client-reference-manifest.js +1 -0
  73. package/.next/server/app/api/mcp/cancel/route.js +2 -2
  74. package/.next/server/app/api/mcp/cancel/route.js.nft.json +1 -1
  75. package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/mcp/oauth-capability/route.js +1 -0
  77. package/.next/server/app/api/mcp/oauth-capability/route.js.nft.json +1 -0
  78. package/.next/server/app/api/mcp/oauth-capability/route_client-reference-manifest.js +1 -0
  79. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js +1 -1
  80. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js.nft.json +1 -1
  81. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js +1 -1
  83. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js.nft.json +1 -1
  84. package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js +1 -1
  86. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js.nft.json +1 -1
  87. package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/mcp/servers/[name]/resources/route.js +1 -1
  89. package/.next/server/app/api/mcp/servers/[name]/resources/route.js.nft.json +1 -1
  90. package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/mcp/servers/[name]/route.js +1 -1
  92. package/.next/server/app/api/mcp/servers/[name]/route.js.nft.json +1 -1
  93. package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/mcp/servers/[name]/status/route.js +1 -1
  95. package/.next/server/app/api/mcp/servers/[name]/status/route.js.nft.json +1 -1
  96. package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js +1 -1
  98. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js.nft.json +1 -1
  99. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/mcp/servers/[name]/tools/route.js +1 -1
  101. package/.next/server/app/api/mcp/servers/[name]/tools/route.js.nft.json +1 -1
  102. package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/mcp/servers/route.js +1 -1
  104. package/.next/server/app/api/mcp/servers/route.js.nft.json +1 -1
  105. package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/mcp/test-connection/route.js +1 -1
  107. package/.next/server/app/api/mcp/test-connection/route.js.nft.json +1 -1
  108. package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/mcp/test-connection/stream/route.js +1 -1
  110. package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -1
  111. package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/mcp-registry/route.js +2 -2
  113. package/.next/server/app/api/mcp-registry/route.js.nft.json +1 -1
  114. package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/mcp-registry/spotlight/route.js +1 -1
  116. package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/model/[id]/route.js +1 -1
  118. package/.next/server/app/api/model/[id]/route.js.nft.json +1 -1
  119. package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/model/provider/route.js +2 -2
  121. package/.next/server/app/api/model/provider/route.js.nft.json +1 -1
  122. package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/model/route.js +1 -1
  124. package/.next/server/app/api/model/route.js.nft.json +1 -1
  125. package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/model/test/route.js +2 -2
  127. package/.next/server/app/api/model/test/route.js.nft.json +1 -1
  128. package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/oauth/callback/route.js +2 -2
  130. package/.next/server/app/api/oauth/callback/route.js.nft.json +1 -1
  131. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/oauth/initiate/route.js +2 -2
  133. package/.next/server/app/api/oauth/initiate/route.js.nft.json +1 -1
  134. package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
  135. package/.next/server/app/api/oauth/reset/route.js +2 -2
  136. package/.next/server/app/api/oauth/reset/route.js.nft.json +1 -1
  137. package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/packages/build/route.js +1 -0
  139. package/.next/server/app/api/packages/build/route.js.nft.json +1 -0
  140. package/.next/server/app/api/packages/build/route_client-reference-manifest.js +1 -0
  141. package/.next/server/app/api/packages/derive-secrets/route.js +1 -0
  142. package/.next/server/app/api/packages/derive-secrets/route.js.nft.json +1 -0
  143. package/.next/server/app/api/packages/derive-secrets/route_client-reference-manifest.js +1 -0
  144. package/.next/server/app/api/packages/install/route.js +1 -0
  145. package/.next/server/app/api/packages/install/route.js.nft.json +1 -0
  146. package/.next/server/app/api/packages/install/route_client-reference-manifest.js +1 -0
  147. package/.next/server/app/api/packages/install/status/route.js +1 -0
  148. package/.next/server/app/api/packages/install/status/route.js.nft.json +1 -0
  149. package/.next/server/app/api/packages/install/status/route_client-reference-manifest.js +1 -0
  150. package/.next/server/app/api/packages/installed/route.js +1 -0
  151. package/.next/server/app/api/packages/installed/route.js.nft.json +1 -0
  152. package/.next/server/app/api/packages/installed/route_client-reference-manifest.js +1 -0
  153. package/.next/server/app/api/packages/resolve/route.js +1 -0
  154. package/.next/server/app/api/packages/resolve/route.js.nft.json +1 -0
  155. package/.next/server/app/api/packages/resolve/route_client-reference-manifest.js +1 -0
  156. package/.next/server/app/api/packages/uninstall/route.js +1 -0
  157. package/.next/server/app/api/packages/uninstall/route.js.nft.json +1 -0
  158. package/.next/server/app/api/packages/uninstall/route_client-reference-manifest.js +1 -0
  159. package/.next/server/app/api/planned-executions/[id]/route.js +2 -2
  160. package/.next/server/app/api/planned-executions/[id]/route.js.nft.json +1 -1
  161. package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
  162. package/.next/server/app/api/planned-executions/[id]/run/route.js +2 -2
  163. package/.next/server/app/api/planned-executions/[id]/run/route.js.nft.json +1 -1
  164. package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
  165. package/.next/server/app/api/planned-executions/[id]/runs/route.js +2 -2
  166. package/.next/server/app/api/planned-executions/[id]/runs/route.js.nft.json +1 -1
  167. package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
  168. package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
  169. package/.next/server/app/api/planned-executions/reconcile/route.js +1 -1
  170. package/.next/server/app/api/planned-executions/reconcile/route.js.nft.json +1 -1
  171. package/.next/server/app/api/planned-executions/reconcile/route_client-reference-manifest.js +1 -1
  172. package/.next/server/app/api/planned-executions/route.js +1 -1
  173. package/.next/server/app/api/planned-executions/route.js.nft.json +1 -1
  174. package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
  175. package/.next/server/app/api/registry/auth/resend/route.js +1 -0
  176. package/.next/server/app/api/registry/auth/resend/route.js.nft.json +1 -0
  177. package/.next/server/app/api/registry/auth/resend/route_client-reference-manifest.js +1 -0
  178. package/.next/server/app/api/registry/auth/reset/route.js +1 -0
  179. package/.next/server/app/api/registry/auth/reset/route.js.nft.json +1 -0
  180. package/.next/server/app/api/registry/auth/reset/route_client-reference-manifest.js +1 -0
  181. package/.next/server/app/api/registry/auth/route.js +1 -0
  182. package/.next/server/app/api/registry/auth/route.js.nft.json +1 -0
  183. package/.next/server/app/api/registry/auth/route_client-reference-manifest.js +1 -0
  184. package/.next/server/app/api/registry/oauth/callback/route.js +1 -0
  185. package/.next/server/app/api/registry/oauth/callback/route.js.nft.json +1 -0
  186. package/.next/server/app/api/registry/oauth/callback/route_client-reference-manifest.js +1 -0
  187. package/.next/server/app/api/registry/oauth/initiate/route.js +1 -0
  188. package/.next/server/app/api/registry/oauth/initiate/route.js.nft.json +1 -0
  189. package/.next/server/app/api/registry/oauth/initiate/route_client-reference-manifest.js +1 -0
  190. package/.next/server/app/api/registry/publish/route.js +1 -0
  191. package/.next/server/app/api/registry/publish/route.js.nft.json +1 -0
  192. package/.next/server/app/api/registry/publish/route_client-reference-manifest.js +1 -0
  193. package/.next/server/app/api/registry/settings/route.js +1 -0
  194. package/.next/server/app/api/registry/settings/route.js.nft.json +1 -0
  195. package/.next/server/app/api/registry/settings/route_client-reference-manifest.js +1 -0
  196. package/.next/server/app/api/restore/route.js +1 -1
  197. package/.next/server/app/api/restore/route.js.nft.json +1 -1
  198. package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
  199. package/.next/server/app/api/runs/active/route.js +2 -2
  200. package/.next/server/app/api/runs/active/route.js.nft.json +1 -1
  201. package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -1
  202. package/.next/server/app/api/storage/route.js +1 -1
  203. package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
  204. package/.next/server/app/api/update/route.js +1 -1
  205. package/.next/server/app/api/update/route.js.nft.json +1 -1
  206. package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  207. package/.next/server/app/api/waves/route.js +1 -1
  208. package/.next/server/app/api/waves/route.js.nft.json +1 -1
  209. package/.next/server/app/api/waves/route_client-reference-manifest.js +1 -1
  210. package/.next/server/app/api/webhooks/[id]/route.js +1 -1
  211. package/.next/server/app/api/webhooks/[id]/route.js.nft.json +1 -1
  212. package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
  213. package/.next/server/app/chat/page.js +9 -10
  214. package/.next/server/app/chat/page.js.nft.json +1 -1
  215. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  216. package/.next/server/app/chat.html +1 -1
  217. package/.next/server/app/chat.rsc +3 -3
  218. package/.next/server/app/docs/page.js +7 -6
  219. package/.next/server/app/docs/page.js.nft.json +1 -1
  220. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  221. package/.next/server/app/docs.html +1 -1
  222. package/.next/server/app/docs.rsc +3 -3
  223. package/.next/server/app/executions/page.js +39 -3
  224. package/.next/server/app/executions/page.js.nft.json +1 -1
  225. package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
  226. package/.next/server/app/executions.html +1 -1
  227. package/.next/server/app/executions.rsc +3 -3
  228. package/.next/server/app/flows/page.js +3 -3
  229. package/.next/server/app/flows/page.js.nft.json +1 -1
  230. package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
  231. package/.next/server/app/flows.html +1 -1
  232. package/.next/server/app/flows.rsc +4 -4
  233. package/.next/server/app/index.html +1 -1
  234. package/.next/server/app/index.rsc +3 -3
  235. package/.next/server/app/mcp/page.js +14 -14
  236. package/.next/server/app/mcp/page.js.nft.json +1 -1
  237. package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
  238. package/.next/server/app/mcp-flows/route.js +1 -1
  239. package/.next/server/app/mcp-flows/route.js.nft.json +1 -1
  240. package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
  241. package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
  242. package/.next/server/app/mcp-proxy/[server]/route.js.nft.json +1 -1
  243. package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
  244. package/.next/server/app/mcp.html +1 -1
  245. package/.next/server/app/mcp.rsc +3 -3
  246. package/.next/server/app/models/page.js +2 -2
  247. package/.next/server/app/models/page.js.nft.json +1 -1
  248. package/.next/server/app/models/page_client-reference-manifest.js +1 -1
  249. package/.next/server/app/packages/page.js +2 -0
  250. package/.next/server/app/packages/page.js.nft.json +1 -0
  251. package/.next/server/app/packages/page_client-reference-manifest.js +1 -0
  252. package/.next/server/app/packages.html +1 -0
  253. package/.next/server/app/packages.meta +7 -0
  254. package/.next/server/app/packages.rsc +22 -0
  255. package/.next/server/app/page.js +1 -1
  256. package/.next/server/app/page.js.nft.json +1 -1
  257. package/.next/server/app/page_client-reference-manifest.js +1 -1
  258. package/.next/server/app/settings/page.js +2 -2
  259. package/.next/server/app/settings/page.js.nft.json +1 -1
  260. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  261. package/.next/server/app/settings.html +1 -1
  262. package/.next/server/app/settings.rsc +3 -3
  263. package/.next/server/app/v1/chat/completions/route.js +1 -1
  264. package/.next/server/app/v1/chat/completions/route.js.nft.json +1 -1
  265. package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
  266. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js +2 -2
  267. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js.nft.json +1 -1
  268. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
  269. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js +2 -2
  270. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js.nft.json +1 -1
  271. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
  272. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js +1 -1
  273. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js.nft.json +1 -1
  274. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
  275. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js +1 -1
  276. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js.nft.json +1 -1
  277. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
  278. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js +2 -2
  279. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js.nft.json +1 -1
  280. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
  281. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js +3 -3
  282. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js.nft.json +1 -1
  283. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
  284. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route.js +1 -1
  285. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -1
  286. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js +1 -1
  287. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js.nft.json +1 -1
  288. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
  289. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js +2 -2
  290. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js.nft.json +1 -1
  291. package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
  292. package/.next/server/app/v1/chat/conversations/route.js +2 -2
  293. package/.next/server/app/v1/chat/conversations/route.js.nft.json +1 -1
  294. package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
  295. package/.next/server/app/v1/chat/events/route.js +11 -0
  296. package/.next/server/app/v1/chat/events/route.js.nft.json +1 -0
  297. package/.next/server/app/v1/chat/events/route_client-reference-manifest.js +1 -0
  298. package/.next/server/app/v1/models/route.js +2 -2
  299. package/.next/server/app/v1/models/route.js.nft.json +1 -1
  300. package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
  301. package/.next/server/app/waves/page.js +4 -4
  302. package/.next/server/app/waves/page.js.nft.json +1 -1
  303. package/.next/server/app/waves/page_client-reference-manifest.js +1 -1
  304. package/.next/server/app/waves.html +1 -1
  305. package/.next/server/app/waves.rsc +3 -3
  306. package/.next/server/app-paths-manifest.json +28 -8
  307. package/.next/server/chunks/1083.js +1 -1
  308. package/.next/server/chunks/1114.js +1 -1
  309. package/.next/server/chunks/1197.js +1 -1
  310. package/.next/server/chunks/1226.js +1 -1
  311. package/.next/server/chunks/1314.js +1 -0
  312. package/.next/server/chunks/1604.js +70 -0
  313. package/.next/server/chunks/1615.js +1 -0
  314. package/.next/server/chunks/1659.js +1 -1
  315. package/.next/server/chunks/166.js +5 -5
  316. package/.next/server/chunks/1805.js +1 -0
  317. package/.next/server/chunks/1819.js +2 -0
  318. package/.next/server/chunks/1925.js +1 -0
  319. package/.next/server/chunks/2388.js +1 -0
  320. package/.next/server/chunks/2434.js +2 -0
  321. package/.next/server/chunks/2666.js +1 -0
  322. package/.next/server/chunks/2859.js +1 -1
  323. package/.next/server/chunks/2940.js +46 -0
  324. package/.next/server/chunks/2985.js +1 -0
  325. package/.next/server/chunks/3128.js +62 -0
  326. package/.next/server/chunks/3273.js +1 -0
  327. package/.next/server/chunks/3298.js +1 -1
  328. package/.next/server/chunks/{8445.js → 3392.js} +2 -2
  329. package/.next/server/chunks/346.js +1 -0
  330. package/.next/server/chunks/3570.js +249 -0
  331. package/.next/server/chunks/3629.js +1 -0
  332. package/.next/server/chunks/38.js +2 -2
  333. package/.next/server/chunks/3951.js +151 -0
  334. package/.next/server/chunks/4042.js +1 -0
  335. package/.next/server/chunks/4265.js +1 -1
  336. package/.next/server/chunks/4306.js +1 -0
  337. package/.next/server/chunks/4322.js +1 -0
  338. package/.next/server/chunks/4426.js +6 -0
  339. package/.next/server/chunks/{6745.js → 4661.js} +1 -1
  340. package/.next/server/chunks/4671.js +1 -1
  341. package/.next/server/chunks/4681.js +1 -0
  342. package/.next/server/chunks/4765.js +1 -0
  343. package/.next/server/chunks/4771.js +2 -2
  344. package/.next/server/chunks/5067.js +1 -0
  345. package/.next/server/chunks/5096.js +1 -0
  346. package/.next/server/chunks/510.js +1 -0
  347. package/.next/server/chunks/5148.js +1 -1
  348. package/.next/server/chunks/{4578.js → 5150.js} +1 -1
  349. package/.next/server/chunks/5200.js +1 -0
  350. package/.next/server/chunks/5463.js +1 -1
  351. package/.next/server/chunks/5471.js +1 -0
  352. package/.next/server/chunks/5544.js +5 -5
  353. package/.next/server/chunks/5708.js +6 -5
  354. package/.next/server/chunks/5880.js +1 -0
  355. package/.next/server/chunks/5958.js +2 -0
  356. package/.next/server/chunks/6005.js +1 -0
  357. package/.next/server/chunks/6126.js +53 -0
  358. package/.next/server/chunks/6529.js +5 -0
  359. package/.next/server/chunks/6537.js +1 -1
  360. package/.next/server/chunks/6826.js +1 -1
  361. package/.next/server/chunks/6849.js +66 -0
  362. package/.next/server/chunks/688.js +3 -0
  363. package/.next/server/chunks/701.js +1 -1
  364. package/.next/server/chunks/7032.js +1 -1
  365. package/.next/server/chunks/7214.js +4 -4
  366. package/.next/server/chunks/724.js +1 -1
  367. package/.next/server/chunks/7463.js +4 -4
  368. package/.next/server/chunks/7506.js +1 -1
  369. package/.next/server/chunks/7538.js +21 -0
  370. package/.next/server/chunks/7579.js +8 -7
  371. package/.next/server/chunks/{3030.js → 7674.js} +1 -1
  372. package/.next/server/chunks/7821.js +1 -1
  373. package/.next/server/chunks/793.js +393 -0
  374. package/.next/server/chunks/8037.js +1 -0
  375. package/.next/server/chunks/8165.js +3 -0
  376. package/.next/server/chunks/8339.js +1 -0
  377. package/.next/server/chunks/8387.js +1 -1
  378. package/.next/server/chunks/8522.js +2 -0
  379. package/.next/server/chunks/8568.js +12 -0
  380. package/.next/server/chunks/8667.js +1 -0
  381. package/.next/server/chunks/869.js +2 -0
  382. package/.next/server/chunks/{3489.js → 8730.js} +1 -1
  383. package/.next/server/chunks/8739.js +2 -2
  384. package/.next/server/chunks/8745.js +1 -1
  385. package/.next/server/chunks/8979.js +37 -0
  386. package/.next/server/chunks/8994.js +1 -1
  387. package/.next/server/chunks/9165.js +1 -1
  388. package/.next/server/chunks/9285.js +1 -1
  389. package/.next/server/chunks/94.js +1 -1
  390. package/.next/server/chunks/9400.js +2 -0
  391. package/.next/server/chunks/{4456.js → 9472.js} +2 -2
  392. package/.next/server/chunks/9583.js +1 -0
  393. package/.next/server/chunks/9671.js +1 -0
  394. package/.next/server/chunks/9724.js +393 -0
  395. package/.next/server/chunks/991.js +2 -0
  396. package/.next/server/functions-config-manifest.json +1 -0
  397. package/.next/server/instrumentation.js +1 -1
  398. package/.next/server/instrumentation.js.nft.json +1 -1
  399. package/.next/server/middleware-build-manifest.js +1 -1
  400. package/.next/server/middleware-manifest.json +1 -1
  401. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  402. package/.next/server/pages/404.html +1 -1
  403. package/.next/server/pages/500.html +1 -1
  404. package/.next/server/server-reference-manifest.js +1 -1
  405. package/.next/server/server-reference-manifest.json +1 -1
  406. package/.next/server/src/middleware.js +1 -1
  407. package/.next/server/src/middleware.js.map +1 -1
  408. package/.next/static/Q6ITx_bZyoEOnKdZu_C7j/_buildManifest.js +1 -0
  409. package/.next/static/chunks/1594-309fa6363f215d76.js +1 -0
  410. package/.next/static/chunks/1809-e56cf3c476261e34.js +1 -0
  411. package/.next/static/chunks/1937-6bbdcdc660db562c.js +1 -0
  412. package/.next/static/chunks/1988-1b651d581fc44a36.js +1 -0
  413. package/.next/static/chunks/{2003-7710c23acaef11c9.js → 2003-f826c607d609d1fa.js} +1 -1
  414. package/.next/static/chunks/2164-7d6451e88a447de7.js +1 -0
  415. package/.next/static/chunks/218-6cbe09820faa3272.js +1 -0
  416. package/.next/static/chunks/2566-60acd5838abd9f3f.js +1 -0
  417. package/.next/static/chunks/{2403-5c26e0abd76095b1.js → 2800-4fa29a3eeb693593.js} +1 -1
  418. package/.next/static/chunks/289-98f50bfcf833d661.js +1 -0
  419. package/.next/static/chunks/3089.9e15df4ffd0fe4e8.js +1 -0
  420. package/.next/static/chunks/{3217.f728df99ab5da33c.js → 3217.260785c2198d1e9d.js} +1 -1
  421. package/.next/static/chunks/3392-6dd9ad3be66a7ce9.js +1 -0
  422. package/.next/static/chunks/3418-a2f5d0c4f29ee2fb.js +1 -0
  423. package/.next/static/chunks/{3556-3b6f7c99b015b752.js → 3556-b9855146c7506696.js} +1 -1
  424. package/.next/static/chunks/3827-9e9a6e11ef808d90.js +1 -0
  425. package/.next/static/chunks/3910.5c6885d7a5bd753e.js +1 -0
  426. package/.next/static/chunks/3948-1cb8fc7a64805254.js +1 -0
  427. package/.next/static/chunks/3958-5641a828b320f2fe.js +100 -0
  428. package/.next/static/chunks/{488-623d07c3fbc21e28.js → 488-7ab54d8ae2b4b550.js} +1 -1
  429. package/.next/static/chunks/5328-4e556503b70e72b4.js +1 -0
  430. package/.next/static/chunks/{5512.d01d565f73109a1a.js → 5512.682bef7fd3a7c286.js} +1 -1
  431. package/.next/static/chunks/6195-8c4c57628e9013d5.js +1 -0
  432. package/.next/static/chunks/6669-a949326b30ea1d39.js +1 -0
  433. package/.next/static/chunks/6777-4b0d05731a089de4.js +1 -0
  434. package/.next/static/chunks/6947-0ff3545efb53e959.js +1 -0
  435. package/.next/static/chunks/7111-44538f8a64241b74.js +1 -0
  436. package/.next/static/chunks/7304-e7cd725083617b81.js +8 -0
  437. package/.next/static/chunks/7445-2802e158c9093556.js +1 -0
  438. package/.next/static/chunks/795-704a0e742ecc2ef6.js +1 -0
  439. package/.next/static/chunks/812-3ceea0da38ad2891.js +1 -0
  440. package/.next/static/chunks/{8345.fbc0af16acce7256.js → 8345.bc5534ec13abc9ee.js} +1 -1
  441. package/.next/static/chunks/8401-0f39d91810180a88.js +1 -0
  442. package/.next/static/chunks/{8405.e728bc83a7c9fed6.js → 8405.73e8be2c8e5b55c5.js} +1 -1
  443. package/.next/static/chunks/8551-a28272acfda62ac9.js +1 -0
  444. package/.next/static/chunks/8855-02889c9ab4bf0bcf.js +1 -0
  445. package/.next/static/chunks/{8989-401559d9f3bc80a0.js → 8989-5fa9c7c670eb9a1a.js} +1 -1
  446. package/.next/static/chunks/{9164-829ab5b085ec06d6.js → 9164-840f056a0e11d979.js} +1 -1
  447. package/.next/static/chunks/9562-ef0ddd4e6b9023cf.js +1 -0
  448. package/.next/static/chunks/app/api/approvals/[id]/route-c745e5b53b81491a.js +1 -0
  449. package/.next/static/chunks/app/api/approvals/route-c745e5b53b81491a.js +1 -0
  450. package/.next/static/chunks/app/api/backup/route-c745e5b53b81491a.js +1 -0
  451. package/.next/static/chunks/app/api/browse/route-c745e5b53b81491a.js +1 -0
  452. package/.next/static/chunks/app/api/bugs/enhance/route-c745e5b53b81491a.js +1 -0
  453. package/.next/static/chunks/app/api/cwd/route-c745e5b53b81491a.js +1 -0
  454. package/.next/static/chunks/app/api/encryption/secure/route-c745e5b53b81491a.js +1 -0
  455. package/.next/static/chunks/app/api/env/route-c745e5b53b81491a.js +1 -0
  456. package/.next/static/chunks/app/api/flow/[id]/route-c745e5b53b81491a.js +1 -0
  457. package/.next/static/chunks/app/api/flow/[id]/versions/[versionId]/route-c745e5b53b81491a.js +1 -0
  458. package/.next/static/chunks/app/api/flow/[id]/versions/route-c745e5b53b81491a.js +1 -0
  459. package/.next/static/chunks/app/api/flow/compile/route-c745e5b53b81491a.js +1 -0
  460. package/.next/static/chunks/app/api/flow/generate/route-c745e5b53b81491a.js +1 -0
  461. package/.next/static/chunks/app/api/flow/improve/route-c745e5b53b81491a.js +1 -0
  462. package/.next/static/chunks/app/api/flow/prompt-renderer/route-c745e5b53b81491a.js +1 -0
  463. package/.next/static/chunks/app/api/flow/quick-chat/route-c745e5b53b81491a.js +1 -0
  464. package/.next/static/chunks/app/api/flow/repair/route-c745e5b53b81491a.js +1 -0
  465. package/.next/static/chunks/app/api/flow/route-c745e5b53b81491a.js +1 -0
  466. package/.next/static/chunks/app/api/git/route-c745e5b53b81491a.js +1 -0
  467. package/.next/static/chunks/app/api/init/route-c745e5b53b81491a.js +1 -0
  468. package/.next/static/chunks/app/api/local-models/capability/route-c745e5b53b81491a.js +1 -0
  469. package/.next/static/chunks/app/api/local-models/pull/route-c745e5b53b81491a.js +1 -0
  470. package/.next/static/chunks/app/api/local-models/suggest/route-c745e5b53b81491a.js +1 -0
  471. package/.next/static/chunks/app/api/mcp/app-sandbox/route-c745e5b53b81491a.js +1 -0
  472. package/.next/static/chunks/app/api/mcp/cancel/route-c745e5b53b81491a.js +1 -0
  473. package/.next/static/chunks/app/api/mcp/oauth-capability/route-c745e5b53b81491a.js +1 -0
  474. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-c745e5b53b81491a.js +1 -0
  475. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-c745e5b53b81491a.js +1 -0
  476. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-c745e5b53b81491a.js +1 -0
  477. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-c745e5b53b81491a.js +1 -0
  478. package/.next/static/chunks/app/api/mcp/servers/[name]/route-c745e5b53b81491a.js +1 -0
  479. package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-c745e5b53b81491a.js +1 -0
  480. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-c745e5b53b81491a.js +1 -0
  481. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-c745e5b53b81491a.js +1 -0
  482. package/.next/static/chunks/app/api/mcp/servers/route-c745e5b53b81491a.js +1 -0
  483. package/.next/static/chunks/app/api/mcp/test-connection/route-c745e5b53b81491a.js +1 -0
  484. package/.next/static/chunks/app/api/mcp/test-connection/stream/route-c745e5b53b81491a.js +1 -0
  485. package/.next/static/chunks/app/api/mcp-registry/route-c745e5b53b81491a.js +1 -0
  486. package/.next/static/chunks/app/api/mcp-registry/spotlight/route-c745e5b53b81491a.js +1 -0
  487. package/.next/static/chunks/app/api/model/[id]/route-c745e5b53b81491a.js +1 -0
  488. package/.next/static/chunks/app/api/model/provider/route-c745e5b53b81491a.js +1 -0
  489. package/.next/static/chunks/app/api/model/route-c745e5b53b81491a.js +1 -0
  490. package/.next/static/chunks/app/api/model/test/route-c745e5b53b81491a.js +1 -0
  491. package/.next/static/chunks/app/api/oauth/callback/route-c745e5b53b81491a.js +1 -0
  492. package/.next/static/chunks/app/api/oauth/initiate/route-c745e5b53b81491a.js +1 -0
  493. package/.next/static/chunks/app/api/oauth/reset/route-c745e5b53b81491a.js +1 -0
  494. package/.next/static/chunks/app/api/packages/build/route-c745e5b53b81491a.js +1 -0
  495. package/.next/static/chunks/app/api/packages/derive-secrets/route-c745e5b53b81491a.js +1 -0
  496. package/.next/static/chunks/app/api/packages/install/route-c745e5b53b81491a.js +1 -0
  497. package/.next/static/chunks/app/api/packages/install/status/route-c745e5b53b81491a.js +1 -0
  498. package/.next/static/chunks/app/api/packages/installed/route-c745e5b53b81491a.js +1 -0
  499. package/.next/static/chunks/app/api/packages/resolve/route-c745e5b53b81491a.js +1 -0
  500. package/.next/static/chunks/app/api/packages/uninstall/route-c745e5b53b81491a.js +1 -0
  501. package/.next/static/chunks/app/api/planned-executions/[id]/route-c745e5b53b81491a.js +1 -0
  502. package/.next/static/chunks/app/api/planned-executions/[id]/run/route-c745e5b53b81491a.js +1 -0
  503. package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-c745e5b53b81491a.js +1 -0
  504. package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-c745e5b53b81491a.js +1 -0
  505. package/.next/static/chunks/app/api/planned-executions/reconcile/route-c745e5b53b81491a.js +1 -0
  506. package/.next/static/chunks/app/api/planned-executions/route-c745e5b53b81491a.js +1 -0
  507. package/.next/static/chunks/app/api/registry/auth/resend/route-c745e5b53b81491a.js +1 -0
  508. package/.next/static/chunks/app/api/registry/auth/reset/route-c745e5b53b81491a.js +1 -0
  509. package/.next/static/chunks/app/api/registry/auth/route-c745e5b53b81491a.js +1 -0
  510. package/.next/static/chunks/app/api/registry/oauth/callback/route-c745e5b53b81491a.js +1 -0
  511. package/.next/static/chunks/app/api/registry/oauth/initiate/route-c745e5b53b81491a.js +1 -0
  512. package/.next/static/chunks/app/api/registry/publish/route-c745e5b53b81491a.js +1 -0
  513. package/.next/static/chunks/app/api/registry/settings/route-c745e5b53b81491a.js +1 -0
  514. package/.next/static/chunks/app/api/restore/route-c745e5b53b81491a.js +1 -0
  515. package/.next/static/chunks/app/api/runs/active/route-c745e5b53b81491a.js +1 -0
  516. package/.next/static/chunks/app/api/storage/route-c745e5b53b81491a.js +1 -0
  517. package/.next/static/chunks/app/api/update/route-c745e5b53b81491a.js +1 -0
  518. package/.next/static/chunks/app/api/waves/route-c745e5b53b81491a.js +1 -0
  519. package/.next/static/chunks/app/api/webhooks/[id]/route-c745e5b53b81491a.js +1 -0
  520. package/.next/static/chunks/app/chat/page-c39160ddf90bbae9.js +1 -0
  521. package/.next/static/chunks/app/docs/page-250523af44e96120.js +1 -0
  522. package/.next/static/chunks/app/executions/page-10d09f36de30939f.js +1 -0
  523. package/.next/static/chunks/app/flows/page-0d8fb471adfc2981.js +1 -0
  524. package/.next/static/chunks/app/layout-eea7078d7553c21a.js +1 -0
  525. package/.next/static/chunks/app/mcp/page-8ad71bf5801bfe5f.js +1 -0
  526. package/.next/static/chunks/app/mcp-flows/route-c745e5b53b81491a.js +1 -0
  527. package/.next/static/chunks/app/mcp-proxy/[server]/route-c745e5b53b81491a.js +1 -0
  528. package/.next/static/chunks/app/models/page-17e8e6668f92f58d.js +1 -0
  529. package/.next/static/chunks/app/packages/page-9f61751e98134f3d.js +1 -0
  530. package/.next/static/chunks/app/{page-0a95c40a65dbd2eb.js → page-d3ea90b065b95d1e.js} +1 -1
  531. package/.next/static/chunks/app/settings/page-afbf8790e99fecaf.js +1 -0
  532. package/.next/static/chunks/app/v1/chat/completions/route-c745e5b53b81491a.js +1 -0
  533. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-c745e5b53b81491a.js +1 -0
  534. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-c745e5b53b81491a.js +1 -0
  535. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-c745e5b53b81491a.js +1 -0
  536. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-c745e5b53b81491a.js +1 -0
  537. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-c745e5b53b81491a.js +1 -0
  538. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-c745e5b53b81491a.js +1 -0
  539. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/resources/route-c745e5b53b81491a.js +1 -0
  540. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-c745e5b53b81491a.js +1 -0
  541. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-c745e5b53b81491a.js +1 -0
  542. package/.next/static/chunks/app/v1/chat/conversations/route-c745e5b53b81491a.js +1 -0
  543. package/.next/static/chunks/app/v1/chat/events/route-c745e5b53b81491a.js +1 -0
  544. package/.next/static/chunks/app/v1/models/route-c745e5b53b81491a.js +1 -0
  545. package/.next/static/chunks/app/waves/page-97ad6b51c9cae4b3.js +1 -0
  546. package/.next/static/chunks/webpack-0d4a4e773990ac44.js +1 -0
  547. package/.next/static/css/{64cb1f185b52a623.css → 69ab44eb350e0b6c.css} +1 -1
  548. package/.next/trace +10 -10
  549. package/.next/types/app/api/flow/[id]/versions/[versionId]/route.ts +347 -0
  550. package/.next/types/app/api/flow/[id]/versions/route.ts +347 -0
  551. package/.next/types/app/api/mcp/app-sandbox/route.ts +347 -0
  552. package/.next/types/app/api/mcp/oauth-capability/route.ts +347 -0
  553. package/.next/types/app/api/packages/build/route.ts +347 -0
  554. package/.next/types/app/api/packages/derive-secrets/route.ts +347 -0
  555. package/.next/types/app/api/packages/install/route.ts +347 -0
  556. package/.next/types/app/api/packages/install/status/route.ts +347 -0
  557. package/.next/types/app/api/packages/installed/route.ts +347 -0
  558. package/.next/types/app/api/packages/resolve/route.ts +347 -0
  559. package/.next/types/app/api/packages/uninstall/route.ts +347 -0
  560. package/.next/types/app/api/registry/auth/resend/route.ts +347 -0
  561. package/.next/types/app/api/registry/auth/reset/route.ts +347 -0
  562. package/.next/types/app/api/registry/auth/route.ts +347 -0
  563. package/.next/types/app/api/registry/oauth/callback/route.ts +347 -0
  564. package/.next/types/app/api/registry/oauth/initiate/route.ts +347 -0
  565. package/.next/types/app/api/registry/publish/route.ts +347 -0
  566. package/.next/types/app/api/registry/settings/route.ts +347 -0
  567. package/.next/types/app/packages/page.ts +84 -0
  568. package/.next/types/app/v1/chat/events/route.ts +347 -0
  569. package/.next/types/routes.d.ts +22 -2
  570. package/.next/types/validator.ts +180 -0
  571. package/README.md +1 -1
  572. package/package.json +97 -90
  573. package/.next/server/chunks/1152.js +0 -2
  574. package/.next/server/chunks/1223.js +0 -1
  575. package/.next/server/chunks/1377.js +0 -1
  576. package/.next/server/chunks/2373.js +0 -1
  577. package/.next/server/chunks/289.js +0 -1
  578. package/.next/server/chunks/3774.js +0 -6
  579. package/.next/server/chunks/3823.js +0 -41
  580. package/.next/server/chunks/3855.js +0 -1
  581. package/.next/server/chunks/3924.js +0 -52
  582. package/.next/server/chunks/4372.js +0 -1
  583. package/.next/server/chunks/4545.js +0 -21
  584. package/.next/server/chunks/4561.js +0 -65
  585. package/.next/server/chunks/4677.js +0 -37
  586. package/.next/server/chunks/472.js +0 -1
  587. package/.next/server/chunks/4793.js +0 -2
  588. package/.next/server/chunks/4836.js +0 -1
  589. package/.next/server/chunks/5311.js +0 -1
  590. package/.next/server/chunks/5662.js +0 -2
  591. package/.next/server/chunks/5734.js +0 -60
  592. package/.next/server/chunks/584.js +0 -1
  593. package/.next/server/chunks/62.js +0 -1
  594. package/.next/server/chunks/6240.js +0 -1
  595. package/.next/server/chunks/6306.js +0 -1
  596. package/.next/server/chunks/6793.js +0 -1
  597. package/.next/server/chunks/6908.js +0 -12
  598. package/.next/server/chunks/6996.js +0 -62
  599. package/.next/server/chunks/7362.js +0 -158
  600. package/.next/server/chunks/8216.js +0 -1
  601. package/.next/server/chunks/856.js +0 -5
  602. package/.next/server/chunks/8652.js +0 -42
  603. package/.next/server/chunks/9427.js +0 -1
  604. package/.next/static/Il6IDWxf3CN0dv-P6QQrp/_buildManifest.js +0 -1
  605. package/.next/static/chunks/1675-773454288de4309d.js +0 -1
  606. package/.next/static/chunks/1731-6e45fb529f9044a3.js +0 -1
  607. package/.next/static/chunks/2318-76fcb6c769b1a569.js +0 -1
  608. package/.next/static/chunks/2566-6e2b9d9349814789.js +0 -1
  609. package/.next/static/chunks/2734-59fbe2f62a59df86.js +0 -1
  610. package/.next/static/chunks/3089.6b4e21e1faa304e2.js +0 -1
  611. package/.next/static/chunks/3109-11bdec9bdfd996c3.js +0 -1
  612. package/.next/static/chunks/333-5f3c5be57c80c48c.js +0 -1
  613. package/.next/static/chunks/3333-b7b3e5758a568013.js +0 -1
  614. package/.next/static/chunks/4003-3b3768446ae333df.js +0 -1
  615. package/.next/static/chunks/4635-0fe310d3be64e71e.js +0 -1
  616. package/.next/static/chunks/4690-ec7d397cfacedac3.js +0 -1
  617. package/.next/static/chunks/4775-cb9c0be621363a08.js +0 -8
  618. package/.next/static/chunks/5336-81da1080de29ebfc.js +0 -1
  619. package/.next/static/chunks/6691-117567b2b40cd9f4.js +0 -1
  620. package/.next/static/chunks/7274-1184563607f2b5f5.js +0 -1
  621. package/.next/static/chunks/812-624e93f4c0f671c7.js +0 -1
  622. package/.next/static/chunks/8166-e75acdc559b34fcd.js +0 -1
  623. package/.next/static/chunks/8607-5787e42775fc3acb.js +0 -1
  624. package/.next/static/chunks/8610-660d5088bc1dd7a7.js +0 -1
  625. package/.next/static/chunks/9240-d0a51f4d504f34b1.js +0 -1
  626. package/.next/static/chunks/9562-b7922ceb400ec536.js +0 -1
  627. package/.next/static/chunks/9704-6b7415964d7c042a.js +0 -1
  628. package/.next/static/chunks/app/api/approvals/[id]/route-6b442f97c5062f2c.js +0 -1
  629. package/.next/static/chunks/app/api/approvals/route-6b442f97c5062f2c.js +0 -1
  630. package/.next/static/chunks/app/api/backup/route-6b442f97c5062f2c.js +0 -1
  631. package/.next/static/chunks/app/api/browse/route-6b442f97c5062f2c.js +0 -1
  632. package/.next/static/chunks/app/api/bugs/enhance/route-6b442f97c5062f2c.js +0 -1
  633. package/.next/static/chunks/app/api/cwd/route-6b442f97c5062f2c.js +0 -1
  634. package/.next/static/chunks/app/api/encryption/secure/route-6b442f97c5062f2c.js +0 -1
  635. package/.next/static/chunks/app/api/env/route-6b442f97c5062f2c.js +0 -1
  636. package/.next/static/chunks/app/api/flow/[id]/route-6b442f97c5062f2c.js +0 -1
  637. package/.next/static/chunks/app/api/flow/compile/route-6b442f97c5062f2c.js +0 -1
  638. package/.next/static/chunks/app/api/flow/generate/route-6b442f97c5062f2c.js +0 -1
  639. package/.next/static/chunks/app/api/flow/improve/route-6b442f97c5062f2c.js +0 -1
  640. package/.next/static/chunks/app/api/flow/prompt-renderer/route-6b442f97c5062f2c.js +0 -1
  641. package/.next/static/chunks/app/api/flow/quick-chat/route-6b442f97c5062f2c.js +0 -1
  642. package/.next/static/chunks/app/api/flow/repair/route-6b442f97c5062f2c.js +0 -1
  643. package/.next/static/chunks/app/api/flow/route-6b442f97c5062f2c.js +0 -1
  644. package/.next/static/chunks/app/api/git/route-6b442f97c5062f2c.js +0 -1
  645. package/.next/static/chunks/app/api/init/route-6b442f97c5062f2c.js +0 -1
  646. package/.next/static/chunks/app/api/local-models/capability/route-6b442f97c5062f2c.js +0 -1
  647. package/.next/static/chunks/app/api/local-models/pull/route-6b442f97c5062f2c.js +0 -1
  648. package/.next/static/chunks/app/api/local-models/suggest/route-6b442f97c5062f2c.js +0 -1
  649. package/.next/static/chunks/app/api/mcp/cancel/route-6b442f97c5062f2c.js +0 -1
  650. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-6b442f97c5062f2c.js +0 -1
  651. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-6b442f97c5062f2c.js +0 -1
  652. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-6b442f97c5062f2c.js +0 -1
  653. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-6b442f97c5062f2c.js +0 -1
  654. package/.next/static/chunks/app/api/mcp/servers/[name]/route-6b442f97c5062f2c.js +0 -1
  655. package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-6b442f97c5062f2c.js +0 -1
  656. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-6b442f97c5062f2c.js +0 -1
  657. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-6b442f97c5062f2c.js +0 -1
  658. package/.next/static/chunks/app/api/mcp/servers/route-6b442f97c5062f2c.js +0 -1
  659. package/.next/static/chunks/app/api/mcp/test-connection/route-6b442f97c5062f2c.js +0 -1
  660. package/.next/static/chunks/app/api/mcp/test-connection/stream/route-6b442f97c5062f2c.js +0 -1
  661. package/.next/static/chunks/app/api/mcp-registry/route-6b442f97c5062f2c.js +0 -1
  662. package/.next/static/chunks/app/api/mcp-registry/spotlight/route-6b442f97c5062f2c.js +0 -1
  663. package/.next/static/chunks/app/api/model/[id]/route-6b442f97c5062f2c.js +0 -1
  664. package/.next/static/chunks/app/api/model/provider/route-6b442f97c5062f2c.js +0 -1
  665. package/.next/static/chunks/app/api/model/route-6b442f97c5062f2c.js +0 -1
  666. package/.next/static/chunks/app/api/model/test/route-6b442f97c5062f2c.js +0 -1
  667. package/.next/static/chunks/app/api/oauth/callback/route-6b442f97c5062f2c.js +0 -1
  668. package/.next/static/chunks/app/api/oauth/initiate/route-6b442f97c5062f2c.js +0 -1
  669. package/.next/static/chunks/app/api/oauth/reset/route-6b442f97c5062f2c.js +0 -1
  670. package/.next/static/chunks/app/api/planned-executions/[id]/route-6b442f97c5062f2c.js +0 -1
  671. package/.next/static/chunks/app/api/planned-executions/[id]/run/route-6b442f97c5062f2c.js +0 -1
  672. package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-6b442f97c5062f2c.js +0 -1
  673. package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-6b442f97c5062f2c.js +0 -1
  674. package/.next/static/chunks/app/api/planned-executions/reconcile/route-6b442f97c5062f2c.js +0 -1
  675. package/.next/static/chunks/app/api/planned-executions/route-6b442f97c5062f2c.js +0 -1
  676. package/.next/static/chunks/app/api/restore/route-6b442f97c5062f2c.js +0 -1
  677. package/.next/static/chunks/app/api/runs/active/route-6b442f97c5062f2c.js +0 -1
  678. package/.next/static/chunks/app/api/storage/route-6b442f97c5062f2c.js +0 -1
  679. package/.next/static/chunks/app/api/update/route-6b442f97c5062f2c.js +0 -1
  680. package/.next/static/chunks/app/api/waves/route-6b442f97c5062f2c.js +0 -1
  681. package/.next/static/chunks/app/api/webhooks/[id]/route-6b442f97c5062f2c.js +0 -1
  682. package/.next/static/chunks/app/chat/page-04ad1fad78048afb.js +0 -1
  683. package/.next/static/chunks/app/docs/page-5475c616764dbb18.js +0 -1
  684. package/.next/static/chunks/app/executions/page-c18708ed96d228ec.js +0 -1
  685. package/.next/static/chunks/app/flows/page-f7e44aa545bcc56e.js +0 -1
  686. package/.next/static/chunks/app/layout-e6fbae80e0f456a6.js +0 -1
  687. package/.next/static/chunks/app/mcp/page-3638fbee04a3a6ea.js +0 -1
  688. package/.next/static/chunks/app/mcp-flows/route-6b442f97c5062f2c.js +0 -1
  689. package/.next/static/chunks/app/mcp-proxy/[server]/route-6b442f97c5062f2c.js +0 -1
  690. package/.next/static/chunks/app/models/page-e690a986047b1e62.js +0 -1
  691. package/.next/static/chunks/app/settings/page-3ef9b95187e18a5a.js +0 -1
  692. package/.next/static/chunks/app/v1/chat/completions/route-6b442f97c5062f2c.js +0 -1
  693. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-6b442f97c5062f2c.js +0 -1
  694. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-6b442f97c5062f2c.js +0 -1
  695. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-6b442f97c5062f2c.js +0 -1
  696. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-6b442f97c5062f2c.js +0 -1
  697. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-6b442f97c5062f2c.js +0 -1
  698. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-6b442f97c5062f2c.js +0 -1
  699. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/resources/route-6b442f97c5062f2c.js +0 -1
  700. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-6b442f97c5062f2c.js +0 -1
  701. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-6b442f97c5062f2c.js +0 -1
  702. package/.next/static/chunks/app/v1/chat/conversations/route-6b442f97c5062f2c.js +0 -1
  703. package/.next/static/chunks/app/v1/models/route-6b442f97c5062f2c.js +0 -1
  704. package/.next/static/chunks/app/waves/page-c9a307e2236423a4.js +0 -1
  705. package/.next/static/chunks/webpack-a6844e1074885c2f.js +0 -1
  706. /package/.next/static/{Il6IDWxf3CN0dv-P6QQrp → Q6ITx_bZyoEOnKdZu_C7j}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3080],{9898:(e,t,r)=>{"use strict";r.d(t,{v:()=>s});var n=r(12115),o=r(17897);let l=(0,r(87021).h)("frontend/hooks/useServerStatus");function a(e){return"stdio"===e.transport?e.args&&e.args.length>0?e.args[0]:"Unknown path":"websocket"===e.transport?e.websocketUrl||"Unknown URL":e.serverUrl||"Unknown URL"}function s(){let[e,t]=(0,n.useState)([]),[r,s]=(0,n.useState)(!0),[i,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(new Set),p=(0,n.useCallback)(async()=>{l.debug("Loading servers"),s(!0),d(null);try{let e=await o.S.loadServerConfigs();if(!e||"error"in e){l.warn("Failed to load server configurations:",null==e?void 0:e.error),d((null==e?void 0:e.error)||"Failed to load server configurations"),s(!1);return}let r=await Promise.all(e.map(async e=>{l.debug("Getting status for server: ".concat(e.name));let t=await o.S.getServerStatus(e.name),r="string"==typeof t?t:t.status,n="object"==typeof t&&t.message?t.message:void 0,s="object"==typeof t&&t.stderrOutput?t.stderrOutput:void 0,i=a(e);return{...e,path:i,status:r,error:n,stderrOutput:s}}));l.debug("Final server states:",r),t(r),s(!1)}catch(e){l.warn("Failed to load servers:",e),d("Failed to load servers"),s(!1)}},[]),h=(0,n.useCallback)(async(r,n)=>{l.debug("Toggling server ".concat(r," to ").concat(n?"enabled":"disabled"));try{let a=e.find(e=>e.name===r);if(!a)return l.warn("Server not found: ".concat(r)),!1;l.debug("Found server ".concat(r,", current disabled state: ").concat(a.disabled));let s=await o.S.updateServerConfig(r,{disabled:!n});if(s.error)return l.warn("Failed to update server config:",[s.error,r]),!1;l.debug("Updating server ".concat(r," state in UI, new disabled state: ").concat(!n)),t(e=>e.map(e=>e.name===r?{...e,disabled:!n}:e)),l.info("Successfully toggled server ".concat(r," to ").concat(n?"enabled":"disabled"));try{let e=await o.S.getServerStatus(r),n="string"==typeof e?e:e.status,l="object"==typeof e&&e.message?e.message:void 0,a="object"==typeof e&&e.stderrOutput?e.stderrOutput:void 0;t(e=>e.map(e=>e.name===r?{...e,status:n,error:l,stderrOutput:a}:e))}catch(e){l.warn("Failed to get status for server ".concat(r," after toggle:"),e)}return!0}catch(e){return l.warn("Failed to toggle server:",e),!1}},[e]),f=(0,n.useCallback)(async r=>{l.debug("Deleting server: ".concat(r));try{if(!e.find(e=>e.name===r))return l.warn("Server not found:",r),!1;let n=await o.S.deleteServerConfig(r);if(n.error)return l.warn("Failed to delete server config:",n.error),!1;return t(e=>e.filter(e=>e.name!==r)),!0}catch(e){return l.warn("Failed to delete server:",e),!1}},[e]),m=(0,n.useCallback)(async e=>{l.debug("Adding server:",e);try{let r=a(e),n={...e,path:r,status:"connecting",tools:[],env:e.env||{}};t(e=>[...e,n]),u(t=>new Set(t).add(e.name));let s=await o.S.updateServerConfig(e.name,e);if(s.error)return l.warn("Failed to update server config:",s.error),t(t=>t.map(t=>t.name===e.name?{...t,status:"error",error:s.error}:t)),u(t=>{let r=new Set(t);return r.delete(e.name),r}),!1;l.info("Successfully added server ".concat(e.name));try{let r=await o.S.getServerStatus(e.name),n="string"==typeof r?r:r.status,l="object"==typeof r&&r.message?r.message:void 0,a="object"==typeof r&&r.stderrOutput?r.stderrOutput:void 0;t(t=>t.map(t=>t.name===e.name?{...t,status:n,error:l,stderrOutput:a}:t))}catch(t){l.warn("Failed to get status for server ".concat(e.name," after adding:"),t)}return u(t=>{let r=new Set(t);return r.delete(e.name),r}),!0}catch(r){return l.warn("Failed to add server:",r),t(t=>t.map(t=>t.name===e.name?{...t,status:"error",error:r instanceof Error?r.message:"Unknown error during server addition"}:t)),u(t=>{let r=new Set(t);return r.delete(e.name),r}),!1}},[]),g=(0,n.useCallback)(async(e,r)=>{let n=null!=r?r:e.name,s=n!==e.name;l.debug("Updating server:",e);try{t(t=>t.map(t=>t.name===n?{...e,path:a(e),status:t.status,error:t.error,stderrOutput:t.stderrOutput}:t));let r=await o.S.updateServerConfig(n,e);if(r.error){if(l.warn("Failed to update server config:",r.error),s)return await p(),!1;return t(t=>t.map(t=>t.name===e.name?{...t,status:"error",error:r.error}:t)),!1}l.info("Successfully updated config for server ".concat(e.name));try{let r=await o.S.getServerStatus(e.name),n="string"==typeof r?r:r.status,l="object"==typeof r&&r.message?r.message:void 0,a="object"==typeof r&&r.stderrOutput?r.stderrOutput:void 0;t(t=>t.map(t=>t.name===e.name?{...t,status:n,error:l,stderrOutput:a}:t))}catch(t){l.warn("Failed to get status for server ".concat(e.name," after config update:"),t)}return!0}catch(n){if(l.warn("Failed to update server:",n),s)return await p(),!1;let r=n instanceof Error?n.message:"Unknown error during update";return t(t=>t.map(t=>t.name===e.name?{...t,status:"error",error:r}:t)),!1}},[p]),x=(0,n.useCallback)(async(e,r)=>{let n=r&&r.trim()?r.trim():"";l.debug("Setting folder for server ".concat(e," to ").concat(n||"(none)"));try{let r=await o.S.updateServerConfig(e,{folder:n});if("error"in r&&r.error)return l.warn("Failed to update server folder:",r.error),!1;return t(t=>t.map(t=>t.name===e?{...t,folder:n||void 0}:t)),!0}catch(e){return l.warn("Failed to set server folder:",e),!1}},[]),v=(0,n.useCallback)(async(e,r)=>{l.debug("Setting favorite for server ".concat(e," to ").concat(r));try{let n=await o.S.updateServerConfig(e,{favorite:r});if("error"in n&&n.error)return l.warn("Failed to update server favorite:",n.error),!1;return t(t=>t.map(t=>t.name===e?{...t,favorite:r}:t)),!0}catch(e){return l.warn("Failed to set server favorite:",e),!1}},[]),w=(0,n.useCallback)(async(r,n)=>{l.debug("Saving environment variables for server: ".concat(r),n);try{if(!e.find(e=>e.name===r))return l.warn("Server not found: ".concat(r)),!1;let a=await o.S.updateServerConfig(r,{env:n});if(a.error)return l.warn("Failed to update server config:",a.error),!1;return l.debug("Updating environment variables in UI for server: ".concat(r)),t(e=>e.map(e=>e.name===r?{...e,env:n}:e)),l.info("Successfully saved environment variables for server: ".concat(r)),!0}catch(e){return l.warn("Failed to save environment variables:",e),!1}},[e]);return(0,n.useEffect)(()=>{p()},[p]),{servers:e,isLoading:r,loadError:i,connectingServers:c,loadServers:p,toggleServer:h,retryServer:(0,n.useCallback)(async e=>{l.debug("Retrying server status for: ".concat(e));try{let r=await o.S.getServerStatus(e),n="string"==typeof r?r:r.status,l="object"==typeof r&&r.message?r.message:void 0,a="object"==typeof r&&r.stderrOutput?r.stderrOutput:void 0;return t(t=>t.map(t=>t.name===e?{...t,status:n,error:l,stderrOutput:a}:t)),!0}catch(e){return l.warn("Failed to retry server status:",e),!1}},[]),deleteServer:f,addServer:m,updateServer:g,setServerFolder:x,setServerFavorite:v,saveEnv:w}}},60530:(e,t,r)=>{"use strict";r.d(t,{L_:()=>a,QO:()=>o,bH:()=>l});let n=null;function o(e){n=e}function l(e){n===e&&(n=null)}function a(e){return!!n&&(n(e),!0)}},71075:(e,t,r)=>{Promise.resolve().then(r.bind(r,98774))},71651:(e,t,r)=>{"use strict";r.d(t,{A:()=>x});var n=r(95155),o=r(12115),l=r(94049),a=r(25635),s=r(80777),i=r(9562),d=r(78470),c=r(41983),u=r(91871),p=r(86946),h=r(4484),f=r(80007),m=r(79299),g=r(62640);let x=e=>{let{roots:t,onChange:r}=e,x=Array.isArray(t)?t:[],[v,w]=(0,o.useState)(null),b=(e,t)=>{r(x.map((r,n)=>n===e?t:r))};return(0,n.jsxs)(l.default,{children:[(0,n.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",mb:.5},children:[(0,n.jsx)(f.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),(0,n.jsx)(a.default,{variant:"subtitle1",children:"Workspace folders"})]}),(0,n.jsxs)(a.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:["Limit which folders this server may work in. Advisory only — the server is told these paths via MCP roots; it is not a hard sandbox. Leave empty to default to the server's own root dir. Supports ",(0,n.jsx)("code",{children:"${global:VAR}"}),"."]}),(0,n.jsx)(s.A,{spacing:1,children:x.map((e,t)=>(0,n.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,n.jsx)(i.A,{size:"small",fullWidth:!0,placeholder:"/path/to/folder or file:///path",value:e,onChange:e=>b(t,e.target.value)}),(0,n.jsx)(d.A,{title:"Browse folders (on the FLUJO machine)",children:(0,n.jsx)(c.A,{size:"small",onClick:()=>w(t),"aria-label":"browse for folder",children:(0,n.jsx)(m.A,{fontSize:"small"})})}),(0,n.jsx)(d.A,{title:"Remove",children:(0,n.jsx)(c.A,{size:"small",onClick:()=>r(x.filter((e,r)=>r!==t)),"aria-label":"remove workspace folder",children:(0,n.jsx)(h.A,{fontSize:"small"})})})]},t))}),(0,n.jsx)(u.A,{size:"small",startIcon:(0,n.jsx)(p.A,{}),onClick:()=>r([...x,""]),sx:{mt:1},children:"Add folder"}),(0,n.jsx)(g.A,{open:null!==v,title:"Choose a workspace folder",initialPath:null!==v&&x[v]||void 0,onClose:()=>w(null),onSelect:e=>{null!==v&&b(v,e)}})]})}},94035:(e,t,r)=>{"use strict";r.d(t,{O:()=>a});var n=r(12115),o=r(17897);let l=(0,r(87021).h)("frontend/hooks/useServerTools");function a(e){let[t,r]=(0,n.useState)([]),[a,s]=(0,n.useState)(!1),[i,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(null),[p,h]=(0,n.useState)(null),[f,m]=(0,n.useState)(0),[g,x]=(0,n.useState)(!1),v=(0,n.useRef)(null);(0,n.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);let w=(0,n.useCallback)(async function(){let n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e){r([]),d(null);return}if(h(e),!n&&c&&new Date().getTime()-c.getTime()<200&&t.length>0&&e===p)return void l.debug("Rate limiting tool refresh for server: ".concat(e));l.debug("Loading tools for server: ".concat(e)),s(!0),d(null);try{let t=await o.S.listServerTools(e);if(e!==p)return void l.debug("Server changed during tool loading from ".concat(e," to ").concat(p));if(t.error)l.warn("Error loading tools for ".concat(e,":"),t.error),d(t.error),r([]);else{let n=t.tools||[];l.debug("Loaded ".concat(n.length," tools for ").concat(e)),r(n),u(new Date),m(0)}}catch(t){if(e!==p)return void l.debug("Server changed during tool loading from ".concat(e," to ").concat(p));l.warn("Failed to load tools for server ".concat(e,":"),t),d("Failed to load tools: ".concat(t instanceof Error?t.message:"Unknown error")),r([])}finally{e===p&&s(!1)}},[e,c,t.length,p]),b=(0,n.useCallback)(()=>{if(!e)return;v.current&&(clearTimeout(v.current),v.current=null),x(!0);let t=Math.min(1e3*Math.pow(2,f),1e4);return l.debug("Retrying tool load for ".concat(e," in ").concat(t,"ms (attempt ").concat(f+1,")")),v.current=setTimeout(()=>{m(e=>e+1),w(!0),x(!1)},t),()=>{v.current&&clearTimeout(v.current)}},[e,f,w]),y=(0,n.useCallback)(async(t,r,n)=>{if(!e)return{success:!1,output:"",error:"No server selected"};l.debug("Testing tool ".concat(t," on server ").concat(e," with params:"),r);try{let a=await o.S.callTool(e,t,r,n);if(a.error)return l.warn("Error calling tool ".concat(t,":"),a.error),{success:!1,output:"",error:a.error};return l.debug("Tool ".concat(t," executed successfully:"),a),{success:!0,output:JSON.stringify(a,null,2)}}catch(e){return l.error("Exception calling tool ".concat(t,":"),e),{success:!1,output:"",error:e instanceof Error?e.message:"Unknown error occurred"}}},[e]);return(0,n.useEffect)(()=>{l.debug("Server name changed to: ".concat(e||"null")),v.current&&(clearTimeout(v.current),v.current=null),m(0),x(!1),e?(h(e),w()):(l.debug("Clearing tools as no server is selected"),r([]),d(null),h(null))},[e,w]),{tools:t,isLoading:a||g,error:i,loadTools:w,retryLoadTools:b,isRetrying:g,retryCount:f,testTool:y}}},98774:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>rF});var n=r(95155),o=r(12115),l=r(20063),a=r(33567),s=r(94049),i=r(25635),d=r(91871),c=r(5421),u=r(41983),p=r(78470),h=r(50430),f=r(22003),m=r(2778),g=r(52363),x=r(65036),v=r(50001),w=r(9562),b=r(75912),y=r(14287),j=r(86946),A=r(72167),C=r(12313),S=r(48116),k=r(2300),T=r(99944),I=r(9957),M=r(27845),N=r(36314),F=r(86973),P=r(21067),E=r(87021),R=r(22539),D=r(74879),W=r(90057),z=r(17897),L=r(93764);function B(e){var t;return null==(t=e.data)?void 0:t.edgeType}function O(e){return"mcp"===B(e)}function U(e){return"resource"===B(e)}var H=r(18466),G=r(61033);function V(e){return{id:e.id,label:e.data.label,type:e.type||e.data.type}}var K=r(77758);r(18037);var $=r(56350),_=r(77842),q=r(55930),J=r(59323),X=r(20195),Y=r(33420);let Z=(0,E.h)("components/flow/FlowBuilder/NodePalette.tsx"),Q="NodePalette",ee=(0,S.Ay)(k.A)(e=>{let{theme:t}=e;return{padding:t.spacing(2),width:"200px",height:"80vh",display:"flex",flexDirection:"column",gap:t.spacing(2)}}),et=(0,S.Ay)(k.A,{shouldForwardProp:e=>"nodeType"!==e})(e=>{let{theme:t,nodeType:r}=e;return{padding:t.spacing(1.5),minWidth:"180px",borderRadius:"8px",backgroundColor:t.palette.background.paper,border:"2px solid ".concat("process"===r?t.palette.secondary.main:"finish"===r?t.palette.success.main:"subflow"===r?t.palette.warning.main:"resource"===r?Y.nH:"signal"===r?Y.vp:t.palette.info.main),boxShadow:t.shadows[2],transition:"all 0.2s ease",cursor:"grab","&:hover":{boxShadow:"0 0 0 1px ".concat("process"===r?t.palette.secondary.main:"finish"===r?t.palette.success.main:"subflow"===r?t.palette.warning.main:"resource"===r?Y.nH:"signal"===r?Y.vp:t.palette.info.main,", 0 3px 10px rgba(0,0,0,0.1)")},"&:active":{cursor:"grabbing"}}}),er=(0,S.Ay)(s.default,{shouldForwardProp:e=>"nodeType"!==e})(e=>{let{theme:t,nodeType:r}=e;return{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid ".concat("process"===r?t.palette.secondary.light:"finish"===r?t.palette.success.light:"subflow"===r?t.palette.warning.light:"resource"===r?"#4DB6AC":"signal"===r?"#B39DDB":t.palette.info.light),marginBottom:t.spacing(1),paddingBottom:t.spacing(.5)}}),en=(0,S.Ay)(s.default)({display:"flex",alignItems:"center",gap:"8px"}),eo=[{type:"process",label:"Process Node",description:"Let a LLM do your work"},{type:"finish",label:"Finish Node",description:"End your flow here"},{type:"mcp",label:"MCP Node",description:"Add functionality"},{type:"subflow",label:"Subflow Node",description:"Run another flow as a step"},{type:"resource",label:"Resource Node",description:"A data artifact steps read or write"},{type:"signal",label:"Signal Node",description:"Emit a named signal to trigger another flow"}],el=()=>{Z.debug("".concat(Q,": Entering component")),(0,a.A)();let e=(0,o.useCallback)(e=>{Z.debug("".concat(Q,".onNodeDoubleClick: Double-clicked on ").concat(e," node"));let t=new CustomEvent("addNodeFromPalette",{detail:{nodeType:e,position:{x:250,y:150}}});document.dispatchEvent(t),Z.info("".concat(Q,".onNodeDoubleClick: Dispatched addNodeFromPalette event for ").concat(e," node"))},[]);return Z.debug("".concat(Q,": Rendering component")),(0,n.jsxs)(ee,{elevation:2,children:[(0,n.jsx)(i.default,{variant:"h6",gutterBottom:!0,children:"Node Types"}),(0,n.jsx)(s.default,{display:"flex",flexDirection:"column",gap:2,children:eo.map(t=>(0,n.jsxs)(et,{nodeType:t.type,elevation:1,draggable:!0,onDragStart:e=>((e,t)=>{Z.debug("".concat(Q,".onDragStart: Entering method with nodeType=").concat(t)),e.dataTransfer.setData("application/reactflow",t),e.dataTransfer.effectAllowed="move";let r=document.createElement("div");r.innerHTML='<div style="padding: 10px; background: white; border: 1px solid #ccc; border-radius: 4px;">'.concat(t," Node</div>"),document.body.appendChild(r),Z.debug("".concat(Q,".onDragStart: Created drag preview element"));try{e.dataTransfer.setDragImage(r,75,25),Z.debug("".concat(Q,".onDragStart: Set drag image with offset (75, 25)"))}catch(e){Z.error("".concat(Q,".onDragStart: Error setting drag image:"),e)}setTimeout(()=>{document.body.removeChild(r),Z.debug("".concat(Q,".onDragStart: Removed drag preview element"))},0),Z.debug("".concat(Q,".onDragStart: Drag operation initialized"))})(e,t.type),onDragEnd:e=>{var r;return r=t.type,void Z.debug("".concat(Q,".onDragEnd: Drag operation ended for nodeType=").concat(r))},onDoubleClick:()=>e(t.type),children:[(0,n.jsx)(er,{nodeType:t.type,children:(0,n.jsxs)(en,{children:[(e=>{switch(e){case"process":default:return(0,n.jsx)($.A,{color:"secondary"});case"finish":return(0,n.jsx)(_.A,{color:"success"});case"mcp":return(0,n.jsx)($.A,{color:"info"});case"subflow":return(0,n.jsx)(q.A,{color:"warning"});case"resource":return(0,n.jsx)(J.A,{sx:{color:Y.nH}});case"signal":return(0,n.jsx)(X.A,{sx:{color:Y.vp}})}})(t.type),(0,n.jsx)(i.default,{variant:"subtitle2",fontWeight:"bold",children:t.label})]})}),(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",children:t.description})]},t.type))})]})};var ea=r(28548),es=r(4474),ei=r(41602),ed=r(49501),ec=r(17681),eu=r(73707),ep=r(23820),eh=r(5155),ef=r(60691),em=r(76808),eg=r(36741),ex=r(19875);let ev=/\$\{var:([^}]+)\}/g,ew=/^[A-Za-z_][\w-]*$/;function eb(e){return"string"==typeof e&&ew.test(e)}let ey=/\$\{kv:([^}]+)\}/g,ej=["global","flow","folder"];function eA(e){let t=(null!=e?e:"").trim(),r=t.indexOf("/");if(r>0){let e=t.slice(0,r);if(ej.includes(e))return{scope:e,key:t.slice(r+1).trim()}}return{scope:"folder",key:t}}function eC(e,t){let r=(null!=t?t:"").trim();return r?"folder"===e?r:"".concat(e,"/").concat(r):""}let eS=/^[A-Za-z_][\w-]*$/;function ek(e){return"string"==typeof e&&eS.test(e)}function eT(e){var t,r,n;return null!=(n=null!=(r=null==(t=e.data)?void 0:t.type)?r:e.type)?n:"unknown"}function eI(e){var t;return(null==(t=e.data)?void 0:t.label)||e.id}function eM(e){var t;return(null==(t=e.data)?void 0:t.edgeType)==="mcp"}function eN(e){var t;return(null==(t=e.data)?void 0:t.edgeType)==="resource"}function eF(e){return eM(e)||eN(e)}function eP(e,t,r){let n=new Map(t.map(e=>[e.id,e])),o=new Set;for(let t of r){var l,a;if(!eM(t))continue;let r=null;if(t.source===e?r=t.target:t.target===e&&(r=t.source),!r)continue;let s=n.get(r);if(!s||"mcp"!==eT(s))continue;let i=null==(a=s.data)||null==(l=a.properties)?void 0:l.boundServer;"string"==typeof i&&i&&o.add(i)}return o}function eE(e,t,r){let n=new Map(t.map(e=>[e.id,e])),o=[],l=new Set;for(let t of r){var a;if(eF(t))continue;let r=null;t.source===e?r=t.target:t.target===e&&(null==(a=t.data)?void 0:a.bidirectional)&&(r=t.source),!r||l.has(r)||(l.add(r),o.push(r))}let s=o.map(e=>n.get(e)).filter(e=>!!e).map(e=>{var t;return{id:e.id,label:null==(t=e.data)?void 0:t.label,type:eT(e)}});return new Set((0,H.E9)(s).values())}function eR(e){var t,r,n,o,l,a,s,i,d,c,u,p,h,f,m,g,x,v,w,b,y,j,A,C;let S=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},k=[],T=Array.isArray(null==e?void 0:e.nodes)?e.nodes:[],I=Array.isArray(null==e?void 0:e.edges)?e.edges:[],M=(e,t,r,n)=>k.push({severity:e,code:t,message:r,nodeId:null==n?void 0:n.id,nodeLabel:n?eI(n):void 0}),N=new Map((null!=(t=S.models)?t:[]).map(e=>[e.id,e])),F=new Map((null!=(r=S.servers)?r:[]).map(e=>[e.name,e])),P=!!S.models,E=!!S.servers,R=T.filter(e=>"start"===eT(e)),D=T.filter(e=>"finish"===eT(e)),W=T.filter(e=>"process"===eT(e)),z=T.filter(e=>"mcp"===eT(e));if(0===R.length)M("error","no-start-node","The flow has no Start node, so it has no entry point.");else if(R.length>1)for(let e of R.slice(1))M("error","multiple-start-nodes","The flow has more than one Start node; only one is allowed.",e);for(let e of(0===D.length&&M("warning","no-finish-node","The flow has no Finish node; it will run but never reaches a defined end."),W)){let t=null!=(o=null==(n=e.data)?void 0:n.properties)?o:{},r=t.boundModel;if(r){if(P&&!N.has(r)){let r="string"==typeof t.modelName&&t.modelName?' (was "'.concat(t.modelName,'")'):"";M("error","process-model-missing",'Process node "'.concat(eI(e),'" is bound to a model that no longer exists').concat(r,"."),e)}}else M("error","process-missing-model",'Process node "'.concat(eI(e),'" has no model bound.'),e)}for(let e of z){let t=(null!=(a=null==(l=e.data)?void 0:l.properties)?a:{}).boundServer;if(t){if(E&&!F.has(t))M("warning","mcp-server-missing",'MCP node "'.concat(eI(e),'" is bound to server "').concat(t,"\", which isn't in your current MCP server list. It may be offline (e.g. not connected), renamed, or removed — if it was renamed or removed, rebind this node."),e);else if(E){let r=F.get(t);if(r.status&&"connected"!==r.status){let n="disabled"===r.status?"disabled":"not connected (".concat(r.status,")");M("warning","mcp-server-disconnected",'MCP node "'.concat(eI(e),'" is bound to server "').concat(t,'", which is currently ').concat(n,". It will provide tools again once it reconnects."),e)}}}else M("warning","mcp-missing-server",'MCP node "'.concat(eI(e),'" is not bound to a server.'),e);I.some(t=>eM(t)&&(t.source===e.id||t.target===e.id))||M("warning","mcp-node-unconnected",'MCP node "'.concat(eI(e),'" is not connected to any Process node.'),e)}for(let e of T.filter(e=>"resource"===eT(e))){let t=null!=(i=null==(s=e.data)?void 0:s.properties)?i:{},r="run"===t.scope?"run":"mcp",n="string"==typeof t.boundServer?t.boundServer:"",o="string"==typeof t.uri?t.uri:"",l="string"==typeof t.runName?t.runName.trim():"";"mcp"!==r||n&&o||M("warning","resource-missing-binding",'Resource node "'.concat(eI(e),'" has no ').concat(n?"resource URI":"server"," bound; connected steps will receive nothing."),e),"run"!==r||l||M("warning","resource-missing-binding",'Resource node "'.concat(eI(e),'" is a run artifact with no name; give it a name so steps can produce/consume it.'),e),"run"===r&&l&&!eb(l)&&M("warning","resource-run-name",'Resource node "'.concat(eI(e),'" is named "').concat(l,'", which is not a valid artifact name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with ${res:...}.'),e),"mcp"===r&&n&&E&&!F.has(n)&&M("warning","resource-server-missing",'Resource node "'.concat(eI(e),'" is bound to server "').concat(n,"\", which isn't in your current MCP server list."),e);let a=I.filter(t=>eN(t)&&(t.source===e.id||t.target===e.id));0===a.length&&M("warning","resource-node-unconnected",'Resource node "'.concat(eI(e),'" is not connected to any Process node.'),e);let d=a.filter(t=>t.target===e.id);"mcp"===r&&d.length>0&&M("error","resource-produce-static",'Resource node "'.concat(eI(e),'" is a static MCP resource, but a step writes INTO it. Only run artifacts (scope "run") can be produced by a step — flip the edge or make this a run artifact.'),e),"run"===r&&d.length>1&&M("warning","resource-multiple-producers",'Resource node "'.concat(eI(e),'" is produced by ').concat(d.length," steps; the last writer wins. Consider one producer per artifact."),e),"run"===r&&0===d.length&&a.length>0&&M("warning","resource-consumed-never-produced",'Resource node "'.concat(eI(e),'" is consumed but no step in this flow produces it; it resolves to nothing unless an earlier run captured it.'),e)}for(let e of T.filter(e=>"signal"===eT(e))){let t=null!=(c=null==(d=e.data)?void 0:d.properties)?c:{};("string"==typeof t.topic?t.topic.trim():"")||M("warning","signal-missing-topic",'Signal node "'.concat(eI(e),'" has no topic; it emits nothing. Give it a topic that a flow-event trigger can listen for.'),e)}if(R.length>0){let e=function(e){let t=new Map,r=(e,r)=>{t.has(e)||t.set(e,[]),t.get(e).push(r)};for(let t of e){var n;!eF(t)&&(r(t.source,t.target),(null==(n=t.data)?void 0:n.bidirectional)&&r(t.target,t.source))}return t}(I);for(let t of R)(null==(u=e.get(t.id))?void 0:u.length)||M("error","start-no-outgoing","The Start node is not connected to anything; the flow cannot run.",t);let t=function(e,t){let r=new Set(e),n=[...e];for(;n.length;){var o;let e=n.shift();for(let l of null!=(o=t.get(e))?o:[])r.has(l)||(r.add(l),n.push(l))}return r}(R.map(e=>e.id),e);for(let e of[...W,...D])t.has(e.id)||M("warning","unreachable-node","".concat("finish"===eT(e)?"Finish":"Process",' node "').concat(eI(e),'" is not reachable from the Start node.'),e)}for(let e of T.filter(e=>"subflow"===eT(e))){let t=I.filter(t=>{var r;return!eF(t)&&(t.source===e.id||t.target===e.id&&!!(null==(r=t.data)?void 0:r.bidirectional))});t.length>1&&M("error","subflow-multiple-outgoing",'Subflow node "'.concat(eI(e),'" has ').concat(t.length," outgoing connections; a subflow can only have one (either A > B > C or a bidirectional A <> B)."),e);let r=null!=(h=null==(p=e.data)?void 0:p.properties)?h:{},n="string"==typeof r.subflowId&&r.subflowId?r.subflowId:void 0,o=Array.isArray(r.parallelSubflowIds)?r.parallelSubflowIds.filter(e=>"string"==typeof e&&!!e):[];n&&o.length>0&&M("error","subflow-both-targets",'Subflow node "'.concat(eI(e),'" sets both a single "subflowId" and "parallelSubflowIds"; use one or the other.'),e);let l=!0===r.mapOverList;l&&o.length>0&&M("error","subflow-map-and-parallel",'Subflow node "'.concat(eI(e),'" combines "mapOverList" with "parallelSubflowIds"; map-over-list runs a single child once per item and cannot be combined with parallel fan-out.'),e),l&&!n&&0===o.length&&M("error","subflow-map-no-child",'Subflow node "'.concat(eI(e),'" has "mapOverList" but no child flow ("subflowId"); select a flow to run once per item.'),e);let a=Array.isArray(r.spawnBriefs)?r.spawnBriefs.filter(e=>"string"==typeof e&&""!==e.trim()):[];a.length>0&&!n&&M("error","subflow-spawn-no-child",'Subflow node "'.concat(eI(e),'" has spawn briefs but no sub-agent flow ("subflowId"); select the flow to spawn once per brief.'),e),a.length>0&&o.length>0&&M("error","subflow-spawn-and-parallel",'Subflow node "'.concat(eI(e),'" combines "spawnBriefs" with "parallelSubflowIds"; spawn briefs run one sub-agent per brief and cannot be combined with a multi-flow fan-out list.'),e),a.length>0&&l&&M("error","subflow-spawn-and-map",'Subflow node "'.concat(eI(e),'" combines "spawnBriefs" with "mapOverList"; use one lane source or the other.'),e);let s="string"==typeof r.parallelSubflowIdsVar?r.parallelSubflowIdsVar.trim():"";if(s&&(eb(s)||M("warning","subflow-parallel-var-name",'Subflow node "'.concat(eI(e),'" reads dynamic fan-out targets from "').concat(s,'", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to capture with ${var:...}.'),e),l&&M("error","subflow-map-and-parallel-var",'Subflow node "'.concat(eI(e),'" combines "mapOverList" with dynamic fan-out ("parallelSubflowIdsVar"); map-over-list runs a single child once per item and cannot be combined with fan-out.'),e),T.some(e=>{var t,r;let n=null==(r=e.data)||null==(t=r.properties)?void 0:t.captureVariable;return"string"==typeof n&&n.trim()===s})||M("warning","subflow-parallel-var-uncaptured",'Subflow node "'.concat(eI(e),'" reads dynamic fan-out targets from variable "').concat(s,'", but no node captures it (captureVariable). It may be seeded by the caller; otherwise it resolves to no targets and the node falls back to its static parallel list.'),e)),!0===r.allowCallerFanout&&l&&M("error","subflow-map-and-caller-fanout",'Subflow node "'.concat(eI(e),'" combines "mapOverList" with agentic fan-out ("allowCallerFanout"); map-over-list runs a single child once per item and cannot be combined with fan-out.'),e),o.length>0||a.length>0){let t=r.concurrencyLimit;"number"==typeof t&&t<1&&M("warning","subflow-concurrency-limit",'Subflow node "'.concat(eI(e),'" has a concurrencyLimit of ').concat(t,"; it must be at least 1 (the runtime default will be used)."),e)}}{let e=new Map(T.map(e=>[e.id,e])),t=new Set;for(let r of I){if(eF(r))continue;let n=null==(f=r.data)?void 0:f.condition;if(!n||"object"!=typeof n)continue;let o=e.get(r.source),l=o?eT(o):"unknown";if("process"!==l){M("error","edge-condition-non-process","An edge leaving ".concat("unknown"===l?"an unknown":"the ".concat(l),' node "').concat(o?eI(o):r.source,'" has a routing condition, but only process nodes can route on a condition.'),null!=o?o:void 0);continue}t.add(r.source),(0,ex.C)(n.kind)?"always"===n.kind||("string"!=typeof n.value||0===n.value.length?M("warning","edge-condition-value",'Process node "'.concat(eI(o),'" has an outgoing edge condition with no "value"; it will never match.'),o):"regex"!==n.kind||(0,ex.wM)(n.value)||M("warning","edge-condition-regex",'Process node "'.concat(eI(o),'" has an outgoing edge with a regex condition that does not compile; it will never match.'),o)):M("warning","edge-condition-kind",'Process node "'.concat(eI(o),'" has an outgoing edge whose condition kind "').concat(String(n.kind),'" is unknown; it will never match.'),o)}for(let r of t){let t=e.get(r);t&&(I.some(e=>{var t,n;return!eF(e)&&(e.source===r?!(null==(n=e.data)?void 0:n.condition)||"always"===e.data.condition.kind&&!e.data.condition.negate:e.target===r&&null!=(t=e.data)&&!!t.bidirectional)})||M("warning","edge-condition-no-fallback",'Process node "'.concat(eI(t),'" has conditioned outgoing edges but no bare fallback edge; if no condition matches, the flow ends here.'),t))}}{let e=new Set;for(let t of T){let r=null==(g=t.data)||null==(m=g.properties)?void 0:m.captureVariable;if("string"==typeof r&&r.trim()){let n=r.trim();e.add(n),eb(n)||M("warning","capture-var-name","".concat("subflow"===eT(t)?"Subflow":"Process",' node "').concat(eI(t),'" captures into "').concat(n,'", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with ${var:...}.'),t)}}let t=["promptTemplate","isolatedPrompt"],r=new Set;for(let n of T){let o=null!=(v=null==(x=n.data)?void 0:x.properties)?v:{};for(let l of t){let t=o[l];if("string"==typeof t&&t)for(let o of function(e){let t;if("string"!=typeof e||0===e.length)return[];let r=new Set;for(ev.lastIndex=0;null!==(t=ev.exec(e));){let e=t[1].trim();e&&r.add(e)}return[...r]}(t)){if(e.has(o))continue;let t="".concat(n.id,":").concat(o);r.has(t)||(r.add(t),M("warning","var-ref-uncaptured","".concat(eI(n)," references ${var:").concat(o,'} but no step in this flow captures "').concat(o,'" (via captureVariable). It resolves to empty unless supplied as a run input — check for a typo or a step ordered after this one.'),n))}}}}{for(let e of T){let t=null==(b=e.data)||null==(w=b.properties)?void 0:w.captureKv;if("string"==typeof t&&t.trim()){let{key:r}=eA(t.trim());ek(r)||M("warning","capture-kv-name","".concat("subflow"===eT(e)?"Subflow":"Process",' node "').concat(eI(e),'" captures into kv "').concat(t.trim(),'", whose key is not a valid name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with ${kv:...}.'),e)}}let e=["promptTemplate","isolatedPrompt"],t=new Set;for(let r of T){let n=null!=(j=null==(y=r.data)?void 0:y.properties)?j:{};for(let o of e){let e=n[o];if("string"==typeof e&&e)for(let n of function(e){let t;if("string"!=typeof e||0===e.length)return[];let r=new Set;for(ey.lastIndex=0;null!==(t=ey.exec(e));){let e=t[1].trim();e&&r.add(e)}return[...r]}(e)){let{key:e}=eA(n);if(ek(e))continue;let o="".concat(r.id,":").concat(n);t.has(o)||(t.add(o),M("warning","kv-ref-name","".concat(eI(r)," references ${kv:").concat(n,"}, whose key is not a valid name (letters, digits, _ and - only, not starting with a digit); it resolves to empty."),r))}}}}for(let e of W){let t=null==(C=e.data)||null==(A=C.properties)?void 0:A.promptTemplate;if("string"!=typeof t||!t)continue;let r=eP(e.id,T,I),n=null,o=new Set,l=new Set;for(let a of(0,G.A$)(t)){if("handoff"===a.server){let t="handoff:".concat(a.name);if(l.has(t))continue;l.add(t),o.add(a.name),n||(n=eE(e.id,T,I)),n.has(a.name)||M("warning","handoff-pill-obsolete",'Process node "'.concat(eI(e),'" references handoff tool "').concat(a.name,'", which no longer exists (the target node was removed, or renamed so the tool name changed). Update or remove the pill.'),e);continue}let t="".concat(a.kind,":").concat(a.server,":").concat(a.name);!l.has(t)&&(l.add(t),r.has(a.server)?"tool"===a.kind&&S.serverTools&&S.serverTools[a.server]&&!S.serverTools[a.server].includes(a.name)&&M("warning","tool-unavailable",'Process node "'.concat(eI(e),'" references tool "').concat(a.name,'" which server "').concat(a.server,'" no longer provides.'),e):M("error","tool-pill-disconnected",'Process node "'.concat(eI(e),'" references ').concat(a.kind,' "').concat(a.name,'" from server "').concat(a.server,'", but it is not connected to that server (the MCP node was removed or the server was renamed).'),e))}if(o.size>0)for(let t of null!=n?n:eE(e.id,T,I))o.has(t)||M("warning","handoff-target-unreferenced",'Process node "'.concat(eI(e),'" can hand off to "').concat(t,'" but its prompt never references ${tool:handoff__').concat(t,"}, so the model may never route there."),e)}if(S.serverTools)for(let e of W)for(let t of eP(e.id,T,I)){let r=S.serverTools[t];Array.isArray(r)&&0===r.length&&M("warning","mcp-server-no-tools",'Process node "'.concat(eI(e),'" is connected to MCP server "').concat(t,'", which currently exposes 0 tools. The connection has no effect until the server provides tools.'),e)}let L=k.filter(e=>"error"===e.severity).length,B=k.length-L;return{issues:k,errorCount:L,warningCount:B,isRunnable:0===L}}var eD=r(43076);let eW=(0,E.h)("components/flow/FlowBuilder/FlowValidationButton"),ez=e=>{var t,r;let{nodes:l,edges:a}=e,[c,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(!1),[f,v]=(0,o.useState)(null),w=(0,o.useCallback)(async()=>{h(!0);try{var e,t,r,n,o;let s=null!=(e=await eD.N.tryLoadModels())?e:void 0,i=await z.S.loadServerConfigs(),d=Array.isArray(i)?i.map(e=>({name:e.name,status:e.disabled?"disabled":void 0})):void 0,c={};try{let e=new Map((Array.isArray(i)?i:[]).map(e=>[e.name,!!e.disabled])),a=new Set;for(let e of l){let l=null!=(o=null==e||null==(t=e.data)?void 0:t.type)?o:null==e?void 0:e.type,s=null==e||null==(n=e.data)||null==(r=n.properties)?void 0:r.boundServer;"mcp"===l&&"string"==typeof s&&s&&a.add(s)}await Promise.all([...a].map(async t=>{if(e.get(t))return;let r=await z.S.listServerTools(t);!r.error&&Array.isArray(r.tools)&&(c[t]=r.tools.map(e=>null==e?void 0:e.name).filter(e=>"string"==typeof e))}))}catch(e){eW.debug("Could not gather MCP tool lists for the flow check",e)}let u=eR({nodes:l,edges:a},{models:s,servers:d,serverTools:c});v(u.issues)}catch(e){eW.warn("Flow validation failed to run",e),v([])}finally{h(!1)}},[l,a]),y=(0,o.useCallback)(()=>{u(!0),v(null),w()},[w]),j=(0,o.useCallback)(e=>{e&&(u(!1),document.dispatchEvent(new CustomEvent("editNode",{detail:{nodeId:e}})))},[]),A=null!=(t=null==f?void 0:f.filter(e=>"error"===e.severity).length)?t:0,C=(null!=(r=null==f?void 0:f.length)?r:0)-A;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.A,{variant:"outlined",color:"primary",onClick:y,startIcon:(0,n.jsx)(eh.A,{}),sx:{textTransform:"none"},children:"Check Flow"}),(0,n.jsxs)(m.A,{open:c,onClose:()=>u(!1),maxWidth:"sm",fullWidth:!0,children:[(0,n.jsxs)(g.A,{component:"div",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,n.jsx)("span",{children:"Flow Check"}),f&&(0,n.jsxs)(s.default,{sx:{display:"flex",gap:1,ml:1},children:[A>0&&(0,n.jsx)(ea.A,{size:"small",color:"error",label:"".concat(A," error").concat(1===A?"":"s")}),C>0&&(0,n.jsx)(ea.A,{size:"small",color:"warning",label:"".concat(C," warning").concat(1===C?"":"s")})]})]}),(0,n.jsx)(x.A,{dividers:!0,children:p?(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:2,py:3,justifyContent:"center"},children:[(0,n.jsx)(es.default,{size:22}),(0,n.jsx)(i.default,{color:"text.secondary",children:"Checking flow…"})]}):f&&0===f.length?(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1.5,py:3,justifyContent:"center"},children:[(0,n.jsx)(eg.A,{color:"success"}),(0,n.jsx)(i.default,{children:"No problems found — this flow looks runnable."})]}):(0,n.jsx)(ei.A,{dense:!0,disablePadding:!0,children:(null!=f?f:[]).map((e,t)=>{var r;let o=!!e.nodeId,l=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ed.A,{sx:{minWidth:36},children:"error"===e.severity?(0,n.jsx)(ef.A,{color:"error",fontSize:"small"}):(0,n.jsx)(em.A,{color:"warning",fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:e.message,secondary:o?"Node: ".concat(null!=(r=e.nodeLabel)?r:e.nodeId," — click to open"):void 0})]});return o?(0,n.jsx)(eu.A,{onClick:()=>j(e.nodeId),alignItems:"flex-start",children:l},t):(0,n.jsx)(ep.Ay,{alignItems:"flex-start",children:l},t)})})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:w,disabled:p,children:"Re-check"}),(0,n.jsx)(d.A,{onClick:()=>u(!1),variant:"contained",children:"Close"})]})]})]})};var eL=r(33077),eB=r(57813),eO=r(26466),eU=r(77073);function eH(e){let{currentLabel:t,nameIsCustom:r,defaultLabel:n,previousAutoLabel:o,nextAutoLabel:l}=e;return!0===r?t&&t.length>0?t:l:!t||0===t.length||t===n||void 0!==o&&o.length>0&&t===o?l:t}let eG=(0,E.h)("components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useModelManagement.ts");var eV=r(9898);let eK=(0,E.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useServerConnection");function e$(e,t){let r=e.replace(/\s+/g," ").trim();if(r.length<=t)return r;let n=r.slice(0,t),o=n.lastIndexOf(" ");return"".concat((o>.6*t?n.slice(0,o):n).trimEnd(),"…")}let e_=(0,E.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useHandoffTools"),eq=e=>{let{nodeData:t,setNodeData:r}=e;return t?(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pr:2},children:[(0,n.jsx)(i.default,{variant:"h6",gutterBottom:!0,children:"Node Configuration"}),(0,n.jsx)(w.A,{fullWidth:!0,label:"Node Label",value:t.label||"",onChange:e=>r(t=>({...t,label:e.target.value,properties:{...null==t?void 0:t.properties,nameIsCustom:!0}})),margin:"normal"}),(0,n.jsx)(w.A,{fullWidth:!0,label:"Description",value:t.description||"",onChange:e=>r({...t,description:e.target.value}),margin:"normal",multiline:!0,rows:2,helperText:"This description will be displayed on the node"})]}):null};var eJ=r(18369),eX=r(12857),eY=r(99162),eZ=r(61267),eQ=r(68503);let e0=e=>{let{isLoadingModels:t,loadError:r,models:o,selectedModelId:l,handleModelSelect:a,isModelBound:c,handleUnbindModel:u}=e,p=(0,eQ.E)("models",o),h=e=>({key:e.id,content:(e=>(0,n.jsx)(eZ.A,{model:e,selectable:!0,selected:l===e.id,onSelect:a}))(e)}),f=p.items.map(h),m=p.groups?p.groups.map(e=>({...e,items:e.items.map(h)})):null;return(0,n.jsxs)(s.default,{sx:{mt:4},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Bind to Model"}),(0,n.jsx)(s.default,{role:"radiogroup","aria-label":"Bind to model",children:(0,n.jsx)(eY.A,{isLoading:t,error:r,loadingMessage:"Loading models...",emptyMessage:"No models available. Add some in the Model Manager.",searchable:!0,searchPlaceholder:"Search models…",searchTerm:p.searchTerm,onSearchChange:p.setSearchTerm,columns:{xs:12,sm:6},items:f,groups:m,collapsedKeys:p.collapsedKeys,onToggleGroup:p.toggleGroup})}),!t&&!r&&o.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eJ.A,{children:l?"This node will use the selected model for processing.":"Select a model to bind this node to."}),c&&(0,n.jsx)(s.default,{sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:(0,n.jsx)(d.A,{startIcon:(0,n.jsx)(eX.A,{}),onClick:u,color:"primary",variant:"outlined",size:"small",children:"Unbind Model"})})]})]})};var e1=r(66177),e2=r(56422),e5=r(29767),e6=r(84578),e3=r(76530),e4=r(25541),e8=r(51611),e7=r(89218),e9=r(96362),te=r(40962);let tt=(0,E.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerTools"),tr=e=>{var t,r,l;let{isLoadingServers:a,connectedMcpNodes:c,availableServers:h,onConnectMcpServer:f,serverToolsMap:m,serverStatuses:g,isLoadingTools:x,handleSelectToolServer:v,handleInsertToolBinding:b,selectedToolServerNodeId:y,selectedNodeId:A,isLoadingSelectedServerTools:C,promptBuilderRef:S,handleRetryServer:T,handleRestartServer:I}=e,M=null!=(l=null!=y?y:null==(t=c[0])?void 0:t.nodeId)?l:null,[N,F]=(0,o.useState)({}),[P,E]=(0,o.useState)(!1),R=(null!=h?h:[]).filter(e=>!c.some(t=>t.serverName===e.name)),D=!!f&&R.length>0,W=(0,eQ.E)("mcp",R),z=e=>({key:e.name,content:(e=>(0,n.jsx)(te.A,{name:e.name,status:e.status||"disconnected",path:e.rootPath||"",enabled:!e.disabled,transport:e.transport||"stdio",pickerMode:!0,onClick:()=>{var t;return t=e.name,void(E(!1),null==f||f(t))}}))(e)}),L=W.items.map(z),B=W.groups?W.groups.map(e=>({...e,items:e.items.map(z)})):null,O=(0,n.jsx)(e9.A,{open:P,onClose:()=>E(!1),title:"Connect an MCP server",description:"Pick a server to add to this flow and wire to this Process node.",emptyMessage:"No more servers to connect.",searchable:!0,searchPlaceholder:"Search servers…",searchTerm:W.searchTerm,onSearchChange:W.setSearchTerm,columns:{xs:12,sm:6},items:L,groups:B,collapsedKeys:W.collapsedKeys,onToggleGroup:W.toggleGroup}),[U,H]=(0,o.useState)(""),G=e=>{try{let t=c.find(t=>t.nodeId===e);if(!t)return tt.warn("Could not find connected MCP node with ID ".concat(e)),[];let r=t.enabledTools||[];return tt.debug("Enabled tools for node ".concat(e,": ").concat(JSON.stringify(r))),Array.isArray(r)?r:[]}catch(t){return tt.error("Error getting enabled tools for node ".concat(e,":"),t),[]}},V=(e,t,r)=>{try{if(!r||!Array.isArray(r))return tt.warn("Tools array is not available or not an array for server ".concat(t)),[];let n=G(e),o=r;if(n.length>0?o=r.filter(e=>e&&e.name&&n.includes(e.name)):(tt.debug("No tools explicitly enabled for node ".concat(e,", showing none.")),o=[]),U.trim()){let e=U.toLowerCase().trim();o=o.filter(t=>t.name&&t.name.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)||t.inputSchema&&JSON.stringify(t.inputSchema).toLowerCase().includes(e))}return o}catch(n){return tt.error("Error filtering tools for node ".concat(e," (server ").concat(t,"):"),n),r||[]}},K=e=>{v(e)},$=async(e,t)=>{t.stopPropagation(),tt.debug("Retry button clicked for server: ".concat(e)),F(t=>({...t,[e]:!0}));try{T&&await T(e)}finally{setTimeout(()=>{F(t=>({...t,[e]:!1}))},500)}},_=async(e,t)=>{t.stopPropagation(),tt.debug("Restart button clicked for server: ".concat(e)),F(t=>({...t,[e]:!0}));try{I&&await I(e)}finally{setTimeout(()=>{F(t=>({...t,[e]:!1}))},500)}};(0,o.useEffect)(()=>{c.length>0&&!y&&v(c[0].nodeId)},[c,y,v]);let q=c.find(e=>e.nodeId===M),J=null==q?void 0:q.serverName;return(0,n.jsxs)(s.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Connected MCP Servers and Tools"}),a?(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,n.jsx)(es.default,{size:20}),(0,n.jsx)(i.default,{color:"text.secondary",children:"Loading connected MCP nodes..."})]}):0===c.length?(0,n.jsxs)(s.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,n.jsx)(i.default,{color:"text.secondary",align:"center",children:"No MCP nodes connected to this Process node."}),(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:D?"Pick a server below — the MCP node is added to the flow and wired up for you.":"Connect MCP nodes to this Process node using the side handles to access their tools."}),D&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",mt:2},children:(0,n.jsx)(d.A,{variant:"contained",size:"small",startIcon:(0,n.jsx)(j.A,{}),onClick:()=>E(!0),children:"Connect MCP Server"})}),O]}):(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",mb:2,borderBottom:1,borderColor:"divider"},children:[(0,n.jsx)(eB.A,{value:M||(null==(r=c[0])?void 0:r.nodeId)||"",onChange:(e,t)=>K(t),variant:"scrollable",scrollButtons:"auto",sx:{flexGrow:1},children:c.map(e=>{if(!e||!e.nodeId||!e.serverName)return tt.warn("Skipping invalid MCP node in tabs:",e),null;let t=e.serverName,r=e.nodeId,o=e.status;N[t],x[t];let l=m[t]||[],a=G(r);return V(r,t,l).length,(0,n.jsx)(eO.A,{value:r,label:(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(i.default,{variant:"body2",sx:{color:"connected"===o?"success.main":"error"===o?"error.main":"text.secondary"},children:t}),a.length>0&&(0,n.jsx)(e1.A,{badgeContent:a.length,color:"primary",sx:{ml:1}})]}),sx:{textTransform:"none",minHeight:"48px",opacity:"connected"!==o?.7:1}},r)})}),D&&(0,n.jsx)(p.A,{title:"Connect another MCP server",children:(0,n.jsx)(u.A,{size:"small",onClick:()=>E(!0),sx:{ml:1},children:(0,n.jsx)(j.A,{fontSize:"small"})})}),O]}),q&&J&&(0,n.jsxs)(s.default,{sx:{display:"flex",justifyContent:"flex-end",mb:2},children:[(0,n.jsx)(p.A,{title:"Retry connection for ".concat(J),children:(0,n.jsx)("span",{children:(0,n.jsx)(u.A,{size:"small",onClick:e=>$(J,e),disabled:N[J]||x[J],children:N[J]?(0,n.jsx)(es.default,{size:16}):(0,n.jsx)(e3.A,{fontSize:"small"})})})}),"connected"===q.status&&I&&(0,n.jsx)(p.A,{title:"Restart server ".concat(J),children:(0,n.jsx)("span",{children:(0,n.jsx)(u.A,{size:"small",onClick:e=>_(J,e),disabled:N[J],sx:{ml:1},children:(0,n.jsx)(e4.A,{fontSize:"small"})})})})]}),(0,n.jsx)(w.A,{placeholder:"Search enabled tools...",variant:"outlined",size:"small",fullWidth:!0,value:U,onChange:e=>H(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,n.jsx)(e2.A,{position:"start",children:(0,n.jsx)(e8.A,{fontSize:"small"})})}}),(0,n.jsx)(k.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 140px)"},children:q&&J&&(()=>{let e=q.nodeId,t=q.serverName;if("connected"!==q.status)return(0,n.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,n.jsxs)(i.default,{color:"text.secondary",children:["Server '",t,"' is not connected. Connect to view tools."]})},e);if(x[t])return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,n.jsx)(es.default,{size:24})},e);let r=m[t]||[],o=V(e,t,r);if(0===o.length){let t=G(e).length;return(0,n.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,n.jsx)(i.default,{color:"text.secondary",children:U.trim()?'No enabled tools match "'.concat(U,'" for this node.'):0===t?"No tools are enabled for this node instance. Enable tools in the MCP Node properties.":"No tools available or enabled for this node instance."})},e)}return(0,n.jsx)(ei.A,{disablePadding:!0,children:o.map(r=>(0,n.jsxs)(e5.A,{variant:"outlined",onClick:()=>{e!==M?(tt.debug("Node tab not selected, selecting node first",{selectedNodeId:e,serverName:t,toolName:r.name}),K(e)):t&&r.name?(tt.debug("Inserting tool binding",{serverName:t,toolName:r.name}),b(t,r.name)):tt.warn("Cannot insert tool binding, server or tool name is undefined",{serverName:t,toolName:r.name})},sx:{mb:1,mx:1,mt:1,cursor:"pointer",position:"relative","&:hover":{boxShadow:1,bgcolor:"action.hover"}},children:[(0,n.jsx)(e6.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsxs)(i.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(e7.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),r.name]}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:r.description||"No description available"}),r.inputSchema&&(e=>e&&e.properties?(0,n.jsxs)(s.default,{sx:{mt:1},children:[(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",sx:{fontWeight:"medium"},children:"Parameters:"}),(0,n.jsx)(s.default,{sx:{pl:1,mt:.5},children:Object.entries(e.properties).map(t=>{var r;let[o,l]=t;return(0,n.jsxs)(s.default,{sx:{mb:.5},children:[(0,n.jsxs)(i.default,{variant:"caption",component:"span",sx:{fontWeight:"medium"},children:[o,(null==(r=e.required)?void 0:r.includes(o))&&(0,n.jsx)(i.default,{variant:"caption",component:"span",color:"error.main",children:" *"}),": "]}),(0,n.jsx)(i.default,{variant:"caption",component:"span",color:"text.secondary",children:l.description||l.type||"No description"})]},o)})})]}):null)(r.inputSchema)]})})}),(0,n.jsx)(p.A,{title:"Add ".concat(r.name," from ").concat(t," to prompt"),children:(0,n.jsx)(s.default,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0}})})]},r.name))},e)})()})]})]})},tn=(0,E.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerResources"),to=e=>{let{primary:t,secondary:r,chip:o,onClick:l}=e;return(0,n.jsx)(e5.A,{variant:"outlined",onClick:l,sx:{mb:1,mx:1,mt:1,cursor:"pointer","&:hover":{boxShadow:1,bgcolor:"action.hover"}},children:(0,n.jsx)(e6.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,n.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsxs)(i.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(J.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),t]}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,wordBreak:"break-all"},children:r})]}),o&&(0,n.jsx)(ea.A,{size:"small",label:o,sx:{ml:1,flexShrink:0}})]})})})},tl=e=>{var t;let{connectedMcpNodes:r,handleInsertResourceBinding:l,promptBuilderRef:a}=e,[d,c]=(0,o.useState)(null),[u,p]=(0,o.useState)([]),[h,m]=(0,o.useState)([]),[g,x]=(0,o.useState)(!1),[v,b]=(0,o.useState)(),[y,j]=(0,o.useState)(""),A=r.find(e=>e.nodeId===d),C=null==A?void 0:A.serverName;(0,o.useEffect)(()=>{r.length>0&&!d&&c(r[0].nodeId)},[r,d]);let S=(0,o.useCallback)(async e=>{x(!0),b(void 0);try{let t=await z.S.listServerResources(e);p(t.resources||[]),m(t.resourceTemplates||[]),b(t.error)}catch(t){tn.warn("Failed to load resources for ".concat(e),t),b(t instanceof Error?t.message:"Failed to load resources")}finally{x(!1)}},[]);(0,o.useEffect)(()=>{C?S(C):(p([]),m([]))},[C,S]);let T=e=>e.toLowerCase().includes(y.toLowerCase().trim()),I=y.trim()?u.filter(e=>T(e.name||"")||T(e.uri)||T(e.description||"")):u,M=y.trim()?h.filter(e=>T(e.name||"")||T(e.uriTemplate)||T(e.description||"")):h,N=e=>{C&&e&&l(C,e)};return(0,n.jsxs)(s.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Give this step access to…"}),(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",sx:{mb:1},children:"Pick a resource to insert. Its contents are read and placed into the prompt each time the step runs."}),0===r.length?(0,n.jsxs)(s.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,n.jsx)(i.default,{color:"text.secondary",align:"center",children:"No MCP nodes connected to this Process node."}),(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:"Connect MCP nodes using the side handles to access their resources."})]}):(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,n.jsx)(eB.A,{value:d||(null==(t=r[0])?void 0:t.nodeId)||"",onChange:(e,t)=>c(t),variant:"scrollable",scrollButtons:"auto",sx:{mb:2,borderBottom:1,borderColor:"divider"},children:r.map(e=>(0,n.jsx)(eO.A,{value:e.nodeId,label:(0,n.jsx)(i.default,{variant:"body2",sx:{color:"connected"===e.status?"success.main":"error"===e.status?"error.main":"text.secondary"},children:e.serverName}),sx:{textTransform:"none",minHeight:48,opacity:"connected"!==e.status?.7:1}},e.nodeId))}),(0,n.jsx)(w.A,{placeholder:"Search resources…",variant:"outlined",size:"small",fullWidth:!0,value:y,onChange:e=>j(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,n.jsx)(e2.A,{position:"start",children:(0,n.jsx)(e8.A,{fontSize:"small"})})}}),v&&(0,n.jsx)(f.A,{severity:"warning",sx:{mb:2},children:v}),(0,n.jsx)(k.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 140px)"},children:A&&"connected"!==A.status?(0,n.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,n.jsxs)(i.default,{color:"text.secondary",children:["Server '",C,"' is not connected. Connect to view resources."]})}):g?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,n.jsx)(es.default,{size:24})}):0===I.length&&0===M.length?(0,n.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,n.jsx)(i.default,{color:"text.secondary",children:y.trim()?'No resources match "'.concat(y,'".'):"This server does not publish any resources."})}):(0,n.jsxs)(ei.A,{disablePadding:!0,children:[I.map(e=>(0,n.jsx)(to,{primary:e.name||e.uri,secondary:e.description||e.uri,chip:e.mimeType,tooltip:"Add ".concat(e.name||e.uri," to prompt"),onClick:()=>N(e.uri)},e.uri)),M.map(e=>(0,n.jsx)(to,{primary:e.name||e.uriTemplate,secondary:e.description||e.uriTemplate,chip:"template",tooltip:"Add template ".concat(e.uriTemplate," to prompt (fill in variables, e.g. with ${global:VAR})"),onClick:()=>N(e.uriTemplate)},e.uriTemplate))]})})]})]})};var ta=r(91873);let ts=e=>{let{wiredResources:t,promptBuilderRef:r}=e;return 0===t.length?null:(0,n.jsxs)(s.default,{sx:{mb:3},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Wired resource nodes"}),(0,n.jsxs)(i.default,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:["Resource nodes connected to this step on the canvas. A ",(0,n.jsx)("strong",{children:"produce"})," node is written by the step's ",(0,n.jsx)("code",{children:"write_resource"})," tool; a ",(0,n.jsx)("strong",{children:"consume"})," node's contents are injected into the prompt when the step runs."]}),(0,n.jsx)(ei.A,{disablePadding:!0,children:t.map(e=>(0,n.jsx)(e5.A,{variant:"outlined",sx:{mb:1,mt:1},children:(0,n.jsx)(e6.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,n.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsxs)(i.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(J.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),e.label]}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,wordBreak:"break-all"},children:"run"===e.scope?"Temporary Data".concat(e.runName?' "'.concat(e.runName,'"'):" (no name set)"):"MCP resource".concat(e.uri?" ".concat(e.uri):"").concat(e.boundServer?" on ".concat(e.boundServer):"")})]}),(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",flexShrink:0,ml:1,gap:.5},children:["run"===e.scope&&e.runName&&(0,n.jsx)(p.A,{title:"Insert ${res:".concat(e.runName,"} into the prompt"),children:(0,n.jsx)(ea.A,{size:"small",icon:(0,n.jsx)(ta.A,{}),label:"${res:".concat(e.runName,"}"),onClick:()=>(e=>{e&&r.current&&r.current.insertText("${res:".concat(e,"}"))})(e.runName),clickable:!0,sx:{maxWidth:220}})}),(0,n.jsx)(ea.A,{size:"small",color:"produce"===e.role?"secondary":"default",label:e.role})]})]})})},"".concat(e.role,"-").concat(e.id)))})]})},ti=(0,E.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerTools/AgentTools"),td=e=>{let{handoffTools:t,isLoadingHandoffTools:r,handleInsertToolBinding:l,promptBuilderRef:a}=e,[d,c]=(0,o.useState)(""),u=t.filter(e=>{if(!d.trim())return!0;let t=d.toLowerCase().trim();return e.name&&e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)});return(0,n.jsxs)(s.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Agent Handoff Tools"}),r?(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,n.jsx)(es.default,{size:20}),(0,n.jsx)(i.default,{color:"text.secondary",children:"Loading handoff tools..."})]}):0===t.length?(0,n.jsxs)(s.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,n.jsx)(i.default,{color:"text.secondary",align:"center",children:"No handoff tools available for this node."}),(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:"Connect this Process node to other nodes to enable handoff tools."})]}):(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,n.jsx)(w.A,{placeholder:"Search handoff tools...",variant:"outlined",size:"small",fullWidth:!0,value:d,onChange:e=>c(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,n.jsx)(e2.A,{position:"start",children:(0,n.jsx)(e8.A,{fontSize:"small"})})}}),(0,n.jsx)(k.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 56px)"},children:0===u.length?(0,n.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,n.jsx)(i.default,{color:"text.secondary",children:d.trim()?'No handoff tools match "'.concat(d,'".'):"No handoff tools available."})}):(0,n.jsx)(ei.A,{disablePadding:!0,children:u.map(e=>(0,n.jsxs)(e5.A,{variant:"outlined",onClick:()=>{e.name?(ti.debug("Inserting handoff tool binding",{toolType:"handoff",toolName:e.name}),l("handoff",e.name)):ti.warn("Cannot insert handoff tool binding, tool name is undefined",{toolName:e.name})},sx:{mb:1,mx:1,mt:1,cursor:"pointer",position:"relative",bgcolor:"rgba(0, 0, 0, 0.04)","&:hover":{boxShadow:1,bgcolor:"rgba(0, 0, 0, 0.08)"}},children:[(0,n.jsx)(e6.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsxs)(i.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(e7.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),e.name]}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:e.description||"No description available"}),e.inputSchema&&(e=>e&&e.properties&&0!==Object.keys(e.properties).length?(0,n.jsxs)(s.default,{sx:{mt:1},children:[(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",sx:{fontWeight:"medium"},children:"Parameters:"}),(0,n.jsx)(s.default,{sx:{pl:1,mt:.5},children:Object.entries(e.properties).map(t=>{var r;let[o,l]=t;return(0,n.jsxs)(s.default,{sx:{mb:.5},children:[(0,n.jsxs)(i.default,{variant:"caption",component:"span",sx:{fontWeight:"medium"},children:[o,(null==(r=e.required)?void 0:r.includes(o))&&(0,n.jsx)(i.default,{variant:"caption",component:"span",color:"error.main",children:" *"}),": "]}),(0,n.jsx)(i.default,{variant:"caption",component:"span",color:"text.secondary",children:l.description||l.type||"No description"}),l.enum&&(0,n.jsx)(s.default,{sx:{pl:2,mt:.5},children:(0,n.jsxs)(i.default,{variant:"caption",color:"text.secondary",children:["Options: ",l.enum.join(", ")]})})]},o)})})]}):(0,n.jsx)(s.default,{sx:{mt:1},children:(0,n.jsx)(i.default,{variant:"caption",color:"text.secondary",sx:{fontStyle:"italic"},children:"No parameters required."})}))(e.inputSchema)]})})}),(0,n.jsx)(p.A,{title:"Add ".concat(e.name," handoff tool to prompt"),children:(0,n.jsx)(s.default,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0}})})]},e.name))})})]})]})};var tc=r(22822),tu=r(16757),tp=r(46496),th=r(54043),tf=r(54178),tm=r(26811),tg=r(95480);let tx=e=>{let{selected:t,icon:r,title:o,description:l,onClick:a}=e;return(0,n.jsxs)(s.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:a,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),a())},sx:{flex:1,minWidth:180,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,n.jsx)(eg.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[r,(0,n.jsx)(i.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:o})]}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",children:l})]})},tv=(0,E.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ProcessNodePropertiesModal/PromptTemplateEditor"),tw=(0,o.forwardRef)((e,t)=>{let{promptTemplate:r,handlePromptChange:l,excludeModelPrompt:a,setExcludeModelPrompt:c,excludeStartNodePrompt:u,setExcludeStartNodePrompt:p,excludeSystemPrompt:h,setExcludeSystemPrompt:m,inputMode:g,setInputMode:x,isolatedPrompt:v,setIsolatedPrompt:b,allowCallerPrompt:y,setAllowCallerPrompt:j,outputMode:A,setOutputMode:C,isModelBound:S,models:M,nodeData:N,flowId:F}=e,[P,E]=(0,o.useState)(""),[R,D]=(0,o.useState)(!1),[W,z]=(0,o.useState)(null),L=(0,o.useRef)(null);(0,o.useImperativeHandle)(t,()=>({insertText:e=>{L.current&&L.current.insertText(e)},getMode:()=>L.current?L.current.getMode():"raw"}));let B=async()=>{if(tv.debug("fetchRenderedPrompt called with:",{flowId:F,nodeId:null==N?void 0:N.id}),!F||!N||!N.id)return void z("Flow ID or Node ID is missing");D(!0),z(null);try{var e;let t=await fetch("/api/flow/prompt-renderer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:F,nodeId:N.id,options:{renderMode:"rendered",includeConversationHistory:!1,excludeModelPrompt:a,excludeStartNodePrompt:u,excludeSystemPrompt:h}})}),r=await t.json();if(!t.ok)throw Error(r.error||"Failed to render prompt");tv.debug("Rendered prompt received",{promptLength:null==(e=r.prompt)?void 0:e.length}),E(r.prompt+"\n\n [Messages sent by User]")}catch(e){tv.error("Error fetching rendered prompt",e),z(e instanceof Error?e.message:"An unknown error occurred")}finally{D(!1)}};return(0,o.useEffect)(()=>{L.current&&"preview"===L.current.getMode()&&B()},[r,a,u,h,F,null==N?void 0:N.id]),(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pl:2},children:[(0,n.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,n.jsx)(i.default,{variant:"h6",children:"Prompt Template"}),(0,n.jsxs)(s.default,{sx:{display:"flex",gap:2},children:[(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{checked:a,onChange:e=>c(e.target.checked),color:"primary",size:"small"}),label:"Exclude Model Prompt"}),(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{checked:u,onChange:e=>p(e.target.checked),color:"primary",size:"small"}),label:"Exclude Start Node Prompt"}),(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{checked:h,onChange:e=>m(e.target.checked),color:"primary",size:"small"}),label:"Exclude System Prompt"})]})]}),(0,n.jsxs)(s.default,{sx:{mb:2,p:2,bgcolor:"rgba(0, 0, 0, 0.03)",borderRadius:1,fontSize:"0.85rem"},children:[(0,n.jsx)(i.default,{variant:"caption",sx:{display:"block",mb:1,fontWeight:"bold"},children:"Prompt Rendering Order:"}),(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[!u&&(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(i.default,{variant:"caption",sx:{color:"primary.main",fontWeight:"medium"},children:"1. Start Node Prompt"}),(0,n.jsx)(i.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"(from the Start node in this flow)"})]}),!a&&S&&(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)(i.default,{variant:"caption",sx:{color:"secondary.main",fontWeight:"medium"},children:[u?"1.":"2."," Model Prompt"]}),(0,n.jsxs)(i.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:["(from the selected model: ",(()=>{var e,t;let r=null==(e=N.properties)?void 0:e.boundModel;if(!r)return"None";let n=M.find(e=>e.id===r);return n?n.displayName||n.name:(null==(t=N.properties)?void 0:t.modelName)||"None"})(),")"]})]}),(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)(i.default,{variant:"caption",sx:{fontWeight:"medium"},children:[u||a||!S?u&&(a||!S)?"1.":"2.":"3."," This Node's Prompt"]}),(0,n.jsx)(i.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"(defined below)"})]}),(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)(i.default,{variant:"caption",sx:{fontWeight:"medium"},children:[u||a||!S?u&&(a||!S)?"2.":"3.":"4."," ","isolated"===g?"Isolated prompt":"latest-message"===g?"Latest message only":"Conversation History"]}),(0,n.jsx)(i.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"isolated"===g?"(the prompt below, as the user message)":"latest-message"===g?"(the last user message + the last assistant response)":"(coming from ChatCompletion endpoint)"})]})]})]}),(0,n.jsxs)(s.default,{sx:{mb:2},children:[(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mb:1},children:"What does the model receive?"}),(0,n.jsxs)(s.default,{role:"radiogroup","aria-label":"Model input",sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[(0,n.jsx)(tx,{selected:"full-history"===g,onClick:()=>x("full-history"),icon:(0,n.jsx)(tu.A,{fontSize:"small"}),title:"Full conversation",description:"The model sees this node's prompt plus the whole conversation so far. The default."}),(0,n.jsx)(tx,{selected:"latest-message"===g,onClick:()=>x("latest-message"),icon:(0,n.jsx)(tp.A,{fontSize:"small"}),title:"Latest message only",description:"The model sees this node's prompt plus the most recent exchange — the last user message and the last assistant response — plus this turn's own in-flight tool calls and results."}),(0,n.jsx)(tx,{selected:"isolated"===g,onClick:()=>x("isolated"),icon:(0,n.jsx)(th.A,{fontSize:"small"}),title:"Isolated",description:"The conversation is ignored. The model sees this node's prompt plus the prompt below, sent as the user message."})]}),"isolated"===g&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(T.A,{sx:{mt:1,display:"block"},control:(0,n.jsx)(tc.A,{checked:y,onChange:e=>j(e.target.checked)}),label:"Let the caller pass a prompt"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{ml:4,mt:-.5},children:"When on, a step that hands off to this node can attach an instruction through its handoff tool, overriding the prompt below. The prompt below is then used only as a default when the caller sends none."}),(0,n.jsx)(w.A,{fullWidth:!0,label:y?"Default prompt (used if the caller sends none)":"Isolated prompt",value:v,onChange:e=>b(e.target.value),margin:"normal",multiline:!0,rows:2,helperText:y?"The default user message. A routing model may override it via the handoff tool. The prior conversation is not shown to the model (it is still kept in the transcript for later nodes).":"Sent to the model as the user message. The prior conversation is not shown to the model (it is still kept in the transcript for later nodes)."})]})]}),(0,n.jsxs)(s.default,{sx:{mb:2},children:[(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mb:1},children:"What do later steps see of this step's work?"}),(0,n.jsxs)(s.default,{role:"radiogroup","aria-label":"Model output",sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[(0,n.jsx)(tx,{selected:"full-conversation"===A,onClick:()=>C("full-conversation"),icon:(0,n.jsx)(tf.A,{fontSize:"small"}),title:"Full conversation",description:"Later steps see everything this step did — tool calls, tool results, and intermediate turns. The default."}),(0,n.jsx)(tx,{selected:"latest-message"===A,onClick:()=>C("latest-message"),icon:(0,n.jsx)(tm.A,{fontSize:"small"}),title:"Latest message only",description:"Later steps see only this step's final response. Its tool calls and results are hidden from later models to save context tokens (they stay visible in the chat and log)."})]})]}),(0,n.jsx)(s.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 120px)"},children:(0,n.jsx)(tg.A,{ref:L,value:r,onChange:l,label:"",height:"100%",onModeChange:e=>{"preview"===e&&B()},customPreviewRenderer:()=>R?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(es.default,{size:40})}):W?(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",p:2},children:[(0,n.jsx)(f.A,{severity:"error",sx:{mb:2},action:(0,n.jsx)(d.A,{color:"inherit",size:"small",onClick:B,children:"Retry"}),children:W}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:2,textAlign:"center"},children:F?"Check that the flow and node IDs are valid and try again.":"This flow hasn't been saved yet. Save the flow first to enable complete preview."})]}):(0,n.jsxs)(s.default,{sx:{p:2},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,sx:{fontWeight:"medium"},children:"Complete Rendered Prompt"}),(0,n.jsx)(k.A,{elevation:0,sx:{p:2,overflow:"auto",bgcolor:"rgba(0, 0, 0, 0.02)",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:1},children:(0,n.jsx)(s.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"0.875rem",m:0},children:P||"No rendered prompt available. Please check your flow configuration."})})]})})})]})});tw.displayName="PromptTemplateEditor";var tb=r(52641),ty=r(51221),tj=r(55606);let tA=e=>{let{nodeData:t,handlePropertyChange:r,properties:o}=e;return(0,n.jsx)(n.Fragment,{children:o.length>0&&(0,n.jsxs)(s.default,{sx:{mt:3},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Node Properties"}),o.map(e=>(e=>{var o,l,a;if(!t)return null;let s=null!=(l=null==(o=t.properties)?void 0:o[e.key])?l:"";switch(e.type){case"text":return(0,n.jsx)(w.A,{fullWidth:!0,label:e.label,multiline:e.multiline,rows:e.multiline?4:1,value:s,onChange:t=>r(e.key,t.target.value),margin:"normal",helperText:e.helperText},e.key);case"number":return(0,n.jsx)(w.A,{fullWidth:!0,type:"number",label:e.label,value:s,inputProps:{min:e.min,max:e.max,step:e.step},onChange:t=>{let n=t.target.value;r(e.key,""===n?void 0:Number(n))},margin:"normal",helperText:e.helperText},e.key);case"select":return(0,n.jsxs)(tb.A,{fullWidth:!0,margin:"normal",children:[(0,n.jsx)(ty.A,{children:e.label}),(0,n.jsx)(tj.A,{value:s||"",label:e.label,onChange:t=>r(e.key,t.target.value),children:null==(a=e.options)?void 0:a.map(e=>(0,n.jsx)(F.A,{value:e,children:e},e))})]},e.key);case"boolean":return(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{checked:s||!1,onChange:t=>r(e.key,t.target.checked)}),label:e.label,sx:{my:1}},e.key);default:return null}})(e))]})})};var tC=r(80777);let tS=e=>{let{value:t,onChange:r,onInsertRef:o}=e,l=t.captureVariable.trim(),a=t.captureKvKey.trim(),c=t.captureResource.trim(),u=""===l||eb(l),p=""===a||ek(a);return(0,n.jsxs)(s.default,{children:[(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mb:.5},children:"Data-flow capture"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Optionally save this step's output so a later step can reuse it. Leave a field empty to not capture it."}),(0,n.jsxs)(tC.A,{direction:"row",spacing:1,alignItems:"flex-start",sx:{mb:2},children:[(0,n.jsx)(w.A,{fullWidth:!0,size:"small",label:"Capture as run variable",value:t.captureVariable,onChange:e=>r({captureVariable:e.target.value}),error:!u,helperText:u?"Saves this step’s output into a run-scoped variable, injected later with ${var:NAME}.":"Use letters, digits, _ or - and start with a letter or _."}),o&&(0,n.jsxs)(d.A,{variant:"outlined",size:"small",sx:{mt:.5,whiteSpace:"nowrap",textTransform:"none"},disabled:!l||!u,onClick:()=>o("${var:".concat(l,"}")),children:["Insert $","{var:NAME}"]})]}),(0,n.jsxs)(tC.A,{direction:"row",spacing:1,alignItems:"flex-start",sx:{mb:2},children:[(0,n.jsx)(w.A,{fullWidth:!0,size:"small",label:"Capture as run resource",value:t.captureResource,onChange:e=>r({captureResource:e.target.value}),helperText:"Saves this step’s output as a named run resource, referenced later with ${res:NAME}."}),o&&(0,n.jsxs)(d.A,{variant:"outlined",size:"small",sx:{mt:.5,whiteSpace:"nowrap",textTransform:"none"},disabled:!c,onClick:()=>o("${res:".concat(c,"}")),children:["Insert $","{res:NAME}"]})]}),(0,n.jsxs)(tC.A,{direction:"row",spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(w.A,{select:!0,size:"small",label:"Scope",sx:{width:130,flexShrink:0},value:t.captureKvScope,onChange:e=>r({captureKvScope:e.target.value}),children:ej.map(e=>(0,n.jsx)(F.A,{value:e,children:e},e))}),(0,n.jsx)(w.A,{fullWidth:!0,size:"small",label:"Capture as persistent key (kv)",value:t.captureKvKey,onChange:e=>r({captureKvKey:e.target.value}),error:!p,helperText:p?"Persists across runs. Reference later with ${kv:NAME} (scope lives on this capture, not the reference).":"Use letters, digits, _ or - and start with a letter or _."}),o&&(0,n.jsxs)(d.A,{variant:"outlined",size:"small",sx:{mt:.5,whiteSpace:"nowrap",textTransform:"none"},disabled:!a||!p,onClick:()=>o("${kv:".concat(a,"}")),children:["Insert $","{kv:NAME}"]})]})]})},tk=(0,E.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ProcessNodePropertiesModal"),tT=e=>{var t;let{open:r,node:l,onClose:a,onSave:c,flowEdges:p=[],flowNodes:h=[],flowId:f,onConnectMcpServer:v}=e;tk.debug("ProcessNodePropertiesModal rendered with:",{node:l,flowId:f});let{nodeData:w,setNodeData:y,handlePropertyChange:j}=(e=>{let[t,r]=(0,o.useState)(null);(0,o.useEffect)(()=>{e&&r({id:e.id,...e.data,properties:{...e.data.properties}})},[e]);let n=(0,o.useCallback)((e,t)=>{r(r=>r?{...r,properties:{...r.properties,[e]:t}}:null)},[]);return{nodeData:t,setNodeData:r,handlePropertyChange:n}})(l),[A,C]=(0,o.useState)(""),[S,k]=(0,o.useState)(!1),[T,I]=(0,o.useState)(!1),[M,N]=(0,o.useState)(!1),[F,E]=(0,o.useState)(!1),[R,D]=(0,o.useState)("full-history"),[W,L]=(0,o.useState)(""),[B,O]=(0,o.useState)(!0),[U,V]=(0,o.useState)("full-conversation"),[K,$]=(0,o.useState)(""),[_,q]=(0,o.useState)(""),[J,X]=(0,o.useState)("folder"),[Y,Z]=(0,o.useState)(""),[Q,ee]=(0,o.useState)("server"),{models:et,isLoadingModels:er,loadError:en,handleModelSelect:eo,handleUnbindModel:el}=((e,t,r,n,l)=>{var a,s;eG.debug("useModelManagement: Entering hook");let[i,d]=(0,o.useState)([]),[c,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(null);(0,o.useEffect)(()=>{eG.debug("useModelManagement useEffect: Checking if modal is open",{open:e}),e&&f()},[e]),(0,o.useEffect)(()=>{var e,n;if(0===i.length)return;let o=null==t||null==(e=t.properties)?void 0:e.boundModel;if(!o)return;let l=i.find(e=>e.id===o);l&&l.name&&(null==t||null==(n=t.properties)?void 0:n.modelName)!==l.name&&r(e=>{var t;return e&&(null==(t=e.properties)?void 0:t.modelName)!==l.name?{...e,properties:{...e.properties,modelName:l.name}}:e})},[i,null==t||null==(a=t.properties)?void 0:a.boundModel,null==t||null==(s=t.properties)?void 0:s.modelName,r]);let f=async()=>{eG.debug("loadModels: Entering method"),u(!0),h(null);try{let e=await eD.N.loadModels();d(e)}catch(e){eG.warn("loadModels: Failed to load models:",e),h("Failed to load models")}u(!1)},m=(0,o.useCallback)(e=>{eG.debug("handleModelSelect: Entering method",{modelId:e});let t=i.find(t=>t.id===e);t&&(r(r=>{var n;if(!r)return null;let o=i.find(e=>{var t;return e.id===(null==(t=r.properties)?void 0:t.boundModel)}),l=eH({currentLabel:r.label,nameIsCustom:null==(n=r.properties)?void 0:n.nameIsCustom,defaultLabel:"Process Node",previousAutoLabel:o?o.displayName||o.name:void 0,nextAutoLabel:t.displayName||t.name});return{...r,label:l,properties:{...r.properties,boundModel:e,modelName:t.name}}}),l(!0))},[i,r,n,l]);return{models:i,isLoadingModels:c,loadError:p,handleModelSelect:m,handleUnbindModel:(0,o.useCallback)(()=>{eG.debug("handleUnbindModel: Entering method"),r(e=>{if(!e)return null;let{boundModel:t,modelName:r,...n}=e.properties;return{...e,properties:{...n,promptTemplate:n.promptTemplate||""}}}),l(!1)},[r,l])}})(r,w,y,C,k),{connectedMcpNodes:ea,allServers:es,isLoadingServers:ei,selectedToolServerNodeId:ed,serverToolsMap:ec,serverStatuses:eu,isLoadingTools:ep,handleSelectToolServer:eh,isLoadingSelectedServerTools:ef,handleRetryServer:em,handleRestartServer:eg}=((e,t,r,n)=>{let l=(0,eV.v)(),a=l.servers||[],s=l.isLoading||!1,[i,d]=(0,o.useState)({}),[c,u]=(0,o.useState)({}),[p,h]=(0,o.useState)({}),[f,m]=(0,o.useState)(null),[g,x]=(0,o.useState)(!1),v=(0,o.useMemo)(()=>t?((e,t)=>[...new Set(t.filter(t=>{var r,n;return t.source===e&&(null==(r=t.data)?void 0:r.edgeType)==="mcp"||t.target===e&&(null==(n=t.data)?void 0:n.edgeType)==="mcp"}).map(t=>t.source===e?t.target:t.source))])(t.id,r):[],[t,r]),w=(0,o.useMemo)(()=>{if(!t||0===v.length)return[];if(!n||!Array.isArray(n))return eK.warn("flowNodes is not available or not an array when filtering connected servers"),[];try{let e=[],t=new Set;return v.forEach(r=>{if(t.has(r))return;let o=n.find(e=>e&&e.id===r);if(!o||!o.data||!o.data.properties)return void eK.warn("Could not find valid MCP node data for ID ".concat(r));let l=o.data.properties.boundServer;if(!l)return void eK.warn("MCP node ".concat(r," is not bound to any server."));let s=a.find(e=>e.name===l),i=(null==s?void 0:s.status)||"unknown",d=o.data.properties.enabledTools||[];e.push({nodeId:r,serverName:l,status:i,enabledTools:Array.isArray(d)?d:[]}),t.add(r)}),eK.debug("Generated connectedMcpNodes:",JSON.stringify(e)),e}catch(e){return eK.error("Error preparing connected MCP nodes:",e),[]}},[t,v,a,n]);(0,o.useEffect)(()=>{if(w&&w.length>0){let e={};w.forEach(t=>{let r=a.find(e=>e.name===t.serverName);e[t.serverName]=(null==r?void 0:r.status)||t.status||"unknown"}),d(e)}},[w,a]),(0,o.useEffect)(()=>{if(e&&w.length>0){let e=Array.from(new Set(w.map(e=>e.serverName)));(async()=>{let t={},r={...c},n=e.filter(e=>{let t=a.find(t=>t.name===e);return(null==t?void 0:t.status)==="connected"&&!c[e]&&!p[e]});0!==n.length&&(n.forEach(e=>{t[e]=!0}),h(e=>({...e,...t})),await Promise.all(n.map(async e=>{try{eK.debug("Loading tools for server: ".concat(e));let t=await z.S.listServerTools(e);if(t.error)eK.warn("Error loading tools for ".concat(e,":"),t.error),r[e]=[];else{let n=t.tools||[];eK.debug("Loaded ".concat(n.length," tools for ").concat(e)),r[e]=n}}catch(t){eK.warn("Failed to load tools for server ".concat(e,":"),t),r[e]=[]}finally{h(t=>({...t,[e]:!1}))}})),u(r))})()}},[e,w,a]);let b=(0,o.useRef)(c);(0,o.useEffect)(()=>{b.current=c},[c]);let y=(0,o.useCallback)(e=>{eK.debug("Selected MCP Node ID: ".concat(e)),m(e);let t=w.find(t=>t.nodeId===e),r=null==t?void 0:t.serverName;!r||b.current[r]||p[r]?x(p[r||""]||!1):(eK.debug("Tools not loaded for server ".concat(r,", loading now.")),x(!0),h(e=>({...e,[r]:!0})),z.S.listServerTools(r).then(e=>{let t=e.tools||[];e.error?eK.warn("Error loading tools for ".concat(r,":"),e.error):eK.debug("Loaded ".concat(t.length," tools for ").concat(r)),u(e=>({...e,[r]:t}))}).catch(e=>{eK.warn("Failed to load tools for server ".concat(r,":"),e),u(e=>({...e,[r]:[]}))}).finally(()=>{x(!1),h(e=>({...e,[r]:!1}))}))},[w,p]),j=(0,o.useRef)(l);return(0,o.useEffect)(()=>{j.current=l},[l]),{connectedMcpNodes:w,allServers:a,isLoadingServers:s,selectedToolServerNodeId:f,serverToolsMap:c,serverStatuses:i,isLoadingTools:p,handleSelectToolServer:y,isLoadingSelectedServerTools:g,handleRetryServer:(0,o.useCallback)(async e=>{eK.debug("Retrying server: ".concat(e)),h(t=>({...t,[e]:!0}));try{await j.current.retryServer(e);let t=await z.S.listServerTools(e);if(t.error)return eK.warn("Error loading tools for ".concat(e," after retry:"),t.error),!1;{let r=t.tools||[];return eK.debug("Loaded ".concat(r.length," tools for ").concat(e," after retry")),u(t=>({...t,[e]:r})),!0}}catch(t){return eK.warn("Failed to retry or load tools for server ".concat(e,":"),t),!1}finally{h(t=>({...t,[e]:!1}))}},[]),handleRestartServer:(0,o.useCallback)(async e=>{eK.debug("Restarting server: ".concat(e)),h(t=>({...t,[e]:!0}));try{await z.S.restartServer(e),await new Promise(e=>setTimeout(e,1e3));let t=await z.S.listServerTools(e);if(t.error)return eK.warn("Error loading tools for ".concat(e," after restart:"),t.error),!1;{let r=t.tools||[];return eK.debug("Loaded ".concat(r.length," tools for ").concat(e," after restart")),u(t=>({...t,[e]:r})),!0}}catch(t){return eK.warn("Failed to restart or load tools for server ".concat(e,":"),t),!1}finally{h(t=>({...t,[e]:!1}))}},[])}})(r,l,p,h),ex=o.useMemo(()=>{if(!l)return[];let e=[];for(let o of p){var t,r,n;let a,s;if((null==(t=o.data)?void 0:t.edgeType)!=="resource"||(o.target===l.id?(a=o.source,s="consume"):o.source===l.id&&(a=o.target,s="produce"),!a||!s))continue;let i=h.find(e=>e.id===a);if(!i||"resource"!==i.type)continue;let d=null!=(n=null==(r=i.data)?void 0:r.properties)?n:{};e.push({id:a,role:s,label:d.name||d.runName||d.uri||a,scope:d.scope,runName:d.runName,uri:d.uri,boundServer:d.boundServer})}return e},[l,p,h]),ev=((e,t,r,n)=>{let[l,a]=(0,o.useState)([]),[s,i]=(0,o.useState)(!1),d=(0,o.useMemo)(()=>t?function(e,t){let r=[];for(let l of t){var n,o;!("string"==typeof(null==(n=l.data)?void 0:n.edgeType)&&(l.data.edgeType.includes("mcp")||"resource"===l.data.edgeType))&&(l.source===e?r.push(l.target):l.target===e&&(null==(o=l.data)?void 0:o.bidirectional)&&r.push(l.source))}return[...new Set(r)]}(t.id,r):[],[t,r]);return(0,o.useEffect)(()=>{if(e&&t){i(!0);try{let e=d.map(e=>n.find(t=>t.id===e)).filter(e=>!!e),t=(0,H.E9)(e.map(e=>({id:e.id,label:e.data.label,type:e.type||e.data.type}))),r=e.map(e=>({name:t.get(e.id)||"handoff_to_".concat(e.id),description:function(e){if(e.userDescription&&e.userDescription.trim())return e$(e.userDescription,1500);let t="Hand off execution to ".concat(e.label," (").concat(e.type,")."),r=[];!function e(t,r,n){let o=" ".repeat(r);if(t.userDescription&&t.userDescription.trim())return void n.push("".concat(o).concat(e$(t.userDescription,200)));if("subflow"===t.type){var l,a;if(t.subflowMissing)return void n.push("".concat(o,"Runs a subflow (referenced flow not found)."));if(t.subflowDetailsUnavailable){let e=t.subflowName?' "'.concat(t.subflowName,'"'):"";n.push("".concat(o,"Runs a subflow").concat(e," (contents summarised when the flow runs)."));return}if(n.push("".concat(o,'Runs the subflow "').concat(null!=(l=t.subflowName)?l:"unknown",'", which contains:')),t.depthCapReached)return void n.push("".concat(o," (nested subflows omitted — recursion depth limit reached)"));let s=null!=(a=t.children)?a:[];if(0===s.length)return void n.push("".concat(o," (no process or subflow steps)"));for(let t of s.slice(0,10))n.push("".concat(o," - ").concat(t.label,":")),e(t,r+2,n);return void(s.length>10&&n.push("".concat(o," - …and ").concat(s.length-10," more step(s)")))}if(t.modelName&&n.push("".concat(o,"Model: ").concat(t.modelName)),t.promptSummary&&n.push("".concat(o,"Role: ").concat(e$(t.promptSummary,200))),t.servers&&t.servers.length>0)for(let e of t.servers)if(e.connected&&e.tools&&e.tools.length>0){let t=e.tools.slice(0,10),r=e.tools.length-t.length,l=r>0?", +".concat(r," more"):"";n.push("".concat(o,"Tools (").concat(e.name,"): ").concat(t.join(", ")).concat(l))}else n.push("".concat(o,"Tools (").concat(e.name,"): server not connected"))}(e,0,r);let n=r.join("\n").trim(),o=n?"".concat(t,"\n").concat(n):t;if(o.length<=1500)return o;let l=1500-t.length-2;return l<=0?t:"".concat(t,"\n").concat(e$(n,l))}(function(e){let t=e.type||e.data.type||"unknown",r=e.data.label||"Unknown Node",n=e.data.description,o=e.data.properties||{},l={label:r,type:t,userDescription:n};if(n&&n.trim())return l;if("subflow"===t)return l.subflowDetailsUnavailable=!0,l;"string"==typeof o.boundModel&&o.boundModel&&(l.modelName=o.boundModel),"string"==typeof o.promptTemplate&&o.promptTemplate.trim()&&(l.promptSummary=o.promptTemplate);let a=Array.isArray(o.mcpNodes)?o.mcpNodes:[],s=[],i=new Set;for(let e of a){var d,c;let t=null==e||null==(d=e.properties)?void 0:d.boundServer;if(!t||i.has(t))continue;i.add(t);let r=Array.isArray(null==e||null==(c=e.properties)?void 0:c.enabledTools)?e.properties.enabledTools:[];s.push({name:t,connected:!0,tools:r})}return s.length>0&&(l.servers=s),l}(e)),inputSchema:{type:"object",properties:{},required:[]}}));a(r),e_.debug("Generated handoff tools",{toolsCount:r.length})}catch(e){e_.error("Error generating handoff tools",e),a([])}finally{i(!1)}}else a([])},[e,t,d,r,n]),{handoffTools:l,isLoadingHandoffTools:s}})(r,l,p,h),ew=(null==ev?void 0:ev.handoffTools)||[],eb=(null==ev?void 0:ev.isLoadingHandoffTools)||!1;(0,o.useEffect)(()=>{r&&l&&tk.debug("Handoff tools:",{count:ew.length,tools:ew.map(e=>e.name)})},[r,l,ew]),(0,o.useEffect)(()=>{if(l){var e,t,r,n,o,a,s,i,d,c,u,p;C((null==(e=l.data.properties)?void 0:e.promptTemplate)||""),(null==(t=l.data.properties)?void 0:t.boundModel)?k(!0):k(!1),I((null==(r=l.data.properties)?void 0:r.excludeModelPrompt)||!1),N((null==(n=l.data.properties)?void 0:n.excludeStartNodePrompt)||!1),E((null==(o=l.data.properties)?void 0:o.excludeSystemPrompt)||!1),D((null==(a=l.data.properties)?void 0:a.inputMode)||"full-history"),L((null==(s=l.data.properties)?void 0:s.isolatedPrompt)||""),O((null==(i=l.data.properties)?void 0:i.allowCallerPrompt)!==!1),V((null==(d=l.data.properties)?void 0:d.outputMode)||"full-conversation"),$((null==(c=l.data.properties)?void 0:c.captureVariable)||""),q((null==(u=l.data.properties)?void 0:u.captureResource)||"");let h=eA((null==(p=l.data.properties)?void 0:p.captureKv)||"");X(h.scope),Z(h.key||"")}},[l,r]);let ey=(0,o.useRef)(null),ej=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"server";if(tk.debug("handleInsertToolBinding called with:",JSON.stringify({serverName:e,toolName:t})),!e||!t)return void tk.warn("Invalid parameters for handleInsertToolBinding:",{serverName:e,toolName:t});let n=(ec[e]||[]).find(e=>e.name===t);null==n||n.description;let o="handoff"===r?(0,G.X8)("tool","handoff",t):(0,G.X8)("tool",e,t),l=(!(A.length>0)||A.endsWith(" ")||A.endsWith("\n")?"":" ")+o;ey.current?(tk.debug("Inserting text into PromptBuilder:",JSON.stringify({textToInsert:l})),ey.current.insertText(l),tk.debug("Tool binding inserted successfully")):tk.warn("promptBuilderRef.current is null, cannot insert text")};if(!l||!w)return null;let eS=(null==(t=w.properties)?void 0:t.boundModel)||"";return(0,n.jsxs)(m.A,{open:r,onClose:a,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"secondary.main",width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,n.jsx)(g.A,{component:"div",children:(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,n.jsxs)(i.default,{variant:"h6",children:[w.label||"Process Node"," Properties"]}),(0,n.jsx)(u.A,{edge:"end",color:"inherit",onClick:a,"aria-label":"close",children:(0,n.jsx)(eU.A,{})})]})}),(0,n.jsx)(P.A,{}),(0,n.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto",height:"calc(90vh - 130px)"},children:(0,n.jsxs)(eL.Ay,{container:!0,spacing:2,sx:{flexGrow:1,height:"100%"},children:[(0,n.jsxs)(eL.Ay,{item:!0,xs:6,sx:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:[(0,n.jsx)(s.default,{sx:{mb:3},children:(0,n.jsx)(eq,{nodeData:w,setNodeData:y})}),(0,n.jsx)(s.default,{sx:{mb:3},children:(0,n.jsx)(e0,{isLoadingModels:er,loadError:en,models:et,selectedModelId:eS,handleModelSelect:eo,isModelBound:S,handleUnbindModel:el})}),(0,n.jsxs)(s.default,{sx:{mb:3},children:[(0,n.jsx)(s.default,{sx:{borderBottom:1,borderColor:"divider",mb:2},children:(0,n.jsxs)(eB.A,{value:Q,onChange:(e,t)=>ee(t),children:[(0,n.jsx)(eO.A,{label:"Server Tools",value:"server"}),(0,n.jsx)(eO.A,{label:"Resources",value:"resources"}),(0,n.jsx)(eO.A,{label:"Agent Tools",value:"agent"})]})}),"server"===Q&&(0,n.jsx)(tr,{isLoadingServers:ei,connectedMcpNodes:ea,availableServers:es,onConnectMcpServer:v,serverStatuses:eu,serverToolsMap:ec,isLoadingTools:ep,handleInsertToolBinding:ej,selectedToolServerNodeId:ed,selectedNodeId:(null==l?void 0:l.id)||null,handleSelectToolServer:eh,isLoadingSelectedServerTools:ef,promptBuilderRef:ey,handleRetryServer:em,handleRestartServer:eg}),"resources"===Q&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ts,{wiredResources:ex,promptBuilderRef:ey}),(0,n.jsx)(tl,{connectedMcpNodes:ea,handleInsertResourceBinding:(e,t)=>{if(!e||!t)return void tk.warn("Invalid parameters for handleInsertResourceBinding:",{serverName:e,uri:t});let r=(0,G.X8)("resource",e,t),n=A.length>0&&!A.endsWith(" ")&&!A.endsWith("\n");ey.current?ey.current.insertText((n?" ":"")+r):tk.warn("promptBuilderRef.current is null, cannot insert resource binding")},promptBuilderRef:ey})]}),"agent"===Q&&(0,n.jsx)(td,{handoffTools:ew,isLoadingHandoffTools:eb,handleInsertToolBinding:(e,t)=>ej(e,t,"handoff"),promptBuilderRef:ey})]}),(0,n.jsx)(s.default,{children:(0,n.jsx)(tA,{nodeData:w,handlePropertyChange:j,properties:[{key:"maxTurns",label:"Max Turns (override)",type:"number",min:1,helperText:"Optional. Overrides the bound model's Max Turns for this node. Leave empty to inherit the model setting (default 50)."},{key:"maxTokens",label:"Max Output Tokens (override)",type:"number",min:1,helperText:"Optional. Overrides the bound model's Max Output Tokens for this node. Leave empty to inherit the model setting (adapter default). Not enforced for the Claude subscription adapter."}]})}),(0,n.jsx)(s.default,{sx:{mt:3},children:(0,n.jsx)(tS,{value:{captureVariable:K,captureResource:_,captureKvScope:J,captureKvKey:Y},onChange:e=>{void 0!==e.captureVariable&&$(e.captureVariable),void 0!==e.captureResource&&q(e.captureResource),void 0!==e.captureKvScope&&X(e.captureKvScope),void 0!==e.captureKvKey&&Z(e.captureKvKey)},onInsertRef:e=>{let t=A.length>0&&!A.endsWith(" ")&&!A.endsWith("\n");ey.current?ey.current.insertText((t?" ":"")+e):tk.warn("promptBuilderRef.current is null, cannot insert capture reference")}})})]}),(0,n.jsx)(eL.Ay,{item:!0,xs:6,sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,n.jsx)(tw,{ref:ey,promptTemplate:A,handlePromptChange:e=>{C(e),y(t=>t?{...t,properties:{...t.properties,promptTemplate:e}}:null)},excludeModelPrompt:T,setExcludeModelPrompt:I,excludeStartNodePrompt:M,setExcludeStartNodePrompt:N,excludeSystemPrompt:F,setExcludeSystemPrompt:E,inputMode:R,setInputMode:D,isolatedPrompt:W,setIsolatedPrompt:L,allowCallerPrompt:B,setAllowCallerPrompt:O,outputMode:U,setOutputMode:V,isModelBound:S,models:et,nodeData:w,flowId:f})})]})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:a,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{if(l&&w){let e={...w.properties,promptTemplate:A,excludeModelPrompt:T,excludeStartNodePrompt:M,excludeSystemPrompt:F,inputMode:R,isolatedPrompt:W,allowCallerPrompt:B,outputMode:U},t=K.trim();t?e.captureVariable=t:delete e.captureVariable;let r=_.trim();r?e.captureResource=r:delete e.captureResource;let n=eC(J,Y);n?e.captureKv=n:delete e.captureKv,c(l.id,{...w,properties:e}),a()}},variant:"contained",color:"primary",children:"Save Changes"})]})]})};var tI=r(71651),tM=r(94035);let tN=(0,E.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/MCPNodePropertiesModal"),tF=e=>{var t,r,l,a,c,h,f,v;let{open:y,node:j,onClose:A,onSave:C}=e,[S,k]=(0,o.useState)(null),{servers:M,isLoading:N,loadError:F,retryServer:E}=(0,eV.v)(),[R,D]=(0,o.useState)({}),W=(0,eQ.E)("mcp",M),[z,L]=(0,o.useState)(!1),B=async()=>{L(!0);try{await Promise.all(M.map(e=>E(e.name)))}finally{setTimeout(()=>L(!1),500)}},{tools:O,isLoading:U,error:H,loadTools:G}=(0,tM.O)((null==S||null==(t=S.properties)?void 0:t.boundServer)||"");(0,o.useEffect)(()=>{j&&k({...j.data,properties:{...j.data.properties}})},[j,y]);let V=(null==S||null==(r=S.properties)?void 0:r.boundServer)||"";(0,o.useEffect)(()=>{O&&O.length>0&&(e=>{S&&0===(S.properties.enabledTools||[]).length&&e.length>0&&(tN.debug("Enabling all tools by default"),k(t=>t?{...t,properties:{...t.properties,enabledTools:e.map(e=>e.name)}}:null))})(O)},[O]);let K=(e,t)=>{k(r=>r?{...r,properties:{...r.properties,[e]:t}}:null)},$=async(e,t)=>{t&&t.stopPropagation(),tN.debug("Retrying server: ".concat(e)),D(t=>({...t,[e]:!0}));try{return await E(e),e===V&&G(!0),!0}catch(t){return tN.warn("Failed to retry server ".concat(e,": ").concat(t)),!1}finally{setTimeout(()=>{D(t=>({...t,[e]:!1}))},500)}};if(!j||!S)return null;let _=(null==(l=S.properties)?void 0:l.boundServer)||"",q=(null==(a=S.properties)?void 0:a.enabledTools)||[],J=e=>({key:e.name,content:(e=>(0,n.jsx)(te.A,{name:e.name,status:e.status||"disconnected",path:e.path||e.rootPath||"",enabled:!e.disabled,transport:e.transport||"stdio",pickerMode:!0,selected:_===e.name,onClick:()=>(e=>{tN.debug("Server selected: ".concat(e)),tN.debug("Server selected: ".concat(e)),k(t=>{var r,n;if(!t)return null;let o=eH({currentLabel:t.label,nameIsCustom:null==(r=t.properties)?void 0:r.nameIsCustom,defaultLabel:"MCP Node",previousAutoLabel:(null==(n=t.properties)?void 0:n.boundServer)||void 0,nextAutoLabel:e});return{...t,label:o,properties:{...t.properties,boundServer:e}}})})(e.name)}))(e)}),X=W.items.map(J),Y=W.groups?W.groups.map(e=>({...e,items:e.items.map(J)})):null,Z=null==(c=S.properties)?void 0:c.toolTimeout,Q=-1===Z;return(0,n.jsxs)(m.A,{open:y,onClose:A,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"info.main",height:"80vh",maxHeight:"80vh"}},children:[(0,n.jsx)(g.A,{component:"div",children:(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,n.jsxs)(i.default,{variant:"h6",children:[S.label||"MCP Node"," Properties"]}),(0,n.jsx)(u.A,{edge:"end",color:"inherit",onClick:A,"aria-label":"close",children:(0,n.jsx)(eU.A,{})})]})}),(0,n.jsx)(P.A,{}),(0,n.jsxs)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto"},children:[(0,n.jsx)(w.A,{fullWidth:!0,label:"Node Label",value:S.label||"",onChange:e=>{k(t=>t?{...t,label:e.target.value,properties:{...t.properties,nameIsCustom:!0}}:null)},margin:"normal",helperText:"The display name for this node on the canvas",sx:{mb:2}}),(0,n.jsxs)(s.default,{sx:{mb:4},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Bind to MCP Server"}),(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"flex-end",mb:1},children:(0,n.jsx)(p.A,{title:"Retry all server connections",children:(0,n.jsx)("span",{children:(0,n.jsx)(u.A,{size:"small",onClick:B,disabled:z||N,children:z?(0,n.jsx)(es.default,{size:16}):(0,n.jsx)(e3.A,{fontSize:"small"})})})})}),(0,n.jsx)(eY.A,{isLoading:N,error:F,emptyMessage:"No MCP servers available. Add some in the MCP Manager.",loadingMessage:"Loading MCP servers…",searchable:!0,searchPlaceholder:"Search servers…",searchTerm:W.searchTerm,onSearchChange:W.setSearchTerm,columns:{xs:12,sm:6},items:X,groups:Y,collapsedKeys:W.collapsedKeys,onToggleGroup:W.toggleGroup}),(0,n.jsx)(eJ.A,{children:_?'This node will use the "'.concat(_,'" MCP server for processing.'):"Select an MCP server to bind this node to."})]}),(0,n.jsx)(w.A,{fullWidth:!0,label:"Description",value:S.description||"",onChange:e=>k({...S,description:e.target.value}),margin:"normal",multiline:!0,rows:2,helperText:"This description will be displayed on the node"}),_&&(0,n.jsxs)(s.default,{sx:{mt:4},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Tool Call Timeout"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"How long a single tool call on this server may run before it is aborted. Tools that report progress keep the timeout alive while they work."}),(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,n.jsx)(w.A,{label:"Timeout (seconds)",type:"number",size:"small",sx:{width:200},value:Q?"":null!=Z?Z:"",placeholder:String(300),disabled:Q,inputProps:{min:1},onChange:e=>{let t=e.target.value;if(""===t)return void K("toolTimeout",void 0);let r=parseInt(t,10);!isNaN(r)&&r>0&&K("toolTimeout",r)},helperText:Q?"No timeout — tool calls run until they finish.":"Empty = default (".concat(300," seconds / 5 minutes).")}),(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{checked:Q,onChange:e=>K("toolTimeout",e.target.checked?-1:void 0)}),label:"No timeout (infinite)"})]})]}),_&&(0,n.jsxs)(s.default,{sx:{mt:4},children:[(0,n.jsx)(i.default,{variant:"subtitle1",gutterBottom:!0,children:"Allowed Tools"}),(null==(h=M.find(e=>e.name===_))?void 0:h.status)!=="connected"&&(0,n.jsxs)(s.default,{sx:{mb:2,p:2,bgcolor:"error.light",borderRadius:1},children:[(0,n.jsx)(i.default,{color:"error.dark",children:"Server is disconnected. Tools cannot be fetched. Please retry the connection."}),(0,n.jsx)(d.A,{variant:"outlined",size:"small",color:"primary",startIcon:R[_]?(0,n.jsx)(es.default,{size:16}):(0,n.jsx)(e3.A,{}),onClick:()=>$(_),disabled:R[_],sx:{mt:1},children:"Retry Connection"})]}),U?(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,n.jsx)(es.default,{size:20}),(0,n.jsx)(i.default,{color:"text.secondary",children:"Loading tools..."})]}):H?(0,n.jsx)(i.default,{color:"error",children:H}):O&&0!==O.length?(0,n.jsxs)(s.default,{sx:{mt:2},children:[(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Select which tools this node will have access to. This helps limit the tools available to connected process nodes."}),(0,n.jsx)(ei.A,{children:O.map(e=>(0,n.jsxs)(ep.Ay,{sx:{py:0},children:[(0,n.jsx)(ed.A,{sx:{minWidth:42},children:(0,n.jsx)(I.A,{edge:"start",checked:q.includes(e.name),onChange:()=>(e=>{tN.debug("Tool toggled: ".concat(e)),k(t=>{let r;if(!t)return null;let n=t.properties.enabledTools||[];return r=n.includes(e)?n.filter(t=>t!==e):[...n,e],{...t,properties:{...t.properties,enabledTools:r}}})})(e.name)})}),(0,n.jsx)(ec.A,{primary:e.name,secondary:e.description,primaryTypographyProps:{fontWeight:"medium"}})]},e.name))})]}):(0,n.jsx)(i.default,{color:"text.secondary",children:(null==(f=M.find(e=>e.name===_))?void 0:f.status)==="connected"?"No tools available for this MCP server.":"Connect to the server to view available tools."})]}),_&&(0,n.jsxs)(s.default,{sx:{mt:4},children:[(0,n.jsx)(tI.A,{roots:(null==(v=S.properties)?void 0:v.roots)||[],onChange:e=>K("roots",e)}),(0,n.jsxs)(i.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:["These folders apply to this node only and are ",(0,n.jsx)("strong",{children:"added to"}),' the workspace folders configured on the "',_,'" server itself. When neither is set, the server sees its own root dir as its workspace folder.']})]})]}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:A,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{j&&S&&(C(j.id,S),A())},variant:"contained",color:"primary",children:"Save Changes"})]})]})},tP=e=>{let{open:t,node:r,onClose:l,onSave:a}=e,[c,p]=(0,o.useState)(null),[h,f]=(0,o.useState)("");return((0,o.useEffect)(()=>{if(r){var e;p({...r.data,properties:{...r.data.properties}}),f((null==(e=r.data.properties)?void 0:e.promptTemplate)||"")}},[r,t]),r&&c)?(0,n.jsxs)(m.A,{open:t,onClose:l,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,n.jsx)(g.A,{component:"div",children:(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,n.jsxs)(i.default,{variant:"h6",children:[c.label||"Start Node"," Properties"]}),(0,n.jsx)(u.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,n.jsx)(eU.A,{})})]})}),(0,n.jsx)(P.A,{}),(0,n.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto",height:"calc(90vh - 130px)"},children:(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,n.jsx)(i.default,{variant:"h6",gutterBottom:!0,children:"Prompt Template"}),(0,n.jsx)(s.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 40px)"},children:(0,n.jsx)(tg.A,{value:h,onChange:e=>{f(e),p(t=>t?{...t,properties:{...t.properties,promptTemplate:e}}:null)},label:"",height:"100%"})})]})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:l,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{if(r&&c){let e={...c,properties:{...c.properties,promptTemplate:h}};a(r.id,e),l()}},variant:"contained",color:"primary",children:"Save Changes"})]})]}):null},tE=e=>{let{open:t,node:r,onClose:l,onSave:a}=e,[c,p]=(0,o.useState)(null);return((0,o.useEffect)(()=>{r&&p({...r.data,properties:{...r.data.properties}})},[r,t]),r&&c)?(0,n.jsxs)(m.A,{open:t,onClose:l,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"success.main",width:"600px",height:"400px",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,n.jsx)(g.A,{component:"div",children:(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,n.jsxs)(i.default,{variant:"h6",children:[c.label||"Finish Node"," Properties"]}),(0,n.jsx)(u.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,n.jsx)(eU.A,{})})]})}),(0,n.jsx)(P.A,{}),(0,n.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto"},children:(0,n.jsx)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"center",alignItems:"center",py:4},children:(0,n.jsxs)(k.A,{elevation:0,sx:{p:4,textAlign:"center",backgroundColor:"rgba(76, 175, 80, 0.08)",borderRadius:2,width:"100%"},children:[(0,n.jsx)(i.default,{variant:"h6",color:"success.main",gutterBottom:!0,children:"Finish Node"}),(0,n.jsx)(i.default,{variant:"body1",color:"text.secondary",children:"This is the end point of your flow. No additional configuration is needed."}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mt:2,fontStyle:"italic"},children:"Future versions will support output formatting options."})]})})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:l,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{r&&c&&(a(r.id,c),l())},variant:"contained",color:"primary",children:"Save"})]})]}):null},tR={contains:"Contains",regex:"Regex",equals:"Equals",always:"Always (any reply)"},tD={"last-assistant":"Last assistant reply (this step's output)","last-message":"Last message (any role)"},tW=e=>{let{open:t,edge:r,onClose:l,onSave:a}=e,[c,p]=(0,o.useState)(!1),[h,f]=(0,o.useState)("contains"),[v,y]=(0,o.useState)(""),[j,A]=(0,o.useState)("last-assistant"),[C,S]=(0,o.useState)(!1),[k,M]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{var e,t;let n=null==r||null==(e=r.data)?void 0:e.condition;n?(p(!0),f(n.kind),y("string"==typeof n.value?n.value:""),A(null!=(t=n.target)?t:"last-assistant"),S(!!n.ignoreCase),M(!!n.negate)):(p(!1),f("contains"),y(""),A("last-assistant"),S(!1),M(!1))},[r,t]),!r)return null;let N="always"!==h,E=c&&"regex"===h&&v.length>0&&!(0,ex.wM)(v),R=c&&N&&0===v.length;return(0,n.jsxs)(m.A,{open:t,onClose:l,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",width:"520px",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,n.jsx)(g.A,{component:"div",children:(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,n.jsx)(i.default,{variant:"h6",children:"Edge Properties"}),(0,n.jsx)(u.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,n.jsx)(eU.A,{})})]})}),(0,n.jsx)(P.A,{}),(0,n.jsxs)(x.A,{sx:{display:"flex",flexDirection:"column",gap:2,p:3},children:[(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",children:"A conditional edge is taken only when its predicate matches the selected message at runtime. The flow takes the first matching outgoing edge; a plain (condition-less) edge is the default/fallback."}),(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{checked:c,onChange:e=>p(e.target.checked)}),label:"Conditional edge"}),c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(tb.A,{fullWidth:!0,size:"small",children:[(0,n.jsx)(ty.A,{id:"edge-condition-kind-label",children:"Kind"}),(0,n.jsx)(tj.A,{labelId:"edge-condition-kind-label",label:"Kind",value:h,onChange:e=>f(e.target.value),children:ex.w4.map(e=>(0,n.jsx)(F.A,{value:e,children:tR[e]},e))})]}),N&&(0,n.jsx)(w.A,{fullWidth:!0,size:"small",label:"regex"===h?"Pattern (JS regex source)":"Value",value:v,onChange:e=>y(e.target.value),error:E||R,helperText:E?"Invalid regular expression — will never match at runtime.":R?"A value is required for this kind (an empty value never matches).":" "}),(0,n.jsxs)(tb.A,{fullWidth:!0,size:"small",children:[(0,n.jsx)(ty.A,{id:"edge-condition-target-label",children:"Test against"}),(0,n.jsx)(tj.A,{labelId:"edge-condition-target-label",label:"Test against",value:j,onChange:e=>A(e.target.value),children:ex.L2.map(e=>(0,n.jsx)(F.A,{value:e,children:tD[e]},e))})]}),(0,n.jsxs)(s.default,{display:"flex",gap:2,flexWrap:"wrap",children:[N&&(0,n.jsx)(T.A,{control:(0,n.jsx)(tc.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Ignore case"}),(0,n.jsx)(T.A,{control:(0,n.jsx)(tc.A,{checked:k,onChange:e=>M(e.target.checked)}),label:"Negate (match when NOT true)"})]}),(0,n.jsx)(eJ.A,{children:"Predicates never throw at runtime: a broken regex simply never matches."})]})]}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:l,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{if(!c){a(r.id,void 0),l();return}let e={kind:h};N&&(e.value=v,C&&(e.ignoreCase=!0)),"last-assistant"!==j&&(e.target=j),k&&(e.negate=!0),a(r.id,e),l()},variant:"contained",color:"primary",disabled:E,children:"Save"})]})]})};var tz=r(56900),tL=r(9226);let tB=(0,E.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/SubflowNodePropertiesModal"),tO=e=>{var t,r,l,a,c,p,h,v,y,j,A,C,S,k,M,N,E,R,D;let{open:z,node:L,onClose:B,onSave:O,flowId:U}=e,[H,G]=(0,o.useState)(null),[V,K]=(0,o.useState)([]),[$,_]=(0,o.useState)(!1),[q,J]=(0,o.useState)(!1),[X,Y]=(0,o.useState)(""),[Z,Q]=(0,o.useState)(""),[ee,et]=(0,o.useState)(""),[er,en]=(0,o.useState)("folder"),[eo,el]=(0,o.useState)("");(0,o.useEffect)(()=>{if(L){let e=L.data.properties||{};G({...L.data,properties:{...e}}),Y(Array.isArray(e.spawnBriefs)?e.spawnBriefs.filter(e=>"string"==typeof e).join("\n"):""),Q(e.captureVariable||""),et(e.captureResource||"");let t=eA(e.captureKv||"");en(t.scope),el(t.key||"")}},[L,z]),(0,o.useEffect)(()=>{if(!z)return;let e=!1;return _(!0),W.g.loadFlows().then(t=>{e||K(t||[])}).catch(t=>{tB.warn("Failed to load flows for subflow picker",t),e||K([])}).finally(()=>{e||_(!1)}),()=>{e=!0}},[z]);let ea=(e,t)=>{G(r=>r?{...r,properties:{...r.properties,[e]:t}}:null)},es=e=>{G(t=>{if(!t)return null;let r={...t.properties};return delete r[e],{...t,properties:r}})},ei=V.filter(e=>e.id!==U),ed=(0,eQ.E)("flows",ei);if(!L||!H)return null;let ec=(null==(t=H.properties)?void 0:t.subflowId)||"",eu=!!ec&&!V.some(e=>e.id===ec),ep=eu?"":(null==(r=V.find(e=>e.id===ec))?void 0:r.name)||"",eh=Array.isArray(null==(l=H.properties)?void 0:l.parallelSubflowIds)?H.properties.parallelSubflowIds.filter(e=>"string"==typeof e&&""!==e):[],ef=eh.map(e=>{var t;return(null==(t=V.find(t=>t.id===e))?void 0:t.name)||e}),em="string"==typeof(null==(a=H.properties)?void 0:a.parallelSubflowIdsVar)?H.properties.parallelSubflowIdsVar.trim():"",eg=(null==(c=H.properties)?void 0:c.mapOverList)===!0,ex=!!(null==(p=H.properties)?void 0:p.allowCallerFanout),ev=X.split("\n").some(e=>""!==e.trim()),ew=ex||ev||eh.length>0||!!em||eg,eb=eh.length>0,ey=ex||ev,ej=!eb&&!em&&!ey,eS=!eg&&!eb,ek=(null==(h=H.properties)?void 0:h.promptTemplate)||"",eT=(null==(v=H.properties)?void 0:v.inputMode)||(ek.trim()?"isolated":"full-history");return(0,n.jsxs)(m.A,{open:z,onClose:B,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"warning.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,n.jsx)(g.A,{component:"div",children:(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,n.jsxs)(i.default,{variant:"h6",children:[H.label||"Subflow Node"," Properties"]}),(0,n.jsx)(u.A,{edge:"end",color:"inherit",onClick:B,"aria-label":"close",children:(0,n.jsx)(eU.A,{})})]})}),(0,n.jsx)(P.A,{}),(0,n.jsxs)(x.A,{sx:{p:3},children:[(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This step runs another flow inside this one — like calling a helper. When it finishes, its answer becomes part of this conversation and the flow continues to the next node."}),(0,n.jsx)(w.A,{fullWidth:!0,label:"Node Label",value:H.label||"",onChange:e=>G({...H,label:e.target.value}),margin:"normal"}),(0,n.jsxs)(s.default,{sx:{mt:2},children:[(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mb:1},children:"Flow to run"}),(0,n.jsx)(d.A,{variant:"outlined",startIcon:(0,n.jsx)(tz.A,{}),onClick:()=>J(!0),sx:{textTransform:"none",maxWidth:"100%"},children:(0,n.jsx)(s.default,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ep||(eh.length>0?"Parallel fan-out: ".concat(eh.length," flows"):em?"Fan-out targets from ${var:".concat(em,"}"):"Choose a flow…")})})]}),eu&&(0,n.jsx)(f.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),eh.length>0&&(0,n.jsx)(f.A,{severity:"info",sx:{mt:1},children:"This node runs ".concat(eh.length," flows in parallel and merges their results: ").concat(ef.join(", "),". (Configured via the flow API.)")}),(0,n.jsx)(e9.A,{open:q,onClose:()=>J(!1),title:"Choose a flow to run",description:"This subflow node will run the selected flow as a helper.",isLoading:$,skeleton:(0,n.jsx)(tL.o,{}),emptyMessage:"No other flows available. Create another flow first.",searchable:!0,searchPlaceholder:"Search flows…",searchTerm:ed.searchTerm,onSearchChange:ed.setSearchTerm,items:ed.items.map(e=>({key:e.id,content:(0,n.jsx)(tL.A,{flow:e,selected:e.id===ec,onSelect:e=>{ea("subflowId",e),J(!1)},pickerMode:!0})})),groups:ed.groups?ed.groups.map(e=>({...e,items:e.items.map(e=>({key:e.id,content:(0,n.jsx)(tL.A,{flow:e,selected:e.id===ec,onSelect:e=>{ea("subflowId",e),J(!1)},pickerMode:!0})}))})):null,collapsedKeys:ed.collapsedKeys,onToggleGroup:ed.toggleGroup}),(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"What does the subflow receive?"}),(0,n.jsxs)(s.default,{role:"radiogroup","aria-label":"Subflow input",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,n.jsx)(tx,{selected:"full-history"===eT,onClick:()=>ea("inputMode","full-history"),icon:(0,n.jsx)(tu.A,{}),title:"Full conversation",description:"The subflow sees the whole conversation so far, minus tool plumbing (system messages, tool calls and tool results are always stripped). Best for a helper that should continue with all the context."}),(0,n.jsx)(tx,{selected:"latest-message"===eT,onClick:()=>ea("inputMode","latest-message"),icon:(0,n.jsx)(tp.A,{}),title:"Latest message only",description:"The subflow sees the conversation from the most recent user message onward (not just one message), with tool plumbing stripped. Best for an orchestrator that hands off one task at a time, so old tasks don't leak in."}),(0,n.jsx)(tx,{selected:"isolated"===eT,onClick:()=>ea("inputMode","isolated"),icon:(0,n.jsx)(th.A,{}),title:"Isolated",description:"The conversation is ignored. The subflow receives only the prompt you write below, as its first message."})]}),"isolated"===eT&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(T.A,{sx:{mt:1,display:"block"},control:(0,n.jsx)(tc.A,{checked:(null==(y=H.properties)?void 0:y.allowCallerPrompt)!==!1,onChange:e=>ea("allowCallerPrompt",e.target.checked)}),label:"Let the caller pass a prompt"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:1,ml:4,mt:-.5},children:"When on, a step that routes to this subflow can attach an instruction through its handoff tool, overriding the prompt below. The prompt below is then used only as a default when the caller sends none."}),(0,n.jsx)(w.A,{fullWidth:!0,label:(null==(j=H.properties)?void 0:j.allowCallerPrompt)!==!1?"Default prompt (used if the caller sends none)":"Isolated prompt",value:ek,onChange:e=>ea("promptTemplate",e.target.value),margin:"normal",multiline:!0,rows:3,helperText:(null==(A=H.properties)?void 0:A.allowCallerPrompt)!==!1?"The default first message for the subflow. A routing model may override it via the handoff tool. The parent conversation is not passed.":"Sent to the subflow as its single user message. The parent conversation is not passed."})]}),(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"Dynamic fan-out"}),(0,n.jsx)(w.A,{fullWidth:!0,label:"Parallel flows from run variable",value:em,disabled:!eS,onChange:e=>{let t=e.target.value.trim();t?ea("parallelSubflowIdsVar",t):es("parallelSubflowIdsVar")},margin:"normal",helperText:eS?"Enter a run-variable NAME only (no ${…}); it resolves at runtime to the list of flow ids to run in parallel.":eg?"Disabled while “map over list” is on — a node can’t do both.":"Disabled while a static parallel list is configured via the flow API."}),(0,n.jsx)(T.A,{sx:{display:"block",mt:1},control:(0,n.jsx)(tc.A,{checked:eg,disabled:!ej&&!eg,onChange:e=>{e.target.checked?ea("mapOverList",!0):G(e=>{if(!e)return null;let{mapOverList:t,itemSplit:r,sequential:n,...o}=e.properties;return{...e,properties:o}})}}),label:"Run the selected flow once per input item (map over list)"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:1,ml:4,mt:-.5},children:ej||eg?"When on, the node parses its input into a list and runs the single selected flow once per item, merging the results.":"Disabled: map-over-list needs a single selected flow and can’t combine with parallel or spawning modes."}),eg&&(0,n.jsxs)(s.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",ml:4,mt:1},children:[(0,n.jsxs)(w.A,{label:"Split input as",select:!0,size:"small",sx:{width:240},value:(null==(C=H.properties)?void 0:C.itemSplit)==="lines"?"lines":"json-array",onChange:e=>{"lines"===e.target.value?ea("itemSplit","lines"):es("itemSplit")},helperText:"How the input is parsed into items",children:[(0,n.jsx)(F.A,{value:"json-array",children:"JSON array (default)"}),(0,n.jsx)(F.A,{value:"lines",children:"Lines"})]}),(0,n.jsx)(T.A,{control:(0,n.jsx)(tc.A,{checked:(null==(S=H.properties)?void 0:S.sequential)===!0,onChange:e=>{e.target.checked?ea("sequential",!0):es("sequential")}}),label:"Run items one at a time (ignores max copies)"})]}),(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"Parallel workers (spawning)"}),(0,n.jsx)(T.A,{sx:{display:"block"},control:(0,n.jsx)(tc.A,{checked:ex,onChange:e=>ea("allowCallerFanout",e.target.checked)}),label:"Let the caller spawn parallel copies of this sub-agent"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{mb:1,ml:4,mt:-.5},children:"When on, the step that hands off here may call this node's handoff tool several times in one reply — each call runs one parallel copy of the selected flow with its own task brief. The copies run concurrently; their results are merged in order and the flow continues once all of them finish."}),(0,n.jsx)(w.A,{fullWidth:!0,label:"Always spawn these briefs (one per line, optional)",value:X,onChange:e=>Y(e.target.value),margin:"normal",multiline:!0,minRows:2,helperText:"When set, every visit runs one parallel copy of the selected flow per line — no caller needed. Caller-passed tasks (above) override this list for that visit. Supports ${var:NAME}, ${res:NAME} and ${kv:NAME}."}),ew&&(0,n.jsxs)(s.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",mt:1},children:[(0,n.jsx)(w.A,{label:"Max copies at once",type:"number",size:"small",sx:{width:160},value:"number"==typeof(null==(k=H.properties)?void 0:k.concurrencyLimit)?H.properties.concurrencyLimit:"",onChange:e=>{let t=e.target.value;if(""===t)G(e=>{if(!e)return null;let{concurrencyLimit:t,...r}=e.properties;return{...e,properties:r}});else{let e=Math.max(1,Math.floor(Number(t)));Number.isNaN(e)||ea("concurrencyLimit",e)}},helperText:"Default 4"}),(0,n.jsxs)(w.A,{label:"Error handling",select:!0,size:"small",sx:{width:220},value:(null==(M=H.properties)?void 0:M.errorStrategy)==="fail-fast"?"fail-fast":"collect-all",onChange:e=>ea("errorStrategy",e.target.value),helperText:"What happens if a copy fails",children:[(0,n.jsx)(F.A,{value:"collect-all",children:"Collect all (note failures, continue)"}),(0,n.jsx)(F.A,{value:"fail-fast",children:"Fail fast (first failure stops the node)"})]}),(0,n.jsx)(w.A,{label:"Separator between merged results",size:"small",sx:{width:260},multiline:!0,maxRows:2,value:"string"==typeof(null==(N=H.properties)?void 0:N.joinSeparator)?H.properties.joinSeparator:"",onChange:e=>{let t=e.target.value;""===t?G(e=>{if(!e)return null;let{joinSeparator:t,...r}=e.properties;return{...e,properties:r}}):ea("joinSeparator",t)},helperText:"Empty = blank line"})]}),(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"What do you see in the chat while the subflow runs?"}),(0,n.jsxs)(s.default,{role:"radiogroup","aria-label":"Subflow output",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,n.jsx)(tx,{selected:"final-only"!==((null==(E=H.properties)?void 0:E.outputMode)||"steps"),onClick:()=>ea("outputMode","steps"),icon:(0,n.jsx)(tf.A,{}),title:"Full",description:"You see all of the subflow's messages in the chat, indented under this step — like watching it work."}),(0,n.jsx)(tx,{selected:(null==(R=H.properties)?void 0:R.outputMode)==="final-only",onClick:()=>ea("outputMode","final-only"),icon:(0,n.jsx)(tm.A,{}),title:"Condensed",description:"You only see the subflow's final answer as a single message. Its inner steps stay hidden."})]}),(0,n.jsx)(i.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"Debugging"}),(0,n.jsx)(T.A,{sx:{display:"block"},control:(0,n.jsx)(I.A,{checked:(null==(D=H.properties)?void 0:D.saveConversation)!==!1,onChange:e=>ea("saveConversation",e.target.checked)}),label:"Save this subflow's conversation to the sidebar (useful for debugging)"}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",sx:{ml:4,mt:-.5},children:'When on, each run of this subflow is persisted as its own conversation in the chat sidebar, linked to the parent run — like a planned execution\'s "Save full conversations". Parallel copies each get their own conversation, titled by their brief.'}),(0,n.jsx)(P.A,{sx:{my:3}}),(0,n.jsx)(tS,{value:{captureVariable:Z,captureResource:ee,captureKvScope:er,captureKvKey:eo},onChange:e=>{void 0!==e.captureVariable&&Q(e.captureVariable),void 0!==e.captureResource&&et(e.captureResource),void 0!==e.captureKvScope&&en(e.captureKvScope),void 0!==e.captureKvKey&&el(e.captureKvKey)}})]}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:B,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{if(L&&H){let e=X.split("\n").map(e=>e.trim()).filter(e=>""!==e),t={...H.properties};e.length>0?t.spawnBriefs=e:delete t.spawnBriefs;let r=Z.trim();r?t.captureVariable=r:delete t.captureVariable;let n=ee.trim();n?t.captureResource=n:delete t.captureResource;let o=eC(er,eo);o?t.captureKv=o:delete t.captureKv,O(L.id,{...H,properties:t}),B()}},variant:"contained",color:"primary",children:"Save"})]})]})};var tU=r(43861),tH=r(75656),tG=r(63109),tV=r(32683),tK=r(90880);let t$=(0,E.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ResourceNodePropertiesModal"),t_=e=>{var t,r,l,a,c;let{open:u,node:p,onClose:f,onSave:v,flowNodes:y}=e,[j,A]=(0,o.useState)(null),{servers:C,isLoading:S}=(0,eV.v)(),[k,I]=(0,o.useState)([]),[M,N]=(0,o.useState)(!1),[P,E]=(0,o.useState)(null),[R,D]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(p){A({...p.data,properties:{scope:"run",...p.data.properties}});let e=!!p.data.label&&"Resource Node"!==p.data.label.trim(),t=!!p.data.description&&p.data.description.trim().length>0;D(e||t)}},[p,u]);let W=(null==j||null==(t=j.properties)?void 0:t.scope)==="mcp"?"mcp":"run",L=(null==j||null==(r=j.properties)?void 0:r.boundServer)||"",B=(null==j||null==(l=j.properties)?void 0:l.uri)||"",O=(null==j||null==(a=j.properties)?void 0:a.runName)||"",U=(0,o.useMemo)(()=>{let e=(null!=y?y:[]).filter(e=>e.id!==(null==p?void 0:p.id)).map(e=>{try{var t,r;return JSON.stringify(null!=(r=null==(t=e.data)?void 0:t.properties)?r:{})}catch(e){return""}});return(0,tK.jX)(e)},[y,null==p?void 0:p.id]),H=(0,o.useCallback)((e,t)=>{A(r=>r?{...r,properties:{...r.properties,[e]:t}}:r)},[]);(0,o.useEffect)(()=>{if(!u||"mcp"!==W||!L){I([]),E(null);return}let e=!1;return N(!0),E(null),z.S.listServerResources(L).then(t=>{if(!e)if(t.error)E(t.error),I([]);else{var r,n;I([...(null!=(r=t.resources)?r:[]).map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})),...(null!=(n=t.resourceTemplates)?n:[]).map(e=>({uri:e.uriTemplate,name:e.name?"".concat(e.name," (template)"):"(template)",description:e.description}))])}}).catch(t=>{e||(t$.warn("Failed to browse resources of ".concat(L),t),E(t instanceof Error?t.message:String(t)))}).finally(()=>{e||N(!1)}),()=>{e=!0}},[u,W,L]);let G="run"===W&&!!O.trim()&&!eb(O.trim());return j?(0,n.jsxs)(m.A,{open:u,onClose:f,maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(g.A,{children:"Resource Node Properties"}),(0,n.jsx)(x.A,{children:(0,n.jsxs)(s.default,{display:"flex",flexDirection:"column",gap:2,mt:1,children:[(0,n.jsxs)(tb.A,{children:[(0,n.jsxs)(tU.A,{row:!0,value:W,onChange:e=>H("scope","mcp"===e.target.value?"mcp":"run"),children:[(0,n.jsx)(T.A,{value:"run",control:(0,n.jsx)(tH.A,{}),label:"Temporary Data"}),(0,n.jsx)(T.A,{value:"mcp",control:(0,n.jsx)(tH.A,{}),label:"MCP resource"})]}),(0,n.jsx)(eJ.A,{children:"mcp"===W?"A static resource published by an MCP server. Steps connected FROM this node receive its contents.":"A named piece of run data: a step writing INTO this node saves its output here; steps reading FROM it receive the latest value (also available as ${res:NAME})."})]}),"mcp"===W?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(tb.A,{fullWidth:!0,children:[(0,n.jsx)(ty.A,{id:"resource-server-label",children:"Server"}),(0,n.jsxs)(tj.A,{labelId:"resource-server-label",label:"Server",value:L,onChange:e=>{H("boundServer",e.target.value)},children:[S&&(0,n.jsx)(F.A,{value:"",disabled:!0,children:"Loading servers…"}),C.map(e=>(0,n.jsx)(F.A,{value:e.name,children:e.name},e.name))]})]}),(0,n.jsx)(w.A,{label:"Resource URI",value:B,onChange:e=>H("uri",e.target.value),fullWidth:!0,placeholder:"e.g. file:///data/report.md",helperText:"Pick from the list below or paste a URI / filled-in template."}),M&&(0,n.jsxs)(s.default,{display:"flex",alignItems:"center",gap:1,children:[(0,n.jsx)(es.default,{size:18}),(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",children:"Loading resources…"})]}),P&&(0,n.jsxs)(i.default,{variant:"body2",color:"warning.main",children:["Could not list resources: ",P]}),!M&&!P&&L&&0===k.length&&(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",children:"This server publishes no resources (you can still paste a URI above)."}),k.length>0&&(0,n.jsx)(ei.A,{dense:!0,sx:{maxHeight:240,overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:k.map(e=>(0,n.jsxs)(eu.A,{selected:e.uri===B,onClick:()=>H("uri",e.uri),children:[(0,n.jsx)(ed.A,{sx:{minWidth:34},children:(0,n.jsx)(J.A,{fontSize:"small",sx:{color:"#009688"}})}),(0,n.jsx)(ec.A,{primary:e.name||e.uri,secondary:e.name?e.uri:e.description,secondaryTypographyProps:{sx:{wordBreak:"break-all"}}})]},e.uri))})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tG.A,{freeSolo:!0,options:U,inputValue:O,onInputChange:(e,t)=>H("runName",t),renderInput:e=>(0,n.jsx)(w.A,{...e,label:"Temporary Data name",fullWidth:!0,error:G,helperText:G?"Letters, digits, _ and - only; must not start with a digit.":U.length>0?"Steps reference it as ${res:NAME}. Suggestions are names already used in this flow.":"Steps reference it as ${res:NAME}; a producing edge saves the step output under this name."})}),O.trim()&&!G&&(0,n.jsxs)(i.default,{variant:"caption",color:"text.secondary",children:['URI at run time: flujo://run/<conversation>/… (named "',O.trim(),'")']})]}),(0,n.jsx)(tV.A,{component:"button",type:"button",underline:"hover",onClick:()=>D(e=>!e),sx:{alignSelf:"flex-start"},children:R?"Hide advanced":"Advanced — name & description"}),(0,n.jsx)(h.A,{in:R,unmountOnExit:!0,children:(0,n.jsxs)(s.default,{display:"flex",flexDirection:"column",gap:2,children:[(0,n.jsx)(w.A,{label:"Label",value:j.label,onChange:e=>A({...j,label:e.target.value}),fullWidth:!0,helperText:"Optional. The node's name on the canvas; defaults to the Temporary Data name."}),(0,n.jsx)(w.A,{label:"Description",value:null!=(c=j.description)?c:"",onChange:e=>A({...j,description:e.target.value}),fullWidth:!0,multiline:!0,minRows:2})]})})]})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:f,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{var e;if(!p||!j)return;let t={...j.properties};"run"===W?(delete t.boundServer,delete t.uri,delete t.mimeType,t.scope="run",t.runName=O.trim()):(delete t.runName,t.scope="mcp");let r=(null!=(e=j.label)?e:"").trim()||("run"===W?O.trim()||"Temporary Data":"MCP resource");v(p.id,{...j,label:r,properties:t})},variant:"contained",children:"Save"})]})]}):null},tq=e=>{var t,r,l,a;let{open:i,node:c,onClose:u,onSave:p}=e,[v,y]=(0,o.useState)(null),[j,A]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(c){var e;y({...c.data,properties:{...c.data.properties}}),A(!!(null==(e=c.data.properties)?void 0:e.payloadTemplate))}},[c,i]);let C=(e,t)=>{y(r=>r?{...r,properties:{...r.properties,[e]:t}}:r)};if(!v)return null;let S=null!=(l=null==(t=v.properties)?void 0:t.topic)?l:"",k=null!=(a=null==(r=v.properties)?void 0:r.payloadTemplate)?a:"";return(0,n.jsxs)(m.A,{open:i,onClose:u,maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(g.A,{children:"Signal Node"}),(0,n.jsx)(x.A,{children:(0,n.jsxs)(s.default,{display:"flex",flexDirection:"column",gap:2,mt:1,children:[(0,n.jsx)(w.A,{label:"Signal Name (topic)",value:S,onChange:e=>C("topic",e.target.value),fullWidth:!0,required:!0,autoFocus:!0,error:!S.trim(),placeholder:"e.g. review-blocked",helperText:S.trim()?"A free-form shared name (no registry). A planned execution reacts to it via a flow-event trigger with this signal name. This is also the node’s display name.":"A signal name is required — a flow-event trigger listens for this exact name."}),(0,n.jsx)(f.A,{severity:"info",children:"When execution reaches this node it emits the signal and continues immediately (fire-and-forget). To emit conditionally, put a conditioned edge into this node. Runaway signal chains are bounded by the trigger’s max chain depth."}),(0,n.jsx)(tV.A,{component:"button",type:"button",underline:"hover",onClick:()=>A(e=>!e),sx:{alignSelf:"flex-start"},children:j?"Hide advanced":"Advanced — optional payload"}),(0,n.jsx)(h.A,{in:j,unmountOnExit:!0,children:(0,n.jsx)(w.A,{label:"Payload template (optional)",value:k,onChange:e=>C("payloadTemplate",e.target.value),fullWidth:!0,multiline:!0,minRows:3,placeholder:"e.g. Review found blockers: ${var:reviewSummary}",helperText:"Optional. Emitted as the signal payload and handed to the triggered flow. ${var:NAME} is resolved from run variables at emit time."})})]})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:u,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:()=>{if(!c||!v)return;let e={...v.properties},t="string"==typeof e.topic?e.topic.trim():"";e.topic=t;let r=t||"Signal";p(c.id,{...v,label:r,properties:e})},variant:"contained",children:"Save"})]})]})};var tJ=r(50291),tX=r(76122);let tY=e=>{let{flow:t}=e,r=(0,a.A)(),l=(0,o.useMemo)(()=>(t.edges||[]).filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle),[t.edges]),s=(0,o.useMemo)(()=>({type:"custom",animated:!1,style:{stroke:r.palette.text.secondary,strokeWidth:2},markerEnd:{type:tX.TG.ArrowClosed,width:20,height:20,color:r.palette.text.secondary}}),[r.palette.text.secondary]);return(0,n.jsx)(R.Gc,{nodes:t.nodes||[],edges:l,nodeTypes:K.c_,edgeTypes:K.nd,defaultEdgeOptions:s,connectionLineType:tX.Do.SmoothStep,fitView:!0,minZoom:.1,maxZoom:2,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,deleteKeyCode:null,proOptions:{hideAttribution:!0},children:(0,n.jsx)(R.VS,{})})},tZ=e=>(0,n.jsx)(R.Ln,{children:(0,n.jsx)(tY,{...e})}),tQ=(0,E.h)("components/flow/FlowBuilder/Modals/FlowVersionHistoryDialog"),t0=e=>{let{open:t,flowId:r,onClose:l,onRestore:a}=e,[c,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)([]),[f,v]=(0,o.useState)(null),[w,y]=(0,o.useState)(!1),[j,A]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!t||!r)return;let e=!1;return u(!0),h([]),v(null),A(null),W.g.listFlowVersions(r).then(t=>{e||h(t)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t,r]);let C=(0,o.useCallback)(e=>{r&&(v(e),y(!0),A(null),W.g.getFlowVersion(r,e).then(t=>{t?A(t.flow):tQ.warn("Version ".concat(e," could not be loaded (pruned?)"))}).finally(()=>y(!1)))},[r]),S=(0,o.useCallback)(()=>{j&&a(j)},[j,a]);return(0,n.jsxs)(m.A,{open:t,onClose:l,maxWidth:"lg",fullWidth:!0,children:[(0,n.jsx)(g.A,{children:"Version History"}),(0,n.jsx)(x.A,{dividers:!0,sx:{p:0},children:(0,n.jsxs)(s.default,{sx:{display:"flex",height:"65vh"},children:[(0,n.jsx)(s.default,{sx:{width:300,borderRight:1,borderColor:"divider",overflowY:"auto"},children:c?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(es.default,{size:28})}):0===p.length?(0,n.jsx)(s.default,{sx:{p:3},children:(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",children:"No saved versions yet. A version is archived automatically each time you save a change to this flow."})}):(0,n.jsx)(ei.A,{disablePadding:!0,children:p.map((e,t)=>(0,n.jsxs)(o.Fragment,{children:[(0,n.jsx)(eu.A,{selected:e.versionId===f,onClick:()=>C(e.versionId),children:(0,n.jsx)(ec.A,{primary:(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,n.jsx)(i.default,{variant:"body2",children:function(e){try{return new Date(e).toLocaleString()}catch(t){return String(e)}}(e.savedAt)}),0===t&&(0,n.jsx)(ea.A,{label:"most recent",size:"small"})]}),secondary:"".concat(e.nodeCount," node").concat(1===e.nodeCount?"":"s"," \xb7 ").concat(e.edgeCount," edge").concat(1===e.edgeCount?"":"s")})}),(0,n.jsx)(P.A,{component:"li"})]},e.versionId))})}),(0,n.jsx)(s.default,{sx:{flex:1,position:"relative",minWidth:0},children:w?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(es.default,{size:32})}):j?(0,n.jsx)(tZ,{flow:j}):(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",p:4},children:(0,n.jsx)(i.default,{variant:"body2",color:"text.secondary",align:"center",children:0===p.length?"Versions appear here after you save changes.":"Select a version on the left to preview it."})})})]})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:l,children:"Close"}),(0,n.jsx)(d.A,{variant:"contained",color:"primary",startIcon:(0,n.jsx)(tJ.A,{}),onClick:S,disabled:!j,children:"Restore this version"})]})]})};var t1=r(31102),t2=r(18581),t5=r(13179),t6=r(90363),t3=r(67063),t4=r(30989);let t8=(0,E.h)("frontend/components/Flow/FlowManager/ImproveFlowDialog"),t7=e=>{let{open:t,onClose:r,currentFlow:l,onImproved:a,initialDescription:i}=e,[c,u]=(0,o.useState)(""),[p,h]=(0,o.useState)([]),[y,j]=(0,o.useState)(""),[A,C]=(0,o.useState)(!1),[S,k]=(0,o.useState)(!1),[I,M]=(0,o.useState)(null);(0,o.useEffect)(()=>{t&&u(null!=i?i:"")},[t,i]),(0,o.useEffect)(()=>{if(!t)return;let e=!1;return eD.N.loadModels().then(t=>{e||(h(t),j(e=>{var r,n;return t.some(t=>t.id===e)?e:null!=(n=null==(r=t[0])?void 0:r.id)?n:""}))}).catch(t=>{t8.warn("Failed to load models for the improve dialog",t),e||M("Could not load your models. Configure a model first.")}),()=>{e=!0}},[t]);let N=(0,o.useCallback)(()=>{S||(M(null),r())},[S,r]),P=(0,o.useCallback)(async()=>{M(null),k(!0);try{let e={...l,nodes:[...l.nodes],edges:[...l.edges]},t=await W.g.improveFlow(e,c.trim(),y,{allowInstall:A});if(!t.success)return void M(t.error);t8.info("Flow improved",{flowId:t.flow.id,attempts:t.attempts,errors:t.validation.errorCount,warnings:t.validation.warningCount,installedServers:t.installedServers.length}),u(""),a({flow:t.flow,errorCount:t.validation.errorCount,warningCount:t.validation.warningCount,attempts:t.attempts,installedServers:t.installedServers})}finally{k(!1)}},[l,c,y,A,a]),E=!S&&c.trim().length>0&&!!y;return(0,n.jsxs)(m.A,{open:t,onClose:N,maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(g.A,{children:"Improve this flow with AI"}),(0,n.jsxs)(x.A,{children:[(0,n.jsxs)(v.A,{sx:{mb:2},children:["Describe the changes you want — add or remove a step, rewrite a prompt, wire up a tool, rename a node. The model revises the ",(0,n.jsx)("strong",{children:"current"})," flow and the result opens on the canvas as an unsaved change you can review, undo, and save."]}),I&&(0,n.jsx)(f.A,{severity:"error",sx:{mb:2},onClose:()=>M(null),children:I}),(0,n.jsx)(w.A,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:4,label:"What should change?",placeholder:"e.g. Add a step after the research that emails the summary, and make the research step use the full conversation",value:c,onChange:e=>u(e.target.value),disabled:S,sx:{mb:2}}),(0,n.jsxs)(tb.A,{fullWidth:!0,disabled:S||0===p.length,children:[(0,n.jsx)(ty.A,{id:"improve-flow-model-label",children:"Generator model"}),(0,n.jsx)(tj.A,{labelId:"improve-flow-model-label",label:"Generator model",value:y,onChange:e=>j(e.target.value),children:p.map(e=>{var t;return(0,n.jsx)(F.A,{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),(0,n.jsx)(T.A,{sx:{mt:2},control:(0,n.jsx)(tc.A,{checked:A,onChange:e=>C(e.target.checked),disabled:S}),label:"Let the improver install MCP servers it needs (self-improve)"}),A&&(0,n.jsxs)(f.A,{severity:"warning",sx:{mt:1},children:["The improver may ",(0,n.jsx)("strong",{children:"download, install, and run third-party MCP servers"})," from the public registry on this machine — without asking again. It prefers servers that need no API keys, but anything it installs executes real code with your user's permissions. Installed servers stay configured afterwards (remove them on the MCP page)."]}),S&&(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1.5,mt:2},children:[(0,n.jsx)(es.default,{size:20}),(0,n.jsx)(v.A,{children:A?"Improving… the model may search the marketplace and install servers (this can take a few minutes).":"Improving… the model revises the flow and FLUJO checks it (this can take up to a minute)."})]})]}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:N,disabled:S,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:P,variant:"contained",color:"primary",startIcon:(0,n.jsx)(t6.A,{}),disabled:!E,children:"Improve"})]})]})};var t9=r(77890),re=r(57563);let rt=e=>({source:"".concat(e,"-bottom"),target:"".concat(e,"-top")});function rr(e){var t,r,n;return null!=(n=null!=(r=null==(t=e.data)?void 0:t.type)?r:e.type)?n:"unknown"}let rn=(0,E.h)("components/flow/FlowBuilder/index.tsx"),ro=(0,S.Ay)(s.default)(e=>{let{theme:t}=e;return{display:"flex",height:"calc(100vh - 64px)",gap:"16px",padding:"16px",backgroundColor:t.palette.background.default}}),rl=(0,S.Ay)(k.A)(e=>{let{theme:t}=e;return{padding:t.spacing(1),display:"flex",gap:t.spacing(1),borderBottom:"1px solid",borderColor:t.palette.divider,alignItems:"center",marginBottom:t.spacing(1),backgroundColor:t.palette.background.paper,boxShadow:t.shadows[1]}}),ra=(0,S.Ay)(s.default)({flex:1,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"}),rs=o.forwardRef((e,t)=>{var r;let{initialFlow:l,onSave:a,onDelete:i,allFlows:c}=e;rn.debug("FlowBuilder rendered with initialFlow:",l);let[y,j]=(0,o.useState)((null==l?void 0:l.nodes)||[]),[A,C]=(0,o.useState)(((null==l?void 0:l.edges)||[]).filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle)),[S,k]=(0,o.useState)((null==l?void 0:l.name)||"NewFlow"),[E,B]=(0,o.useState)(null),[$,_]=(0,o.useState)((null==l?void 0:l.description)||""),[J,X]=(0,o.useState)(null!=(r=null==l?void 0:l.unattended)&&r),[Y,Z]=(0,o.useState)(!1),[Q,ee]=(0,o.useState)("none"),[et,er]=(0,o.useState)(""),[en,eo]=(0,o.useState)(null),[ea,es]=(0,o.useState)(!1),[ei,ed]=(0,o.useState)(!1),[ec,eu]=(0,o.useState)(!1),[ep,eh]=(0,o.useState)(!1),[ef,em]=(0,o.useState)(!1),[eg,ex]=(0,o.useState)(!1),[ev,ew]=(0,o.useState)(!1),[eb,ey]=(0,o.useState)(null),[ej,eA]=(0,o.useState)(null),[eC,eS]=(0,o.useState)(!1),[ek,eT]=(0,o.useState)(null),[eI,eM]=(0,o.useState)(null),[eN,eF]=(0,o.useState)(""),[eP,eE]=(0,o.useState)(!1),[eR,eD]=(0,o.useState)([]),[eW,eL]=(0,o.useState)(-1),[eB,eO]=(0,o.useState)(!1),[eU,eH]=(0,o.useState)(!1),eG=(0,o.useRef)(null),eV=(0,o.useRef)(!1),eK=(0,o.useRef)(!0),e$=(0,o.useCallback)(e=>e.filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle).map(e=>{var t;return(null==(t=e.data)?void 0:t.edgeType)==="resource"&&"resourceEdge"!==e.type?{...e,type:"resourceEdge"}:e}),[]);(0,o.useEffect)(()=>{if(eK.current=!0,l){var e;j(l.nodes||[]);let t=e$(l.edges||[]);t.length!==l.edges.length&&console.warn("Filtered out ".concat(l.edges.length-t.length," invalid edges")),C(t),k(l.name),_(l.description||""),X(null!=(e=l.unattended)&&e),eD([{nodes:l.nodes||[],edges:t}]),eL(0)}else{let e=W.g.createStartNode();j([e]),C([]),k("NewFlow"),_(""),X(!1),eD([{nodes:[e],edges:[]}]),eL(0)}},[l]);let e_=e=>JSON.stringify(e,(e,t)=>"selected"===e||"dragging"===e||"measured"===e||"width"===e||"height"===e||"positionAbsolute"===e||"resizing"===e?void 0:t);(0,o.useEffect)(()=>{if(eB)return void eO(!1);if(eK.current){eK.current=!1;return}if(eV.current)return;let e={nodes:[...y],edges:[...A]},t=eR.slice(0,eW+1);(eW<0||e_(e)!==e_(t[eW]))&&(eD([...t,e]),eL(eW+1),eH(!0))},[y,A]),(0,o.useEffect)(()=>{let e=e=>{if(eU)return e.preventDefault(),e.returnValue="",""};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[eU]);let eq=e=>e.trim()?/^[\w-]+$/.test(e)?(!l||l&&l.name!==e)&&c.some(t=>t.id!==((null==l?void 0:l.id)||"")&&t.name.toLowerCase()===e.toLowerCase())?"A flow with this name already exists":null:"Flow name can only contain letters, numbers, underscores, and dashes":"Flow name cannot be empty",eJ=(0,o.useCallback)(()=>{rn.debug('handleSave: Attempting to save flow "'.concat(S,'"'));let e=eq(S);if(e)return rn.warn("handleSave: Invalid flow name - ".concat(e)),B(e),"invalid-name";let t=[...y];if(0===t.length&&(rn.debug("handleSave: No nodes found, adding a default Start node"),j(t=[W.g.createStartNode()])),l&&l.name!==S)return rn.debug('handleSave: Flow name changed from "'.concat(l.name,'" to "').concat(S,'", opening rename dialog')),ee("rename"),er(S),Z(!0),"rename-dialog";let r={id:(null==l?void 0:l.id)||(0,D.A)(),name:S,description:$,unattended:J,nodes:t,edges:A,folder:null==l?void 0:l.folder,favorite:null==l?void 0:l.favorite};return rn.info('handleSave: Saving flow "'.concat(S,'" with ').concat(t.length," nodes and ").concat(A.length," edges")),a(r),eH(!1),"saved"},[S,$,J,y,A,l,a,c]);o.useImperativeHandle(t,()=>({requestNavigation:e=>{eU?(eG.current=e,ee("unsaved"),Z(!0)):e()}}),[eU]);let eX=(0,o.useCallback)(()=>{l?(rn.info('handleDelete: Deleting flow "'.concat(l.name,'" (ID: ').concat(l.id,")")),i(l.id)):rn.warn("handleDelete: Attempted to delete flow but no initialFlow is available")},[l,i]),eY=(0,o.useCallback)(e=>{rn.info("Applying AI-improved flow to the canvas",{flowId:e.flow.id,attempts:e.attempts,errors:e.errorCount,warnings:e.warningCount}),eS(!1),j(e.flow.nodes||[]),C(e$(e.flow.edges||[])),k(e.flow.name),_(e.flow.description||""),B(eq(e.flow.name)),eH(!0);let t=e.installedServers.filter(e=>!e.alreadyExisted),r=t.length>0?" Installed MCP server(s): ".concat(t.map(e=>e.name).join(", "),"."):"";e.errorCount>0?eT({severity:"warning",message:"Flow revised with ".concat(e.errorCount," error(s) and ").concat(e.warningCount," warning(s) — use the Check button, fix, then Save.").concat(r)}):e.warningCount>0?eT({severity:"info",message:"Flow revised with ".concat(e.warningCount," warning(s) — review the changes, then Save to keep them.").concat(r)}):eT({severity:"success",message:"Flow revised — review the changes (Undo reverts them), then Save to keep them.".concat(r)})},[e$]),eZ=(0,o.useCallback)(e=>{var t,r,n,o,l;rn.info("Restoring an archived flow version to the canvas",{flowId:e.id,nodes:null!=(n=null==(t=e.nodes)?void 0:t.length)?n:0,edges:null!=(o=null==(r=e.edges)?void 0:r.length)?o:0}),eE(!1),j(e.nodes||[]),C(e$(e.edges||[])),k(e.name),_(e.description||""),X(null!=(l=e.unattended)&&l),B(eq(e.name)),eH(!0),eT({severity:"info",message:"Restored an earlier version to the canvas — review it (Undo reverts), then Save to keep it."})},[e$]),eQ=(0,o.useCallback)(()=>{eM(null);let{flow:e,changes:t}=function(e){var t,r,n,o,l,a,s,i;let d=(null!=(t=null==e?void 0:e.nodes)?t:[]).map(e=>{var t;return{...e,position:{...null!=(t=e.position)?t:{x:0,y:0}},data:{...e.data}}}),c=[...null!=(r=null==e?void 0:e.edges)?r:[]],u={...e,nodes:d,edges:c},p=[],h=function(e,t){let r=e.filter(e=>"mcp"!==e.type&&"resource"!==e.type&&"string"==typeof e.id),n=new Map(r.map(e=>[e.id,e])),o=new Map,l=new Map,a=new Set;for(let e of r)o.set(e.id,0),l.set(e.id,0);let s=(e,t)=>{var r,n;a.add("".concat(e,"->").concat(t)),l.set(e,(null!=(r=l.get(e))?r:0)+1),o.set(t,(null!=(n=o.get(t))?n:0)+1)};for(let e of t)n.has(e.from)&&n.has(e.to)&&e.from!==e.to&&(s(e.from,e.to),e.bidirectional&&s(e.to,e.from));let i=[];for(let e of[...r].sort((e,t)=>e.y-t.y||e.x-t.x)){let t=i[i.length-1];t&&70>=Math.abs(e.y-t[0].y)?t.push(e):i.push([e])}let d=new Map;i.forEach((e,t)=>e.forEach(e=>d.set(e.id,t)));let c=new Map;for(let e=1;e<i.length;e++){let t=i[e],r=t.filter(e=>"subflow"===e.type);if(r.length>=2&&r.length===t.length){let t=i[e-1];if(1===t.length&&"process"===t[0].type)for(let e of r)c.set(e.id,t[0].id)}}let u=[],p=(e,t)=>{var r;if(e===t||a.has("".concat(e,"->").concat(t)))return!1;let o=n.get(e),s=n.get(t);return!!o&&!!s&&null===(0,re.vC)(o.type,rt(o.type).source,s.type,rt(s.type).target)&&("subflow"!==o.type||!((null!=(r=l.get(e))?r:0)>=1))},h=(e,t,r,n)=>{u.push({from:e,to:t,bidirectional:r,reason:n}),s(e,t),r&&s(t,e)},f=e=>{var t;let r=null!=(t=d.get(e.id))?t:0;for(let t=r-1;t>=0;t--){let r=i[t].filter(t=>t.id!==e.id&&"finish"!==t.type&&!c.has(t.id));if(0!==r.length){if(1===r.length)return r[0];return r.reduce((t,r)=>Math.abs(r.x-e.x)<Math.abs(t.x-e.x)?r:t)}}return null};for(let e of i)for(let t of e){var m;if("start"===t.type||(null!=(m=o.get(t.id))?m:0)>0)continue;let e=c.get(t.id);if(e){p(e,t.id)&&h(e,t.id,!0,"auto-bidirectional-subflow");continue}let r=f(t);r&&p(r.id,t.id)&&h(r.id,t.id,!1,"auto-connected")}let g=r.filter(e=>"start"===e.type),x=()=>r.filter(e=>{var t;return"start"!==e.type&&"finish"!==e.type&&!c.has(e.id)&&(null!=(t=o.get(e.id))?t:0)===0}),v=null;if(0===g.length){let e=x();if(e.length>0)v={targets:e.map(e=>e.id)};else{let e=r.filter(e=>"finish"!==e.type).sort((e,t)=>e.y-t.y)[0];e&&(v={targets:[e.id]})}}else{let e=g[0];for(let t of x())p(e.id,t.id)&&h(e.id,t.id,!1,"auto-connected")}let w=r.filter(e=>"finish"===e.type),b=()=>r.filter(e=>{var t;return"start"!==e.type&&"finish"!==e.type&&!c.has(e.id)&&(null!=(t=l.get(e.id))?t:0)===0}),y=null;if(0===w.length){let e=b();e.length>0&&(y={sources:e.map(e=>e.id)})}else{let e=w[0];for(let t of b())p(t.id,e.id)&&h(t.id,e.id,!1,"auto-connected")}return{addEdges:u,addStart:v,addFinish:y}}(d.filter(e=>"mcp"!==rr(e)&&"resource"!==rr(e)).map(e=>{var t,r,n,o;return{id:e.id,type:rr(e),x:null!=(n=null==(t=e.position)?void 0:t.x)?n:0,y:null!=(o=null==(r=e.position)?void 0:r.y)?o:0}}),c.filter(e=>!function(e){var t;let r=null==(t=e.data)?void 0:t.edgeType;return"mcp"===r||"resource"===r}(e)).map(e=>{var t;return{from:e.source,to:e.target,bidirectional:(null==(t=e.data)?void 0:t.bidirectional)===!0}})),f=new Map(d.map(e=>[e.id,e])),m=(e,t,r)=>{let n=f.get(e),o=f.get(t);n&&o&&c.push((0,t9.pX)(n,o,r))};for(let e of h.addEdges)m(e.from,e.to,e.bidirectional),p.push({code:e.reason,message:function(e){switch(e){case"auto-connected":return"Connected a disconnected step into the flow.";case"auto-bidirectional-subflow":return"Wired a parallel subflow with a two-way handoff to its orchestrator.";case"auto-added-start":return"Added a Start node.";case"auto-added-finish":return"Added a Finish node."}}(e.reason),nodeId:e.to});if(h.addStart){let e=h.addStart.targets.map(e=>f.get(e)).filter(Boolean).reduce((e,t)=>!e||t.position.y<e.position.y?t:e,null),t=(s={x:null!=(n=null==e?void 0:e.position.x)?n:250,y:(null!=(o=null==e?void 0:e.position.y)?o:150)-150},{id:(0,D.A)(),type:"start",position:s,data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}});for(let e of(d.unshift(t),f.set(t.id,t),h.addStart.targets))m(t.id,e,!1);p.push({code:"auto-added-start",message:"Added a Start node connected to ".concat(h.addStart.targets.length," entry step(s)."),nodeId:t.id})}if(h.addFinish){let e=h.addFinish.sources.map(e=>f.get(e)).filter(Boolean).reduce((e,t)=>!e||t.position.y>e.position.y?t:e,null),t=(i={x:null!=(l=null==e?void 0:e.position.x)?l:250,y:(null!=(a=null==e?void 0:e.position.y)?a:0)+150},{id:(0,D.A)(),type:"finish",position:i,data:{label:"Finish Node",type:"finish",properties:{}}});for(let e of(d.push(t),f.set(t.id,t),h.addFinish.sources))m(e,t.id,!1);p.push({code:"auto-added-finish",message:"Added a Finish node connected from ".concat(h.addFinish.sources.length," final step(s)."),nodeId:t.id})}return{flow:u,changes:p}}({id:(null==l?void 0:l.id)||"",name:S,description:$,unattended:J,nodes:y,edges:A,folder:null==l?void 0:l.folder,favorite:null==l?void 0:l.favorite});if(0===t.length)return void eT({severity:"info",message:"Nothing to repair — the flow is already wired up."});rn.info("Applying static auto-repair to the canvas (".concat(t.length," change(s))")),j(e.nodes||[]),C(e$(e.edges||[])),eH(!0);let r=t.filter(e=>"auto-added-start"===e.code||"auto-added-finish"===e.code).length,n=t.length-r,o=[];t.some(e=>"auto-added-start"===e.code)&&o.push("added a Start node"),t.some(e=>"auto-added-finish"===e.code)&&o.push("added a Finish node"),n>0&&o.push("connected ".concat(n," step(s)")),eT({severity:"success",message:"Repaired the flow — ".concat(o.join(", "),". Review the changes (Undo reverts them), then Save to keep them.")})},[l,S,$,y,A,e$]),e0=(0,o.useCallback)(()=>{eM(null),eF("Repair this flow's wiring so it is runnable, without changing any node's prompt, model, or servers: add a Start node if one is missing (connected to the first step), add a Finish node if one is missing (connected from the last step), and connect any disconnected process/subflow nodes. Read node placement as intent: nodes stacked top-to-bottom are sequential steps, and nodes on the same horizontal line are parallel branches under a shared parent above them."),eS(!0)},[]),e1=(0,o.useCallback)((e,t)=>{rn.debug('handleCopyFlow: Copying flow "'.concat(e.name,'" to "').concat(t,'"'));let r={id:(0,D.A)(),name:t,description:e.description,unattended:e.unattended,nodes:e.nodes,edges:e.edges,folder:e.folder,favorite:e.favorite};rn.info('handleCopyFlow: Created copy of flow "'.concat(e.name,'" with new name "').concat(t,'" (').concat(e.nodes.length," nodes, ").concat(e.edges.length," edges)")),a(r)},[a]),e2=()=>{let e=eG.current;eG.current=null,e&&e()},e5=()=>{eG.current=null,Z(!1),ee("none"),er(""),eo(null)},e6=()=>{let e=eq(et);if(e)return void eo(e);"duplicate"===Q?l&&e1(l,et):"rename"===Q&&(a({id:(null==l?void 0:l.id)||(0,D.A)(),name:et,description:$,unattended:J,nodes:y,edges:A,folder:null==l?void 0:l.folder,favorite:null==l?void 0:l.favorite}),eH(!1),e2()),e5()},e3=eW>0,e4=eW<eR.length-1,e8=(0,o.useCallback)(()=>{if(e3){rn.debug("handleUndo: Performing undo operation, moving from history index ".concat(eW," to ").concat(eW-1)),eO(!0);let e=eW-1,t=eR[e];j(t.nodes),C(t.edges),eL(e),rn.info("handleUndo: Restored flow state to previous version (".concat(t.nodes.length," nodes, ").concat(t.edges.length," edges)"))}},[eR,eW,e3]),e7=(0,o.useCallback)(()=>{if(e4){rn.debug("handleRedo: Performing redo operation, moving from history index ".concat(eW," to ").concat(eW+1)),eO(!0);let e=eW+1,t=eR[e];j(t.nodes),C(t.edges),eL(e),rn.info("handleRedo: Restored flow state to next version (".concat(t.nodes.length," nodes, ").concat(t.edges.length," edges)"))}},[eR,eW,e4]),e9=(0,o.useCallback)(e=>{for(let t of e)"position"===t.type&&(eV.current=!0===t.dragging);j(t=>(0,R._0)(e,t))},[]),te=(0,o.useCallback)((e,t)=>{C(r=>r.map(r=>{var n;if(r.id!==e)return r;let o={...null!=(n=r.data)?n:{}};return t?o.condition=t:delete o.condition,{...r,data:o}})),rn.info("handleSaveEdgeCondition: ".concat(t?"set":"cleared"," condition on edge ").concat(e))},[]),tt=(0,o.useCallback)(e=>{rn.debug("onEdgesChange: Processing ".concat(e.length," edge changes")),e.forEach(e=>{"remove"===e.type?rn.info("onEdgesChange: Edge ".concat(e.id," removed")):"select"===e.type&&rn.debug("onEdgesChange: Edge ".concat(e.id," selection changed to ").concat(e.selected))}),C(t=>(0,R.zW)(e,t))},[]),tr=(0,o.useRef)(null),[tn,to]=(0,o.useState)(null),tl=(0,o.useCallback)(()=>{rn.debug("handleAutoAlign: auto-arranging flow nodes"),j(e=>(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{direction:n="TB",rankSep:o=120,nodeSep:l=80,mcpOffsetX:a=350,mcpStackY:s=120}=r,i=e.filter(e=>"mcp"===e.type),d=e.filter(e=>"resource"===e.type),c=e.filter(e=>"mcp"!==e.type&&"resource"!==e.type);if(c.length<=1)return e;let u=new Set(c.map(e=>e.id)),p=new Map;for(let e of(c.forEach(e=>p.set(e.id,new Set)),t))!(O(e)||U(e))&&e.source!==e.target&&u.has(e.source)&&u.has(e.target)&&p.get(e.source).add(e.target);let h=new Map;c.forEach(e=>h.set(e.id,0));let f=c.length;for(let e=0;e<f;e++){let e=!1;for(let[t,r]of p){let n=h.get(t)+1;for(let t of r)h.get(t)<n&&(h.set(t,n),e=!0)}if(!e)break}let m=new Map;for(let e of c){let t=h.get(e.id),r=m.get(t);r?r.push(e):m.set(t,[e])}let g=[...m.keys()].sort((e,t)=>e-t),x=new Map,v=0;for(let e of g){let t=m.get(e),r=0,a=0;for(let e of t){let{width:t,height:o}=function(e){var t,r,n,o;let l=e.measured;return{width:null!=(r=null!=(t=null==l?void 0:l.width)?t:e.width)?r:240,height:null!=(o=null!=(n=null==l?void 0:l.height)?n:e.height)?o:80}}(e);"TB"===n?(x.set(e.id,{x:r,y:v}),r+=t+l,a=Math.max(a,o)):(x.set(e.id,{x:v,y:r}),r+=o+l,a=Math.max(a,t))}v+=a+o}let w=(e,r,n)=>{let o=new Set(e.map(e=>e.id)),l=new Map;for(let e of t){let t,n;if(!r(e))continue;let a=o.has(e.source),s=o.has(e.target);a&&!s?(t=e.source,n=e.target):s&&!a&&(t=e.target,n=e.source),t&&n&&x.has(n)&&!l.has(t)&&l.set(t,n)}let a=new Map;for(let t of e){var i;let e=l.get(t.id);if(!e)continue;let r=x.get(e),o=null!=(i=a.get(e))?i:0;a.set(e,o+1),x.set(t.id,{x:r.x+n,y:r.y+o*s})}};return w(i,O,a),w(d,U,-a),e.map(e=>{let t=x.get(e.id);return t?{...e,position:t}:e})})(e,A)),requestAnimationFrame(()=>null==tn?void 0:tn.fitView({padding:.2}))},[A,tn]),ta=(0,o.useCallback)((e,t)=>{rn.debug("handleNodeUpdate: Updating node ".concat(e," properties")),j(r=>{let n=r.map(r=>r.id===e?(rn.info("handleNodeUpdate: Node ".concat(e," properties updated")),{...r,data:t}):r);return function(e,t,r){let n=new Map(e.map(e=>[e.id,e])),o=new Map(t.map(e=>[e.id,e])),l=!1;for(let[e,t]of o){let r=n.get(e);if(r&&r.data.label!==t.data.label){l=!0;break}}return l?t.map(e=>{var t;let l=null==(t=e.data.properties)?void 0:t.promptTemplate;if("string"!=typeof l||!l)return e;let a=function(e,t){let r=[];for(let l of t){var n,o;!("string"==typeof(null==(n=l.data)?void 0:n.edgeType)&&(l.data.edgeType.includes("mcp")||"resource"===l.data.edgeType))&&(l.source===e?r.push(l.target):l.target===e&&(null==(o=l.data)?void 0:o.bidirectional)&&r.push(l.source))}return[...new Set(r)]}(e.id,r);if(0===a.length)return e;let s=[],i=[];for(let e of a){let t=o.get(e);if(!t)continue;let r=n.get(e)||t;s.push(V(r)),i.push(V(t))}if(0===i.length)return e;let d=(0,H.E9)(s),c=(0,H.E9)(i),u=new Map;for(let e of a){let t=d.get(e),r=c.get(e);t&&r&&t!==r&&u.set(t,r)}if(0===u.size)return e;let p=function(e,t){if(!e||0===t.size)return e;let r=(0,G.A$)(e);if(0===r.length)return e;let n="",o=0,l=!1;for(let a of r){n+=e.slice(o,a.index);let r="tool"===a.kind&&"handoff"===a.server?t.get(a.name):void 0;r?(n+=(0,G.X8)("tool","handoff",r),l=!0):n+=a.fullMatch,o=a.index+a.fullMatch.length}return n+=e.slice(o),l?n:e}(l,u);return p===l?e:{...e,data:{...e.data,properties:{...e.data.properties,promptTemplate:p}}}}):t}(r,n,A)}),es(!1),ed(!1),eu(!1),eh(!1),em(!1),ex(!1),ew(!1),ey(null),rn.debug("handleNodeUpdate: Closed property modals")},[A]),ts=(0,o.useCallback)(async(e,t)=>{var r;let n=y.find(t=>t.id===e);if(!n)return void rn.warn("handleConnectMcpServer: process node ".concat(e," not found"));let o=[];try{let e=await z.S.listServerTools(t);!e.error&&Array.isArray(e.tools)&&(o=e.tools.map(e=>e.name))}catch(e){rn.warn("handleConnectMcpServer: could not load tools for ".concat(t),e)}let l=A.filter(t=>{var r;return(null==(r=t.data)?void 0:r.edgeType)==="mcp"&&(t.source===e||t.target===e)}).length,a=W.g.createNode("mcp",{x:n.position.x+350,y:n.position.y+120*l});a.data.label=t,a.data.properties={...null!=(r=a.data.properties)?r:{},boundServer:t,enabledTools:o};let s=(0,L.wn)({source:e,sourceHandle:"process-right-mcp",target:a.id,targetHandle:"mcp-left"},[...y,a]);j(e=>[...e,a]),C(e=>[...e,s]),rn.info('Connected MCP server "'.concat(t,'" to process node ').concat(e))},[y,A]),ti=(0,o.useCallback)(e=>{rn.debug("Opening properties for node:",e),ey(e),"mcp"===e.data.type?ed(!0):"start"===e.data.type?eu(!0):"finish"===e.data.type?eh(!0):"subflow"===e.data.type?em(!0):"resource"===e.data.type?ex(!0):"signal"===e.data.type?ew(!0):es(!0)},[]),td=(0,o.useCallback)(e=>{rn.debug("onDrop: Node dropped on canvas"),e.preventDefault();let t=e.dataTransfer.getData("application/reactflow");if(rn.debug("onDrop: Node type from data transfer: ".concat(t)),!t||!tn)return void rn.debug("onDrop: Missing required data - type: ".concat(!!t,", reactFlowInstance: ").concat(!!tn));let r=tn.screenToFlowPosition({x:e.clientX,y:e.clientY});rn.debug("onDrop: Calculated position: (".concat(r.x,", ").concat(r.y,")"));let n=W.g.createNode(t,r);rn.info("onDrop: Created new ".concat(t," node with ID: ").concat(n.id)),j(e=>[...e.map(e=>({...e,selected:!1})),{...n,selected:!0}]),ti(n),rn.debug("onDrop: Opened properties modal for new node: ".concat(n.id))},[tn,ti]),tc=(0,o.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},[]),tp=(0,o.useCallback)(e=>{rn.debug("onInit: ReactFlow instance initialized"),to(e)},[]);return(0,n.jsxs)(ro,{children:[(0,n.jsx)(el,{}),(0,n.jsx)(R.Ln,{children:(0,n.jsxs)(ra,{children:[(0,n.jsxs)(rl,{elevation:1,children:[(0,n.jsx)(w.A,{size:"small",label:"Flow Name",value:S,onChange:e=>{let t=e.target.value;k(t),B(eq(t))},sx:{minWidth:300},error:!!E,helperText:E}),(0,n.jsx)(w.A,{size:"small",label:"Description",value:$,onChange:e=>{_(e.target.value),eH(!0)},multiline:!0,maxRows:3,sx:{minWidth:300,flex:1},placeholder:"Optional — shown on the flow card"}),(0,n.jsx)(p.A,{arrow:!0,title:"Unattended: if a step's model stops without handing off, the engine drives the conversation forward to the next step instead of silently ending the run. Recommended for scheduled/headless flows; leave off for interactive chat.",children:(0,n.jsx)(T.A,{control:(0,n.jsx)(I.A,{size:"small",checked:J,onChange:e=>{X(e.target.checked),eH(!0)}}),label:"Unattended",sx:{whiteSpace:"nowrap",ml:.5}})}),(0,n.jsx)(d.A,{variant:"contained",color:"primary",onClick:eJ,startIcon:(0,n.jsx)(t1.A,{}),disabled:!!E,children:"Save Flow"}),(0,n.jsx)(ez,{nodes:y,edges:A}),(0,n.jsx)(p.A,{title:"Auto-arrange nodes into a clean layout",children:(0,n.jsx)("span",{children:(0,n.jsx)(d.A,{variant:"outlined",color:"primary",onClick:tl,startIcon:(0,n.jsx)(q.A,{}),disabled:y.length<=1,children:"Auto-Align"})})}),(0,n.jsx)(p.A,{title:"Add a missing Start/Finish and connect disconnected nodes",children:(0,n.jsxs)(M.A,{variant:"outlined",color:"primary",disabled:0===y.length,children:[(0,n.jsx)(d.A,{onClick:eQ,startIcon:(0,n.jsx)(t3.A,{}),children:"Repair"}),(0,n.jsx)(d.A,{size:"small",onClick:e=>eM(e.currentTarget),"aria-label":"Repair options",children:(0,n.jsx)(t4.A,{})})]})}),(0,n.jsxs)(N.A,{anchorEl:eI,open:!!eI,onClose:()=>eM(null),children:[(0,n.jsx)(F.A,{onClick:eQ,children:"Repair automatically (no model)"}),(0,n.jsx)(F.A,{onClick:e0,children:"Repair with AI…"})]}),l&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.A,{variant:"outlined",color:"secondary",onClick:()=>{eF(""),eS(!0)},startIcon:(0,n.jsx)(t6.A,{}),"data-tour":"improve-flow",children:"AI-Improve"}),(0,n.jsx)(p.A,{title:"Browse, preview, and restore earlier saved versions of this flow",children:(0,n.jsx)(d.A,{variant:"outlined",color:"primary",onClick:()=>eE(!0),startIcon:(0,n.jsx)(tu.A,{}),children:"History"})}),(0,n.jsx)(d.A,{variant:"outlined",color:"primary",onClick:()=>{ee("duplicate"),er("".concat(l.name,"_copy")),Z(!0)},children:"Copy Flow"}),(0,n.jsx)(d.A,{variant:"outlined",color:"error",onClick:eX,children:"Delete Flow"})]}),(0,n.jsx)(P.A,{orientation:"vertical",flexItem:!0}),(0,n.jsx)(u.A,{onClick:e8,disabled:!e3,color:"primary",size:"small",children:(0,n.jsx)(t2.A,{})}),(0,n.jsx)(u.A,{onClick:e7,disabled:!e4,color:"primary",size:"small",children:(0,n.jsx)(t5.A,{})}),(0,n.jsx)(s.default,{sx:{flex:1}})]}),(0,n.jsx)(h.A,{in:!!ek,unmountOnExit:!0,children:ek&&(0,n.jsx)(f.A,{severity:ek.severity,onClose:()=>eT(null),sx:{mb:1},children:ek.message})}),(0,n.jsx)(s.default,{sx:{flex:1,position:"relative"},children:(0,n.jsx)(K.Ay,{ref:tr,nodes:y,edges:A,onNodesChange:e9,onEdgesChange:tt,onDrop:td,onDragOver:tc,onInit:tp,reactFlowWrapper:tr,onEditNode:ti,onEditEdge:e=>eA(e)})})]})}),(0,n.jsx)(tT,{open:ea,node:eb,onClose:()=>es(!1),onSave:ta,flowEdges:A,flowNodes:y,flowId:null==l?void 0:l.id,onConnectMcpServer:e=>{eb&&ts(eb.id,e)}}),(0,n.jsx)(tF,{open:ei,node:eb,onClose:()=>ed(!1),onSave:ta}),(0,n.jsx)(tP,{open:ec,node:eb,onClose:()=>eu(!1),onSave:ta}),(0,n.jsx)(tE,{open:ep,node:eb,onClose:()=>eh(!1),onSave:ta}),(0,n.jsx)(tO,{open:ef,node:eb,onClose:()=>em(!1),onSave:ta,flowId:null==l?void 0:l.id}),(0,n.jsx)(t_,{open:eg,node:eb,onClose:()=>ex(!1),onSave:ta,flowNodes:y}),(0,n.jsx)(tq,{open:ev,node:eb,onClose:()=>ew(!1),onSave:ta}),(0,n.jsx)(tW,{open:!!ej,edge:ej,onClose:()=>eA(null),onSave:te}),(0,n.jsx)(t0,{open:eP,flowId:null==l?void 0:l.id,onClose:()=>eE(!1),onRestore:eZ}),(0,n.jsx)(t7,{open:eC,onClose:()=>eS(!1),currentFlow:{id:(null==l?void 0:l.id)||"",name:S,description:$,unattended:J,nodes:y,edges:A},onImproved:eY,initialDescription:eN}),(0,n.jsxs)(m.A,{open:Y,onClose:e5,children:[(0,n.jsx)(g.A,{children:"duplicate"===Q?"Copy Flow":"rename"===Q?"Rename Flow":"Unsaved Changes"}),(0,n.jsx)(x.A,{children:"unsaved"===Q?(0,n.jsx)(v.A,{children:"You have unsaved changes in the current flow. What would you like to do?"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.A,{children:"duplicate"===Q?"Enter a name for the copied flow:":"You are changing the name of this flow. Do you want to rename it or create a copy with the new name?"}),(0,n.jsx)(w.A,{autoFocus:!0,margin:"dense",label:"Flow Name",type:"text",fullWidth:!0,value:et,onChange:e=>{let t=e.target.value;er(t),eo(eq(t))},error:!!en,helperText:en,sx:{mt:2}})]})}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:e5,children:"Cancel"}),"unsaved"===Q&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.A,{onClick:()=>{eH(!1),e2(),e5()},color:"error",children:"Discard Changes"}),(0,n.jsx)(d.A,{onClick:()=>{let e=eJ();"saved"===e?(e2(),e5()):"invalid-name"===e&&e5()},variant:"contained",color:"primary",children:"Save Changes"})]}),"rename"===Q&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.A,{onClick:()=>{let e=eq(et);if(e)return void eo(e);l&&e1(l,et),e5()},children:"Copy"}),(0,n.jsx)(d.A,{onClick:e6,variant:"contained",color:"primary",disabled:!!en,children:"Rename"})]}),"duplicate"===Q&&(0,n.jsx)(d.A,{onClick:e6,variant:"contained",color:"primary",disabled:!!en,children:"Copy"})]})]})]})});rs.displayName="FlowBuilder";let ri=(0,E.h)("frontend/components/Flow/FlowManager/GenerateFlowDialog"),rd=e=>{let{open:t,onClose:r,onGenerated:l}=e,[a,i]=(0,o.useState)(""),[c,u]=(0,o.useState)([]),[p,h]=(0,o.useState)(""),[y,j]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[k,I]=(0,o.useState)(2),[M,N]=(0,o.useState)(!1),[P,E]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!t)return;let e=!1;return eD.N.loadModels().then(t=>{e||(u(t),h(e=>{var r,n;return t.some(t=>t.id===e)?e:null!=(n=null==(r=t[0])?void 0:r.id)?n:""}))}).catch(t=>{ri.warn("Failed to load models for the generate dialog",t),e||E("Could not load your models. Configure a model first.")}),()=>{e=!0}},[t]);let R=(0,o.useCallback)(()=>{M||(E(null),r())},[M,r]),D=(0,o.useCallback)(async()=>{E(null),N(!0);try{let e=await W.g.generateFlow(a.trim(),p,{allowInstall:y,allowSubflows:C,...C?{maxDepth:k}:{}});if(!e.success)return void E(e.error);ri.info("Draft flow generated",{flowId:e.flow.id,flowCount:e.flows.length,attempts:e.attempts,errors:e.validation.errorCount,warnings:e.validation.warningCount,installedServers:e.installedServers.length}),i(""),l({flow:e.flow,flows:e.flows.map(e=>e.flow),rootFlowId:e.rootFlowId,errorCount:e.validation.errorCount,warningCount:e.validation.warningCount,attempts:e.attempts,installedServers:e.installedServers})}finally{N(!1)}},[a,p,y,C,k,l]),z=!M&&a.trim().length>0&&!!p;return(0,n.jsxs)(m.A,{open:t,onClose:R,maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(g.A,{children:"Generate a flow"}),(0,n.jsxs)(x.A,{children:[(0,n.jsx)(v.A,{sx:{mb:2},children:"Describe what the flow should do — which steps, which tools, what the result is. The generated flow opens in the builder as a draft for you to review before saving."}),P&&(0,n.jsx)(f.A,{severity:"error",sx:{mb:2},onClose:()=>E(null),children:P}),(0,n.jsx)(w.A,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:4,label:"What should this flow do?",placeholder:"e.g. Research a topic on the web, then summarize the findings as bullet points",value:a,onChange:e=>i(e.target.value),disabled:M,sx:{mb:2}}),(0,n.jsxs)(tb.A,{fullWidth:!0,disabled:M||0===c.length,children:[(0,n.jsx)(ty.A,{id:"generate-flow-model-label",children:"Generator model"}),(0,n.jsx)(tj.A,{labelId:"generate-flow-model-label",label:"Generator model",value:p,onChange:e=>h(e.target.value),children:c.map(e=>{var t;return(0,n.jsx)(F.A,{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),(0,n.jsx)(T.A,{sx:{mt:2},control:(0,n.jsx)(tc.A,{checked:y,onChange:e=>j(e.target.checked),disabled:M}),label:"Let the generator install MCP servers it needs (self-improve)"}),(0,n.jsx)(T.A,{sx:{mt:1,display:"flex"},control:(0,n.jsx)(tc.A,{checked:C,onChange:e=>S(e.target.checked),disabled:M}),label:"Allow multi-level flows (auto-generate nested subflows)"}),C&&(0,n.jsxs)(s.default,{sx:{mt:1,ml:4,display:"flex",flexDirection:"column",gap:1},children:[(0,n.jsxs)(tb.A,{sx:{maxWidth:220},size:"small",disabled:M,children:[(0,n.jsx)(ty.A,{id:"generate-flow-depth-label",children:"Max nesting depth"}),(0,n.jsxs)(tj.A,{labelId:"generate-flow-depth-label",label:"Max nesting depth",value:k,onChange:e=>I(Number(e.target.value)),children:[(0,n.jsx)(F.A,{value:1,children:"1 level"}),(0,n.jsx)(F.A,{value:2,children:"2 levels"}),(0,n.jsx)(F.A,{value:3,children:"3 levels"})]})]}),(0,n.jsx)(f.A,{severity:"info",children:"The generator can design subflows that are themselves generated (up to a few flows total). This is slower and uses more tokens. You review the whole bundle before anything is saved."})]}),y&&(0,n.jsxs)(f.A,{severity:"warning",sx:{mt:1},children:["The generator may ",(0,n.jsx)("strong",{children:"download, install, and run third-party MCP servers"})," from the public registry on this machine. It prefers servers that need no API keys, but anything it installs executes real code with your user's permissions. The ",(0,n.jsx)("strong",{children:"exact command and arguments"})," of every install are recorded (audited) before it runs, and each installed server is listed in the post-generation summary so you can review — and remove (on the MCP page) — exactly what was added."]}),M&&(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1.5,mt:2},children:[(0,n.jsx)(es.default,{size:20}),(0,n.jsx)(v.A,{children:y?"Generating… the model may search the marketplace and install servers (this can take a few minutes).":"Generating… the model designs the flow and FLUJO checks it (this can take up to a minute)."})]})]}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:R,disabled:M,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:D,variant:"contained",color:"primary",startIcon:(0,n.jsx)(A.A,{}),disabled:!z,children:"Generate"})]})]})};var rc=r(60530),ru=r(15712),rp=r(64419),rh=r(98405),rf=r(7302),rm=r(70822),rg=r(28466),rx=r(3986),rv=r(94885),rw=r(15686),rb=r(91665),ry=r(22573),rj=r(38459),rA=r(88377),rC=r(97104),rS=r(64598),rk=r(23201);let rT=(0,E.h)("components/Flow/FlowDashboard/FlowDashboard");function rI(e,t){return e+Math.round(255*t).toString(16).padStart(2,"0")}let rM=e=>{let{flows:t,selectedFlow:r,onSelectFlow:l,onDeleteFlow:c,onCopyFlow:p,onEditFlow:h,onOpenInChat:f,onCreateFlow:m,onSetFolder:g,onToggleFavorite:x,isLoading:v=!1}=e,[b,y]=(0,o.useState)(""),[A,C]=(0,rC.Xk)("flujo-ui:flows:sort","name-asc"),[S,T]=(0,rC.Xk)("flujo-ui:flows:view","grid"),[I,M]=(0,o.useState)(null),[E,R]=(0,rC.Xk)("flujo-ui:flows:group","none"),[D,W]=(0,o.useState)(null),[z,L]=(0,rC.Xk)("flujo-ui:flows:collapsed",[]),B=(0,o.useMemo)(()=>new Set(z),[z]),[O,U]=(0,o.useState)({});(0,o.useEffect)(()=>{let e=!1;return(async()=>{let t={};try{let e=await fetch("/api/model");if(e.ok){let r=await e.json();Array.isArray(r)&&(t.models=r)}}catch(e){rT.warn("Could not load models for flow badges",e)}try{let e=await fetch("/api/mcp/servers");if(e.ok){let r=await e.json();Array.isArray(r)&&(t.servers=r.map(e=>({name:e.name,status:e.disabled?"disabled":void 0})))}}catch(e){rT.warn("Could not load servers for flow badges",e)}e||U(t)})(),()=>{e=!0}},[]);let H=(0,o.useMemo)(()=>{let e={};for(let r of t)try{e[r.id]=eR(r,O)}catch(e){rT.warn("Failed to validate flow for badge",{flowId:r.id,error:e})}return e},[t,O]),G=(0,a.A)(),V=(0,ru.A)(G.breakpoints.down("sm")),K=(0,ru.A)(G.breakpoints.down("md")),$=()=>{M(null)},_=e=>{C(e),$()},q=e=>{R(e),W(null)},J=(0,o.useMemo)(()=>{rT.debug("Filtering and sorting flows",{searchTerm:b,sortOption:A});let e=t;if(""!==b.trim()){let r=b.toLowerCase();e=t.filter(e=>e.name.toLowerCase().includes(r))}return(0,rA.NP)(e,A)},[t,b,A]),{ref:X,showBackToTop:Y,scrollToTop:Z}=(0,rS.R)("flujo-ui:scroll:flows",{deps:[v,J.length]}),Q=(0,o.useMemo)(()=>(0,rj.yF)(t,e=>e.folder),[t]),ee=(0,o.useMemo)(()=>"folder"===E?(0,rj.Je)(J,e=>e.folder):"sort"===E?(0,rj.Az)(J,e=>(0,rA.ts)(e,A)):[],[E,J,A]),et=e=>(0,n.jsx)(eL.Ay,{container:!0,spacing:2,children:e.map(e=>(0,n.jsx)(eL.Ay,{item:!0,xs:12,sm:"compact"===S?12:6,md:"compact"===S?12:3==("compact"===S||V?1:K?2:3)?4:6,children:(0,n.jsx)(tL.A,{flow:e,selected:r===e.id,onSelect:l,onDelete:c,onCopy:p,onEdit:h,onOpenInChat:f,onSetFolder:g,onToggleFavorite:x,folders:Q,validation:H[e.id]})},e.id))});return(0,n.jsxs)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,n.jsx)(k.A,{elevation:1,sx:{mb:2,p:1},children:(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:1,alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[(0,n.jsx)(w.A,{placeholder:"Search flows...",variant:"outlined",size:"small",fullWidth:!0,value:b,onChange:e=>{y(e.target.value)},InputProps:{startAdornment:(0,n.jsx)(e2.A,{position:"start",children:(0,n.jsx)(e8.A,{fontSize:"small"})})},sx:{maxWidth:{sm:300}}}),(0,n.jsxs)(s.default,{sx:{display:"flex",gap:1,alignItems:"center"},children:[(0,n.jsxs)(s.default,{sx:{display:"flex",backgroundColor:G.palette.background.default,borderRadius:1,border:"1px solid ".concat(G.palette.divider),overflow:"hidden"},children:[(0,n.jsx)(u.A,{size:"small",onClick:()=>T("grid"),color:"grid"===S?"primary":"default",sx:{borderRadius:0,backgroundColor:"grid"===S?rI(G.palette.primary.main,.1):"transparent"},children:(0,n.jsx)(rm.A,{fontSize:"small"})}),(0,n.jsx)(u.A,{size:"small",onClick:()=>T("compact"),color:"compact"===S?"primary":"default",sx:{borderRadius:0,backgroundColor:"compact"===S?rI(G.palette.primary.main,.1):"transparent"},children:(0,n.jsx)(rf.A,{fontSize:"small"})})]}),(0,n.jsx)(u.A,{size:"small",onClick:e=>W(e.currentTarget),color:"none"!==E?"primary":"default",sx:{border:"1px solid ".concat(G.palette.divider),backgroundColor:G.palette.background.default},title:"Group cards",children:(0,n.jsx)(rv.A,{fontSize:"small"})}),(0,n.jsx)(u.A,{size:"small",onClick:e=>{M(e.currentTarget)},sx:{border:"1px solid ".concat(G.palette.divider),backgroundColor:G.palette.background.default},children:(0,n.jsx)(rp.A,{fontSize:"small"})})]})]})}),(0,n.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",mb:2,px:1},children:[(0,n.jsxs)(i.default,{variant:"body2",color:"textSecondary",children:[J.length," of ",t.length," flows",b&&' matching "'.concat(b,'"')]}),(0,n.jsxs)(i.default,{variant:"body2",color:"textSecondary",children:["Sorted by: ","name-asc"===A?"Name (A-Z)":"name-desc"===A?"Name (Z-A)":"newest"===A?"Newest first":"oldest"===A?"Oldest first":"most-nodes"===A?"Most nodes":"Least nodes"]})]}),(0,n.jsx)(s.default,{ref:X,sx:{flex:1,overflow:"auto",px:1,pb:2},children:v?(0,n.jsx)(eL.Ay,{container:!0,spacing:2,children:Array(6).fill(0).map((e,t)=>(0,n.jsx)(eL.Ay,{item:!0,xs:12,sm:"compact"===S?12:6,md:"compact"===S?12:4,children:(0,n.jsx)(tL.o,{})},"skeleton-".concat(t)))}):J.length>0?"none"===E?et(J):ee.map(e=>(0,n.jsx)(ry.A,{label:e.label,count:e.items.length,expanded:!B.has(e.key),onToggle:()=>(e=>{L(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])})(e.key),showFolderIcon:"folder"===E,children:et(e.items)},e.key)):(0,n.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",p:4,backgroundColor:G.palette.background.paper,borderRadius:1,border:"1px dashed ".concat(G.palette.divider),height:"100%",minHeight:200},children:[(0,n.jsx)(i.default,{variant:"h6",gutterBottom:!0,color:"textSecondary",children:"No flows found"}),b?(0,n.jsxs)(i.default,{variant:"body2",color:"textSecondary",align:"center",children:["No flows match your search criteria.",(0,n.jsxs)(s.default,{component:"span",display:"block",mt:1,children:["Try a different search term or ",(0,n.jsx)(d.A,{size:"small",onClick:()=>y(""),children:"clear the search"})]})]}):(0,n.jsxs)(i.default,{variant:"body2",color:"textSecondary",align:"center",children:["Get started by creating your first flow.",m&&(0,n.jsx)(s.default,{component:"span",display:"block",mt:2,children:(0,n.jsx)(d.A,{variant:"contained",color:"primary",startIcon:(0,n.jsx)(j.A,{}),onClick:m,children:"Create New Flow"})})]})]})}),(0,n.jsxs)(N.A,{anchorEl:D,open:!!D,onClose:()=>W(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,n.jsxs)(F.A,{selected:"none"===E,onClick:()=>q("none"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rw.A,{fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:"No grouping"})]}),(0,n.jsxs)(F.A,{selected:"folder"===E,onClick:()=>q("folder"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rb.A,{fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:"By folder"})]}),(0,n.jsxs)(F.A,{selected:"sort"===E,onClick:()=>q("sort"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rv.A,{fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:"By sort setting"})]})]}),(0,n.jsxs)(N.A,{anchorEl:I,open:!!I,onClose:$,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,n.jsxs)(F.A,{onClick:()=>_("name-asc"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rg.A,{fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:"Name (A-Z)"})]}),(0,n.jsxs)(F.A,{onClick:()=>_("name-desc"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rg.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,n.jsx)(ec.A,{primary:"Name (Z-A)"})]}),(0,n.jsx)(P.A,{}),(0,n.jsxs)(F.A,{onClick:()=>_("newest"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rx.A,{fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:"Newest first"})]}),(0,n.jsxs)(F.A,{onClick:()=>_("oldest"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rx.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,n.jsx)(ec.A,{primary:"Oldest first"})]}),(0,n.jsx)(P.A,{}),(0,n.jsxs)(F.A,{onClick:()=>_("most-nodes"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rh.A,{fontSize:"small"})}),(0,n.jsx)(ec.A,{primary:"Most nodes"})]}),(0,n.jsxs)(F.A,{onClick:()=>_("least-nodes"),children:[(0,n.jsx)(ed.A,{children:(0,n.jsx)(rh.A,{fontSize:"small",sx:{transform:"scaleY(-1)"}})}),(0,n.jsx)(ec.A,{primary:"Least nodes"})]})]}),(0,n.jsx)(rk.A,{show:Y,onClick:Z})]})},rN=(0,E.h)("app/flows/page"),rF=()=>{var e;rN.debug("Rendering FlowsPage"),(0,a.A)();let t=(0,l.useRouter)(),[r,S]=(0,o.useState)([]),[k,T]=(0,o.useState)(null),[I,M]=(0,o.useState)(!0),[N,F]=(0,o.useState)(!1),P=(0,o.useRef)(null),[E,R]=(0,o.useState)(null),[z,L]=(0,o.useState)([]),[B,O]=(0,o.useState)(!1),[U,H]=(0,o.useState)(!1),[G,V]=(0,o.useState)(null),[K,$]=(0,o.useState)(""),[_,q]=(0,o.useState)(null),[J,X]=(0,o.useState)({open:!1,message:"",severity:"info"});(0,o.useEffect)(()=>{rN.info("Loading flows"),(async()=>{M(!0);try{let e=await W.g.loadFlows();rN.debug("Flows loaded successfully",{count:e.length}),S(e),k&&(e.some(e=>e.id===k)||(null==E?void 0:E.id)===k||(rN.warn("Previously selected flow no longer exists",{flowId:k}),T(null),F(!1),et("The previously selected flow is no longer available","warning")))}catch(e){rN.error("Error loading flows",e),et("Failed to load flows","error")}finally{M(!1)}})()},[k,E]);let Y=(0,o.useCallback)(e=>{rN.debug("Flow selected",{flowId:e}),T(e),F(!0)},[]),Z=(0,o.useCallback)(e=>{rN.debug("Opening flow in chat",{flowId:e}),t.push("/chat?flow=".concat(encodeURIComponent(e)))},[t]),Q=(0,o.useCallback)(()=>{if(!k)return;let e=()=>t.push("/chat?flow=".concat(encodeURIComponent(k)));P.current?P.current.requestNavigation(e):e()},[k,t]),ee=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(ee.current||I)return;let e=new URLSearchParams(window.location.search).get("flow");if(!e){ee.current=!0;return}r.some(t=>t.id===e)&&(ee.current=!0,Y(e))},[I,r,Y]),(0,o.useEffect)(()=>{if(!(N&&k))return;let e=e=>{P.current?P.current.requestNavigation(e):e()};return(0,rc.QO)(e),()=>(0,rc.bH)(e)},[N,k]);let et=(0,o.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";rN.debug("Showing snackbar",{message:e,severity:t}),X({open:!0,message:e,severity:t})},[]),er=(0,o.useCallback)(()=>{rN.debug("Returning to dashboard");let e=()=>{if(F(!1),E&&E.id===k){let e=z.length>0;R(null),L([]),T(null),et(e?"Generated draft (and its subflows) discarded":"Generated draft discarded","info")}};P.current?P.current.requestNavigation(e):e()},[E,z,k,et]),en=(0,o.useCallback)(()=>{X(e=>({...e,open:!1}))},[]);(0,o.useEffect)(()=>{if(!J.open||"error"===J.severity)return;let e=setTimeout(()=>{X(e=>({...e,open:!1}))},6e3);return()=>clearTimeout(e)},[J.open,J.message,J.severity]);let eo=(0,o.useCallback)(e=>(rN.debug("Validating flow name",{name:e}),e.trim())?/^[\w-]+$/.test(e)?r.some(t=>t.name.toLowerCase()===e.toLowerCase())?(rN.debug("Flow name validation failed: duplicate name"),"A flow with this name already exists"):(rN.debug("Flow name validation passed"),null):(rN.debug("Flow name validation failed: invalid characters"),"Flow name can only contain letters, numbers, underscores, and dashes"):(rN.debug("Flow name validation failed: empty name"),"Flow name cannot be empty"),[r]),el=async e=>{rN.info("Saving flow",{flowId:e.id,flowName:e.name});try{if((null==E?void 0:E.id)===e.id&&z.length>0){for(let e of(rN.info("Persisting generated subflow descendants before the root",{count:z.length}),z)){let t=r.some(t=>t.id===e.id)?await W.g.updateFlow(e):await W.g.addFlow(e);if(!t.success){rN.error("Failed to save a generated subflow",{error:t.error,childId:e.id}),et(t.error||"Failed to save a generated subflow","error");return}}S(e=>{let t=new Set(e.map(e=>e.id)),r=z.filter(e=>!t.has(e.id));return r.length?[...e,...r]:e}),L([])}let t=r.some(t=>t.id===e.id)?await W.g.updateFlow(e):await W.g.addFlow(e);if(!t.success){rN.error("Failed to save flow",{error:t.error}),et(t.error||"Failed to save flow","error");return}rN.debug("Flow saved successfully"),S(t=>{let r=t.findIndex(t=>t.id===e.id);if(!(r>=0))return rN.debug("Adding new flow to state"),[...t,e];{rN.debug("Updating existing flow in state");let n=[...t];return n[r]=e,n}}),(null==E?void 0:E.id)===e.id&&R(null),T(e.id),et("Flow saved successfully","success")}catch(e){rN.error("Error saving flow",e),et("Failed to save flow","error")}},ea=async e=>{rN.info("Deleting flow",{flowId:e});try{await W.g.deleteFlow(e),rN.debug("Flow deleted successfully"),S(t=>t.filter(t=>t.id!==e)),k===e&&(rN.debug("Clearing selected flow as it was deleted"),T(null),F(!1)),et("Flow deleted","success")}catch(e){rN.error("Error deleting flow",e),et("Failed to delete flow","error")}},es=(0,o.useCallback)(async(e,t)=>{rN.info("Setting flow folder",{flowId:e,folder:t});let n=r.find(t=>t.id===e);if(!n)return void rN.warn("Flow to move not found",{flowId:e});let o={...n,folder:t&&t.trim()?t.trim():void 0};try{let t=await W.g.updateFlow(o);if(!t.success)return void et(t.error||"Failed to move flow to folder","error");S(t=>t.map(t=>t.id===e?o:t)),et(o.folder?'Moved to "'.concat(o.folder,'"'):"Removed from folder","success")}catch(e){rN.error("Error setting flow folder",e),et("Failed to move flow to folder","error")}},[r,et]),ei=(0,o.useCallback)(async e=>{rN.info("Toggling flow favorite",{flowId:e});let t=r.find(t=>t.id===e);if(!t)return void rN.warn("Flow to favorite not found",{flowId:e});let n=!t.favorite,o={...t,favorite:n||void 0};try{let t=await W.g.updateFlow(o);if(!t.success)return void et(t.error||"Failed to update favorite","error");S(t=>t.map(t=>t.id===e?o:t)),et(n?"Added to favorites":"Removed from favorites","success")}catch(e){rN.error("Error toggling flow favorite",e),et("Failed to update favorite","error")}},[r,et]),ed=e=>{rN.info("Copying flow",{flowId:e});let t=r.find(t=>t.id===e);t?(rN.debug("Found flow to copy",{flowName:t.name}),V(t),$("".concat(t.name,"_copy")),H(!0)):(rN.warn("Flow to copy not found",{flowId:e}),et("Flow not found","error"))},ec=()=>{rN.debug("Closing copy flow dialog"),H(!1),V(null),$(""),q(null)},eu=async()=>{if(rN.info("Confirming flow copy"),!G){rN.warn("No flow to copy"),et("No flow selected to copy","error");return}let e=eo(K);if(e){rN.debug("Flow name validation failed",{error:e}),q(e);return}let t=(0,D.A)();rN.debug("Creating new flow from copy",{newId:t,newName:K});let r={id:t,name:K,description:G.description,unattended:G.unattended,nodes:G.nodes,edges:G.edges,folder:G.folder,favorite:G.favorite};await el(r),ec(),rN.debug("Selecting newly copied flow"),T(r.id),F(!0),et('Created a copy named "'.concat(K,'"'),"success")},ep=(0,o.useCallback)(e=>{var t,r,n;rN.info("Opening generated draft flow",{flowId:e.flow.id,attempts:e.attempts,errors:e.errorCount,warnings:e.warningCount}),O(!1);let o=(null!=(r=e.flows)?r:[]).filter(t=>t.id!==e.rootFlowId);R(e.flow),L(o),T(e.flow.id),F(!0);let l=null!=(n=null==(t=e.installedServers)?void 0:t.filter(e=>!e.alreadyExisted))?n:[],a=l.length>0?" Installed MCP server(s): ".concat(l.map(e=>e.name).join(", "),"."):"",s=o.length>0?" Includes ".concat(o.length," auto-generated subflow(s) that save with it."):"";e.errorCount>0?et("Draft generated with ".concat(e.errorCount," error(s) and ").concat(e.warningCount," warning(s) — use the Check button, fix, then save.").concat(s).concat(a),"warning"):e.warningCount>0?et("Draft generated with ".concat(e.warningCount," warning(s) — review, then save to keep it.").concat(s).concat(a),"info"):et("Flow drafted — review it and save to keep it.".concat(s).concat(a),"success")},[et]),eh=async()=>{rN.info("Creating new flow");let e="NewFlow",t=e,n=1;for(;r.some(e=>e.name===t);)t="".concat(e).concat(n),n++;let o=W.g.createNewFlow(t);await el(o),F(!0),et("New flow created","success")};return(0,n.jsxs)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)(s.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:1,borderColor:"divider"},children:[(0,n.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[N&&k&&(0,n.jsx)(u.A,{color:"primary",onClick:er,sx:{mr:1},children:(0,n.jsx)(y.A,{})}),(0,n.jsx)(s.default,{children:(0,n.jsx)(i.default,{variant:"h5",children:N&&k?(null==E?void 0:E.id)===k?"Editing: ".concat(E.name," (unsaved draft)"):"Editing: ".concat((null==(e=r.find(e=>e.id===k))?void 0:e.name)||"Flow"):"Flow Dashboard"})})]}),N&&k&&(null==E?void 0:E.id)!==k&&(0,n.jsx)(s.default,{sx:{display:"flex",gap:1},children:(0,n.jsx)(p.A,{title:"Start a new conversation with this flow",children:(0,n.jsx)(d.A,{variant:"outlined",color:"primary",startIcon:(0,n.jsx)(C.A,{}),onClick:Q,children:"Chat with this flow"})})}),!N&&(0,n.jsxs)(s.default,{sx:{display:"flex",gap:1},children:[(0,n.jsx)(p.A,{title:"Describe a flow in plain language and let a model draft it",children:(0,n.jsx)(d.A,{variant:"outlined",color:"primary",startIcon:(0,n.jsx)(A.A,{}),onClick:()=>O(!0),"data-tour":"generate-flow",children:"Generate Flow"})}),(0,n.jsx)(p.A,{title:"Create a new flow with a starter template",children:(0,n.jsx)(d.A,{variant:"contained",color:"primary",startIcon:(0,n.jsx)(j.A,{}),onClick:eh,"data-tour":"new-flow",children:"New Flow"})})]})]}),(0,n.jsx)(h.A,{in:J.open,unmountOnExit:!0,children:(0,n.jsx)(f.A,{severity:J.severity,onClose:en,sx:{borderRadius:0},children:J.message})}),(0,n.jsx)(s.default,{sx:{flex:1,overflow:"hidden"},children:(()=>{if(N&&k){var e;let t=null!=(e=r.find(e=>e.id===k))?e:(null==E?void 0:E.id)===k?E:void 0;return t?(0,n.jsx)(c.A,{in:!0,timeout:300,children:(0,n.jsx)(s.default,{sx:{height:"100%"},children:(0,n.jsx)(rs,{ref:P,initialFlow:t,onSave:el,onDelete:ea,allFlows:r},k)})}):(0,n.jsxs)(s.default,{sx:{p:4,textAlign:"center"},children:[(0,n.jsx)(i.default,{variant:"h6",color:"error",children:"Selected flow not found"}),(0,n.jsx)(d.A,{variant:"contained",onClick:er,sx:{mt:2},children:"Back to Dashboard"})]})}return(0,n.jsx)(c.A,{in:!0,timeout:300,children:(0,n.jsx)(s.default,{sx:{height:"100%"},children:(0,n.jsx)(rM,{flows:r,selectedFlow:k,onSelectFlow:Y,onDeleteFlow:ea,onCopyFlow:ed,onCreateFlow:eh,onSetFolder:es,onToggleFavorite:ei,onOpenInChat:Z,isLoading:I})})})})()}),(0,n.jsxs)(m.A,{open:U,onClose:ec,children:[(0,n.jsx)(g.A,{children:"Copy Flow"}),(0,n.jsxs)(x.A,{children:[(0,n.jsx)(v.A,{children:"Enter a name for the copied flow:"}),(0,n.jsx)(w.A,{autoFocus:!0,margin:"dense",label:"Flow Name",type:"text",fullWidth:!0,value:K,onChange:e=>{let t=e.target.value;rN.debug("Flow name changed",{name:t}),$(t),q(eo(t))},error:!!_,helperText:_})]}),(0,n.jsxs)(b.A,{children:[(0,n.jsx)(d.A,{onClick:ec,children:"Cancel"}),(0,n.jsx)(d.A,{onClick:eu,variant:"contained",color:"primary",disabled:!!_,children:"Copy"})]})]}),(0,n.jsx)(rd,{open:B,onClose:()=>O(!1),onGenerated:ep})]})}}},e=>{e.O(0,[1137,3862,7926,2678,4754,9244,3392,1871,7111,2003,9562,488,3272,8470,3077,8598,2800,1937,795,8551,3556,3418,8401,3948,289,3827,2164,6195,812,2566,6669,1988,7445,8441,1255,7358],()=>e(e.s=71075)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{1150:(e,n,r)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return s}});let t=r(95155),o=r(12115),a=r(24437);function l(e){return{default:e&&"default"in e?e.default:e}}r(36552);let i={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},s=function(e){let n={...i,...e},r=(0,o.lazy)(()=>n.loader().then(l)),s=n.loading;function c(e){let l=s?(0,t.jsx)(s,{isLoading:!0,pastDelay:!0,error:null}):null,i=!n.ssr||!!n.loading,c=i?o.Suspense:o.Fragment,d=n.ssr?(0,t.jsxs)(t.Fragment,{children:[null,(0,t.jsx)(r,{...e})]}):(0,t.jsx)(a.BailoutToCSR,{reason:"next/dynamic",children:(0,t.jsx)(r,{...e})});return(0,t.jsx)(c,{...i?{fallback:l}:{},children:d})}return c.displayName="LoadableComponent",c}},3946:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_c29908",variable:"__variable_c29908"}},8567:(e,n,r)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"workAsyncStorage",{enumerable:!0,get:function(){return t.workAsyncStorageInstance}});let t=r(17828)},13673:()=>{},17828:(e,n,r)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"workAsyncStorageInstance",{enumerable:!0,get:function(){return t}});let t=(0,r(64054).createAsyncLocalStorage)()},24437:(e,n,r)=>{"use strict";function t(e){let{reason:n,children:r}=e;return r}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return t}}),r(24553)},36552:(e,n,r)=>{"use strict";function t(e){let{moduleIds:n}=e;return null}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return t}}),r(95155),r(47650),r(8567),r(77278)},59742:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_246ccd",variable:"__variable_246ccd"}},64054:(e,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),!function(e,n){for(var r in n)Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}(n,{bindSnapshot:function(){return l},createAsyncLocalStorage:function(){return a},createSnapshot:function(){return i}});let r=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class t{disable(){throw r}getStore(){}run(){throw r}exit(){throw r}enterWith(){throw r}static bind(e){return e}}let o="undefined"!=typeof globalThis&&globalThis.AsyncLocalStorage;function a(){return o?new o:new t}function l(e){return o?o.bind(e):t.bind(e)}function i(){return o?o.snapshot():function(e,...n){return e(...n)}}},68187:(e,n,r)=>{Promise.resolve().then(r.t.bind(r,59742,23)),Promise.resolve().then(r.t.bind(r,3946,23)),Promise.resolve().then(r.t.bind(r,13673,23)),Promise.resolve().then(r.bind(r,72403))},72403:(e,n,r)=>{"use strict";r.d(n,{default:()=>h});var t=r(95155),o=r(12115),a=r(86278),l=r.n(a);let i=(0,r(87021).h)("frontend/components/AppWrapper"),s=l()(()=>Promise.all([r.e(2678),r.e(8598),r.e(8405)]).then(r.bind(r,26796)).then(e=>e.ThemeProvider),{loadableGenerated:{webpack:()=>[26796]},ssr:!1,loading:()=>(0,t.jsx)("div",{children:"Loading theme..."})}),c=l()(()=>r.e(9164).then(r.bind(r,9164)).then(e=>e.StorageProvider),{loadableGenerated:{webpack:()=>[9164]},ssr:!1,loading:()=>(0,t.jsx)("div",{children:"Loading storage..."})}),d=l()(()=>Promise.all([r.e(2678),r.e(4754),r.e(9244),r.e(3392),r.e(1871),r.e(7111),r.e(2003),r.e(9562),r.e(3272),r.e(8470),r.e(8598),r.e(4523),r.e(5512),r.e(9164),r.e(3089)]).then(r.bind(r,93089)),{loadableGenerated:{webpack:()=>[93089]},ssr:!1,loading:()=>(0,t.jsx)("div",{children:"Loading navigation..."})}),u=l()(()=>Promise.all([r.e(2678),r.e(4754),r.e(9244),r.e(3392),r.e(1871),r.e(7111),r.e(2003),r.e(9562),r.e(3272),r.e(9164),r.e(3217)]).then(r.bind(r,23217)),{loadableGenerated:{webpack:()=>[23217]},ssr:!1,loading:()=>null}),f=l()(()=>Promise.all([r.e(9164),r.e(9195)]).then(r.bind(r,69195)).then(e=>e.TourProvider),{loadableGenerated:{webpack:()=>[69195]},ssr:!1,loading:()=>null}),b=l()(()=>Promise.all([r.e(2678),r.e(4754),r.e(9244),r.e(3392),r.e(1871),r.e(2005),r.e(8345),r.e(9164),r.e(3545)]).then(r.bind(r,83545)),{loadableGenerated:{webpack:()=>[83545]},ssr:!1,loading:()=>null});class p extends o.Component{static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){i.error("AppWrapper error boundary caught an error:",e)}render(){return this.state.hasError?(0,t.jsxs)("div",{style:{padding:"20px",textAlign:"center"},children:[(0,t.jsx)("h2",{children:"Something went wrong loading the application."}),(0,t.jsx)("p",{children:"Please try refreshing the page."}),(0,t.jsx)("button",{onClick:()=>window.location.reload(),style:{padding:"8px 16px",background:"#3498DB",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",marginTop:"10px"},children:"Refresh"})]}):this.props.children}constructor(e){super(e),this.state={hasError:!1}}}function h(e){let{children:n}=e;return i.debug("Rendering AppWrapper"),(0,t.jsx)(p,{children:(0,t.jsx)(o.Suspense,{fallback:(0,t.jsx)("div",{children:"Loading application..."}),children:(0,t.jsx)(s,{children:(0,t.jsx)(c,{children:(0,t.jsxs)(f,{children:[(0,t.jsxs)(o.Suspense,{fallback:(0,t.jsx)("div",{children:"Loading navigation..."}),children:[(0,t.jsx)(d,{}),(0,t.jsx)(u,{})]}),(0,t.jsx)("main",{children:n}),(0,t.jsx)(b,{})]})})})})})}},86278:(e,n,r)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return o}});let t=r(28140)._(r(1150));function o(e,n){var r;let o={};"function"==typeof e&&(o.loader=e);let a={...o,...n};return(0,t.default)({...a,modules:null==(r=a.loadableGenerated)?void 0:r.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),e.exports=n.default)},87021:(e,n,r)=>{"use strict";r.d(n,{h:()=>s});let t={LOG_LEVEL:3},o={VERBOSE:-1,DEBUG:0,INFO:1,WARN:2,ERROR:3},a="number"==typeof t.LOG_LEVEL?t.LOG_LEVEL:o.ERROR;function l(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(n>6)return String(e);if(!(e instanceof Error))return e;let r={name:e.name,message:e.message};for(let t of Object.getOwnPropertyNames(e)){if("name"===t||"message"===t)continue;let o=e[t];"function"!=typeof o&&("stack"===t?r.stack=o:"cause"===t?r.cause=l(o,n+1):"errors"===t&&Array.isArray(o)?r.errors=o.map(e=>l(e,n+1)):r[t]=o)}return r}function i(e,n,r,t,i){if(e>=("number"==typeof i?i:a)){if("function"==typeof t)try{t=t()}catch(e){t="[lazy log data threw]"}let a=new Date().toISOString(),i="[".concat(a,"] [").concat(n,"]"),s="".concat(i," ").concat(r);if(void 0!==t)if(t instanceof Error||"object"==typeof t)try{let e=t instanceof Error?l(t):t,n=JSON.stringify(e,(e,n)=>n instanceof Error?l(n):n,2);s+=":\n".concat(n)}catch(e){s+=": [Object cannot be stringified]"}else s+=": ".concat(t);switch(e){case o.VERBOSE:console.debug("[VERBOSE] ".concat(s));break;case o.DEBUG:console.debug(s);break;case o.INFO:console.info(s);break;case o.WARN:console.warn(s);break;case o.ERROR:console.error(s);break;default:console.log(s)}}}function s(e,n){let r,t=((r=e.replace(/^src\//,"")).startsWith("/")&&(r=r.substring(1)),r);return{verbose:(e,r)=>{i(o.VERBOSE,t,e,r,n)},debug:(e,r)=>{i(o.DEBUG,t,e,r,n)},info:(e,r)=>{i(o.INFO,t,e,r,n)},warn:(e,r)=>{i(o.WARN,t,e,r,n)},error:(e,r)=>{i(o.ERROR,t,e,r,n)}}}}},e=>{e.O(0,[6317,6714,2978,8441,1255,7358],()=>e(e.s=68187)),_N_E=e.O()}]);