flujo-ai 3.18.0 → 3.20.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 (487) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +252 -231
  3. package/.next/app-path-routes-manifest.json +13 -11
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +21 -21
  6. package/.next/react-loadable-manifest.json +11 -11
  7. package/.next/routes-manifest.json +8 -0
  8. package/.next/server/app/_not-found/page.js +2 -2
  9. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/_not-found.html +1 -1
  11. package/.next/server/app/_not-found.rsc +2 -2
  12. package/.next/server/app/api/backup/route.js +1 -1
  13. package/.next/server/app/api/backup/route.js.nft.json +1 -1
  14. package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/encryption/secure/route.js +1 -1
  18. package/.next/server/app/api/encryption/secure/route.js.nft.json +1 -1
  19. package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/env/route.js +2 -2
  21. package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/flow/[id]/route.js +1 -1
  23. package/.next/server/app/api/flow/[id]/route.js.nft.json +1 -1
  24. package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/flow/compile/route.js +1 -1
  26. package/.next/server/app/api/flow/compile/route.js.nft.json +1 -1
  27. package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/flow/generate/route.js +1 -1
  29. package/.next/server/app/api/flow/generate/route.js.nft.json +1 -1
  30. package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/flow/improve/route.js +1 -1
  32. package/.next/server/app/api/flow/improve/route.js.nft.json +1 -1
  33. package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/flow/prompt-renderer/route.js +2 -2
  35. package/.next/server/app/api/flow/prompt-renderer/route.js.nft.json +1 -1
  36. package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/flow/quick-chat/route.js +1 -1
  38. package/.next/server/app/api/flow/quick-chat/route.js.nft.json +1 -1
  39. package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/flow/repair/route.js +1 -0
  41. package/.next/server/app/api/flow/repair/route.js.nft.json +1 -0
  42. package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -0
  43. package/.next/server/app/api/flow/route.js +1 -1
  44. package/.next/server/app/api/flow/route.js.nft.json +1 -1
  45. package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/git/route.js +4 -4
  47. package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/api/init/route.js +1 -1
  49. package/.next/server/app/api/init/route.js.nft.json +1 -1
  50. package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/mcp/cancel/route.js +2 -2
  55. package/.next/server/app/api/mcp/cancel/route.js.nft.json +1 -1
  56. package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js +1 -1
  58. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js.nft.json +1 -1
  59. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js +1 -1
  61. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js.nft.json +1 -1
  62. package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
  63. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js +1 -1
  64. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js.nft.json +1 -1
  65. package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
  66. package/.next/server/app/api/mcp/servers/[name]/resources/route.js +1 -1
  67. package/.next/server/app/api/mcp/servers/[name]/resources/route.js.nft.json +1 -1
  68. package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/mcp/servers/[name]/route.js +1 -1
  70. package/.next/server/app/api/mcp/servers/[name]/route.js.nft.json +1 -1
  71. package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/mcp/servers/[name]/status/route.js +1 -1
  73. package/.next/server/app/api/mcp/servers/[name]/status/route.js.nft.json +1 -1
  74. package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js +1 -1
  76. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js.nft.json +1 -1
  77. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/mcp/servers/[name]/tools/route.js +1 -1
  79. package/.next/server/app/api/mcp/servers/[name]/tools/route.js.nft.json +1 -1
  80. package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/mcp/servers/route.js +1 -1
  82. package/.next/server/app/api/mcp/servers/route.js.nft.json +1 -1
  83. package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
  84. package/.next/server/app/api/mcp/test-connection/route.js +1 -1
  85. package/.next/server/app/api/mcp/test-connection/route.js.nft.json +1 -1
  86. package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/mcp/test-connection/stream/route.js +1 -1
  88. package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -1
  89. package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/mcp-registry/route.js +2 -1
  91. package/.next/server/app/api/mcp-registry/route.js.nft.json +1 -1
  92. package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/model/[id]/route.js +1 -1
  95. package/.next/server/app/api/model/[id]/route.js.nft.json +1 -1
  96. package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/model/provider/route.js +2 -2
  98. package/.next/server/app/api/model/provider/route.js.nft.json +1 -1
  99. package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/model/route.js +1 -1
  101. package/.next/server/app/api/model/route.js.nft.json +1 -1
  102. package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/model/test/route.js +2 -2
  104. package/.next/server/app/api/model/test/route.js.nft.json +1 -1
  105. package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/oauth/callback/route.js +2 -2
  107. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/oauth/initiate/route.js +2 -2
  109. package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/oauth/reset/route.js +2 -2
  111. package/.next/server/app/api/oauth/reset/route.js.nft.json +1 -1
  112. package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/planned-executions/[id]/route.js +2 -2
  114. package/.next/server/app/api/planned-executions/[id]/route.js.nft.json +1 -1
  115. package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/planned-executions/[id]/run/route.js +2 -2
  117. package/.next/server/app/api/planned-executions/[id]/run/route.js.nft.json +1 -1
  118. package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/planned-executions/[id]/runs/route.js +2 -2
  120. package/.next/server/app/api/planned-executions/[id]/runs/route.js.nft.json +1 -1
  121. package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/planned-executions/route.js +1 -1
  124. package/.next/server/app/api/planned-executions/route.js.nft.json +1 -1
  125. package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/restore/route.js +1 -1
  127. package/.next/server/app/api/restore/route.js.nft.json +1 -1
  128. package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  131. package/.next/server/app/api/webhooks/[id]/route.js +1 -1
  132. package/.next/server/app/api/webhooks/[id]/route.js.nft.json +1 -1
  133. package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/chat/page.js +8 -7
  135. package/.next/server/app/chat/page.js.nft.json +1 -1
  136. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  137. package/.next/server/app/chat.html +1 -1
  138. package/.next/server/app/chat.rsc +3 -3
  139. package/.next/server/app/docs/page.js +37 -6
  140. package/.next/server/app/docs/page.js.nft.json +1 -1
  141. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/docs.html +1 -1
  143. package/.next/server/app/docs.rsc +3 -3
  144. package/.next/server/app/executions/page.js +3 -5
  145. package/.next/server/app/executions/page.js.nft.json +1 -1
  146. package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
  147. package/.next/server/app/executions.html +1 -1
  148. package/.next/server/app/executions.rsc +3 -3
  149. package/.next/server/app/flows/page.js +3 -3
  150. package/.next/server/app/flows/page.js.nft.json +1 -1
  151. package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
  152. package/.next/server/app/flows.html +1 -1
  153. package/.next/server/app/flows.rsc +3 -3
  154. package/.next/server/app/index.html +1 -1
  155. package/.next/server/app/index.rsc +3 -3
  156. package/.next/server/app/mcp/page.js +6 -6
  157. package/.next/server/app/mcp/page.js.nft.json +1 -1
  158. package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
  159. package/.next/server/app/mcp-flows/route.js +1 -5
  160. package/.next/server/app/mcp-flows/route.js.nft.json +1 -1
  161. package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
  162. package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
  163. package/.next/server/app/mcp-proxy/[server]/route.js.nft.json +1 -1
  164. package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
  165. package/.next/server/app/mcp.html +1 -1
  166. package/.next/server/app/mcp.rsc +3 -3
  167. package/.next/server/app/models/page.js +2 -3
  168. package/.next/server/app/models/page.js.nft.json +1 -1
  169. package/.next/server/app/models/page_client-reference-manifest.js +1 -1
  170. package/.next/server/app/page.js +3 -2
  171. package/.next/server/app/page.js.nft.json +1 -1
  172. package/.next/server/app/page_client-reference-manifest.js +1 -1
  173. package/.next/server/app/settings/page.js +4 -3
  174. package/.next/server/app/settings/page.js.nft.json +1 -1
  175. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  176. package/.next/server/app/settings.html +1 -1
  177. package/.next/server/app/settings.rsc +3 -3
  178. package/.next/server/app/v1/chat/completions/route.js +1 -1
  179. package/.next/server/app/v1/chat/completions/route.js.nft.json +1 -1
  180. package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
  181. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js +2 -2
  182. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js.nft.json +1 -1
  183. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
  184. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js +2 -2
  185. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js.nft.json +1 -1
  186. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
  187. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js +1 -1
  188. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js.nft.json +1 -1
  189. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
  190. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js +1 -1
  191. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js.nft.json +1 -1
  192. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
  193. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js +2 -2
  194. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js.nft.json +1 -1
  195. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
  196. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js +3 -3
  197. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js.nft.json +1 -1
  198. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
  199. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route.js +1 -0
  200. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route.js.nft.json +1 -0
  201. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -0
  202. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js +1 -1
  203. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js.nft.json +1 -1
  204. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
  205. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js +2 -2
  206. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js.nft.json +1 -1
  207. package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
  208. package/.next/server/app/v1/chat/conversations/route.js +2 -2
  209. package/.next/server/app/v1/chat/conversations/route.js.nft.json +1 -1
  210. package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
  211. package/.next/server/app/v1/models/route.js +2 -2
  212. package/.next/server/app/v1/models/route.js.nft.json +1 -1
  213. package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
  214. package/.next/server/app-paths-manifest.json +13 -11
  215. package/.next/server/chunks/{2776.js → 1083.js} +2 -3
  216. package/.next/server/chunks/1119.js +1 -0
  217. package/.next/server/chunks/{7731.js → 1152.js} +2 -2
  218. package/.next/server/chunks/1197.js +2 -0
  219. package/.next/server/chunks/1373.js +1 -1
  220. package/.next/server/chunks/1491.js +1 -0
  221. package/.next/server/chunks/{8460.js → 1991.js} +1 -1
  222. package/.next/server/chunks/2246.js +1 -0
  223. package/.next/server/chunks/2261.js +1 -0
  224. package/.next/server/chunks/227.js +5 -0
  225. package/.next/server/chunks/2350.js +1 -1
  226. package/.next/server/chunks/2430.js +1 -0
  227. package/.next/server/chunks/264.js +1 -1
  228. package/.next/server/chunks/2859.js +3 -7
  229. package/.next/server/chunks/289.js +1 -0
  230. package/.next/server/chunks/3511.js +1 -0
  231. package/.next/server/chunks/{6069.js → 3574.js} +2 -2
  232. package/.next/server/chunks/3778.js +42 -0
  233. package/.next/server/chunks/{8367.js → 38.js} +2 -2
  234. package/.next/server/chunks/3953.js +1 -0
  235. package/.next/server/chunks/3984.js +4 -4
  236. package/.next/server/chunks/4028.js +1 -0
  237. package/.next/server/chunks/4045.js +1 -0
  238. package/.next/server/chunks/4265.js +1 -0
  239. package/.next/server/chunks/4436.js +1 -0
  240. package/.next/server/chunks/{8227.js → 4456.js} +2 -2
  241. package/.next/server/chunks/4498.js +40 -0
  242. package/.next/server/chunks/4637.js +70 -0
  243. package/.next/server/chunks/4671.js +1 -0
  244. package/.next/server/chunks/{1912.js → 4690.js} +2 -2
  245. package/.next/server/chunks/4949.js +1 -0
  246. package/.next/server/chunks/5625.js +28 -0
  247. package/.next/server/chunks/{805.js → 5662.js} +2 -2
  248. package/.next/server/chunks/5708.js +64 -0
  249. package/.next/server/chunks/5734.js +4 -4
  250. package/.next/server/chunks/62.js +1 -0
  251. package/.next/server/chunks/6532.js +52 -0
  252. package/.next/server/chunks/{6760.js → 6772.js} +1 -1
  253. package/.next/server/chunks/{6201.js → 6901.js} +3 -2
  254. package/.next/server/chunks/{9314.js → 6908.js} +3 -3
  255. package/.next/server/chunks/6981.js +1 -0
  256. package/.next/server/chunks/6996.js +3 -3
  257. package/.next/server/chunks/701.js +1 -1
  258. package/.next/server/chunks/7101.js +64 -0
  259. package/.next/server/chunks/7214.js +3 -3
  260. package/.next/server/chunks/724.js +3 -3
  261. package/.next/server/chunks/7362.js +4 -4
  262. package/.next/server/chunks/7463.js +6 -0
  263. package/.next/server/chunks/7506.js +1 -1
  264. package/.next/server/chunks/7635.js +1 -1
  265. package/.next/server/chunks/7821.js +1 -1
  266. package/.next/server/chunks/8739.js +2 -2
  267. package/.next/server/chunks/9509.js +2 -2
  268. package/.next/server/chunks/9632.js +1 -0
  269. package/.next/server/chunks/9957.js +1 -1
  270. package/.next/server/functions-config-manifest.json +3 -3
  271. package/.next/server/instrumentation.js.nft.json +1 -1
  272. package/.next/server/middleware-build-manifest.js +1 -1
  273. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  274. package/.next/server/pages/404.html +1 -1
  275. package/.next/server/pages/500.html +1 -1
  276. package/.next/server/server-reference-manifest.js +1 -1
  277. package/.next/server/server-reference-manifest.json +1 -1
  278. package/.next/static/chunks/1161-970b105d0ab11425.js +1 -0
  279. package/.next/static/chunks/1620-0d8ecd877f123f7b.js +1 -0
  280. package/.next/static/chunks/1871-14c3e63ca865d85e.js +1 -0
  281. package/.next/static/chunks/{1892-359187893bbc7f3a.js → 1892-5c1e38d89e0a5a9c.js} +1 -1
  282. package/.next/static/chunks/3217.058098140ec3f563.js +1 -0
  283. package/.next/static/chunks/3381-5fd2417957ca0881.js +1 -0
  284. package/.next/static/chunks/{3545.d3a512315a9fce3e.js → 3545.353a62a68d3b7fd1.js} +1 -1
  285. package/.next/static/chunks/{2084-2463e1d781bad2a6.js → 3648-733cf7ca4a5d1f19.js} +1 -1
  286. package/.next/static/chunks/3736-5e2b3f6cda1bb923.js +1 -0
  287. package/.next/static/chunks/3930-cc8d73c953811b97.js +1 -0
  288. package/.next/static/chunks/422-268783d9ad5897e1.js +1 -0
  289. package/.next/static/chunks/4365-5d0e3d01c1bc0fdc.js +1 -0
  290. package/.next/static/chunks/5134-e21bd33daaf14ecf.js +1 -0
  291. package/.next/static/chunks/5501-c400aaeaf57e6297.js +1 -0
  292. package/.next/static/chunks/5619-82fc5c3133837739.js +1 -0
  293. package/.next/static/chunks/6013-cb423bc438256acb.js +1 -0
  294. package/.next/static/chunks/6920-a83ad5c0d5a54cf3.js +1 -0
  295. package/.next/static/chunks/7258-e27017c1b98f43f9.js +1 -0
  296. package/.next/static/chunks/{7583.b6c2f8874b6b89cd.js → 7583.26a8c1f6e6823daf.js} +1 -1
  297. package/.next/static/chunks/7687-7edf1a6e1f063b08.js +1 -0
  298. package/.next/static/chunks/8066-c202a83aef15143a.js +1 -0
  299. package/.next/static/chunks/{8187.15bf331f5318c00f.js → 8187.fd653767df53db87.js} +1 -1
  300. package/.next/static/chunks/8755-9f375ec8740fecac.js +1 -0
  301. package/.next/static/chunks/{9164-a56181e5e93cc47e.js → 9164-f54d3531ca1df5f7.js} +1 -1
  302. package/.next/static/chunks/{9747-ffb8be5e59700c27.js → 9587-706bfd1a692c4660.js} +3 -3
  303. package/.next/static/chunks/app/api/backup/route-b296683a5faf800a.js +1 -0
  304. package/.next/static/chunks/app/api/browse/route-b296683a5faf800a.js +1 -0
  305. package/.next/static/chunks/app/api/cwd/route-b296683a5faf800a.js +1 -0
  306. package/.next/static/chunks/app/api/encryption/secure/route-b296683a5faf800a.js +1 -0
  307. package/.next/static/chunks/app/api/env/route-b296683a5faf800a.js +1 -0
  308. package/.next/static/chunks/app/api/flow/[id]/route-b296683a5faf800a.js +1 -0
  309. package/.next/static/chunks/app/api/flow/compile/route-b296683a5faf800a.js +1 -0
  310. package/.next/static/chunks/app/api/flow/generate/route-b296683a5faf800a.js +1 -0
  311. package/.next/static/chunks/app/api/flow/improve/route-b296683a5faf800a.js +1 -0
  312. package/.next/static/chunks/app/api/flow/prompt-renderer/route-b296683a5faf800a.js +1 -0
  313. package/.next/static/chunks/app/api/flow/quick-chat/route-b296683a5faf800a.js +1 -0
  314. package/.next/static/chunks/app/api/flow/repair/route-b296683a5faf800a.js +1 -0
  315. package/.next/static/chunks/app/api/flow/route-b296683a5faf800a.js +1 -0
  316. package/.next/static/chunks/app/api/git/route-b296683a5faf800a.js +1 -0
  317. package/.next/static/chunks/app/api/init/route-b296683a5faf800a.js +1 -0
  318. package/.next/static/chunks/app/api/local-models/capability/route-b296683a5faf800a.js +1 -0
  319. package/.next/static/chunks/app/api/local-models/pull/route-b296683a5faf800a.js +1 -0
  320. package/.next/static/chunks/app/api/local-models/suggest/route-b296683a5faf800a.js +1 -0
  321. package/.next/static/chunks/app/api/mcp/cancel/route-b296683a5faf800a.js +1 -0
  322. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-b296683a5faf800a.js +1 -0
  323. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-b296683a5faf800a.js +1 -0
  324. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-b296683a5faf800a.js +1 -0
  325. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-b296683a5faf800a.js +1 -0
  326. package/.next/static/chunks/app/api/mcp/servers/[name]/route-b296683a5faf800a.js +1 -0
  327. package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-b296683a5faf800a.js +1 -0
  328. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-b296683a5faf800a.js +1 -0
  329. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-b296683a5faf800a.js +1 -0
  330. package/.next/static/chunks/app/api/mcp/servers/route-b296683a5faf800a.js +1 -0
  331. package/.next/static/chunks/app/api/mcp/test-connection/route-b296683a5faf800a.js +1 -0
  332. package/.next/static/chunks/app/api/mcp/test-connection/stream/route-b296683a5faf800a.js +1 -0
  333. package/.next/static/chunks/app/api/mcp-registry/route-b296683a5faf800a.js +1 -0
  334. package/.next/static/chunks/app/api/mcp-registry/spotlight/route-b296683a5faf800a.js +1 -0
  335. package/.next/static/chunks/app/api/model/[id]/route-b296683a5faf800a.js +1 -0
  336. package/.next/static/chunks/app/api/model/provider/route-b296683a5faf800a.js +1 -0
  337. package/.next/static/chunks/app/api/model/route-b296683a5faf800a.js +1 -0
  338. package/.next/static/chunks/app/api/model/test/route-b296683a5faf800a.js +1 -0
  339. package/.next/static/chunks/app/api/oauth/callback/route-b296683a5faf800a.js +1 -0
  340. package/.next/static/chunks/app/api/oauth/initiate/route-b296683a5faf800a.js +1 -0
  341. package/.next/static/chunks/app/api/oauth/reset/route-b296683a5faf800a.js +1 -0
  342. package/.next/static/chunks/app/api/planned-executions/[id]/route-b296683a5faf800a.js +1 -0
  343. package/.next/static/chunks/app/api/planned-executions/[id]/run/route-b296683a5faf800a.js +1 -0
  344. package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-b296683a5faf800a.js +1 -0
  345. package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-b296683a5faf800a.js +1 -0
  346. package/.next/static/chunks/app/api/planned-executions/route-b296683a5faf800a.js +1 -0
  347. package/.next/static/chunks/app/api/restore/route-b296683a5faf800a.js +1 -0
  348. package/.next/static/chunks/app/api/storage/route-b296683a5faf800a.js +1 -0
  349. package/.next/static/chunks/app/api/update/route-b296683a5faf800a.js +1 -0
  350. package/.next/static/chunks/app/api/webhooks/[id]/route-b296683a5faf800a.js +1 -0
  351. package/.next/static/chunks/app/chat/page-a67ad3683443e7ad.js +1 -0
  352. package/.next/static/chunks/app/docs/page-097827ec4dae1d30.js +1 -0
  353. package/.next/static/chunks/app/executions/page-cb0dcc66d84c9bf8.js +1 -0
  354. package/.next/static/chunks/app/flows/page-abdd0642e378c5da.js +1 -0
  355. package/.next/static/chunks/app/{layout-2878f13d7e253503.js → layout-64fc0ae7efe81e3c.js} +1 -1
  356. package/.next/static/chunks/app/mcp/page-7d3a269dce68b529.js +1 -0
  357. package/.next/static/chunks/app/mcp-flows/route-b296683a5faf800a.js +1 -0
  358. package/.next/static/chunks/app/mcp-proxy/[server]/route-b296683a5faf800a.js +1 -0
  359. package/.next/static/chunks/app/models/{error-2b00c98abf1e02cf.js → error-5732fbb053e182c5.js} +1 -1
  360. package/.next/static/chunks/app/models/page-616950f93a1e0027.js +1 -0
  361. package/.next/static/chunks/app/{page-6e18a8cd78b2050e.js → page-77e1ba238b0ee1d0.js} +1 -1
  362. package/.next/static/chunks/app/settings/{page-9430dfdaff87d70c.js → page-199d0ffae9ec7263.js} +1 -1
  363. package/.next/static/chunks/app/v1/chat/completions/route-b296683a5faf800a.js +1 -0
  364. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-b296683a5faf800a.js +1 -0
  365. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-b296683a5faf800a.js +1 -0
  366. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-b296683a5faf800a.js +1 -0
  367. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-b296683a5faf800a.js +1 -0
  368. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-b296683a5faf800a.js +1 -0
  369. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-b296683a5faf800a.js +1 -0
  370. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/resources/route-b296683a5faf800a.js +1 -0
  371. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-b296683a5faf800a.js +1 -0
  372. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-b296683a5faf800a.js +1 -0
  373. package/.next/static/chunks/app/v1/chat/conversations/route-b296683a5faf800a.js +1 -0
  374. package/.next/static/chunks/app/v1/models/route-b296683a5faf800a.js +1 -0
  375. package/.next/static/chunks/webpack-ef5b2cef70829f42.js +1 -0
  376. package/.next/static/dvSaKx6-EfRNi7Xj-cSv_/_buildManifest.js +1 -0
  377. package/.next/trace +9 -7
  378. package/.next/types/app/api/flow/repair/route.ts +347 -0
  379. package/.next/types/app/v1/chat/conversations/[conversationId]/resources/route.ts +347 -0
  380. package/.next/types/routes.d.ts +3 -1
  381. package/.next/types/validator.ts +18 -0
  382. package/README.md +1 -1
  383. package/package.json +1 -1
  384. package/.next/server/chunks/1050.js +0 -1
  385. package/.next/server/chunks/1403.js +0 -8
  386. package/.next/server/chunks/2439.js +0 -52
  387. package/.next/server/chunks/2666.js +0 -1
  388. package/.next/server/chunks/3310.js +0 -35
  389. package/.next/server/chunks/453.js +0 -1
  390. package/.next/server/chunks/4681.js +0 -1
  391. package/.next/server/chunks/5311.js +0 -1
  392. package/.next/server/chunks/6037.js +0 -41
  393. package/.next/server/chunks/6390.js +0 -28
  394. package/.next/server/chunks/6936.js +0 -37
  395. package/.next/server/chunks/7186.js +0 -2
  396. package/.next/server/chunks/7982.js +0 -1
  397. package/.next/server/chunks/8342.js +0 -1
  398. package/.next/server/chunks/906.js +0 -35
  399. package/.next/server/chunks/9687.js +0 -1
  400. package/.next/server/chunks/9880.js +0 -1
  401. package/.next/server/chunks/9938.js +0 -1
  402. package/.next/static/Fdh7zqKv38txmpLAxepeR/_buildManifest.js +0 -1
  403. package/.next/static/chunks/1374-e084b3c40554288a.js +0 -1
  404. package/.next/static/chunks/2380-5696e0dc0469f6a5.js +0 -1
  405. package/.next/static/chunks/2709-29f91a54eef90221.js +0 -1
  406. package/.next/static/chunks/3217.1a7e24fd70294370.js +0 -1
  407. package/.next/static/chunks/4105-8fddb00196bf3c6d.js +0 -1
  408. package/.next/static/chunks/4244-6f399c7ff9980207.js +0 -1
  409. package/.next/static/chunks/4809-423a2a4a90d02f2c.js +0 -1
  410. package/.next/static/chunks/6084-68908a197e957e5f.js +0 -1
  411. package/.next/static/chunks/6509-3380826fd7c82b4e.js +0 -1
  412. package/.next/static/chunks/6582-6735fdd6b42b5c35.js +0 -1
  413. package/.next/static/chunks/690-391bc0f482a9f67c.js +0 -1
  414. package/.next/static/chunks/7290-fd5bb2c94fd7f605.js +0 -1
  415. package/.next/static/chunks/8098-297bf477152a565b.js +0 -1
  416. package/.next/static/chunks/924-64f908860caf1a35.js +0 -1
  417. package/.next/static/chunks/9286-6ea909e5bf70a97e.js +0 -1
  418. package/.next/static/chunks/9562-93cc45aef3630781.js +0 -1
  419. package/.next/static/chunks/9984-1ed094ea9f5b1f17.js +0 -1
  420. package/.next/static/chunks/app/api/backup/route-1691635994fcddb5.js +0 -1
  421. package/.next/static/chunks/app/api/browse/route-1691635994fcddb5.js +0 -1
  422. package/.next/static/chunks/app/api/cwd/route-1691635994fcddb5.js +0 -1
  423. package/.next/static/chunks/app/api/encryption/secure/route-1691635994fcddb5.js +0 -1
  424. package/.next/static/chunks/app/api/env/route-1691635994fcddb5.js +0 -1
  425. package/.next/static/chunks/app/api/flow/[id]/route-1691635994fcddb5.js +0 -1
  426. package/.next/static/chunks/app/api/flow/compile/route-1691635994fcddb5.js +0 -1
  427. package/.next/static/chunks/app/api/flow/generate/route-1691635994fcddb5.js +0 -1
  428. package/.next/static/chunks/app/api/flow/improve/route-1691635994fcddb5.js +0 -1
  429. package/.next/static/chunks/app/api/flow/prompt-renderer/route-1691635994fcddb5.js +0 -1
  430. package/.next/static/chunks/app/api/flow/quick-chat/route-1691635994fcddb5.js +0 -1
  431. package/.next/static/chunks/app/api/flow/route-1691635994fcddb5.js +0 -1
  432. package/.next/static/chunks/app/api/git/route-1691635994fcddb5.js +0 -1
  433. package/.next/static/chunks/app/api/init/route-1691635994fcddb5.js +0 -1
  434. package/.next/static/chunks/app/api/local-models/capability/route-1691635994fcddb5.js +0 -1
  435. package/.next/static/chunks/app/api/local-models/pull/route-1691635994fcddb5.js +0 -1
  436. package/.next/static/chunks/app/api/local-models/suggest/route-1691635994fcddb5.js +0 -1
  437. package/.next/static/chunks/app/api/mcp/cancel/route-1691635994fcddb5.js +0 -1
  438. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-1691635994fcddb5.js +0 -1
  439. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-1691635994fcddb5.js +0 -1
  440. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-1691635994fcddb5.js +0 -1
  441. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-1691635994fcddb5.js +0 -1
  442. package/.next/static/chunks/app/api/mcp/servers/[name]/route-1691635994fcddb5.js +0 -1
  443. package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-1691635994fcddb5.js +0 -1
  444. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-1691635994fcddb5.js +0 -1
  445. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-1691635994fcddb5.js +0 -1
  446. package/.next/static/chunks/app/api/mcp/servers/route-1691635994fcddb5.js +0 -1
  447. package/.next/static/chunks/app/api/mcp/test-connection/route-1691635994fcddb5.js +0 -1
  448. package/.next/static/chunks/app/api/mcp/test-connection/stream/route-1691635994fcddb5.js +0 -1
  449. package/.next/static/chunks/app/api/mcp-registry/route-1691635994fcddb5.js +0 -1
  450. package/.next/static/chunks/app/api/mcp-registry/spotlight/route-1691635994fcddb5.js +0 -1
  451. package/.next/static/chunks/app/api/model/[id]/route-1691635994fcddb5.js +0 -1
  452. package/.next/static/chunks/app/api/model/provider/route-1691635994fcddb5.js +0 -1
  453. package/.next/static/chunks/app/api/model/route-1691635994fcddb5.js +0 -1
  454. package/.next/static/chunks/app/api/model/test/route-1691635994fcddb5.js +0 -1
  455. package/.next/static/chunks/app/api/oauth/callback/route-1691635994fcddb5.js +0 -1
  456. package/.next/static/chunks/app/api/oauth/initiate/route-1691635994fcddb5.js +0 -1
  457. package/.next/static/chunks/app/api/oauth/reset/route-1691635994fcddb5.js +0 -1
  458. package/.next/static/chunks/app/api/planned-executions/[id]/route-1691635994fcddb5.js +0 -1
  459. package/.next/static/chunks/app/api/planned-executions/[id]/run/route-1691635994fcddb5.js +0 -1
  460. package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-1691635994fcddb5.js +0 -1
  461. package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-1691635994fcddb5.js +0 -1
  462. package/.next/static/chunks/app/api/planned-executions/route-1691635994fcddb5.js +0 -1
  463. package/.next/static/chunks/app/api/restore/route-1691635994fcddb5.js +0 -1
  464. package/.next/static/chunks/app/api/storage/route-1691635994fcddb5.js +0 -1
  465. package/.next/static/chunks/app/api/update/route-1691635994fcddb5.js +0 -1
  466. package/.next/static/chunks/app/api/webhooks/[id]/route-1691635994fcddb5.js +0 -1
  467. package/.next/static/chunks/app/chat/page-6486974f4a6c7b57.js +0 -1
  468. package/.next/static/chunks/app/docs/page-5da72cc6db51f238.js +0 -1
  469. package/.next/static/chunks/app/executions/page-fe19f6a1bd3fe05c.js +0 -1
  470. package/.next/static/chunks/app/flows/page-3b84093cdf2aee84.js +0 -1
  471. package/.next/static/chunks/app/mcp/page-355386ec2a542e42.js +0 -1
  472. package/.next/static/chunks/app/mcp-flows/route-1691635994fcddb5.js +0 -1
  473. package/.next/static/chunks/app/mcp-proxy/[server]/route-1691635994fcddb5.js +0 -1
  474. package/.next/static/chunks/app/models/page-20c80d398bf83fc5.js +0 -1
  475. package/.next/static/chunks/app/v1/chat/completions/route-1691635994fcddb5.js +0 -1
  476. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-1691635994fcddb5.js +0 -1
  477. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-1691635994fcddb5.js +0 -1
  478. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-1691635994fcddb5.js +0 -1
  479. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-1691635994fcddb5.js +0 -1
  480. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-1691635994fcddb5.js +0 -1
  481. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-1691635994fcddb5.js +0 -1
  482. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-1691635994fcddb5.js +0 -1
  483. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-1691635994fcddb5.js +0 -1
  484. package/.next/static/chunks/app/v1/chat/conversations/route-1691635994fcddb5.js +0 -1
  485. package/.next/static/chunks/app/v1/models/route-1691635994fcddb5.js +0 -1
  486. package/.next/static/chunks/webpack-4880945dd240d429.js +0 -1
  487. /package/.next/static/{Fdh7zqKv38txmpLAxepeR → dvSaKx6-EfRNi7Xj-cSv_}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{69732:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>tz});var o=n(95155),r=n(12115),l=n(97322),a=n(94049),i=n(78470),s=n(41983),d=n(22003),c=n(28548),u=n(70690),p=n(25635),h=n(3339),f=n(67895),g=n(2778),x=n(52363),m=n(65036),v=n(50001),b=n(75912),y=n(22719),j=n(11096),w=n(76530),A=n(36741),S=n(60691),I=n(78410),C=n(29692),k=n(21067),E=n(41602),T=n(23820),N=n(17681),z=n(73707),R=n(4484),D=n(86946),P=n(19219);let F=e=>{let{conversations:t,currentConversationId:n,onSelectConversation:r,onDeleteConversation:l,onNewConversation:d,onQuickChat:c,onCollapse:h}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(a.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",gap:1},children:[h&&(0,o.jsx)(i.A,{title:"Hide sidebar",children:(0,o.jsx)(s.A,{size:"small",onClick:h,"aria-label":"Hide conversation sidebar",children:(0,o.jsx)(P.A,{})})}),(0,o.jsx)(p.default,{variant:"h6",sx:{flex:1},noWrap:!0,children:"Conversations"}),c&&(0,o.jsx)(i.A,{title:"Quick Chat: a model + optional MCP servers, no saved flow",children:(0,o.jsx)(u.A,{variant:"outlined",color:"primary",startIcon:(0,o.jsx)(j.A,{}),onClick:c,size:"small",children:"Quick"})}),(0,o.jsx)(u.A,{variant:"contained",color:"primary",startIcon:(0,o.jsx)(D.A,{}),onClick:d,size:"small",children:"New"})]}),(0,o.jsx)(k.A,{}),(0,o.jsx)(E.A,{sx:{overflow:"auto",flex:1},children:0===t.length?(0,o.jsx)(T.Ay,{children:(0,o.jsx)(N.A,{primary:"No conversations yet",secondary:"Start a new conversation",primaryTypographyProps:{align:"center"},secondaryTypographyProps:{align:"center"}})}):t.sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>(0,o.jsx)(T.Ay,{disablePadding:!0,secondaryAction:(0,o.jsx)(s.A,{edge:"end","aria-label":"delete",onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,o.jsx)(R.A,{})}),sx:{opacity:e.id===n?1:.7},children:(0,o.jsx)(z.A,{selected:e.id===n,onClick:()=>r(e.id),sx:{pr:7},children:(0,o.jsx)(N.A,{primary:(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.status&&(0,o.jsx)(i.A,{title:(e=>{switch(e){case"running":return"Processing";case"awaiting_tool_approval":return"Waiting for tool approval";case"paused_debug":return"Paused in debug mode";case"completed":return"Completed";case"error":return"Error";default:return""}})(e.status),children:(0,o.jsx)(a.default,{component:"span",sx:{width:8,height:8,borderRadius:"50%",bgcolor:(e=>{switch(e){case"running":return"primary.main";case"awaiting_tool_approval":return"warning.main";case"paused_debug":return"secondary.main";case"completed":return"success.main";case"error":return"error.main";default:return"transparent"}})(e.status),display:"inline-block",flexShrink:0}})}),(0,o.jsx)(p.default,{component:"span",noWrap:!0,fontWeight:e.id===n?"bold":"normal",children:e.title})]}),secondary:new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})})},e.id))})]})};var M=n(4474),_=n(50430),O=n(99944),W=n(9957),L=n(2300),H=n(52641),q=n(51221),B=n(55606),U=n(86973),J=n(98267),Y=n(20537),Q=n(37960),G=n(36314),K=n(49501),X=n(6504),$=n(22133),V=n(11665),Z=n(97516),ee=n(91861),et=n(53612),en=n(3014),eo=n(63186),er=n(70863),el=n(67891),ea=n(12121),ei=n(14915),es=n(63992),ed=n(59637),ec=n(30949),eu=n(1877),ep=n(18466),eh=n(26188),ef=n(38952),eg=n(62962),ex=n(17897),em=n(81029).hp,ev=n(87021);let eb=(0,ev.h)("frontend/components/Chat/McpAppFrame"),ey=e=>{let{serverName:t,uri:n}=e,[l,s]=(0,r.useState)(!1),[c,h]=(0,r.useState)(!1),[f,g]=(0,r.useState)(null),[x,m]=(0,r.useState)(null),v=(0,r.useCallback)(async()=>{h(!0),g(null);try{let e=await ex.S.readResource(t,n);if(!e||!1===e.success)return void g((null==e?void 0:e.error)||"Failed to read the UI resource.");let o=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2097152,o=null==e?void 0:e.contents;if(!Array.isArray(o)||0===o.length)return{error:"Resource has no contents"};let r=o.find(e=>(function(e){if("string"!=typeof e)return!1;let t=e.toLowerCase().replace(/\s+/g,"");return t.startsWith("text/html")&&t.includes("profile=mcp-app")})(e.mimeType)&&"string"==typeof e.text)||o.find(e=>"string"==typeof e.text);if(!r||"string"!=typeof r.text)return{error:"Resource has no HTML text body"};if((void 0!==em?em.byteLength(r.text,"utf8"):new TextEncoder().encode(r.text).length)>n)return{error:"Resource exceeds the ".concat(Math.round(n/1024)," KiB size cap")};let l=null==(t=r._meta)?void 0:t.ui;return{html:r.text,meta:l}}(e.data);if("error"in o)return void g(o.error);m(function(e,t){let n='<meta http-equiv="Content-Security-Policy" content="'.concat(function(e){let t=e=>(e||[]).map(e=>"string"==typeof e?e.trim():"").filter(Boolean).join(" "),n=t(null==e?void 0:e.connectDomains),o=t(null==e?void 0:e.resourceDomains),r=t(null==e?void 0:e.frameDomains),l=t(null==e?void 0:e.baseUriDomains);return["default-src 'none'","script-src 'unsafe-inline'".concat(o?" ".concat(o):""),"style-src 'unsafe-inline'".concat(o?" ".concat(o):""),"img-src data: blob:".concat(o?" ".concat(o):""),"font-src".concat(o?" ".concat(o):" 'none'"),"media-src data: blob:".concat(o?" ".concat(o):""),"connect-src".concat(n?" ".concat(n):" 'none'"),"frame-src".concat(r?" ".concat(r):" 'none'"),"base-uri".concat(l?" ".concat(l):" 'none'"),"form-action 'none'"].join("; ")}(t),'">');return/<head[\s>]/i.test(e)?e.replace(/<head([^>]*)>/i,"<head$1>".concat(n)):'<!DOCTYPE html><html><head><meta charset="utf-8">'.concat(n,"</head><body>").concat(e,"</body></html>")}(o.html,o.meta))}catch(e){eb.warn("Failed to load MCP App resource ".concat(n," from ").concat(t),e),g(e instanceof Error?e.message:"Failed to load the UI resource.")}finally{h(!1)}},[t,n]),b=(0,r.useCallback)(()=>{let e=!l;s(e),e&&null===x&&!c&&v()},[l,x,c,v]);return(0,o.jsxs)(a.default,{sx:{mt:1,border:"1px solid",borderColor:"divider",borderRadius:1,overflow:"hidden"},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1,px:1,py:.5,bgcolor:"action.hover"},children:[(0,o.jsx)(eh.A,{fontSize:"small",color:"primary"}),(0,o.jsxs)(p.default,{variant:"body2",sx:{fontWeight:500},children:["Interactive app from ",t]}),(0,o.jsx)(i.A,{title:"Rendered read-only in a strict sandbox (no same-origin access, no network unless the app declares it). The app cannot call tools in this view.",children:(0,o.jsx)(ef.A,{fontSize:"small",color:"action"})}),(0,o.jsx)(u.A,{size:"small",onClick:b,startIcon:l?(0,o.jsx)(eg.A,{}):(0,o.jsx)(eo.A,{}),sx:{ml:"auto"},children:l?"Hide":"Open app"})]}),(0,o.jsx)(_.A,{in:l,unmountOnExit:!0,children:(0,o.jsxs)(a.default,{sx:{p:1},children:[c&&(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1,py:2,justifyContent:"center"},children:[(0,o.jsx)(M.default,{size:16,thickness:6}),(0,o.jsx)(p.default,{variant:"body2",color:"text.secondary",children:"Loading the app…"})]}),f&&(0,o.jsx)(d.A,{severity:"error",sx:{my:1},children:f}),!c&&!f&&null!==x&&(0,o.jsx)(a.default,{component:"iframe",title:"MCP App: ".concat(n),srcDoc:x,sandbox:"allow-scripts",referrerPolicy:"no-referrer",sx:{width:"100%",height:420,border:"none",borderRadius:1,bgcolor:"#fff"}})]})})]})},ej=(0,ev.h)("frontend/components/Chat/ChatMessages");function ew(e){return"assistant"===e.role&&"tool_calls"in e&&Array.isArray(e.tool_calls)}function eA(e){if("tool"!==e.role||"string"!=typeof e.content)return!1;try{var t;return(null==(t=JSON.parse(e.content))?void 0:t.handoff)===!0}catch(e){return!1}}let eS={p:e=>(0,o.jsx)(p.default,{variant:"body1",sx:{mb:.5,whiteSpace:"pre-line"},children:e.children}),h1:e=>(0,o.jsx)(p.default,{variant:"h5",sx:{mt:2,mb:.5},children:e.children}),h2:e=>(0,o.jsx)(p.default,{variant:"h6",sx:{mt:2,mb:.5},children:e.children}),h3:e=>(0,o.jsx)(p.default,{variant:"subtitle1",sx:{mt:1.5,mb:.5},children:e.children}),h4:e=>(0,o.jsx)(p.default,{variant:"subtitle2",sx:{mt:1.5,mb:.5},children:e.children}),h5:e=>(0,o.jsx)(p.default,{variant:"body1",sx:{mt:1,mb:.5,fontWeight:"bold"},children:e.children}),h6:e=>(0,o.jsx)(p.default,{variant:"body2",sx:{mt:1,mb:.5,fontWeight:"bold"},children:e.children}),ul:e=>(0,o.jsx)(a.default,{component:"ul",sx:{pl:2,mb:1},children:e.children}),ol:e=>(0,o.jsx)(a.default,{component:"ol",sx:{pl:2,mb:1},children:e.children}),li:e=>(0,o.jsx)(a.default,{component:"li",sx:{mb:.5,whiteSpace:"pre-line"},children:e.children}),a:e=>(0,o.jsx)(p.default,{component:"a",sx:{color:"primary.main"},href:e.href,children:e.children}),blockquote:e=>(0,o.jsx)(a.default,{component:"blockquote",sx:{borderLeft:"4px solid",borderColor:"divider",pl:2,py:.5,my:1,bgcolor:"action.hover",borderRadius:"4px"},children:e.children}),code:e=>{let{node:t,className:n,children:r,...l}=e;return/language-(\w+)/.exec(n||"")||n?(0,o.jsx)(a.default,{component:"pre",sx:{bgcolor:"action.hover",p:1.5,borderRadius:"4px",overflowX:"auto",fontFamily:"monospace",fontSize:"0.875rem",my:1,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:r}):(0,o.jsx)(p.default,{component:"code",sx:{bgcolor:"action.hover",px:.5,py:.25,borderRadius:"4px",fontFamily:"monospace",wordBreak:"break-all"},children:r})}},eI=e=>{let{content:t,showRaw:n}=e;return n?(0,o.jsx)(a.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontSize:"0.8rem",p:1,borderRadius:1,border:1,borderColor:e=>"dark"===e.palette.mode?"#3a3a3a":"#e5e7eb",bgcolor:"action.hover",color:e=>e.palette.text.primary,overflow:"auto",maxHeight:"300px"},children:"string"==typeof t?t:"[Invalid tool content]"}):"string"!=typeof t?(0,o.jsx)(p.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",children:"[Invalid tool content]"}):(0,o.jsx)(a.default,{sx:{width:"100%",minWidth:0},children:(()=>{try{let e=JSON.parse(t);if(e&&Array.isArray(e.content))return(0,o.jsx)(a.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.content.map((e,t)=>"text"===e.type?(0,o.jsx)(X.oz,{remarkPlugins:[$.A],children:e.text},t):"image"===e.type&&e.data&&e.mimeType?(0,o.jsx)("img",{src:"data:".concat(e.mimeType,";base64,").concat(e.data),alt:"Tool Result Image ".concat(t+1),style:{maxWidth:"100%",height:"auto",borderRadius:"4px",marginTop:"8px"}},t):"audio"===e.type&&e.data&&e.mimeType?(0,o.jsx)("audio",{controls:!0,src:"data:".concat(e.mimeType,";base64,").concat(e.data),style:{width:"100%",marginTop:"8px"},children:"Your browser does not support the audio element."},t):(0,o.jsx)(a.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontSize:"0.8rem",p:1,borderRadius:1,border:1,borderColor:e=>"dark"===e.palette.mode?"#3a3a3a":"#e5e7eb",bgcolor:"action.hover",color:e=>e.palette.text.primary,overflow:"auto",mt:1},children:"Unsupported content type: ".concat(e.type,"\n").concat(JSON.stringify(e,null,2))},t))});return(0,o.jsx)(X.oz,{remarkPlugins:[$.A],children:"```json\n".concat(JSON.stringify(e,null,2),"\n```")})}catch(e){return(0,o.jsx)(X.oz,{remarkPlugins:[$.A],children:t})}})()})},eC=e=>{let{pairs:t,messageId:n}=e,[l,s]=(0,r.useState)(null),[d,u]=(0,r.useState)({}),h=(e,t)=>e.toolCall.id||"tc-".concat(n,"-").concat(t);return(0,o.jsxs)(a.default,{sx:{mt:1,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",color:"primary.main",mb:1},children:[(0,o.jsx)(er.A,{fontSize:"small",sx:{mr:1}}),(0,o.jsx)(p.default,{variant:"body2",children:1===t.length?"The assistant used a tool":"The assistant used ".concat(t.length," tools")})]}),(0,o.jsx)(a.default,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:.5},children:t.map((e,t)=>{let n=h(e,t),d=function(e){if(!e)return"pending";if("string"==typeof e.content)try{let t=JSON.parse(e.content);if(t&&(!0===t.isError||null!=t.error))return"error"}catch(e){}return"done"}(e.result),u=l===n;return(0,o.jsxs)(r.Fragment,{children:[t>0&&(0,o.jsx)(a.default,{sx:{width:14,height:"2px",bgcolor:"divider",flexShrink:0}}),(0,o.jsx)(i.A,{title:u?"Hide call & result":"Show call & result",children:(0,o.jsx)(c.A,{icon:function(e){return"pending"===e?(0,o.jsx)(M.default,{size:14,thickness:6}):"error"===e?(0,o.jsx)(S.A,{fontSize:"small"}):(0,o.jsx)(ea.A,{fontSize:"small"})}(d),label:(0,eu.yo)(e.toolCall.function.name),size:"small",clickable:!0,variant:u?"filled":"outlined",color:"error"===d?"error":"pending"===d?"default":"primary",onClick:()=>s(u?null:n),sx:{maxWidth:"100%"}})})]},n)})}),t.map((e,t)=>{var n,r;let i=h(e,t),s=e.toolCall.function.arguments;try{s=JSON.stringify(JSON.parse(e.toolCall.function.arguments),null,2)}catch(e){}let f=!!d[i];return(0,o.jsx)(_.A,{in:l===i,unmountOnExit:!0,children:(0,o.jsxs)(a.default,{sx:{mt:1,p:1,borderRadius:1,bgcolor:"rgba(0, 0, 0, 0.03)"},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",mb:.5},children:[(0,o.jsx)(er.A,{fontSize:"small",sx:{mr:.5,color:"primary.main"}}),(0,o.jsx)(p.default,{variant:"caption",sx:{fontWeight:"bold"},children:"Parameters"}),(0,o.jsx)(c.A,{label:"ID: ".concat(e.toolCall.id?e.toolCall.id.substring(0,8):"N/A","..."),size:"small",color:"default",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}})]}),(0,o.jsx)(a.default,{component:"pre",sx:{bgcolor:"action.hover",p:1,borderRadius:"4px",overflowX:"auto",fontFamily:"monospace",fontSize:"0.75rem",my:.5,maxHeight:"150px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",mt:1,mb:.5},children:[(0,o.jsx)(el.A,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),(0,o.jsx)(p.default,{variant:"caption",sx:{fontWeight:"bold"},children:"Result"}),e.result&&(0,o.jsx)(O.A,{control:(0,o.jsx)(W.A,{size:"small",checked:f,onChange:e=>u(t=>({...t,[i]:e.target.checked}))}),label:"Raw",sx:{ml:"auto",mr:0,"& .MuiTypography-root":{fontSize:"0.75rem"}}})]}),e.result?(0,o.jsx)(eI,{content:e.result.content,showRaw:f}):(0,o.jsxs)(p.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(M.default,{size:14,thickness:6})," Waiting for the tool to respond…"]}),(null==(r=e.result)||null==(n=r.ui)?void 0:n.uri)&&e.result.ui.serverName&&(0,o.jsx)(ey,{serverName:e.result.ui.serverName,uri:e.result.ui.uri})]})},i)})]})},ek=r.memo(function(e){var t,n;let r,{message:l,nodeLabel:d,availableNodes:h,showRaw:f,toolCallPairs:g,hoistedHandoffs:x,edit:m,onMenuOpen:v,onToggleRaw:b,onEditContentChange:y,onEditNodeChange:j,onSaveEdit:w,onCancelEdit:A}=e,S=null!=(t=l.depth)?t:0;return(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",alignItems:"user"===l.role?"flex-end":"flex-start",opacity:l.disabled?.5:1,...S>0&&{pl:3*S,borderLeft:"2px solid",borderColor:"divider",ml:1}},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",mb:.5},children:[(0,o.jsxs)(p.default,{variant:"caption",color:"text.secondary",sx:{mr:1},children:["user"===l.role?"You":"assistant"===l.role?"Assistant":"tool"===l.role?"Tool":"System"," • ","number"!=typeof(n=l.timestamp)||isNaN(n)?(ej.warn("formatTime received invalid timestamp:",n),"Invalid Date"):new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]}),l.processNodeId&&(0,o.jsx)(i.A,{title:"".concat(d?"".concat(d," — "):"","Process Node ID: ").concat(l.processNodeId),children:(0,o.jsx)(c.A,{label:"Node: ".concat(d||"".concat(l.processNodeId.substring(0,6),"...")),size:"small",color:"primary",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),S>0&&(0,o.jsx)(i.A,{title:"Nested subflow step (depth ".concat(S,")"),children:(0,o.jsx)(c.A,{label:"Subflow step",size:"small",color:"secondary",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),l.disabled&&(0,o.jsx)(c.A,{label:"Disabled",size:"small",color:"default",variant:"outlined",sx:{height:20,fontSize:"0.7rem"}}),l.usage&&(0,o.jsx)(i.A,{title:"".concat(l.usage.promptTokens.toLocaleString()," prompt + ").concat(l.usage.completionTokens.toLocaleString()," completion tokens (provider-reported)"),children:(0,o.jsx)(c.A,{label:"".concat((r=l.usage.totalTokens)>=1e3?"".concat((r/1e3).toFixed(r>=1e5?0:1),"k"):"".concat(r)," tok"),size:"small",color:"default",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),(0,o.jsx)(s.A,{size:"small",onClick:e=>v(e,l.id),sx:{ml:1},children:(0,o.jsx)(V.A,{fontSize:"small"})})]}),(0,o.jsxs)(L.A,{elevation:1,sx:{p:2,maxWidth:"75vw",borderRadius:2,bgcolor:"user"===l.role?"primary.light":"assistant"===l.role||"tool"===l.role?"background.paper":"info.light",color:"user"===l.role?"primary.contrastText":"assistant"===l.role||"tool"===l.role?"text.primary":"info.contrastText",position:"relative",borderLeft:"tool"===l.role?"4px solid":"none",borderColor:"tool"===l.role?"grey.400":"transparent",overflowWrap:"break-word",wordBreak:"break-word",overflow:"hidden"},children:[m?(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:[(0,o.jsx)("textarea",{value:m.content,onChange:e=>y(e.target.value),style:{width:"100%",minHeight:"100px",padding:"8px",borderRadius:"4px",border:"1px solid #ccc",fontFamily:"inherit",fontSize:"inherit",backgroundColor:"white",color:"black"}}),(0,o.jsxs)(H.A,{fullWidth:!0,size:"small",sx:{mt:1},children:[(0,o.jsx)(q.A,{id:"node-id-select-label",children:"Process Node"}),(0,o.jsx)(B.A,{labelId:"node-id-select-label",id:"node-id-select",value:m.nodeId||(h.length>0?h[0].id:""),label:"Process Node",onChange:e=>j(e.target.value),children:h.map(e=>(0,o.jsx)(U.A,{value:e.id,children:e.label||e.id.substring(0,8)},e.id))})]}),(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:1},children:[(0,o.jsx)(u.A,{variant:"outlined",size:"small",onClick:A,children:"Cancel"}),(0,o.jsx)(u.A,{variant:"contained",size:"small",onClick:w,children:"Save"})]})]}):(0,o.jsxs)(o.Fragment,{children:["tool"!==l.role&&"string"==typeof l.content&&(0,o.jsx)(X.oz,{remarkPlugins:[$.A],components:eS,children:l.content}),"tool"!==l.role&&Array.isArray(l.content)&&(0,o.jsx)(a.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:l.content.map((e,t)=>{var n;return(null==e?void 0:e.type)==="text"?(0,o.jsx)(X.oz,{remarkPlugins:[$.A],children:e.text},t):(null==e?void 0:e.type)==="image_url"&&(null==(n=e.image_url)?void 0:n.url)?(0,o.jsx)("img",{src:e.image_url.url,alt:"Image ".concat(t+1),style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}},t):null})}),"tool"!==l.role&&"string"!=typeof l.content&&!Array.isArray(l.content)&&!ew(l)&&(0,o.jsx)(p.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",children:"[No text content]"})]}),[...ew(l)?l.tool_calls.filter(e=>{var t;return!!(t=e.function.name)&&(t.startsWith(ep.n9)||"handoff"===t)}):[],...null!=x?x:[]].map((e,t)=>(0,o.jsxs)(a.default,{sx:{mt:1,display:"flex",alignItems:"center",gap:.5,color:"secondary.main",fontStyle:"italic"},children:[(0,o.jsx)(ec.A,{fontSize:"small"}),(0,o.jsxs)(p.default,{variant:"body2",sx:{display:"flex",alignItems:"center",gap:.5},children:["Handoff to",(0,o.jsx)(a.default,{component:"span",sx:{fontWeight:"bold",fontStyle:"normal"},children:function(e,t){let n=e.startsWith(ep.n9)?e.slice(ep.n9.length):e,o=n.replace(/_\d+$/,""),r=t.find(e=>{let t=(0,ep.RN)(e.label);return t===n||t===o});return(null==r?void 0:r.label)?r.label:o.split("_").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")||"target node"}(e.function.name,h)})]})]},e.id||"handoff-".concat(l.id,"-").concat(t))),g&&g.length>0&&(0,o.jsx)(eC,{pairs:g,messageId:l.id}),"tool"===l.role&&l.tool_call_id&&!eA(l)&&(0,o.jsxs)(a.default,{children:[(0,o.jsxs)(p.default,{variant:"body2",sx:{display:"flex",alignItems:"center",color:"text.secondary",mb:1},children:[(0,o.jsx)(el.A,{fontSize:"small",sx:{mr:1}}),"The tool responded to the assistant"]}),(0,o.jsxs)(J.A,{defaultExpanded:!1,sx:{mb:.5,"&:before":{display:"none"},boxShadow:"none",bgcolor:"rgba(0, 0, 0, 0.02)"},children:[(0,o.jsx)(Y.A,{expandIcon:(0,o.jsx)(eo.A,{}),children:(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(el.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),(0,o.jsx)(p.default,{variant:"subtitle2",children:"Tool Result"}),(0,o.jsx)(c.A,{label:"ID: ".concat(l.tool_call_id.substring(0,8),"..."),size:"small",color:"default",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}}),(0,o.jsx)(O.A,{control:(0,o.jsx)(W.A,{size:"small",checked:f,onChange:e=>b(l.id,e.target.checked),onClick:e=>e.stopPropagation()}),label:"Raw",sx:{mr:1,ml:"auto","& .MuiTypography-root":{fontSize:"0.75rem"}},onClick:e=>e.stopPropagation()})]})}),(0,o.jsx)(Q.A,{sx:{pt:0,pb:1,overflow:"hidden"},children:(0,o.jsx)(eI,{content:l.content,showRaw:f})})]})]}),l.attachments&&l.attachments.length>0&&(0,o.jsxs)(a.default,{sx:{mt:1,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,o.jsx)(p.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Attachments:"}),l.attachments.map(e=>"image"===e.type?(0,o.jsx)(a.default,{sx:{mb:.5},children:(0,o.jsx)("img",{src:e.content,alt:e.originalName||"image attachment",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}})},e.id):(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",p:1,borderRadius:1,bgcolor:"rgba(0, 0, 0, 0.04)",mb:.5},children:["document"===e.type?(0,o.jsx)(et.A,{fontSize:"small",sx:{mr:1}}):(0,o.jsx)(en.A,{fontSize:"small",sx:{mr:1}}),(0,o.jsx)(p.default,{variant:"caption",sx:{wordBreak:"break-all"},children:e.originalName||"".concat(e.type," attachment")})]},e.id))]})]})]})}),eE=e=>{let{messages:t,pendingToolCalls:n,availableNodes:l=[],conversationId:i,onToggleDisabled:s,onSplitConversation:d,onEditMessage:h,onApproveToolCall:f,onRejectToolCall:g}=e,[x,m]=(0,r.useState)(50);(0,r.useEffect)(()=>{m(50)},[i]);let v=Math.max(0,(Array.isArray(t)?t.length:0)-x),b=(0,r.useMemo)(()=>Array.isArray(t)?v>0?t.slice(v):t:[],[t,v]),{pairsByAnchorId:y,handoffsByAnchorId:j,consumedToolCallIds:w,groups:A}=(0,r.useMemo)(()=>(function(e){let t=new Map,n=new Map,o=new Set,r=new Set,l=new Map,a=[];if(!Array.isArray(e))return{pairsByAnchorId:t,handoffsByAnchorId:n,hoistedAssistantIds:o,consumedToolCallIds:r,groups:a};let i=new Map;for(let t of e)"tool"===t.role&&"string"==typeof t.tool_call_id&&t.tool_call_id&&!i.has(t.tool_call_id)&&i.set(t.tool_call_id,t);let s=e=>{let o=l.get(e);return o||(o={anchorId:e,memberIds:[e],hoistedIds:[]},l.set(e,o),a.push(o),t.set(e,[]),n.set(e,[])),o},d=null;for(let l of e){if("user"===l.role||"system"===l.role){d=null;continue}if("assistant"!==l.role)continue;let e=Array.isArray(l.tool_calls)?l.tool_calls:[],a=[],p=[];for(let t of e){var c,u;if("function"!==t.type)continue;if((u=null==(c=t.function)?void 0:c.name)&&(u.startsWith(ep.n9)||"handoff"===u)){p.push(t);continue}let e=t.id,n=e?i.get(e):void 0;e&&r.add(e),a.push({toolCall:t,result:n})}let h=function(e){let t=e.content;return"string"==typeof t?t.trim().length>0:!!Array.isArray(t)&&t.some(e=>{var t,n;return!!e&&"object"==typeof e&&("text"===e.type?"string"==typeof e.text&&e.text.trim().length>0:"image_url"===e.type?!!(null==(t=e.image_url)?void 0:t.url):"input_audio"===e.type&&!!(null==(n=e.input_audio)?void 0:n.data))})}(l),f=a.length>0||p.length>0;if(h){d=l.id,f&&(s(l.id),t.get(l.id).push(...a),n.get(l.id).push(...p));continue}if(f)if(d){let e=s(d);t.get(d).push(...a),n.get(d).push(...p),e.memberIds.push(l.id),e.hoistedIds.push(l.id),o.add(l.id)}else d=l.id,s(l.id),t.get(l.id).push(...a),n.get(l.id).push(...p)}return{pairsByAnchorId:t,handoffsByAnchorId:n,hoistedAssistantIds:o,consumedToolCallIds:r,groups:a}})(t),[t]),S=(0,r.useMemo)(()=>new Set(b.map(e=>e.id)),[b]),{renderPairsById:I,renderHandoffsById:C,suppressedIds:k}=(0,r.useMemo)(()=>{let e=new Map,t=new Map,n=new Set;for(let a of A){var o,r,l;let i=null!=(o=y.get(a.anchorId))?o:[],s=null!=(r=j.get(a.anchorId))?r:[],d=null!=(l=a.memberIds.find(e=>S.has(e)))?l:a.anchorId;for(let o of(i.length>0&&e.set(d,i),s.length>0&&t.set(d,s),a.hoistedIds))o!==d&&n.add(o)}return{renderPairsById:e,renderHandoffsById:t,suppressedIds:n}},[A,y,j,S]),[E,T]=r.useState(null),[z,R]=r.useState(null),[D,P]=r.useState(null),[F,M]=r.useState(!1),[_,O]=r.useState(""),[W,H]=r.useState(null),[q,B]=r.useState({}),X=(0,r.useCallback)((e,t)=>{ej.debug("handleMenuOpen called with messageId: ".concat(t)),T(e.currentTarget),R(t)},[]),$=(0,r.useCallback)((e,t)=>{B(n=>({...n,[e]:t}))},[]),V=(0,r.useCallback)(e=>{O(e)},[]),et=(0,r.useCallback)(e=>{H(e)},[]),en=()=>{T(null),R(null)},el=()=>{if(z){let e=t.find(e=>e.id===z);e&&"user"===e.role&&"string"==typeof e.content&&(O(e.content),H(e.processNodeId||(l.length>0?l[0].id:"")),P(z),M(!0)),en()}},ea=()=>{D&&h&&(h(D,_,W||""),M(!1),P(null),H(null))},ec=()=>{M(!1),P(null),H(null)},eh=(0,r.useMemo)(()=>{let e=new Map;for(let t of l)e.set(t.id,t.label);return e},[l]),ef=(0,r.useMemo)(()=>z&&t.find(e=>e.id===z)||null,[z,t]);return(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:[v>0&&(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center"},children:(0,o.jsxs)(u.A,{size:"small",variant:"outlined",onClick:()=>m(e=>e+200),children:["Show earlier messages (",v," more)"]})}),b.map((e,t)=>{if(eA(e)||"tool"===e.role&&"string"==typeof e.tool_call_id&&w.has(e.tool_call_id)||k.has(e.id))return null;let n=F&&e.id===D;return(0,o.jsx)(ek,{message:e,nodeLabel:e.processNodeId?eh.get(e.processNodeId):void 0,availableNodes:l,showRaw:!!q[e.id],toolCallPairs:I.get(e.id),hoistedHandoffs:C.get(e.id),edit:n?{content:_,nodeId:W}:null,onMenuOpen:X,onToggleRaw:$,onEditContentChange:V,onEditNodeChange:et,onSaveEdit:n?ea:void 0,onCancelEdit:n?ec:void 0},e.id||"msg-".concat(v+t))}),(0,o.jsxs)(G.A,{anchorEl:E,open:!!E,onClose:en,children:[ef&&(()=>{ej.debug("Entering menu item rendering logic",{activeMessageId:z}),ej.debug("Active message object for menu:",ef),ej.debug("Active message role for menu:",null==ef?void 0:ef.role);try{let e=!!h,t="user"===ef.role&&e;if(ej.debug("Rendering Edit Message menu item check",{activeMessageId:ef.id,messageRole:ef.role,onEditMessagePropType:typeof h,hasOnEditMessageProp:e,shouldShowEdit:t}),t)return(0,o.jsxs)(U.A,{onClick:el,children:[(0,o.jsx)(K.A,{children:(0,o.jsx)(ei.A,{fontSize:"small"})}),(0,o.jsx)(N.A,{children:"Edit Message"})]});return null}catch(e){return ej.error("Error rendering Edit Message menu item",{error:e}),null}})(),(0,o.jsxs)(U.A,{onClick:()=>{z&&(s(z),en())},children:[(0,o.jsx)(K.A,{children:(0,o.jsx)(Z.A,{fontSize:"small"})}),(0,o.jsx)(N.A,{children:(null==ef?void 0:ef.disabled)?"Enable Message":"Disable Message"})]}),(0,o.jsxs)(U.A,{onClick:()=>{z&&(d(z),en())},children:[(0,o.jsx)(K.A,{children:(0,o.jsx)(ee.A,{fontSize:"small"})}),(0,o.jsx)(N.A,{children:"Split Conversation Here"})]})]}),n&&n.length>0&&(0,o.jsxs)(L.A,{elevation:2,sx:{p:2,mt:2,bgcolor:"warning.light",border:"1px solid",borderColor:"warning.main",borderRadius:2},children:[(0,o.jsxs)(p.default,{variant:"h6",sx:{mb:1,display:"flex",alignItems:"center"},children:[(0,o.jsx)(er.A,{sx:{mr:1}})," Tool Approval Required"]}),(0,o.jsx)(p.default,{variant:"body2",sx:{mb:2},children:"The assistant wants to use the following tool(s). Please approve or reject each request."}),n.map((e,t)=>{let n=(0,eu.yo)(e.function.name),r=e.function.arguments;try{let t=JSON.parse(e.function.arguments);r=JSON.stringify(t,null,2)}catch(e){}return(0,o.jsxs)(J.A,{defaultExpanded:!0,sx:{mb:1,"&:before":{display:"none"},boxShadow:1},children:[(0,o.jsx)(Y.A,{expandIcon:(0,o.jsx)(eo.A,{}),children:(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",width:"100%"},children:[(0,o.jsx)(er.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),(0,o.jsx)(p.default,{variant:"subtitle2",sx:{fontWeight:"bold",flexGrow:1},children:n}),(0,o.jsx)(c.A,{label:"ID: ".concat(e.id?e.id.substring(0,8):"N/A","..."),size:"small",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}})]})}),(0,o.jsxs)(Q.A,{sx:{pt:0},children:[(0,o.jsx)(a.default,{component:"pre",sx:{bgcolor:"action.hover",p:1,borderRadius:"4px",overflowX:"auto",fontFamily:"monospace",fontSize:"0.75rem",my:.5,maxHeight:"150px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:r}),(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:1},children:[(0,o.jsx)(u.A,{variant:"outlined",color:"error",size:"small",startIcon:(0,o.jsx)(ed.A,{}),onClick:()=>g&&g(e.id),disabled:!g,children:"Reject"}),(0,o.jsx)(u.A,{variant:"contained",color:"success",size:"small",startIcon:(0,o.jsx)(es.A,{}),onClick:()=>f&&f(e.id),disabled:!f,children:"Approve"})]})]})]},e.id||"ptc-".concat(t))})]})]})};var eT=n(84869);let eN=(0,ev.h)("frontend/services/transcription");async function ez(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onProgress:n,onStatusChange:o,language:r}=t;try{if(eN.debug("Starting transcription service"),o&&o("Initializing transcription..."),!(0,eT.G)().supported)throw Error("Web Speech API is not supported in this browser");o&&o("Using browser speech recognition...");let t=await (0,eT.S)(e,{language:r,onInterimResult:e=>{o&&o("Transcribing: ".concat(e)),n&&n(50)}});return o&&o("Transcription completed"),eN.debug("Web Speech API transcription completed successfully",{textLength:t.length}),{text:t,success:!0,engine:"webspeech"}}catch(e){return eN.error("Transcription failed",{error:e}),o&&o("Transcription failed"),{text:"Transcription failed. Please check if your browser supports speech recognition.",success:!1,error:e instanceof Error?e.message:String(e)}}}var eR=n(9164),eD=n(9562),eP=n(22822),eF=n(35205),eM=n(77073),e_=n(55930),eO=n(9693),eW=n(4823),eL=n(74879);let eH=(0,ev.h)("frontend/components/Chat/ChatInput"),eq=e=>{var t;let{onSendMessage:n,disabled:l=!1,requireApproval:d=!1,onRequireApprovalChange:h,executeInDebugger:f=!1,onExecuteInDebuggerChange:v,availableNodes:y=[],currentNodeId:j=null,nodeOverrideActive:w=!1,onSelectNode:A}=e,{settings:S}=(0,eR.useStorage)(),[I,C]=(0,r.useState)(""),[E,T]=(0,r.useState)([]),[z,R]=(0,r.useState)(!1),[D,P]=(0,r.useState)(0),[F,_]=(0,r.useState)(null),W=(0,r.useRef)(null),H=(0,r.useRef)(null),q=(0,r.useRef)([]),[B,J]=(0,r.useState)(null),Y=(null==(t=y.find(e=>e.id===j))?void 0:t.label)||(j?"".concat(j.substring(0,6),"..."):"Start"),[Q,X]=(0,r.useState)(!1),[$,V]=(0,r.useState)(""),[Z,ee]=(0,r.useState)(""),[eo,er]=(0,r.useState)("document"),[el,ea]=(0,r.useState)(!1),[ei,es]=(0,r.useState)(0),[ed,ec]=(0,r.useState)(""),eu=()=>{(I.trim()||E.length>0)&&(eH.debug("Sending message",{messageLength:I.length,attachmentsCount:E.length}),n(I,E),C(""),T([]))},ep=async e=>{let t=e.target.files;if(!t||0===t.length)return;let n=t[0];eH.debug("File selected",{fileName:n.name,fileSize:n.size,fileType:n.type}),ee("Processing ".concat(n.name)),er("document"),V(""),ea(!0),X(!0);try{let e=await eh(n);eH.debug("File read successfully",{contentLength:e.length}),V(e),ea(!1)}catch(e){eH.error("Error reading file:",e),V("Error reading file. Please try again with a text file."),ea(!1)}W.current&&(W.current.value="")},eh=e=>new Promise((t,n)=>{let o=new FileReader;o.onload=e=>{var o;(null==(o=e.target)?void 0:o.result)?t(e.target.result):n(Error("Failed to read file"))},o.onerror=()=>{n(Error("Error reading file"))},o.readAsText(e)}),ef=async()=>{eH.debug("Starting audio recording");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});eH.debug("Audio stream obtained successfully"),q.current=[];let t=new MediaRecorder(e);H.current=t,t.ondataavailable=e=>{e.data.size>0&&q.current.push(e.data)},t.onstop=async()=>{let t=new Blob(q.current,{type:"audio/wav"});ee("Audio Recording"),er("audio"),V(""),ea(!0),X(!0);try{if(((null==S?void 0:S.speech)||{enabled:!0,modelSize:"base",autoDownload:!1}).enabled){ec("Initializing transcription..."),es(0);let e=await ez(t,{onProgress:es,onStatusChange:ec,language:navigator.language});if(e.success){let t=e.text;V(t),eH.debug("Transcription successful",{textLength:e.text.length,engine:e.engine})}else V("Error transcribing audio: ".concat(e.error,".")),eH.error("Transcription failed",{error:e.error})}else V("Speech recognition is disabled in settings. Enable it to get automatic transcriptions.")}catch(e){eH.error("Error handling audio recording",{error:e}),V("Failed to process audio: ".concat(e))}finally{ea(!1),e.getTracks().forEach(e=>e.stop())}},t.start(),R(!0);let n=setInterval(()=>{P(e=>e+1)},1e3);_(n)}catch(e){eH.error("Error starting recording:",e),alert("Could not access microphone. Please check permissions.")}};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(L.A,{elevation:3,sx:{p:2,display:"flex",flexDirection:"column",borderRadius:2},children:[E.length>0&&(0,o.jsx)(a.default,{sx:{mb:2,display:"flex",flexWrap:"wrap",gap:1},children:E.map(e=>(0,o.jsxs)(L.A,{variant:"outlined",sx:{p:1,display:"flex",alignItems:"center",borderRadius:1,bgcolor:"background.default"},children:["image"===e.type?(0,o.jsx)(a.default,{component:"img",src:e.content,alt:e.originalName||"pasted image",sx:{width:40,height:40,objectFit:"cover",borderRadius:1,mr:1}}):"document"===e.type?(0,o.jsx)(et.A,{fontSize:"small",sx:{mr:1}}):(0,o.jsx)(en.A,{fontSize:"small",sx:{mr:1}}),(0,o.jsx)(p.default,{variant:"body2",noWrap:!0,sx:{maxWidth:150},children:e.originalName||"".concat(e.type," attachment")}),(0,o.jsx)(s.A,{size:"small",onClick:()=>(e=>{eH.debug("Removing attachment",{id:e}),T(E.filter(t=>t.id!==e))})(e.id),sx:{ml:1},children:(0,o.jsx)(eM.A,{fontSize:"small"})})]},e.id))}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"flex-end"},children:[(0,o.jsx)(eD.A,{fullWidth:!0,multiline:!0,maxRows:4,"data-tour":"chat-input",placeholder:"Type a message...",value:I,onChange:e=>{C(e.target.value)},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(eH.debug("Enter key pressed, sending message"),e.preventDefault(),eu())},onPaste:e=>{var t;let n=null==(t=e.clipboardData)?void 0:t.items;if(!n)return;let o=[];for(let e=0;e<n.length;e++){let t=n[e];if("file"===t.kind&&t.type.startsWith("image/")){let e=t.getAsFile();e&&o.push(e)}}0!==o.length&&(e.preventDefault(),eH.debug("Pasting image attachment(s)",{count:o.length}),o.forEach(e=>{let t=new FileReader;t.onload=t=>{var n;let o=null==(n=t.target)?void 0:n.result;if("string"!=typeof o)return;let r=(e.type.split("/")[1]||"png").split("+")[0];T(t=>[...t,{id:(0,eL.A)(),type:"image",content:o,originalName:e.name&&!/^image\.\w+$/i.test(e.name)?e.name:"Pasted image.".concat(r)}])},t.onerror=()=>eH.error("Failed to read pasted image"),t.readAsDataURL(e)}))},disabled:l,variant:"outlined",sx:{mr:1},InputProps:{sx:{borderRadius:2}}}),(0,o.jsx)(i.A,{title:"Attach document",children:(0,o.jsx)(s.A,{color:"primary",onClick:()=>{var e;eH.debug("File selection triggered"),null==(e=W.current)||e.click()},disabled:l||z,children:(0,o.jsx)(et.A,{})})}),(0,o.jsx)("input",{type:"file",ref:W,onChange:ep,style:{display:"none"},accept:".txt,.md,.json,.csv,.html,.xml,.js,.ts,.jsx,.tsx,.css,.scss"}),(0,o.jsx)(i.A,{title:z?"Stop recording":"Record audio",children:(0,o.jsxs)(s.A,{color:z?"error":"primary",onClick:z?()=>{eH.debug("Stopping audio recording"),H.current&&"inactive"!==H.current.state&&(H.current.stop(),R(!1),F&&(clearInterval(F),_(null)),P(0))}:ef,disabled:l,children:[(0,o.jsx)(en.A,{}),z&&(0,o.jsx)(p.default,{variant:"caption",sx:{position:"absolute",bottom:-15,fontSize:"0.7rem",color:"error.main"},children:(e=>{let t=Math.floor(e/60);return"".concat(t.toString().padStart(2,"0"),":").concat((e%60).toString().padStart(2,"0"))})(D)})]})}),(0,o.jsx)(i.A,{title:"Send message",children:(0,o.jsx)(s.A,{color:"primary",onClick:eu,disabled:l||!I.trim()&&0===E.length,children:(0,o.jsx)(eF.A,{})})})]})," ",(h||A&&y.length>0)&&(0,o.jsxs)(a.default,{sx:{mt:1,display:"flex",justifyContent:"flex-start",alignItems:"center",flexWrap:"wrap",gap:1},children:[A&&y.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{title:w?"Next message will run on this manually picked node — click to change":"Node the next message will run on — click to pick a different one",children:(0,o.jsx)(c.A,{icon:(0,o.jsx)(e_.A,{}),label:Y,size:"small",color:w?"primary":"default",variant:w?"filled":"outlined",onClick:e=>J(e.currentTarget),disabled:l})}),(0,o.jsxs)(G.A,{anchorEl:B,open:!!B,onClose:()=>J(null),children:[(0,o.jsxs)(U.A,{selected:!w,onClick:()=>{A(null),J(null)},children:[(0,o.jsx)(K.A,{children:(0,o.jsx)(eW.A,{fontSize:"small"})}),(0,o.jsx)(N.A,{primary:"Automatic",secondary:"Follow the conversation",secondaryTypographyProps:{variant:"caption"}})]}),(0,o.jsx)(k.A,{}),y.map(e=>(0,o.jsxs)(U.A,{selected:w&&e.id===j,onClick:()=>{A(e.id),J(null)},children:[(0,o.jsx)(K.A,{children:e.id===j?(0,o.jsx)(eO.A,{fontSize:"small"}):null}),(0,o.jsx)(N.A,{primary:e.label})]},e.id))]})]}),h&&(0,o.jsx)(O.A,{control:(0,o.jsx)(eP.A,{checked:d,onChange:e=>h(e.target.checked),size:"small",disabled:l}),label:(0,o.jsx)(p.default,{variant:"caption",children:"Require Tool Approvals"}),sx:{mr:"auto"}}),v&&(0,o.jsx)(O.A,{control:(0,o.jsx)(eP.A,{checked:f,onChange:e=>v(e.target.checked),size:"small",disabled:l}),label:(0,o.jsx)(p.default,{variant:"caption",children:"Execute in Debugger"}),sx:{ml:2}})]})," "]})," ",(0,o.jsxs)(g.A,{open:Q,onClose:()=>!el&&X(!1),maxWidth:"md",fullWidth:!0,children:[(0,o.jsxs)(x.A,{children:[Z,!el&&(0,o.jsx)(s.A,{"aria-label":"close",onClick:()=>X(!1),sx:{position:"absolute",right:8,top:8},children:(0,o.jsx)(eM.A,{})})]}),(0,o.jsx)(m.A,{dividers:!0,children:el?(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",p:4},children:[(0,o.jsx)(M.default,{value:"audio"===eo&&ei?ei:void 0,variant:"audio"===eo&&ei>0?"determinate":"indeterminate"}),"audio"===eo&&(0,o.jsxs)(a.default,{sx:{mt:2,textAlign:"center"},children:[(0,o.jsx)(p.default,{variant:"body2",children:ed||"Processing audio..."}),ei>0&&(0,o.jsxs)(p.default,{variant:"body2",color:"text.secondary",sx:{mt:1},children:[Math.round(ei),"%"]})]})]}):(0,o.jsx)(eD.A,{multiline:!0,fullWidth:!0,minRows:10,maxRows:20,value:$,onChange:e=>V(e.target.value),variant:"outlined",placeholder:"document"===eo?"Document content":"Audio transcription"})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(u.A,{onClick:()=>X(!1),disabled:el,children:"Cancel"}),(0,o.jsx)(u.A,{onClick:()=>{eH.debug("Adding attachment",{type:eo,titleLength:Z.length}),T([...E,{id:(0,eL.A)(),type:eo,content:$,originalName:Z}]),X(!1)},variant:"contained",disabled:el||!$.trim(),children:"Add to Message"})]})]})]})},eB=e=>{var t;let{liveStats:n,onStop:l,stopDisabled:i}=e,[s,d]=(0,r.useState)(()=>Date.now());(0,r.useEffect)(()=>{let e=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(e)},[]);let c=n?Math.max(0,Math.round((s-n.startedAt)/1e3)):0,h=n?Math.round((s-n.lastEventAt)/1e3):0,f=!!n&&h>=60;return(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",alignItems:"center",my:2,gap:.5},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,o.jsx)(M.default,{size:20,color:f?"warning":"primary"}),(0,o.jsx)(p.default,{variant:"body2",color:"textSecondary",children:(null==n?void 0:n.activeNode)?"Running: ".concat(n.activeNode):"Working…"}),(0,o.jsx)(u.A,{variant:"outlined",color:"secondary",size:"small",onClick:l,disabled:i,children:"Stop"})]}),(0,o.jsxs)(p.default,{variant:"caption",color:f?"warning.main":"textSecondary",children:[(null!=(t=null==n?void 0:n.totalTokens)?t:0).toLocaleString()," tokens \xb7 ",c,"s elapsed",f?" \xb7 no activity for ".concat(h,"s — may be stuck"):""]})]})};var eU=n(88538),eJ=n(16963),eY=n(2456),eQ=n(64792),eG=n(71356),eK=n(45202),eX=n(52005),e$=n(77998);let eV=e=>e>=1e3?"".concat((e/1e3).toFixed(e>=1e5?0:1),"k"):"".concat(e),eZ=e=>{var t;let{usage:n,contextInfo:l,availableNodes:s}=e,[d,u]=(0,r.useState)(null);if(!n&&!l)return null;let h=(null==n?void 0:n.byNode)?Object.entries(n.byNode):[],f=null!=(t=null==n?void 0:n.cacheReadTokens)?t:0,g=n?Math.max(0,n.promptTokens-f):0,x=n?Math.max(0,n.totalTokens-f):0,m=(null==l?void 0:l.contextWindow)&&l.contextWindow>0?Math.min(100,Math.round(l.promptTokens/l.contextWindow*100)):void 0;return(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0},children:[n&&x>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{title:"Tokens this conversation — ".concat(g.toLocaleString()," prompt / ").concat(n.completionTokens.toLocaleString()," completion").concat(f>0?" (+".concat(f.toLocaleString()," cached reads, not counted)"):"",". Click for the per-node breakdown."),children:(0,o.jsx)(c.A,{icon:(0,o.jsx)(e$.A,{}),label:"".concat(eV(x)," tokens"),size:"small",variant:"outlined",onClick:e=>u(e.currentTarget),sx:{cursor:"pointer"}})}),(0,o.jsx)(eU.Ay,{open:!!d,anchorEl:d,onClose:()=>u(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,o.jsxs)(a.default,{sx:{p:2,maxWidth:420},children:[(0,o.jsx)(p.default,{variant:"subtitle2",sx:{mb:1},children:"Token usage by node"}),(0,o.jsxs)(eJ.A,{size:"small",children:[(0,o.jsx)(eY.A,{children:(0,o.jsxs)(eQ.A,{children:[(0,o.jsx)(eG.A,{children:"Node"}),(0,o.jsx)(eG.A,{align:"right",children:"Prompt"}),(0,o.jsx)(eG.A,{align:"right",children:"Completion"}),(0,o.jsx)(eG.A,{align:"right",children:"Total"})]})}),(0,o.jsxs)(eK.A,{children:[h.map(e=>{let[t,n]=e;return(0,o.jsxs)(eQ.A,{children:[(0,o.jsx)(eG.A,{children:(0,o.jsx)(i.A,{title:t,children:(0,o.jsx)("span",{children:(e=>{var t;return(null==(t=s.find(t=>t.id===e))?void 0:t.label)||"".concat(e.substring(0,8),"…")})(t)})})}),(0,o.jsx)(eG.A,{align:"right",children:n.promptTokens.toLocaleString()}),(0,o.jsx)(eG.A,{align:"right",children:n.completionTokens.toLocaleString()}),(0,o.jsx)(eG.A,{align:"right",children:n.totalTokens.toLocaleString()})]},t)}),(0,o.jsxs)(eQ.A,{children:[(0,o.jsx)(eG.A,{sx:{fontWeight:"bold"},children:"Total"}),(0,o.jsx)(eG.A,{align:"right",sx:{fontWeight:"bold"},children:n.promptTokens.toLocaleString()}),(0,o.jsx)(eG.A,{align:"right",sx:{fontWeight:"bold"},children:n.completionTokens.toLocaleString()}),(0,o.jsx)(eG.A,{align:"right",sx:{fontWeight:"bold"},children:n.totalTokens.toLocaleString()})]})]})]}),f>0&&(0,o.jsxs)(p.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:["Prompt totals include ",f.toLocaleString()," tokens re-read from the prompt cache. The header chip shows the fresh figure (",x.toLocaleString(),") with those cached reads excluded."]})]})})]}),l&&void 0!==m&&(0,o.jsx)(i.A,{title:"Context of the latest call".concat(l.modelDisplayName?" (".concat(l.modelDisplayName,")"):"",": ").concat(l.promptTokens.toLocaleString()," of ").concat(l.contextWindow.toLocaleString()," tokens"),children:(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:140},children:[(0,o.jsx)(eX.A,{variant:"determinate",value:m,color:m>=90?"error":m>=70?"warning":"primary",sx:{flex:1,height:6,borderRadius:3}}),(0,o.jsxs)(p.default,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:[eV(l.promptTokens),"/",eV(l.contextWindow)," (",m,"%)"]})]})}),l&&void 0===m&&(0,o.jsx)(i.A,{title:"Prompt size of the latest call".concat(l.modelDisplayName?" (".concat(l.modelDisplayName,")"):"",". Set the model's Context Window in its settings to see a usage meter."),children:(0,o.jsxs)(p.default,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:["ctx ",eV(l.promptTokens)]})})]})};var e0=n(56900),e1=n(90057),e2=n(96362),e5=n(9226);let e6=e=>{let{selectedFlowId:t,onSelectFlow:n,disabled:l=!1}=e,[i,s]=(0,r.useState)([]),[d,c]=(0,r.useState)(!0),[h,f]=(0,r.useState)(null),[g,x]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{c(!0),f(null);try{let e=await e1.g.loadFlows();s(e)}catch(e){console.error("Error loading flows:",e),f("Failed to load flows")}finally{c(!1)}})()},[]);let m=e=>{n(e),x(!1)},v=(()=>{if(!t)return"";let e=i.find(e=>e.id===t);return e?e.name:""})();return(0,o.jsxs)(a.default,{children:[(0,o.jsx)(p.default,{variant:"subtitle1",gutterBottom:!0,children:"Select Flow"}),d?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(M.default,{size:20}),(0,o.jsx)(p.default,{variant:"body2",color:"text.secondary",children:"Loading flows..."})]}):h?(0,o.jsx)(p.default,{color:"error",variant:"body2",children:h}):0===i.length?(0,o.jsx)(p.default,{variant:"body2",color:"text.secondary",children:"No flows available. Create some flows in the Flow Builder first."}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(u.A,{variant:"outlined",startIcon:(0,o.jsx)(e0.A,{}),onClick:()=>x(!0),disabled:l,sx:{textTransform:"none",maxWidth:"100%"},children:(0,o.jsx)(a.default,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t&&v||"Select a flow"})}),(0,o.jsx)(p.default,{variant:"caption",color:"text.secondary",display:"block",sx:{mt:.5},children:t?'Using "'.concat(v,'" flow for this conversation'):"Select a flow to use for this conversation"}),(0,o.jsx)(e2.A,{open:g,onClose:()=>x(!1),title:"Select a flow",description:"Pick the flow this conversation will run.",skeleton:(0,o.jsx)(e5.o,{}),emptyMessage:"No flows available. Create some flows in the Flow Builder first.",items:i.map(e=>({key:e.id,content:(0,o.jsx)(e5.A,{flow:e,selected:e.id===t,onSelect:m,pickerMode:!0})}))})]})]})};var e4=n(43076);let e9=(0,ev.h)("frontend/components/Chat/QuickChatDialog"),e3=e=>{let{open:t,onClose:n,onStart:l}=e,[i,h]=(0,r.useState)([]),[f,v]=(0,r.useState)([]),[y,j]=(0,r.useState)(!1),[w,A]=(0,r.useState)(null),[S,I]=(0,r.useState)(""),[C,E]=(0,r.useState)(""),[T,N]=(0,r.useState)({}),[z,R]=(0,r.useState)(!1),[D,P]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!t)return;let e=!1;return j(!0),A(null),(async()=>{try{let[t,n]=await Promise.all([e4.N.loadModels(),ex.S.loadServerConfigs()]);if(e)return;h(t);let o=Array.isArray(n)?n.filter(e=>!e.disabled).map(e=>e.name):[];v(o),I(e=>{var n;return e||(null==(n=t[0])?void 0:n.id)||""})}catch(t){e||(e9.warn("Failed to load models/servers for quick chat",t),A("Could not load models or servers."))}finally{e||j(!1)}})(),()=>{e=!0}},[t]),(0,r.useEffect)(()=>{t||(E(""),N({}),P(null),R(!1))},[t]);let F=(0,r.useCallback)(e=>{N(t=>{let n=t[e];return(null==n?void 0:n.selected)?{...t,[e]:{...n,selected:!1}}:{...t,[e]:{...null!=n?n:{tools:null,expanded:!1},selected:!0}}})},[]),W=(0,r.useCallback)(async e=>{N(t=>{var n;let o=null!=(n=t[e])?n:{selected:!1,tools:null,expanded:!1};return{...t,[e]:{...o,expanded:!o.expanded}}});let t=T[e];if(!(null==t?void 0:t.available)&&!(null==t?void 0:t.loading)){N(t=>{var n;return{...t,[e]:{...null!=(n=t[e])?n:{selected:!1,tools:null,expanded:!0},loading:!0}}});try{let{tools:t}=await ex.S.listServerTools(e),n=Array.isArray(t)?t.map(e=>e.name).filter(Boolean):[];N(t=>{var o;return{...t,[e]:{...null!=(o=t[e])?o:{selected:!1,tools:null,expanded:!0},available:n,loading:!1}}})}catch(t){e9.warn("Failed to load tools for ".concat(e),t),N(t=>{var n;return{...t,[e]:{...null!=(n=t[e])?n:{selected:!1,tools:null,expanded:!0},available:[],loading:!1}}})}}},[T]),L=(0,r.useCallback)((e,t,n)=>{N(o=>{var r,l;let a=null!=(r=o[e])?r:{selected:!0,tools:null,expanded:!0},i=new Set(null!=(l=a.tools)?l:new Set(n));return i.has(t)?i.delete(t):i.add(t),{...o,[e]:{...a,selected:!0,tools:i}}})},[]),J=!!S&&!z&&!y,Y=async()=>{if(!S)return void P("Pick a model to chat with.");R(!0),P(null);let e=f.filter(e=>{var t;return null==(t=T[e])?void 0:t.selected}).map(e=>{let t=T[e];return!t.tools||t.available&&t.tools.size===t.available.length?{name:e}:{name:e,enabledTools:[...t.tools]}});try{await l({modelId:S,servers:e,systemPrompt:C.trim()||void 0})}catch(e){e9.warn("Quick chat failed to start",e),P(e instanceof Error?e.message:"Could not start the quick chat."),R(!1)}};return(0,o.jsxs)(g.A,{open:t,onClose:z?void 0:n,maxWidth:"sm",fullWidth:!0,children:[(0,o.jsx)(x.A,{children:"Quick Chat"}),(0,o.jsxs)(m.A,{children:[(0,o.jsx)(p.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Chat with a model and, optionally, some MCP servers — no need to build and save a flow."}),w&&(0,o.jsx)(d.A,{severity:"error",sx:{mb:2},children:w}),(0,o.jsxs)(H.A,{fullWidth:!0,size:"small",sx:{mb:2},disabled:y,children:[(0,o.jsx)(q.A,{id:"quick-chat-model-label",children:"Model"}),(0,o.jsxs)(B.A,{labelId:"quick-chat-model-label",label:"Model",value:S,onChange:e=>I(e.target.value),children:[0===i.length&&(0,o.jsx)(U.A,{value:"",disabled:!0,children:y?"Loading…":"No models configured"}),i.map(e=>(0,o.jsx)(U.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),(0,o.jsx)(eD.A,{fullWidth:!0,size:"small",multiline:!0,minRows:2,maxRows:6,label:"System prompt (optional)",placeholder:"e.g. You are a concise coding assistant.",value:C,onChange:e=>E(e.target.value),sx:{mb:2}}),(0,o.jsx)(k.A,{sx:{mb:1}}),(0,o.jsx)(p.default,{variant:"subtitle2",gutterBottom:!0,children:"MCP servers (optional)"}),y?(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,o.jsx)(M.default,{size:22})}):0===f.length?(0,o.jsx)(p.default,{variant:"body2",color:"text.secondary",children:"No connected MCP servers. You can still chat with the model alone."}):f.map(e=>{let t=T[e],n=!!(null==t?void 0:t.selected),r=null==t?void 0:t.available,l=null==t?void 0:t.tools;return(0,o.jsxs)(a.default,{sx:{mb:.5},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(O.A,{sx:{flexGrow:1,mr:0},control:(0,o.jsx)(eP.A,{size:"small",checked:n,onChange:()=>F(e)}),label:(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(p.default,{variant:"body2",children:e}),n&&(0,o.jsx)(c.A,{size:"small",variant:"outlined",label:l?"".concat(l.size," tool").concat(1===l.size?"":"s"):"all tools"})]})}),(0,o.jsx)(s.A,{size:"small",onClick:()=>W(e),"aria-label":"customize ".concat(e," tools"),children:(null==t?void 0:t.expanded)?(0,o.jsx)(eg.A,{fontSize:"small"}):(0,o.jsx)(eo.A,{fontSize:"small"})})]}),(0,o.jsx)(_.A,{in:!!(null==t?void 0:t.expanded),unmountOnExit:!0,children:(0,o.jsx)(a.default,{sx:{pl:4,pb:1},children:(null==t?void 0:t.loading)?(0,o.jsx)(M.default,{size:16}):r&&r.length>0?r.map(t=>{let n=!l||l.has(t);return(0,o.jsx)(O.A,{sx:{display:"flex"},control:(0,o.jsx)(eP.A,{size:"small",checked:n,onChange:()=>L(e,t,r)}),label:(0,o.jsx)(p.default,{variant:"caption",children:t})},t)}):(0,o.jsx)(p.default,{variant:"caption",color:"text.secondary",children:r?"No tools reported (server may be offline).":""})})})]},e)}),D&&(0,o.jsx)(d.A,{severity:"error",sx:{mt:2},children:D})]}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(u.A,{onClick:n,disabled:z,children:"Cancel"}),(0,o.jsx)(u.A,{variant:"contained",onClick:Y,disabled:!J,startIcon:z?(0,o.jsx)(M.default,{size:16,color:"inherit"}):void 0,children:z?"Starting…":"Start chat"})]})]})};var e7=n(53940),e8=n(48116),te=n(33567),tt=n(22539),tn=n(33420),to=n(80685);let tr=(0,ev.h)("frontend/components/Chat/DebuggerCanvas"),tl={start:tn.vm,process:tn.Uw,finish:tn.IK,mcp:tn.v2,subflow:tn.lA},ta={custom:to.jY,mcpEdge:to.oY},ti=(0,e8.Ay)(L.A)(e=>{let{theme:t}=e;return{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",padding:t.spacing(1)}}),ts=(0,e8.Ay)(a.default)(e=>{let{theme:t}=e;return{padding:t.spacing(1,2),borderBottom:"1px solid ".concat(t.palette.divider)}}),td=(0,e8.Ay)(a.default)({flexGrow:1,display:"flex",overflow:"hidden"}),tc=(0,e8.Ay)(a.default)(e=>{let{theme:t}=e;return{width:"200px",borderRight:"1px solid ".concat(t.palette.divider),overflowY:"auto",padding:t.spacing(1)}}),tu=(0,e8.Ay)(a.default)({flexGrow:1,position:"relative",height:"100%"}),tp=(0,e8.Ay)(a.default)(e=>{let{theme:t}=e;return{width:"300px",borderLeft:"1px solid ".concat(t.palette.divider),overflowY:"auto",padding:t.spacing(2)}}),th=(0,e8.Ay)(a.default)(e=>{let{theme:t}=e;return{padding:t.spacing(1,2),borderTop:"1px solid ".concat(t.palette.divider),display:"flex",gap:t.spacing(1),justifyContent:"center"}}),tf=e=>{var t,n,l,c;let{debugState:h,conversationId:f,onStep:g,onStepOver:x,onContinue:m,onCancel:v,isLoading:b,breakpoints:y,onToggleBreakpoint:j,onClose:w}=e,A=(0,te.A)(),[S,I]=(0,r.useState)(h.executionTrace&&h.executionTrace.length>0?h.executionTrace.length-1:-1),[C,k]=(0,r.useState)(!0),[R,D]=(0,r.useState)(!0),[P,F]=(0,r.useState)(null),[_,O]=(0,r.useState)(!0),[W,L]=(0,r.useState)(null),[H,q,B]=(0,tt.ck)([]),[U,G,K]=(0,tt.fM)([]);(0,r.useEffect)(()=>{var e;let t=(null==(e=h.executionTrace)?void 0:e.length)||0;t>0?(I(e=>Math.min(e,t-1)),S<t-1&&I(t-1)):I(-1)},[h.executionTrace]),(0,r.useEffect)(()=>{(async()=>{if(!h.flowId){L("Flow ID is missing in debug state."),O(!1);return}O(!0),L(null);try{tr.debug("Loading flow definition for ID: ".concat(h.flowId));let e=await e1.g.getFlow(h.flowId);if(!e)throw Error("Flow with ID ".concat(h.flowId," not found."));F(e),tr.info("Flow definition loaded: ".concat(e.name))}catch(e){tr.error("Error loading flow definition:",e),L(e instanceof Error?e.message:"Failed to load flow definition."),F(null)}finally{O(!1)}})()},[h.flowId]),(0,r.useEffect)(()=>{if(P){tr.debug("Setting nodes and edges from flow definition");let e=P.nodes.map(e=>({...e,draggable:!1,selectable:!1,connectable:!1})),t=P.edges.map(e=>({...e,selectable:!1}));q(e),G(t)}},[P,q,G]);let X=(0,r.useCallback)(()=>{if(tr.debug("Previous button clicked. Current index: ".concat(S)),S>0){let e=S-1;tr.debug("Setting current step index to: ".concat(e)),I(e)}else tr.debug("Already at the first step, cannot go previous.")},[S]),$=(0,r.useCallback)(()=>{var e;if(tr.debug("Next button clicked. Current index: ".concat(S,", Trace length: ").concat(null==(e=h.executionTrace)?void 0:e.length)),h.executionTrace&&S<h.executionTrace.length-1){let e=S+1;tr.debug("Navigating to next trace step: ".concat(e)),I(e)}else tr.info("At end of trace, triggering API call for next step."),g()},[S,h.executionTrace,g]),V=(0,r.useMemo)(()=>{if(h.executionTrace&&S>=0&&S<h.executionTrace.length)return h.executionTrace[S]},[h.executionTrace,S]),Z=(0,r.useMemo)(()=>{let e=null==V?void 0:V.nodeId;return H.map(t=>{var n;let o=t.id===e,r=null==y?void 0:y.includes(t.id);return{...t,style:{...t.style,border:o?"2px solid ".concat(A.palette.warning.main):r?"2px dashed ".concat(A.palette.error.main):null==(n=t.style)?void 0:n.border,boxShadow:o?"0 0 10px ".concat(A.palette.warning.light):void 0}}})},[H,V,y,A]);return(0,o.jsxs)(ti,{elevation:2,children:[(0,o.jsxs)(ts,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,o.jsxs)(a.default,{children:[(0,o.jsx)(p.default,{variant:"h6",children:"Flow Debugger"}),(0,o.jsxs)(p.default,{variant:"caption",color:"textSecondary",display:"block",children:["Click a node to toggle a breakpoint",y&&y.length>0?" \xb7 ".concat(y.length," active"):""]})]}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,o.jsx)(i.A,{title:C?"Hide execution trace":"Show execution trace",children:(0,o.jsx)(s.A,{size:"small",onClick:()=>k(e=>!e),color:C?"primary":"default","aria-label":C?"Hide execution trace":"Show execution trace",children:(0,o.jsx)(e7.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})})}),(0,o.jsx)(i.A,{title:R?"Hide step inspector":"Show step inspector",children:(0,o.jsx)(s.A,{size:"small",onClick:()=>D(e=>!e),color:R?"primary":"default","aria-label":R?"Hide step inspector":"Show step inspector",children:(0,o.jsx)(e7.A,{fontSize:"small"})})}),w&&(0,o.jsx)(i.A,{title:"Close debugger",children:(0,o.jsx)(s.A,{size:"small",onClick:w,"aria-label":"Close debugger",children:(0,o.jsx)(eM.A,{fontSize:"small"})})})]})]}),(0,o.jsxs)(td,{children:[C&&(0,o.jsxs)(tc,{children:[(0,o.jsx)(p.default,{variant:"subtitle2",gutterBottom:!0,children:"Execution Trace"}),(0,o.jsxs)(E.A,{dense:!0,disablePadding:!0,children:[null==(t=h.executionTrace)?void 0:t.map((e,t)=>(0,o.jsx)(T.Ay,{disablePadding:!0,children:(0,o.jsx)(z.A,{selected:t===S,onClick:()=>(e=>{h.executionTrace&&e>=0&&e<h.executionTrace.length?(tr.debug("Trace step selected: ".concat(e)),I(e)):tr.warn("Invalid step index selected: ".concat(e)),I(e),I(e)})(t),children:(0,o.jsx)(N.A,{primary:"".concat(e.stepIndex,": ").concat(e.nodeName||e.nodeId),secondary:e.nodeType})})},e.stepIndex)),b&&(0,o.jsx)(T.Ay,{children:(0,o.jsx)(M.default,{size:20,sx:{margin:"auto"}})})]})]}),(0,o.jsx)(tu,{children:_?(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(M.default,{})}):W?(0,o.jsx)(d.A,{severity:"error",sx:{margin:2},children:W}):(0,o.jsxs)(tt.Ln,{children:[" ",(0,o.jsx)(tt.Gc,{nodes:Z,edges:U,onNodesChange:B,onEdgesChange:K,nodeTypes:tl,edgeTypes:ta,fitView:!0,attributionPosition:"bottom-right",nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!1,onNodeClick:(e,t)=>{e.preventDefault(),j&&j(t.id)},onEdgeClick:e=>e.preventDefault(),onPaneClick:()=>{},children:" "})]})}),R&&(0,o.jsxs)(tp,{children:[(0,o.jsx)(p.default,{variant:"subtitle2",gutterBottom:!0,children:"Step Inspector"}),V?(0,o.jsxs)(a.default,{children:[(0,o.jsxs)(p.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Node:"})," ",V.nodeName," (",V.nodeId,")"]}),(0,o.jsxs)(p.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Type:"})," ",V.nodeType]}),(0,o.jsxs)(p.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Timestamp:"})," ",new Date(V.timestamp).toLocaleString()]}),(0,o.jsxs)(p.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Action Taken:"})," ",V.actionTaken]}),(0,o.jsxs)(J.A,{sx:{mt:2,boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(Y.A,{expandIcon:(0,o.jsx)(eo.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsx)(p.default,{variant:"caption",children:"Prep Result"})}),(0,o.jsx)(Q.A,{sx:{p:0},children:(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify(V.prepResultSnapshot,null,2)})})]}),(0,o.jsxs)(J.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(Y.A,{expandIcon:(0,o.jsx)(eo.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsxs)(p.default,{variant:"caption",color:(null==(n=V.execResultSnapshot)?void 0:n.success)===!1?"error":"inherit",children:["Exec Result ",(null==(l=V.execResultSnapshot)?void 0:l.success)===!1?"(Error)":""]})}),(0,o.jsx)(Q.A,{sx:{p:0},children:(null==(c=V.execResultSnapshot)?void 0:c.success)===!1?(0,o.jsxs)(a.default,{sx:{p:1,background:A.palette.error.light,borderRadius:1},children:[" ",(0,o.jsxs)(p.default,{variant:"body2",color:"error",gutterBottom:!0,children:[(0,o.jsx)("b",{children:"Error:"})," ",V.execResultSnapshot.error||"Unknown error"]}),V.execResultSnapshot.errorDetails&&(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"150px",overflowY:"auto",background:"#f5f5f5",padding:"4px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify(V.execResultSnapshot.errorDetails,null,2)})]}):(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify(V.execResultSnapshot,null,2)})})]}),(0,o.jsxs)(J.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(Y.A,{expandIcon:(0,o.jsx)(eo.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsx)(p.default,{variant:"caption",children:"State Before"})}),(0,o.jsx)(Q.A,{sx:{p:0},children:(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify(V.stateBefore,null,2)})})]}),(0,o.jsxs)(J.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(Y.A,{expandIcon:(0,o.jsx)(eo.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsx)(p.default,{variant:"caption",children:"State After"})}),(0,o.jsx)(Q.A,{sx:{p:0},children:(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify(V.stateAfter,null,2)})})]})]}):(0,o.jsx)(p.default,{variant:"body2",color:"textSecondary",children:"Select a step from the trace."})]})]}),(0,o.jsxs)(th,{children:[(0,o.jsx)(u.A,{variant:"outlined",size:"small",onClick:X,disabled:b||S<=0,children:"Previous"}),(0,o.jsx)(u.A,{variant:"contained",size:"small",onClick:$,disabled:b||-1===S,children:h.executionTrace&&S<h.executionTrace.length-1?"Next Trace Step":"Step Next"}),x&&(0,o.jsx)(u.A,{variant:"outlined",size:"small",onClick:x,disabled:b,children:"Step Over"}),(0,o.jsx)(u.A,{variant:"contained",color:"secondary",size:"small",onClick:m,disabled:b,children:"Continue"}),(0,o.jsx)(u.A,{variant:"outlined",color:"error",size:"small",onClick:v,disabled:b,children:"Stop"})]})]})};function tg(e){return"string"==typeof e&&e.startsWith("quickchat-")}var tx=n(94929),tm=n(29155),tv=n(63650);let tb=(0,ev.h)("frontend/services/chat/index");class ty extends Error{constructor(e,t,n){super(e),this.name="ChatApiError",this.status=t,this.body=n}}let tj="/v1/chat/conversations";async function tw(e){let t;if(204===e.status)return;let n=await e.text();if(n)try{t=JSON.parse(n)}catch(e){t=n}if(!e.ok)throw new ty(t&&"object"==typeof t&&(t.error||t.message)||"Request failed with status ".concat(e.status),e.status,t);return t}class tA{async listConversations(){return tb.debug("listConversations: Entering method"),tw(await fetch(tj))}async getConversation(e){return tb.debug("getConversation: Entering method",{conversationId:e}),tw(await fetch("".concat(tj,"/").concat(encodeURIComponent(e))))}async createConversation(e){return tb.debug("createConversation: Entering method",{conversationId:e.id}),tw(await fetch(tj,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}))}async updateConversationFlow(e,t){return tb.debug("updateConversationFlow: Entering method",{conversationId:e,flowId:t}),tw(await fetch("".concat(tj,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:t})}))}async updateConversationApproval(e,t){return tb.debug("updateConversationApproval: Entering method",{conversationId:e,requireApproval:t}),tw(await fetch("".concat(tj,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApproval:t})}))}async deleteConversation(e){tb.debug("deleteConversation: Entering method",{conversationId:e});let t=await fetch("".concat(tj,"/").concat(encodeURIComponent(e)),{method:"DELETE"});await tw(t)}async respondToToolCall(e,t,n){return tb.debug("respondToToolCall: Entering method",{conversationId:e,action:t,toolCallId:n}),tw(await fetch("".concat(tj,"/").concat(encodeURIComponent(e),"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,toolCallId:n})}))}async debugStep(e){return tb.debug("debugStep: Entering method",{conversationId:e}),tw(await fetch("".concat(tj,"/").concat(encodeURIComponent(e),"/debug/step"),{method:"POST"}))}async debugContinue(e){return tb.debug("debugContinue: Entering method",{conversationId:e}),tw(await fetch("".concat(tj,"/").concat(encodeURIComponent(e),"/debug/continue"),{method:"POST"}))}async setBreakpoints(e,t){tb.debug("setBreakpoints: Entering method",{conversationId:e,count:t.length});let n=await fetch("".concat(tj,"/").concat(encodeURIComponent(e),"/breakpoints"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({breakpoints:t})});await tw(n)}async synthesizeQuickChat(e){return tb.debug("synthesizeQuickChat: Entering method",{conversationId:e.conversationId}),tw(await fetch("/api/flow/quick-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}))}async cancel(e){tb.debug("cancel: Entering method",{conversationId:e});let t=await fetch("".concat(tj,"/").concat(encodeURIComponent(e),"/cancel"),{method:"POST"});await tw(t)}subscribeToEvents(e,t,n){let o=new EventSource(void 0!==n?"".concat(tj,"/").concat(encodeURIComponent(e),"/events?fromSeq=").concat(n):"".concat(tj,"/").concat(encodeURIComponent(e),"/events"));return o.onopen=()=>{var n;tb.debug("Execution event stream open",{conversationId:e}),null==(n=t.onOpen)||n.call(t)},o.onmessage=e=>{try{t.onEvent(JSON.parse(e.data))}catch(e){tb.warn("Failed to parse SSE event",{err:e})}},o.onerror=e=>{var n;tb.debug("SSE stream error (browser will retry if still open)"),null==(n=t.onError)||n.call(t,e)},o}}let tS=new tA,tI=(0,ev.h)("frontend/components/Chat/index");function tC(e){var t;if(Array.isArray(e.content))return e.content;let n="string"==typeof e.content?e.content:"",o=null!=(t=e.attachments)?t:[],r=o.filter(e=>"image"!==e.type),l=o.filter(e=>"image"===e.type);if(r.length>0&&(n+="\n\n"+r.map(e=>"[".concat(e.type.toUpperCase(),"]: ").concat(e.content)).join("\n\n")),0===l.length)return n;let a=[];for(let e of(n.trim()&&a.push({type:"text",text:n}),l))a.push({type:"image_url",image_url:{url:e.content}});return a}let tk=()=>{var e;let[t,n]=(0,r.useState)([]),[l,k]=(0,r.useState)(!0),[E,T]=(0,r.useState)(null),[N,z]=(0,r.useState)(null),[R,D]=(0,r.useState)(!1),[P,M]=(0,r.useState)(null),[_,O]=(0,C.Mj)(C.Zg.CURRENT_CONVERSATION_ID,null),[W,L]=(0,r.useState)(!1),[H,q]=(0,r.useState)(new Set),B=(0,r.useCallback)((e,t)=>{e&&q(n=>{if(t===n.has(e))return n;let o=new Set(n);return t?o.add(e):o.delete(e),o})},[]),[U,J]=(0,r.useState)(null),[Y,Q]=(0,r.useState)([]),[G,K]=(0,r.useState)(!1),[X,$]=(0,r.useState)(!1),[V,Z]=(0,r.useState)(null),[ee,et]=(0,r.useState)(null),[en,eo]=(0,r.useState)(null),[er,el]=(0,r.useState)(!1),[ea,ei]=(0,r.useState)(null),[es,ed]=(0,r.useState)(!1),[ec,eu]=(0,r.useState)(()=>{let e=Number(window.localStorage.getItem("flujo-debugger-width"));return Number.isFinite(e)&&e>0?e:0}),ep=(0,r.useCallback)(e=>{e.preventDefault();let t=document.body.style.userSelect,n=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";let o=e=>{eu(Math.min(Math.max(window.innerWidth-e.clientX,360),Math.round(.85*window.innerWidth)))},r=()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",r),document.body.style.userSelect=t,document.body.style.cursor=n,eu(e=>(e>0&&window.localStorage.setItem("flujo-debugger-width",String(Math.round(e))),e))};window.addEventListener("pointermove",o),window.addEventListener("pointerup",r)},[]),[eh,ef]=(0,r.useState)(()=>{let e=Number(window.localStorage.getItem("flujo-chat-sidebar-width"));return Number.isFinite(e)&&e>0?e:300}),[eg,ex]=(0,r.useState)(()=>"1"===window.localStorage.getItem("flujo-chat-sidebar-collapsed")),em=(0,r.useCallback)(()=>{ex(e=>{let t=!e;return window.localStorage.setItem("flujo-chat-sidebar-collapsed",t?"1":"0"),t})},[]),ev=(0,r.useCallback)(e=>{e.preventDefault();let t=document.body.style.userSelect,n=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";let o=e=>{ef(Math.min(Math.max(e.clientX,220),560))},r=()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",r),document.body.style.userSelect=t,document.body.style.cursor=n,ef(e=>(e>0&&window.localStorage.setItem("flujo-chat-sidebar-width",String(Math.round(e))),e))};window.addEventListener("pointermove",o),window.addEventListener("pointerup",r)},[]),[eb,ey]=(0,r.useState)(null),[ej,ew]=(0,r.useState)([]),[eA,eS]=(0,r.useState)(null),eI=(0,r.useRef)(null),eC=(0,r.useRef)(null),ek=(0,r.useRef)(null),eT=(0,r.useRef)(-1),eN=(0,r.useRef)(_);(0,r.useEffect)(()=>{eN.current=_},[_]);let ez=(0,r.useRef)(null),eR=(0,r.useRef)(!0),[eD,eP]=(0,r.useState)(!1),eF=(0,r.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"auto",t=ez.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),eM=(0,r.useCallback)(()=>{let e=ez.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;eR.current=t,eP(!t)},[]),e_=(0,r.useCallback)(()=>{eR.current=!0,eP(!1),eF("smooth")},[eF]);(0,r.useEffect)(()=>{eR.current=!0,eP(!1)},[_]),(0,r.useEffect)(()=>{eR.current&&eF("auto")},[null==N?void 0:N.messages,eF]);let eO=(0,r.useRef)(null);(0,r.useEffect)(()=>{eO.current=eA},[eA]),(0,r.useEffect)(()=>{let e=window.location.origin+"/v1";eI.current=new tm.Ay({baseURL:e,apiKey:"FLUJO",dangerouslyAllowBrowser:!0,maxRetries:0,timeout:18e6})},[]),(0,r.useEffect)(()=>{(async()=>{tI.debug("Loading flows");try{let e=await e1.g.loadFlows();Q(e)}catch(e){tI.error("Error loading flows:",e)}})()},[]);let eW=(0,r.useCallback)(async(e,t)=>{var o;let r=null!=(o=null==t?void 0:t.silent)&&o;tI.debug("Fetching conversation list from backend",{silent:r}),r||(k(!0),T(null));let l=[],a=!1;try{l=(await tS.listConversations()).sort((e,t)=>t.updatedAt-e.updatedAt),n(l),tI.info("Fetched ".concat(l.length," conversations for the list"))}catch(e){a=!0,tI.error("Error fetching conversation list:",e),r||(T("Failed to load conversation history."),n([]))}finally{if(r||k(!1),r||a)return;let t=void 0!==e?e:eN.current,n=eN.current;if(t&&l.some(e=>e.id===t))t!==n&&(tI.debug("Setting currentConversationId to ".concat(t," after fetch/operation.")),O(t));else if(l.length>0){let e=l[0].id;e!==n&&(tI.debug("Selecting most recent conversation ".concat(e," after fetch/operation.")),O(e))}else null!==n&&(tI.debug("No conversations available after fetch/operation, clearing selection."),O(null))}},[O]);(0,r.useEffect)(()=>{eW()},[]);let eH=(0,r.useCallback)(async e=>{tI.debug("Fetching detailed conversation",{conversationId:e}),D(!0),M(null),z(null);try{let t=await tS.getConversation(e);if(eN.current!==e)return void tI.debug("Discarding stale detailed conversation response",{fetchedId:e,currentId:eN.current});z(t),n(n=>n.map(n=>n.id===e?{...n,title:t.title,flowId:t.flowId,updatedAt:t.updatedAt}:n).sort((e,t)=>t.updatedAt-e.updatedAt)),tI.info("Fetched detailed conversation successfully",{conversationId:e})}catch(t){if(tI.error("Error fetching detailed conversation:",{conversationId:e,err:t}),eN.current!==e)return;t instanceof ty&&404===t.status?(M("Conversation ".concat(e," not found.")),O(null),eW()):M("Failed to load details for conversation ".concat(e,".")),z(null)}finally{eN.current===e&&D(!1)}},[eW,O]);(0,r.useEffect)(()=>{Z(null),eo(null),_?eH(_):(z(null),D(!1),M(null))},[_,eH]),(0,r.useEffect)(()=>{if(N){var e;K(null!=(e=N.requireApproval)&&e)}},[null==N?void 0:N.id]);let eU=(0,r.useCallback)(async e=>{if(K(e),_)try{await tS.updateConversationApproval(_,e)}catch(e){tI.warn("Failed to persist requireApproval setting",{conversationId:_,err:e})}},[_]),eJ=t.find(e=>e.id===_)||null,eY=(0,r.useMemo)(()=>{var e,t;return(null==(t=Y.find(e=>e.id===(null==N?void 0:N.flowId)))||null==(e=t.nodes)?void 0:e.map(e=>({id:e.id,label:e.data.label||e.id})))||[]},[Y,null==N?void 0:N.flowId]),eQ=(0,r.useMemo)(()=>{var e,t,n;let o=e=>!!e&&eY.some(t=>t.id===e);if(o(en))return en;if(o(null==N?void 0:N.currentNodeId))return N.currentNodeId;let r=null!=(t=null==N?void 0:N.messages)?t:[];for(let e=r.length-1;e>=0;e--){let t=r[e];if("assistant"===t.role&&o(t.processNodeId))return t.processNodeId}return null!=(n=null==(e=eY[0])?void 0:e.id)?n:null},[en,N,eY]),eG=async()=>{var e,t;tI.debug("Attempting to create new conversation"),J(null);let o=(null==(e=Y[0])?void 0:e.id)||null;if(!o){tI.error("Cannot create conversation: No flows available or first flow has no ID."),J("Cannot create a new conversation: No flows available.");return}let r=(0,eL.A)(),l=Date.now(),a={id:r,title:"New Conversation",flowId:o,createdAt:l,updatedAt:l};try{tI.info("Sending request to create conversation on backend",{payload:JSON.stringify(a)});let e=await tS.createConversation(a);tI.info("Successfully created conversation on backend",{conversationId:e.id}),n(t=>[e,...t].sort((e,t)=>t.updatedAt-e.updatedAt)),O(e.id),z({id:e.id,title:e.title,flowId:e.flowId,createdAt:e.createdAt,updatedAt:e.updatedAt,messages:[]}),D(!1),M(null)}catch(n){tI.error("Error creating conversation on backend:",n);let e="Failed to create conversation on the server.";n instanceof ty?e+=" Error: ".concat((null==(t=n.body)?void 0:t.error)||n.message):n instanceof Error&&(e+=" Error: ".concat(n.message)),J(e)}},[eK,eX]=(0,r.useState)(!1),e$=async e=>{J(null);let t=(0,eL.A)(),{flow:o}=await tS.synthesizeQuickChat({conversationId:t,modelId:e.modelId,servers:e.servers,systemPrompt:e.systemPrompt}),r=Date.now(),l=await tS.createConversation({id:t,title:"Quick Chat",flowId:o.id,flowSnapshot:o,createdAt:r,updatedAt:r});n(e=>[l,...e].sort((e,t)=>t.updatedAt-e.updatedAt)),O(l.id),z({id:l.id,title:l.title,flowId:l.flowId,createdAt:l.createdAt,updatedAt:l.updatedAt,messages:[]}),D(!1),M(null),eX(!1)},eV=(0,r.useCallback)(e=>{tI.debug("Updating detailed conversation state locally",{conversationId:e.id});let t={...e,updatedAt:Date.now()};z(t),n(e=>e.map(e=>e.id===t.id?{...e,title:t.title,updatedAt:t.updatedAt}:e).sort((e,t)=>t.updatedAt-e.updatedAt))},[]),e0=(0,r.useCallback)(()=>{ek.current&&(tI.debug("Closing execution event stream"),ek.current.close(),ek.current=null)},[]),e2=(0,r.useCallback)(e=>{if("number"==typeof e.seq){if(e.seq<=eT.current)return;eT.current=e.seq}let t=e=>ey(t=>{var n,o,r,l;return{totalTokens:null!=(o=null!=(n=e.totalTokens)?n:null==t?void 0:t.totalTokens)?o:0,activeNode:void 0!==e.activeNode?e.activeNode:null!=(r=null==t?void 0:t.activeNode)?r:null,startedAt:null!=(l=null==t?void 0:t.startedAt)?l:Date.now(),lastEventAt:Date.now()}});switch(e.type){case"run:start":ey({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()});break;case"message":{let n=e.message;t({}),z(t=>{let o;if(!t||t.id!==e.conversationId)return t;let r=t.messages.findIndex(e=>e.id===n.id);return r>=0?(o=[...t.messages])[r]={...o[r],...n}:o=[...t.messages,n],{...t,messages:o}});break}case"usage":ey(t=>{var n,o,r;return{totalTokens:(null!=(n=null==t?void 0:t.totalTokens)?n:0)+(e.totalTokens||0),activeNode:null!=(o=null==t?void 0:t.activeNode)?o:null,startedAt:null!=(r=null==t?void 0:t.startedAt)?r:Date.now(),lastEventAt:Date.now()}});break;case"node:enter":var n,o;t({activeNode:(null==(n=e.node)?void 0:n.nodeName)||(null==(o=e.node)?void 0:o.nodeId)||null});break;case"tool:call":t({activeNode:e.name});break;case"tool:progress":t({activeNode:e.message?"".concat(e.name," — ").concat(e.message):e.name});break;case"subflow:start":t({activeNode:"↳ ".concat(e.subflowName||e.subflowId)});break;case"handoff":t({activeNode:"→ ".concat(e.toNodeId)});break;case"run:awaiting_approval":e.conversationId&&e.conversationId===eN.current&&Z(e.pendingToolCalls||[]);break;case"breakpoint:hit":case"run:paused":L(!1),e.conversationId&&B(e.conversationId,!1),el(!0);break;case"run:done":ey(null),L(!1),eS(null),e.conversationId&&B(e.conversationId,!1),e0(),e.conversationId&&e.conversationId===eN.current?eH(e.conversationId):eW(void 0,{silent:!0});break;case"error":J(e.message||"Execution error");break;default:t({})}},[e0,eH,eW,B]),e5=(0,r.useCallback)((e,t)=>(e0(),eT.current=void 0!==t?t-1:-1,new Promise(n=>{let o=!1,r=()=>{o||(o=!0,n())};try{ek.current=tS.subscribeToEvents(e,{onEvent:e2,onOpen:r},t),setTimeout(r,1500)}catch(t){tI.error("Failed to open execution event stream",{conversationId:e,err:t}),r()}})),[e2,e0]);(0,r.useEffect)(()=>{_&&(null==eJ?void 0:eJ.status)==="running"&&eO.current!==_&&(tI.info("Re-attaching to in-progress run",{conversationId:_}),eO.current=_,L(!0),eS(_),B(_,!0),ey(e=>null!=e?e:{totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),e5(_,0))},[_,null==eJ?void 0:eJ.status,e5]);let e4=async e=>{tI.debug("Attempting to delete conversation",{conversationId:e}),J(null);let o=t.filter(t=>t.id!==e);n(o);let r=_;_===e&&(o.length>0?(r=o[0].id,tI.debug("Deleted current conversation, selecting next most recent",{nextSelectionId:r})):(r=null,tI.debug("Deleted last conversation, clearing selection")),O(r));try{await tS.deleteConversation(e),tI.info("Successfully deleted conversation on backend",{conversationId:e})}catch(o){tI.error("Error deleting conversation:",{conversationId:e,err:o}),J("Failed to delete conversation ".concat(e,". Please try again.")),n(t),O(_)}},e9=async e=>{if(tI.debug("Flow selected, attempting to update",{flowId:e,currentConversationId:_}),J(null),!_){tI.warn("Cannot update flow: No conversation selected."),J("Please select a conversation first.");return}N&&N.id===_&&z({...N,flowId:e,updatedAt:Date.now()}),n(t=>t.map(t=>t.id===_?{...t,flowId:e,updatedAt:Date.now()}:t).sort((e,t)=>t.updatedAt-e.updatedAt));try{let t=await tS.updateConversationFlow(_,e);tI.info("Successfully updated flowId on backend",{conversationId:_,flowId:e}),z(e=>e&&e.id===_?(tI.debug("Confirming detailedConversation update from server response",{conversationId:_,flowId:t.flowId}),{...e,flowId:t.flowId,updatedAt:t.updatedAt}):(tI.debug("Skipping detailedConversation update, ID mismatch or null state",{currentDetailedId:null==e?void 0:e.id,targetId:_}),e)),n(e=>e.map(e=>e.id===_?t:e).sort((e,t)=>t.updatedAt-e.updatedAt))}catch(l){tI.error("Error updating flowId on backend:",{conversationId:_,flowId:e,err:l});let r="Failed to update the selected flow.";if(l instanceof ty){var o;r+=" Error: ".concat((null==(o=l.body)?void 0:o.error)||l.message)}else l instanceof Error&&(r+=" Error: ".concat(l.message));J(r),z(N),n(t)}},e7=async function(e){var t,n;let o,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e.trim()&&0===r.length)return;if(!N){tI.error("Cannot send message, detailed conversation not loaded."),J("Cannot send message: conversation details not loaded.");return}tI.debug("Sending message",{conversationId:N.id,contentLength:e.length,attachmentsCount:r.length});let l=N.messages,a=!l.some(e=>"user"===e.role),i=N.flowId;if(en)o=en,eo(null),tI.debug("Assigning manually picked node ID to user message: ".concat(o));else if(a){let e=Y.find(e=>e.id===i),n=null==e||null==(t=e.nodes)?void 0:t[0];n?(o=n.id,tI.debug("Assigning start node ID to first user message: ".concat(o))):tI.warn("Could not find start node for flow ".concat(i,". User message will not have a processNodeId."))}else{for(let e=l.length-1;e>=0;e--){let t=l[e];if("assistant"===t.role&&t.processNodeId){o=t.processNodeId,tI.debug("Assigning last assistant node ID to user message: ".concat(o));break}}if(!o){let e=Y.find(e=>e.id===i),t=null==e||null==(n=e.nodes)?void 0:n[0];t?(o=t.id,tI.debug("No prior assistant node ID found, falling back to start node ID: ".concat(o))):tI.warn("Could not find start node for fallback in flow ".concat(i,". User message will not have a processNodeId."))}}let s={id:(0,eL.A)(),role:"user",content:e,timestamp:Date.now(),attachments:r.length>0?r:void 0,processNodeId:o},d={...N,messages:[...N.messages,s]};eV(d),d.flowId?await tt(d):(J("Please select a flow for this conversation before sending messages"),z(N))},e8=(0,r.useCallback)((e,t)=>{if(tI.verbose("Handling API response data",JSON.stringify(e)),B(t,"running"===e.status),"paused_debug"===e.status&&e.debugState)return tI.info("API Response: Paused for debugging",{conversationId:t}),ei(e.debugState),el(!0),ed(!0),L(!1),eS(null),e0(),te(),z(n=>(null==n?void 0:n.id)===t&&e.debugState.messages&&JSON.stringify(n.messages)!==JSON.stringify(e.debugState.messages)?(tI.debug("Updating detailed conversation messages from debug state"),{...n,messages:e.debugState.messages,updatedAt:e.debugState.updatedAt}):n),n(n=>n.map(n=>{var o,r;return n.id===t?{...n,title:null!=(o=e.debugState.title)?o:n.title,flowId:null!=(r=e.debugState.flowId)?r:n.flowId,status:"paused_debug",updatedAt:e.debugState.updatedAt}:n}).sort((e,t)=>t.updatedAt-e.updatedAt)),!0;if("completed"===e.status||"error"===e.status?(tI.info("API Response: Execution completed or errored (Status: ".concat(e.status,"). Hiding debugger panel."),{conversationId:t}),el(!1),ei(null),ed(!1)):tI.debug("API Response: Status is '".concat(e.status,"'. Debugger panel visibility unchanged (currently ").concat(er?"visible":"hidden",")."),{conversationId:t}),e.messages&&e.conversation_id===t){let n=e.messages.map((e,n)=>"number"!=typeof e.timestamp||isNaN(e.timestamp)?(tI.warn("Invalid timestamp found in message index ".concat(n," from API response. Defaulting to Date.now()."),{conversationId:t,messageId:e.id,invalidTimestamp:e.timestamp}),{...e,timestamp:Date.now()}):e);z(o=>{var r,l;let a=o;return(null==o?void 0:o.id)===t&&JSON.stringify(o.messages)!==JSON.stringify(n)&&(tI.info("API Response/Polling: Updating detailed conversation messages",{conversationId:t,newMessageCount:n.length}),a={...o,messages:n,updatedAt:e.updatedAt||o.updatedAt}),tI.debug("Polling: setDetailedConversation callback executed.",{conversationId:t,messagesChanged:a!==o,newMessageCount:null!=(l=null==a||null==(r=a.messages)?void 0:r.length)?l:"N/A"}),a})}if("awaiting_tool_approval"===e.status)tI.info("API Response/Polling: Pausing for tool approval",{conversationId:t}),Z(e.pendingToolCalls||[]),L(!1),eS(null),e0(),te();else if("completed"===e.status||"error"===e.status){if(tI.info("API Response/Polling: Stopping due to final status",{conversationId:t,status:e.status}),te(),L(!1),eS(null),e0(),"error"===e.status){var o,r;J((null==(o=e.error)?void 0:o.message)||(null==(r=e.lastResponse)?void 0:r.error)||"Unknown error during execution"),tI.error("API Response/Polling: Execution resulted in error",{conversationId:t,error:e.error||e.lastResponse})}eH(t)}else"running"!==e.status||er?Z(null):(Z(null),eC.current||L(!0));return e.conversation_id===t&&n(n=>n.map(n=>{var o,r,l;return n.id===t?{...n,title:null!=(o=e.title)?o:n.title,flowId:null!=(r=e.flowId)?r:n.flowId,status:null!=(l=e.status)?l:n.status,updatedAt:e.updatedAt||n.updatedAt}:n}).sort((e,t)=>t.updatedAt-e.updatedAt)),!1},[z,Z,L,J,el,ei,n,eH,e0,B]),te=()=>{eC.current&&(tI.debug("Stopping polling interval"),clearInterval(eC.current),eC.current=null)};(0,r.useEffect)(()=>()=>{e0()},[e0]);let tt=async e=>{if(!(null==e?void 0:e.id)||!e.flowId||!eI.current)return tI.error("Cannot send to completions: Missing conversation ID or flow ID.",{id:null==e?void 0:e.id,flowId:null==e?void 0:e.flowId}),J("Cannot send message: Missing conversation ID or flow ID."),!1;Z(null),J(null),L(!0),eS(e.id),B(e.id,!0),ey({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),await e5(e.id);let t=!1;try{let n;if(tg(e.flowId))n="flow-Quick Chat",tI.debug("Sending quick chat to completions",{flowId:e.flowId,conversationId:e.id});else{let t=await e1.g.getFlow(e.flowId);if(!t)throw Error("Flow with ID ".concat(e.flowId," not found"));n="flow-".concat(t.name),tI.debug("Sending to chat completions",{flowId:e.flowId,flowName:t.name,conversationId:e.id})}let o=e.messages.filter(e=>{var t;return!e.disabled&&!((null!=(t=e.depth)?t:0)>0)}).map(e=>{let t=tC(e),n=e.processNodeId,o={id:e.id,timestamp:e.timestamp};return"user"===e.role?{role:"user",content:t,...o,processNodeId:n}:"assistant"===e.role?{role:"assistant",content:t,tool_calls:e.tool_calls,...o,processNodeId:n}:"system"===e.role?{role:"system",content:t,...o,processNodeId:n}:"tool"===e.role?e.tool_call_id?{role:"tool",content:t,tool_call_id:e.tool_call_id,...o,processNodeId:n}:{role:"user",content:"string"==typeof t?"Tool result: ".concat(t):t,...o,processNodeId:n}:{role:"user",content:t,...o,processNodeId:n}}),r=await eI.current.chat.completions.create({model:n,messages:o,stream:!1,metadata:(()=>{let t={flujo:"true",requireApproval:G?"true":void 0,flujodebug:X?"true":void 0,conversationId:e.id},n={};return t.flujo&&(n.flujo=t.flujo),t.requireApproval&&(n.requireApproval=t.requireApproval),t.flujodebug&&(n.flujodebug=t.flujodebug),t.conversationId&&(n.conversationId=t.conversationId),n})()});tI.debug("Chat completion initial response received",{completionId:r.id}),t=!0;let l={...r,status:r.status||"completed",conversation_id:e.id,messages:r.messages||e.messages,pendingToolCalls:r.pendingToolCalls,debugState:r.debugState,error:r.error,lastResponse:r.lastResponse,updatedAt:r.updatedAt||Date.now()},a=e8(l,e.id);a||eC.current?a&&tI.debug("Debug state handled, polling remains stopped."):tI.debug("Starting polling after initial non-debug response.")}catch(r){tI.error("Error calling chat completions API:",r),t=!1;let o="An error occurred while sending the message.";if(r instanceof tv.LG)o="API Error: ".concat(r.message," (Status: ").concat(r.status,")"),r.code&&(o+=" (Code: ".concat(r.code,")")),r.type&&(o+=" [Type: ".concat(r.type,"]")),tI.verbose("APIError details",JSON.stringify(r));else if(r instanceof tv.vc){o="OpenAI Error: ".concat(r.message);let e=r.error;e&&"object"==typeof e&&(e.code&&(o+=" (Code: ".concat(e.code,")")),e.type&&(o+=" [Type: ".concat(e.type,"]"))),tI.verbose("OpenAIError details",JSON.stringify(r))}else if(r instanceof ty){var n;o="Error: ".concat((null==(n=r.body)?void 0:n.error)||r.message),r.status&&(o+=" (Status: ".concat(r.status,")")),tI.verbose("ChatApiError details",JSON.stringify(r.body))}else r instanceof Error&&(o=r.message);J(o),te(),L(!1),eS(null),B(e.id,!1),e0()}finally{}return t},tn=async(e,t,n)=>{if(!N)return;tI.debug("Editing message",{messageId:e,contentLength:t.length,processNodeId:n});let o=N.messages.findIndex(t=>t.id===e);if(-1===o)return;let r={...N.messages[o],content:t,timestamp:Date.now(),processNodeId:n||void 0},l=[...N.messages.slice(0,o),r],a={...N,messages:l};if(eV(a),a.flowId){let e={flujo:"true",requireApproval:G?"true":void 0,flujodebug:X?"true":void 0,conversationId:a.id,processNodeId:n||void 0};if(!eI.current)return;J(null),L(!0),eS(a.id),B(a.id,!0),ey({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),await e5(a.id);try{let t=await e1.g.getFlow(a.flowId);if(!t)throw Error("Flow with ID ".concat(a.flowId," not found"));let n=a.messages.filter(e=>{var t;return!e.disabled&&!((null!=(t=e.depth)?t:0)>0)}).map(e=>{let t=tC(e),n={id:e.id,timestamp:e.timestamp,processNodeId:e.processNodeId};return"user"===e.role?{role:"user",content:t,...n}:"assistant"===e.role?{role:"assistant",content:t,tool_calls:e.tool_calls,...n}:"system"===e.role?{role:"system",content:t,...n}:"tool"===e.role?e.tool_call_id?{role:"tool",content:t,tool_call_id:e.tool_call_id,...n}:{role:"user",content:"string"==typeof t?"Tool result: ".concat(t):t,...n}:{role:"user",content:t,...n}}),o=await eI.current.chat.completions.create({model:"flow-".concat(t.name),messages:n,stream:!1,metadata:(()=>{let t={};return e.flujo&&(t.flujo=e.flujo),e.requireApproval&&(t.requireApproval=e.requireApproval),e.flujodebug&&(t.flujodebug=e.flujodebug),e.conversationId&&(t.conversationId=e.conversationId),e.processNodeId&&(t.processNodeId=e.processNodeId),t})()}),r={...o,status:o.status||"completed",conversation_id:a.id,messages:o.messages||a.messages,pendingToolCalls:o.pendingToolCalls,debugState:o.debugState,error:o.error,updatedAt:o.updatedAt||Date.now()};e8(r,a.id)}catch(e){tI.error("Error sending edited message:",e),J(e instanceof Error?e.message:"Failed to send edited message"),L(!1),eS(null),B(a.id,!1),e0()}}},to=async(e,t)=>{if(_){tI.info("Handling tool response: ".concat(e),{conversationId:_,toolCallId:t}),Z(null),L(!0),eS(_),B(_,!0),J(null),await e5(_);try{let n=await tS.respondToToolCall(_,e,t);tI.debug("Tool response successful",{conversationId:_,action:e,toolCallId:t}),e8(n,_)}catch(r){tI.error("Error sending tool response (".concat(e,")"),{conversationId:_,toolCallId:t,err:r});let o="Failed to ".concat(e," tool call.");if(r instanceof ty){var n;o+=" Error: ".concat((null==(n=r.body)?void 0:n.error)||r.message)}else r instanceof Error&&(o+=" Error: ".concat(r.message));J(o),L(!1),B(_,!1)}}},tr=async()=>{if(_&&er){tI.info("Handling debug step request",{conversationId:_}),L(!0),eS(_),B(_,!0),J(null),await e5(_);try{let e=await tS.debugStep(_);e8(e,_)}catch(e){tI.error("Error during debug step API call",{conversationId:_,err:e}),J(e instanceof Error?e.message:"Failed to execute debug step."),L(!1),B(_,!1),el(!1),ei(null)}finally{}}},tl=async()=>{if(_&&er){tI.info("Handling debug continue request",{conversationId:_}),L(!0),eS(_),B(_,!0),J(null),el(!1),await e5(_);try{let e=await tS.debugContinue(_);e8(e,_)}catch(e){tI.error("Error during debug continue API call",{conversationId:_,err:e}),J(e instanceof Error?e.message:"Failed to continue execution."),L(!1),B(_,!1)}finally{}}};(0,r.useEffect)(()=>{if(ea){var e;ew(null!=(e=ea.breakpoints)?e:[])}},[ea]);let ta=(0,r.useCallback)(async e=>{if(!_)return;let t=ej.includes(e)?ej.filter(t=>t!==e):[...ej,e];ew(t);try{await tS.setBreakpoints(_,t)}catch(e){tI.error("Failed to update breakpoints",{conversationId:_,err:e}),ew(ej)}},[ej,_]),ti=async()=>{if(!_||!er)return;let e=null==ea?void 0:ea.currentNodeId;L(!0),eS(_),B(_,!0),J(null),await e5(_);try{for(let r=0;r<50;r++){var t,n,o;let r=await tS.debugStep(_),l=null!=(o=null==r?void 0:r.status)?o:null==r||null==(t=r.debugState)?void 0:t.status,a=null==r||null==(n=r.debugState)?void 0:n.currentNodeId;if("paused_debug"!==l||a&&a!==e)return void e8(r,_)}tI.warn("Step Over hit iteration cap",{conversationId:_}),L(!1),B(_,!1)}catch(e){tI.error("Error during step over",{conversationId:_,err:e}),J(e instanceof Error?e.message:"Failed to step over."),L(!1),B(_,!1)}},ts=async()=>{if(_){tI.info("Cancelling request",{conversationId:_}),te(),L(!1),eS(null),B(_,!1),ed(!1),e0(),Z(null);try{await tS.cancel(_),tI.debug("Cancel request sent successfully",{conversationId:_}),await eH(_)}catch(e){tI.error("Error sending cancel request",{conversationId:_,err:e}),J("Failed to send cancel request to the server.")}}},td=async()=>{tI.info("Closing debugger panel",{conversationId:_}),el(!1),ei(null),ed(!1),await ts()};tI.debug("Rendering Chat component",{currentConversationId:_,isHandleEditMessageDefined:!0});let tc=(es||er)&&!!ea&&!!_;return(0,o.jsxs)(a.default,{sx:{display:"flex",height:"calc(100vh - 64px)"},children:[eg&&(0,o.jsx)(a.default,{sx:{width:40,flexShrink:0,borderRight:1,borderColor:"divider",display:"flex",justifyContent:"center",pt:1},children:(0,o.jsx)(i.A,{title:"Show conversation sidebar",children:(0,o.jsx)(s.A,{size:"small",onClick:em,"aria-label":"Show conversation sidebar",children:(0,o.jsx)(I.A,{fontSize:"small"})})})}),!eg&&(0,o.jsx)(a.default,{sx:{width:eh,flexShrink:0,borderRight:1,borderColor:"divider",display:"flex",flexDirection:"column"},children:l?(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",p:2},children:(0,o.jsx)(tx.default,{size:"medium",color:"primary"})}):E?(0,o.jsx)(d.A,{severity:"error",sx:{m:2},children:E}):(0,o.jsx)(F,{conversations:t,currentConversationId:_,onSelectConversation:O,onDeleteConversation:e4,onNewConversation:eG,onQuickChat:()=>eX(!0),onCollapse:em})}),!eg&&(0,o.jsx)(a.default,{onPointerDown:ev,sx:{width:"6px",flexShrink:0,cursor:"col-resize",bgcolor:"divider",transition:"background-color 120ms","&:hover":{bgcolor:"primary.main"},touchAction:"none"},"aria-label":"Resize conversation sidebar"}),(0,o.jsxs)(a.default,{sx:{flex:1,height:"100%",display:"flex",minWidth:0,minHeight:0},children:[(0,o.jsxs)(a.default,{sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",height:"100%"},children:[_&&(0,o.jsxs)(a.default,{sx:{p:2,borderBottom:1,borderColor:"divider",display:"flex",alignItems:"center",gap:2},children:[(0,o.jsx)(a.default,{sx:{flex:1,minWidth:0},children:tg((null==eJ?void 0:eJ.flowId)||(null==N?void 0:N.flowId))?(0,o.jsx)(c.A,{color:"primary",variant:"outlined",icon:(0,o.jsx)(j.A,{}),label:"Quick Chat"}):(0,o.jsx)(e6,{selectedFlowId:(null==eJ?void 0:eJ.flowId)||(null==N?void 0:N.flowId)||null,onSelectFlow:e=>{var t,n,o,r;if(!_){tI.warn("Cannot update flow: No conversation selected."),J("Please select a conversation first.");return}let l=null!=(o=null!=(n=null==N?void 0:N.flowId)?n:null==eJ?void 0:eJ.flowId)?o:null;if((null!=(r=null==N||null==(t=N.messages)?void 0:t.length)?r:0)>0&&l&&e!==l){tI.debug("Flow switch on executed conversation — asking for confirmation",{flowId:e,currentFlowId:l}),et(e);return}e9(e)},disabled:er})}),(0,o.jsx)(eZ,{usage:null==N?void 0:N.usage,contextInfo:null==N?void 0:N.contextInfo,availableNodes:eY})]}),(0,o.jsxs)(a.default,{sx:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[(0,o.jsx)(a.default,{ref:ez,onScroll:eM,sx:{flex:1,overflow:"auto",p:2},children:R?(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(tx.default,{size:"medium",color:"primary"})}):P?(0,o.jsx)(d.A,{severity:"error",sx:{m:2},children:P}):N?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(eE,{messages:N.messages,pendingToolCalls:V,availableNodes:eY,conversationId:N.id,onToggleDisabled:e=>{if(!N)return;tI.debug("Toggling message disabled state",{messageId:e});let t=N.messages.map(t=>t.id===e?{...t,disabled:!t.disabled}:t);eV({...N,messages:t})},onSplitConversation:e=>{if(!N)return;tI.debug("Splitting conversation at message",{messageId:e});let t=N.messages.findIndex(t=>t.id===e);if(-1===t)return;let o=N.messages.slice(0,t+1),r=(0,eL.A)(),l={id:r,title:"Split from ".concat(N.title),messages:o,flowId:N.flowId,createdAt:Date.now(),updatedAt:Date.now()},a={id:r,title:l.title,flowId:l.flowId,createdAt:l.createdAt,updatedAt:l.updatedAt};n(e=>[a,...e].sort((e,t)=>t.updatedAt-e.updatedAt)),O(r),z(l),D(!1),M(null)},onEditMessage:tn,onApproveToolCall:e=>{to("approve",e)},onRejectToolCall:e=>{to("reject",e)}}),!W&&!er&&N.messages.length>0&&(null==eJ?void 0:eJ.status)==="completed"&&(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,o.jsx)(d.A,{icon:(0,o.jsx)(A.A,{fontSize:"inherit"}),severity:"success",variant:"filled",sx:{borderRadius:2,py:.5},children:"Conversation completed"})}),!W&&!er&&!U&&(null==eJ?void 0:eJ.status)==="error"&&(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,o.jsx)(d.A,{icon:(0,o.jsx)(S.A,{fontSize:"inherit"}),severity:"error",variant:"filled",sx:{borderRadius:2,py:.5,alignItems:"center"},action:(0,o.jsx)(u.A,{color:"inherit",size:"small",startIcon:(0,o.jsx)(w.A,{}),onClick:()=>{tt(N)},children:"Retry"}),children:"Conversation ended with an error"})}),W&&eA===_&&(0,o.jsx)(eB,{liveStats:eb,onStop:ts,stopDisabled:!_}),U&&(0,o.jsx)(d.A,{severity:"error",sx:{mt:2},action:(0,o.jsx)(u.A,{color:"inherit",size:"small",startIcon:(0,o.jsx)(w.A,{}),onClick:()=>{N&&tt(N)},children:"Retry"}),children:U})]}):(0,o.jsx)(p.default,{variant:"body1",color:"textSecondary",align:"center",sx:{mt:4},children:t.length>0?"Select a conversation or create a new one.":"Create a new conversation to start chatting."})}),(0,o.jsx)(h.A,{in:eD,unmountOnExit:!0,children:(0,o.jsx)(f.A,{size:"small",color:"primary","aria-label":"Scroll to latest messages",onClick:e_,sx:{position:"absolute",bottom:16,right:24,zIndex:2},children:(0,o.jsx)(y.A,{})})})]}),(0,o.jsx)(a.default,{sx:{p:2,borderTop:1,borderColor:"divider"},children:(0,o.jsx)(eq,{onSendMessage:e7,disabled:R||!!_&&H.has(_)||!((null==N?void 0:N.flowId)||(null==eJ?void 0:eJ.flowId))||!!V||er,requireApproval:G,onRequireApprovalChange:eU,executeInDebugger:X,onExecuteInDebuggerChange:$,availableNodes:eY,currentNodeId:eQ,nodeOverrideActive:!!en,onSelectNode:eo})})]})," ",tc&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.default,{onPointerDown:ep,sx:{width:"6px",flexShrink:0,cursor:"col-resize",bgcolor:"divider",transition:"background-color 120ms","&:hover":{bgcolor:"primary.main"},touchAction:"none"},"aria-label":"Resize debugger panel"}),(0,o.jsx)(a.default,{sx:{width:ec?"".concat(ec,"px"):"50%",minWidth:360,maxWidth:"85vw",flexShrink:0,display:"flex",flexDirection:"column",height:"100%"},children:(0,o.jsx)(tf,{debugState:ea,conversationId:_,onStep:tr,onStepOver:ti,onContinue:tl,onCancel:ts,isLoading:W,breakpoints:ej,onToggleBreakpoint:ta,onClose:td})})]})]})," ",(0,o.jsxs)(g.A,{open:!!ee,onClose:()=>et(null),children:[(0,o.jsx)(x.A,{children:"Switch flow?"}),(0,o.jsx)(m.A,{children:(0,o.jsxs)(v.A,{children:["This conversation has already been processed with its current flow."," ","If you switch to"," ",(0,o.jsx)("strong",{children:(null==(e=Y.find(e=>e.id===ee))?void 0:e.name)||"the selected flow"}),","," ","the conversation will continue processing from that flow's Start node again."]})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(u.A,{onClick:()=>et(null),children:"Cancel"}),(0,o.jsx)(u.A,{variant:"contained",onClick:()=>{et(null),ee&&e9(ee)},children:"Switch Flow"})]})]}),(0,o.jsx)(e3,{open:eK,onClose:()=>eX(!1),onStart:e$})]})},tE=(0,ev.h)("frontend/components/ClientOnly");function tT(e){let{children:t}=e,[n,l]=(0,r.useState)(!1);return((0,r.useEffect)(()=>(tE.debug("ClientOnly component mounted"),l(!0),()=>{tE.debug("ClientOnly component unmounted")}),[]),n)?(tE.debug("ClientOnly component rendering children"),(0,o.jsx)(o.Fragment,{children:t})):(tE.debug("ClientOnly component rendering null (not yet mounted)"),null)}let tN=(0,ev.h)("app/chat/page");function tz(){return tN.debug("Rendering ChatPage"),(0,o.jsx)(l.A,{maxWidth:!1,disableGutters:!0,children:(0,o.jsx)(tT,{children:(0,o.jsx)(tk,{})})})}},81956:(e,t,n)=>{"use strict";n.d(t,{A:()=>y});var o=n(95155),r=n(12115),l=n(36314),a=n(86973),i=n(49501),s=n(17681),d=n(21067),c=n(2778),u=n(52363),p=n(65036),h=n(9562),f=n(75912),g=n(70690),x=n(9693),m=n(91665),v=n(7517),b=n(8190);let y=e=>{let{anchorEl:t,open:n,currentFolder:y,folders:j,onClose:w,onAssign:A}=e,[S,I]=(0,r.useState)(!1),[C,k]=(0,r.useState)(""),E=e=>{A(e),w()},T=()=>{let e=C.trim();e&&(I(!1),E(e))};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(l.A,{anchorEl:t,open:n,onClose:w,children:[j.length>0&&j.map(e=>(0,o.jsxs)(a.A,{onClick:()=>E(e),selected:e===y,children:[(0,o.jsx)(i.A,{children:e===y?(0,o.jsx)(x.A,{fontSize:"small"}):(0,o.jsx)(m.A,{fontSize:"small"})}),(0,o.jsx)(s.A,{primary:e})]},e)),j.length>0&&(0,o.jsx)(d.A,{}),(0,o.jsxs)(a.A,{onClick:()=>{k(""),I(!0)},children:[(0,o.jsx)(i.A,{children:(0,o.jsx)(v.A,{fontSize:"small"})}),(0,o.jsx)(s.A,{primary:"New folder…"})]}),y&&(0,o.jsxs)(a.A,{onClick:()=>E(void 0),children:[(0,o.jsx)(i.A,{children:(0,o.jsx)(b.A,{fontSize:"small"})}),(0,o.jsx)(s.A,{primary:"Remove from folder"})]})]}),(0,o.jsxs)(c.A,{open:S,onClose:()=>I(!1),maxWidth:"xs",fullWidth:!0,children:[(0,o.jsx)(u.A,{children:"New folder"}),(0,o.jsx)(p.A,{children:(0,o.jsx)(h.A,{autoFocus:!0,margin:"dense",label:"Folder name",fullWidth:!0,value:C,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),T())}})}),(0,o.jsxs)(f.A,{children:[(0,o.jsx)(g.A,{onClick:()=>I(!1),children:"Cancel"}),(0,o.jsx)(g.A,{variant:"contained",disabled:!C.trim(),onClick:T,children:"Create"})]})]})]})}},84869:(e,t,n)=>{"use strict";n.d(t,{G:()=>a,S:()=>l});let o=(0,n(87021).h)("frontend/services/transcription/webSpeech"),r=()=>"webkitSpeechRecognition"in window||"SpeechRecognition"in window;async function l(e,t){if(!r())throw Error("Web Speech API is not supported in this browser");o.debug("Starting Web Speech API transcription");try{let n=URL.createObjectURL(e),r=new Audio(n),l=new(window.SpeechRecognition||window.webkitSpeechRecognition);return l.continuous=!0,l.interimResults=!0,(null==t?void 0:t.language)&&(l.lang=t.language),new Promise((e,n)=>{let a="";l.onresult=e=>{let n="";for(let t=e.resultIndex;t<e.results.length;t++){let o=e.results[t][0].transcript;e.results[t].isFinal?a+=o+" ":n+=o}(null==t?void 0:t.onInterimResult)&&t.onInterimResult(a+n),o.debug("Recognition interim result",{finalLength:a.length,interimLength:n.length})},l.onend=()=>{o.debug("Recognition ended",{transcriptLength:a.length}),e(a.trim())},l.onerror=e=>{o.error("Recognition error",{error:e.error}),n(Error("Speech recognition error: ".concat(e.error)))},r.onplay=()=>{l.start(),o.debug("Recognition started")},r.onended=()=>{l.stop(),o.debug("Audio playback ended")},r.onerror=e=>{o.error("Audio playback error",{error:e}),l.stop(),n(Error("Error playing audio"))},r.play().catch(e=>{o.error("Error starting audio playback",{error:e}),n(e)})})}catch(e){throw o.error("Error in Web Speech API transcription",{error:e}),e}}function a(){return{supported:r(),message:r()?"Web Speech API is supported":"Web Speech API is not supported in this browser"}}},94929:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var o=n(95155);n(12115);var r=n(94049),l=n(4474);let a=e=>{let{size:t="medium",color:n="primary",className:a="",sx:i={}}=e,s="white"===n?{color:"#fff",...i}:i;return(0,o.jsxs)(r.default,{component:"span",sx:{display:"inline-block",lineHeight:0,...s},className:a,role:"status",children:[(0,o.jsx)(l.default,{size:{small:16,medium:24,large:36}[t],color:"white"===n?"inherit":n,"aria-hidden":"true"}),(0,o.jsx)(r.default,{component:"span",sx:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0},children:"Loading..."})]})}},97206:(e,t,n)=>{Promise.resolve().then(n.bind(n,69732))}},e=>{e.O(0,[3862,2678,4754,9244,8548,690,9562,2003,488,3272,3077,6582,2403,9554,9286,2005,2084,924,9747,9164,2380,4244,8441,1255,7358],()=>e(e.s=97206)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9040],{11947:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var o=a(19868),n=a(89505);function s(e){let{props:t,name:a,defaultTheme:s,themeId:r}=e,i=(0,n.A)(s);return r&&(i=i[r]||i),(0,o.A)({theme:i,name:a,props:t})}},19868:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var o=a(37821);function n(e){let{theme:t,name:a,props:n}=e;return t&&t.components&&t.components[a]&&t.components[a].defaultProps?(0,o.A)(t.components[a].defaultProps,n):n}},32651:(e,t,a)=>{Promise.resolve().then(a.bind(a,71113))},71113:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>x});var o=a(95155),n=a(94049),s=a(12115),r=a(28548),i=a(2300),d=a(25635),l=a(97322),p=a(9562),c=a(56422),m=a(21067),u=a(32683),h=a(51611);let f=[{id:"openai",name:"Chat — OpenAI-compatible",description:'A drop-in OpenAI-compatible surface. In OpenAI-compatible clients (Roo Code, Cline, Cursor, the OpenAI SDK, …) set the Base URL to this instance + "/v1" (e.g. http://localhost:4200/v1) and the model to a flow id (format flow-<NAME>, as listed by /v1/models).',endpoints:[{method:"POST",alsoMethods:["GET","OPTIONS"],path:"/v1/chat/completions",summary:"OpenAI-compatible chat completion. Runs a FLUJO flow as the model. Supports streaming and non-streaming. CORS-enabled; rate-limited (~6000 req/min).",paramsLabel:"Body",params:[{name:"model",type:"string",required:!0,description:"Flow to run, as flow-<NAME>."},{name:"messages",type:"ChatMessage[]",required:!0,description:"Conversation messages (OpenAI shape)."},{name:"stream",type:"boolean",description:"Stream the response as SSE chunks."},{name:"flujo",type:"boolean",description:"Enable FLUJO-specific behavior."},{name:"conversation_id",type:"string",description:"Reuse/continue an existing conversation."},{name:"requireApproval",type:"boolean",description:"Pause for manual tool-call approval."},{name:"flujodebug",type:"boolean",description:"Run in the visual debugger (single-step)."}],response:"OpenAI ChatCompletion object, or an SSE stream of chunks when stream=true."},{method:"GET",path:"/v1/models",summary:"List all flows as OpenAI-style models.",response:'{ object: "list", data: [{ id: "flow-<NAME>", object: "model" }, ...] }'}]},{id:"conversations",name:"Conversations & Execution",description:"Manage conversations and drive flow execution: live event streaming (SSE), tool-call approval, cancellation, and visual-debugger stepping.",endpoints:[{method:"GET",path:"/v1/chat/conversations",summary:"List all conversations (id, title, flowId, createdAt, updatedAt, status), newest first.",response:"Conversation summary array."},{method:"POST",path:"/v1/chat/conversations",summary:"Create a new conversation and initialize its execution state.",paramsLabel:"Body",params:[{name:"id",type:"string",required:!0,description:"Client-generated conversation id."},{name:"title",type:"string",required:!0,description:"Display title."},{name:"flowId",type:"string",required:!0,description:"Flow bound to this conversation."},{name:"createdAt",type:"number",required:!0,description:"Unix ms timestamp."},{name:"updatedAt",type:"number",required:!0,description:"Unix ms timestamp."}]},{method:"GET",alsoMethods:["PATCH","DELETE"],path:"/v1/chat/conversations/{conversationId}",summary:"GET the displayed conversation (messages + metadata); PATCH updates flowId; DELETE removes the conversation and its event log.",paramsLabel:"Body",params:[{name:"flowId",type:"string",description:"New flow id (PATCH only)."}],response:"Conversation with messages, plus usage (token totals, per-node breakdown), status, and contextInfo (latest prompt-token count + the bound model's context window — what the chat token counter and context meter display).",notes:["Messages are a projection of the append-only conversation log when one exists (legacy conversations without a log are served as stored). Node system prompts are never included.","Subflow steps appear inline as depth-tagged, display-only messages (nested in the chat UI); they are never part of the parent's model context."]},{method:"GET",path:"/v1/chat/conversations/{conversationId}/events",summary:"Server-Sent Events stream of execution events (node:enter/exit, message, usage, run:*). Supports Last-Event-ID reconnect.",paramsLabel:"Query",params:[{name:"fromSeq",type:"number",description:"Replay events from this sequence number."}],response:"text/event-stream of ExecutionEvent objects with monotonic seq ids."},{method:"POST",path:"/v1/chat/conversations/{conversationId}/respond",summary:"Approve or reject a pending tool call; resumes execution when all pending calls are handled.",paramsLabel:"Body",params:[{name:"action",type:'"approve" | "reject"',required:!0,description:"Decision for the tool call."},{name:"toolCallId",type:"string",required:!0,description:"Which pending tool call."}]},{method:"POST",path:"/v1/chat/conversations/{conversationId}/cancel",summary:"Request cancellation of an in-progress run (sets the isCancelled flag)."},{method:"PUT",path:"/v1/chat/conversations/{conversationId}/breakpoints",summary:"Set the visual-debugger breakpoint node ids.",paramsLabel:"Body",params:[{name:"breakpoints",type:"string[]",required:!0,description:"Node ids to break on."}]},{method:"POST",path:"/v1/chat/conversations/{conversationId}/debug/step",summary:"Execute exactly one productive step (only when status is paused_debug); pauses after advancing."},{method:"POST",path:"/v1/chat/conversations/{conversationId}/debug/continue",summary:"Resume a debug session — run freely to the next pause, tool approval, or completion."},{method:"PATCH",path:"/v1/chat/conversations/{conversationId}/edit-state",summary:"Edit paused debug state (a message's content, or the next node to run). Only when paused_debug.",paramsLabel:"Body",params:[{name:"messageId",type:"string",description:"Message to edit."},{name:"content",type:"string",description:"New message content."},{name:"currentNodeId",type:"string",description:"Override the next node."}]}]},{id:"model",name:"Models",description:"CRUD for model configurations and provider model discovery. API keys are encrypted at rest and never returned to the browser in clear text.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/model",summary:"GET lists all models; POST creates a model (409 on duplicate name, 201 on success).",paramsLabel:"Body",params:[{name:"model",type:"Model",required:!0,description:"Model config (POST). Secrets are stored encrypted."}],notes:["Stored API keys are masked before reaching the frontend — never expect a clear-text key in a response."]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/model/{id}",summary:"GET / PUT / DELETE a single model. The path id is authoritative on PUT. DELETE returns 204."},{method:"POST",path:"/api/model/provider",summary:"Fetch available models from a provider, using a supplied or stored API key (resolved server-side).",paramsLabel:"Body",params:[{name:"baseUrl",type:"string",required:!0,description:"Provider base URL."},{name:"modelId",type:"string",description:"Existing model whose stored key to reuse."},{name:"searchTerm",type:"string",description:"Filter the returned model list."}],notes:["Accepts an apiKey only inbound to query the provider; keys are never echoed back to the client."]}]},{id:"flow",name:"Flows",description:"CRUD for flow definitions, programmatic flow authoring (FlowSpec), LLM flow generation, and prompt rendering for individual nodes. For creating flows programmatically, prefer POST /api/flow/compile with a FlowSpec — the raw Flow format (ReactFlow JSON) is the internal canvas representation and easy to get subtly wrong.",endpoints:[{method:"POST",path:"/api/flow/compile",summary:"Compile a FlowSpec (the semantic authoring format — see below) into a complete flow, validate it, and optionally save it. Deterministic, no LLM: layout, ids, handles, and MCP wiring are generated for you. THE recommended way for external apps and agents to create flows. Also exposed as MCP tools (create_flow / validate_flow_spec) on /mcp-flows.",paramsLabel:"Body",params:[{name:"spec",type:"FlowSpec",required:!0,description:"The flow specification (format below)."},{name:"save",type:"boolean",description:"Persist the flow — only happens when validation finds ZERO errors."}],response:"{ flow, validation: { issues, errorCount, warningCount, isRunnable }, saved } — 201 when saved, 200 otherwise. Iterate on the issues until clean.",details:'A FlowSpec is a JSON object describing a FLUJO flow semantically — node keys and edges, no coordinates, no ids, no layout:\n{\n "name": "short_flow_name", // letters/digits/_/- only\n "description": "what the flow does",\n "nodes": [ ... ],\n "edges": [ ... ]\n}\n\nNODE TYPES:\n- { "key": "unique_key", "type": "start", "label": "...", "prompt": "system-level instructions for the whole flow" }\n- { "key": "...", "type": "process", "label": "...", "description": "what this step does",\n "model": "<model id or name from the catalog>",\n "prompt": "instructions for this step",\n "servers": [ { "name": "<server name>", "tools": ["tool_a"] } ], // optional; omit "tools" to enable all\n "inputMode": "full-history" | "latest-message" | "isolated", // optional, default full-history\n "isolatedPrompt": "...", // only with inputMode "isolated"\n "outputMode": "full-conversation" | "latest-message" } // optional, default full-conversation; latest-message hides this step\'s tool calls/results from later steps (they see only its final response)\n- { "key": "...", "type": "subflow", "label": "...",\n "flow": "<existing flow name or id>", // reference an EXISTING flow, OR:\n "subflowSpec": { ...a nested FlowSpec... }, // define a brand-new child flow INLINE (compiled into its own flow and wired automatically)\n "inputMode": "full-history" | "latest-message" | "isolated",\n "allowCallerPrompt": true | false, // optional, only with inputMode "isolated"; when true a routing step may pass a "prompt" via its handoff tool that overrides the subflow\'s "prompt" (default)\n "outputMode": "steps" | "final-only" }\n- { "key": "...", "type": "finish", "label": "..." }\n\nEDGES: { "from": "<node key>", "to": "<node key>", "bidirectional": true|false }\n\nRULES:\n1. Exactly ONE start node; at least one finish node reachable from it.\n2. Every process node MUST reference a configured model (by id, display name, or name).\n3. A process step uses MCP tools ONLY via its "servers" list — never emit nodes of type "mcp".\n4. Do not embed ${tool:...} or ${resource:...} references in prompts — tools are wired through "servers".\n5. Branching: give a process node multiple outgoing edges; its model decides where to hand off at runtime. "bidirectional": true lets the target hand back to the source (agent <-> agent).\n6. A subflow node may have only ONE outgoing edge. Give it EITHER a "flow" (naming an existing flow) OR a "subflowSpec" (an inline nested FlowSpec that becomes its own child flow) — not both. A "subflowSpec" may itself contain subflow nodes with their own "subflowSpec" (bounded nesting), so you can author whole multi-level flows in one object.\n7. Keep flows minimal — only the steps the task needs. Write clear, specific prompts and labels; fill "description" on process nodes.'},{method:"POST",path:"/api/flow/generate",summary:"Generate a draft flow from a natural-language description using one of your configured models. The model authors a FlowSpec, FLUJO compiles + validates it and feeds problems back for a bounded number of repair rounds. The generator can always SEARCH the public MCP registry; with allowInstall it can also INSTALL servers it needs. Returns an UNSAVED draft (the UI opens it in the builder for review); persist via the normal save path or /api/flow/compile.",paramsLabel:"Body",params:[{name:"description",type:"string",required:!0,description:"What the flow should do, in plain language."},{name:"modelId",type:"string",required:!0,description:"Configured model that does the generating."},{name:"maxRepairs",type:"number",description:"Repair rounds after the first attempt (default 1, max 2)."},{name:"allowInstall",type:"boolean",description:"Let the generator install MCP servers from the public registry (downloads + RUNS third-party packages on this machine). Off by default."}],response:"{ flow, validation, attempts, installedServers } — the flow is a draft; nothing flow-related is persisted by this endpoint (installed servers ARE persisted).",notes:["allowInstall executes third-party code with this machine's user permissions — opt in deliberately."]},{method:"GET",alsoMethods:["POST"],path:"/api/flow",summary:"GET lists all flow definitions; POST creates a flow (create-only; 409 if the id exists). POST takes the raw internal Flow format — prefer /api/flow/compile for programmatic creation.",paramsLabel:"Body",params:[{name:"flow",type:"Flow",required:!0,description:"Flow object including id (POST)."}]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/flow/{id}",summary:"GET / PUT / DELETE a single flow. On PUT the path id wins over the body id (404 if missing)."},{method:"POST",path:"/api/flow/prompt-renderer",summary:"Render the assembled prompt for a node within a flow.",paramsLabel:"Body",params:[{name:"flowId",type:"string",required:!0,description:"Flow containing the node."},{name:"nodeId",type:"string",required:!0,description:"Node to render."},{name:"options",type:"object",description:"Render options."}]}]},{id:"planned-executions",name:"Planned Executions",description:"Run flows headlessly on triggers: schedules (cron), inbound webhooks, and more. Managed from the Executions page; each run is recorded in a per-execution run history.",endpoints:[{method:"GET",alsoMethods:["POST","PATCH"],path:"/api/planned-executions",summary:"GET lists all planned executions with live trigger status and last run; POST creates one; PATCH toggles the global pause switch ({ paused: boolean }).",response:"GET: { paused, executions: [{ execution, status, lastRun }] }."},{method:"GET",alsoMethods:["PATCH","DELETE"],path:"/api/planned-executions/{id}",summary:"GET / PATCH / DELETE a single planned execution. PATCH takes a partial config and re-arms the trigger."},{method:"POST",path:"/api/planned-executions/{id}/run",summary:"Run now: fire the execution immediately (even while disabled or paused) and wait for the run.",response:"{ record: RunRecord } with status, output preview, and token usage."},{method:"GET",path:"/api/planned-executions/{id}/runs",summary:"The execution’s run history (newest 100 runs, oldest first)."},{method:"POST",path:"/api/planned-executions/preview-schedule",summary:"Validate a cron pattern and preview its next fire times (editor helper).",paramsLabel:"Body",params:[{name:"cron",type:"string",required:!0,description:"Cron pattern (5 or 6 fields)."},{name:"timezone",type:"string",description:"IANA timezone name."}],response:"{ valid, error?, nextRuns: string[] }."},{method:"POST",path:"/api/webhooks/{id}",summary:"Inbound webhook trigger. Fires the planned execution with the request body as trigger context and responds 202 { runId } immediately (the flow runs in the background). For a synchronous answer use /v1/chat/completions instead.",paramsLabel:"Query",params:[{name:"token",type:"string",required:!0,description:"Per-execution secret (alternatively send the X-Flujo-Token header)."}],notes:["Localhost-only by default; external callers must be explicitly allowed per execution.","The webhook body is untrusted input to the flow — prompts should treat it as data."]}]},{id:"mcp",name:"MCP Servers",description:"Manage MCP server configurations, connection state, tool discovery, and tool invocation.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/mcp/servers",summary:"GET lists all MCP server configs; POST registers a new one (409 on duplicate name).",paramsLabel:"Body",params:[{name:"config",type:"MCPServerConfig",required:!0,description:"Server config (POST)."}]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/mcp/servers/{name}",summary:"GET / PUT / DELETE a server config. PUT merges fields; toggling disabled connects/disconnects; a new name triggers a validated rename."},{method:"GET",path:"/api/mcp/servers/{name}/status",summary:"Live connection status. Always 200, even when the server is down.",response:"{ status, ... }"},{method:"GET",path:"/api/mcp/servers/{name}/tools",summary:"List tools exposed by a connected server.",response:"{ tools, error? } (empty tools + error when disconnected)."},{method:"POST",path:"/api/mcp/servers/{name}/tools/{toolName}",summary:"Invoke a tool on a server. Status may reflect the tool itself (408 on timeout).",paramsLabel:"Body",params:[{name:"args",type:"Record<string, unknown>",required:!0,description:"Tool arguments."},{name:"timeout",type:"number",description:"Optional timeout (ms)."}]},{method:"POST",path:"/api/mcp/test-connection",summary:"Run a real MCP handshake against an unsaved config (tests custom CAs and headers) without registering it.",paramsLabel:"Body",params:[{name:"config",type:"MCPServerConfig",required:!0,description:"Config to test."}]},{method:"POST",path:"/api/mcp/cancel",summary:"Cancel an in-progress tool execution; force-reconnects if no token is supplied.",paramsLabel:"Body",params:[{name:"reason",type:"string",required:!0,description:"Cancellation reason."}]}]},{id:"mcp-proxy",name:"FLUJO as an MCP server (proxy)",description:'Re-expose a configured MCP server to EXTERNAL MCP clients (Claude Desktop, Cursor, Cline, mcp-inspector, …) so you configure the server once in FLUJO and reach it everywhere. Enable per server via the "Expose to external apps" toggle on its card. In your MCP client, add a Streamable-HTTP server with the URL below. One downstream server per endpoint, so tool names are unchanged. Localhost-only for now (no auth token in this version — see the security roadmap).',endpoints:[{method:"POST",alsoMethods:["GET","DELETE"],path:"/mcp-proxy/{server}",summary:'A Streamable-HTTP MCP endpoint that forwards tools/list and tools/call to the named downstream MCP server. {server} is the configured server name; it must have "Expose to external apps" enabled (otherwise 404). Rejects non-localhost requests.',response:"MCP JSON-RPC over Streamable HTTP (handled by your MCP client, not called directly)."}]},{id:"mcp-flows",name:"FLUJO as an MCP server (flows + authoring)",description:"A Streamable-HTTP MCP endpoint that exposes FLUJO itself to external MCP clients. Every saved flow is a callable tool (running it ephemerally and returning its output), and three authoring tools let an external agent CREATE flows by sending a semantic FlowSpec — no raw ReactFlow JSON required. Localhost-only (same posture as the proxy).",endpoints:[{method:"POST",alsoMethods:["GET","DELETE"],path:"/mcp-flows",summary:'MCP server with two tool families. Flow tools: one per saved flow (name = slug of the flow name; input = a single "input" string sent as the user turn; runs are ephemeral and never appear in the chat sidebar). Authoring tools: list_flow_building_blocks (models, MCP servers + tools, and existing flows a spec may reference — call first), validate_flow_spec (compile + validate without saving; iterate on the returned issues), create_flow (compile + validate + save; only saves when validation finds zero errors), plus capability acquisition: search_mcp_marketplace (search the public registry) and install_mcp_server (install + connect a registry server — downloads and RUNS third-party packages on the FLUJO host; required keys can be passed via its env argument). The FlowSpec format is documented on POST /api/flow/compile above and inside the tools\' own descriptions.',response:"MCP JSON-RPC over Streamable HTTP (handled by your MCP client, not called directly)."}]},{id:"oauth",name:"OAuth (for MCP)",description:"OAuth authorization flow for MCP servers that require it. Tokens are stored server-side and never sent to the browser.",endpoints:[{method:"POST",path:"/api/oauth/initiate",summary:"Begin the OAuth flow for a server; dynamically registers a client and returns an authorization URL.",paramsLabel:"Body",params:[{name:"serverName",type:"string",required:!0,description:"MCP server to authorize."}]},{method:"GET",alsoMethods:["POST"],path:"/api/oauth/callback",summary:"OAuth redirect target; exchanges the code for tokens, updates the config, and redirects to /mcp.",notes:["Tokens are persisted server-side only."]},{method:"POST",path:"/api/oauth/reset",summary:"Clear a server's OAuth tokens and force re-authentication on the next connection.",paramsLabel:"Body",params:[{name:"serverName",type:"string",required:!0,description:"Server to reset."}]}]},{id:"env",name:"Environment & Secrets",description:"Global environment variables and server-side encryption operations. Secret values are encrypted at rest and masked as ******** in responses.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/env",summary:"GET reads env vars (secrets masked); POST sets/deletes vars (secrets encrypted server-side).",paramsLabel:"Body",params:[{name:"action",type:'"set" | "setAll" | "delete"',required:!0,description:"Operation."},{name:"key",type:"string",description:"Variable name (set/delete)."},{name:"value",type:"string",description:"Value; the placeholder ******** is ignored."},{name:"metadata",type:"{ isSecret: boolean }",description:"Marks a value for encryption."}],notes:["GET masks secret values unless an internal includeSecrets flag is set; the browser never receives clear-text secrets."]},{method:"POST",path:"/api/encryption/secure",summary:"Server-side encryption operations: initialize, authenticate, change_password, encrypt, verify_password, check_initialized, and status queries.",paramsLabel:"Body",params:[{name:"action",type:"string",required:!0,description:"One of the encryption actions."}],notes:["Passwords and tokens are handled here and stay server-side — never log or surface them in the UI."]}]},{id:"storage",name:"Storage & Backup",description:"Generic key-value storage plus zip backup/restore of selected data.",endpoints:[{method:"GET",alsoMethods:["POST","DELETE"],path:"/api/storage",summary:"GET loads an item by StorageKey (with optional default); POST saves; DELETE clears.",paramsLabel:"Query",params:[{name:"key",type:"StorageKey",required:!0,description:"Storage key."},{name:"defaultValue",type:"JSON",description:"Returned when the key is missing (GET)."}]},{method:"POST",path:"/api/backup",summary:"Create a zip backup of selected items and download it.",paramsLabel:"Body",params:[{name:"selections",type:"string[]",required:!0,description:"e.g. models, mcpServers, flows, chatHistory, settings."}],notes:["A backup may include the encryption key and secrets — handle the downloaded file carefully."]},{method:"POST",path:"/api/restore",summary:"Restore data from a backup zip.",paramsLabel:"Form data",params:[{name:"file",type:"File (zip)",required:!0,description:"Backup archive."},{name:"selections",type:"JSON string[]",required:!0,description:"Which items to restore."}]}]},{id:"system",name:"System & Updates",description:"App initialization, working-directory info, repository operations, and self-update.",endpoints:[{method:"GET",path:"/api/init",summary:"Server-side initialization: verify storage and start enabled MCP servers."},{method:"GET",path:"/api/cwd",summary:"Return the current working directory and the mcp-servers directory path."},{method:"GET",path:"/api/browse",summary:"List a directory of the machine running FLUJO, for the folder-picker dialogs (file-watch triggers, MCP server paths). Defaults to the home directory; includes available drives on Windows.",paramsLabel:"Query",params:[{name:"path",type:"string",description:"Absolute directory path to list."}],response:"{ path, parent, home, sep, drives, entries: [{ name, path, isDirectory }] }",notes:["Exposes backend filesystem listings — like the rest of the API it assumes a single trusted user."]},{method:"POST",path:"/api/git",summary:"Repository operations for MCP servers: clone, install, build, run, exists, readFile, listDir, list, checkUpdates, checkUpdatesBatch, pullUpdates.",paramsLabel:"Body",params:[{name:"action",type:"string",required:!0,description:"Operation to perform."}]},{method:"GET",alsoMethods:["POST"],path:"/api/update",summary:'GET checks for a newer version (git fetch + behind count); POST { action: "apply" } pulls, rebuilds, and restarts.',response:"{ success, isGitRepo, updateAvailable, behindBy?, branch?, currentVersion }"}]}],y={GET:"#2e7d32",POST:"#1565c0",PUT:"#ed6c02",PATCH:"#9c27b0",DELETE:"#c62828",OPTIONS:"#616161"};function g(e){let{method:t}=e;return(0,o.jsx)(r.A,{label:t,size:"small",sx:{bgcolor:y[t],color:"#fff",fontWeight:700,fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.7rem",height:22}})}function v(e){var t,a,s,r;let{endpoint:l}=e;return(0,o.jsxs)(i.A,{variant:"outlined",sx:{p:2,mb:1.5},children:[(0,o.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap",mb:1},children:[(0,o.jsx)(g,{method:l.method}),null==(t=l.alsoMethods)?void 0:t.map(e=>(0,o.jsx)(g,{method:e},e)),(0,o.jsx)(d.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.9rem",wordBreak:"break-all"},children:l.path})]}),(0,o.jsx)(d.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5*(null!=(a=l.params)&&!!a.length)},children:l.summary}),l.params&&l.params.length>0&&(0,o.jsxs)(n.default,{sx:{mb:1},children:[(0,o.jsx)(d.default,{variant:"caption",sx:{fontWeight:700,textTransform:"uppercase",color:"text.secondary"},children:null!=(r=l.paramsLabel)?r:"Parameters"}),(0,o.jsx)(n.default,{component:"ul",sx:{m:0,mt:.5,pl:2.5},children:l.params.map(e=>(0,o.jsx)(n.default,{component:"li",sx:{mb:.25},children:(0,o.jsxs)(d.default,{variant:"body2",component:"span",children:[(0,o.jsx)(n.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontWeight:600},children:e.name}),(0,o.jsxs)(n.default,{component:"span",sx:{color:"text.secondary"},children:[" ",e.type,e.required?" \xb7 required":""," — ",e.description]})]})},e.name))})]}),l.response&&(0,o.jsxs)(d.default,{variant:"body2",sx:{mt:.5},children:[(0,o.jsxs)(n.default,{component:"span",sx:{fontWeight:600},children:["Response:"," "]}),(0,o.jsx)(n.default,{component:"span",sx:{color:"text.secondary"},children:l.response})]}),null==(s=l.notes)?void 0:s.map((e,t)=>(0,o.jsxs)(d.default,{variant:"caption",sx:{display:"block",mt:1,color:"warning.main"},children:["⚠ ",e]},t)),l.details&&(0,o.jsx)(n.default,{component:"pre",sx:{mt:1.5,p:1.5,bgcolor:"action.hover",borderRadius:1,fontSize:"0.75rem",fontFamily:"monospace",whiteSpace:"pre-wrap",overflowX:"auto",m:0,mb:0},children:l.details})]})}function b(){let[e,t]=(0,s.useState)(""),[a,r]=(0,s.useState)("");s.useEffect(()=>{r(window.location.origin)},[]);let y=(0,s.useMemo)(()=>{let t=e.trim().toLowerCase();return t?f.map(e=>{let a=e.endpoints.filter(a=>{var o;return"".concat(a.method," ").concat((null!=(o=a.alsoMethods)?o:[]).join(" ")," ").concat(a.path," ").concat(a.summary).toLowerCase().includes(t)||e.name.toLowerCase().includes(t)});return{...e,endpoints:a}}).filter(e=>e.endpoints.length>0):f},[e]);return(0,o.jsxs)(l.A,{maxWidth:"md",sx:{py:5},children:[(0,o.jsx)(d.default,{variant:"h4",gutterBottom:!0,children:"API Documentation"}),(0,o.jsx)(d.default,{variant:"body1",color:"text.secondary",sx:{mb:2},children:"FLUJO exposes an OpenAI-compatible chat API and a REST surface for managing models, MCP servers, flows, and conversations. All endpoints are served from this instance."}),(0,o.jsxs)(i.A,{variant:"outlined",sx:{p:2,mb:3},children:[(0,o.jsx)(d.default,{variant:"subtitle2",gutterBottom:!0,children:"Base URL"}),(0,o.jsx)(n.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.9rem"},children:a||"http://localhost:4200"}),(0,o.jsxs)(d.default,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["Point any OpenAI SDK at"," ",(0,o.jsx)(n.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace"},children:(a||"http://localhost:4200")+"/v1"})," ","and set the model to"," ",(0,o.jsx)(n.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace"},children:"flow-<NAME>"}),". Any API key value is accepted locally."]})]}),(0,o.jsx)(p.A,{fullWidth:!0,size:"small",placeholder:"Search endpoints (path, method, description)…",value:e,onChange:e=>t(e.target.value),sx:{mb:3},InputProps:{startAdornment:(0,o.jsx)(c.A,{position:"start",children:(0,o.jsx)(h.A,{fontSize:"small"})})}}),0===y.length&&(0,o.jsxs)(d.default,{color:"text.secondary",children:["No endpoints match “",e,"”."]}),y.map(e=>(0,o.jsxs)(n.default,{sx:{mb:4},id:e.id,children:[(0,o.jsx)(d.default,{variant:"h6",gutterBottom:!0,children:e.name}),(0,o.jsx)(d.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:e.description}),e.endpoints.map(e=>(0,o.jsx)(v,{endpoint:e},"".concat(e.method," ").concat(e.path)))]},e.id)),(0,o.jsx)(m.A,{sx:{my:3}}),(0,o.jsxs)(d.default,{variant:"caption",color:"text.secondary",children:["Secrets (API keys, encryption passwords, OAuth tokens) are encrypted at rest and never returned to the browser in clear text. See the project"," ",(0,o.jsx)(u.A,{href:"https://github.com/mario-andreschak/FLUJO",target:"_blank",rel:"noopener",children:"repository"})," ","for source-level details."]})]})}let w=(0,a(87021).h)("app/docs/page");function x(){return w.debug("Rendering DocsPage"),(0,o.jsx)(n.default,{component:"main",sx:{minHeight:"100vh"},children:(0,o.jsx)(b,{})})}},78831:(e,t,a)=>{"use strict";a.d(t,{A:()=>o});let o=(0,a(80271).Ay)()},87021:(e,t,a)=>{"use strict";a.d(t,{h:()=>d});let o={LOG_LEVEL:3},n={VERBOSE:-1,DEBUG:0,INFO:1,WARN:2,ERROR:3},s="number"==typeof o.LOG_LEVEL?o.LOG_LEVEL:n.ERROR;function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t>6)return String(e);if(!(e instanceof Error))return e;let a={name:e.name,message:e.message};for(let o of Object.getOwnPropertyNames(e)){if("name"===o||"message"===o)continue;let n=e[o];"function"!=typeof n&&("stack"===o?a.stack=n:"cause"===o?a.cause=r(n,t+1):"errors"===o&&Array.isArray(n)?a.errors=n.map(e=>r(e,t+1)):a[o]=n)}return a}function i(e,t,a,o,i){if(e>=("number"==typeof i?i:s)){if("function"==typeof o)try{o=o()}catch(e){o="[lazy log data threw]"}let s=new Date().toISOString(),i="[".concat(s,"] [").concat(t,"]"),d="".concat(i," ").concat(a);if(void 0!==o)if(o instanceof Error||"object"==typeof o)try{let e=o instanceof Error?r(o):o,t=JSON.stringify(e,(e,t)=>t instanceof Error?r(t):t,2);d+=":\n".concat(t)}catch(e){d+=": [Object cannot be stringified]"}else d+=": ".concat(o);switch(e){case n.VERBOSE:console.debug("[VERBOSE] ".concat(d));break;case n.DEBUG:console.debug(d);break;case n.INFO:console.info(d);break;case n.WARN:console.warn(d);break;case n.ERROR:console.error(d);break;default:console.log(d)}}}function d(e,t){let a,o=((a=e.replace(/^src\//,"")).startsWith("/")&&(a=a.substring(1)),a);return{verbose:(e,a)=>{i(n.VERBOSE,o,e,a,t)},debug:(e,a)=>{i(n.DEBUG,o,e,a,t)},info:(e,a)=>{i(n.INFO,o,e,a,t)},warn:(e,a)=>{i(n.WARN,o,e,a,t)},error:(e,a)=>{i(n.ERROR,o,e,a,t)}}}},97322:(e,t,a)=>{"use strict";a.d(t,{A:()=>v});var o=a(12115),n=a(2821),s=a(95195),r=a(57001),i=a(88133),d=a(11947),l=a(78831),p=a(41934),c=a(95155);let m=(0,p.A)(),u=(0,l.A)("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:a}=e;return[t.root,t["maxWidth".concat((0,i.A)(String(a.maxWidth)))],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),h=e=>(0,d.A)({props:e,name:"MuiContainer",defaultTheme:m});var f=a(81852),y=a(48116),g=a(16625);let v=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{createStyledComponent:t=u,useThemeProps:a=h,componentName:d="MuiContainer"}=e,l=t(e=>{let{theme:t,ownerState:a}=e;return{width:"100%",marginLeft:"auto",boxSizing:"border-box",marginRight:"auto",...!a.disableGutters&&{paddingLeft:t.spacing(2),paddingRight:t.spacing(2),[t.breakpoints.up("sm")]:{paddingLeft:t.spacing(3),paddingRight:t.spacing(3)}}}},e=>{let{theme:t,ownerState:a}=e;return a.fixed&&Object.keys(t.breakpoints.values).reduce((e,a)=>{let o=t.breakpoints.values[a];return 0!==o&&(e[t.breakpoints.up(a)]={maxWidth:"".concat(o).concat(t.breakpoints.unit)}),e},{})},e=>{let{theme:t,ownerState:a}=e;return{..."xs"===a.maxWidth&&{[t.breakpoints.up("xs")]:{maxWidth:Math.max(t.breakpoints.values.xs,444)}},...a.maxWidth&&"xs"!==a.maxWidth&&{[t.breakpoints.up(a.maxWidth)]:{maxWidth:"".concat(t.breakpoints.values[a.maxWidth]).concat(t.breakpoints.unit)}}}});return o.forwardRef(function(e,t){let o=a(e),{className:p,component:m="div",disableGutters:u=!1,fixed:h=!1,maxWidth:f="lg",classes:y,...g}=o,v={...o,component:m,disableGutters:u,fixed:h,maxWidth:f},b=((e,t)=>{let{classes:a,fixed:o,disableGutters:n,maxWidth:d}=e,l={root:["root",d&&"maxWidth".concat((0,i.A)(String(d))),o&&"fixed",n&&"disableGutters"]};return(0,r.A)(l,e=>(0,s.Ay)(t,e),a)})(v,d);return(0,c.jsx)(l,{as:m,ownerState:v,className:(0,n.A)(b.root,p),ref:t,...g})})}({createStyledComponent:(0,y.Ay)("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:a}=e;return[t.root,t["maxWidth".concat((0,f.A)(String(a.maxWidth)))],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),useThemeProps:e=>(0,g.b)({props:e,name:"MuiContainer"})})}},e=>{e.O(0,[2678,4754,9244,8548,9562,488,1374,8441,1255,7358],()=>e(e.s=32651)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1488],{17427:(e,t,l)=>{"use strict";l.d(t,{A:()=>p});var a=l(95155),n=l(12115),r=l(25635),o=l(94049),s=l(99944),i=l(9957),d=l(52641),c=l(51221),u=l(55606),h=l(86973),x=l(9562);let p=e=>{var t;let{schema:l,values:p,onChange:f,size:m="small"}=e,[g,w]=(0,n.useState)({}),y=null!=(t=null==l?void 0:l.properties)?t:{},v=Array.isArray(null==l?void 0:l.required)?l.required:[],j=Object.keys(y);if(0===j.length)return(0,a.jsx)(r.default,{variant:"body2",color:"text.secondary",children:"This tool takes no parameters."});let b=(e,t)=>{let l={...p};void 0===t?delete l[e]:l[e]=t,f(l)};return(0,a.jsx)(o.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:j.map(e=>{var t,l;let n=null!=(t=y[e])?t:{},f=v.includes(e)?"".concat(e," *"):e,j="string"==typeof n.description?n.description:"";if("boolean"===n.type)return(0,a.jsx)(s.A,{control:(0,a.jsx)(i.A,{size:m,checked:!0===p[e],onChange:t=>b(e,t.target.checked)}),label:(0,a.jsxs)(o.default,{children:[(0,a.jsx)(r.default,{variant:"body2",children:f}),j&&(0,a.jsx)(r.default,{variant:"caption",color:"text.secondary",children:j})]})},e);if(Array.isArray(n.enum)&&n.enum.length>0){let t=p[e];return(0,a.jsxs)(d.A,{size:m,fullWidth:!0,children:[(0,a.jsx)(c.A,{id:"schema-param-".concat(e),children:f}),(0,a.jsx)(u.A,{labelId:"schema-param-".concat(e),label:f,value:n.enum.includes(t)?t:"",onChange:t=>b(e,t.target.value),children:n.enum.map(e=>(0,a.jsx)(h.A,{value:e,children:String(e)},String(e)))}),j&&(0,a.jsx)(r.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mx:1.75},children:j})]},e)}if("number"===n.type||"integer"===n.type)return(0,a.jsx)(x.A,{fullWidth:!0,size:m,type:"number",label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>{let l=t.target.value;if(""===l)return void b(e,void 0);let a="integer"===n.type?parseInt(l,10):parseFloat(l);b(e,Number.isNaN(a)?void 0:a)},helperText:j},e);if("object"===n.type||"array"===n.type){let t=null!=(l=g[e])?l:void 0!==p[e]?JSON.stringify(p[e],null,2):"",r=null;if(t.trim())try{JSON.parse(t)}catch(e){r="Not valid JSON yet"}return(0,a.jsx)(x.A,{fullWidth:!0,size:m,multiline:!0,minRows:2,label:"".concat(f," (JSON ").concat(n.type,")"),value:t,error:!!r,helperText:null!=r?r:j,onChange:t=>{let l=t.target.value;if(w(t=>({...t,[e]:l})),!l.trim())return void b(e,void 0);try{b(e,JSON.parse(l))}catch(e){}},slotProps:{input:{sx:{fontFamily:"monospace",fontSize:13}}}},e)}return(0,a.jsx)(x.A,{fullWidth:!0,size:m,label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>b(e,""===t.target.value?void 0:t.target.value),helperText:j},e)})})}},60187:(e,t,l)=>{Promise.resolve().then(l.bind(l,95271))},62640:(e,t,l)=>{"use strict";l.d(t,{A:()=>T});var a=l(95155),n=l(12115),r=l(2778),o=l(52363),s=l(65036),i=l(94049),d=l(78470),c=l(41983),u=l(9562),h=l(28548),x=l(22003),p=l(4474),f=l(25635),m=l(41602),g=l(73707),w=l(49501),y=l(17681),v=l(75912),j=l(70690),b=l(80007),A=l(74482),k=l(40171),C=l(36944);let S=(0,l(87021).h)("frontend/components/shared/FolderPickerDialog"),T=e=>{let{open:t,title:l="Choose a folder",selectFiles:T=!1,initialPath:N,onClose:F,onSelect:I}=e,[E,W]=(0,n.useState)(null),[P,R]=(0,n.useState)(""),[O,z]=(0,n.useState)(!1),[D,M]=(0,n.useState)(null),U=(0,n.useCallback)(async e=>{z(!0),M(null);try{let t=e?"?path=".concat(encodeURIComponent(e)):"",l=await fetch("/api/browse".concat(t)),a=await l.json();if(!l.ok||a.error)return void M(a.error||"HTTP ".concat(l.status));W(a),R(a.path)}catch(e){S.warn("Browse failed",e),M("Could not reach the backend to browse folders.")}finally{z(!1)}},[]);(0,n.useEffect)(()=>{t?U(N||void 0):(W(null),M(null))},[t,N,U]);let L=e=>{I(e),F()};return(0,a.jsxs)(r.A,{open:t,onClose:F,maxWidth:"sm",fullWidth:!0,children:[(0,a.jsx)(o.A,{children:l}),(0,a.jsxs)(s.A,{dividers:!0,sx:{display:"flex",flexDirection:"column",gap:1.5},children:[(0,a.jsxs)(i.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,a.jsx)(d.A,{title:"Up one folder",children:(0,a.jsx)("span",{children:(0,a.jsx)(c.A,{size:"small",disabled:!(null==E?void 0:E.parent)||O,onClick:()=>(null==E?void 0:E.parent)&&void U(E.parent),children:(0,a.jsx)(k.A,{fontSize:"small"})})})}),(0,a.jsx)(d.A,{title:"Home folder",children:(0,a.jsx)("span",{children:(0,a.jsx)(c.A,{size:"small",disabled:O,onClick:()=>void U(),children:(0,a.jsx)(C.A,{fontSize:"small"})})})}),(0,a.jsx)(u.A,{fullWidth:!0,size:"small",value:P,onChange:e=>R(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),U(P))},placeholder:"Type a path and press Enter"})]}),E&&E.drives.length>0&&(0,a.jsx)(i.default,{sx:{display:"flex",gap:.75,flexWrap:"wrap"},children:E.drives.map(e=>(0,a.jsx)(h.A,{label:e,size:"small",variant:E.path.toLowerCase().startsWith(e.toLowerCase())?"filled":"outlined",onClick:()=>void U(e)},e))}),D&&(0,a.jsx)(x.A,{severity:"error",children:D}),(0,a.jsxs)(i.default,{sx:{minHeight:240,maxHeight:"45vh",overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:[O&&(0,a.jsx)(i.default,{sx:{display:"flex",justifyContent:"center",py:4},children:(0,a.jsx)(p.default,{size:24})}),!O&&E&&0===E.entries.length&&(0,a.jsx)(f.default,{variant:"body2",color:"text.secondary",sx:{p:2},children:"This folder is empty."}),!O&&(0,a.jsx)(m.A,{dense:!0,disablePadding:!0,children:null==E?void 0:E.entries.map(e=>(0,a.jsxs)(g.A,{disabled:!e.isDirectory&&!T,onClick:()=>e.isDirectory?void U(e.path):L(e.path),children:[(0,a.jsx)(w.A,{sx:{minWidth:34},children:e.isDirectory?(0,a.jsx)(b.A,{fontSize:"small",color:"primary"}):(0,a.jsx)(A.A,{fontSize:"small"})}),(0,a.jsx)(y.A,{primary:e.name,primaryTypographyProps:{noWrap:!0}})]},e.path))})]})]}),(0,a.jsxs)(v.A,{children:[(0,a.jsx)(j.A,{onClick:F,children:"Cancel"}),(0,a.jsx)(j.A,{variant:"contained",disabled:!E||O,onClick:()=>E&&L(E.path),children:"Select this folder"})]})]})}},90057:(e,t,l)=>{"use strict";l.d(t,{g:()=>o});var a=l(74879);let n=(0,l(87021).h)("frontend/services/flow/index");class r{async loadFlows(){n.debug("loadFlows: Entering method");try{if(this.flowsCache)return n.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return n.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return n.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){n.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return n.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return n.debug("getFlow: Flow ".concat(e," not found")),null;let l=await t.json();throw Error(l.error||"Failed to get flow: ".concat(e))}let l=await t.json();return n.debug("getFlow: Retrieved flow from API",{flowId:e}),l}catch(t){return n.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){n.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let l=await t.json();return this.flowsCache&&this.flowsCache.push(l),n.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async generateFlow(e,t,l){n.debug("generateFlow: Entering method",{modelId:t,allowInstall:null==l?void 0:l.allowInstall,allowSubflows:null==l?void 0:l.allowSubflows,maxDepth:null==l?void 0:l.maxDepth});try{var a,r,o,s,i,d,c;let u=await fetch("/api/flow/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:e,modelId:t,allowInstall:(null==l?void 0:l.allowInstall)===!0,allowSubflows:(null==l?void 0:l.allowSubflows)===!0,..."number"==typeof(null==l?void 0:l.maxDepth)?{maxDepth:l.maxDepth}:{}})}),h=await u.json().catch(()=>null);if(!u.ok)return{success:!1,error:(null==h?void 0:h.error)||"Failed to generate flow"};let x=Array.isArray(h.flows)&&h.flows.length>0?h.flows:[{flow:h.flow,validation:h.validation}];return n.debug("generateFlow: Draft generated",{flowId:null==(a=h.flow)?void 0:a.id,flowCount:x.length,attempts:h.attempts,errorCount:null==(r=h.validation)?void 0:r.errorCount,installedServers:null!=(i=null==(o=h.installedServers)?void 0:o.length)?i:0}),{success:!0,flow:h.flow,validation:h.validation,flows:x,rootFlowId:null!=(d=h.rootFlowId)?d:null==(s=h.flow)?void 0:s.id,attempts:h.attempts,installedServers:null!=(c=h.installedServers)?c:[]}}catch(e){return n.warn("generateFlow: Failed to generate flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to generate flow"}}}async improveFlow(e,t,l,a){n.debug("improveFlow: Entering method",{flowId:null==e?void 0:e.id,modelId:l,allowInstall:null==a?void 0:a.allowInstall});try{var r,o,s,i,d;let c=await fetch("/api/flow/improve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flow:e,description:t,modelId:l,allowInstall:(null==a?void 0:a.allowInstall)===!0})}),u=await c.json().catch(()=>null);if(!c.ok)return{success:!1,error:(null==u?void 0:u.error)||"Failed to improve flow"};return n.debug("improveFlow: Draft revised",{flowId:null==(r=u.flow)?void 0:r.id,attempts:u.attempts,errorCount:null==(o=u.validation)?void 0:o.errorCount,installedServers:null!=(i=null==(s=u.installedServers)?void 0:s.length)?i:0}),{success:!0,flow:u.flow,validation:u.validation,attempts:u.attempts,installedServers:null!=(d=u.installedServers)?d:[]}}catch(e){return n.warn("improveFlow: Failed to improve flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to improve flow"}}}async updateFlow(e){n.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let l=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=l:this.flowsCache.push(l)}return n.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){n.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),n.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return n.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}createNode(e,t){return n.debug("createNode: Entering method",{type:e,position:t}),{id:(0,a.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:{}}}}createStartNode(){return{id:(0,a.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";return n.debug("createNewFlow: Entering method",{name:e}),{id:(0,a.A)(),name:e,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return n.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return n.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,a.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let o=new r},95271:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>eE});var a=l(95155),n=l(94049),r=l(12115),o=l(25635),s=l(99944),i=l(9957),d=l(70690),c=l(2778),u=l(52363),h=l(65036),x=l(75912),p=l(86946),f=l(76530),m=l(78470),g=l(41983),w=l(87021);let y=(0,w.h)("frontend/services/plannedExecutions");class v{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return y.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),l=await t.json();if(!t.ok)return{success:!1,error:(null==l?void 0:l.error)||"HTTP ".concat(t.status)};return{success:!0,execution:l.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let l=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await l.json();if(!l.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(l.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),l=await t.json();if(!t.ok)return{success:!1,error:(null==l?void 0:l.error)||"HTTP ".concat(t.status)};return{success:!0,record:l.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let l=await t.json();return Array.isArray(null==l?void 0:l.runs)?l.runs:[]}catch(t){return y.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let l=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!l.ok)throw Error("HTTP ".concat(l.status));return await l.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let j=new v;var b=l(2300),A=l(28548),k=l(4474),C=l(50430),S=l(55406),T=l(14915),N=l(4484),F=l(63186),I=l(62962),E=l(3713);let W=e=>String(e).padStart(2,"0"),P=e=>{switch(e){case"completed":return"success.main";case"error":return"error.main";case"skipped":return"warning.main";default:return"transparent"}},R=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",O=e=>{if(!e.finishedAt)return"";let t=new Date(e.finishedAt).getTime()-new Date(e.firedAt).getTime();return t<1e3?"<1s":t<6e4?"".concat(Math.round(t/1e3),"s"):"".concat(Math.round(t/6e4),"min")},z=e=>{var t;let{entry:l,onEdit:s,onDelete:p,onToggleEnabled:f,onRanNow:w}=e,{execution:y,status:v,lastRun:z}=l,[D,M]=(0,r.useState)(!1),[U,L]=(0,r.useState)(null),[H,J]=(0,r.useState)(!1),[q,$]=(0,r.useState)(!1),[B,G]=(0,r.useState)(null),[_,K]=(0,r.useState)(10),Q=(0,r.useCallback)(async()=>{J(!0),L([...await j.loadRuns(y.id)].reverse()),K(10),J(!1)},[y.id]);(0,r.useEffect)(()=>{D&&Q()},[D,Q,null==z?void 0:z.runId]);let X=async()=>{$(!0),await j.runNow(y.id),$(!1),D&&Q(),w()};return(0,a.jsxs)(b.A,{variant:"outlined",sx:{p:2},children:[(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap"},children:[(0,a.jsxs)(n.default,{sx:{flexGrow:1,minWidth:220},children:[(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[(0,a.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600},children:y.name}),(0,a.jsx)(A.A,{size:"small",label:function(e){switch(e.type){case"schedule":{var t;let l,a=(t=e.cron,(l=/^\*\/(\d+) \* \* \* \* \*$/.exec(t))?"Every ".concat(l[1],"s"):(l=/^\*\/(\d+) \* \* \* \*$/.exec(t))?"Every ".concat(l[1]," min"):(l=/^0 \*\/(\d+) \* \* \*$/.exec(t))?1===Number(l[1])?"Every hour":"Every ".concat(l[1]," hours"):(l=/^(\d+) (\d+) \* \* \*$/.exec(t))?"Daily at ".concat(W(Number(l[2])),":").concat(W(Number(l[1]))):(l=/^(\d+) (\d+) \* \* 1-5$/.exec(t))?"Weekdays at ".concat(W(Number(l[2])),":").concat(W(Number(l[1]))):null);return null!=a?a:"Schedule: ".concat(e.cron)}case"webhook":return"Webhook";case"file-watch":return"Watching ".concat(e.path);case"mcp-poll":return"Watching ".concat(e.serverName," › ").concat(e.toolName);case"url-watch":try{return"Watching ".concat(new URL(e.url).hostname)}catch(e){return"Watching a URL"}default:return"Trigger"}}(y.trigger)}),!y.enabled&&(0,a.jsx)(A.A,{size:"small",label:"Off",variant:"outlined"})]}),v.running?(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,a.jsx)(k.default,{size:12,thickness:6}),(0,a.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Running…",v.runningSince?" — started ".concat(R(v.runningSince)):""]})]}):(0,a.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[v.nextRun&&y.enabled?"Next run: ".concat(R(v.nextRun)):y.enabled&&!v.armed?"Not armed":"",v.lastTriggerError?" — trigger error: ".concat(v.lastTriggerError):""]}),z&&(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,a.jsx)(m.A,{title:z.status,children:(0,a.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(z.status),flexShrink:0}})}),(0,a.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Last run ",R(z.firedAt),"error"===z.status&&z.error?" — ".concat(z.error):""]})]})]}),(0,a.jsx)(m.A,{title:"Run now",children:(0,a.jsx)("span",{children:(0,a.jsx)(g.A,{onClick:X,disabled:q,color:"primary",children:q?(0,a.jsx)(k.default,{size:20}):(0,a.jsx)(S.A,{})})})}),(0,a.jsx)(m.A,{title:y.enabled?"Turn off":"Turn on",children:(0,a.jsx)(i.A,{checked:y.enabled,onChange:e=>f(e.target.checked)})}),(0,a.jsx)(m.A,{title:"Edit",children:(0,a.jsx)(g.A,{onClick:s,children:(0,a.jsx)(T.A,{})})}),(0,a.jsx)(m.A,{title:"Delete",children:(0,a.jsx)(g.A,{onClick:p,children:(0,a.jsx)(N.A,{})})}),(0,a.jsx)(m.A,{title:D?"Hide run history":"Show run history",children:(0,a.jsx)(g.A,{onClick:()=>M(e=>!e),children:D?(0,a.jsx)(I.A,{}):(0,a.jsx)(F.A,{})})})]}),(0,a.jsx)(C.A,{in:D,timeout:"auto",unmountOnExit:!0,children:(0,a.jsxs)(n.default,{sx:{mt:2,borderTop:1,borderColor:"divider",pt:1.5},children:[H&&!U&&(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Loading runs…"}),U&&0===U.length&&(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No runs yet. Use the play button to try it now."}),null==U?void 0:U.slice(0,_).map(e=>{var t;return(0,a.jsxs)(n.default,{sx:{display:"flex",gap:1,py:.75,alignItems:"flex-start","&:hover .run-detail-button":{opacity:1}},children:[(0,a.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(e.status),mt:"5px",flexShrink:0}}),(0,a.jsxs)(n.default,{sx:{minWidth:0,flexGrow:1},children:[(0,a.jsxs)(o.default,{variant:"body2",children:[R(e.firedAt),O(e)?" \xb7 ".concat(O(e)):""," \xb7 ",e.triggerSummary,(null==(t=e.usage)?void 0:t.totalTokens)?" \xb7 ".concat(e.usage.totalTokens.toLocaleString()," tokens"):""]}),e.error&&(0,a.jsx)(o.default,{variant:"body2",color:"error",children:e.error}),e.outputText&&(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.outputText})]}),(0,a.jsx)(m.A,{title:"Show full output",children:(0,a.jsx)(g.A,{className:"run-detail-button",size:"small",onClick:()=>G(e),sx:{opacity:{xs:1,md:.35},transition:"opacity 120ms",flexShrink:0},children:(0,a.jsx)(E.A,{fontSize:"inherit"})})})]},e.runId)}),U&&U.length>_&&(0,a.jsxs)(d.A,{size:"small",onClick:()=>K(e=>e+10),sx:{mt:1},children:["Load more (",U.length-_," older)"]})]})}),(0,a.jsxs)(c.A,{open:null!==B,onClose:()=>G(null),maxWidth:"md",fullWidth:!0,children:[(0,a.jsx)(u.A,{component:"div",children:(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,a.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:B?P(B.status):"transparent",flexShrink:0}}),(0,a.jsxs)(o.default,{variant:"h6",children:[y.name," — ",B?R(B.firedAt):""]})]})}),(0,a.jsx)(h.A,{dividers:!0,children:B&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:[B.status,O(B)?" \xb7 ".concat(O(B)):""," \xb7 ",B.triggerSummary,(null==(t=B.usage)?void 0:t.totalTokens)?" \xb7 ".concat(B.usage.totalTokens.toLocaleString()," tokens (").concat(B.usage.promptTokens.toLocaleString()," in / ").concat(B.usage.completionTokens.toLocaleString()," out)"):""]}),B.error&&(0,a.jsx)(o.default,{variant:"body2",color:"error",sx:{mb:1.5,whiteSpace:"pre-wrap"},children:B.error}),B.outputText?(0,a.jsx)(n.default,{sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",bgcolor:"action.hover",borderRadius:1,p:2,fontSize:14,maxHeight:"55vh",overflow:"auto"},children:B.outputText}):!B.error&&(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This run produced no output text."})]})}),(0,a.jsx)(x.A,{children:(0,a.jsx)(d.A,{onClick:()=>G(null),children:"Close"})})]})]})};var D=l(21067),M=l(9562),U=l(52641),L=l(51221),H=l(55606),J=l(86973),q=l(22003),$=l(77073),B=l(26922),G=l(40520),_=l(79299),K=l(22590),Q=l(53657),X=l(90057),Y=l(36741);let V=e=>{let{selected:t,icon:l,title:r,description:s,onClick:i}=e;return(0,a.jsxs)(n.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:i,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},sx:{flex:1,minWidth:200,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,a.jsx)(Y.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[l,(0,a.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:r})]}),(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:s})]})};var Z=l(22822),ee=l(98267),et=l(20537),el=l(37960);let ea=e=>String(e).padStart(2,"0"),en=e=>{let{cron:t,timezone:l,onChange:i,verb:d="Runs",catchUp:c,onCatchUpChange:u}=e,h=(0,r.useMemo)(()=>(function(e){let t=/^\*\/(\d+) \* \* \* \* \*$/.exec(e);return t?{mode:"seconds",n:Number(t[1]),time:"09:00"}:(t=/^\*\/(\d+) \* \* \* \*$/.exec(e))?{mode:"minutes",n:Number(t[1]),time:"09:00"}:(t=/^0 \*\/(\d+) \* \* \*$/.exec(e))?{mode:"hours",n:Number(t[1]),time:"09:00"}:(t=/^(\d+) (\d+) \* \* \*$/.exec(e))?{mode:"daily",n:1,time:"".concat(ea(Number(t[2])),":").concat(ea(Number(t[1])))}:(t=/^(\d+) (\d+) \* \* 1-5$/.exec(e))?{mode:"weekdays",n:1,time:"".concat(ea(Number(t[2])),":").concat(ea(Number(t[1])))}:{mode:"custom",n:15,time:"09:00"}})(t),[]),[x,p]=(0,r.useState)(h.mode),[f,m]=(0,r.useState)(h.n),[g,w]=(0,r.useState)(h.time),[y,v]=(0,r.useState)(t),[b,A]=(0,r.useState)(null),k=function(e,t,l,a){let[n,r]=l.split(":").map(Number);switch(e){case"seconds":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * * *");case"minutes":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * *");case"hours":return"0 */".concat(Math.max(1,Math.min(23,Math.floor(t)||1))," * * *");case"daily":return"".concat(r||0," ").concat(n||0," * * *");case"weekdays":return"".concat(r||0," ").concat(n||0," * * 1-5");default:return a}}(x,f,g,y);return(0,r.useEffect)(()=>{k!==t&&i({cron:k,timezone:l})},[k]),(0,r.useEffect)(()=>{let e=!1,t=setTimeout(()=>{j.previewSchedule(k,l).then(t=>{e||A(t)})},300);return()=>{e=!0,clearTimeout(t)}},[k,l]),(0,a.jsxs)(n.default,{children:[(0,a.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1},children:[(0,a.jsxs)(U.A,{sx:{minWidth:180},children:[(0,a.jsx)(L.A,{id:"schedule-preset-label",children:d}),(0,a.jsxs)(H.A,{labelId:"schedule-preset-label",label:d,value:x,onChange:e=>p(e.target.value),children:[(0,a.jsx)(J.A,{value:"seconds",children:"Every N seconds"}),(0,a.jsx)(J.A,{value:"minutes",children:"Every N minutes"}),(0,a.jsx)(J.A,{value:"hours",children:"Every N hours"}),(0,a.jsx)(J.A,{value:"daily",children:"Daily at a time"}),(0,a.jsx)(J.A,{value:"weekdays",children:"Weekdays at a time"}),(0,a.jsx)(J.A,{value:"custom",children:"Custom (cron)"})]})]}),("seconds"===x||"minutes"===x||"hours"===x)&&(0,a.jsx)(M.A,{label:"seconds"===x?"Seconds":"minutes"===x?"Minutes":"Hours",type:"number",value:f,onChange:e=>m(Number(e.target.value)),inputProps:{min:1,max:"hours"===x?23:59},sx:{width:120}}),("daily"===x||"weekdays"===x)&&(0,a.jsx)(M.A,{label:"Time",type:"time",value:g,onChange:e=>w(e.target.value),sx:{width:150},InputLabelProps:{shrink:!0}}),"custom"===x&&(0,a.jsx)(M.A,{label:"Cron pattern",value:y,onChange:e=>v(e.target.value),sx:{minWidth:220},placeholder:"*/15 * * * *"})]}),b&&!b.valid&&(0,a.jsx)(q.A,{severity:"error",sx:{mt:2},children:b.error||"This schedule is not valid."}),b&&b.valid&&b.nextRuns.length>0&&(0,a.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:2},children:["Next: ",b.nextRuns.map(e=>new Date(e).toLocaleString()).join(" \xb7 ")]}),u&&(0,a.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,a.jsx)(Z.A,{checked:!0===c,onChange:e=>u(e.target.checked)}),label:"If FLUJO was closed at a scheduled time, run once on startup"}),(0,a.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,a.jsx)(et.A,{expandIcon:(0,a.jsx)(F.A,{}),sx:{px:0},children:(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,a.jsx)(el.A,{sx:{px:0},children:(0,a.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,a.jsx)(M.A,{label:"Timezone (optional)",value:l||"",onChange:e=>i({cron:k,timezone:e.target.value||void 0}),placeholder:"e.g. Europe/Berlin",helperText:"IANA timezone name. Empty = this computer's timezone.",sx:{minWidth:260}}),(0,a.jsx)(M.A,{label:"Generated cron pattern",value:k,InputProps:{readOnly:"custom"!==x},onChange:e=>{p("custom"),v(e.target.value)},helperText:"Editing switches to Custom mode.",sx:{minWidth:220}})]})})]})]})};var er=l(52277),eo=l(9693);let es=e=>{let{config:t,onChange:l,executionId:i,saved:c}=e,[u,h]=(0,r.useState)(null),x=window.location.origin,p="".concat(x,"/api/webhooks/").concat(i),f=async(e,t)=>{try{await navigator.clipboard.writeText(t),h(e),setTimeout(()=>h(null),1500)}catch(e){}};return(0,a.jsxs)(n.default,{sx:{mt:1},children:[!c&&(0,a.jsx)(q.A,{severity:"info",sx:{mb:2},children:"This URL and token are ready to copy now — they become active when you save."}),(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,a.jsx)(M.A,{fullWidth:!0,label:"Webhook URL",value:p,InputProps:{readOnly:!0},size:"small"}),(0,a.jsx)(m.A,{title:"Copy URL",children:(0,a.jsx)(g.A,{onClick:()=>f("url",p),children:"url"===u?(0,a.jsx)(eo.A,{color:"success"}):(0,a.jsx)(er.A,{})})})]}),(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mt:2},children:[(0,a.jsx)(M.A,{fullWidth:!0,label:"Secret token",value:t.token,InputProps:{readOnly:!0},size:"small",type:"password"}),(0,a.jsx)(m.A,{title:"Copy token",children:(0,a.jsx)(g.A,{onClick:()=>f("token",t.token),disabled:!t.token,children:"token"===u?(0,a.jsx)(eo.A,{color:"success"}):(0,a.jsx)(er.A,{})})}),(0,a.jsx)(d.A,{size:"small",onClick:()=>l({...t,token:crypto.randomUUID()}),sx:{whiteSpace:"nowrap"},children:"New token"})]}),(0,a.jsx)(o.default,{variant:"caption",color:"text.secondary",children:c?"A new token takes effect when you save — callers using the old one are cut off.":""}),(0,a.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:1.5},children:["Callers send a POST with the token in the ",(0,a.jsx)("code",{children:"X-Flujo-Token"})," ","header (or ",(0,a.jsx)("code",{children:"?token=…"}),"). The request body becomes part of the flow's input — treat it as untrusted data in your prompt."]}),(0,a.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,a.jsx)(Z.A,{checked:!0===t.allowExternal,onChange:e=>l({...t,allowExternal:e.target.checked})}),label:"Allow calls from other machines (default: this computer only)"}),t.allowExternal&&(0,a.jsx)(q.A,{severity:"warning",children:"FLUJO assumes a single user on this machine. If you expose it beyond localhost (port forwarding, tunnels), securing that access is your responsibility — anyone with the URL and token can run this flow."})]})};var ei=l(56422),ed=l(17325),ec=l(80007),eu=l(62640);let eh=[{value:"add",label:"A file appears"},{value:"change",label:"A file changes"},{value:"unlink",label:"A file is deleted"}],ex=e=>{var t;let{config:l,onChange:i}=e,[d,c]=(0,r.useState)(!1);return(0,a.jsxs)(n.default,{sx:{mt:1},children:[(0,a.jsx)(M.A,{fullWidth:!0,label:"Folder (or file) to watch",value:l.path,onChange:e=>i({...l,path:e.target.value}),placeholder:"e.g. C:\\Users\\me\\Documents\\inbox",margin:"normal",InputProps:{endAdornment:(0,a.jsx)(ei.A,{position:"end",children:(0,a.jsx)(m.A,{title:"Browse folders (on the FLUJO machine)",children:(0,a.jsx)(g.A,{edge:"end",onClick:()=>c(!0),children:(0,a.jsx)(ec.A,{})})})})}}),(0,a.jsx)(eu.A,{open:d,title:"Choose what to watch",selectFiles:!0,initialPath:l.path||void 0,onClose:()=>c(!1),onSelect:e=>i({...l,path:e})}),(0,a.jsx)(M.A,{fullWidth:!0,label:"Only files matching (optional)",value:l.glob||"",onChange:e=>i({...l,glob:e.target.value||void 0}),placeholder:"e.g. *.pdf or reports/**/*.csv",helperText:"Simple patterns: * matches within a folder, ** across folders, ? one character.",margin:"normal"}),(0,a.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"Run when…"}),(0,a.jsx)(ed.A,{row:!0,children:eh.map(e=>(0,a.jsx)(s.A,{control:(0,a.jsx)(Z.A,{checked:l.events.includes(e.value),onChange:t=>((e,t)=>{let a=t?[...l.events,e]:l.events.filter(t=>t!==e);i({...l,events:a})})(e.value,t.target.checked)}),label:e.label},e.value))}),(0,a.jsx)(q.A,{severity:"info",sx:{mt:1},children:"Bursts are batched: many files changing at once produce one run with all changes listed. If this flow writes into the watched folder, it will trigger itself in a loop — point its output somewhere else."}),(0,a.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,a.jsx)(et.A,{expandIcon:(0,a.jsx)(F.A,{}),sx:{px:0},children:(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,a.jsx)(el.A,{sx:{px:0},children:(0,a.jsx)(M.A,{label:"Quiet window (ms)",type:"number",value:null!=(t=l.debounceMs)?t:2e3,onChange:e=>i({...l,debounceMs:Math.max(0,Number(e.target.value)||0)}),helperText:"How long to wait after the last change before running.",inputProps:{min:0,step:500},sx:{width:220}})})]})]})};var ep=l(41356),ef=l(24610),em=l(17897),eg=l(43076),ew=l(17427);let ey=(0,w.h)("frontend/components/PlannedExecutions/WatchToolPanel"),ev=e=>{var t,l;let{config:s,onChange:i}=e,[c,u]=(0,r.useState)([]),[h,x]=(0,r.useState)([]),[p,f]=(0,r.useState)(!1),[m,g]=(0,r.useState)(Object.keys(s.args||{}).length>0?JSON.stringify(s.args,null,2):""),[w,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,S]=(0,r.useState)(null),[T,N]=(0,r.useState)([]),[F,I]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return em.S.loadServerConfigs().then(t=>{e||(Array.isArray(t)?u(t.filter(e=>!e.disabled).map(e=>e.name)):(ey.warn("Failed to load MCP servers for watch-tool panel",t),u([])))}),()=>{e=!0}},[]),(0,r.useEffect)(()=>{if(!s.serverName)return void x([]);let e=!1;return f(!0),em.S.listServerTools(s.serverName).then(t=>{let{tools:l}=t;e||x(l||[])}).finally(()=>{e||f(!1)}),()=>{e=!0}},[s.serverName]),(0,r.useEffect)(()=>{let e=!1;return eg.N.loadModels().then(t=>{e||N(Array.isArray(t)?t:[])}).catch(()=>{e||N([])}),X.g.loadFlows().then(t=>{e||I(t||[])}).catch(()=>{e||I([])}),()=>{e=!0}},[]);let E=async()=>{j(!0),A(null),S(null);try{let l=await em.S.callTool(s.serverName,s.toolName,s.args||{});if(null==l?void 0:l.error)S("string"==typeof l.error?l.error:"Tool call failed");else{var e,t;let a=null!=(e=null==l?void 0:l.data)?e:l,n=null!=(t=JSON.stringify(a,null,2))?t:"";A(n.length>6e3?"".concat(n.slice(0,6e3),"\n… (truncated)"):n)}}catch(e){S(e instanceof Error?e.message:"Tool call failed")}finally{j(!1)}},W=s.evaluate,P=h.find(e=>e.name===s.toolName);return(0,a.jsxs)(n.default,{sx:{mt:1},children:[(0,a.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,a.jsxs)(U.A,{sx:{minWidth:220,flex:1},margin:"normal",children:[(0,a.jsx)(L.A,{id:"watch-server-label",children:"Server"}),(0,a.jsxs)(H.A,{labelId:"watch-server-label",label:"Server",value:c.includes(s.serverName)?s.serverName:"",onChange:e=>i({...s,serverName:e.target.value,toolName:""}),children:[0===c.length&&(0,a.jsx)(J.A,{value:"",disabled:!0,children:"No MCP servers configured"}),c.map(e=>(0,a.jsx)(J.A,{value:e,children:e},e))]})]}),(0,a.jsxs)(U.A,{sx:{minWidth:220,flex:1},margin:"normal",disabled:!s.serverName,children:[(0,a.jsx)(L.A,{id:"watch-tool-label",children:"Tool"}),(0,a.jsxs)(H.A,{labelId:"watch-tool-label",label:"Tool",value:h.some(e=>e.name===s.toolName)?s.toolName:"",onChange:e=>i({...s,toolName:e.target.value,args:{}}),children:[0===h.length&&(0,a.jsx)(J.A,{value:"",disabled:!0,children:p?"Loading tools…":"Pick a server first"}),h.map(e=>(0,a.jsx)(J.A,{value:e.name,children:e.name},e.name))]})]})]}),(0,a.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,a.jsx)(en,{verb:"Check",cron:null!=(t=s.cron)?t:function(e){let t=Math.max(5,Math.round((null!=e?e:6e4)/1e3));if(t<60)return"*/".concat(t," * * * * *");let l=Math.max(1,Math.round(t/60));if(l<60)return"*/".concat(l," * * * *");let a=Math.max(1,Math.min(23,Math.round(l/60)));return"0 */".concat(a," * * *")}(s.intervalMs),timezone:s.timezone,onChange:e=>{let{cron:t,timezone:l}=e;return i({...s,cron:t,timezone:l})}}),P?(0,a.jsxs)(n.default,{sx:{my:1.5},children:[(0,a.jsx)(o.default,{variant:"subtitle2",sx:{mb:1.5},children:"Tool parameters — sent on every check"}),(0,a.jsx)(ew.A,{schema:P.inputSchema,values:s.args||{},onChange:e=>i({...s,args:e})})]}):(0,a.jsx)(M.A,{fullWidth:!0,label:"Tool arguments (JSON, optional)",value:m,onChange:e=>(e=>{if(g(e),!e.trim()){y(null),i({...s,args:{}});return}try{let t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))return void y('Arguments must be a JSON object, e.g. { "query": "…" }');y(null),i({...s,args:t})}catch(e){y("Not valid JSON yet")}})(e.target.value),margin:"normal",multiline:!0,minRows:2,placeholder:'{ "query": "is:unread" }',error:!!w,helperText:null!=w?w:"Sent to the tool on every check.",slotProps:{input:{sx:{fontFamily:"monospace",fontSize:14}}}}),(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[(0,a.jsx)(d.A,{variant:"outlined",size:"small",onClick:E,disabled:!s.serverName||!s.toolName||v||!!w,startIcon:v?(0,a.jsx)(k.default,{size:16}):void 0,children:"Test: call the tool now"}),(0,a.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"See what the result looks like — useful for the settings below."})]}),C&&(0,a.jsx)(q.A,{severity:"error",sx:{mb:1},children:C}),b&&(0,a.jsx)(n.default,{component:"pre",sx:{maxHeight:240,overflow:"auto",bgcolor:"action.hover",borderRadius:1,p:1.5,fontSize:12,m:0,mb:1},children:b}),(0,a.jsx)(o.default,{variant:"subtitle2",sx:{mt:2,mb:1},children:"Run the flow when…"}),(0,a.jsxs)(n.default,{role:"radiogroup","aria-label":"Poll condition",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,a.jsx)(V,{selected:"on-change"===W.mode,onClick:()=>i({...s,evaluate:{mode:"on-change"}}),icon:(0,a.jsx)(ep.A,{}),title:"The result changes",description:"Any difference from the last check runs the flow. Simplest — no setup."}),(0,a.jsx)(V,{selected:"llm-gate"===W.mode||"flow-gate"===W.mode,onClick:()=>{"llm-gate"!==W.mode&&"flow-gate"!==W.mode&&i({...s,evaluate:{mode:"llm-gate",condition:"",modelId:""}})},icon:(0,a.jsx)(ef.A,{}),title:"AI decides",description:"Describe the condition in plain language; a model — or one of your flows — checks the result whenever it changes."})]}),("llm-gate"===W.mode||"flow-gate"===W.mode)&&(0,a.jsxs)(n.default,{sx:{mt:1},children:[(0,a.jsx)(M.A,{fullWidth:!0,label:"Run the flow if…",value:W.condition,onChange:e=>i({...s,evaluate:{...W,condition:e.target.value}}),multiline:!0,minRows:2,margin:"normal",placeholder:"e.g. any email mentions an invoice or a payment reminder"}),(0,a.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-start"},children:[(0,a.jsxs)(U.A,{sx:{minWidth:170},children:[(0,a.jsx)(L.A,{id:"gate-checker-label",children:"Checked by"}),(0,a.jsxs)(H.A,{labelId:"gate-checker-label",label:"Checked by",value:W.mode,onChange:e=>{let t=e.target.value;if(t===W.mode)return;let l={condition:W.condition,maxCallsPerDay:W.maxCallsPerDay};i({...s,evaluate:"llm-gate"===t?{mode:t,...l,modelId:""}:{mode:t,...l,flowId:""}})},children:[(0,a.jsx)(J.A,{value:"llm-gate",children:"A model"}),(0,a.jsx)(J.A,{value:"flow-gate",children:"One of my flows"})]})]}),"llm-gate"===W.mode&&(0,a.jsxs)(U.A,{sx:{minWidth:240,flex:1},children:[(0,a.jsx)(L.A,{id:"gate-model-label",children:"Model that checks"}),(0,a.jsxs)(H.A,{labelId:"gate-model-label",label:"Model that checks",value:T.some(e=>e.id===W.modelId)?W.modelId:"",onChange:e=>i({...s,evaluate:{...W,modelId:e.target.value}}),children:[0===T.length&&(0,a.jsx)(J.A,{value:"",disabled:!0,children:"No models configured"}),T.map(e=>(0,a.jsx)(J.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),"flow-gate"===W.mode&&(0,a.jsxs)(U.A,{sx:{minWidth:240,flex:1},children:[(0,a.jsx)(L.A,{id:"gate-flow-label",children:"Flow that checks"}),(0,a.jsxs)(H.A,{labelId:"gate-flow-label",label:"Flow that checks",value:F.some(e=>e.id===W.flowId)?W.flowId:"",onChange:e=>i({...s,evaluate:{...W,flowId:e.target.value}}),children:[0===F.length&&(0,a.jsx)(J.A,{value:"",disabled:!0,children:"No flows available"}),F.map(e=>(0,a.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),(0,a.jsx)(M.A,{label:"Max checks per day",type:"number",value:null!=(l=W.maxCallsPerDay)?l:500,onChange:e=>i({...s,evaluate:{...W,maxCallsPerDay:Math.max(1,Number(e.target.value)||1)}}),inputProps:{min:1},helperText:"Cost guard per check.",sx:{width:180}})]}),(0,a.jsx)(o.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5},children:"flow-gate"===W.mode?'The checker flow runs invisibly (never in the chat), gets the condition + tool result, and must answer with {"fire": true/false, "reason": "…"} — it can use its own tools to verify before deciding.':"The model is only asked when the result actually changed since the last check — an idle feed costs nothing. Pick a small, cheap model."})]}),(0,a.jsx)(q.A,{severity:"info",sx:{mt:2},children:"The first check only takes a snapshot — the flow runs from the second check onwards, when something actually changed. FLUJO must be running for checks to happen."})]})},ej=e=>{let{config:t,onChange:l}=e;return(0,a.jsxs)(n.default,{sx:{mt:1},children:[(0,a.jsx)(M.A,{fullWidth:!0,label:"URL to watch",value:t.url,onChange:e=>l({...t,url:e.target.value}),placeholder:"https://example.com/status or an API/feed URL",margin:"normal",type:"url"}),(0,a.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,a.jsx)(en,{verb:"Check",cron:t.cron,timezone:t.timezone,onChange:e=>{let{cron:a,timezone:n}=e;return l({...t,cron:a,timezone:n})}}),(0,a.jsx)(q.A,{severity:"info",sx:{mt:1},children:"The first check only takes a snapshot; the flow runs when a later check finds different content, and the fetched content is handed to the flow. Pages that embed ever-changing bits (timestamps, session tokens) look “changed” on every check — plain APIs, feeds, and raw files work best."})]})},eb=(0,w.h)("frontend/components/PlannedExecutions/ExecutionModal"),eA={type:"schedule",cron:"0 9 * * *"},ek={type:"file-watch",path:"",events:["add","change"]},eC={type:"mcp-poll",serverName:"",toolName:"",args:{},cron:"*/5 * * * *",evaluate:{mode:"on-change"}},eS={type:"url-watch",url:"",cron:"*/15 * * * *"},eT=e=>{var t;let{open:l,execution:p,onClose:f,onSaved:m}=e,[w,y]=(0,r.useState)(""),[v,b]=(0,r.useState)(""),[A,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!1),[T,N]=(0,r.useState)(eA),[F,I]=(0,r.useState)(""),[E,W]=(0,r.useState)([]),[P,R]=(0,r.useState)(!1),[O,z]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e,t,a,n;l&&(Z(null),y(null!=(e=null==p?void 0:p.name)?e:""),b(null!=(t=null==p?void 0:p.flowId)?t:""),k(null!=(a=null==p?void 0:p.prompt)?a:""),S((null==p?void 0:p.saveConversations)===!0),N(null!=(n=null==p?void 0:p.trigger)?n:eA),I(p?"":crypto.randomUUID()))},[l,p]),(0,r.useEffect)(()=>{if(!l)return;let e=!1;return R(!0),X.g.loadFlows().then(t=>{e||W(t||[])}).catch(t=>{eb.warn("Failed to load flows for execution picker",t),e||W([])}).finally(()=>{e||R(!1)}),()=>{e=!0}},[l]);let ee=!!v&&!P&&E.length>0&&!E.some(e=>e.id===v),et=async()=>{var e;z(!0),Z(null);let t={name:w,flowId:v,prompt:A,saveConversations:C,trigger:T,enabled:null==(e=null==p?void 0:p.enabled)||e,...p?{}:{id:F}},l=p?await j.update(p.id,t):await j.create(t);if(z(!1),!l.success)return void Z(l.error||"Failed to save");m(),f()};return(0,a.jsxs)(c.A,{open:l,onClose:f,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,a.jsx)(u.A,{component:"div",children:(0,a.jsxs)(n.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,a.jsx)(o.default,{variant:"h6",children:p?"Edit planned execution":"New planned execution"}),(0,a.jsx)(g.A,{edge:"end",color:"inherit",onClick:f,"aria-label":"close",children:(0,a.jsx)($.A,{})})]})}),(0,a.jsx)(D.A,{}),(0,a.jsxs)(h.A,{sx:{p:3},children:[(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"A planned execution runs one of your flows automatically — on a schedule or when something happens — without anyone sitting in the chat. Results show up in its run history on the Executions page."}),(0,a.jsx)(M.A,{fullWidth:!0,label:"Name",value:w,onChange:e=>y(e.target.value),margin:"normal",placeholder:"e.g. Morning news digest"}),(0,a.jsx)(o.default,{variant:"subtitle1",sx:{mt:3,mb:1,fontWeight:600},children:"1 \xb7 When should it run?"}),(0,a.jsxs)(n.default,{role:"radiogroup","aria-label":"Trigger type",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,a.jsx)(V,{selected:"schedule"===T.type,onClick:()=>{"schedule"!==T.type&&N((null==p?void 0:p.trigger.type)==="schedule"?p.trigger:eA)},icon:(0,a.jsx)(B.A,{}),title:"On a schedule",description:"Run at fixed times — every few minutes, daily, on weekdays, or a custom rhythm."}),(0,a.jsx)(V,{selected:"webhook"===T.type,onClick:()=>{"webhook"!==T.type&&N((null==p?void 0:p.trigger.type)==="webhook"?p.trigger:{type:"webhook",token:crypto.randomUUID()})},icon:(0,a.jsx)(G.A,{}),title:"When called (webhook)",description:"Other apps run this flow by calling a URL — GitHub, Stripe, Slack and most services can send webhooks."}),(0,a.jsx)(V,{selected:"file-watch"===T.type,onClick:()=>{"file-watch"!==T.type&&N((null==p?void 0:p.trigger.type)==="file-watch"?p.trigger:ek)},icon:(0,a.jsx)(_.A,{}),title:"When files change",description:"Watch a folder on this computer and run when files appear, change, or disappear."}),(0,a.jsx)(V,{selected:"mcp-poll"===T.type,onClick:()=>{"mcp-poll"!==T.type&&N((null==p?void 0:p.trigger.type)==="mcp-poll"?p.trigger:eC)},icon:(0,a.jsx)(K.A,{}),title:"Watch a tool",description:"Check one of your MCP tools regularly — run when its result changes, or let AI decide."}),(0,a.jsx)(V,{selected:"url-watch"===T.type,onClick:()=>{"url-watch"!==T.type&&N((null==p?void 0:p.trigger.type)==="url-watch"?p.trigger:eS)},icon:(0,a.jsx)(Q.A,{}),title:"When a website changes",description:"Check a URL regularly and run when its content is different from the last check."})]}),"schedule"===T.type&&(0,a.jsx)(en,{cron:T.cron,timezone:T.timezone,onChange:e=>{let{cron:t,timezone:l}=e;return N({...T,cron:t,timezone:l})},catchUp:!0===T.catchUp,onCatchUpChange:e=>N({...T,catchUp:e})}),"webhook"===T.type&&(0,a.jsx)(es,{config:T,onChange:N,executionId:null!=(t=null==p?void 0:p.id)?t:F,saved:null!==p}),"file-watch"===T.type&&(0,a.jsx)(ex,{config:T,onChange:N}),"mcp-poll"===T.type&&(0,a.jsx)(ev,{config:T,onChange:N}),"url-watch"===T.type&&(0,a.jsx)(ej,{config:T,onChange:N}),(0,a.jsx)(D.A,{sx:{mt:3}}),(0,a.jsx)(o.default,{variant:"subtitle1",sx:{mt:2,mb:0,fontWeight:600},children:"2 \xb7 What should it run?"}),(0,a.jsxs)(U.A,{fullWidth:!0,margin:"normal",children:[(0,a.jsx)(L.A,{id:"execution-flow-label",children:"Flow to run"}),(0,a.jsxs)(H.A,{labelId:"execution-flow-label",label:"Flow to run",value:ee?"":v,onChange:e=>b(e.target.value),displayEmpty:!0,children:[0===E.length&&(0,a.jsx)(J.A,{value:"",disabled:!0,children:P?"Loading flows…":"No flows available"}),E.map(e=>(0,a.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),ee&&(0,a.jsx)(q.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),(0,a.jsx)(M.A,{fullWidth:!0,label:"What should the flow do?",value:A,onChange:e=>k(e.target.value),margin:"normal",multiline:!0,rows:3,helperText:"Sent to the flow as the user message each time this runs. Run details are attached automatically: current time, what triggered it, the previous run, the next planned run, and any trigger data."}),(0,a.jsx)(s.A,{sx:{mt:1},control:(0,a.jsx)(i.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Save full conversations (each run appears in the chat sidebar — useful for debugging)"}),Y&&(0,a.jsx)(q.A,{severity:"error",sx:{mt:2},children:Y})]}),(0,a.jsxs)(x.A,{children:[(0,a.jsx)(d.A,{onClick:f,children:"Cancel"}),(0,a.jsx)(d.A,{onClick:et,variant:"contained",color:"primary",disabled:O||!w.trim()||!v,children:O?"Saving…":"Save"})]})]})},eN=(0,w.h)("frontend/components/PlannedExecutions"),eF=()=>{let[e,t]=(0,r.useState)([]),[l,w]=(0,r.useState)(!1),[y,v]=(0,r.useState)(!1),[b,A]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,T]=(0,r.useState)(null),N=(0,r.useCallback)(async()=>{let e=await j.list();t(e.executions),w(e.paused),v(!0)},[]);(0,r.useEffect)(()=>{N()},[N]);let F=e.some(e=>e.status.running);(0,r.useEffect)(()=>{let e=setInterval(()=>{document.hidden||N()},F?3e3:1e4);return()=>clearInterval(e)},[N,F]);let I=async e=>{w(e);let t=await j.setPaused(e);t.success||eN.warn("Failed to toggle pause",t.error),N()},E=async(e,t)=>{await j.update(e.id,{enabled:t}),N()},W=async()=>{S&&(await j.delete(S.id),T(null),N())};return(0,a.jsxs)(n.default,{sx:{p:3,maxWidth:1100,mx:"auto",width:"100%"},children:[(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:2,mb:1},children:[(0,a.jsx)(o.default,{variant:"h5",children:"Planned Executions"}),(0,a.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,a.jsx)(m.A,{title:"Refresh",children:(0,a.jsx)(g.A,{onClick:()=>void N(),children:(0,a.jsx)(f.A,{})})}),(0,a.jsx)(s.A,{control:(0,a.jsx)(i.A,{checked:!l,onChange:e=>I(!e.target.checked)}),label:l?"Paused":"Active"}),(0,a.jsx)(d.A,{variant:"contained",startIcon:(0,a.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},"data-tour":"add-execution",children:"Add"})]})]}),(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Run your flows automatically — on a schedule or when something happens — without opening the chat. FLUJO must be running for triggers to fire."}),y&&0===e.length&&(0,a.jsxs)(n.default,{sx:{border:1,borderColor:"divider",borderRadius:2,borderStyle:"dashed",p:6,textAlign:"center"},children:[(0,a.jsx)(o.default,{variant:"h6",sx:{mb:1},children:"Nothing planned yet"}),(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Create your first planned execution to run a flow on a schedule."}),(0,a.jsx)(d.A,{variant:"contained",startIcon:(0,a.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},children:"New planned execution"})]}),(0,a.jsx)(n.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(e=>(0,a.jsx)(z,{entry:e,onEdit:()=>{C(e.execution),A(!0)},onDelete:()=>T(e.execution),onToggleEnabled:t=>E(e.execution,t),onRanNow:()=>void N()},e.execution.id))}),(0,a.jsx)(eT,{open:b,execution:k,onClose:()=>A(!1),onSaved:()=>void N()}),(0,a.jsxs)(c.A,{open:null!==S,onClose:()=>T(null),children:[(0,a.jsxs)(u.A,{children:["Delete “",null==S?void 0:S.name,"”?"]}),(0,a.jsx)(h.A,{children:(0,a.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This removes the planned execution and its run history. The flow itself is not affected."})}),(0,a.jsxs)(x.A,{children:[(0,a.jsx)(d.A,{onClick:()=>T(null),children:"Cancel"}),(0,a.jsx)(d.A,{color:"error",variant:"contained",onClick:W,children:"Delete"})]})]})]})},eI=(0,w.h)("app/executions/page");function eE(){return eI.debug("Rendering ExecutionsPage"),(0,a.jsx)(n.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,a.jsx)(eF,{})})}}},e=>{e.O(0,[2678,4754,9244,8548,690,9562,2003,488,3272,6582,2403,9554,9984,2380,8441,1255,7358],()=>e(e.s=60187)),_N_E=e.O()}]);