flujo-ai 3.20.0 → 3.22.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 (553) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +312 -242
  3. package/.next/app-path-routes-manifest.json +19 -12
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +39 -15
  6. package/.next/react-loadable-manifest.json +15 -13
  7. package/.next/routes-manifest.json +14 -0
  8. package/.next/server/app/_not-found/page.js +2 -2
  9. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  10. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/_not-found.html +1 -1
  12. package/.next/server/app/_not-found.rsc +5 -3
  13. package/.next/server/app/api/approvals/[id]/route.js +1 -0
  14. package/.next/server/app/api/approvals/[id]/route.js.nft.json +1 -0
  15. package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -0
  16. package/.next/server/app/api/approvals/route.js +2 -0
  17. package/.next/server/app/api/approvals/route.js.nft.json +1 -0
  18. package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -0
  19. package/.next/server/app/api/backup/route.js +1 -1
  20. package/.next/server/app/api/backup/route.js.nft.json +1 -1
  21. package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/browse/route.js +1 -1
  23. package/.next/server/app/api/browse/route.js.nft.json +1 -1
  24. package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/bugs/enhance/route.js +14 -0
  26. package/.next/server/app/api/bugs/enhance/route.js.nft.json +1 -0
  27. package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -0
  28. package/.next/server/app/api/cwd/route.js +1 -1
  29. package/.next/server/app/api/cwd/route.js.nft.json +1 -1
  30. package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/encryption/secure/route.js +1 -1
  32. package/.next/server/app/api/encryption/secure/route.js.nft.json +1 -1
  33. package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/env/route.js +1 -1
  35. package/.next/server/app/api/env/route.js.nft.json +1 -1
  36. package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/flow/[id]/route.js +1 -1
  38. package/.next/server/app/api/flow/[id]/route.js.nft.json +1 -1
  39. package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/flow/compile/route.js +1 -1
  41. package/.next/server/app/api/flow/compile/route.js.nft.json +1 -1
  42. package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/flow/generate/route.js +1 -1
  44. package/.next/server/app/api/flow/generate/route.js.nft.json +1 -1
  45. package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/flow/improve/route.js +1 -1
  47. package/.next/server/app/api/flow/improve/route.js.nft.json +1 -1
  48. package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/flow/prompt-renderer/route.js +2 -2
  50. package/.next/server/app/api/flow/prompt-renderer/route.js.nft.json +1 -1
  51. package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/flow/quick-chat/route.js +1 -1
  53. package/.next/server/app/api/flow/quick-chat/route.js.nft.json +1 -1
  54. package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/flow/repair/route.js +1 -1
  56. package/.next/server/app/api/flow/repair/route.js.nft.json +1 -1
  57. package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/flow/route.js +1 -1
  59. package/.next/server/app/api/flow/route.js.nft.json +1 -1
  60. package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/git/route.js +6 -4
  62. package/.next/server/app/api/git/route.js.nft.json +1 -1
  63. package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  64. package/.next/server/app/api/init/route.js +1 -1
  65. package/.next/server/app/api/init/route.js.nft.json +1 -1
  66. package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/mcp/cancel/route.js +2 -2
  71. package/.next/server/app/api/mcp/cancel/route.js.nft.json +1 -1
  72. package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js +1 -1
  74. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js.nft.json +1 -1
  75. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js +1 -1
  77. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js.nft.json +1 -1
  78. package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js +1 -1
  80. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js.nft.json +1 -1
  81. package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/mcp/servers/[name]/resources/route.js +1 -1
  83. package/.next/server/app/api/mcp/servers/[name]/resources/route.js.nft.json +1 -1
  84. package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/mcp/servers/[name]/route.js +1 -1
  86. package/.next/server/app/api/mcp/servers/[name]/route.js.nft.json +1 -1
  87. package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/mcp/servers/[name]/status/route.js +1 -1
  89. package/.next/server/app/api/mcp/servers/[name]/status/route.js.nft.json +1 -1
  90. package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js +1 -1
  92. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js.nft.json +1 -1
  93. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/mcp/servers/[name]/tools/route.js +1 -1
  95. package/.next/server/app/api/mcp/servers/[name]/tools/route.js.nft.json +1 -1
  96. package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/mcp/servers/route.js +1 -1
  98. package/.next/server/app/api/mcp/servers/route.js.nft.json +1 -1
  99. package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/mcp/test-connection/route.js +1 -1
  101. package/.next/server/app/api/mcp/test-connection/route.js.nft.json +1 -1
  102. package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/mcp/test-connection/stream/route.js +1 -1
  104. package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -1
  105. package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/mcp-registry/route.js +1 -1
  107. package/.next/server/app/api/mcp-registry/route.js.nft.json +1 -1
  108. package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/mcp-registry/spotlight/route.js +1 -1
  110. package/.next/server/app/api/mcp-registry/spotlight/route.js.nft.json +1 -1
  111. package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/model/[id]/route.js +1 -1
  113. package/.next/server/app/api/model/[id]/route.js.nft.json +1 -1
  114. package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/model/provider/route.js +1 -1
  116. package/.next/server/app/api/model/provider/route.js.nft.json +1 -1
  117. package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
  118. package/.next/server/app/api/model/route.js +1 -1
  119. package/.next/server/app/api/model/route.js.nft.json +1 -1
  120. package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/model/test/route.js +1 -1
  122. package/.next/server/app/api/model/test/route.js.nft.json +1 -1
  123. package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
  124. package/.next/server/app/api/oauth/callback/route.js +2 -2
  125. package/.next/server/app/api/oauth/callback/route.js.nft.json +1 -1
  126. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/oauth/initiate/route.js +2 -2
  128. package/.next/server/app/api/oauth/initiate/route.js.nft.json +1 -1
  129. package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/oauth/reset/route.js +1 -1
  131. package/.next/server/app/api/oauth/reset/route.js.nft.json +1 -1
  132. package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/planned-executions/[id]/route.js +1 -1
  134. package/.next/server/app/api/planned-executions/[id]/route.js.nft.json +1 -1
  135. package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
  136. package/.next/server/app/api/planned-executions/[id]/run/route.js +1 -1
  137. package/.next/server/app/api/planned-executions/[id]/run/route.js.nft.json +1 -1
  138. package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
  139. package/.next/server/app/api/planned-executions/[id]/runs/route.js +1 -1
  140. package/.next/server/app/api/planned-executions/[id]/runs/route.js.nft.json +1 -1
  141. package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/planned-executions/preview-schedule/route.js +1 -1
  143. package/.next/server/app/api/planned-executions/preview-schedule/route.js.nft.json +1 -1
  144. package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
  145. package/.next/server/app/api/planned-executions/reconcile/route.js +1 -0
  146. package/.next/server/app/api/planned-executions/reconcile/route.js.nft.json +1 -0
  147. package/.next/server/app/api/planned-executions/reconcile/route_client-reference-manifest.js +1 -0
  148. package/.next/server/app/api/planned-executions/route.js +1 -1
  149. package/.next/server/app/api/planned-executions/route.js.nft.json +1 -1
  150. package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
  151. package/.next/server/app/api/restore/route.js +1 -1
  152. package/.next/server/app/api/restore/route.js.nft.json +1 -1
  153. package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/api/runs/active/route.js +2 -0
  155. package/.next/server/app/api/runs/active/route.js.nft.json +1 -0
  156. package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -0
  157. package/.next/server/app/api/storage/route.js +1 -1
  158. package/.next/server/app/api/storage/route.js.nft.json +1 -1
  159. package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
  160. package/.next/server/app/api/update/route.js +1 -1
  161. package/.next/server/app/api/update/route.js.nft.json +1 -1
  162. package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  163. package/.next/server/app/api/waves/route.js +1 -0
  164. package/.next/server/app/api/waves/route.js.nft.json +1 -0
  165. package/.next/server/app/api/waves/route_client-reference-manifest.js +1 -0
  166. package/.next/server/app/api/webhooks/[id]/route.js +1 -1
  167. package/.next/server/app/api/webhooks/[id]/route.js.nft.json +1 -1
  168. package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
  169. package/.next/server/app/chat/page.js +10 -10
  170. package/.next/server/app/chat/page.js.nft.json +1 -1
  171. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  172. package/.next/server/app/chat.html +1 -1
  173. package/.next/server/app/chat.rsc +6 -4
  174. package/.next/server/app/docs/page.js +9 -4
  175. package/.next/server/app/docs/page.js.nft.json +1 -1
  176. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  177. package/.next/server/app/docs.html +1 -1
  178. package/.next/server/app/docs.rsc +6 -4
  179. package/.next/server/app/executions/page.js +3 -3
  180. package/.next/server/app/executions/page.js.nft.json +1 -1
  181. package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
  182. package/.next/server/app/executions.html +1 -1
  183. package/.next/server/app/executions.rsc +6 -4
  184. package/.next/server/app/flows/page.js +3 -3
  185. package/.next/server/app/flows/page.js.nft.json +1 -1
  186. package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
  187. package/.next/server/app/flows.html +1 -1
  188. package/.next/server/app/flows.rsc +6 -4
  189. package/.next/server/app/index.html +1 -1
  190. package/.next/server/app/index.rsc +6 -4
  191. package/.next/server/app/mcp/page.js +5 -5
  192. package/.next/server/app/mcp/page.js.nft.json +1 -1
  193. package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
  194. package/.next/server/app/mcp-flows/route.js +1 -1
  195. package/.next/server/app/mcp-flows/route.js.nft.json +1 -1
  196. package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
  197. package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
  198. package/.next/server/app/mcp-proxy/[server]/route.js.nft.json +1 -1
  199. package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
  200. package/.next/server/app/mcp.html +1 -1
  201. package/.next/server/app/mcp.rsc +6 -4
  202. package/.next/server/app/models/page.js +2 -2
  203. package/.next/server/app/models/page.js.nft.json +1 -1
  204. package/.next/server/app/models/page_client-reference-manifest.js +1 -1
  205. package/.next/server/app/page.js +2 -2
  206. package/.next/server/app/page.js.nft.json +1 -1
  207. package/.next/server/app/page_client-reference-manifest.js +1 -1
  208. package/.next/server/app/settings/page.js +14 -4
  209. package/.next/server/app/settings/page.js.nft.json +1 -1
  210. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  211. package/.next/server/app/settings.html +1 -1
  212. package/.next/server/app/settings.rsc +6 -4
  213. package/.next/server/app/v1/chat/completions/route.js +1 -1
  214. package/.next/server/app/v1/chat/completions/route.js.nft.json +1 -1
  215. package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
  216. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js +2 -2
  217. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js.nft.json +1 -1
  218. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
  219. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js +2 -2
  220. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js.nft.json +1 -1
  221. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
  222. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js +1 -1
  223. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js.nft.json +1 -1
  224. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
  225. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js +1 -1
  226. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js.nft.json +1 -1
  227. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
  228. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js +2 -2
  229. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js.nft.json +1 -1
  230. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
  231. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js +2 -2
  232. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js.nft.json +1 -1
  233. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
  234. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route.js +1 -1
  235. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route.js.nft.json +1 -1
  236. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -1
  237. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js +1 -1
  238. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js.nft.json +1 -1
  239. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
  240. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js +2 -2
  241. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js.nft.json +1 -1
  242. package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
  243. package/.next/server/app/v1/chat/conversations/route.js +2 -2
  244. package/.next/server/app/v1/chat/conversations/route.js.nft.json +1 -1
  245. package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
  246. package/.next/server/app/v1/models/route.js +1 -1
  247. package/.next/server/app/v1/models/route.js.nft.json +1 -1
  248. package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
  249. package/.next/server/app/waves/page.js +4 -0
  250. package/.next/server/app/waves/page.js.nft.json +1 -0
  251. package/.next/server/app/waves/page_client-reference-manifest.js +1 -0
  252. package/.next/server/app/waves.html +1 -0
  253. package/.next/server/app/waves.meta +7 -0
  254. package/.next/server/app/waves.rsc +22 -0
  255. package/.next/server/app-paths-manifest.json +19 -12
  256. package/.next/server/chunks/1083.js +1 -1
  257. package/.next/server/chunks/1152.js +1 -1
  258. package/.next/server/chunks/1197.js +1 -1
  259. package/.next/server/chunks/1226.js +1 -0
  260. package/.next/server/chunks/1373.js +1 -1
  261. package/.next/server/chunks/1377.js +1 -0
  262. package/.next/server/chunks/1439.js +1 -0
  263. package/.next/server/chunks/1556.js +52 -0
  264. package/.next/server/chunks/1659.js +1 -0
  265. package/.next/server/chunks/1910.js +37 -0
  266. package/.next/server/chunks/{4949.js → 1999.js} +1 -1
  267. package/.next/server/chunks/264.js +1 -1
  268. package/.next/server/chunks/2859.js +3 -3
  269. package/.next/server/chunks/289.js +1 -1
  270. package/.next/server/chunks/{6772.js → 3030.js} +1 -1
  271. package/.next/server/chunks/3286.js +6 -0
  272. package/.next/server/chunks/3489.js +1 -0
  273. package/.next/server/chunks/3648.js +1 -0
  274. package/.next/server/chunks/3774.js +6 -0
  275. package/.next/server/chunks/3823.js +40 -0
  276. package/.next/server/chunks/{3511.js → 3928.js} +1 -1
  277. package/.next/server/chunks/4239.js +1 -0
  278. package/.next/server/chunks/4265.js +1 -1
  279. package/.next/server/chunks/4372.js +1 -0
  280. package/.next/server/chunks/4456.js +1 -1
  281. package/.next/server/chunks/4561.js +64 -0
  282. package/.next/server/chunks/4637.js +13 -8
  283. package/.next/server/chunks/4671.js +1 -1
  284. package/.next/server/chunks/472.js +1 -0
  285. package/.next/server/chunks/4771.js +6 -0
  286. package/.next/server/chunks/5148.js +1 -0
  287. package/.next/server/chunks/5311.js +1 -0
  288. package/.next/server/chunks/5662.js +1 -1
  289. package/.next/server/chunks/5708.js +8 -3
  290. package/.next/server/chunks/5734.js +4 -4
  291. package/.next/server/chunks/6537.js +1 -0
  292. package/.next/server/chunks/6644.js +1 -0
  293. package/.next/server/chunks/6793.js +1 -0
  294. package/.next/server/chunks/6908.js +3 -3
  295. package/.next/server/chunks/701.js +1 -1
  296. package/.next/server/chunks/7032.js +1 -0
  297. package/.next/server/chunks/7214.js +4 -4
  298. package/.next/server/chunks/724.js +1 -1
  299. package/.next/server/chunks/7362.js +18 -18
  300. package/.next/server/chunks/7427.js +1 -0
  301. package/.next/server/chunks/7463.js +4 -4
  302. package/.next/server/chunks/7506.js +1 -1
  303. package/.next/server/chunks/7821.js +1 -1
  304. package/.next/server/chunks/8357.js +1 -0
  305. package/.next/server/chunks/8518.js +2 -0
  306. package/.next/server/chunks/{3778.js → 8652.js} +2 -2
  307. package/.next/server/chunks/8739.js +2 -2
  308. package/.next/server/chunks/8745.js +28 -0
  309. package/.next/server/chunks/9285.js +1 -0
  310. package/.next/server/chunks/9343.js +1 -1
  311. package/.next/server/functions-config-manifest.json +1 -1
  312. package/.next/server/instrumentation.js.nft.json +1 -1
  313. package/.next/server/middleware-build-manifest.js +1 -1
  314. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  315. package/.next/server/pages/404.html +1 -1
  316. package/.next/server/pages/500.html +1 -1
  317. package/.next/server/server-reference-manifest.js +1 -1
  318. package/.next/server/server-reference-manifest.json +1 -1
  319. package/.next/static/MMmWHUQ3UAJBdRB7G1zGj/_buildManifest.js +1 -0
  320. package/.next/static/chunks/1871-dd8c10ed9d37100b.js +1 -0
  321. package/.next/static/chunks/1983-242862b3dc022a26.js +1 -0
  322. package/.next/static/chunks/2003-460f30484998c05d.js +1 -0
  323. package/.next/static/chunks/4207-41abb9622eb4b4f8.js +1 -0
  324. package/.next/static/chunks/4812-4a9aceb49632a973.js +1 -0
  325. package/.next/static/chunks/5501-f5b093c8dfd74196.js +1 -0
  326. package/.next/static/chunks/5545-2ab6e5d749e103cd.js +1 -0
  327. package/.next/static/chunks/6016.a157e5bde2faa652.js +1 -0
  328. package/.next/static/chunks/6288-a285bbbd701e0dbf.js +1 -0
  329. package/.next/static/chunks/{3648-733cf7ca4a5d1f19.js → 6730-c330b55cd0fe4f47.js} +1 -1
  330. package/.next/static/chunks/6731-c230e88cf0032609.js +1 -0
  331. package/.next/static/chunks/7430-6e78aaeac66988a9.js +1 -0
  332. package/.next/static/chunks/{7583.26a8c1f6e6823daf.js → 7583.7cb88044a5212b29.js} +1 -1
  333. package/.next/static/chunks/8083.16fda2c7f6d10d0c.js +1 -0
  334. package/.next/static/chunks/812-181496bc32cd0cd3.js +1 -0
  335. package/.next/static/chunks/8480-229fd353b68b570f.js +1 -0
  336. package/.next/static/chunks/8834-bda798efab40c60a.js +1 -0
  337. package/.next/static/chunks/{9164-f54d3531ca1df5f7.js → 9164-3d34bf7eab100ac7.js} +1 -1
  338. package/.next/static/chunks/9181-8d8ecd3f641b7209.js +8 -0
  339. package/.next/static/chunks/9356-99ba407b60b9dfe9.js +1 -0
  340. package/.next/static/chunks/9451-680fa09f81f18806.js +1 -0
  341. package/.next/static/chunks/9659-a279e3aaba407251.js +1 -0
  342. package/.next/static/chunks/app/api/approvals/[id]/route-6b442f97c5062f2c.js +1 -0
  343. package/.next/static/chunks/app/api/approvals/route-6b442f97c5062f2c.js +1 -0
  344. package/.next/static/chunks/app/api/backup/route-6b442f97c5062f2c.js +1 -0
  345. package/.next/static/chunks/app/api/browse/route-6b442f97c5062f2c.js +1 -0
  346. package/.next/static/chunks/app/api/bugs/enhance/route-6b442f97c5062f2c.js +1 -0
  347. package/.next/static/chunks/app/api/cwd/route-6b442f97c5062f2c.js +1 -0
  348. package/.next/static/chunks/app/api/encryption/secure/route-6b442f97c5062f2c.js +1 -0
  349. package/.next/static/chunks/app/api/env/route-6b442f97c5062f2c.js +1 -0
  350. package/.next/static/chunks/app/api/flow/[id]/route-6b442f97c5062f2c.js +1 -0
  351. package/.next/static/chunks/app/api/flow/compile/route-6b442f97c5062f2c.js +1 -0
  352. package/.next/static/chunks/app/api/flow/generate/route-6b442f97c5062f2c.js +1 -0
  353. package/.next/static/chunks/app/api/flow/improve/route-6b442f97c5062f2c.js +1 -0
  354. package/.next/static/chunks/app/api/flow/prompt-renderer/route-6b442f97c5062f2c.js +1 -0
  355. package/.next/static/chunks/app/api/flow/quick-chat/route-6b442f97c5062f2c.js +1 -0
  356. package/.next/static/chunks/app/api/flow/repair/route-6b442f97c5062f2c.js +1 -0
  357. package/.next/static/chunks/app/api/flow/route-6b442f97c5062f2c.js +1 -0
  358. package/.next/static/chunks/app/api/git/route-6b442f97c5062f2c.js +1 -0
  359. package/.next/static/chunks/app/api/init/route-6b442f97c5062f2c.js +1 -0
  360. package/.next/static/chunks/app/api/local-models/capability/route-6b442f97c5062f2c.js +1 -0
  361. package/.next/static/chunks/app/api/local-models/pull/route-6b442f97c5062f2c.js +1 -0
  362. package/.next/static/chunks/app/api/local-models/suggest/route-6b442f97c5062f2c.js +1 -0
  363. package/.next/static/chunks/app/api/mcp/cancel/route-6b442f97c5062f2c.js +1 -0
  364. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-6b442f97c5062f2c.js +1 -0
  365. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-6b442f97c5062f2c.js +1 -0
  366. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-6b442f97c5062f2c.js +1 -0
  367. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-6b442f97c5062f2c.js +1 -0
  368. package/.next/static/chunks/app/api/mcp/servers/[name]/route-6b442f97c5062f2c.js +1 -0
  369. package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-6b442f97c5062f2c.js +1 -0
  370. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-6b442f97c5062f2c.js +1 -0
  371. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-6b442f97c5062f2c.js +1 -0
  372. package/.next/static/chunks/app/api/mcp/servers/route-6b442f97c5062f2c.js +1 -0
  373. package/.next/static/chunks/app/api/mcp/test-connection/route-6b442f97c5062f2c.js +1 -0
  374. package/.next/static/chunks/app/api/mcp/test-connection/stream/route-6b442f97c5062f2c.js +1 -0
  375. package/.next/static/chunks/app/api/mcp-registry/route-6b442f97c5062f2c.js +1 -0
  376. package/.next/static/chunks/app/api/mcp-registry/spotlight/route-6b442f97c5062f2c.js +1 -0
  377. package/.next/static/chunks/app/api/model/[id]/route-6b442f97c5062f2c.js +1 -0
  378. package/.next/static/chunks/app/api/model/provider/route-6b442f97c5062f2c.js +1 -0
  379. package/.next/static/chunks/app/api/model/route-6b442f97c5062f2c.js +1 -0
  380. package/.next/static/chunks/app/api/model/test/route-6b442f97c5062f2c.js +1 -0
  381. package/.next/static/chunks/app/api/oauth/callback/route-6b442f97c5062f2c.js +1 -0
  382. package/.next/static/chunks/app/api/oauth/initiate/route-6b442f97c5062f2c.js +1 -0
  383. package/.next/static/chunks/app/api/oauth/reset/route-6b442f97c5062f2c.js +1 -0
  384. package/.next/static/chunks/app/api/planned-executions/[id]/route-6b442f97c5062f2c.js +1 -0
  385. package/.next/static/chunks/app/api/planned-executions/[id]/run/route-6b442f97c5062f2c.js +1 -0
  386. package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-6b442f97c5062f2c.js +1 -0
  387. package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-6b442f97c5062f2c.js +1 -0
  388. package/.next/static/chunks/app/api/planned-executions/reconcile/route-6b442f97c5062f2c.js +1 -0
  389. package/.next/static/chunks/app/api/planned-executions/route-6b442f97c5062f2c.js +1 -0
  390. package/.next/static/chunks/app/api/restore/route-6b442f97c5062f2c.js +1 -0
  391. package/.next/static/chunks/app/api/runs/active/route-6b442f97c5062f2c.js +1 -0
  392. package/.next/static/chunks/app/api/storage/route-6b442f97c5062f2c.js +1 -0
  393. package/.next/static/chunks/app/api/update/route-6b442f97c5062f2c.js +1 -0
  394. package/.next/static/chunks/app/api/waves/route-6b442f97c5062f2c.js +1 -0
  395. package/.next/static/chunks/app/api/webhooks/[id]/route-6b442f97c5062f2c.js +1 -0
  396. package/.next/static/chunks/app/chat/page-3a3efba25b59a747.js +1 -0
  397. package/.next/static/chunks/app/docs/page-84a92c3d5d8d5e13.js +1 -0
  398. package/.next/static/chunks/app/executions/page-445afbf37819e3ce.js +1 -0
  399. package/.next/static/chunks/app/flows/page-74ebca19957cc6db.js +1 -0
  400. package/.next/static/chunks/app/layout-2ebf01d97702a18a.js +1 -0
  401. package/.next/static/chunks/app/mcp/page-770a870b3d40766b.js +1 -0
  402. package/.next/static/chunks/app/mcp-flows/route-6b442f97c5062f2c.js +1 -0
  403. package/.next/static/chunks/app/mcp-proxy/[server]/route-6b442f97c5062f2c.js +1 -0
  404. package/.next/static/chunks/app/models/error-a3183f168e8a9b04.js +1 -0
  405. package/.next/static/chunks/app/models/page-5a13ea6ff5ac1b9c.js +1 -0
  406. package/.next/static/chunks/app/{page-77e1ba238b0ee1d0.js → page-a859e4dbd180df98.js} +1 -1
  407. package/.next/static/chunks/app/settings/page-7a68583660508ffd.js +1 -0
  408. package/.next/static/chunks/app/v1/chat/completions/route-6b442f97c5062f2c.js +1 -0
  409. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-6b442f97c5062f2c.js +1 -0
  410. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-6b442f97c5062f2c.js +1 -0
  411. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-6b442f97c5062f2c.js +1 -0
  412. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-6b442f97c5062f2c.js +1 -0
  413. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-6b442f97c5062f2c.js +1 -0
  414. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-6b442f97c5062f2c.js +1 -0
  415. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/resources/route-6b442f97c5062f2c.js +1 -0
  416. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-6b442f97c5062f2c.js +1 -0
  417. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-6b442f97c5062f2c.js +1 -0
  418. package/.next/static/chunks/app/v1/chat/conversations/route-6b442f97c5062f2c.js +1 -0
  419. package/.next/static/chunks/app/v1/models/route-6b442f97c5062f2c.js +1 -0
  420. package/.next/static/chunks/app/waves/page-ec33cf79f6103a9e.js +1 -0
  421. package/.next/static/chunks/webpack-dded92b3d7b33173.js +1 -0
  422. package/.next/static/css/39393a79f7cb0dee.css +1 -0
  423. package/.next/static/css/599369d853c61df7.css +31 -0
  424. package/.next/static/css/b496025c9cd768cc.css +1 -0
  425. package/.next/trace +9 -9
  426. package/.next/types/app/api/approvals/[id]/route.ts +347 -0
  427. package/.next/types/app/api/approvals/route.ts +347 -0
  428. package/.next/types/app/api/bugs/enhance/route.ts +347 -0
  429. package/.next/types/app/api/planned-executions/reconcile/route.ts +347 -0
  430. package/.next/types/app/api/runs/active/route.ts +347 -0
  431. package/.next/types/app/api/waves/route.ts +347 -0
  432. package/.next/types/app/waves/page.ts +84 -0
  433. package/.next/types/routes.d.ts +9 -2
  434. package/.next/types/validator.ts +63 -0
  435. package/README.md +1 -1
  436. package/package.json +1 -1
  437. package/.next/server/chunks/1491.js +0 -1
  438. package/.next/server/chunks/1690.js +0 -1
  439. package/.next/server/chunks/1746.js +0 -1
  440. package/.next/server/chunks/1991.js +0 -1
  441. package/.next/server/chunks/2261.js +0 -1
  442. package/.next/server/chunks/2350.js +0 -1
  443. package/.next/server/chunks/2430.js +0 -1
  444. package/.next/server/chunks/3574.js +0 -6
  445. package/.next/server/chunks/3953.js +0 -1
  446. package/.next/server/chunks/4028.js +0 -1
  447. package/.next/server/chunks/4045.js +0 -1
  448. package/.next/server/chunks/4322.js +0 -1
  449. package/.next/server/chunks/4498.js +0 -40
  450. package/.next/server/chunks/4690.js +0 -38
  451. package/.next/server/chunks/5625.js +0 -28
  452. package/.next/server/chunks/6532.js +0 -52
  453. package/.next/server/chunks/6901.js +0 -6
  454. package/.next/server/chunks/6981.js +0 -1
  455. package/.next/server/chunks/7101.js +0 -64
  456. package/.next/server/chunks/7635.js +0 -6
  457. package/.next/server/chunks/8298.js +0 -1
  458. package/.next/server/chunks/9957.js +0 -1
  459. package/.next/static/chunks/1161-970b105d0ab11425.js +0 -1
  460. package/.next/static/chunks/1871-14c3e63ca865d85e.js +0 -1
  461. package/.next/static/chunks/1892-5c1e38d89e0a5a9c.js +0 -1
  462. package/.next/static/chunks/2003-7710c23acaef11c9.js +0 -1
  463. package/.next/static/chunks/2720-2a926505ec98a6de.js +0 -1
  464. package/.next/static/chunks/3381-5fd2417957ca0881.js +0 -1
  465. package/.next/static/chunks/3930-cc8d73c953811b97.js +0 -1
  466. package/.next/static/chunks/422-268783d9ad5897e1.js +0 -1
  467. package/.next/static/chunks/4365-5d0e3d01c1bc0fdc.js +0 -1
  468. package/.next/static/chunks/5134-e21bd33daaf14ecf.js +0 -1
  469. package/.next/static/chunks/5501-c400aaeaf57e6297.js +0 -1
  470. package/.next/static/chunks/5619-82fc5c3133837739.js +0 -1
  471. package/.next/static/chunks/6013-cb423bc438256acb.js +0 -1
  472. package/.next/static/chunks/7258-e27017c1b98f43f9.js +0 -1
  473. package/.next/static/chunks/7539.41f0448cf9783388.js +0 -1
  474. package/.next/static/chunks/8066-c202a83aef15143a.js +0 -1
  475. package/.next/static/chunks/8187.fd653767df53db87.js +0 -1
  476. package/.next/static/chunks/8345.76f420453fc0dee7.js +0 -1
  477. package/.next/static/chunks/8755-9f375ec8740fecac.js +0 -1
  478. package/.next/static/chunks/9587-706bfd1a692c4660.js +0 -8
  479. package/.next/static/chunks/app/api/backup/route-b296683a5faf800a.js +0 -1
  480. package/.next/static/chunks/app/api/browse/route-b296683a5faf800a.js +0 -1
  481. package/.next/static/chunks/app/api/cwd/route-b296683a5faf800a.js +0 -1
  482. package/.next/static/chunks/app/api/encryption/secure/route-b296683a5faf800a.js +0 -1
  483. package/.next/static/chunks/app/api/env/route-b296683a5faf800a.js +0 -1
  484. package/.next/static/chunks/app/api/flow/[id]/route-b296683a5faf800a.js +0 -1
  485. package/.next/static/chunks/app/api/flow/compile/route-b296683a5faf800a.js +0 -1
  486. package/.next/static/chunks/app/api/flow/generate/route-b296683a5faf800a.js +0 -1
  487. package/.next/static/chunks/app/api/flow/improve/route-b296683a5faf800a.js +0 -1
  488. package/.next/static/chunks/app/api/flow/prompt-renderer/route-b296683a5faf800a.js +0 -1
  489. package/.next/static/chunks/app/api/flow/quick-chat/route-b296683a5faf800a.js +0 -1
  490. package/.next/static/chunks/app/api/flow/repair/route-b296683a5faf800a.js +0 -1
  491. package/.next/static/chunks/app/api/flow/route-b296683a5faf800a.js +0 -1
  492. package/.next/static/chunks/app/api/git/route-b296683a5faf800a.js +0 -1
  493. package/.next/static/chunks/app/api/init/route-b296683a5faf800a.js +0 -1
  494. package/.next/static/chunks/app/api/local-models/capability/route-b296683a5faf800a.js +0 -1
  495. package/.next/static/chunks/app/api/local-models/pull/route-b296683a5faf800a.js +0 -1
  496. package/.next/static/chunks/app/api/local-models/suggest/route-b296683a5faf800a.js +0 -1
  497. package/.next/static/chunks/app/api/mcp/cancel/route-b296683a5faf800a.js +0 -1
  498. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-b296683a5faf800a.js +0 -1
  499. package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-b296683a5faf800a.js +0 -1
  500. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-b296683a5faf800a.js +0 -1
  501. package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-b296683a5faf800a.js +0 -1
  502. package/.next/static/chunks/app/api/mcp/servers/[name]/route-b296683a5faf800a.js +0 -1
  503. package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-b296683a5faf800a.js +0 -1
  504. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-b296683a5faf800a.js +0 -1
  505. package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-b296683a5faf800a.js +0 -1
  506. package/.next/static/chunks/app/api/mcp/servers/route-b296683a5faf800a.js +0 -1
  507. package/.next/static/chunks/app/api/mcp/test-connection/route-b296683a5faf800a.js +0 -1
  508. package/.next/static/chunks/app/api/mcp/test-connection/stream/route-b296683a5faf800a.js +0 -1
  509. package/.next/static/chunks/app/api/mcp-registry/route-b296683a5faf800a.js +0 -1
  510. package/.next/static/chunks/app/api/mcp-registry/spotlight/route-b296683a5faf800a.js +0 -1
  511. package/.next/static/chunks/app/api/model/[id]/route-b296683a5faf800a.js +0 -1
  512. package/.next/static/chunks/app/api/model/provider/route-b296683a5faf800a.js +0 -1
  513. package/.next/static/chunks/app/api/model/route-b296683a5faf800a.js +0 -1
  514. package/.next/static/chunks/app/api/model/test/route-b296683a5faf800a.js +0 -1
  515. package/.next/static/chunks/app/api/oauth/callback/route-b296683a5faf800a.js +0 -1
  516. package/.next/static/chunks/app/api/oauth/initiate/route-b296683a5faf800a.js +0 -1
  517. package/.next/static/chunks/app/api/oauth/reset/route-b296683a5faf800a.js +0 -1
  518. package/.next/static/chunks/app/api/planned-executions/[id]/route-b296683a5faf800a.js +0 -1
  519. package/.next/static/chunks/app/api/planned-executions/[id]/run/route-b296683a5faf800a.js +0 -1
  520. package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-b296683a5faf800a.js +0 -1
  521. package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-b296683a5faf800a.js +0 -1
  522. package/.next/static/chunks/app/api/planned-executions/route-b296683a5faf800a.js +0 -1
  523. package/.next/static/chunks/app/api/restore/route-b296683a5faf800a.js +0 -1
  524. package/.next/static/chunks/app/api/storage/route-b296683a5faf800a.js +0 -1
  525. package/.next/static/chunks/app/api/update/route-b296683a5faf800a.js +0 -1
  526. package/.next/static/chunks/app/api/webhooks/[id]/route-b296683a5faf800a.js +0 -1
  527. package/.next/static/chunks/app/chat/page-a67ad3683443e7ad.js +0 -1
  528. package/.next/static/chunks/app/docs/page-097827ec4dae1d30.js +0 -1
  529. package/.next/static/chunks/app/executions/page-cb0dcc66d84c9bf8.js +0 -1
  530. package/.next/static/chunks/app/flows/page-abdd0642e378c5da.js +0 -1
  531. package/.next/static/chunks/app/layout-64fc0ae7efe81e3c.js +0 -1
  532. package/.next/static/chunks/app/mcp/page-7d3a269dce68b529.js +0 -1
  533. package/.next/static/chunks/app/mcp-flows/route-b296683a5faf800a.js +0 -1
  534. package/.next/static/chunks/app/mcp-proxy/[server]/route-b296683a5faf800a.js +0 -1
  535. package/.next/static/chunks/app/models/error-5732fbb053e182c5.js +0 -1
  536. package/.next/static/chunks/app/models/page-616950f93a1e0027.js +0 -1
  537. package/.next/static/chunks/app/settings/page-199d0ffae9ec7263.js +0 -1
  538. package/.next/static/chunks/app/v1/chat/completions/route-b296683a5faf800a.js +0 -1
  539. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-b296683a5faf800a.js +0 -1
  540. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-b296683a5faf800a.js +0 -1
  541. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-b296683a5faf800a.js +0 -1
  542. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-b296683a5faf800a.js +0 -1
  543. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-b296683a5faf800a.js +0 -1
  544. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-b296683a5faf800a.js +0 -1
  545. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/resources/route-b296683a5faf800a.js +0 -1
  546. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-b296683a5faf800a.js +0 -1
  547. package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-b296683a5faf800a.js +0 -1
  548. package/.next/static/chunks/app/v1/chat/conversations/route-b296683a5faf800a.js +0 -1
  549. package/.next/static/chunks/app/v1/models/route-b296683a5faf800a.js +0 -1
  550. package/.next/static/chunks/webpack-ef5b2cef70829f42.js +0 -1
  551. package/.next/static/css/d1484588c616b291.css +0 -31
  552. package/.next/static/dvSaKx6-EfRNi7Xj-cSv_/_buildManifest.js +0 -1
  553. /package/.next/static/{dvSaKx6-EfRNi7Xj-cSv_ → MMmWHUQ3UAJBdRB7G1zGj}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";exports.id=4637,exports.ids=[4637],exports.modules={74637:(a,b,c)=>{let d;c.d(b,{internalCallTool:()=>a9,internalToolDefinitions:()=>aQ});var e=c(33873),f=c.n(e),g=c(29021),h=c(79646),i=c(18230);let j=(0,i.h)("utils/process/killProcessTree");var k=c(11659),l=c(12763),m=c(71188),n=c(67463),o=c(89850),p=c(8336),q=c(78606);function r(a,b,c,d){return"number"!=typeof a||Number.isNaN(a)?d:Math.max(b,Math.min(c,Math.floor(a)))}let s={type:"arrowclosed",width:20,height:20,color:"#1976d2"},t={stroke:"#1976d2",strokeWidth:2},u={type:"arrowclosed",width:20,height:20,color:"#009688"},v={stroke:"#009688",strokeWidth:2},w=new Set(["full-history","latest-message","isolated"]),x=new Set(["steps","final-only"]),y=new Set(["full-conversation","latest-message"]);function z(a){let b=(0,p.A$)(a);if(0===b.length)return{text:a,stripped:!1};let c="",d=0;for(let e of b)c+=a.slice(d,e.index)+e.name,d=e.index+e.fullMatch.length;return{text:c+=a.slice(d),stripped:!0}}function A(a,b){if(b.some(b=>b.id===a))return a;let c=a.toLowerCase(),d=b.find(a=>a.name.toLowerCase()===c);return d?d.id:null}var B=c(54898),C=c(99924);let D=(0,i.h)("backend/services/flow/generationContext");function E(a,b){let c=String(a).replace(/\s+/g," ").trim();return c.length<=b?c:`${c.slice(0,b).trimEnd()}…`}async function F(){let a=await l.modelService.loadModels(),b=a.map(a=>({id:a.id,name:a.name,...a.displayName?{displayName:a.displayName}:{},...a.description?{description:E(a.description,100)}:{}})),c=[],d={};try{let a=await C.mcpService.loadServerConfigs();if(Array.isArray(a))for(let b of a){if(b.disabled)continue;let a=!1;try{let c=await C.mcpService.getServerStatus(b.name);a=c?.status==="connected"}catch(a){D.debug(`getServerStatus failed for ${b.name}; listing name only`,a)}if(!a){c.push({name:b.name,connected:!1});continue}let{tools:e}=await C.mcpService.listServerTools(b.name),f=(e??[]).filter(a=>a.name).map(a=>({name:a.name,...a.description?{description:E(a.description,100)}:{}}));d[b.name]=f.map(a=>a.name),c.push({name:b.name,connected:!0,tools:f})}}catch(a){D.warn("Could not load MCP servers for the authoring context",a)}let e=[];try{e=await k.flowService.loadFlows()}catch(a){D.warn("Could not load flows for the authoring context",a)}let f={models:b,servers:c,flows:e.map(a=>({id:a.id,name:a.name,...a.description?{description:E(a.description,300)}:{},nodeCount:a.nodes?.length??0}))};return{blocks:f,compile:{models:a.map(a=>({id:a.id,name:a.name,displayName:a.displayName})),servers:c.map(a=>({name:a.name})),serverTools:d,flows:e.map(a=>({id:a.id,name:a.name}))},catalog:function(a){let b=[];for(let c of(b.push("AVAILABLE MODELS (reference by id or name):"),0===a.models.length&&b.push(" (none configured)"),a.models)){let a=c.displayName&&c.displayName!==c.name?`"${c.displayName}" (${c.name})`:c.name,d=c.description?` — ${c.description}`:"";b.push(` - id: ${c.id} — ${a}${d}`)}for(let c of(b.push("",'AVAILABLE MCP SERVERS (attach to process nodes via "servers"):'),0===a.servers.length&&b.push(" (none configured)"),a.servers)){if(!c.connected){b.push(` - ${c.name} (offline — tools unknown; may still be used)`);continue}b.push(` - ${c.name}:`);let a=(c.tools??[]).slice(0,20);for(let c of a){let a=c.description?` — ${c.description}`:"";b.push(` - ${c.name}${a}`)}let d=(c.tools?.length??0)-a.length;d>0&&b.push(` - …and ${d} more`)}for(let c of(b.push("",'EXISTING FLOWS (usable as subflow targets via "flow"):'),0===a.flows.length&&b.push(" (none)"),a.flows.slice(0,15))){let a=c.description?` — ${c.description}`:` — ${c.nodeCount} nodes`;b.push(` - "${c.name}"${a}`)}return a.flows.length>15&&b.push(` - …and ${a.flows.length-15} more`),b.join("\n")}(f),validatorServers:c.map(a=>({name:a.name,status:a.connected?"connected":"disconnected"}))}}let G=(0,i.h)("backend/services/flow/compileFlow");async function H(a,b={}){if(!a||"object"!=typeof a||Array.isArray(a))return{success:!1,error:"The spec must be a JSON object (a FlowSpec)",statusCode:400};let c=await F(),d=c.compile;if(b.updateFlowId){let a=d.flows??[];if(!a.some(a=>a.id===b.updateFlowId))return{success:!1,error:`No flow with id "${b.updateFlowId}" to update`,statusCode:404};d={...d,flows:a.filter(a=>a.id!==b.updateFlowId)}}let e=function(a,b={},c={}){let d=[],e=(a,b,c)=>d.push({severity:"error",code:a,message:b,nodeKey:c}),f=(a,b,c)=>d.push({severity:"warning",code:a,message:b,nodeKey:c}),g=b.models??[],h=new Set((b.servers??[]).map(a=>a.name)),i=b.serverTools??{},j=r(c.maxDepth,0,3,3),k=r(c.maxFlows,1,8,8),l=[],m=[...(b.flows??[]).map(a=>a.name)],n=[],p=0;var B=function a(d,B,C){let D=Array.isArray(d?.nodes)?d.nodes:[],E=Array.isArray(d?.edges)?d.edges:[],G=function(a,b){let c=(a??"").trim().replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"");c||(c="generated_flow");let d=new Set(b.map(a=>a.toLowerCase()));if(!d.has(c.toLowerCase()))return c;for(let a=2;;a++){let b=`${c}_${a}`;if(!d.has(b.toLowerCase()))return b}}(d?.name,m);m.push(G),p++;let H=(0,o.A)(),I=[...C,G],J=new Map,K=[],L=[];for(let c of D){let d=c?.key;if(!d||"string"!=typeof d){e("node-missing-key",'A node is missing its "key" — every node needs a unique key.');continue}if(J.has(d)){e("node-duplicate-key",`Duplicate node key "${d}" — keys must be unique; the later node was dropped.`,d);continue}let l=c.type;if("mcp"===l){e("mcp-node-not-allowed",`Node "${d}": do not emit "mcp" nodes — attach servers to a process node via its "servers" list instead.`,d);continue}if("start"!==l&&"process"!==l&&"finish"!==l&&"subflow"!==l&&"resource"!==l){e("unknown-node-type",`Node "${d}" has unknown type "${String(l)}".`,d);continue}let m={},q="string"==typeof c.prompt?c.prompt:void 0;if("start"===l){let{text:a,stripped:b}=z(q??"");b&&f("pill-stripped",`Node "${d}": binding pills are not supported in generated prompts and were replaced with plain names.`,d),m.promptTemplate=a}else if("process"===l){let{text:a,stripped:b}=z(q??"");if(b&&f("pill-stripped",`Node "${d}": binding pills are not supported in generated prompts and were replaced with plain names.`,d),m.promptTemplate=a,c.model){let a=function(a,b){if(b.some(b=>b.id===a))return a;let c=a.toLowerCase(),d=b.find(a=>a.displayName?.toLowerCase()===c);if(d)return d.id;let e=b.find(a=>a.name?.toLowerCase()===c);return e?e.id:null}(c.model,g);a?m.boundModel=a:(m.boundModel=c.model,f("model-unresolved",`Node "${d}": model "${c.model}" does not match any configured model (by id, display name, or name).`,d))}void 0!==c.inputMode&&(w.has(c.inputMode)?(m.inputMode=c.inputMode,"isolated"===c.inputMode&&"string"==typeof c.isolatedPrompt&&(m.isolatedPrompt=c.isolatedPrompt)):f("invalid-input-mode",`Node "${d}": inputMode "${String(c.inputMode)}" is not valid (full-history | latest-message | isolated); omitted.`,d)),void 0!==c.outputMode&&(y.has(c.outputMode)?m.outputMode=c.outputMode:f("invalid-output-mode",`Node "${d}": outputMode "${String(c.outputMode)}" is not valid on a process node (full-conversation | latest-message); omitted.`,d)),void 0!==c.maxTurns&&("number"!=typeof c.maxTurns||Number.isNaN(c.maxTurns)?f("invalid-max-turns",`Node "${d}": maxTurns "${String(c.maxTurns)}" is not a number; omitted.`,d):m.maxTurns=r(c.maxTurns,1,1e3,1)),"boolean"==typeof c.excludeModelPrompt&&(m.excludeModelPrompt=c.excludeModelPrompt),"boolean"==typeof c.excludeStartNodePrompt&&(m.excludeStartNodePrompt=c.excludeStartNodePrompt),"boolean"==typeof c.excludeSystemPrompt&&(m.excludeSystemPrompt=c.excludeSystemPrompt),Array.isArray(c.allowedTools)&&(m.allowedTools=c.allowedTools.filter(a=>"string"==typeof a&&a)),"string"==typeof c.captureVariable&&c.captureVariable.trim()&&(m.captureVariable=c.captureVariable.trim()),"string"==typeof c.captureResource&&c.captureResource.trim()&&(m.captureResource=c.captureResource.trim())}else if("subflow"===l){if(function(c,d,g,h,i){let l=Array.isArray(c.parallelFlows)&&c.parallelFlows.length>0,m=Array.isArray(c.parallelSubflowSpecs)&&c.parallelSubflowSpecs.length>0;if([void 0!==c.flow&&null!==c.flow?"flow":null,void 0!==c.subflowSpec&&null!==c.subflowSpec?"subflowSpec":null,l?"parallelFlows":null,m?"parallelSubflowSpecs":null,void 0!==c.generateSubflow&&null!==c.generateSubflow?"generateSubflow":null].filter(Boolean).length>1&&f("subflow-multiple-sources",`Node "${d}": a subflow node should have only one target source ("flow", "subflowSpec", "parallelFlows", "parallelSubflowSpecs", or "generateSubflow"); applying precedence flow > subflowSpec > parallelFlows > parallelSubflowSpecs > generateSubflow.`,d),!0===c.mapOverList){let a=void 0!==c.flow&&null!==c.flow||void 0!==c.subflowSpec&&null!==c.subflowSpec;(l||m)&&e("subflow-map-and-parallel",`Node "${d}": "mapOverList" runs a SINGLE child once per item and cannot be combined with "parallelFlows"/"parallelSubflowSpecs".`,d),a?(i.mapOverList=!0,void 0!==c.itemSplit&&("json-array"===c.itemSplit||"lines"===c.itemSplit?i.itemSplit=c.itemSplit:f("invalid-item-split",`Node "${d}": itemSplit "${String(c.itemSplit)}" is not valid (json-array | lines); using json-array.`,d)),!0===c.sequential&&(i.sequential=!0),F(c,i)):e("subflow-map-no-child",`Node "${d}": "mapOverList" needs a single child ("flow" or "subflowSpec") to run once per item.`,d)}if(c.flow){if(h.some(a=>a.toLowerCase()===c.flow.toLowerCase()))return e("subflow-cycle",`Node "${d}": flow "${c.flow}" refers to an ancestor flow, which would create a cycle.`,d);let a=A(c.flow,[...b.flows??[],...n]);return a?i.subflowId=a:e("subflow-unresolved",`Node "${d}": flow "${c.flow}" does not match any existing flow (by id or name).`,d)}if(c.subflowSpec){if(g+1>j)return e("subflow-too-deep",`Node "${d}": nested subflows may not go deeper than ${j} level(s); this inline subflow was not compiled.`,d);if(p>=k)return e("subflow-too-many",`Node "${d}": compiling this inline subflow would exceed the maximum of ${k} flows in one bundle; it was not compiled.`,d);let b=a(c.subflowSpec,g+1,h);return b?i.subflowId=b.id:e("subflow-child-empty",`Node "${d}": the inline "subflowSpec" produced no usable flow.`,d)}if(l){let a=[];for(let f of c.parallelFlows){if("string"!=typeof f||!f){e("parallel-flow-invalid",`Node "${d}": a "parallelFlows" entry is missing or not a string.`,d);continue}if(h.some(a=>a.toLowerCase()===f.toLowerCase())){e("subflow-cycle",`Node "${d}": parallel flow "${f}" refers to an ancestor flow, which would create a cycle.`,d);continue}let c=A(f,[...b.flows??[],...n]);c?a.includes(c)||a.push(c):e("parallel-flow-unresolved",`Node "${d}": parallel flow "${f}" does not match any existing flow (by id or name).`,d)}a.length>0?(i.parallelSubflowIds=a,F(c,i)):e("parallel-empty",`Node "${d}": "parallelFlows" resolved to no runnable lanes.`,d);return}if(m){let b=[];for(let f of c.parallelSubflowSpecs){if(!f||"object"!=typeof f){e("parallel-spec-invalid",`Node "${d}": a "parallelSubflowSpecs" entry is not a FlowSpec object.`,d);continue}if(g+1>j){e("subflow-too-deep",`Node "${d}": nested subflows may not go deeper than ${j} level(s); a parallel inline subflow was not compiled.`,d);continue}if(p>=k){e("subflow-too-many",`Node "${d}": compiling a parallel inline subflow would exceed the maximum of ${k} flows in one bundle; it was not compiled.`,d);continue}let c=a(f,g+1,h);c?b.push(c.id):e("subflow-child-empty",`Node "${d}": a "parallelSubflowSpecs" entry produced no usable flow.`,d)}b.length>0?(i.parallelSubflowIds=b,F(c,i)):e("parallel-empty",`Node "${d}": "parallelSubflowSpecs" produced no runnable lanes.`,d);return}if(void 0!==c.generateSubflow&&null!==c.generateSubflow)return e("subflow-generate-unsupported",`Node "${d}": "generateSubflow" is only available through the AI flow generator. Use "subflowSpec" for deterministic nested authoring, or "flow" to reference an existing flow.`,d);e("subflow-missing-flow",`Node "${d}": subflow nodes need a "flow" (existing flow), a "subflowSpec" (inline child), "parallelFlows"/"parallelSubflowSpecs" (concurrent children), or "generateSubflow".`,d)}(c,d,B,I,m),void 0!==c.inputMode&&(w.has(c.inputMode)?m.inputMode=c.inputMode:f("invalid-input-mode",`Node "${d}": inputMode "${String(c.inputMode)}" is not valid (full-history | latest-message | isolated); omitted.`,d)),void 0!==c.outputMode&&(x.has(c.outputMode)?m.outputMode=c.outputMode:f("invalid-output-mode",`Node "${d}": outputMode "${String(c.outputMode)}" is not valid (steps | final-only); omitted.`,d)),void 0!==q){let{text:a,stripped:b}=z(q);b&&f("pill-stripped",`Node "${d}": binding pills are not supported in generated prompts and were replaced with plain names.`,d),m.promptTemplate=a}"boolean"==typeof c.allowCallerPrompt&&(m.allowCallerPrompt=c.allowCallerPrompt),"string"==typeof c.captureVariable&&c.captureVariable.trim()&&(m.captureVariable=c.captureVariable.trim()),"string"==typeof c.captureResource&&c.captureResource.trim()&&(m.captureResource=c.captureResource.trim())}else if("resource"===l){let a="string"==typeof c.runName?c.runName.trim():"",b="string"==typeof c.server?c.server.trim():"",e="string"==typeof c.uri?c.uri.trim():"";a?(m.scope="run",m.runName=a,(b||e)&&f("resource-both-bindings",`Node "${d}": a resource node is EITHER a run artifact ("runName") or a static MCP resource ("server"+"uri"); kept the run artifact.`,d)):(m.scope="mcp",b&&(m.boundServer=b),e&&(m.uri=e),b&&e?h.has(b)||f("server-unknown",`Node "${d}": MCP server "${b}" is not configured in FLUJO.`,d):f("resource-missing-binding",`Node "${d}": a static resource node needs both "server" and "uri" (or a "runName" for a run artifact).`,d))}let s={id:(0,o.A)(),type:l,position:{x:0,y:0},data:{label:c.label||`${l.charAt(0).toUpperCase()}${l.slice(1)} Node`,type:l,...c.description?{description:c.description}:{},properties:m}};if(J.set(d,s),K.push(s),"process"===l&&Array.isArray(c.servers)){let a=new Set;for(let b of c.servers){let c,e=b?.name;if(!e||"string"!=typeof e){f("server-missing-name",`Node "${d}": a server reference is missing its "name"; skipped.`,d);continue}if(a.has(e))continue;a.add(e),h.has(e)||f("server-unknown",`Node "${d}": MCP server "${e}" is not configured in FLUJO.`,d);let g=i[e];if(Array.isArray(b.tools)){if(c=b.tools.filter(a=>"string"==typeof a&&a),g){let a=c.filter(a=>!g.includes(a));a.length>0&&f("tool-unknown",`Node "${d}": server "${e}" does not report tool(s): ${a.join(", ")}.`,d)}}else c=g?[...g]:[];let j={id:(0,o.A)(),type:"mcp",position:{x:0,y:0},data:{label:e,type:"mcp",properties:{boundServer:e,enabledTools:c}}};K.push(j),L.push({processKey:d,mcpNode:j})}}else"process"!==l&&Array.isArray(c.servers)&&c.servers.length>0&&f("servers-on-non-process",`Node "${d}": only process nodes can have "servers"; ignored.`,d)}if(0===J.size)return e("no-usable-nodes","No usable nodes — the spec must contain at least a start node and one step."),null;let M=[],N=new Set;for(let a of E){let b,c=a?.from,d=a?.to,g=c?J.get(c):void 0,h=d?J.get(d):void 0;if(!g||!h){e("edge-unknown-node",`Edge "${String(c)}" -> "${String(d)}" references a node key that does not exist (or was dropped).`);continue}if(g===h){e("edge-self-loop",`Edge "${c}" -> "${d}": a node cannot connect to itself.`);continue}if("resource"===g.type||"resource"===h.type){if(("resource"!==g.type||"process"!==h.type)&&("process"!==g.type||"resource"!==h.type)){e("resource-edge-invalid",`Edge "${c}" -> "${d}": resource nodes connect only to process nodes.`);continue}a.condition&&f("resource-edge-condition",`Edge "${c}" -> "${d}": conditions do not apply to resource wiring; dropped.`),!0===a.bidirectional&&f("resource-edge-bidirectional",`Edge "${c}" -> "${d}": resource wiring is directional (read vs write); "bidirectional" was ignored — add the opposite edge explicitly if the step both reads and writes.`);let b=`${c}->${d}`;if(N.has(b)){f("edge-duplicate",`Edge "${c}" -> "${d}" appears more than once; kept the first.`);continue}N.add(b),M.push(function(a,b){let c="resource"===a.type?"resource-out":"process-right-resource",d="resource"===b.type?"resource-in":"process-left-resource";return{id:`${a.id}:${c}->${b.id}:${d}`,source:a.id,sourceHandle:c,target:b.id,targetHandle:d,type:"resourceEdge",data:{edgeType:"resource"},animated:!1,markerEnd:{...u},style:{...v}}}(g,h));continue}if("start"===h.type){e("edge-into-start",`Edge "${c}" -> "${d}": nothing may connect INTO a start node.`);continue}if("finish"===g.type){e("edge-out-of-finish",`Edge "${c}" -> "${d}": nothing may connect OUT OF a finish node.`);continue}let i=`${c}->${d}`;if(N.has(i)){f("edge-duplicate",`Edge "${c}" -> "${d}" appears more than once; kept the first.`);continue}N.add(i);let j=!0===a.bidirectional;j&&("start"===g.type||"finish"===h.type)&&(f("bidirectional-illegal",`Edge "${c}" -> "${d}" cannot be bidirectional; downgraded to one-way.`),j=!1);let k=a.condition;k&&"object"==typeof k&&("process"!==g.type?f("edge-condition-non-process",`Edge "${c}" -> "${d}" has a condition but leaves a ${g.type} node; conditions only route from process nodes and were dropped.`):(0,q.C)(k.kind)?"string"!=typeof k.value||0===k.value.length?f("edge-condition-value",`Edge "${c}" -> "${d}" has a condition with no "value"; the condition was dropped.`):("regex"!==k.kind||(0,q.wM)(k.value)||f("edge-condition-regex",`Edge "${c}" -> "${d}" has a regex condition that does not compile; it is kept but will never match at runtime.`),b={kind:k.kind,value:k.value,..."last-message"===k.target?{target:"last-message"}:{},...!0===k.ignoreCase?{ignoreCase:!0}:{},...!0===k.negate?{negate:!0}:{}}):f("edge-condition-kind",`Edge "${c}" -> "${d}" has an unknown condition kind "${String(k.kind)}"; the condition was dropped.`)),M.push(function(a,b,c,d){let e=`${a.type}-bottom`,f=`${b.type}-top`;return{id:`${a.id}:${e}->${b.id}:${f}`,source:a.id,sourceHandle:e,target:b.id,targetHandle:f,type:"custom",data:{edgeType:"standard",...c?{bidirectional:!0}:{},...d?{condition:d}:{}},animated:!0}}(g,h,j,b))}for(let{processKey:a,mcpNode:b}of L){let c=J.get(a);M.push(function(a,b){let c="process-right-mcp",d="mcp-left";return{id:`${a.id}:${c}->${b.id}:${d}`,source:a.id,sourceHandle:c,target:b.id,targetHandle:d,type:"mcpEdge",data:{edgeType:"mcp"},animated:!1,markerEnd:{...s},markerStart:{...s},style:{...t}}}(c,b))}!function(a,b,c,d,e){let f=new Map;for(let a of c){let b=a.data?.edgeType;"mcp"!==b&&"resource"!==b&&(f.has(a.source)||f.set(a.source,[]),f.get(a.source).push(a.target))}let g=[...b.values()],h=g.filter(a=>"resource"===a.type),i=g.filter(a=>"resource"!==a.type),j=i.filter(a=>"start"===a.type),k=j.length>0?j:i.slice(0,1),l=new Map,m=k.map(a=>({id:a.id,depth:0}));for(let a of m)l.set(a.id,0);for(;m.length;){let{id:a,depth:b}=m.shift();for(let c of f.get(a)??[])l.has(c)||(l.set(c,b+1),m.push({id:c,depth:b+1}))}let n=0;for(let a of l.values())n=Math.max(n,a);for(let a of i)l.has(a.id)||l.set(a.id,n+1);let o=new Map;for(let[a,c]of b)o.set(c.id,a);let p=new Map;for(let a of i){let b=o.get(a.id),c=e&&b?e[b]:void 0;if(c&&"number"==typeof c.x&&"number"==typeof c.y){a.position={x:c.x,y:c.y};continue}let d=l.get(a.id),f=p.get(d)??0;p.set(d,f+1),a.position={x:250+280*f,y:150+170*d}}let q=new Map;for(let{processKey:a,mcpNode:c}of d){let d=b.get(a),e=q.get(a)??0;q.set(a,e+1),c.position={x:d.position.x+320,y:d.position.y+150*e}}let r=new Map(g.map(a=>[a.id,a])),s=new Map,t=0;for(let a of h){let b=o.get(a.id),d=e&&b?e[b]:void 0;if(d&&"number"==typeof d.x&&"number"==typeof d.y){a.position={x:d.x,y:d.y};continue}let f=c.find(b=>b.data?.edgeType==="resource"&&(b.source===a.id||b.target===a.id)),g=f?f.source===a.id?f.target:f.source:void 0,h=g?r.get(g):void 0;if(h){let b=s.get(h.id)??0;s.set(h.id,b+1),a.position={x:h.position.x-320,y:h.position.y+150*b}}else{let b=0;for(let a of i)b=Math.max(b,a.position.y);a.position={x:250+280*t,y:b+170},t++}}}(0,J,M,L,0===B?c.positions:void 0);let O={id:H,name:G,...d?.description?{description:d.description}:{},nodes:K,edges:M};return l.push(O),n.push({id:O.id,name:O.name}),O}(a,0,[]),C=l,D=d;let E=D.filter(a=>"error"===a.severity).length;return{flow:B,flows:C,issues:D,errorCount:E,warningCount:D.length-E};function F(a,b){void 0!==a.concurrencyLimit&&("number"!=typeof a.concurrencyLimit||Number.isNaN(a.concurrencyLimit)?f("invalid-concurrency-limit",`Node "${a.key}": concurrencyLimit "${String(a.concurrencyLimit)}" is not a number; using the runtime default.`,a.key):b.concurrencyLimit=Math.max(1,Math.floor(a.concurrencyLimit))),"string"==typeof a.joinSeparator&&(b.joinSeparator=a.joinSeparator),void 0!==a.errorStrategy&&("fail-fast"===a.errorStrategy||"collect-all"===a.errorStrategy?b.errorStrategy=a.errorStrategy:f("invalid-error-strategy",`Node "${a.key}": errorStrategy "${String(a.errorStrategy)}" is not valid (fail-fast | collect-all); using collect-all.`,a.key))}}(a,d);if(!e.flow)return{success:!1,error:"The spec could not be compiled into a flow",statusCode:422,issues:e.issues.map(a=>({severity:a.severity,code:a.code,message:a.message}))};b.updateFlowId&&(e.flow.id=b.updateFlowId);let f=e.flows.flatMap(a=>(0,B.nC)(a,{models:c.compile.models,servers:c.validatorServers,serverTools:c.compile.serverTools}).issues),g=function(a,b){let c=[...a.map(a=>({severity:a.severity,code:a.code,message:a.message})),...b.issues],d=c.filter(a=>"error"===a.severity).length;return{issues:c,errorCount:d,warningCount:c.length-d,isRunnable:0===d}}(e.issues,{issues:f,errorCount:0,warningCount:0,isRunnable:!0}),h=!1;if(b.save&&0===g.errorCount){for(let a of e.flows)await k.flowService.saveFlow(a);h=!0,G.info(`Compiled and saved ${e.flows.length} flow(s); root "${e.flow.name}" (${e.flow.id})`)}else b.save&&G.info(`Compiled flow "${e.flow.name}" has ${g.errorCount} error(s); NOT saved`);return{success:!0,flow:e.flow,flows:e.flows,validation:g,saved:h}}var I=c(37101),J=c(79111),K=c(34115);let L=(0,i.h)("backend/execution/flow/loadConversationState");async function M(a){if(I.FlowExecutor.conversationStates.has(a))return L.debug("Loaded state from memory",{conversationId:a}),I.FlowExecutor.conversationStates.get(a);let b=`conversations/${a}`;try{let c=await (0,J.YM)(b,void 0);if(c)return L.debug("Loaded state from storage",{conversationId:a}),await (0,K.jM)(c),I.FlowExecutor.conversationStates.set(a,c),c}catch(b){L.warn("Error loading conversation state from storage",{conversationId:a,error:b})}}var N=c(96249),O=c(63129);let P=`A FlowSpec is a JSON object describing a FLUJO flow semantically — node keys and edges, no coordinates, no ids, no layout:
1
+ "use strict";exports.id=4637,exports.ids=[4637],exports.modules={74637:(a,b,c)=>{let d;c.d(b,{internalCallTool:()=>bm,internalToolDefinitions:()=>aS});var e=c(33873),f=c.n(e),g=c(29021),h=c(79646),i=c(18230);let j=(0,i.h)("utils/process/killProcessTree");var k=c(11659),l=c(12763),m=c(50010),n=c(35432),o=c(67463),p=c(89850),q=c(8336),r=c(78606);function s(a,b,c,d){return"number"!=typeof a||Number.isNaN(a)?d:Math.max(b,Math.min(c,Math.floor(a)))}let t={type:"arrowclosed",width:20,height:20,color:"#1976d2"},u={stroke:"#1976d2",strokeWidth:2},v={type:"arrowclosed",width:20,height:20,color:"#009688"},w={stroke:"#009688",strokeWidth:2},x=new Set(["full-history","latest-message","isolated"]),y=new Set(["steps","final-only"]),z=new Set(["full-conversation","latest-message"]);function A(a){let b=(0,q.A$)(a);if(0===b.length)return{text:a,stripped:!1};let c="",d=0;for(let e of b)c+=a.slice(d,e.index)+e.name,d=e.index+e.fullMatch.length;return{text:c+=a.slice(d),stripped:!0}}function B(a,b){if(b.some(b=>b.id===a))return a;let c=a.toLowerCase(),d=b.find(a=>a.name.toLowerCase()===c);return d?d.id:null}var C=c(54898),D=c(82464);let E=(0,i.h)("backend/services/flow/generationContext");function F(a,b){let c=String(a).replace(/\s+/g," ").trim();return c.length<=b?c:`${c.slice(0,b).trimEnd()}…`}async function G(){let a=await l.modelService.loadModels(),b=a.map(a=>({id:a.id,name:a.name,...a.displayName?{displayName:a.displayName}:{},...a.description?{description:F(a.description,100)}:{}})),c=[],d={};try{let a=await D.mcpService.loadServerConfigs();if(Array.isArray(a))for(let b of a){if(b.disabled)continue;let a=!1;try{let c=await D.mcpService.getServerStatus(b.name);a=c?.status==="connected"}catch(a){E.debug(`getServerStatus failed for ${b.name}; listing name only`,a)}if(!a){c.push({name:b.name,connected:!1});continue}let{tools:e}=await D.mcpService.listServerTools(b.name),f=(e??[]).filter(a=>a.name).map(a=>({name:a.name,...a.description?{description:F(a.description,100)}:{}}));d[b.name]=f.map(a=>a.name),c.push({name:b.name,connected:!0,tools:f})}}catch(a){E.warn("Could not load MCP servers for the authoring context",a)}let e=[];try{e=await k.flowService.loadFlows()}catch(a){E.warn("Could not load flows for the authoring context",a)}let f={models:b,servers:c,flows:e.map(a=>({id:a.id,name:a.name,...a.description?{description:F(a.description,300)}:{},nodeCount:a.nodes?.length??0}))};return{blocks:f,compile:{models:a.map(a=>({id:a.id,name:a.name,displayName:a.displayName})),servers:c.map(a=>({name:a.name})),serverTools:d,flows:e.map(a=>({id:a.id,name:a.name}))},catalog:function(a){let b=[];for(let c of(b.push("AVAILABLE MODELS (reference by id or name):"),0===a.models.length&&b.push(" (none configured)"),a.models)){let a=c.displayName&&c.displayName!==c.name?`"${c.displayName}" (${c.name})`:c.name,d=c.description?` — ${c.description}`:"";b.push(` - id: ${c.id} — ${a}${d}`)}for(let c of(b.push("",'AVAILABLE MCP SERVERS (attach to process nodes via "servers"):'),0===a.servers.length&&b.push(" (none configured)"),a.servers)){if(!c.connected){b.push(` - ${c.name} (offline — tools unknown; may still be used)`);continue}b.push(` - ${c.name}:`);let a=(c.tools??[]).slice(0,20);for(let c of a){let a=c.description?` — ${c.description}`:"";b.push(` - ${c.name}${a}`)}let d=(c.tools?.length??0)-a.length;d>0&&b.push(` - …and ${d} more`)}for(let c of(b.push("",'EXISTING FLOWS (usable as subflow targets via "flow"):'),0===a.flows.length&&b.push(" (none)"),a.flows.slice(0,15))){let a=c.description?` — ${c.description}`:` — ${c.nodeCount} nodes`;b.push(` - "${c.name}"${a}`)}return a.flows.length>15&&b.push(` - …and ${a.flows.length-15} more`),b.join("\n")}(f),validatorServers:c.map(a=>({name:a.name,status:a.connected?"connected":"disconnected"}))}}let H=(0,i.h)("backend/services/flow/compileFlow");async function I(a,b={}){if(!a||"object"!=typeof a||Array.isArray(a))return{success:!1,error:"The spec must be a JSON object (a FlowSpec)",statusCode:400};let c=await G(),d=c.compile;if(b.updateFlowId){let a=d.flows??[];if(!a.some(a=>a.id===b.updateFlowId))return{success:!1,error:`No flow with id "${b.updateFlowId}" to update`,statusCode:404};d={...d,flows:a.filter(a=>a.id!==b.updateFlowId)}}let e=function(a,b={},c={}){let d=[],e=(a,b,c)=>d.push({severity:"error",code:a,message:b,nodeKey:c}),f=(a,b,c)=>d.push({severity:"warning",code:a,message:b,nodeKey:c}),g=b.models??[],h=new Set((b.servers??[]).map(a=>a.name)),i=b.serverTools??{},j=s(c.maxDepth,0,3,3),k=s(c.maxFlows,1,8,8),l=[],m=[...(b.flows??[]).map(a=>a.name)],n=[],o=0;var q=function a(d,q,C){let D=Array.isArray(d?.nodes)?d.nodes:[],E=Array.isArray(d?.edges)?d.edges:[],G=function(a,b){let c=(a??"").trim().replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"");c||(c="generated_flow");let d=new Set(b.map(a=>a.toLowerCase()));if(!d.has(c.toLowerCase()))return c;for(let a=2;;a++){let b=`${c}_${a}`;if(!d.has(b.toLowerCase()))return b}}(d?.name,m);m.push(G),o++;let H=(0,p.A)(),I=[...C,G],J=new Map,K=[],L=[];for(let c of D){let d=c?.key;if(!d||"string"!=typeof d){e("node-missing-key",'A node is missing its "key" — every node needs a unique key.');continue}if(J.has(d)){e("node-duplicate-key",`Duplicate node key "${d}" — keys must be unique; the later node was dropped.`,d);continue}let l=c.type;if("mcp"===l){e("mcp-node-not-allowed",`Node "${d}": do not emit "mcp" nodes — attach servers to a process node via its "servers" list instead.`,d);continue}if("start"!==l&&"process"!==l&&"finish"!==l&&"subflow"!==l&&"resource"!==l&&"signal"!==l){e("unknown-node-type",`Node "${d}" has unknown type "${String(l)}".`,d);continue}let m={},r="string"==typeof c.prompt?c.prompt:void 0;if("start"===l){let{text:a,stripped:b}=A(r??"");b&&f("pill-stripped",`Node "${d}": binding pills are not supported in generated prompts and were replaced with plain names.`,d),m.promptTemplate=a}else if("process"===l){let{text:a,stripped:b}=A(r??"");if(b&&f("pill-stripped",`Node "${d}": binding pills are not supported in generated prompts and were replaced with plain names.`,d),m.promptTemplate=a,c.model){let a=function(a,b){if(b.some(b=>b.id===a))return a;let c=a.toLowerCase(),d=b.find(a=>a.displayName?.toLowerCase()===c);if(d)return d.id;let e=b.find(a=>a.name?.toLowerCase()===c);return e?e.id:null}(c.model,g);a?m.boundModel=a:(m.boundModel=c.model,f("model-unresolved",`Node "${d}": model "${c.model}" does not match any configured model (by id, display name, or name).`,d))}void 0!==c.inputMode&&(x.has(c.inputMode)?(m.inputMode=c.inputMode,"isolated"===c.inputMode&&"string"==typeof c.isolatedPrompt&&(m.isolatedPrompt=c.isolatedPrompt)):f("invalid-input-mode",`Node "${d}": inputMode "${String(c.inputMode)}" is not valid (full-history | latest-message | isolated); omitted.`,d)),void 0!==c.outputMode&&(z.has(c.outputMode)?m.outputMode=c.outputMode:f("invalid-output-mode",`Node "${d}": outputMode "${String(c.outputMode)}" is not valid on a process node (full-conversation | latest-message); omitted.`,d)),void 0!==c.maxTurns&&("number"!=typeof c.maxTurns||Number.isNaN(c.maxTurns)?f("invalid-max-turns",`Node "${d}": maxTurns "${String(c.maxTurns)}" is not a number; omitted.`,d):m.maxTurns=s(c.maxTurns,1,1e3,1)),"boolean"==typeof c.excludeModelPrompt&&(m.excludeModelPrompt=c.excludeModelPrompt),"boolean"==typeof c.excludeStartNodePrompt&&(m.excludeStartNodePrompt=c.excludeStartNodePrompt),"boolean"==typeof c.excludeSystemPrompt&&(m.excludeSystemPrompt=c.excludeSystemPrompt),Array.isArray(c.allowedTools)&&(m.allowedTools=c.allowedTools.filter(a=>"string"==typeof a&&a)),"string"==typeof c.captureVariable&&c.captureVariable.trim()&&(m.captureVariable=c.captureVariable.trim()),"string"==typeof c.captureResource&&c.captureResource.trim()&&(m.captureResource=c.captureResource.trim()),"string"==typeof c.captureKv&&c.captureKv.trim()&&(m.captureKv=c.captureKv.trim())}else if("subflow"===l){if(function(c,d,g,h,i){let l=Array.isArray(c.parallelFlows)&&c.parallelFlows.length>0,m=Array.isArray(c.parallelSubflowSpecs)&&c.parallelSubflowSpecs.length>0,p="string"==typeof c.parallelFlowsVariable?c.parallelFlowsVariable.trim():"";if([void 0!==c.flow&&null!==c.flow?"flow":null,void 0!==c.subflowSpec&&null!==c.subflowSpec?"subflowSpec":null,l?"parallelFlows":null,m?"parallelSubflowSpecs":null,void 0!==c.generateSubflow&&null!==c.generateSubflow?"generateSubflow":null].filter(Boolean).length>1&&f("subflow-multiple-sources",`Node "${d}": a subflow node should have only one target source ("flow", "subflowSpec", "parallelFlows", "parallelSubflowSpecs", or "generateSubflow"); applying precedence flow > subflowSpec > parallelFlows > parallelSubflowSpecs > generateSubflow.`,d),!0===c.mapOverList){let a=void 0!==c.flow&&null!==c.flow||void 0!==c.subflowSpec&&null!==c.subflowSpec;(l||m)&&e("subflow-map-and-parallel",`Node "${d}": "mapOverList" runs a SINGLE child once per item and cannot be combined with "parallelFlows"/"parallelSubflowSpecs".`,d),a?(i.mapOverList=!0,void 0!==c.itemSplit&&("json-array"===c.itemSplit||"lines"===c.itemSplit?i.itemSplit=c.itemSplit:f("invalid-item-split",`Node "${d}": itemSplit "${String(c.itemSplit)}" is not valid (json-array | lines); using json-array.`,d)),!0===c.sequential&&(i.sequential=!0),F(c,i)):e("subflow-map-no-child",`Node "${d}": "mapOverList" needs a single child ("flow" or "subflowSpec") to run once per item.`,d)}if(p&&(!0===c.mapOverList?e("subflow-map-and-parallel-var",`Node "${d}": "parallelFlowsVariable" (dynamic fan-out) cannot be combined with "mapOverList".`,d):i.parallelSubflowIdsVar=p),c.flow){if(h.some(a=>a.toLowerCase()===c.flow.toLowerCase()))return e("subflow-cycle",`Node "${d}": flow "${c.flow}" refers to an ancestor flow, which would create a cycle.`,d);let a=B(c.flow,[...b.flows??[],...n]);return a?i.subflowId=a:e("subflow-unresolved",`Node "${d}": flow "${c.flow}" does not match any existing flow (by id or name).`,d)}if(c.subflowSpec){if(g+1>j)return e("subflow-too-deep",`Node "${d}": nested subflows may not go deeper than ${j} level(s); this inline subflow was not compiled.`,d);if(o>=k)return e("subflow-too-many",`Node "${d}": compiling this inline subflow would exceed the maximum of ${k} flows in one bundle; it was not compiled.`,d);let b=a(c.subflowSpec,g+1,h);return b?i.subflowId=b.id:e("subflow-child-empty",`Node "${d}": the inline "subflowSpec" produced no usable flow.`,d)}if(l){let a=[];for(let f of c.parallelFlows){if("string"!=typeof f||!f){e("parallel-flow-invalid",`Node "${d}": a "parallelFlows" entry is missing or not a string.`,d);continue}if(h.some(a=>a.toLowerCase()===f.toLowerCase())){e("subflow-cycle",`Node "${d}": parallel flow "${f}" refers to an ancestor flow, which would create a cycle.`,d);continue}let c=B(f,[...b.flows??[],...n]);c?a.includes(c)||a.push(c):e("parallel-flow-unresolved",`Node "${d}": parallel flow "${f}" does not match any existing flow (by id or name).`,d)}a.length>0?(i.parallelSubflowIds=a,F(c,i)):e("parallel-empty",`Node "${d}": "parallelFlows" resolved to no runnable lanes.`,d);return}if(m){let b=[];for(let f of c.parallelSubflowSpecs){if(!f||"object"!=typeof f){e("parallel-spec-invalid",`Node "${d}": a "parallelSubflowSpecs" entry is not a FlowSpec object.`,d);continue}if(g+1>j){e("subflow-too-deep",`Node "${d}": nested subflows may not go deeper than ${j} level(s); a parallel inline subflow was not compiled.`,d);continue}if(o>=k){e("subflow-too-many",`Node "${d}": compiling a parallel inline subflow would exceed the maximum of ${k} flows in one bundle; it was not compiled.`,d);continue}let c=a(f,g+1,h);c?b.push(c.id):e("subflow-child-empty",`Node "${d}": a "parallelSubflowSpecs" entry produced no usable flow.`,d)}b.length>0?(i.parallelSubflowIds=b,F(c,i)):e("parallel-empty",`Node "${d}": "parallelSubflowSpecs" produced no runnable lanes.`,d);return}p&&i.parallelSubflowIdsVar?F(c,i):void 0!==c.generateSubflow&&null!==c.generateSubflow?e("subflow-generate-unsupported",`Node "${d}": "generateSubflow" is only available through the AI flow generator. Use "subflowSpec" for deterministic nested authoring, or "flow" to reference an existing flow.`,d):e("subflow-missing-flow",`Node "${d}": subflow nodes need a "flow" (existing flow), a "subflowSpec" (inline child), "parallelFlows"/"parallelSubflowSpecs" (concurrent children), or "generateSubflow".`,d)}(c,d,q,I,m),void 0!==c.inputMode&&(x.has(c.inputMode)?m.inputMode=c.inputMode:f("invalid-input-mode",`Node "${d}": inputMode "${String(c.inputMode)}" is not valid (full-history | latest-message | isolated); omitted.`,d)),void 0!==c.outputMode&&(y.has(c.outputMode)?m.outputMode=c.outputMode:f("invalid-output-mode",`Node "${d}": outputMode "${String(c.outputMode)}" is not valid (steps | final-only); omitted.`,d)),void 0!==r){let{text:a,stripped:b}=A(r);b&&f("pill-stripped",`Node "${d}": binding pills are not supported in generated prompts and were replaced with plain names.`,d),m.promptTemplate=a}"boolean"==typeof c.allowCallerPrompt&&(m.allowCallerPrompt=c.allowCallerPrompt),"string"==typeof c.captureVariable&&c.captureVariable.trim()&&(m.captureVariable=c.captureVariable.trim()),"string"==typeof c.captureResource&&c.captureResource.trim()&&(m.captureResource=c.captureResource.trim()),"string"==typeof c.captureKv&&c.captureKv.trim()&&(m.captureKv=c.captureKv.trim())}else if("resource"===l){let a="string"==typeof c.runName?c.runName.trim():"",b="string"==typeof c.server?c.server.trim():"",e="string"==typeof c.uri?c.uri.trim():"";a?(m.scope="run",m.runName=a,(b||e)&&f("resource-both-bindings",`Node "${d}": a resource node is EITHER a run artifact ("runName") or a static MCP resource ("server"+"uri"); kept the run artifact.`,d)):(m.scope="mcp",b&&(m.boundServer=b),e&&(m.uri=e),b&&e?h.has(b)||f("server-unknown",`Node "${d}": MCP server "${b}" is not configured in FLUJO.`,d):f("resource-missing-binding",`Node "${d}": a static resource node needs both "server" and "uri" (or a "runName" for a run artifact).`,d))}else if("signal"===l){let a="string"==typeof c.topic?c.topic.trim():"";a?m.topic=a:f("signal-missing-topic",`Node "${d}": a signal node needs a "topic" to emit.`,d),"string"==typeof c.payloadTemplate&&c.payloadTemplate?m.payloadTemplate=c.payloadTemplate:void 0!==r&&(m.payloadTemplate=r)}let t={id:(0,p.A)(),type:l,position:{x:0,y:0},data:{label:c.label||`${l.charAt(0).toUpperCase()}${l.slice(1)} Node`,type:l,...c.description?{description:c.description}:{},properties:m}};if(J.set(d,t),K.push(t),"process"===l&&Array.isArray(c.servers)){let a=new Set;for(let b of c.servers){let c,e=b?.name;if(!e||"string"!=typeof e){f("server-missing-name",`Node "${d}": a server reference is missing its "name"; skipped.`,d);continue}if(a.has(e))continue;a.add(e),h.has(e)||f("server-unknown",`Node "${d}": MCP server "${e}" is not configured in FLUJO.`,d);let g=i[e];if(Array.isArray(b.tools)){if(c=b.tools.filter(a=>"string"==typeof a&&a),g){let a=c.filter(a=>!g.includes(a));a.length>0&&f("tool-unknown",`Node "${d}": server "${e}" does not report tool(s): ${a.join(", ")}.`,d)}}else c=g?[...g]:[];let j={id:(0,p.A)(),type:"mcp",position:{x:0,y:0},data:{label:e,type:"mcp",properties:{boundServer:e,enabledTools:c}}};K.push(j),L.push({processKey:d,mcpNode:j})}}else"process"!==l&&Array.isArray(c.servers)&&c.servers.length>0&&f("servers-on-non-process",`Node "${d}": only process nodes can have "servers"; ignored.`,d)}if(0===J.size)return e("no-usable-nodes","No usable nodes — the spec must contain at least a start node and one step."),null;let M=[],N=new Set;for(let a of E){let b,c=a?.from,d=a?.to,g=c?J.get(c):void 0,h=d?J.get(d):void 0;if(!g||!h){e("edge-unknown-node",`Edge "${String(c)}" -> "${String(d)}" references a node key that does not exist (or was dropped).`);continue}if(g===h){e("edge-self-loop",`Edge "${c}" -> "${d}": a node cannot connect to itself.`);continue}if("resource"===g.type||"resource"===h.type){if(("resource"!==g.type||"process"!==h.type)&&("process"!==g.type||"resource"!==h.type)){e("resource-edge-invalid",`Edge "${c}" -> "${d}": resource nodes connect only to process nodes.`);continue}a.condition&&f("resource-edge-condition",`Edge "${c}" -> "${d}": conditions do not apply to resource wiring; dropped.`),!0===a.bidirectional&&f("resource-edge-bidirectional",`Edge "${c}" -> "${d}": resource wiring is directional (read vs write); "bidirectional" was ignored — add the opposite edge explicitly if the step both reads and writes.`);let b=`${c}->${d}`;if(N.has(b)){f("edge-duplicate",`Edge "${c}" -> "${d}" appears more than once; kept the first.`);continue}N.add(b),M.push(function(a,b){let c="resource"===a.type?"resource-out":"process-right-resource",d="resource"===b.type?"resource-in":"process-left-resource";return{id:`${a.id}:${c}->${b.id}:${d}`,source:a.id,sourceHandle:c,target:b.id,targetHandle:d,type:"resourceEdge",data:{edgeType:"resource"},animated:!1,markerEnd:{...v},style:{...w}}}(g,h));continue}if("start"===h.type){e("edge-into-start",`Edge "${c}" -> "${d}": nothing may connect INTO a start node.`);continue}if("finish"===g.type){e("edge-out-of-finish",`Edge "${c}" -> "${d}": nothing may connect OUT OF a finish node.`);continue}let i=`${c}->${d}`;if(N.has(i)){f("edge-duplicate",`Edge "${c}" -> "${d}" appears more than once; kept the first.`);continue}N.add(i);let j=!0===a.bidirectional;j&&("start"===g.type||"finish"===h.type)&&(f("bidirectional-illegal",`Edge "${c}" -> "${d}" cannot be bidirectional; downgraded to one-way.`),j=!1);let k=a.condition;k&&"object"==typeof k&&("process"!==g.type?f("edge-condition-non-process",`Edge "${c}" -> "${d}" has a condition but leaves a ${g.type} node; conditions only route from process nodes and were dropped.`):(0,r.C)(k.kind)?"always"===k.kind?b={kind:"always",..."last-message"===k.target?{target:"last-message"}:{},...!0===k.negate?{negate:!0}:{}}:"string"!=typeof k.value||0===k.value.length?f("edge-condition-value",`Edge "${c}" -> "${d}" has a condition with no "value"; the condition was dropped.`):("regex"!==k.kind||(0,r.wM)(k.value)||f("edge-condition-regex",`Edge "${c}" -> "${d}" has a regex condition that does not compile; it is kept but will never match at runtime.`),b={kind:k.kind,value:k.value,..."last-message"===k.target?{target:"last-message"}:{},...!0===k.ignoreCase?{ignoreCase:!0}:{},...!0===k.negate?{negate:!0}:{}}):f("edge-condition-kind",`Edge "${c}" -> "${d}" has an unknown condition kind "${String(k.kind)}"; the condition was dropped.`)),M.push(function(a,b,c,d){let e=`${a.type}-bottom`,f=`${b.type}-top`;return{id:`${a.id}:${e}->${b.id}:${f}`,source:a.id,sourceHandle:e,target:b.id,targetHandle:f,type:"custom",data:{edgeType:"standard",...c?{bidirectional:!0}:{},...d?{condition:d}:{}},animated:!0}}(g,h,j,b))}for(let{processKey:a,mcpNode:b}of L){let c=J.get(a);M.push(function(a,b){let c="process-right-mcp",d="mcp-left";return{id:`${a.id}:${c}->${b.id}:${d}`,source:a.id,sourceHandle:c,target:b.id,targetHandle:d,type:"mcpEdge",data:{edgeType:"mcp"},animated:!1,markerEnd:{...t},markerStart:{...t},style:{...u}}}(c,b))}!function(a,b,c,d,e){let f=new Map;for(let a of c){let b=a.data?.edgeType;"mcp"!==b&&"resource"!==b&&(f.has(a.source)||f.set(a.source,[]),f.get(a.source).push(a.target))}let g=[...b.values()],h=g.filter(a=>"resource"===a.type),i=g.filter(a=>"resource"!==a.type),j=i.filter(a=>"start"===a.type),k=j.length>0?j:i.slice(0,1),l=new Map,m=k.map(a=>({id:a.id,depth:0}));for(let a of m)l.set(a.id,0);for(;m.length;){let{id:a,depth:b}=m.shift();for(let c of f.get(a)??[])l.has(c)||(l.set(c,b+1),m.push({id:c,depth:b+1}))}let n=0;for(let a of l.values())n=Math.max(n,a);for(let a of i)l.has(a.id)||l.set(a.id,n+1);let o=new Map;for(let[a,c]of b)o.set(c.id,a);let p=new Map;for(let a of i){let b=o.get(a.id),c=e&&b?e[b]:void 0;if(c&&"number"==typeof c.x&&"number"==typeof c.y){a.position={x:c.x,y:c.y};continue}let d=l.get(a.id),f=p.get(d)??0;p.set(d,f+1),a.position={x:250+280*f,y:150+170*d}}let q=new Map;for(let{processKey:a,mcpNode:c}of d){let d=b.get(a),e=q.get(a)??0;q.set(a,e+1),c.position={x:d.position.x+320,y:d.position.y+150*e}}let r=new Map(g.map(a=>[a.id,a])),s=new Map,t=0;for(let a of h){let b=o.get(a.id),d=e&&b?e[b]:void 0;if(d&&"number"==typeof d.x&&"number"==typeof d.y){a.position={x:d.x,y:d.y};continue}let f=c.find(b=>b.data?.edgeType==="resource"&&(b.source===a.id||b.target===a.id)),g=f?f.source===a.id?f.target:f.source:void 0,h=g?r.get(g):void 0;if(h){let b=s.get(h.id)??0;s.set(h.id,b+1),a.position={x:h.position.x-320,y:h.position.y+150*b}}else{let b=0;for(let a of i)b=Math.max(b,a.position.y);a.position={x:250+280*t,y:b+170},t++}}}(0,J,M,L,0===q?c.positions:void 0);let O={id:H,name:G,...d?.description?{description:d.description}:{},nodes:K,edges:M};return l.push(O),n.push({id:O.id,name:O.name}),O}(a,0,[]),C=l,D=d;let E=D.filter(a=>"error"===a.severity).length;return{flow:q,flows:C,issues:D,errorCount:E,warningCount:D.length-E};function F(a,b){void 0!==a.concurrencyLimit&&("number"!=typeof a.concurrencyLimit||Number.isNaN(a.concurrencyLimit)?f("invalid-concurrency-limit",`Node "${a.key}": concurrencyLimit "${String(a.concurrencyLimit)}" is not a number; using the runtime default.`,a.key):b.concurrencyLimit=Math.max(1,Math.floor(a.concurrencyLimit))),"string"==typeof a.joinSeparator&&(b.joinSeparator=a.joinSeparator),void 0!==a.errorStrategy&&("fail-fast"===a.errorStrategy||"collect-all"===a.errorStrategy?b.errorStrategy=a.errorStrategy:f("invalid-error-strategy",`Node "${a.key}": errorStrategy "${String(a.errorStrategy)}" is not valid (fail-fast | collect-all); using collect-all.`,a.key))}}(a,d);if(!e.flow)return{success:!1,error:"The spec could not be compiled into a flow",statusCode:422,issues:e.issues.map(a=>({severity:a.severity,code:a.code,message:a.message}))};b.updateFlowId&&(e.flow.id=b.updateFlowId);let f=e.flows.flatMap(a=>(0,C.nC)(a,{models:c.compile.models,servers:c.validatorServers,serverTools:c.compile.serverTools}).issues),g=function(a,b){let c=[...a.map(a=>({severity:a.severity,code:a.code,message:a.message})),...b.issues],d=c.filter(a=>"error"===a.severity).length;return{issues:c,errorCount:d,warningCount:c.length-d,isRunnable:0===d}}(e.issues,{issues:f,errorCount:0,warningCount:0,isRunnable:!0}),h=!1;if(b.save&&0===g.errorCount){for(let a of e.flows)await k.flowService.saveFlow(a);h=!0,H.info(`Compiled and saved ${e.flows.length} flow(s); root "${e.flow.name}" (${e.flow.id})`)}else b.save&&H.info(`Compiled flow "${e.flow.name}" has ${g.errorCount} error(s); NOT saved`);return{success:!0,flow:e.flow,flows:e.flows,validation:g,saved:h}}var J=c(44561),K=c(79111),L=c(34115);let M=(0,i.h)("backend/execution/flow/loadConversationState");async function N(a){try{(0,K.ln)(a)}catch{M.warn("Rejected unsafe conversationId on load",{conversationId:a});return}if(J.FlowExecutor.conversationStates.has(a))return M.debug("Loaded state from memory",{conversationId:a}),J.FlowExecutor.conversationStates.get(a);let b=`conversations/${a}`;try{let c=await (0,K.YM)(b,void 0);if(c)return M.debug("Loaded state from storage",{conversationId:a}),await (0,L.jM)(c),J.FlowExecutor.conversationStates.set(a,c),c}catch(b){M.warn("Error loading conversation state from storage",{conversationId:a,error:b})}}var O=c(96249),P=c(63129),Q=c(51172);let R=`A FlowSpec is a JSON object describing a FLUJO flow semantically — node keys and edges, no coordinates, no ids, no layout:
2
2
  {
3
3
  "name": "short_flow_name", // letters/digits/_/- only
4
4
  "description": "what the flow does",
@@ -19,6 +19,7 @@ NODE TYPES:
19
19
  "allowedTools": ["tool_a"], // optional; step-level tool allowlist (independent of servers[].tools)
20
20
  "captureVariable": "NAME", // optional; save this step's output into a run variable other steps inject with \${var:NAME}
21
21
  "captureResource": "NAME", // optional; ALSO save this step's output as a tracked run resource other steps inject with \${res:NAME} (see rule 9b)
22
+ "captureKv": "NAME", // optional; ALSO save this step's output to a PERSISTENT cross-run key other steps inject with \${kv:NAME} (see rule 9d)
22
23
  "excludeModelPrompt": true|false, // optional; drop the model's base prompt
23
24
  "excludeStartNodePrompt": true|false, // optional; drop the start node's prompt for this step
24
25
  "excludeSystemPrompt": true|false } // optional; drop the workflow/handoff guidance block
@@ -26,7 +27,8 @@ NODE TYPES:
26
27
  "flow": "<existing flow name or id>", // reference an EXISTING flow, OR:
27
28
  "subflowSpec": { ...a nested FlowSpec... }, // define a brand-new child flow INLINE (compiled into its own flow and wired automatically), OR fan out concurrently:
28
29
  "parallelFlows": ["flow_a", "flow_b"], // run several EXISTING child flows CONCURRENTLY, same input to each, outputs joined; OR:
29
- "parallelSubflowSpecs": [ { ...FlowSpec... } ], // run several INLINE child flows concurrently
30
+ "parallelSubflowSpecs": [ { ...FlowSpec... } ], // run several INLINE child flows concurrently; OR:
31
+ "parallelFlowsVariable": "NAME", // DYNAMIC fan-out (rule 7b): pick the target flows AT RUNTIME from run variable \${var:NAME} (a JSON array of flow ids/names, or newline list); mutually exclusive with mapOverList
30
32
  "mapOverList": true | false, // optional; run the SINGLE child ("flow"/"subflowSpec") ONCE PER ITEM parsed from the input; mutually exclusive with parallelFlows/parallelSubflowSpecs
31
33
  "itemSplit": "json-array" | "lines", // optional (mapOverList only), how to split the input into items, default json-array
32
34
  "sequential": true | false, // optional (mapOverList only), run items one at a time in order instead of concurrently, default false
@@ -37,6 +39,7 @@ NODE TYPES:
37
39
  "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)
38
40
  "captureVariable": "NAME", // optional; save the subflow's output into a run variable other steps inject with \${var:NAME}
39
41
  "captureResource": "NAME", // optional; ALSO save the subflow's output as a tracked run resource (\${res:NAME}, rule 9b)
42
+ "captureKv": "NAME", // optional; ALSO save the subflow's output to a PERSISTENT cross-run key (\${kv:NAME}, rule 9d)
40
43
  "outputMode": "steps" | "final-only" }
41
44
  - { "key": "...", "type": "finish", "label": "..." }
42
45
  - { "key": "...", "type": "resource", "label": "...", // OPTIONAL/advanced (rule 9c): a data artifact shown in the graph
@@ -56,15 +59,17 @@ RULES:
56
59
  5. 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).
57
60
  5b. Deterministic routing: give a process node's outgoing edges a "condition" to route WITHOUT the model — the engine takes the first outgoing edge whose predicate matches the last message (default the step's own last assistant message), and a bare (condition-less) edge is the fallback. Use this for reliable data-driven branches (e.g. output contains "FAIL" -> fix step, else -> publish) instead of relying on a small model to emit a handoff. Only process-node edges may carry a condition. Without any condition on a node, that node keeps model-decided handoff (rule 5). If the model still calls a handoff tool, that wins over the condition.
58
61
  6. 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.
59
- 7. A subflow node may instead fan out to SEVERAL child flows CONCURRENTLY via "parallelFlows" (existing flows) or "parallelSubflowSpecs" (inline). The same input is sent to every lane and their outputs are joined. This is about multiple CHILDREN, not successors — the single-outgoing-edge rule (rule 6) still holds. Prefer "parallelFlows" for large fan-outs.
62
+ 7. A subflow node may instead fan out to SEVERAL child flows CONCURRENTLY via "parallelFlows" (existing flows) or "parallelSubflowSpecs" (inline). These are STATIC (fixed at author time): the same input is sent to every lane and their outputs are joined. This is about multiple CHILDREN, not successors — the single-outgoing-edge rule (rule 6) still holds. Prefer "parallelFlows" for large fan-outs.
63
+ 7b. For DYNAMIC fan-out — when the set of target flows should be decided AT RUNTIME by an earlier step — use "parallelFlowsVariable": "NAME". An upstream process/subflow node captures a JSON array of flow ids/names (or a newline list) into run variable NAME via "captureVariable": "NAME"; this subflow node then fans out over exactly those flows. Unknown ids and a self-reference are dropped, the count is capped, and a non-empty resolution overrides any static "parallelFlows" (empty falls back to it). Mutually exclusive with "mapOverList". Still one outgoing edge (rule 6).
60
64
  8. A subflow node may instead run its SINGLE child flow ONCE PER ITEM via "mapOverList": true. The input is split into items by "itemSplit" ("json-array" default, or "lines"), each item is sent to its own child run, and the per-item outputs are joined (same pool/tuning as parallel). Use "sequential": true to run items in order. Mutually exclusive with "parallelFlows"/"parallelSubflowSpecs".
61
65
  9. Named variables (scratchpad): a step can save its output with "captureVariable": "NAME" (process or subflow) and any LATER step injects it with \${var:NAME} inside its "prompt" / "isolatedPrompt" / subflow prompt. This survives "latest-message"/"isolated" scoping, unlike conversation history — use it to carry a todo list, a file path, a diff, or a captured result across steps that don't share history. \${var:NAME} is run-scoped and plaintext; it is DISTINCT from \${global:VAR} (configured secrets/config, resolved only for tool args). Capture a subflow's output on the PARENT subflow node — a variable set inside a child flow is not visible to the parent.
62
66
  9b. Run resources (tracked data): "captureResource": "NAME" (process or subflow) ALSO saves the step's output as a run-scoped RESOURCE — an addressable artifact (flujo://run/... URI) with lineage (which step produced it, which steps read it), readable via the built-in "flujo" MCP server. A later step injects it with \${res:NAME} exactly like \${var:NAME}. Prefer "captureVariable" for short strings; use "captureResource" when the output is a large document/report/dataset worth tracking, or when other tools/agents should be able to read it back. Large or binary MCP tool results (screenshots, files) are auto-captured as run resources without any spec field.
63
67
  9c. Resource nodes are OPTIONAL/advanced — most flows should not use them; prefer rule 9b's captureResource/\${res:NAME}. Emit one only when the data artifact itself should be VISIBLE in the graph: an edge resource→process means the step READS the artifact (its contents are injected into the step's context); process→resource means the step's output is SAVED to it (run artifacts only, equivalent to captureResource with the node's runName). Resource edges are data wiring, not flow control — they never carry conditions and don't count as a step's successor.
64
- 10. Keep flows minimal — only the steps the task needs. Write clear, specific prompts and labels; fill "description" on process nodes.`;var Q=c(12700),R=c(79861);let S=(0,i.h)("backend/services/mcp/quality/cache"),T="mcp-quality-cache";class U{constructor(a=Date.now()){this.entries={},this.dirty=!1,this.now=a}async load(){try{let a=await (0,J.YM)(T,{entries:{}});this.entries=a?.entries&&"object"==typeof a.entries?a.entries:{}}catch(a){S.warn("Failed to load quality cache; starting empty",a),this.entries={}}}get(a,b){let c=this.entries[`${a}::${b}`];if(c&&!(this.now-c.at>864e5))return c.signal}set(a,b,c){this.entries[`${a}::${b}`]={at:this.now,signal:c},this.dirty=!0}async flush(){let a=!1;for(let[b,c]of Object.entries(this.entries))this.now-c.at>864e5&&(delete this.entries[b],a=!0);if(this.dirty||a)try{await (0,J.VH)(T,{entries:this.entries})}catch(a){S.warn("Failed to persist quality cache",a)}}}function V(a){return!Number.isFinite(a)||a<0?0:a>1?1:a}function W(a,b){return!Number.isFinite(a)||a<=0?0:!Number.isFinite(b)||b<=1?+(a>0):V(Math.log10(a+1)/Math.log10(b+1))}let X=(0,i.h)("backend/services/mcp/quality/providers/githubStars"),Y="github",Z=new Map;function $(){return d??(process.env.GITHUB_TOKEN||void 0)}function _(a){let b,c=a.server.repository;if(c?.source&&"github"!==c.source.toLowerCase())return null;var d=c?.url;if(!d)return null;try{b=new URL(d.replace(/^git\+/,""))}catch{return null}if(!/(^|\.)github\.com$/i.test(b.hostname))return null;let e=b.pathname.replace(/\.git$/i,"").split("/").filter(Boolean);return e.length<2?null:`${e[0]}/${e[1]}`.toLowerCase()}async function aa(a,b){let c=new AbortController,d=()=>c.abort();b.addEventListener("abort",d,{once:!0});let e=setTimeout(()=>c.abort(),6e3);try{return await fetch(`https://api.github.com${a}`,{headers:function(){let a={Accept:"application/vnd.github+json","User-Agent":"FLUJO-mcp-quality","X-GitHub-Api-Version":"2022-11-28"},b=$();return b&&(a.Authorization=`Bearer ${b}`),a}(),signal:c.signal,cache:"no-store"})}catch(b){return X.warn(`GitHub request failed (${a})`,b instanceof Error?b.message:b),null}finally{clearTimeout(e),b.removeEventListener("abort",d)}}function ab(a){return(403===a.status||429===a.status)&&"0"===a.headers.get("x-ratelimit-remaining")}let ac=(0,i.h)("backend/services/mcp/quality/providers/npmDownloads"),ad="npm-downloads",ae=new Map;function af(a){for(let b of a.server.packages??[])if("npm"===b.registryType&&b.identifier)return b.identifier;return null}function ag(a){return a.startsWith("@")}async function ah(a,b){let c=new AbortController,d=()=>c.abort();b.addEventListener("abort",d,{once:!0});let e=setTimeout(()=>c.abort(),6e3);try{return await fetch(`https://api.npmjs.org${a}`,{signal:c.signal,cache:"no-store"})}catch(b){return ac.warn(`npm request failed (${a})`,b instanceof Error?b.message:b),null}finally{clearTimeout(e),b.removeEventListener("abort",d)}}let ai="registry-status",aj=[{id:Y,label:"GitHub Stars & Activity",defaultWeight:.5,isApplicable:a=>null!==_(a),cacheKey:a=>_(a),async prefetch(a,b,c){let d=`${a??""} mcp`.trim(),e=`/search/repositories?q=${encodeURIComponent(d)}&sort=stars&order=desc&per_page=50`,f=await aa(e,c);if(f&&f.ok)try{for(let a of(await f.json()).items??[])a.full_name&&Z.set(a.full_name.toLowerCase(),{stars:"number"==typeof a.stargazers_count?a.stargazers_count:0,pushedAtMs:a.pushed_at?Date.parse(a.pushed_at):null})}catch(a){X.warn("Failed to parse GitHub search response",a)}else if(f&&ab(f))return void X.warn("GitHub search rate-limited; ranking will degrade to other providers");if(!$())return;let g=3;for(let a of b){if(g<=0)break;let b=_(a);if(!b||Z.has(b))continue;g-=1;let d=await aa(`/repos/${b}`,c);if(d){if(ab(d))break;if(d.ok)try{let a=await d.json();Z.set(b,{stars:"number"==typeof a.stargazers_count?a.stargazers_count:0,pushedAtMs:a.pushed_at?Date.parse(a.pushed_at):null})}catch{}}}},async fetch(a){let b=_(a);if(!b)return null;let c=Z.get(b);if(!c)return null;let d=W(c.stars,5e4),e=function(a,b,c=30,d=730){if(!a||!Number.isFinite(a))return 0;let e=(b-a)/864e5;return e<=c?1:e>=d?0:V(1-(e-c)/(d-c))}(c.pushedAtMs,Date.now());return{providerId:Y,score:V(.7*d+.3*e),evidence:{repo:b,stars:c.stars,...c.pushedAtMs?{pushedAt:new Date(c.pushedAtMs).toISOString()}:{},starsScore:d,recencyScore:e}}}},{id:ad,label:"npm Weekly Downloads",defaultWeight:.35,isApplicable:a=>null!==af(a),cacheKey:a=>af(a),async prefetch(a,b,c){let d=b.map(af).filter(a=>!!a&&!ae.has(a)),e=d.filter(a=>!ag(a)),f=d.filter(ag);for(let a=0;a<e.length;a+=100){let b=e.slice(a,a+100),d=await ah(`/downloads/point/last-week/${b.join(",")}`,c);if(d&&d.ok)try{let a=await d.json();if(1===b.length)"number"==typeof a.downloads&&ae.set(b[0],a.downloads);else for(let c of b){let b=a[c];ae.set(c,b&&"number"==typeof b.downloads?b.downloads:0)}}catch(a){ac.warn("Failed to parse npm bulk downloads response",a)}}for(let a of f){let b=await ah(`/downloads/point/last-week/${a}`,c);if(b&&b.ok)try{let c=await b.json();"number"==typeof c.downloads&&ae.set(a,c.downloads)}catch{}}},async fetch(a){let b=af(a);if(!b)return null;let c=ae.get(b);return void 0===c?null:{providerId:ad,score:W(c,1e6),evidence:{package:b,weeklyDownloads:c}}}},{id:ai,label:"Registry Status",defaultWeight:.15,isApplicable:a=>!0,cacheKey:()=>null,fetch:async a=>({providerId:ai,score:+("active"===a.verificationStatus),evidence:{status:a.verificationStatus}})}];var ak=c(89392);let al=(0,i.h)("backend/services/mcp/quality/settings");function am(){return{providers:aj.map(a=>({id:a.id,enabled:!0,weight:a.defaultWeight})),minScore:0,worksGate:!0}}async function an(){try{let a=await (0,J.YM)(ak.Z.MCP_QUALITY_SETTINGS,am());return function(a){var b,c;let d=am(),e=a??{},f=new Map;if(Array.isArray(e.providers))for(let a of e.providers)a&&"string"==typeof a.id&&f.set(a.id,a);return{providers:d.providers.map(a=>{let b=f.get(a.id);return{id:a.id,enabled:"boolean"==typeof b?.enabled?b.enabled:a.enabled,weight:"number"==typeof b?.weight&&Number.isFinite(b.weight)&&b.weight>=0?b.weight:a.weight}}),minScore:(b=e.minScore,c=d.minScore,"number"==typeof b&&Number.isFinite(b)?Math.min(1,Math.max(0,b)):c),worksGate:"boolean"==typeof e.worksGate?e.worksGate:d.worksGate,..."string"==typeof e.githubToken&&e.githubToken.length>0?{githubToken:e.githubToken}:{}}}(a)}catch(a){return al.warn("Failed to load mcpQuality settings; using defaults",a),am()}}let ao=(0,i.h)("backend/services/mcp/quality/orchestrator");async function ap(a,b){let c=new AbortController,d=setTimeout(()=>c.abort(),b);try{return await a(c.signal)}finally{clearTimeout(d)}}async function aq(a,b,c={}){let e=c.topN??10;try{var f;let g=c.settings??await an(),h=aj.filter(a=>(function(a,b){let c=a.providers.find(a=>a.id===b);return!!c?.enabled})(g,a.id));if(0===h.length)return b.map(a=>({candidate:a,score:0,signals:[]}));d=(f=g.githubToken)&&f.length>0?f:void 0;let i=b.slice(0,e),j=b.slice(e),k=new U(c.now??Date.now());await k.load();let l=i.map(()=>[]);for(let b of h){let c=i.map((a,b)=>({c:a,i:b})).filter(({c:a})=>b.isApplicable(a)),d=[],e=[];for(let a of c){let c=b.cacheKey(a.c);if(c){let d=k.get(b.id,c);if(d){e.push({i:a.i,signal:d});continue}}d.push(a)}if(b.prefetch&&d.length>0)try{await ap(c=>b.prefetch(a,d.map(a=>a.c),c),12e3)}catch(a){ao.warn(`Provider "${b.id}" prefetch failed; degrading`,a)}for(let{c:a,i:c}of d)try{let d=await ap(c=>b.fetch(a,c),2e3);if(d){l[c].push(d);let e=b.cacheKey(a);e&&k.set(b.id,e,d)}}catch(c){ao.warn(`Provider "${b.id}" fetch failed for "${a.registryName}"`,c)}for(let{i:a,signal:b}of e)l[a].push(b)}await k.flush();let m=i.map((a,b)=>{let c=l[b],d=new Map(c.map(a=>[a.providerId,a])),e=h.filter(b=>b.isApplicable(a)).map(a=>({providerId:a.id,weight:function(a,b){let c=a.providers.find(a=>a.id===b);return c&&c.enabled?c.weight:0}(g,a.id),score:d.get(a.id)?.score??0})),{score:f}=function(a){let b=0,c=0;for(let d of a){let a=Number.isFinite(d.weight)&&d.weight>0?d.weight:0,e=V(d.score);b+=a,c+=a*e}return{score:b>0?c/b:0,breakdown:a}}(e);return{candidate:a,score:f,signals:c}}).map((a,b)=>({s:a,idx:b})).sort((a,b)=>b.s.score-a.s.score||a.idx-b.idx).map(a=>a.s),n=j.map(a=>({candidate:a,score:0,signals:[]}));return[...m,...n]}catch(a){return ao.warn("enrichAndRank failed; returning unranked candidates",a),b.map(a=>({candidate:a,score:0,signals:[]}))}}let ar=(0,i.h)("backend/services/mcp/registryInstall"),as="/v0.1/servers";function at(a){return{registryName:a.server.name,server:a.server,verificationStatus:(0,R.vf)(a)}}async function au(a,b=8){let c=await av(a,b);return(await aq(a,c.map(at))).map(a=>(function(a,b){let c=(0,R.AH)(a),d=c[0];return{name:a.name,...a.title?{title:a.title}:{},...a.description?{description:a.description}:{},installable:c.length>0,requiredEnv:d?(0,R.jg)(d):[],...b?{quality:function(a){let b=b=>a.signals.find(a=>a.providerId===b)?.evidence,c=b(Y),d=b(ad),e=b(ai);return{score:a.score,..."number"==typeof c?.stars?{stars:c.stars}:{},..."number"==typeof d?.weeklyDownloads?{weeklyDownloads:d.weeklyDownloads}:{},..."string"==typeof e?.status?{status:e.status}:{}}}(b)}:{}}})(a.candidate.server,a))}async function av(a,b){let c=new URL(Q.jD+as);c.searchParams.set("version","latest"),c.searchParams.set("limit",String(Math.min(Math.max(b,1),30))),a&&c.searchParams.set("search",a);let d=await (0,Q.Ws)(c,15e3);return Array.isArray(d?.servers)?d.servers:[]}async function aw(a){let b=new URL(Q.jD+as);b.searchParams.set("version","latest"),b.searchParams.set("limit","10"),b.searchParams.set("search",a);let c=await (0,Q.Ws)(b,15e3),d=Array.isArray(c?.servers)?c.servers:[];return d.find(b=>b.server?.name===a)??d[0]??null}async function ax(a,b,c){let d;if(!a||"string"!=typeof a)return{installed:!1,error:"A registry server name is required"};try{d=await aw(a)}catch(a){return{installed:!1,error:`Registry lookup failed: ${a instanceof Error?a.message:String(a)}`}}let e=d?.server??null;if(!e)return{installed:!1,error:`No registry entry found for "${a}"`};let f=(0,R.AH)(e)[0];if(!f)return{installed:!1,error:`"${e.name}" has no install method FLUJO supports (stdio package or HTTP remote)`};let g=(0,R.vf)(d),h=(0,R.O$)(a,e,f,g);if(c?.resolveOnly)return{installed:!1,serverName:h.serverName,plan:h};let i=(0,R.jg)(f,b);if(i.length>0)return{installed:!1,needsEnv:i,plan:h,error:`"${e.name}" requires values for: ${i.join(", ")}`};let j=(0,R.cy)((0,R.Yr)(e,f),b),k=j.name,l=await C.mcpService.loadServerConfigs();if(Array.isArray(l)&&l.some(a=>a.name===k)){ar.info(`installRegistryServer: "${k}" already configured; reusing`);let{tools:a,error:b}=await C.mcpService.listServerTools(k);return{installed:!0,alreadyExisted:!0,serverName:k,plan:h,tools:(a??[]).map(a=>({name:a.name,...a.description?{description:a.description}:{}})),...b?{error:b}:{}}}ar.info(`installRegistryServer: installing "${e.name}" as "${k}" (${f.kind})`);let m=await C.mcpService.updateServerConfig(k,j);if(!Array.isArray(m)&&m&&"success"in m&&!1===m.success)return{installed:!1,error:`Saving the server failed: ${m.error??"unknown error"}`};let{tools:n,error:o}=await C.mcpService.listServerTools(k),p=(n??[]).map(a=>({name:a.name,...a.description?{description:a.description}:{}}));if((c?.worksGate??(await an()).worksGate)&&0===p.length){ar.warn(`installRegistryServer: "${k}" exposed no tools${o?` (${o})`:""}; rolling back (works-gate)`);try{await C.mcpService.deleteServerConfig(k)}catch(a){ar.error(`installRegistryServer: rollback of "${k}" failed`,a)}return{installed:!1,worksGateRejected:!0,serverName:k,plan:h,error:o?`"${e.name}" failed to start: ${o}`:`"${e.name}" connected but exposed no tools — rejected by the works-gate. Try a different server.`}}return{installed:!0,serverName:k,plan:h,tools:p,...o?{error:o}:{}}}async function ay(a,b,c){let d;if(!a||"string"!=typeof a)return{installed:!1,error:"A capability search query is required"};try{d=await av(a,10)}catch(a){return{installed:!1,error:`Registry lookup failed: ${a instanceof Error?a.message:String(a)}`}}let e=await aq(a,d.map(at)),f=await an(),g=c?.minScore??f.minScore,h=c?.maxAttempts??3,i=[],j=0;for(let a of e){let d=a.candidate.registryName;if(a.score<g){i.push({name:d,score:a.score,reason:`below minScore ${g}`});break}if(0===(0,R.AH)(a.candidate.server).length){i.push({name:d,score:a.score,reason:"no supported install method"});continue}if(j>=h)break;j+=1;let e=await ax(d,b,{worksGate:!0});if(c?.onAttempt)try{await c.onAttempt(e.plan,e)}catch(a){ar.error("installBestForCapability: onAttempt hook failed",a)}if(e.installed)return{...e,attempts:i};let f=e.needsEnv?.length?`needs env: ${e.needsEnv.join(", ")}`:e.worksGateRejected?"works-gate rejected (no tools / failed to start)":e.error??"install failed";i.push({name:d,score:a.score,reason:f})}return{installed:!1,attempts:i,error:`No working server found for "${a}" among the top ${j} installable candidate(s).`}}let az={requireConsent:!0,namespaceAllowlist:[],trustBrainStem:!0};function aA(a){let{caller:b,settings:c,registryName:d,allowInstall:e}=a;if("generator"===b)return!0===e?{allowed:!0,reason:"generator-allowinstall",message:"Approved by the per-generation allowInstall opt-in."}:{allowed:!1,reason:"generator-not-allowed",message:"Installing is not allowed in this generation (allowInstall is off)."};if("authoring-tool"===b&&c.trustBrainStem)return{allowed:!0,reason:"brainstem-trusted",message:"Approved: the /mcp-flows authoring tool is trusted (mcpAutoInstall.trustBrainStem)."};if(!c.requireConsent)return{allowed:!0,reason:"consent-disabled",message:"Approved: consent is not required (mcpAutoInstall.requireConsent is off)."};let f=function(a){if("string"!=typeof a)return"";let b=a.indexOf("/");return b>0?a.slice(0,b):""}(d);return""!==f&&c.namespaceAllowlist.includes(f)?{allowed:!0,reason:"namespace-allowlisted",message:`Approved: namespace "${f}" is allowlisted.`}:{allowed:!1,reason:"consent-required",message:"Consent required: review the exact command and arguments, then approve this install (SEP-1024)."}}function aB(a,b,c,d,e){return{at:new Date().toISOString(),caller:b,registryName:a.registryName,resolvedName:a.resolvedName,serverName:a.serverName,transport:a.transport,...a.command?{command:a.command}:{},...a.args?{args:a.args}:{},...a.serverUrl?{serverUrl:a.serverUrl}:{},requiredEnvNames:a.requiredEnvNames,verificationStatus:a.verificationStatus,consent:{allowed:c.allowed,reason:c.reason},installed:d,...e?{error:e}:{}}}let aC=(0,i.h)("backend/services/mcp/autoInstall");async function aD(){try{let a=await (0,J.YM)(ak.Z.MCP_AUTO_INSTALL_SETTINGS,az)??{};return{requireConsent:"boolean"==typeof a.requireConsent?a.requireConsent:az.requireConsent,namespaceAllowlist:Array.isArray(a.namespaceAllowlist)?a.namespaceAllowlist.filter(a=>"string"==typeof a&&a.length>0):[],trustBrainStem:"boolean"==typeof a.trustBrainStem?a.trustBrainStem:az.trustBrainStem}}catch(a){return aC.warn("Failed to load mcpAutoInstall settings; using safe defaults",a),{...az}}}let aE="mcp-install-audit",aF=Promise.resolve();async function aG(){try{return await (0,J.YM)(aE,[])}catch(a){return aC.error("Failed to load MCP install audit log",a),[]}}async function aH(a){let b=aF.catch(()=>{}).then(async()=>{let b=await aG();b.push(a);let c=b.slice(-300);await (0,J.VH)(aE,c)}).catch(a=>{aC.error("Failed to append MCP install audit entry",a)});aF=b,await b}let aI=(0,i.h)("backend/services/mcp/flowAuthoringTools"),aJ=["list_flow_building_blocks","validate_flow_spec","create_flow","search_mcp_marketplace","install_mcp_server","install_best_mcp_server"];function aK(){return{type:"object",properties:{spec:{type:"object",description:"The FlowSpec object (see the tool description for the format)."}},required:["spec"]}}function aL(a,b=!1){return{content:[{type:"text",text:JSON.stringify(a,null,2)}],...b?{isError:!0}:{}}}async function aM(a,b){try{if("list_flow_building_blocks"===a){let a=await F();return aL(a.blocks)}if("search_mcp_marketplace"===a){let a="string"==typeof b?.query?b.query:"",c=await au(a);return aL(c)}if("install_mcp_server"===a){let a="string"==typeof b?.name?b.name:"",c=b?.env&&"object"==typeof b.env&&!Array.isArray(b.env)?b.env:void 0,d=await ax(a,c,{resolveOnly:!0});if(!d.plan)return aL(d,!0);let e=await aD(),f=aA({caller:"authoring-tool",settings:e,registryName:a}),g=(0,R.nO)(d.plan.verificationStatus)?void 0:`Unverified / self-asserted registry entry (status: ${d.plan.verificationStatus}). Registry entries are publisher-asserted — review the command before approving.`;if(await aH(aB(d.plan,"authoring-tool",f,!1)),!f.allowed)return aL({installed:!1,consentRequired:!0,message:f.message,plan:d.plan,...g?{verificationWarning:g}:{}});let h=await ax(a,c);return await aH(aB(h.plan??d.plan,"authoring-tool",f,h.installed,h.error)),aL({...h,...g?{verificationWarning:g}:{}},!h.installed)}if("install_best_mcp_server"===a){let a="string"==typeof b?.capability?b.capability:"",c=b?.env&&"object"==typeof b.env&&!Array.isArray(b.env)?b.env:void 0;if(!a)return aL({error:'Provide a "capability" search term.'},!0);let d=await aD(),e=aA({caller:"authoring-tool",settings:d,registryName:a});if(!e.allowed){let b=(await au(a)).find(a=>a.installable),d=b?await ax(b.name,c,{resolveOnly:!0}):null;return d?.plan&&await aH(aB(d.plan,"authoring-tool",e,!1)),aL({installed:!1,consentRequired:!0,message:e.message,...d?.plan?{plan:d.plan}:{}})}let f=await ay(a,c,{onAttempt:async(a,b)=>{a&&await aH(aB(a,"authoring-tool",e,b.installed,b.error))}}),g=f.installed&&!(0,R.nO)(f.plan?.verificationStatus)?`Installed an unverified / self-asserted registry entry (status: ${f.plan?.verificationStatus}).`:void 0;return aL({...f,...g?{verificationWarning:g}:{}},!f.installed)}if("validate_flow_spec"===a||"create_flow"===a){let c=function(a){let b=a?.spec;if("string"==typeof b)try{return JSON.parse(b)}catch{return null}return b??null}(b);if(!c)return aL({error:'Provide a "spec" argument: a FlowSpec object (or a JSON string of one).'},!0);let d=await H(c,{save:"create_flow"===a});if(!d.success)return aL({error:d.error,issues:d.issues??[]},!0);let e=d.flows.length,f=e>1?` (plus ${e-1} nested subflow flow(s))`:"",g={flowId:d.flow.id,flowName:d.flow.name,nodeCount:d.flow.nodes.length,edgeCount:d.flow.edges.length,...e>1?{flows:d.flows.map(a=>({id:a.id,name:a.name}))}:{},validation:d.validation,..."create_flow"===a?{saved:d.saved,...d.saved?{note:`Flow "${d.flow.name}"${f} was created. It is callable as a tool on this MCP server (after a fresh tools/list) and as model "flow-${d.flow.name}" on the OpenAI-compatible endpoint.`}:{note:"NOT saved: validation found errors. Fix the issues and call create_flow again."}}:{}};return aL(g,"create_flow"===a&&!d.saved)}return aL({error:`Unknown authoring tool: ${a}`},!0)}catch(b){return aI.error("authoringCallTool failed",{toolName:a,err:b}),aL({error:`Authoring tool failed: ${b instanceof Error?b.message:String(b)}`},!0)}}var aN=c(92018);let aO=(0,i.h)("backend/services/mcp/internalTools");function aP(a,b=!1){return{content:[{type:"text",text:"string"==typeof a?a:JSON.stringify(a,null,2)}],...b?{isError:!0}:{}}}function aQ(){return[{name:"list_flow_building_blocks",description:'List everything a FlowSpec may reference in this FLUJO instance: configured models (bind to process steps), MCP servers and their tools (attach via "servers"), and existing flows (usable as subflow targets). Call this before authoring a spec.',inputSchema:{type:"object",properties:{}}},{name:"validate_flow_spec",description:`Compile and validate a FlowSpec WITHOUT saving. Returns the compiled flow's validation result (errors block saving; warnings are advisory) so you can iterate until clean, then call create_flow.
68
+ 9d. Persistent state (cross-run): "captureKv": "NAME" (process or subflow) saves the step's output to a PERSISTENT key-value store that SURVIVES ACROSS RUNS, injected by any step with \${kv:NAME}. Unlike \${var:} / \${res:} (discarded when the run ends), \${kv:} is what a long-lived SCHEDULED flow uses to carry a loop counter, a pagination cursor, a last-seen id, or a flag to its NEXT run. By default a key lives on the flow's FOLDER board (flows in the same folder share it); prefix the name to change scope: "flow/NAME" (this flow only) or "global/NAME" (whole instance). Plaintext, never secrets (distinct from \${global:VAR}). A model can also read/update a key mid-run via the built-in "flujo" server's kv_get / kv_set tools.
69
+ 10. Keep flows minimal — only the steps the task needs. Write clear, specific prompts and labels; fill "description" on process nodes.`;var S=c(12700),T=c(79861);let U=(0,i.h)("backend/services/mcp/quality/cache"),V="mcp-quality-cache";class W{constructor(a=Date.now()){this.entries={},this.dirty=!1,this.now=a}async load(){try{let a=await (0,K.YM)(V,{entries:{}});this.entries=a?.entries&&"object"==typeof a.entries?a.entries:{}}catch(a){U.warn("Failed to load quality cache; starting empty",a),this.entries={}}}get(a,b){let c=this.entries[`${a}::${b}`];if(c&&!(this.now-c.at>864e5))return c.signal}set(a,b,c){this.entries[`${a}::${b}`]={at:this.now,signal:c},this.dirty=!0}async flush(){let a=!1;for(let[b,c]of Object.entries(this.entries))this.now-c.at>864e5&&(delete this.entries[b],a=!0);if(this.dirty||a)try{await (0,K.VH)(V,{entries:this.entries})}catch(a){U.warn("Failed to persist quality cache",a)}}}function X(a){return!Number.isFinite(a)||a<0?0:a>1?1:a}function Y(a,b){return!Number.isFinite(a)||a<=0?0:!Number.isFinite(b)||b<=1?+(a>0):X(Math.log10(a+1)/Math.log10(b+1))}let Z=(0,i.h)("backend/services/mcp/quality/providers/githubStars"),$="github",_=new Map;function aa(){return d??(process.env.GITHUB_TOKEN||void 0)}function ab(a){let b,c=a.server.repository;if(c?.source&&"github"!==c.source.toLowerCase())return null;var d=c?.url;if(!d)return null;try{b=new URL(d.replace(/^git\+/,""))}catch{return null}if(!/(^|\.)github\.com$/i.test(b.hostname))return null;let e=b.pathname.replace(/\.git$/i,"").split("/").filter(Boolean);return e.length<2?null:`${e[0]}/${e[1]}`.toLowerCase()}async function ac(a,b){let c=new AbortController,d=()=>c.abort();b.addEventListener("abort",d,{once:!0});let e=setTimeout(()=>c.abort(),6e3);try{return await fetch(`https://api.github.com${a}`,{headers:function(){let a={Accept:"application/vnd.github+json","User-Agent":"FLUJO-mcp-quality","X-GitHub-Api-Version":"2022-11-28"},b=aa();return b&&(a.Authorization=`Bearer ${b}`),a}(),signal:c.signal,cache:"no-store"})}catch(b){return Z.warn(`GitHub request failed (${a})`,b instanceof Error?b.message:b),null}finally{clearTimeout(e),b.removeEventListener("abort",d)}}function ad(a){return(403===a.status||429===a.status)&&"0"===a.headers.get("x-ratelimit-remaining")}let ae=(0,i.h)("backend/services/mcp/quality/providers/npmDownloads"),af="npm-downloads",ag=new Map;function ah(a){for(let b of a.server.packages??[])if("npm"===b.registryType&&b.identifier)return b.identifier;return null}function ai(a){return a.startsWith("@")}async function aj(a,b){let c=new AbortController,d=()=>c.abort();b.addEventListener("abort",d,{once:!0});let e=setTimeout(()=>c.abort(),6e3);try{return await fetch(`https://api.npmjs.org${a}`,{signal:c.signal,cache:"no-store"})}catch(b){return ae.warn(`npm request failed (${a})`,b instanceof Error?b.message:b),null}finally{clearTimeout(e),b.removeEventListener("abort",d)}}let ak="registry-status",al=[{id:$,label:"GitHub Stars & Activity",defaultWeight:.5,isApplicable:a=>null!==ab(a),cacheKey:a=>ab(a),async prefetch(a,b,c){let d=`${a??""} mcp`.trim(),e=`/search/repositories?q=${encodeURIComponent(d)}&sort=stars&order=desc&per_page=50`,f=await ac(e,c);if(f&&f.ok)try{for(let a of(await f.json()).items??[])a.full_name&&_.set(a.full_name.toLowerCase(),{stars:"number"==typeof a.stargazers_count?a.stargazers_count:0,pushedAtMs:a.pushed_at?Date.parse(a.pushed_at):null})}catch(a){Z.warn("Failed to parse GitHub search response",a)}else if(f&&ad(f))return void Z.warn("GitHub search rate-limited; ranking will degrade to other providers");if(!aa())return;let g=3;for(let a of b){if(g<=0)break;let b=ab(a);if(!b||_.has(b))continue;g-=1;let d=await ac(`/repos/${b}`,c);if(d){if(ad(d))break;if(d.ok)try{let a=await d.json();_.set(b,{stars:"number"==typeof a.stargazers_count?a.stargazers_count:0,pushedAtMs:a.pushed_at?Date.parse(a.pushed_at):null})}catch{}}}},async fetch(a){let b=ab(a);if(!b)return null;let c=_.get(b);if(!c)return null;let d=Y(c.stars,5e4),e=function(a,b,c=30,d=730){if(!a||!Number.isFinite(a))return 0;let e=(b-a)/864e5;return e<=c?1:e>=d?0:X(1-(e-c)/(d-c))}(c.pushedAtMs,Date.now());return{providerId:$,score:X(.7*d+.3*e),evidence:{repo:b,stars:c.stars,...c.pushedAtMs?{pushedAt:new Date(c.pushedAtMs).toISOString()}:{},starsScore:d,recencyScore:e}}}},{id:af,label:"npm Weekly Downloads",defaultWeight:.35,isApplicable:a=>null!==ah(a),cacheKey:a=>ah(a),async prefetch(a,b,c){let d=b.map(ah).filter(a=>!!a&&!ag.has(a)),e=d.filter(a=>!ai(a)),f=d.filter(ai);for(let a=0;a<e.length;a+=100){let b=e.slice(a,a+100),d=await aj(`/downloads/point/last-week/${b.join(",")}`,c);if(d&&d.ok)try{let a=await d.json();if(1===b.length)"number"==typeof a.downloads&&ag.set(b[0],a.downloads);else for(let c of b){let b=a[c];ag.set(c,b&&"number"==typeof b.downloads?b.downloads:0)}}catch(a){ae.warn("Failed to parse npm bulk downloads response",a)}}for(let a of f){let b=await aj(`/downloads/point/last-week/${a}`,c);if(b&&b.ok)try{let c=await b.json();"number"==typeof c.downloads&&ag.set(a,c.downloads)}catch{}}},async fetch(a){let b=ah(a);if(!b)return null;let c=ag.get(b);return void 0===c?null:{providerId:af,score:Y(c,1e6),evidence:{package:b,weeklyDownloads:c}}}},{id:ak,label:"Registry Status",defaultWeight:.15,isApplicable:a=>!0,cacheKey:()=>null,fetch:async a=>({providerId:ak,score:+("active"===a.verificationStatus),evidence:{status:a.verificationStatus}})}];var am=c(89392);let an=(0,i.h)("backend/services/mcp/quality/settings");function ao(){return{providers:al.map(a=>({id:a.id,enabled:!0,weight:a.defaultWeight})),minScore:0,worksGate:!0}}async function ap(){try{let a=await (0,K.YM)(am.Z.MCP_QUALITY_SETTINGS,ao());return function(a){var b,c;let d=ao(),e=a??{},f=new Map;if(Array.isArray(e.providers))for(let a of e.providers)a&&"string"==typeof a.id&&f.set(a.id,a);return{providers:d.providers.map(a=>{let b=f.get(a.id);return{id:a.id,enabled:"boolean"==typeof b?.enabled?b.enabled:a.enabled,weight:"number"==typeof b?.weight&&Number.isFinite(b.weight)&&b.weight>=0?b.weight:a.weight}}),minScore:(b=e.minScore,c=d.minScore,"number"==typeof b&&Number.isFinite(b)?Math.min(1,Math.max(0,b)):c),worksGate:"boolean"==typeof e.worksGate?e.worksGate:d.worksGate,..."string"==typeof e.githubToken&&e.githubToken.length>0?{githubToken:e.githubToken}:{}}}(a)}catch(a){return an.warn("Failed to load mcpQuality settings; using defaults",a),ao()}}let aq=(0,i.h)("backend/services/mcp/quality/orchestrator");async function ar(a,b){let c=new AbortController,d=setTimeout(()=>c.abort(),b);try{return await a(c.signal)}finally{clearTimeout(d)}}async function as(a,b,c={}){let e=c.topN??10;try{var f;let g=c.settings??await ap(),h=al.filter(a=>(function(a,b){let c=a.providers.find(a=>a.id===b);return!!c?.enabled})(g,a.id));if(0===h.length)return b.map(a=>({candidate:a,score:0,signals:[]}));d=(f=g.githubToken)&&f.length>0?f:void 0;let i=b.slice(0,e),j=b.slice(e),k=new W(c.now??Date.now());await k.load();let l=i.map(()=>[]);for(let b of h){let c=i.map((a,b)=>({c:a,i:b})).filter(({c:a})=>b.isApplicable(a)),d=[],e=[];for(let a of c){let c=b.cacheKey(a.c);if(c){let d=k.get(b.id,c);if(d){e.push({i:a.i,signal:d});continue}}d.push(a)}if(b.prefetch&&d.length>0)try{await ar(c=>b.prefetch(a,d.map(a=>a.c),c),12e3)}catch(a){aq.warn(`Provider "${b.id}" prefetch failed; degrading`,a)}for(let{c:a,i:c}of d)try{let d=await ar(c=>b.fetch(a,c),2e3);if(d){l[c].push(d);let e=b.cacheKey(a);e&&k.set(b.id,e,d)}}catch(c){aq.warn(`Provider "${b.id}" fetch failed for "${a.registryName}"`,c)}for(let{i:a,signal:b}of e)l[a].push(b)}await k.flush();let m=i.map((a,b)=>{let c=l[b],d=new Map(c.map(a=>[a.providerId,a])),e=h.filter(b=>b.isApplicable(a)).map(a=>({providerId:a.id,weight:function(a,b){let c=a.providers.find(a=>a.id===b);return c&&c.enabled?c.weight:0}(g,a.id),score:d.get(a.id)?.score??0})),{score:f}=function(a){let b=0,c=0;for(let d of a){let a=Number.isFinite(d.weight)&&d.weight>0?d.weight:0,e=X(d.score);b+=a,c+=a*e}return{score:b>0?c/b:0,breakdown:a}}(e);return{candidate:a,score:f,signals:c}}).map((a,b)=>({s:a,idx:b})).sort((a,b)=>b.s.score-a.s.score||a.idx-b.idx).map(a=>a.s),n=j.map(a=>({candidate:a,score:0,signals:[]}));return[...m,...n]}catch(a){return aq.warn("enrichAndRank failed; returning unranked candidates",a),b.map(a=>({candidate:a,score:0,signals:[]}))}}let at=(0,i.h)("backend/services/mcp/registryInstall"),au="/v0.1/servers";function av(a){return{registryName:a.server.name,server:a.server,verificationStatus:(0,T.vf)(a)}}async function aw(a,b=8){let c=await ax(a,b);return(await as(a,c.map(av))).map(a=>(function(a,b){let c=(0,T.AH)(a),d=c[0];return{name:a.name,...a.title?{title:a.title}:{},...a.description?{description:a.description}:{},installable:c.length>0,requiredEnv:d?(0,T.jg)(d):[],...b?{quality:function(a){let b=b=>a.signals.find(a=>a.providerId===b)?.evidence,c=b($),d=b(af),e=b(ak);return{score:a.score,..."number"==typeof c?.stars?{stars:c.stars}:{},..."number"==typeof d?.weeklyDownloads?{weeklyDownloads:d.weeklyDownloads}:{},..."string"==typeof e?.status?{status:e.status}:{}}}(b)}:{}}})(a.candidate.server,a))}async function ax(a,b){let c=new URL(S.jD+au);c.searchParams.set("version","latest"),c.searchParams.set("limit",String(Math.min(Math.max(b,1),30))),a&&c.searchParams.set("search",a);let d=await (0,S.Ws)(c,15e3);return Array.isArray(d?.servers)?d.servers:[]}async function ay(a){let b=new URL(S.jD+au);b.searchParams.set("version","latest"),b.searchParams.set("limit","10"),b.searchParams.set("search",a);let c=await (0,S.Ws)(b,15e3),d=Array.isArray(c?.servers)?c.servers:[];return d.find(b=>b.server?.name===a)??d[0]??null}async function az(a,b,c){let d;if(!a||"string"!=typeof a)return{installed:!1,error:"A registry server name is required"};try{d=await ay(a)}catch(a){return{installed:!1,error:`Registry lookup failed: ${a instanceof Error?a.message:String(a)}`}}let e=d?.server??null;if(!e)return{installed:!1,error:`No registry entry found for "${a}"`};let f=(0,T.AH)(e)[0];if(!f)return{installed:!1,error:`"${e.name}" has no install method FLUJO supports (stdio package or HTTP remote)`};let g=(0,T.vf)(d),h=(0,T.O$)(a,e,f,g);if(c?.resolveOnly)return{installed:!1,serverName:h.serverName,plan:h};let i=(0,T.jg)(f,b);if(i.length>0)return{installed:!1,needsEnv:i,plan:h,error:`"${e.name}" requires values for: ${i.join(", ")}`};let j=(0,T.cy)((0,T.Yr)(e,f),b),k=j.name,l=await D.mcpService.loadServerConfigs();if(Array.isArray(l)&&l.some(a=>a.name===k)){at.info(`installRegistryServer: "${k}" already configured; reusing`);let{tools:a,error:b}=await D.mcpService.listServerTools(k);return{installed:!0,alreadyExisted:!0,serverName:k,plan:h,tools:(a??[]).map(a=>({name:a.name,...a.description?{description:a.description}:{}})),...b?{error:b}:{}}}at.info(`installRegistryServer: installing "${e.name}" as "${k}" (${f.kind})`);let m=await D.mcpService.updateServerConfig(k,j);if(!Array.isArray(m)&&m&&"success"in m&&!1===m.success)return{installed:!1,error:`Saving the server failed: ${m.error??"unknown error"}`};let{tools:n,error:o}=await D.mcpService.listServerTools(k),p=(n??[]).map(a=>({name:a.name,...a.description?{description:a.description}:{}}));if((c?.worksGate??(await ap()).worksGate)&&0===p.length){at.warn(`installRegistryServer: "${k}" exposed no tools${o?` (${o})`:""}; rolling back (works-gate)`);try{await D.mcpService.deleteServerConfig(k)}catch(a){at.error(`installRegistryServer: rollback of "${k}" failed`,a)}return{installed:!1,worksGateRejected:!0,serverName:k,plan:h,error:o?`"${e.name}" failed to start: ${o}`:`"${e.name}" connected but exposed no tools — rejected by the works-gate. Try a different server.`}}return{installed:!0,serverName:k,plan:h,tools:p,...o?{error:o}:{}}}async function aA(a,b,c){let d;if(!a||"string"!=typeof a)return{installed:!1,error:"A capability search query is required"};try{d=await ax(a,10)}catch(a){return{installed:!1,error:`Registry lookup failed: ${a instanceof Error?a.message:String(a)}`}}let e=await as(a,d.map(av)),f=await ap(),g=c?.minScore??f.minScore,h=c?.maxAttempts??3,i=[],j=0;for(let a of e){let d=a.candidate.registryName;if(a.score<g){i.push({name:d,score:a.score,reason:`below minScore ${g}`});break}if(0===(0,T.AH)(a.candidate.server).length){i.push({name:d,score:a.score,reason:"no supported install method"});continue}if(j>=h)break;j+=1;let e=await az(d,b,{worksGate:!0});if(c?.onAttempt)try{await c.onAttempt(e.plan,e)}catch(a){at.error("installBestForCapability: onAttempt hook failed",a)}if(e.installed)return{...e,attempts:i};let f=e.needsEnv?.length?`needs env: ${e.needsEnv.join(", ")}`:e.worksGateRejected?"works-gate rejected (no tools / failed to start)":e.error??"install failed";i.push({name:d,score:a.score,reason:f})}return{installed:!1,attempts:i,error:`No working server found for "${a}" among the top ${j} installable candidate(s).`}}let aB={requireConsent:!0,namespaceAllowlist:[],trustBrainStem:!0};function aC(a){let{caller:b,settings:c,registryName:d,allowInstall:e}=a;if("generator"===b)return!0===e?{allowed:!0,reason:"generator-allowinstall",message:"Approved by the per-generation allowInstall opt-in."}:{allowed:!1,reason:"generator-not-allowed",message:"Installing is not allowed in this generation (allowInstall is off)."};if("authoring-tool"===b&&c.trustBrainStem)return{allowed:!0,reason:"brainstem-trusted",message:"Approved: the /mcp-flows authoring tool is trusted (mcpAutoInstall.trustBrainStem)."};if(!c.requireConsent)return{allowed:!0,reason:"consent-disabled",message:"Approved: consent is not required (mcpAutoInstall.requireConsent is off)."};let f=function(a){if("string"!=typeof a)return"";let b=a.indexOf("/");return b>0?a.slice(0,b):""}(d);return""!==f&&c.namespaceAllowlist.includes(f)?{allowed:!0,reason:"namespace-allowlisted",message:`Approved: namespace "${f}" is allowlisted.`}:{allowed:!1,reason:"consent-required",message:"Consent required: review the exact command and arguments, then approve this install (SEP-1024)."}}function aD(a,b,c,d,e){return{at:new Date().toISOString(),caller:b,registryName:a.registryName,resolvedName:a.resolvedName,serverName:a.serverName,transport:a.transport,...a.command?{command:a.command}:{},...a.args?{args:a.args}:{},...a.serverUrl?{serverUrl:a.serverUrl}:{},requiredEnvNames:a.requiredEnvNames,verificationStatus:a.verificationStatus,consent:{allowed:c.allowed,reason:c.reason},installed:d,...e?{error:e}:{}}}let aE=(0,i.h)("backend/services/mcp/autoInstall");async function aF(){try{let a=await (0,K.YM)(am.Z.MCP_AUTO_INSTALL_SETTINGS,aB)??{};return{requireConsent:"boolean"==typeof a.requireConsent?a.requireConsent:aB.requireConsent,namespaceAllowlist:Array.isArray(a.namespaceAllowlist)?a.namespaceAllowlist.filter(a=>"string"==typeof a&&a.length>0):[],trustBrainStem:"boolean"==typeof a.trustBrainStem?a.trustBrainStem:aB.trustBrainStem}}catch(a){return aE.warn("Failed to load mcpAutoInstall settings; using safe defaults",a),{...aB}}}let aG="mcp-install-audit",aH=Promise.resolve();async function aI(){try{return await (0,K.YM)(aG,[])}catch(a){return aE.error("Failed to load MCP install audit log",a),[]}}async function aJ(a){let b=aH.catch(()=>{}).then(async()=>{let b=await aI();b.push(a);let c=b.slice(-300);await (0,K.VH)(aG,c)}).catch(a=>{aE.error("Failed to append MCP install audit entry",a)});aH=b,await b}let aK=(0,i.h)("backend/services/mcp/flowAuthoringTools"),aL=["list_flow_building_blocks","validate_flow_spec","create_flow","search_mcp_marketplace","install_mcp_server","install_best_mcp_server"];function aM(){return{type:"object",properties:{spec:{type:"object",description:"The FlowSpec object (see the tool description for the format)."}},required:["spec"]}}function aN(a,b=!1){return{content:[{type:"text",text:JSON.stringify(a,null,2)}],...b?{isError:!0}:{}}}async function aO(a,b){try{if("list_flow_building_blocks"===a){let a=await G();return aN(a.blocks)}if("search_mcp_marketplace"===a){let a="string"==typeof b?.query?b.query:"",c=await aw(a);return aN(c)}if("install_mcp_server"===a){let a="string"==typeof b?.name?b.name:"",c=b?.env&&"object"==typeof b.env&&!Array.isArray(b.env)?b.env:void 0,d=await az(a,c,{resolveOnly:!0});if(!d.plan)return aN(d,!0);let e=await aF(),f=aC({caller:"authoring-tool",settings:e,registryName:a}),g=(0,T.nO)(d.plan.verificationStatus)?void 0:`Unverified / self-asserted registry entry (status: ${d.plan.verificationStatus}). Registry entries are publisher-asserted — review the command before approving.`;if(await aJ(aD(d.plan,"authoring-tool",f,!1)),!f.allowed)return aN({installed:!1,consentRequired:!0,message:f.message,plan:d.plan,...g?{verificationWarning:g}:{}});let h=await az(a,c);return await aJ(aD(h.plan??d.plan,"authoring-tool",f,h.installed,h.error)),aN({...h,...g?{verificationWarning:g}:{}},!h.installed)}if("install_best_mcp_server"===a){let a="string"==typeof b?.capability?b.capability:"",c=b?.env&&"object"==typeof b.env&&!Array.isArray(b.env)?b.env:void 0;if(!a)return aN({error:'Provide a "capability" search term.'},!0);let d=await aF(),e=aC({caller:"authoring-tool",settings:d,registryName:a});if(!e.allowed){let b=(await aw(a)).find(a=>a.installable),d=b?await az(b.name,c,{resolveOnly:!0}):null;return d?.plan&&await aJ(aD(d.plan,"authoring-tool",e,!1)),aN({installed:!1,consentRequired:!0,message:e.message,...d?.plan?{plan:d.plan}:{}})}let f=await aA(a,c,{onAttempt:async(a,b)=>{a&&await aJ(aD(a,"authoring-tool",e,b.installed,b.error))}}),g=f.installed&&!(0,T.nO)(f.plan?.verificationStatus)?`Installed an unverified / self-asserted registry entry (status: ${f.plan?.verificationStatus}).`:void 0;return aN({...f,...g?{verificationWarning:g}:{}},!f.installed)}if("validate_flow_spec"===a||"create_flow"===a){let c=function(a){let b=a?.spec;if("string"==typeof b)try{return JSON.parse(b)}catch{return null}return b??null}(b);if(!c)return aN({error:'Provide a "spec" argument: a FlowSpec object (or a JSON string of one).'},!0);let d=await I(c,{save:"create_flow"===a});if(!d.success)return aN({error:d.error,issues:d.issues??[]},!0);let e=d.flows.length,f=e>1?` (plus ${e-1} nested subflow flow(s))`:"",g={flowId:d.flow.id,flowName:d.flow.name,nodeCount:d.flow.nodes.length,edgeCount:d.flow.edges.length,...e>1?{flows:d.flows.map(a=>({id:a.id,name:a.name}))}:{},validation:d.validation,..."create_flow"===a?{saved:d.saved,...d.saved?{note:`Flow "${d.flow.name}"${f} was created. It is callable as a tool on this MCP server (after a fresh tools/list) and as model "flow-${d.flow.name}" on the OpenAI-compatible endpoint.`}:{note:"NOT saved: validation found errors. Fix the issues and call create_flow again."}}:{}};return aN(g,"create_flow"===a&&!d.saved)}return aN({error:`Unknown authoring tool: ${a}`},!0)}catch(b){return aK.error("authoringCallTool failed",{toolName:a,err:b}),aN({error:`Authoring tool failed: ${b instanceof Error?b.message:String(b)}`},!0)}}var aP=c(92018);let aQ=(0,i.h)("backend/services/mcp/internalTools");function aR(a,b=!1){return{content:[{type:"text",text:"string"==typeof a?a:JSON.stringify(a,null,2)}],...b?{isError:!0}:{}}}function aS(){return[{name:"list_flow_building_blocks",description:'List everything a FlowSpec may reference in this FLUJO instance: configured models (bind to process steps), MCP servers and their tools (attach via "servers"), and existing flows (usable as subflow targets). Call this before authoring a spec.',inputSchema:{type:"object",properties:{}}},{name:"validate_flow_spec",description:`Compile and validate a FlowSpec WITHOUT saving. Returns the compiled flow's validation result (errors block saving; warnings are advisory) so you can iterate until clean, then call create_flow.
65
70
 
66
- ${P}`,inputSchema:aK()},{name:"create_flow",description:`Create a new FLUJO flow from a FlowSpec. The spec is compiled deterministically (layout, ids, and wiring are generated for you) and saved ONLY when validation finds zero errors — otherwise the issues are returned to fix. Use list_flow_building_blocks first to see the models, MCP servers/tools, and existing flows you may reference.
71
+ ${R}`,inputSchema:aM()},{name:"create_flow",description:`Create a new FLUJO flow from a FlowSpec. The spec is compiled deterministically (layout, ids, and wiring are generated for you) and saved ONLY when validation finds zero errors — otherwise the issues are returned to fix. Use list_flow_building_blocks first to see the models, MCP servers/tools, and existing flows you may reference.
67
72
 
68
- ${P}`,inputSchema:aK()},{name:"search_mcp_marketplace",description:"Search the public MCP server registry for new capabilities (voice, browsing, files, email, vision, …). The registry matches the query against server NAMES only (substring) — use short single terms and try several. Returns name, description, whether FLUJO can install it, and which env vars/keys it would require.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Short search term matched against server names."}},required:["query"]}},{name:"install_mcp_server",description:'Install an MCP server from the public registry (by the exact name returned by search_mcp_marketplace) and connect it — this DOWNLOADS AND RUNS a third-party package on the FLUJO host. Installs are gated by consent (SEP-1024): unless this trusted authoring tool is allowed via the mcpAutoInstall settings (trustBrainStem / requireConsent / namespaceAllowlist), the tool returns the exact resolved command + arguments with consentRequired=true INSTEAD of installing, and the caller must obtain explicit approval. Every attempt is written to an audit log (command, args, env NAMES, verification status — never secret values) before any spawn. Returns the FLUJO server name (reference it in FlowSpec "servers") and the tools it provides, or needsEnv when required keys are missing (supply values via the optional "env" argument), or the resolved plan when consent is required. First install can take minutes (package download).',inputSchema:{type:"object",properties:{name:{type:"string",description:'Exact registry name from search results, e.g. "ai.keenable/web-search".'},env:{type:"object",description:"Optional env var values for the server (e.g. required API keys).",additionalProperties:{type:"string"}}},required:["name"]}},{name:"install_best_mcp_server",description:"Install the BEST WORKING MCP server for a capability, unattended — the recommended way to acquire a capability when you don't already have a specific server name. Searches the registry, RANKS candidates by blended quality (GitHub stars + recent activity, npm weekly downloads, registry status), then installs best→worst until one actually boots and exposes tools (the \"works-gate\"): candidates that need unavailable keys, can't be installed, or start with zero tools are skipped automatically. Same consent/audit rules and third-party-code warning as install_mcp_server. Returns the installed server name + its tools and the list of candidates tried, or needsEnv/consentRequired. Prefer this over search+install for headless self-improvement; use install_mcp_server only when you must pin an exact server.",inputSchema:{type:"object",properties:{capability:{type:"string",description:'Short capability term matched against server names, e.g. "youtube", "email", "browser".'},env:{type:"object",description:"Optional env var values shared across attempted servers (e.g. an API key).",additionalProperties:{type:"string"}}},required:["capability"]}},{name:"execute_flow",description:"Run another FLUJO flow (by name or id) with the given input and return its final output. The run is ephemeral (no chat conversation is created). Use list_flow_building_blocks to see the available flows. Nested runs are limited in depth — a flow cannot recurse through itself indefinitely.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."},input:{type:"string",description:"The message to send to the flow as the user turn."}},required:["flow","input"]}},{name:"read_flow",description:"Read a FLUJO flow's full definition (by name or id): its nodes with their prompts, bound models, attached MCP servers/tools and input/output modes, plus the control and MCP edges. Note this is the COMPILED flow (node ids, not FlowSpec keys) — to change it, author a fresh FlowSpec and call update_flow.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."}},required:["flow"]}},{name:"update_flow",description:"REPLACE an existing FLUJO flow's definition (by name or id) with a newly compiled FlowSpec, keeping the flow's id — so planned executions, subflow nodes and conversations that reference it keep working. The spec format is the same as create_flow/validate_flow_spec (see those tool descriptions); saving is gated on zero validation errors. The replaced definition is archived automatically — list_flow_versions / revert_flow can restore it. Note that manual canvas edits made in the builder are part of what gets replaced. Use read_flow first to see what you are replacing.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id of the flow to replace."},spec:{type:"object",description:"The FlowSpec object (see the create_flow tool description for the format)."}},required:["flow","spec"]}},{name:"list_flow_versions",description:"List a flow's archived versions (by name or id), newest first. A version is created automatically whenever the flow's definition is overwritten (builder save, update_flow, revert_flow) and holds the definition that was replaced. Use read_flow_version to inspect one and revert_flow to restore one.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."}},required:["flow"]}},{name:"read_flow_version",description:"Read one archived version of a flow (see list_flow_versions): the full definition it held before it was replaced, in the same format as read_flow.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."},version:{type:"string",description:"The version id (see list_flow_versions)."}},required:["flow","version"]}},{name:"revert_flow",description:"Restore an archived version (see list_flow_versions) as the flow's CURRENT definition. The definition being reverted away from is archived first, so a revert can itself be undone. References by flow id keep working.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."},version:{type:"string",description:"The version id to restore (see list_flow_versions)."}},required:["flow","version"]}},{name:"delete_flow",description:"PERMANENTLY delete a FLUJO flow (by name or id). This cannot be undone — the flow's version history is deleted with it. Verify the target with list_flow_building_blocks first.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."}},required:["flow"]}},{name:"list_mcp_servers",description:"List the MCP servers configured in this FLUJO instance with their transport, enabled/disabled state and live connection status. Config details (env vars, headers, credentials) are never included.",inputSchema:{type:"object",properties:{}}},{name:"list_mcp_server_tools",description:"List the tools of one configured MCP server (name, description, input schema). Use together with call_mcp_tool for servers that are not bound to this flow.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name (see list_mcp_servers)."}},required:["server"]}},{name:"call_mcp_tool",description:"Call a tool on any configured MCP server by server name + tool name. This lets you use servers that are not bound to the current flow. Check the tool's input schema with list_mcp_server_tools first.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name."},tool:{type:"string",description:"The tool name on that server."},args:{type:"object",description:"Arguments for the tool (per its input schema)."},timeout:{type:"number",description:"Optional timeout in seconds."}},required:["server","tool"]}},{name:"restart_mcp_server",description:"Force-reconnect a configured MCP server (tears the connection down and rebuilds it). Useful when a server is in an error state after a config or environment change.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name."}},required:["server"]}},{name:"set_mcp_server_enabled",description:"Enable or disable a configured MCP server. Disabling disconnects it and prevents any further use; enabling connects it.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name."},enabled:{type:"boolean",description:"true to enable + connect, false to disable + disconnect."}},required:["server","enabled"]}},{name:"list_models",description:"List the models configured in this FLUJO instance (id, name, display name, description, provider, base URL, context window). API keys are never included. Reference models by id or name in FlowSpecs.",inputSchema:{type:"object",properties:{}}},{name:"list_planned_executions",description:"List the planned (scheduled/triggered) executions in this FLUJO instance with their trigger type, enabled state, armed status and last run outcome.",inputSchema:{type:"object",properties:{}}},{name:"run_planned_execution",description:"Fire a planned execution immediately (by id, see list_planned_executions) and return the run record with its output.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The planned execution id."}},required:["id"]}},{name:"list_conversations",description:"List the chat conversations stored in this FLUJO instance (id, title, bound flow, status, created/updated timestamps), newest first. Use read_conversation to get a transcript.",inputSchema:{type:"object",properties:{limit:{type:"number",description:"Optional maximum number of conversations to return (newest first). Default: all."}}}},{name:"read_conversation",description:'Read one chat conversation\'s transcript by conversation id (see list_conversations). Returns the displayed messages: system prompts are excluded, nested subflow steps carry a "depth" marker, assistant tool calls are summarized. Long conversations return only the most recent messages — raise "limit" to get more.',inputSchema:{type:"object",properties:{conversation:{type:"string",description:"The conversation id."},limit:{type:"number",description:"Maximum number of most-recent messages to return (default 50). The total transcript size is capped regardless."}},required:["conversation"]}},{name:"terminal",description:'Run a shell command on the FLUJO host and return its combined stdout/stderr plus exit code. Runs through a shell, so pipes and chained commands (e.g. "npm install && npm run build") work. Use it to install dependencies, build a cloned MCP server, inspect the filesystem, or run diagnostics. Working directory defaults to the FLUJO data directory (where cloned servers live under mcp-servers/); pass "cwd" to run elsewhere. The command is killed if it exceeds the timeout, and very large output is truncated.',inputSchema:{type:"object",properties:{command:{type:"string",description:'The shell command line to execute, e.g. "npm install && npm run build".'},cwd:{type:"string",description:"Optional working directory. Relative paths resolve against the FLUJO data directory. Defaults to the data directory."},timeout:{type:"number",description:"Optional timeout in seconds (default 60, max 600). The command is killed if it runs longer."}},required:["command"]}}]}async function aR(a){let b=await k.flowService.loadFlows();return b.find(b=>b.id===a)??b.find(b=>b.name===a)}async function aS(a){let b=String(a?.flow??"").trim();if(!b)return aP({error:'Provide "flow": a flow name or id.'},!0);let c=await aR(b);if(!c)return aP({error:`No flow named or with id "${b}". Use list_flow_building_blocks to see the available flows.`},!0);let d=global.__flujo_internal_flow_depth??0;if(d>=4)return aP({error:`execute_flow nesting limit (4) reached — refusing to start "${c.name}" to prevent runaway recursion.`},!0);global.__flujo_internal_flow_depth=d+1;try{let b=await (0,n.runFlow)({flowId:c.id,prompt:String(a?.input??""),mode:"ephemeral",flujo:!0,requireApproval:!1});if(b.flowNotFound)return aP({error:`Flow not found: ${b.flowNotFound.name}`},!0);if("error"===b.status)return aP({error:b.error?.message??"Unknown error during flow execution."},!0);return aP(b.outputText??"")}finally{global.__flujo_internal_flow_depth=d}}async function aT(a){let b=String(a?.flow??"").trim();if(!b)return aP({error:'Provide "flow": a flow name or id.'},!0);let c=await aR(b);if(!c)return aP({error:`No flow named or with id "${b}".`},!0);let d=await k.flowService.deleteFlow(c.id);return d.success?aP({deleted:!0,flowId:c.id,flowName:c.name}):aP({error:d.error??`Failed to delete flow "${c.name}".`},!0)}function aU(a){let b=a.nodes.map(a=>{let{mcpNodes:b,...c}=a.data?.properties??{};return{id:a.id,type:a.type,label:a.data?.label,...a.data?.description?{description:a.data.description}:{},properties:c}}),c=a.edges.map(a=>{let b=a.data;return{from:a.source,to:a.target,type:b?.edgeType==="mcp"?"mcp":b?.edgeType==="resource"?"resource":"control",...b?.bidirectional?{bidirectional:!0}:{}}});return{id:a.id,name:a.name,...a.description?{description:a.description}:{},nodes:b,edges:c}}async function aV(a){let b=String(a?.flow??"").trim();if(!b)return aP({error:'Provide "flow": a flow name or id.'},!0);let c=await aR(b);return c?aP({...aU(c),note:"This is the compiled flow (node ids, not FlowSpec keys). To change it, author a fresh FlowSpec and call update_flow — it replaces the whole definition while keeping this flow id."}):aP({error:`No flow named or with id "${b}". Use list_flow_building_blocks to see the available flows.`},!0)}async function aW(a){let b=String(a?.flow??"").trim();if(!b)return aP({error:'Provide "flow": a flow name or id.'},!0);let c=await aR(b);if(!c)return aP({error:`No flow named or with id "${b}".`},!0);let d=await k.flowService.listFlowVersions(c.id);return aP({flowId:c.id,flowName:c.name,versions:d,...0===d.length?{note:"No archived versions yet — versions appear once the flow's definition is overwritten for the first time."}:{}})}async function aX(a){let b=String(a?.flow??"").trim(),c=String(a?.version??"").trim();if(!b||!c)return aP({error:'Provide "flow" (name or id) and "version" (see list_flow_versions).'},!0);let d=await aR(b);if(!d)return aP({error:`No flow named or with id "${b}".`},!0);let e=await k.flowService.getFlowVersion(d.id,c);return e?aP({versionId:e.versionId,savedAt:e.savedAt,...aU(e.flow)}):aP({error:`No version "${c}" of flow "${d.name}". Use list_flow_versions to see the archived versions.`},!0)}async function aY(a){let b=String(a?.flow??"").trim(),c=String(a?.version??"").trim();if(!b||!c)return aP({error:'Provide "flow" (name or id) and "version" (see list_flow_versions).'},!0);let d=await aR(b);if(!d)return aP({error:`No flow named or with id "${b}".`},!0);let e=await k.flowService.revertFlow(d.id,c);return e.success?aP({reverted:!0,flowId:d.id,versionId:c,note:"The definition that was just replaced has been archived too, so this revert can itself be undone via list_flow_versions / revert_flow."}):aP({error:e.error??`Failed to revert flow "${d.name}".`},!0)}async function aZ(a){let b=String(a?.flow??"").trim();if(!b)return aP({error:'Provide "flow": the name or id of the flow to replace.'},!0);let c=function(a){let b=a?.spec;if("string"==typeof b)try{return JSON.parse(b)}catch{return null}return b??null}(a);if(!c)return aP({error:'Provide a "spec" argument: a FlowSpec object (or a JSON string of one).'},!0);let d=await aR(b);if(!d)return aP({error:`No flow named or with id "${b}". Use list_flow_building_blocks to see the available flows.`},!0);let e=await H(c,{save:!0,updateFlowId:d.id});return e.success?aP({flowId:e.flow.id,flowName:e.flow.name,nodeCount:e.flow.nodes.length,edgeCount:e.flow.edges.length,validation:e.validation,saved:e.saved,...e.saved?{note:`Flow "${e.flow.name}" was replaced (id ${e.flow.id} kept — existing references keep working).`}:{note:"NOT saved: validation found errors. The existing flow is unchanged. Fix the issues and call update_flow again."}},!e.saved):aP({error:e.error,issues:e.issues??[]},!0)}async function a$(a){let b=await a.loadServerConfigs();return Array.isArray(b)?aP(await Promise.all(b.map(async b=>{let c="unknown";try{c=(await a.getServerStatus(b.name)).status}catch(a){aO.debug(`list_mcp_servers: getServerStatus failed for ${b.name}`,a)}return{name:b.name,transport:b.transport,enabled:!b.disabled,status:c,...b.builtIn?{builtIn:!0}:{}}}))):aP({error:b.error??"Failed to load server configs."},!0)}async function a_(a,b){let c=String(b?.server??"").trim();if(!c)return aP({error:'Provide "server": a FLUJO server name.'},!0);if(c===aN._)return aP(aQ().map(a=>({name:a.name,description:a.description,inputSchema:a.inputSchema})));let{tools:d,error:e}=await a.listServerTools(c);return e?aP({error:e},!0):aP(d.map(a=>({name:a.name,description:a.description,inputSchema:a.inputSchema})))}async function a0(a,b){let c=String(b?.server??"").trim(),d=String(b?.tool??"").trim();if(!c||!d)return aP({error:'Provide "server" and "tool".'},!0);if(c===aN._)return aP({error:`"${aN._}" is this server — call its tools directly instead of through call_mcp_tool.`},!0);let e=b?.args&&"object"==typeof b.args&&!Array.isArray(b.args)?b.args:{},f="number"==typeof b?.timeout?b.timeout:void 0,g=await a.callTool(c,d,e,f);if(!g.success)return aP({error:g.error??`Tool call failed on ${c}.`},!0);let h=g.data;return h&&Array.isArray(h.content)?h:aP(h??{ok:!0})}async function a1(a,b){let c=String(b?.server??"").trim();if(!c)return aP({error:'Provide "server": a FLUJO server name.'},!0);if(c===aN._)return aP({ok:!0,note:`"${aN._}" is the built-in server — it is always running.`});let d=await a.forceReconnect(c);if(!d.success)return aP({error:d.error??`Failed to restart ${c}.`},!0);let e=await a.getServerStatus(c);return aP({restarted:!0,server:c,status:e.status})}async function a2(a,b){let c=String(b?.server??"").trim(),d=b?.enabled;if(!c||"boolean"!=typeof d)return aP({error:'Provide "server" (string) and "enabled" (boolean).'},!0);if(c===aN._)return aP({error:`The built-in "${aN._}" server cannot be disabled.`},!0);let e=await a.updateServerConfig(c,{disabled:!d});return"error"in e?aP({error:e.error},!0):aP({server:c,enabled:d})}async function a3(){return aP((await l.modelService.loadModels()).map(a=>({id:a.id,name:a.name,...a.displayName?{displayName:a.displayName}:{},...a.description?{description:a.description}:{},...a.provider?{provider:a.provider}:{},...a.baseUrl?{baseUrl:a.baseUrl}:{},...a.contextWindow?{contextWindow:a.contextWindow}:{}})))}async function a4(){return aP((await (0,m.z)().list()).map(({execution:a,status:b,lastRun:c})=>({id:a.id,name:a.name,enabled:a.enabled,flowId:a.flowId,triggerType:a.trigger?.type,armed:b?.armed??!1,...c?{lastRun:{status:c.status,firedAt:c.firedAt,...c.error?{error:c.error}:{}}}:{}})))}async function a5(a){let b=String(a?.id??"").trim();if(!b)return aP({error:'Provide "id": a planned execution id (see list_planned_executions).'},!0);let{record:c,error:d}=await (0,m.z)().runNow(b);return d||!c?aP({error:d??"Run failed."},!0):aP({runId:c.runId,status:c.status,firedAt:c.firedAt,...c.finishedAt?{finishedAt:c.finishedAt}:{},...c.outputText?{outputText:c.outputText}:{},...c.error?{error:c.error}:{}})}async function a6(a){let b,c=f().join((0,O.ok)(),"db","conversations");try{b=await g.promises.readdir(c)}catch(a){if("ENOENT"===a.code)return aP([]);return aP({error:`Failed to list conversations: ${a instanceof Error?a.message:String(a)}`},!0)}let d=(await Promise.all(b.filter(a=>a.endsWith(".json")).map(async a=>{try{let b=await g.promises.readFile(f().join(c,a),"utf-8"),d=JSON.parse(b),e=d.conversationId||a.replace(/\.json$/,""),h=d.status;return"running"===h&&0===N.$.currentSeq(e)&&(h="error"),{id:e,title:d.title||"Untitled Conversation",flowId:d.flowId||null,...h?{status:h}:{},createdAt:d.createdAt||0,updatedAt:d.updatedAt||0}}catch(b){return aO.warn(`list_conversations: skipping unreadable conversation file ${a}`,b),null}}))).filter(a=>null!==a).sort((a,b)=>b.updatedAt-a.updatedAt),e="number"==typeof a?.limit&&a.limit>0?Math.floor(a.limit):void 0;return aP(e?d.slice(0,e):d)}async function a7(a){let b=String(a?.conversation??"").trim();if(!b)return aP({error:'Provide "conversation": a conversation id (see list_conversations).'},!0);await (0,K.u8)(b);let c=await M(b);if(!c)return aP({error:`No conversation with id "${b}". Use list_conversations to see the stored conversations.`},!0);let d=await (0,K.Os)(b),e=d?(0,K.cc)(d):[],f=e.length>0?e:(c.messages||[]).filter(a=>"system"!==a.role),g="number"==typeof a?.limit&&a.limit>0?Math.floor(a.limit):50,h=[],i=0;for(let a=f.length-1;a>=0&&h.length<g;a--){let b=function(a){let b="";"string"==typeof a.content?b=a.content:Array.isArray(a.content)&&(b=a.content.map(a=>"text"in a&&"string"==typeof a.text?a.text:"").filter(Boolean).join("\n"));let c={role:a.role,...b?{content:b}:{},...a.timestamp?{timestamp:a.timestamp}:{},...a.depth?{depth:a.depth}:{}};return"assistant"===a.role&&Array.isArray(a.tool_calls)&&a.tool_calls.length>0&&(c.toolCalls=a.tool_calls.map(a=>{let b="function"in a?a.function:void 0,c=b&&"string"==typeof b.arguments?b.arguments:void 0;return{id:a.id,...b?.name?{name:b.name}:{},...void 0!==c?{arguments:c.length>2e3?c.slice(0,2e3)+"…[truncated]":c}:{}}})),"tool"===a.role&&a.tool_call_id&&(c.toolCallId=a.tool_call_id),c}(f[a]),c=JSON.stringify(b).length;if(h.length>0&&i+c>1e5)break;h.push(b),i+=c}return h.reverse(),aP({id:c.conversationId||b,title:c.title||"Untitled Conversation",flowId:c.flowId||null,...c.status?{status:c.status}:{},createdAt:c.createdAt||0,updatedAt:c.updatedAt||0,totalMessages:f.length,...h.length<f.length?{note:`Returning the ${h.length} most recent of ${f.length} messages — raise "limit" to get more.`}:{},messages:h})}async function a8(a){let b=String(a?.command??"").trim();if(!b)return aP({error:'Provide "command": a shell command line to run.'},!0);let c=(0,O.ok)(),d="string"==typeof a?.cwd?a.cwd.trim():"",e=d?f().isAbsolute(d)?d:f().join(c,d):c,g=Math.min(1e3*("number"==typeof a?.timeout&&a.timeout>0?a.timeout:60),6e5);return await new Promise(a=>{let c,d,f="",i=!1,k=!1,l=!1,m=a=>{!i&&(f+=a).length>1e5&&(f=f.slice(0,1e5)+"\n…[output truncated]",i=!0)},n="win32"!==process.platform;try{c=(0,h.spawn)(b,{cwd:e,shell:!0,env:process.env,detached:n})}catch(b){a(aP({error:`Failed to start command: ${b instanceof Error?b.message:String(b)}`,cwd:e},!0));return}let o=setTimeout(()=>{l=!0,d=function(a,b=2e3){let c=a.pid;if(void 0===c)return()=>{};if("win32"===process.platform){try{(0,h.spawn)("taskkill",["/pid",String(c),"/T","/F"]).on("error",a=>j.debug(`taskkill failed for pid ${c}: ${a.message}`))}catch(a){j.debug(`taskkill spawn threw for pid ${c}: ${a instanceof Error?a.message:String(a)}`)}return()=>{}}try{process.kill(-c,"SIGTERM")}catch{}let d=setTimeout(()=>{try{process.kill(-c,"SIGKILL")}catch{}},b);return d.unref?.(),()=>clearTimeout(d)}(c)},g),p=b=>{k||(k=!0,clearTimeout(o),d?.(),a(b))};c.stdout?.on("data",a=>m(a.toString())),c.stderr?.on("data",a=>m(a.toString())),c.on("error",a=>{m(`
69
- ${a.message}`),p(aP({error:`Command failed to start: ${a.message}`,cwd:e,output:f},!0))}),c.on("close",a=>{if(l)return void p(aP({timedOut:!0,cwd:e,exitCode:a,output:`${f}
70
- [killed after ${g/1e3}s timeout]`},!0));p(aP({exitCode:a,cwd:e,output:f},0!==a))})})}async function a9(a,b,c){try{if(aJ.includes(b))return await aM(b,c);switch(b){case"execute_flow":return await aS(c);case"read_flow":return await aV(c);case"update_flow":return await aZ(c);case"list_flow_versions":return await aW(c);case"read_flow_version":return await aX(c);case"revert_flow":return await aY(c);case"delete_flow":return await aT(c);case"list_mcp_servers":return await a$(a);case"list_mcp_server_tools":return await a_(a,c);case"call_mcp_tool":return await a0(a,c);case"restart_mcp_server":return await a1(a,c);case"set_mcp_server_enabled":return await a2(a,c);case"list_models":return await a3();case"list_planned_executions":return await a4();case"run_planned_execution":return await a5(c);case"list_conversations":return await a6(c);case"read_conversation":return await a7(c);case"terminal":return await a8(c);default:return aP({error:`Unknown tool on the built-in FLUJO server: ${b}`},!0)}}catch(a){return aO.error("internalCallTool failed",{toolName:b,err:a}),aP({error:`Tool failed: ${a instanceof Error?a.message:String(a)}`},!0)}}}};
73
+ ${R}`,inputSchema:aM()},{name:"search_mcp_marketplace",description:"Search the public MCP server registry for new capabilities (voice, browsing, files, email, vision, …). The registry matches the query against server NAMES only (substring) — use short single terms and try several. Returns name, description, whether FLUJO can install it, and which env vars/keys it would require.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Short search term matched against server names."}},required:["query"]}},{name:"install_mcp_server",description:'Install an MCP server from the public registry (by the exact name returned by search_mcp_marketplace) and connect it — this DOWNLOADS AND RUNS a third-party package on the FLUJO host. Installs are gated by consent (SEP-1024): unless this trusted authoring tool is allowed via the mcpAutoInstall settings (trustBrainStem / requireConsent / namespaceAllowlist), the tool returns the exact resolved command + arguments with consentRequired=true INSTEAD of installing, and the caller must obtain explicit approval. Every attempt is written to an audit log (command, args, env NAMES, verification status — never secret values) before any spawn. Returns the FLUJO server name (reference it in FlowSpec "servers") and the tools it provides, or needsEnv when required keys are missing (supply values via the optional "env" argument), or the resolved plan when consent is required. First install can take minutes (package download).',inputSchema:{type:"object",properties:{name:{type:"string",description:'Exact registry name from search results, e.g. "ai.keenable/web-search".'},env:{type:"object",description:"Optional env var values for the server (e.g. required API keys).",additionalProperties:{type:"string"}}},required:["name"]}},{name:"install_best_mcp_server",description:"Install the BEST WORKING MCP server for a capability, unattended — the recommended way to acquire a capability when you don't already have a specific server name. Searches the registry, RANKS candidates by blended quality (GitHub stars + recent activity, npm weekly downloads, registry status), then installs best→worst until one actually boots and exposes tools (the \"works-gate\"): candidates that need unavailable keys, can't be installed, or start with zero tools are skipped automatically. Same consent/audit rules and third-party-code warning as install_mcp_server. Returns the installed server name + its tools and the list of candidates tried, or needsEnv/consentRequired. Prefer this over search+install for headless self-improvement; use install_mcp_server only when you must pin an exact server.",inputSchema:{type:"object",properties:{capability:{type:"string",description:'Short capability term matched against server names, e.g. "youtube", "email", "browser".'},env:{type:"object",description:"Optional env var values shared across attempted servers (e.g. an API key).",additionalProperties:{type:"string"}}},required:["capability"]}},{name:"execute_flow",description:"Run another FLUJO flow (by name or id) with the given input and return its final output. The run is ephemeral (no chat conversation is created). Use list_flow_building_blocks to see the available flows. Nested runs are limited in depth — a flow cannot recurse through itself indefinitely.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."},input:{type:"string",description:"The message to send to the flow as the user turn."}},required:["flow","input"]}},{name:"read_flow",description:"Read a FLUJO flow's full definition (by name or id): its nodes with their prompts, bound models, attached MCP servers/tools and input/output modes, plus the control and MCP edges. Note this is the COMPILED flow (node ids, not FlowSpec keys) — to change it, author a fresh FlowSpec and call update_flow.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."}},required:["flow"]}},{name:"update_flow",description:"REPLACE an existing FLUJO flow's definition (by name or id) with a newly compiled FlowSpec, keeping the flow's id — so planned executions, subflow nodes and conversations that reference it keep working. The spec format is the same as create_flow/validate_flow_spec (see those tool descriptions); saving is gated on zero validation errors. The replaced definition is archived automatically — list_flow_versions / revert_flow can restore it. Note that manual canvas edits made in the builder are part of what gets replaced. Use read_flow first to see what you are replacing.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id of the flow to replace."},spec:{type:"object",description:"The FlowSpec object (see the create_flow tool description for the format)."}},required:["flow","spec"]}},{name:"list_flow_versions",description:"List a flow's archived versions (by name or id), newest first. A version is created automatically whenever the flow's definition is overwritten (builder save, update_flow, revert_flow) and holds the definition that was replaced. Use read_flow_version to inspect one and revert_flow to restore one.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."}},required:["flow"]}},{name:"read_flow_version",description:"Read one archived version of a flow (see list_flow_versions): the full definition it held before it was replaced, in the same format as read_flow.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."},version:{type:"string",description:"The version id (see list_flow_versions)."}},required:["flow","version"]}},{name:"revert_flow",description:"Restore an archived version (see list_flow_versions) as the flow's CURRENT definition. The definition being reverted away from is archived first, so a revert can itself be undone. References by flow id keep working.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."},version:{type:"string",description:"The version id to restore (see list_flow_versions)."}},required:["flow","version"]}},{name:"delete_flow",description:"PERMANENTLY delete a FLUJO flow (by name or id). This cannot be undone — the flow's version history is deleted with it. Verify the target with list_flow_building_blocks first.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow name or flow id."}},required:["flow"]}},{name:"list_mcp_servers",description:"List the MCP servers configured in this FLUJO instance with their transport, enabled/disabled state and live connection status. Config details (env vars, headers, credentials) are never included.",inputSchema:{type:"object",properties:{}}},{name:"list_mcp_server_tools",description:"List the tools of one configured MCP server (name, description, input schema). Use together with call_mcp_tool for servers that are not bound to this flow.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name (see list_mcp_servers)."}},required:["server"]}},{name:"call_mcp_tool",description:"Call a tool on any configured MCP server by server name + tool name. This lets you use servers that are not bound to the current flow. Check the tool's input schema with list_mcp_server_tools first.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name."},tool:{type:"string",description:"The tool name on that server."},args:{type:"object",description:"Arguments for the tool (per its input schema)."},timeout:{type:"number",description:"Optional timeout in seconds."}},required:["server","tool"]}},{name:"restart_mcp_server",description:"Force-reconnect a configured MCP server (tears the connection down and rebuilds it). Useful when a server is in an error state after a config or environment change.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name."}},required:["server"]}},{name:"set_mcp_server_enabled",description:"Enable or disable a configured MCP server. Disabling disconnects it and prevents any further use; enabling connects it.",inputSchema:{type:"object",properties:{server:{type:"string",description:"The FLUJO server name."},enabled:{type:"boolean",description:"true to enable + connect, false to disable + disconnect."}},required:["server","enabled"]}},{name:"list_models",description:"List the models configured in this FLUJO instance (id, name, display name, description, provider, base URL, context window). API keys are never included. Reference models by id or name in FlowSpecs.",inputSchema:{type:"object",properties:{}}},{name:"list_planned_executions",description:"List the planned (scheduled/triggered) executions in this FLUJO instance with their trigger type, enabled state, armed status and last run outcome.",inputSchema:{type:"object",properties:{}}},{name:"run_planned_execution",description:"Fire a planned execution immediately (by id, see list_planned_executions) and return the run record with its output.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The planned execution id."}},required:["id"]}},{name:"update_planned_execution",description:'Modify an existing planned execution (by id or name, see list_planned_executions). Patch any of: "enabled" (turn the schedule on/off), "prompt" (the run prompt), "flowId" (the flow to run — accepts a flow name or id), "cron" (a convenience for the trigger\'s cron pattern — works for schedule / mcp-poll / url-watch triggers) or a full "trigger" object for complete control. Flow-driven cadence changes are clamped to a minimum interval (a runaway every-second schedule is rejected). The webhook secret token is never returned.',inputSchema:{type:"object",properties:{execution:{type:"string",description:"The planned execution id or name."},enabled:{type:"boolean",description:"Enable or disable the execution."},prompt:{type:"string",description:"The run prompt."},flowId:{type:"string",description:"The flow to run — a flow name or id (resolved to the flow id)."},cron:{type:"string",description:"Cron pattern (croner syntax; 6-field form for seconds) for the trigger's schedule. Applies to schedule / mcp-poll / url-watch triggers."},trigger:{type:"object",description:"Full trigger config object (escape hatch for complete control). Prefer the named fields above."}},required:["execution"]}},{name:"create_planned_execution",description:'Create a new planned execution: bind a flow to a trigger so it runs headlessly. Provide "name", "flow" (a flow name or id), an optional "prompt", optional "enabled" (default true), and EITHER a full "trigger" object OR a convenience "cron" (which creates a schedule trigger). Flow-driven cadence is clamped to a minimum interval. A webhook trigger\'s secret token is minted server-side and never returned.',inputSchema:{type:"object",properties:{name:{type:"string",description:"A name for the planned execution."},flow:{type:"string",description:"The flow to run — a flow name or id."},prompt:{type:"string",description:"The run prompt (may be empty)."},enabled:{type:"boolean",description:"Whether to arm the trigger immediately (default true)."},cron:{type:"string",description:'Cron pattern for a schedule trigger (convenience — use "trigger" for other trigger types).'},trigger:{type:"object",description:"Full trigger config object (schedule / webhook / file-watch / mcp-poll / url-watch)."}},required:["name","flow"]}},{name:"delete_planned_execution",description:"Permanently delete a planned execution (by id or name, see list_planned_executions), along with its run history. This cannot be undone.",inputSchema:{type:"object",properties:{execution:{type:"string",description:"The planned execution id or name."}},required:["execution"]}},{name:"list_conversations",description:"List the chat conversations stored in this FLUJO instance (id, title, bound flow, status, created/updated timestamps), newest first. Use read_conversation to get a transcript.",inputSchema:{type:"object",properties:{limit:{type:"number",description:"Optional maximum number of conversations to return (newest first). Default: all."}}}},{name:"read_conversation",description:'Read one chat conversation\'s transcript by conversation id (see list_conversations). Returns the displayed messages: system prompts are excluded, nested subflow steps carry a "depth" marker, assistant tool calls are summarized. Long conversations return only the most recent messages — raise "limit" to get more.',inputSchema:{type:"object",properties:{conversation:{type:"string",description:"The conversation id."},limit:{type:"number",description:"Maximum number of most-recent messages to return (default 50). The total transcript size is capped regardless."}},required:["conversation"]}},{name:"terminal",description:'Run a shell command on the FLUJO host and return its combined stdout/stderr plus exit code. Runs through a shell, so pipes and chained commands (e.g. "npm install && npm run build") work. Use it to install dependencies, build a cloned MCP server, inspect the filesystem, or run diagnostics. Working directory defaults to the FLUJO data directory (where cloned servers live under mcp-servers/); pass "cwd" to run elsewhere. The command is killed if it exceeds the timeout, and very large output is truncated.',inputSchema:{type:"object",properties:{command:{type:"string",description:'The shell command line to execute, e.g. "npm install && npm run build".'},cwd:{type:"string",description:"Optional working directory. Relative paths resolve against the FLUJO data directory. Defaults to the data directory."},timeout:{type:"number",description:"Optional timeout in seconds (default 60, max 600). The command is killed if it runs longer."}},required:["command"]}},{name:"kv_get",description:'Read a value from FLUJO\'s PERSISTENT key-value store (the ${kv:NAME} store) — state that survives ACROSS flow runs (loop counters, cursors, flags). Returns { found, value }. Defaults to the instance-global board; pass "scope" to target another board (e.g. a flow-folder board id). Values are plain strings, never secrets.',inputSchema:{type:"object",properties:{name:{type:"string",description:"The key to read (an identifier: letters, digits, _ and -, not starting with a digit)."},scope:{type:"string",description:'Optional board id to read from. Defaults to "global".'}},required:["name"]}},{name:"kv_set",description:'Write a value to FLUJO\'s PERSISTENT key-value store (the ${kv:NAME} store) — state that survives ACROSS flow runs. Last-write-wins. Defaults to the instance-global board; pass "scope" to target another board. Values are plain strings (never secrets — use ${global:} for those) and are size-capped; an oversized write is refused with { saved:false, skipped }.',inputSchema:{type:"object",properties:{name:{type:"string",description:"The key to write (an identifier: letters, digits, _ and -, not starting with a digit)."},value:{type:"string",description:"The string value to store."},scope:{type:"string",description:'Optional board id to write to. Defaults to "global".'}},required:["name","value"]}}]}async function aT(a){let b=await k.flowService.loadFlows();return b.find(b=>b.id===a)??b.find(b=>b.name===a)}async function aU(a){let b=String(a?.flow??"").trim();if(!b)return aR({error:'Provide "flow": a flow name or id.'},!0);let c=await aT(b);if(!c)return aR({error:`No flow named or with id "${b}". Use list_flow_building_blocks to see the available flows.`},!0);let d=global.__flujo_internal_flow_depth??0;if(d>=4)return aR({error:`execute_flow nesting limit (4) reached — refusing to start "${c.name}" to prevent runaway recursion.`},!0);global.__flujo_internal_flow_depth=d+1;try{let b=await (0,o.runFlow)({flowId:c.id,prompt:String(a?.input??""),mode:"ephemeral",flujo:!0,requireApproval:!1});if(b.flowNotFound)return aR({error:`Flow not found: ${b.flowNotFound.name}`},!0);if("error"===b.status)return aR({error:b.error?.message??"Unknown error during flow execution."},!0);return aR(b.outputText??"")}finally{global.__flujo_internal_flow_depth=d}}async function aV(a){let b=String(a?.flow??"").trim();if(!b)return aR({error:'Provide "flow": a flow name or id.'},!0);let c=await aT(b);if(!c)return aR({error:`No flow named or with id "${b}".`},!0);let d=await k.flowService.deleteFlow(c.id);return d.success?aR({deleted:!0,flowId:c.id,flowName:c.name}):aR({error:d.error??`Failed to delete flow "${c.name}".`},!0)}function aW(a){let b=a.nodes.map(a=>{let{mcpNodes:b,...c}=a.data?.properties??{};return{id:a.id,type:a.type,label:a.data?.label,...a.data?.description?{description:a.data.description}:{},properties:c}}),c=a.edges.map(a=>{let b=a.data;return{from:a.source,to:a.target,type:b?.edgeType==="mcp"?"mcp":b?.edgeType==="resource"?"resource":"control",...b?.bidirectional?{bidirectional:!0}:{}}});return{id:a.id,name:a.name,...a.description?{description:a.description}:{},nodes:b,edges:c}}async function aX(a){let b=String(a?.flow??"").trim();if(!b)return aR({error:'Provide "flow": a flow name or id.'},!0);let c=await aT(b);return c?aR({...aW(c),note:"This is the compiled flow (node ids, not FlowSpec keys). To change it, author a fresh FlowSpec and call update_flow — it replaces the whole definition while keeping this flow id."}):aR({error:`No flow named or with id "${b}". Use list_flow_building_blocks to see the available flows.`},!0)}async function aY(a){let b=String(a?.flow??"").trim();if(!b)return aR({error:'Provide "flow": a flow name or id.'},!0);let c=await aT(b);if(!c)return aR({error:`No flow named or with id "${b}".`},!0);let d=await k.flowService.listFlowVersions(c.id);return aR({flowId:c.id,flowName:c.name,versions:d,...0===d.length?{note:"No archived versions yet — versions appear once the flow's definition is overwritten for the first time."}:{}})}async function aZ(a){let b=String(a?.flow??"").trim(),c=String(a?.version??"").trim();if(!b||!c)return aR({error:'Provide "flow" (name or id) and "version" (see list_flow_versions).'},!0);let d=await aT(b);if(!d)return aR({error:`No flow named or with id "${b}".`},!0);let e=await k.flowService.getFlowVersion(d.id,c);return e?aR({versionId:e.versionId,savedAt:e.savedAt,...aW(e.flow)}):aR({error:`No version "${c}" of flow "${d.name}". Use list_flow_versions to see the archived versions.`},!0)}async function a$(a){let b=String(a?.flow??"").trim(),c=String(a?.version??"").trim();if(!b||!c)return aR({error:'Provide "flow" (name or id) and "version" (see list_flow_versions).'},!0);let d=await aT(b);if(!d)return aR({error:`No flow named or with id "${b}".`},!0);let e=await k.flowService.revertFlow(d.id,c);return e.success?aR({reverted:!0,flowId:d.id,versionId:c,note:"The definition that was just replaced has been archived too, so this revert can itself be undone via list_flow_versions / revert_flow."}):aR({error:e.error??`Failed to revert flow "${d.name}".`},!0)}async function a_(a){let b=String(a?.flow??"").trim();if(!b)return aR({error:'Provide "flow": the name or id of the flow to replace.'},!0);let c=function(a){let b=a?.spec;if("string"==typeof b)try{return JSON.parse(b)}catch{return null}return b??null}(a);if(!c)return aR({error:'Provide a "spec" argument: a FlowSpec object (or a JSON string of one).'},!0);let d=await aT(b);if(!d)return aR({error:`No flow named or with id "${b}". Use list_flow_building_blocks to see the available flows.`},!0);let e=await I(c,{save:!0,updateFlowId:d.id});return e.success?aR({flowId:e.flow.id,flowName:e.flow.name,nodeCount:e.flow.nodes.length,edgeCount:e.flow.edges.length,validation:e.validation,saved:e.saved,...e.saved?{note:`Flow "${e.flow.name}" was replaced (id ${e.flow.id} kept — existing references keep working).`}:{note:"NOT saved: validation found errors. The existing flow is unchanged. Fix the issues and call update_flow again."}},!e.saved):aR({error:e.error,issues:e.issues??[]},!0)}async function a0(a){let b=await a.loadServerConfigs();return Array.isArray(b)?aR(await Promise.all(b.map(async b=>{let c="unknown";try{c=(await a.getServerStatus(b.name)).status}catch(a){aQ.debug(`list_mcp_servers: getServerStatus failed for ${b.name}`,a)}return{name:b.name,transport:b.transport,enabled:!b.disabled,status:c,...b.builtIn?{builtIn:!0}:{}}}))):aR({error:b.error??"Failed to load server configs."},!0)}async function a1(a,b){let c=String(b?.server??"").trim();if(!c)return aR({error:'Provide "server": a FLUJO server name.'},!0);if(c===aP._)return aR(aS().map(a=>({name:a.name,description:a.description,inputSchema:a.inputSchema})));let{tools:d,error:e}=await a.listServerTools(c);return e?aR({error:e},!0):aR(d.map(a=>({name:a.name,description:a.description,inputSchema:a.inputSchema})))}async function a2(a,b){let c=String(b?.server??"").trim(),d=String(b?.tool??"").trim();if(!c||!d)return aR({error:'Provide "server" and "tool".'},!0);if(c===aP._)return aR({error:`"${aP._}" is this server — call its tools directly instead of through call_mcp_tool.`},!0);let e=b?.args&&"object"==typeof b.args&&!Array.isArray(b.args)?b.args:{},f="number"==typeof b?.timeout?b.timeout:void 0,g=await a.callTool(c,d,e,f);if(!g.success)return aR({error:g.error??`Tool call failed on ${c}.`},!0);let h=g.data;return h&&Array.isArray(h.content)?h:aR(h??{ok:!0})}async function a3(a,b){let c=String(b?.server??"").trim();if(!c)return aR({error:'Provide "server": a FLUJO server name.'},!0);if(c===aP._)return aR({ok:!0,note:`"${aP._}" is the built-in server — it is always running.`});let d=await a.forceReconnect(c);if(!d.success)return aR({error:d.error??`Failed to restart ${c}.`},!0);let e=await a.getServerStatus(c);return aR({restarted:!0,server:c,status:e.status})}async function a4(a,b){let c=String(b?.server??"").trim(),d=b?.enabled;if(!c||"boolean"!=typeof d)return aR({error:'Provide "server" (string) and "enabled" (boolean).'},!0);if(c===aP._)return aR({error:`The built-in "${aP._}" server cannot be disabled.`},!0);let e=await a.updateServerConfig(c,{disabled:!d});return"error"in e?aR({error:e.error},!0):aR({server:c,enabled:d})}async function a5(){return aR((await l.modelService.loadModels()).map(a=>({id:a.id,name:a.name,...a.displayName?{displayName:a.displayName}:{},...a.description?{description:a.description}:{},...a.provider?{provider:a.provider}:{},...a.baseUrl?{baseUrl:a.baseUrl}:{},...a.contextWindow?{contextWindow:a.contextWindow}:{}})))}async function a6(){return aR((await (0,m.z)().list()).map(({execution:a,status:b,lastRun:c})=>({id:a.id,name:a.name,enabled:a.enabled,flowId:a.flowId,triggerType:a.trigger?.type,armed:b?.armed??!1,...c?{lastRun:{status:c.status,firedAt:c.firedAt,...c.error?{error:c.error}:{}}}:{}})))}async function a7(a){let b=String(a?.id??"").trim();if(!b)return aR({error:'Provide "id": a planned execution id (see list_planned_executions).'},!0);let{record:c,error:d}=await (0,m.z)().runNow(b);return d||!c?aR({error:d??"Run failed."},!0):aR({runId:c.runId,status:c.status,firedAt:c.firedAt,...c.finishedAt?{finishedAt:c.finishedAt}:{},...c.outputText?{outputText:c.outputText}:{},...c.error?{error:c.error}:{}})}async function a8(a){let b=await (0,m.z)().list(),c=b.find(b=>b.execution.id===a),d=b.find(b=>b.execution.name===a);return(c??d)?.execution??null}function a9(a){return{id:a.id,name:a.name,enabled:a.enabled,flowId:a.flowId,triggerType:a.trigger?.type}}function ba(a,b){try{let c=(0,n.Z9)(a,b,5).map(a=>new Date(a).getTime()),d=1/0;for(let a=1;a<c.length;a++){let b=c[a]-c[a-1];b>0&&b<d&&(d=b)}return Number.isFinite(d)?d:null}catch{return null}}function bb(a){let b=null;return("schedule"===a.type||"url-watch"===a.type?a.cron&&(b=ba(a.cron,a.timezone)):"mcp-poll"===a.type&&(a.cron?b=ba(a.cron,a.timezone):"number"==typeof a.intervalMs&&(b=a.intervalMs)),null!==b&&b<6e4)?`Cadence too fast: the trigger would fire about every ${Math.round(b/1e3)}s, but flow-driven schedule changes are clamped to a minimum interval of 60s. Choose a slower cadence (change it from the Planned Executions page for a faster one).`:null}async function bc(a){let b,c=String(a?.execution??"").trim();if(!c)return aR({error:'Provide "execution": a planned execution id or name (see list_planned_executions).'},!0);let d=await a8(c);if(!d)return aR({error:`No planned execution with id or name "${c}". Use list_planned_executions to see them.`},!0);let e={};"boolean"==typeof a?.enabled&&(e.enabled=a.enabled),"string"==typeof a?.prompt&&(e.prompt=a.prompt);let f=String(a?.flowId??a?.flow??"").trim();if(f){let a=await aT(f);if(!a)return aR({error:`No flow named or with id "${f}". Use list_flow_building_blocks to see the flows.`},!0);e.flowId=a.id}a?.trigger&&"object"==typeof a.trigger&&!Array.isArray(a.trigger)&&(b=a.trigger);let g="string"==typeof a?.cron?a.cron.trim():"";if(g){let a=b??d.trigger;if("schedule"!==a.type&&"mcp-poll"!==a.type&&"url-watch"!==a.type)return aR({error:`The "${a.type}" trigger has no schedule to change with "cron". Pass a full "trigger" object instead.`},!0);b={...a,cron:g}}if(b){let a=bb(b);if(a)return aR({error:a},!0);e.trigger=b}if(0===Object.keys(e).length)return aR({error:"Nothing to update. Provide at least one of: enabled, prompt, flowId, cron, trigger."},!0);let h=await (0,m.z)().update(d.id,e);return h.error||!h.execution?aR({error:h.error??"Update failed."},!0):aR({updated:!0,...a9(h.execution)})}async function bd(a){let b,c=String(a?.name??"").trim();if(!c)return aR({error:'Provide "name": a name for the planned execution.'},!0);let d=String(a?.flow??a?.flowId??"").trim();if(!d)return aR({error:'Provide "flow": a flow name or id to run.'},!0);let e=await aT(d);if(!e)return aR({error:`No flow named or with id "${d}". Use list_flow_building_blocks to see the flows.`},!0);if(a?.trigger&&"object"==typeof a.trigger&&!Array.isArray(a.trigger))b=a.trigger;else{let c="string"==typeof a?.cron?a.cron.trim():"";if(!c)return aR({error:'Provide a "trigger" object or a "cron" pattern (which creates a schedule trigger).'},!0);b={type:"schedule",cron:c}}let f=bb(b);if(f)return aR({error:f},!0);let g={name:c,enabled:"boolean"!=typeof a?.enabled||a.enabled,flowId:e.id,prompt:"string"==typeof a?.prompt?a.prompt:"",trigger:b},h=await (0,m.z)().create(g);return h.error||!h.execution?aR({error:h.error??"Create failed."},!0):aR({created:!0,...a9(h.execution)})}async function be(a){let b=String(a?.execution??"").trim();if(!b)return aR({error:'Provide "execution": a planned execution id or name (see list_planned_executions).'},!0);let c=await a8(b);if(!c)return aR({error:`No planned execution with id or name "${b}". Use list_planned_executions to see them.`},!0);let d=await (0,m.z)().delete(c.id);return d.success?aR({deleted:!0,id:c.id,name:c.name}):aR({error:d.error??`Failed to delete "${c.name}".`},!0)}async function bf(a){let b,c=f().join((0,P.ok)(),"db","conversations");try{b=await g.promises.readdir(c)}catch(a){if("ENOENT"===a.code)return aR([]);return aR({error:`Failed to list conversations: ${a instanceof Error?a.message:String(a)}`},!0)}let d=(await Promise.all(b.filter(a=>a.endsWith(".json")).map(async a=>{try{let b=await g.promises.readFile(f().join(c,a),"utf-8"),d=JSON.parse(b),e=d.conversationId||a.replace(/\.json$/,""),h=d.status;return"running"===h&&0===O.$.currentSeq(e)&&(h="error"),{id:e,title:d.title||"Untitled Conversation",flowId:d.flowId||null,...h?{status:h}:{},createdAt:d.createdAt||0,updatedAt:d.updatedAt||0}}catch(b){return aQ.warn(`list_conversations: skipping unreadable conversation file ${a}`,b),null}}))).filter(a=>null!==a).sort((a,b)=>b.updatedAt-a.updatedAt),e="number"==typeof a?.limit&&a.limit>0?Math.floor(a.limit):void 0;return aR(e?d.slice(0,e):d)}async function bg(a){let b=String(a?.conversation??"").trim();if(!b)return aR({error:'Provide "conversation": a conversation id (see list_conversations).'},!0);await (0,L.u8)(b);let c=await N(b);if(!c)return aR({error:`No conversation with id "${b}". Use list_conversations to see the stored conversations.`},!0);let d=await (0,L.Os)(b),e=d?(0,L.cc)(d):[],f=e.length>0?e:(c.messages||[]).filter(a=>"system"!==a.role),g="number"==typeof a?.limit&&a.limit>0?Math.floor(a.limit):50,h=[],i=0;for(let a=f.length-1;a>=0&&h.length<g;a--){let b=function(a){let b="";"string"==typeof a.content?b=a.content:Array.isArray(a.content)&&(b=a.content.map(a=>"text"in a&&"string"==typeof a.text?a.text:"").filter(Boolean).join("\n"));let c={role:a.role,...b?{content:b}:{},...a.timestamp?{timestamp:a.timestamp}:{},...a.depth?{depth:a.depth}:{}};return"assistant"===a.role&&Array.isArray(a.tool_calls)&&a.tool_calls.length>0&&(c.toolCalls=a.tool_calls.map(a=>{let b="function"in a?a.function:void 0,c=b&&"string"==typeof b.arguments?b.arguments:void 0;return{id:a.id,...b?.name?{name:b.name}:{},...void 0!==c?{arguments:c.length>2e3?c.slice(0,2e3)+"…[truncated]":c}:{}}})),"tool"===a.role&&a.tool_call_id&&(c.toolCallId=a.tool_call_id),c}(f[a]),c=JSON.stringify(b).length;if(h.length>0&&i+c>1e5)break;h.push(b),i+=c}return h.reverse(),aR({id:c.conversationId||b,title:c.title||"Untitled Conversation",flowId:c.flowId||null,...c.status?{status:c.status}:{},createdAt:c.createdAt||0,updatedAt:c.updatedAt||0,totalMessages:f.length,...h.length<f.length?{note:`Returning the ${h.length} most recent of ${f.length} messages — raise "limit" to get more.`}:{},messages:h})}async function bh(a){let b=String(a?.command??"").trim();if(!b)return aR({error:'Provide "command": a shell command line to run.'},!0);let c=(0,P.ok)(),d="string"==typeof a?.cwd?a.cwd.trim():"",e=d?f().isAbsolute(d)?d:f().join(c,d):c,g=Math.min(1e3*("number"==typeof a?.timeout&&a.timeout>0?a.timeout:60),6e5);return await new Promise(a=>{let c,d,f="",i=!1,k=!1,l=!1,m=a=>{!i&&(f+=a).length>1e5&&(f=f.slice(0,1e5)+"\n…[output truncated]",i=!0)},n="win32"!==process.platform;try{c=(0,h.spawn)(b,{cwd:e,shell:!0,env:process.env,detached:n})}catch(b){a(aR({error:`Failed to start command: ${b instanceof Error?b.message:String(b)}`,cwd:e},!0));return}let o=setTimeout(()=>{l=!0,d=function(a,b=2e3){let c=a.pid;if(void 0===c)return()=>{};if("win32"===process.platform){try{(0,h.spawn)("taskkill",["/pid",String(c),"/T","/F"]).on("error",a=>j.debug(`taskkill failed for pid ${c}: ${a.message}`))}catch(a){j.debug(`taskkill spawn threw for pid ${c}: ${a instanceof Error?a.message:String(a)}`)}return()=>{}}try{process.kill(-c,"SIGTERM")}catch{}let d=setTimeout(()=>{try{process.kill(-c,"SIGKILL")}catch{}},b);return d.unref?.(),()=>clearTimeout(d)}(c)},g),p=b=>{k||(k=!0,clearTimeout(o),d?.(),a(b))};c.stdout?.on("data",a=>m(a.toString())),c.stderr?.on("data",a=>m(a.toString())),c.on("error",a=>{m(`
74
+ ${a.message}`),p(aR({error:`Command failed to start: ${a.message}`,cwd:e,output:f},!0))}),c.on("close",a=>{if(l)return void p(aR({timedOut:!0,cwd:e,exitCode:a,output:`${f}
75
+ [killed after ${g/1e3}s timeout]`},!0));p(aR({exitCode:a,cwd:e,output:f},0!==a))})})}let bi=/^[A-Za-z0-9_-]{1,64}$/,bj=/^[A-Za-z_][\w-]*$/;async function bk(a){let b="string"==typeof a.name?a.name.trim():"",c="string"==typeof a.scope&&a.scope.trim()?a.scope.trim():"global";if(!bj.test(b))return aR({error:'kv_get requires a valid "name" (letters, digits, _ and -, not starting with a digit).'},!0);if(!bi.test(c))return aR({error:`Invalid kv scope id: ${c}`},!0);let d=await (0,Q.M3)(c,b);return aR({scope:c,name:b,found:void 0!==d,value:d??null})}async function bl(a){let b="string"==typeof a.name?a.name.trim():"",c="string"==typeof a.scope&&a.scope.trim()?a.scope.trim():"global",d="string"==typeof a.value?a.value:null==a.value?"":String(a.value);if(!bj.test(b))return aR({error:'kv_set requires a valid "name" (letters, digits, _ and -, not starting with a digit).'},!0);if(!bi.test(c))return aR({error:`Invalid kv scope id: ${c}`},!0);let e=await (0,Q.or)(c,b,d);return"skipped"in e?aR({scope:c,name:b,saved:!1,skipped:e.skipped},!0):aR({scope:c,name:b,saved:!0,size:e.size})}async function bm(a,b,c){try{if(aL.includes(b))return await aO(b,c);switch(b){case"execute_flow":return await aU(c);case"read_flow":return await aX(c);case"update_flow":return await a_(c);case"list_flow_versions":return await aY(c);case"read_flow_version":return await aZ(c);case"revert_flow":return await a$(c);case"delete_flow":return await aV(c);case"list_mcp_servers":return await a0(a);case"list_mcp_server_tools":return await a1(a,c);case"call_mcp_tool":return await a2(a,c);case"restart_mcp_server":return await a3(a,c);case"set_mcp_server_enabled":return await a4(a,c);case"list_models":return await a5();case"list_planned_executions":return await a6();case"run_planned_execution":return await a7(c);case"update_planned_execution":return await bc(c);case"create_planned_execution":return await bd(c);case"delete_planned_execution":return await be(c);case"list_conversations":return await bf(c);case"read_conversation":return await bg(c);case"terminal":return await bh(c);case"kv_get":return await bk(c);case"kv_set":return await bl(c);default:return aR({error:`Unknown tool on the built-in FLUJO server: ${b}`},!0)}}catch(a){return aQ.error("internalCallTool failed",{toolName:b,err:a}),aR({error:`Tool failed: ${a instanceof Error?a.message:String(a)}`},!0)}}}};
@@ -1 +1 @@
1
- "use strict";exports.id=4671,exports.ids=[4671],exports.modules={84671:(a,b,c)=>{c.d(b,{nC:()=>l});var d=c(49181),e=c(45131),f=c(41527);function g(a){return a.data?.type??a.type??"unknown"}function h(a){return a.data?.label||a.id}function i(a){return a.data?.edgeType==="mcp"}function j(a){return a.data?.edgeType==="resource"}function k(a){return i(a)||j(a)}function l(a,b={}){let c=[],m=Array.isArray(a?.nodes)?a.nodes:[],n=Array.isArray(a?.edges)?a.edges:[],o=(a,b,d,e)=>c.push({severity:a,code:b,message:d,nodeId:e?.id,nodeLabel:e?h(e):void 0}),p=new Map((b.models??[]).map(a=>[a.id,a])),q=new Map((b.servers??[]).map(a=>[a.name,a])),r=!!b.models,s=!!b.servers,t=m.filter(a=>"start"===g(a)),u=m.filter(a=>"finish"===g(a)),v=m.filter(a=>"process"===g(a)),w=m.filter(a=>"mcp"===g(a));if(0===t.length)o("error","no-start-node","The flow has no Start node, so it has no entry point.");else if(t.length>1)for(let a of t.slice(1))o("error","multiple-start-nodes","The flow has more than one Start node; only one is allowed.",a);for(let a of(0===u.length&&o("warning","no-finish-node","The flow has no Finish node; it will run but never reaches a defined end."),v)){let b=a.data?.properties??{},c=b.boundModel;if(c){if(r&&!p.has(c)){let c="string"==typeof b.modelName&&b.modelName?` (was "${b.modelName}")`:"";o("error","process-model-missing",`Process node "${h(a)}" is bound to a model that no longer exists${c}.`,a)}}else o("error","process-missing-model",`Process node "${h(a)}" has no model bound.`,a)}for(let a of w){let b=(a.data?.properties??{}).boundServer;if(b){if(s&&!q.has(b))o("warning","mcp-server-missing",`MCP node "${h(a)}" is bound to server "${b}", which isn't in your current MCP server list. It may be offline (e.g. not connected), renamed, or removed — if it was renamed or removed, rebind this node.`,a);else if(s){let c=q.get(b);if(c.status&&"connected"!==c.status){let d="disabled"===c.status?"disabled":`not connected (${c.status})`;o("warning","mcp-server-disconnected",`MCP node "${h(a)}" is bound to server "${b}", which is currently ${d}. It will provide tools again once it reconnects.`,a)}}}else o("warning","mcp-missing-server",`MCP node "${h(a)}" is not bound to a server.`,a);n.some(b=>i(b)&&(b.source===a.id||b.target===a.id))||o("warning","mcp-node-unconnected",`MCP node "${h(a)}" is not connected to any Process node.`,a)}for(let a of m.filter(a=>"resource"===g(a))){let b=a.data?.properties??{},c="run"===b.scope?"run":"mcp",d="string"==typeof b.boundServer?b.boundServer:"",e="string"==typeof b.uri?b.uri:"",g="string"==typeof b.runName?b.runName.trim():"";"mcp"!==c||d&&e||o("warning","resource-missing-binding",`Resource node "${h(a)}" has no ${!d?"server":"resource URI"} bound; connected steps will receive nothing.`,a),"run"!==c||g||o("warning","resource-missing-binding",`Resource node "${h(a)}" is a run artifact with no name; give it a name so steps can produce/consume it.`,a),"run"===c&&g&&!(0,f.qW)(g)&&o("warning","resource-run-name",`Resource node "${h(a)}" is named "${g}", which is not a valid artifact name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with \${res:...}.`,a),"mcp"===c&&d&&s&&!q.has(d)&&o("warning","resource-server-missing",`Resource node "${h(a)}" is bound to server "${d}", which isn't in your current MCP server list.`,a);let i=n.filter(b=>j(b)&&(b.source===a.id||b.target===a.id));0===i.length&&o("warning","resource-node-unconnected",`Resource node "${h(a)}" is not connected to any Process node.`,a);let k=i.filter(b=>b.target===a.id);"mcp"===c&&k.length>0&&o("error","resource-produce-static",`Resource node "${h(a)}" is a static MCP resource, but a step writes INTO it. Only run artifacts (scope "run") can be produced by a step — flip the edge or make this a run artifact.`,a),"run"===c&&k.length>1&&o("warning","resource-multiple-producers",`Resource node "${h(a)}" is produced by ${k.length} steps; the last writer wins. Consider one producer per artifact.`,a),"run"===c&&0===k.length&&i.length>0&&o("warning","resource-consumed-never-produced",`Resource node "${h(a)}" is consumed but no step in this flow produces it; it resolves to nothing unless an earlier run captured it.`,a)}if(t.length>0){let a=function(a){let b=new Map,c=(a,c)=>{b.has(a)||b.set(a,[]),b.get(a).push(c)};for(let b of a)!k(b)&&(c(b.source,b.target),b.data?.bidirectional&&c(b.target,b.source));return b}(n);for(let b of t)a.get(b.id)?.length||o("error","start-no-outgoing","The Start node is not connected to anything; the flow cannot run.",b);let b=function(a,b){let c=new Set(a),d=[...a];for(;d.length;){let a=d.shift();for(let e of b.get(a)??[])c.has(e)||(c.add(e),d.push(e))}return c}(t.map(a=>a.id),a);for(let a of[...v,...u])b.has(a.id)||o("warning","unreachable-node",`${"finish"===g(a)?"Finish":"Process"} node "${h(a)}" is not reachable from the Start node.`,a)}for(let a of m.filter(a=>"subflow"===g(a))){let b=n.filter(b=>!k(b)&&(b.source===a.id||b.target===a.id&&!!b.data?.bidirectional));b.length>1&&o("error","subflow-multiple-outgoing",`Subflow node "${h(a)}" has ${b.length} outgoing connections; a subflow can only have one (either A > B > C or a bidirectional A <> B).`,a);let c=a.data?.properties??{},d="string"==typeof c.subflowId&&c.subflowId?c.subflowId:void 0,e=Array.isArray(c.parallelSubflowIds)?c.parallelSubflowIds.filter(a=>"string"==typeof a&&!!a):[];d&&e.length>0&&o("error","subflow-both-targets",`Subflow node "${h(a)}" sets both a single "subflowId" and "parallelSubflowIds"; use one or the other.`,a);let f=!0===c.mapOverList;if(f&&e.length>0&&o("error","subflow-map-and-parallel",`Subflow node "${h(a)}" combines "mapOverList" with "parallelSubflowIds"; map-over-list runs a single child once per item and cannot be combined with parallel fan-out.`,a),f&&!d&&0===e.length&&o("error","subflow-map-no-child",`Subflow node "${h(a)}" has "mapOverList" but no child flow ("subflowId"); select a flow to run once per item.`,a),e.length>0){let b=c.concurrencyLimit;"number"==typeof b&&b<1&&o("warning","subflow-concurrency-limit",`Subflow node "${h(a)}" has a concurrencyLimit of ${b}; it must be at least 1 (the runtime default will be used).`,a)}}{let a=new Map(m.map(a=>[a.id,a])),b=new Set;for(let c of n){if(k(c))continue;let d=c.data?.condition;if(!d||"object"!=typeof d)continue;let f=a.get(c.source),i=f?g(f):"unknown";if("process"!==i){o("error","edge-condition-non-process",`An edge leaving ${"unknown"===i?"an unknown":`the ${i}`} node "${f?h(f):c.source}" has a routing condition, but only process nodes can route on a condition.`,f??void 0);continue}b.add(c.source),(0,e.C)(d.kind)?"string"!=typeof d.value||0===d.value.length?o("warning","edge-condition-value",`Process node "${h(f)}" has an outgoing edge condition with no "value"; it will never match.`,f):"regex"!==d.kind||(0,e.wM)(d.value)||o("warning","edge-condition-regex",`Process node "${h(f)}" has an outgoing edge with a regex condition that does not compile; it will never match.`,f):o("warning","edge-condition-kind",`Process node "${h(f)}" has an outgoing edge whose condition kind "${String(d.kind)}" is unknown; it will never match.`,f)}for(let c of b){let b=a.get(c);b&&(n.some(a=>!k(a)&&(a.source===c?!a.data?.condition:!!(a.target===c&&a.data?.bidirectional)))||o("warning","edge-condition-no-fallback",`Process node "${h(b)}" has conditioned outgoing edges but no bare fallback edge; if no condition matches, the flow ends here.`,b))}}{let a=new Set;for(let b of m){let c=b.data?.properties?.captureVariable;if("string"==typeof c&&c.trim()){let d=c.trim();a.add(d),(0,f.qW)(d)||o("warning","capture-var-name",`${"subflow"===g(b)?"Subflow":"Process"} node "${h(b)}" captures into "${d}", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with \${var:...}.`,b)}}let b=["promptTemplate","isolatedPrompt"],c=new Set;for(let d of m){let e=d.data?.properties??{};for(let g of b){let b=e[g];if("string"==typeof b&&b)for(let e of(0,f.T9)(b)){if(a.has(e))continue;let b=`${d.id}:${e}`;c.has(b)||(c.add(b),o("warning","var-ref-uncaptured",`${h(d)} references \${var:${e}} but no step in this flow captures "${e}" (via captureVariable). It resolves to empty unless supplied as a run input — check for a typo or a step ordered after this one.`,d))}}}}for(let a of v){let c=a.data?.properties?.promptTemplate;if("string"!=typeof c||!c)continue;let e=function(a,b,c){let d=new Map(b.map(a=>[a.id,a])),e=new Set;for(let b of c){if(!i(b))continue;let c=null;if(b.source===a?c=b.target:b.target===a&&(c=b.source),!c)continue;let f=d.get(c);if(!f||"mcp"!==g(f))continue;let h=f.data?.properties?.boundServer;"string"==typeof h&&h&&e.add(h)}return e}(a.id,m,n),f=new Set;for(let g of(0,d.A$)(c)){if("handoff"===g.server)continue;let c=`${g.kind}:${g.server}:${g.name}`;!f.has(c)&&(f.add(c),e.has(g.server)?"tool"===g.kind&&b.serverTools&&b.serverTools[g.server]&&!b.serverTools[g.server].includes(g.name)&&o("warning","tool-unavailable",`Process node "${h(a)}" references tool "${g.name}" which server "${g.server}" no longer provides.`,a):o("error","tool-pill-disconnected",`Process node "${h(a)}" references ${g.kind} "${g.name}" from server "${g.server}", but it is not connected to that server (the MCP node was removed or the server was renamed).`,a))}}let x=c.filter(a=>"error"===a.severity).length,y=c.length-x;return{issues:c,errorCount:x,warningCount:y,isRunnable:0===x}}}};
1
+ "use strict";exports.id=4671,exports.ids=[4671],exports.modules={84671:(a,b,c)=>{c.d(b,{nC:()=>m});var d=c(49181),e=c(67512),f=c(41527),g=c(58505);function h(a){return a.data?.type??a.type??"unknown"}function i(a){return a.data?.label||a.id}function j(a){return a.data?.edgeType==="mcp"}function k(a){return a.data?.edgeType==="resource"}function l(a){return j(a)||k(a)}function m(a,b={}){let c=[],n=Array.isArray(a?.nodes)?a.nodes:[],o=Array.isArray(a?.edges)?a.edges:[],p=(a,b,d,e)=>c.push({severity:a,code:b,message:d,nodeId:e?.id,nodeLabel:e?i(e):void 0}),q=new Map((b.models??[]).map(a=>[a.id,a])),r=new Map((b.servers??[]).map(a=>[a.name,a])),s=!!b.models,t=!!b.servers,u=n.filter(a=>"start"===h(a)),v=n.filter(a=>"finish"===h(a)),w=n.filter(a=>"process"===h(a)),x=n.filter(a=>"mcp"===h(a));if(0===u.length)p("error","no-start-node","The flow has no Start node, so it has no entry point.");else if(u.length>1)for(let a of u.slice(1))p("error","multiple-start-nodes","The flow has more than one Start node; only one is allowed.",a);for(let a of(0===v.length&&p("warning","no-finish-node","The flow has no Finish node; it will run but never reaches a defined end."),w)){let b=a.data?.properties??{},c=b.boundModel;if(c){if(s&&!q.has(c)){let c="string"==typeof b.modelName&&b.modelName?` (was "${b.modelName}")`:"";p("error","process-model-missing",`Process node "${i(a)}" is bound to a model that no longer exists${c}.`,a)}}else p("error","process-missing-model",`Process node "${i(a)}" has no model bound.`,a)}for(let a of x){let b=(a.data?.properties??{}).boundServer;if(b){if(t&&!r.has(b))p("warning","mcp-server-missing",`MCP node "${i(a)}" is bound to server "${b}", which isn't in your current MCP server list. It may be offline (e.g. not connected), renamed, or removed — if it was renamed or removed, rebind this node.`,a);else if(t){let c=r.get(b);if(c.status&&"connected"!==c.status){let d="disabled"===c.status?"disabled":`not connected (${c.status})`;p("warning","mcp-server-disconnected",`MCP node "${i(a)}" is bound to server "${b}", which is currently ${d}. It will provide tools again once it reconnects.`,a)}}}else p("warning","mcp-missing-server",`MCP node "${i(a)}" is not bound to a server.`,a);o.some(b=>j(b)&&(b.source===a.id||b.target===a.id))||p("warning","mcp-node-unconnected",`MCP node "${i(a)}" is not connected to any Process node.`,a)}for(let a of n.filter(a=>"resource"===h(a))){let b=a.data?.properties??{},c="run"===b.scope?"run":"mcp",d="string"==typeof b.boundServer?b.boundServer:"",e="string"==typeof b.uri?b.uri:"",g="string"==typeof b.runName?b.runName.trim():"";"mcp"!==c||d&&e||p("warning","resource-missing-binding",`Resource node "${i(a)}" has no ${!d?"server":"resource URI"} bound; connected steps will receive nothing.`,a),"run"!==c||g||p("warning","resource-missing-binding",`Resource node "${i(a)}" is a run artifact with no name; give it a name so steps can produce/consume it.`,a),"run"===c&&g&&!(0,f.qW)(g)&&p("warning","resource-run-name",`Resource node "${i(a)}" is named "${g}", which is not a valid artifact name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with \${res:...}.`,a),"mcp"===c&&d&&t&&!r.has(d)&&p("warning","resource-server-missing",`Resource node "${i(a)}" is bound to server "${d}", which isn't in your current MCP server list.`,a);let h=o.filter(b=>k(b)&&(b.source===a.id||b.target===a.id));0===h.length&&p("warning","resource-node-unconnected",`Resource node "${i(a)}" is not connected to any Process node.`,a);let j=h.filter(b=>b.target===a.id);"mcp"===c&&j.length>0&&p("error","resource-produce-static",`Resource node "${i(a)}" is a static MCP resource, but a step writes INTO it. Only run artifacts (scope "run") can be produced by a step — flip the edge or make this a run artifact.`,a),"run"===c&&j.length>1&&p("warning","resource-multiple-producers",`Resource node "${i(a)}" is produced by ${j.length} steps; the last writer wins. Consider one producer per artifact.`,a),"run"===c&&0===j.length&&h.length>0&&p("warning","resource-consumed-never-produced",`Resource node "${i(a)}" is consumed but no step in this flow produces it; it resolves to nothing unless an earlier run captured it.`,a)}for(let a of n.filter(a=>"signal"===h(a))){let b=a.data?.properties??{};("string"==typeof b.topic?b.topic.trim():"")||p("warning","signal-missing-topic",`Signal node "${i(a)}" has no topic; it emits nothing. Give it a topic that a flow-event trigger can listen for.`,a)}if(u.length>0){let a=function(a){let b=new Map,c=(a,c)=>{b.has(a)||b.set(a,[]),b.get(a).push(c)};for(let b of a)!l(b)&&(c(b.source,b.target),b.data?.bidirectional&&c(b.target,b.source));return b}(o);for(let b of u)a.get(b.id)?.length||p("error","start-no-outgoing","The Start node is not connected to anything; the flow cannot run.",b);let b=function(a,b){let c=new Set(a),d=[...a];for(;d.length;){let a=d.shift();for(let e of b.get(a)??[])c.has(e)||(c.add(e),d.push(e))}return c}(u.map(a=>a.id),a);for(let a of[...w,...v])b.has(a.id)||p("warning","unreachable-node",`${"finish"===h(a)?"Finish":"Process"} node "${i(a)}" is not reachable from the Start node.`,a)}for(let a of n.filter(a=>"subflow"===h(a))){let b=o.filter(b=>!l(b)&&(b.source===a.id||b.target===a.id&&!!b.data?.bidirectional));b.length>1&&p("error","subflow-multiple-outgoing",`Subflow node "${i(a)}" has ${b.length} outgoing connections; a subflow can only have one (either A > B > C or a bidirectional A <> B).`,a);let c=a.data?.properties??{},d="string"==typeof c.subflowId&&c.subflowId?c.subflowId:void 0,e=Array.isArray(c.parallelSubflowIds)?c.parallelSubflowIds.filter(a=>"string"==typeof a&&!!a):[];d&&e.length>0&&p("error","subflow-both-targets",`Subflow node "${i(a)}" sets both a single "subflowId" and "parallelSubflowIds"; use one or the other.`,a);let g=!0===c.mapOverList;g&&e.length>0&&p("error","subflow-map-and-parallel",`Subflow node "${i(a)}" combines "mapOverList" with "parallelSubflowIds"; map-over-list runs a single child once per item and cannot be combined with parallel fan-out.`,a),g&&!d&&0===e.length&&p("error","subflow-map-no-child",`Subflow node "${i(a)}" has "mapOverList" but no child flow ("subflowId"); select a flow to run once per item.`,a);let h="string"==typeof c.parallelSubflowIdsVar?c.parallelSubflowIdsVar.trim():"";if(h&&((0,f.qW)(h)||p("warning","subflow-parallel-var-name",`Subflow node "${i(a)}" reads dynamic fan-out targets from "${h}", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to capture with \${var:...}.`,a),g&&p("error","subflow-map-and-parallel-var",`Subflow node "${i(a)}" combines "mapOverList" with dynamic fan-out ("parallelSubflowIdsVar"); map-over-list runs a single child once per item and cannot be combined with fan-out.`,a),n.some(a=>{let b=a.data?.properties?.captureVariable;return"string"==typeof b&&b.trim()===h})||p("warning","subflow-parallel-var-uncaptured",`Subflow node "${i(a)}" reads dynamic fan-out targets from variable "${h}", but no node captures it (captureVariable). It may be seeded by the caller; otherwise it resolves to no targets and the node falls back to its static parallel list.`,a)),e.length>0){let b=c.concurrencyLimit;"number"==typeof b&&b<1&&p("warning","subflow-concurrency-limit",`Subflow node "${i(a)}" has a concurrencyLimit of ${b}; it must be at least 1 (the runtime default will be used).`,a)}}{let a=new Map(n.map(a=>[a.id,a])),b=new Set;for(let c of o){if(l(c))continue;let d=c.data?.condition;if(!d||"object"!=typeof d)continue;let f=a.get(c.source),g=f?h(f):"unknown";if("process"!==g){p("error","edge-condition-non-process",`An edge leaving ${"unknown"===g?"an unknown":`the ${g}`} node "${f?i(f):c.source}" has a routing condition, but only process nodes can route on a condition.`,f??void 0);continue}b.add(c.source),(0,e.C)(d.kind)?"always"===d.kind||("string"!=typeof d.value||0===d.value.length?p("warning","edge-condition-value",`Process node "${i(f)}" has an outgoing edge condition with no "value"; it will never match.`,f):"regex"!==d.kind||(0,e.wM)(d.value)||p("warning","edge-condition-regex",`Process node "${i(f)}" has an outgoing edge with a regex condition that does not compile; it will never match.`,f)):p("warning","edge-condition-kind",`Process node "${i(f)}" has an outgoing edge whose condition kind "${String(d.kind)}" is unknown; it will never match.`,f)}for(let c of b){let b=a.get(c);b&&(o.some(a=>!l(a)&&(a.source===c?!a.data?.condition||"always"===a.data.condition.kind&&!a.data.condition.negate:!!(a.target===c&&a.data?.bidirectional)))||p("warning","edge-condition-no-fallback",`Process node "${i(b)}" has conditioned outgoing edges but no bare fallback edge; if no condition matches, the flow ends here.`,b))}}{let a=new Set;for(let b of n){let c=b.data?.properties?.captureVariable;if("string"==typeof c&&c.trim()){let d=c.trim();a.add(d),(0,f.qW)(d)||p("warning","capture-var-name",`${"subflow"===h(b)?"Subflow":"Process"} node "${i(b)}" captures into "${d}", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with \${var:...}.`,b)}}let b=["promptTemplate","isolatedPrompt"],c=new Set;for(let d of n){let e=d.data?.properties??{};for(let g of b){let b=e[g];if("string"==typeof b&&b)for(let e of(0,f.T9)(b)){if(a.has(e))continue;let b=`${d.id}:${e}`;c.has(b)||(c.add(b),p("warning","var-ref-uncaptured",`${i(d)} references \${var:${e}} but no step in this flow captures "${e}" (via captureVariable). It resolves to empty unless supplied as a run input — check for a typo or a step ordered after this one.`,d))}}}}{for(let a of n){let b=a.data?.properties?.captureKv;if("string"==typeof b&&b.trim()){let{key:c}=(0,g.g2)(b.trim());(0,g.ng)(c)||p("warning","capture-kv-name",`${"subflow"===h(a)?"Subflow":"Process"} node "${i(a)}" captures into kv "${b.trim()}", whose key is not a valid name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with \${kv:...}.`,a)}}let a=["promptTemplate","isolatedPrompt"],b=new Set;for(let c of n){let d=c.data?.properties??{};for(let e of a){let a=d[e];if("string"==typeof a&&a)for(let d of(0,g.pf)(a)){let{key:a}=(0,g.g2)(d);if((0,g.ng)(a))continue;let e=`${c.id}:${d}`;b.has(e)||(b.add(e),p("warning","kv-ref-name",`${i(c)} references \${kv:${d}}, whose key is not a valid name (letters, digits, _ and - only, not starting with a digit); it resolves to empty.`,c))}}}}for(let a of w){let c=a.data?.properties?.promptTemplate;if("string"!=typeof c||!c)continue;let e=function(a,b,c){let d=new Map(b.map(a=>[a.id,a])),e=new Set;for(let b of c){if(!j(b))continue;let c=null;if(b.source===a?c=b.target:b.target===a&&(c=b.source),!c)continue;let f=d.get(c);if(!f||"mcp"!==h(f))continue;let g=f.data?.properties?.boundServer;"string"==typeof g&&g&&e.add(g)}return e}(a.id,n,o),f=new Set;for(let g of(0,d.A$)(c)){if("handoff"===g.server)continue;let c=`${g.kind}:${g.server}:${g.name}`;!f.has(c)&&(f.add(c),e.has(g.server)?"tool"===g.kind&&b.serverTools&&b.serverTools[g.server]&&!b.serverTools[g.server].includes(g.name)&&p("warning","tool-unavailable",`Process node "${i(a)}" references tool "${g.name}" which server "${g.server}" no longer provides.`,a):p("error","tool-pill-disconnected",`Process node "${i(a)}" references ${g.kind} "${g.name}" from server "${g.server}", but it is not connected to that server (the MCP node was removed or the server was renamed).`,a))}}let y=c.filter(a=>"error"===a.severity).length,z=c.length-y;return{issues:c,errorCount:y,warningCount:z,isRunnable:0===y}}}};
@@ -0,0 +1 @@
1
+ "use strict";exports.id=472,exports.ids=[472],exports.modules={2560:(a,b,c)=>{c.d(b,{Xk:()=>e});var d=c(38301);function e(a,b){let[c,e]=(0,d.useState)(()=>b);return[c,(0,d.useCallback)(a=>{e(b=>"function"==typeof a?a(b):a)},[a])]}},7329:(a,b,c)=>{function d(a,b){let c=[],d=new Map;for(let e of a){let{key:a,label:f}=b(e),g=d.get(a);g||(g={key:a,label:f,items:[]},d.set(a,g),c.push(g)),g.items.push(e)}return c}function e(a){let b=(a??"").trim().charAt(0).toUpperCase();return b>="A"&&b<="Z"?{key:`letter:${b}`,label:b}:{key:"letter:#",label:"#"}}function f(a,b,c="Ungrouped"){let d=new Map,e=[];for(let c of a){let a=b(c)?.trim();if(a){let b=d.get(a);b?b.push(c):d.set(a,[c])}else e.push(c)}let g=Array.from(d.keys()).sort((a,b)=>a.localeCompare(b)).map(a=>({key:`folder:${a}`,label:a,items:d.get(a)}));return e.length>0&&g.push({key:"folder:__ungrouped__",label:c,items:e}),g}function g(a,b){let c=new Set;for(let d of a){let a=b(d)?.trim();a&&c.add(a)}return Array.from(c).sort((a,b)=>a.localeCompare(b))}c.d(b,{Az:()=>d,Je:()=>f,po:()=>e,yF:()=>g})},28055:(a,b,c)=>{c.d(b,{S:()=>g});var d=c(50648);let e=(0,c(19815).h)("frontend/services/mcp/index");class f{async loadServerConfigs(){try{let a=await fetch("/api/mcp/servers"),b=await a.json();if(!a.ok||b&&b.error){let a=b&&b.error||"Failed to load server configs";return e.warn("Failed to load server configs:",a),{error:a}}return b}catch(a){return e.warn("Failed to load server configs:",a),{error:"Failed to load server configs"}}}async listServerTools(a){try{let b=this.toolsCache.get(a),c=Date.now();if(b&&c-b.timestamp<this.CACHE_TTL)return e.debug(`Using cached tools for server ${a}`),{tools:b.tools};let d=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/tools`),f=await d.json();if(f.error)return e.warn(`Error listing tools for server ${a}:`,f.error),{tools:[],error:f.error};let g=Array.isArray(f.tools)?f.tools:[];return this.toolsCache.set(a,{tools:g,timestamp:c}),{tools:g}}catch(b){return e.warn(`Failed to list tools for server ${a}:`,b),{tools:[],error:`Failed to list tools: ${b instanceof Error?b.message:"Unknown error"}`}}}clearToolsCache(a){a?(this.toolsCache.delete(a),e.debug(`Cleared tools cache for server ${a}`)):(this.toolsCache.clear(),e.debug("Cleared all tools cache"))}async listServerResources(a){try{let b=this.resourcesCache.get(a),c=Date.now();if(b&&c-b.timestamp<this.CACHE_TTL)return e.debug(`Using cached resources for server ${a}`),b.data;let d=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/resources`),f=await d.json(),g={resources:Array.isArray(f.resources)?f.resources:[],resourceTemplates:Array.isArray(f.resourceTemplates)?f.resourceTemplates:[],error:f.error};return g.error||this.resourcesCache.set(a,{data:g,timestamp:c}),g}catch(b){return e.warn(`Failed to list resources for server ${a}:`,b),{resources:[],resourceTemplates:[],error:`Failed to list resources: ${b instanceof Error?b.message:"Unknown error"}`}}}async readResource(a,b){try{let c=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/resources/read?uri=${encodeURIComponent(b)}`);return await c.json()}catch(c){return e.warn(`Failed to read resource ${b} on server ${a}:`,c),{success:!1,error:"Failed to read resource"}}}async listServerPrompts(a){try{let b=this.promptsCache.get(a),c=Date.now();if(b&&c-b.timestamp<this.CACHE_TTL)return e.debug(`Using cached prompts for server ${a}`),{prompts:b.prompts};let d=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/prompts`),f=await d.json();if(f.error)return e.warn(`Error listing prompts for server ${a}:`,f.error),{prompts:[],error:f.error};let g=Array.isArray(f.prompts)?f.prompts:[];return this.promptsCache.set(a,{prompts:g,timestamp:c}),{prompts:g}}catch(b){return e.warn(`Failed to list prompts for server ${a}:`,b),{prompts:[],error:`Failed to list prompts: ${b instanceof Error?b.message:"Unknown error"}`}}}async getPrompt(a,b,c){try{let d=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/prompts/get`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,arguments:c})});return await d.json()}catch(c){return e.warn(`Failed to get prompt ${b} on server ${a}:`,c),{success:!1,error:"Failed to get prompt"}}}clearCapabilitiesCache(a){a?(this.resourcesCache.delete(a),this.promptsCache.delete(a)):(this.resourcesCache.clear(),this.promptsCache.clear())}async callTool(a,b,c,d){try{let e=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/tools/${encodeURIComponent(b)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({args:c,timeout:d})});return await e.json()}catch(c){return e.warn(`Failed to call tool ${b} on server ${a}:`,c),{error:"Failed to call tool"}}}async updateServerConfig(a,b){try{let c=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(c.ok)return e.info(`Successfully updated server config for ${a}`),{success:!0,data:d};if(void 0!==b.disabled)return e.info(`Config update for ${a} treated as success for toggle operation`),{success:!0,data:{...b,name:a},_originalError:d.error};return e.warn(`Failed to update server config for ${a}:`,d.error),{success:!1,error:d.error}}catch(b){return e.warn(`Failed to update server config for ${a}:`,b),{error:"Failed to update server config"}}}async testConnection(a){try{let b=await fetch("/api/mcp/test-connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return await b.json()}catch(b){return e.warn(`Failed to test connection for ${a.name}:`,b),{success:!1,error:`Failed to reach the FLUJO backend to run the connection test: ${b instanceof Error?b.message:"Unknown error"}`}}}async testConnectionStreaming(a,b){try{let c=await fetch("/api/mcp/test-connection/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok||!c.body)return e.warn(`Streaming test-connection unavailable (status ${c.status}); falling back`),this.testConnection(a);let f=null;if(await (0,d.z)(c,a=>{b(a),"result"===a.type&&(f={success:a.success,error:a.error,requiresAuthentication:a.requiresAuthentication,data:a.data})}),f)return f;return e.warn("Streaming test-connection ended without a result event"),{success:!1,error:"The connection test stream ended unexpectedly without a result."}}catch(b){return e.warn(`Streaming test connection failed for ${a.name}; falling back to non-streaming:`,b),this.testConnection(a)}}async getServerStatus(a){try{let b=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}/status`,{headers:{Accept:"application/json"}}),c=await b.json();if(c.error)return e.warn(`Error getting status for server ${a}:`,c.error),{status:"error",message:c.error};return c}catch(b){return e.warn(`Failed to get status for server ${a}:`,b),{status:"error",message:`Failed to get server status: ${b instanceof Error?b.message:"Unknown error"}`}}}async deleteServerConfig(a){try{let b=await fetch(`/api/mcp/servers/${encodeURIComponent(a)}`,{method:"DELETE"});return await b.json()}catch(b){return e.warn(`Failed to delete server config for ${a}:`,b),{error:"Failed to delete server config"}}}async retryServer(a){return e.debug(`Retrying server status for: ${a}`),this.getServerStatus(a)}async restartServer(a){e.debug(`Restarting server: ${a}`);try{let b=await this.updateServerConfig(a,{disabled:!0});if(b.error)return e.warn(`Failed to disable server ${a} during restart:`,b.error),{error:`Failed to restart server: ${b.error}`};await new Promise(a=>setTimeout(a,1e3));let c=await this.updateServerConfig(a,{disabled:!1});if(c.error)return e.warn(`Failed to enable server ${a} during restart:`,c.error),{error:`Failed to restart server: ${c.error}`};return e.info(`Successfully restarted server ${a}`),{success:!0}}catch(b){return e.warn(`Failed to restart server ${a}:`,b),{error:`Failed to restart server: ${b instanceof Error?b.message:"Unknown error"}`}}}constructor(){this.toolsCache=new Map,this.resourcesCache=new Map,this.promptsCache=new Map,this.CACHE_TTL=6e4}}let g=new f},50648:(a,b,c)=>{c.d(b,{z:()=>d});async function d(a,b){if(!a.body||"function"!=typeof a.body.getReader)throw Error("Response has no readable body to stream");let c=a.body.getReader(),d=new TextDecoder,e=function(){let a="",b=(a,b)=>{let c=a.trim();if(c)try{b.push(JSON.parse(c))}catch{}};return{push(c){let d;a+=c;let e=[];for(;(d=a.indexOf("\n"))>=0;)b(a.slice(0,d),e),a=a.slice(d+1);return e},flush(){let c=[];return b(a,c),a="",c}}}();try{for(;;){let{value:a,done:f}=await c.read();if(f)break;for(let c of e.push(d.decode(a,{stream:!0})))b(c)}let a=d.decode();if(a)for(let c of e.push(a))b(c);for(let a of e.flush())b(a)}finally{try{c.releaseLock()}catch{}}}},59737:(a,b,c)=>{c.d(b,{A:()=>m});var d=c(21124);c(38301);var e=c(60839),f=c(81637),g=c(44079),h=c(79515),i=c(41893),j=c(99561),k=c(17332),l=c(18467);let m=({label:a,count:b,expanded:c,onToggle:m,showFolderIcon:n=!1,children:o})=>{let p=(0,e.A)();return(0,d.jsxs)(f.default,{sx:{mb:1.5},children:[(0,d.jsxs)(f.default,{role:"button",tabIndex:0,"aria-expanded":c,onClick:m,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),m())},sx:{display:"flex",alignItems:"center",gap:1,px:1,py:.75,borderRadius:1,cursor:"pointer",userSelect:"none",backgroundColor:p.palette.background.default,border:`1px solid ${p.palette.divider}`,"&:hover":{backgroundColor:p.palette.action.hover}},children:[(0,d.jsx)(g.A,{size:"small","aria-label":c?"Collapse section":"Expand section",onClick:a=>{a.stopPropagation(),m()},sx:{transition:"transform 0.2s",transform:c?"rotate(0deg)":"rotate(-90deg)"},children:(0,d.jsx)(k.A,{fontSize:"small"})}),n&&(0,d.jsx)(l.A,{fontSize:"small",sx:{color:"text.secondary"}}),(0,d.jsx)(h.default,{variant:"subtitle2",sx:{fontWeight:600},children:a}),(0,d.jsx)(i.A,{label:b,size:"small",sx:{height:20,fontSize:"0.7rem"}})]}),(0,d.jsx)(j.A,{in:c,unmountOnExit:!0,children:(0,d.jsx)(f.default,{sx:{pt:1.5},children:o})})]})}},61615:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(21124);c(38301);var e=c(81637),f=c(8521);let g=({size:a="medium",color:b="primary",className:c="",sx:g={}})=>{let h="white"===b?{color:"#fff",...g}:g;return(0,d.jsxs)(e.default,{component:"span",sx:{display:"inline-block",lineHeight:0,...h},className:c,role:"status",children:[(0,d.jsx)(f.default,{size:{small:16,medium:24,large:36}[a],color:"white"===b?"inherit":b,"aria-hidden":"true"}),(0,d.jsx)(e.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..."})]})}},78352:(a,b,c)=>{c.d(b,{A:()=>u});var d=c(21124),e=c(38301),f=c(7118),g=c(94367),h=c(50553),i=c(84233),j=c(91059),k=c(40512),l=c(83899),m=c(52327),n=c(37674),o=c(19925),p=c(68730),q=c(36698),r=c(18467),s=c(31973),t=c(354);let u=({anchorEl:a,open:b,currentFolder:c,folders:u,onClose:v,onAssign:w})=>{let[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(""),B=a=>{w(a),v()},C=()=>{let a=z.trim();a&&(y(!1),B(a))};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(f.A,{anchorEl:a,open:b,onClose:v,children:[u.length>0&&u.map(a=>(0,d.jsxs)(g.A,{onClick:()=>B(a),selected:a===c,children:[(0,d.jsx)(h.A,{children:a===c?(0,d.jsx)(q.A,{fontSize:"small"}):(0,d.jsx)(r.A,{fontSize:"small"})}),(0,d.jsx)(i.A,{primary:a})]},a)),u.length>0&&(0,d.jsx)(j.A,{}),(0,d.jsxs)(g.A,{onClick:()=>{A(""),y(!0)},children:[(0,d.jsx)(h.A,{children:(0,d.jsx)(s.A,{fontSize:"small"})}),(0,d.jsx)(i.A,{primary:"New folder…"})]}),c&&(0,d.jsxs)(g.A,{onClick:()=>B(void 0),children:[(0,d.jsx)(h.A,{children:(0,d.jsx)(t.A,{fontSize:"small"})}),(0,d.jsx)(i.A,{primary:"Remove from folder"})]})]}),(0,d.jsxs)(k.A,{open:x,onClose:()=>y(!1),maxWidth:"xs",fullWidth:!0,children:[(0,d.jsx)(l.A,{children:"New folder"}),(0,d.jsx)(m.A,{children:(0,d.jsx)(n.A,{autoFocus:!0,margin:"dense",label:"Folder name",fullWidth:!0,value:z,onChange:a=>A(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),C())}})}),(0,d.jsxs)(o.A,{children:[(0,d.jsx)(p.A,{onClick:()=>y(!1),children:"Cancel"}),(0,d.jsx)(p.A,{variant:"contained",disabled:!z.trim(),onClick:C,children:"Create"})]})]})]})}},83434:(a,b,c)=>{c.d(b,{N:()=>e,X:()=>d}),(0,c(19815).h)("frontend/services/model");let d=()=>{throw Error("ModelService can only be used in browser environment")},e=new Proxy({},{get(a,b){let c=d(),e=c[b];return"function"==typeof e?e.bind(c):e}})}};