flujo-ai 3.33.0 → 3.34.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 (298) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +240 -240
  3. package/.next/app-path-routes-manifest.json +14 -14
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +21 -21
  6. package/.next/react-loadable-manifest.json +3 -3
  7. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_not-found.html +1 -1
  9. package/.next/server/app/_not-found.rsc +2 -2
  10. package/.next/server/app/api/approvals/[id]/route.js.nft.json +1 -1
  11. package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
  12. package/.next/server/app/api/approvals/route.js.nft.json +1 -1
  13. package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/backup/route.js.nft.json +1 -1
  15. package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/bugs/enhance/route.js.nft.json +1 -1
  18. package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/encryption/secure/route.js +1 -1
  21. package/.next/server/app/api/encryption/secure/route.js.nft.json +1 -1
  22. package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/api/flow/[id]/route.js.nft.json +1 -1
  25. package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/flow/[id]/versions/[versionId]/route.js.nft.json +1 -1
  27. package/.next/server/app/api/flow/[id]/versions/[versionId]/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/flow/[id]/versions/route.js.nft.json +1 -1
  29. package/.next/server/app/api/flow/[id]/versions/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/flow/compile/route.js +1 -1
  31. package/.next/server/app/api/flow/compile/route.js.nft.json +1 -1
  32. package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/flow/generate/route.js +1 -1
  34. package/.next/server/app/api/flow/generate/route.js.nft.json +1 -1
  35. package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/flow/generator/route.js +25 -4
  37. package/.next/server/app/api/flow/generator/route.js.nft.json +1 -1
  38. package/.next/server/app/api/flow/generator/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/flow/improve/route.js +1 -1
  40. package/.next/server/app/api/flow/improve/route.js.nft.json +1 -1
  41. package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/flow/prompt-renderer/route.js.nft.json +1 -1
  43. package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/flow/quick-chat/route.js.nft.json +1 -1
  45. package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/flow/repair/route.js +1 -1
  47. package/.next/server/app/api/flow/repair/route.js.nft.json +1 -1
  48. package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/flow/route.js.nft.json +1 -1
  50. package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/init/route.js +1 -1
  53. package/.next/server/app/api/init/route.js.nft.json +1 -1
  54. package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/mcp/app-sandbox/route_client-reference-manifest.js +1 -1
  59. package/.next/server/app/api/mcp/cancel/route.js.nft.json +1 -1
  60. package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/mcp/oauth-capability/route.js.nft.json +1 -1
  62. package/.next/server/app/api/mcp/oauth-capability/route_client-reference-manifest.js +1 -1
  63. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js.nft.json +1 -1
  64. package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/mcp/servers/[name]/prompts/route.js.nft.json +1 -1
  66. package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js.nft.json +1 -1
  68. package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/mcp/servers/[name]/resources/route.js.nft.json +1 -1
  70. package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
  71. package/.next/server/app/api/mcp/servers/[name]/route.js.nft.json +1 -1
  72. package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/mcp/servers/[name]/status/route.js.nft.json +1 -1
  74. package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js.nft.json +1 -1
  76. package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
  77. package/.next/server/app/api/mcp/servers/[name]/tools/route.js.nft.json +1 -1
  78. package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/mcp/servers/route.js.nft.json +1 -1
  80. package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/mcp/test-connection/route.js.nft.json +1 -1
  82. package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -1
  84. package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/mcp-registry/route.js.nft.json +1 -1
  86. package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/model/[id]/route.js.nft.json +1 -1
  89. package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/model/provider/route.js.nft.json +1 -1
  91. package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/model/route.js.nft.json +1 -1
  93. package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/model/test/route.js.nft.json +1 -1
  95. package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/oauth/reset/route.js.nft.json +1 -1
  99. package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/packages/build/route.js +1 -1
  101. package/.next/server/app/api/packages/build/route.js.nft.json +1 -1
  102. package/.next/server/app/api/packages/build/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/packages/derive-secrets/route.js.nft.json +1 -1
  104. package/.next/server/app/api/packages/derive-secrets/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/packages/install/route.js.nft.json +1 -1
  106. package/.next/server/app/api/packages/install/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/packages/install/status/route.js.nft.json +1 -1
  108. package/.next/server/app/api/packages/install/status/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/packages/installed/route.js.nft.json +1 -1
  110. package/.next/server/app/api/packages/installed/route_client-reference-manifest.js +1 -1
  111. package/.next/server/app/api/packages/resolve/route.js +1 -1
  112. package/.next/server/app/api/packages/resolve/route.js.nft.json +1 -1
  113. package/.next/server/app/api/packages/resolve/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/packages/scan-targets/route.js.nft.json +1 -1
  115. package/.next/server/app/api/packages/scan-targets/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/packages/search/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/packages/uninstall/route.js.nft.json +1 -1
  118. package/.next/server/app/api/packages/uninstall/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/planned-executions/[id]/route.js.nft.json +1 -1
  120. package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/planned-executions/[id]/run/route.js.nft.json +1 -1
  122. package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/planned-executions/[id]/runs/route.js.nft.json +1 -1
  124. package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
  125. package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/planned-executions/reconcile/route.js +1 -1
  127. package/.next/server/app/api/planned-executions/reconcile/route.js.nft.json +1 -1
  128. package/.next/server/app/api/planned-executions/reconcile/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/planned-executions/route.js +1 -1
  130. package/.next/server/app/api/planned-executions/route.js.nft.json +1 -1
  131. package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/registry/auth/resend/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/registry/auth/reset/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/registry/auth/route_client-reference-manifest.js +1 -1
  135. package/.next/server/app/api/registry/feedback/route.js +1 -1
  136. package/.next/server/app/api/registry/feedback/route_client-reference-manifest.js +1 -1
  137. package/.next/server/app/api/registry/oauth/callback/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/registry/oauth/initiate/route_client-reference-manifest.js +1 -1
  139. package/.next/server/app/api/registry/packages/route_client-reference-manifest.js +1 -1
  140. package/.next/server/app/api/registry/publish/route_client-reference-manifest.js +1 -1
  141. package/.next/server/app/api/registry/settings/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/restore/route.js.nft.json +1 -1
  143. package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/runs/active/route.js.nft.json +1 -1
  145. package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -1
  146. package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
  147. package/.next/server/app/api/telemetry/daily-active/route.js +1 -1
  148. package/.next/server/app/api/telemetry/daily-active/route_client-reference-manifest.js +1 -1
  149. package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  150. package/.next/server/app/api/waves/route.js +1 -1
  151. package/.next/server/app/api/waves/route.js.nft.json +1 -1
  152. package/.next/server/app/api/waves/route_client-reference-manifest.js +1 -1
  153. package/.next/server/app/api/webhooks/[id]/route.js +1 -1
  154. package/.next/server/app/api/webhooks/[id]/route.js.nft.json +1 -1
  155. package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
  156. package/.next/server/app/chat/page.js +1 -1
  157. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  158. package/.next/server/app/chat.html +1 -1
  159. package/.next/server/app/chat.rsc +3 -3
  160. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  161. package/.next/server/app/docs.html +1 -1
  162. package/.next/server/app/docs.rsc +2 -2
  163. package/.next/server/app/executions/page.js +2 -2
  164. package/.next/server/app/executions/page.js.nft.json +1 -1
  165. package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
  166. package/.next/server/app/executions.html +1 -1
  167. package/.next/server/app/executions.rsc +3 -3
  168. package/.next/server/app/flows/page.js +3 -3
  169. package/.next/server/app/flows/page.js.nft.json +1 -1
  170. package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
  171. package/.next/server/app/flows.html +1 -1
  172. package/.next/server/app/flows.rsc +3 -3
  173. package/.next/server/app/index.html +1 -1
  174. package/.next/server/app/index.rsc +3 -3
  175. package/.next/server/app/mcp/page.js +1 -1
  176. package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
  177. package/.next/server/app/mcp-flows/route.js +1 -1
  178. package/.next/server/app/mcp-flows/route.js.nft.json +1 -1
  179. package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
  180. package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
  181. package/.next/server/app/mcp-proxy/[server]/route.js.nft.json +1 -1
  182. package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
  183. package/.next/server/app/mcp.html +1 -1
  184. package/.next/server/app/mcp.rsc +3 -3
  185. package/.next/server/app/models/page.js +1 -1
  186. package/.next/server/app/models/page.js.nft.json +1 -1
  187. package/.next/server/app/models/page_client-reference-manifest.js +1 -1
  188. package/.next/server/app/packages/page.js +1 -1
  189. package/.next/server/app/packages/page_client-reference-manifest.js +1 -1
  190. package/.next/server/app/packages.html +1 -1
  191. package/.next/server/app/packages.rsc +3 -3
  192. package/.next/server/app/page.js +4 -2
  193. package/.next/server/app/page_client-reference-manifest.js +1 -1
  194. package/.next/server/app/settings/page.js +1 -1
  195. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  196. package/.next/server/app/settings.html +1 -1
  197. package/.next/server/app/settings.rsc +3 -3
  198. package/.next/server/app/v1/chat/completions/route.js.nft.json +1 -1
  199. package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
  200. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js.nft.json +1 -1
  201. package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
  202. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js.nft.json +1 -1
  203. package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
  204. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js.nft.json +1 -1
  205. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
  206. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js.nft.json +1 -1
  207. package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
  208. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js.nft.json +1 -1
  209. package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
  210. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js.nft.json +1 -1
  211. package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
  212. package/.next/server/app/v1/chat/conversations/[conversationId]/inject/route.js.nft.json +1 -1
  213. package/.next/server/app/v1/chat/conversations/[conversationId]/inject/route_client-reference-manifest.js +1 -1
  214. package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -1
  215. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js.nft.json +1 -1
  216. package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
  217. package/.next/server/app/v1/chat/conversations/[conversationId]/route.js.nft.json +1 -1
  218. package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
  219. package/.next/server/app/v1/chat/conversations/route.js.nft.json +1 -1
  220. package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
  221. package/.next/server/app/v1/chat/events/route.js.nft.json +1 -1
  222. package/.next/server/app/v1/chat/events/route_client-reference-manifest.js +1 -1
  223. package/.next/server/app/v1/models/route.js.nft.json +1 -1
  224. package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
  225. package/.next/server/app/waves/page_client-reference-manifest.js +1 -1
  226. package/.next/server/app/waves.html +1 -1
  227. package/.next/server/app/waves.rsc +2 -2
  228. package/.next/server/app-paths-manifest.json +14 -14
  229. package/.next/server/chunks/1114.js +1 -1
  230. package/.next/server/chunks/1226.js +1 -1
  231. package/.next/server/chunks/1227.js +1 -1
  232. package/.next/server/chunks/166.js +5 -5
  233. package/.next/server/chunks/1664.js +1 -1
  234. package/.next/server/chunks/227.js +1 -1
  235. package/.next/server/chunks/2273.js +1 -1
  236. package/.next/server/chunks/3717.js +1 -0
  237. package/.next/server/chunks/4466.js +1 -1
  238. package/.next/server/chunks/4551.js +1 -1
  239. package/.next/server/chunks/4771.js +1 -1
  240. package/.next/server/chunks/519.js +2 -0
  241. package/.next/server/chunks/5285.js +1 -0
  242. package/.next/server/chunks/5309.js +78 -0
  243. package/.next/server/chunks/544.js +4 -4
  244. package/.next/server/chunks/5463.js +1 -1
  245. package/.next/server/chunks/5544.js +4 -4
  246. package/.next/server/chunks/{5708.js → 6041.js} +1 -1
  247. package/.next/server/chunks/6747.js +42 -13
  248. package/.next/server/chunks/7628.js +1 -1
  249. package/.next/server/chunks/7630.js +11 -0
  250. package/.next/server/chunks/8284.js +42 -0
  251. package/.next/server/chunks/8645.js +1 -1
  252. package/.next/server/chunks/9235.js +25 -4
  253. package/.next/server/instrumentation.js.nft.json +1 -1
  254. package/.next/server/middleware-build-manifest.js +1 -1
  255. package/.next/server/middleware-manifest.json +1 -1
  256. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  257. package/.next/server/pages/404.html +1 -1
  258. package/.next/server/pages/500.html +1 -1
  259. package/.next/server/server-reference-manifest.js +1 -1
  260. package/.next/server/server-reference-manifest.json +1 -1
  261. package/.next/static/chunks/2005.4eea65c00d9a29cd.js +1 -0
  262. package/.next/static/chunks/3429-34fb1a84aed96703.js +1 -0
  263. package/.next/static/chunks/{2005-f9d38c39f10c321f.js → 4386-e9621d3c94969a68.js} +1 -1
  264. package/.next/static/chunks/4919-6c8a48e3cc642349.js +1 -0
  265. package/.next/static/chunks/7561-2b366ddcbc3cc0ec.js +1 -0
  266. package/.next/static/chunks/8404-5aa8ea49197b98b8.js +1 -0
  267. package/.next/static/chunks/{8650-41c2afc0eba37fb8.js → 8650-5294c6ed1173b014.js} +1 -1
  268. package/.next/static/chunks/app/chat/{page-1d100e5d974c919e.js → page-bc7807593b8b7394.js} +1 -1
  269. package/.next/static/chunks/app/executions/page-8296fd69c439ccee.js +1 -0
  270. package/.next/static/chunks/app/flows/page-87fb466e491fc068.js +1 -0
  271. package/.next/static/chunks/app/{layout-38b88f3b057f4852.js → layout-abed1f211e03152f.js} +1 -1
  272. package/.next/static/chunks/app/mcp/page-1648e6fde0c41461.js +1 -0
  273. package/.next/static/chunks/app/models/{page-808c0568ebc5e2c7.js → page-a5e2437356b06db8.js} +1 -1
  274. package/.next/static/chunks/app/packages/page-fba5696f33d9cdfb.js +1 -0
  275. package/.next/static/chunks/app/page-2f9da78a4891731a.js +1 -0
  276. package/.next/static/chunks/app/settings/page-2fc3a70bfd25c48b.js +1 -0
  277. package/.next/static/chunks/{webpack-dccb4f149ebdedcc.js → webpack-d5d737ff6a86674f.js} +1 -1
  278. package/.next/trace +10 -10
  279. package/README.md +16 -15
  280. package/package.json +5 -5
  281. package/.next/server/chunks/2985.js +0 -1
  282. package/.next/server/chunks/4366.js +0 -2
  283. package/.next/server/chunks/5040.js +0 -48
  284. package/.next/server/chunks/8187.js +0 -78
  285. package/.next/server/chunks/8851.js +0 -1
  286. package/.next/static/chunks/289-98f50bfcf833d661.js +0 -1
  287. package/.next/static/chunks/3089.df88f3b16898aad7.js +0 -1
  288. package/.next/static/chunks/8041-05830e887c133085.js +0 -1
  289. package/.next/static/chunks/8404-bfa9203e4296f3fb.js +0 -1
  290. package/.next/static/chunks/95-b9691d3cb15556dc.js +0 -1
  291. package/.next/static/chunks/app/executions/page-10ec7d58c7fbdd6f.js +0 -1
  292. package/.next/static/chunks/app/flows/page-9a78a2915268b2f8.js +0 -1
  293. package/.next/static/chunks/app/mcp/page-56b43b2f8752e9a5.js +0 -1
  294. package/.next/static/chunks/app/packages/page-af6ec89522915206.js +0 -1
  295. package/.next/static/chunks/app/page-30bf4293efa47a47.js +0 -1
  296. package/.next/static/chunks/app/settings/page-59ae1b658838f0bc.js +0 -1
  297. /package/.next/static/{jfb1GsjSGMjBmwfa3kM26 → Zz_Vh59XdtLIPcf-PxCpo}/_buildManifest.js +0 -0
  298. /package/.next/static/{jfb1GsjSGMjBmwfa3kM26 → Zz_Vh59XdtLIPcf-PxCpo}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8329],{15894:(e,t,l)=>{Promise.resolve().then(l.bind(l,94049)),Promise.resolve().then(l.bind(l,25635)),Promise.resolve().then(l.bind(l,24437)),Promise.resolve().then(l.bind(l,36552)),Promise.resolve().then(l.bind(l,43856)),Promise.resolve().then(l.bind(l,36982)),Promise.resolve().then(l.bind(l,94929))},22573:(e,t,l)=>{"use strict";l.d(t,{A:()=>p});var r=l(95155);l(12115);var a=l(33567),i=l(94049),n=l(41983),o=l(25635),s=l(28548),d=l(50430),c=l(63186),u=l(91665);let p=e=>{let{label:t,count:l,expanded:p,onToggle:m,showFolderIcon:h=!1,children:x}=e,f=(0,a.A)();return(0,r.jsxs)(i.default,{sx:{mb:1.5},children:[(0,r.jsxs)(i.default,{role:"button",tabIndex:0,"aria-expanded":p,onClick:m,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),m())},sx:{display:"flex",alignItems:"center",gap:1,px:1,py:.75,borderRadius:1,cursor:"pointer",userSelect:"none",backgroundColor:f.palette.background.default,border:"1px solid ".concat(f.palette.divider),"&:hover":{backgroundColor:f.palette.action.hover}},children:[(0,r.jsx)(n.A,{size:"small","aria-label":p?"Collapse section":"Expand section",onClick:e=>{e.stopPropagation(),m()},sx:{transition:"transform 0.2s",transform:p?"rotate(0deg)":"rotate(-90deg)"},children:(0,r.jsx)(c.A,{fontSize:"small"})}),h&&(0,r.jsx)(u.A,{fontSize:"small",sx:{color:"text.secondary"}}),(0,r.jsx)(o.default,{variant:"subtitle2",sx:{fontWeight:600},children:t}),(0,r.jsx)(s.A,{label:l,size:"small",sx:{height:20,fontSize:"0.7rem"}})]}),(0,r.jsx)(d.A,{in:p,unmountOnExit:!0,children:(0,r.jsx)(i.default,{sx:{pt:1.5},children:x})})]})}},36982:(e,t,l)=>{"use strict";l.d(t,{default:()=>o});var r=l(95155);l(12115);var a=l(94049),i=l(64598),n=l(23201);function o(e){let{storageKey:t,sx:l,threshold:o,deps:s,children:d}=e,{ref:c,showBackToTop:u,scrollToTop:p}=(0,i.R)(t,{threshold:o,deps:s});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.default,{ref:c,sx:{...l,overflow:"auto"},children:d}),(0,r.jsx)(n.A,{show:u,onClick:p})]})}},38459:(e,t,l)=>{"use strict";l.d(t,{Az:()=>a,FM:()=>r,Je:()=>n,po:()=>i,yF:()=>o});let r="folder";function a(e,t){let l=[],r=new Map;for(let a of e){let{key:e,label:i}=t(a),n=r.get(e);n||(n={key:e,label:i,items:[]},r.set(e,n),l.push(n)),n.items.push(a)}return l}function i(e){let t=(null!=e?e:"").trim().charAt(0).toUpperCase();return t>="A"&&t<="Z"?{key:"letter:".concat(t),label:t}:{key:"letter:#",label:"#"}}function n(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Ungrouped",r=new Map,a=[];for(let l of e){var i;let e=null==(i=t(l))?void 0:i.trim();if(e){let t=r.get(e);t?t.push(l):r.set(e,[l])}else a.push(l)}let n=Array.from(r.keys()).sort((e,t)=>e.localeCompare(t)).map(e=>({key:"folder:".concat(e),label:e,items:r.get(e)}));return a.length>0&&n.push({key:"folder:__ungrouped__",label:l,items:a}),n}function o(e,t){let l=new Set;for(let a of e){var r;let e=null==(r=t(a))?void 0:r.trim();e&&l.add(e)}return Array.from(l).sort((e,t)=>e.localeCompare(t))}},43856:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>ei});var r=l(95155),a=l(12115),i=l(20063),n=l(2300),o=l(94049),s=l(9562),d=l(56422),c=l(91871),u=l(22003),p=l(86946),m=l(51611),h=l(74879),x=l(33567),f=l(4474),v=l(33077),g=l(25635),b=l(41983),y=l(36314),A=l(86973),j=l(49501),k=l(17681),C=l(21067),w=l(64419),S=l(28466),T=l(45587),U=l(81952),L=l(94885),N=l(15686),M=l(91665),P=l(61267),I=l(22573),O=l(38459),K=l(97104),F=l(48072),W=l(87021);let z=(0,W.h)("frontend/components/models/list/ModelList"),B=e=>{let{models:t,isLoading:l,onAdd:i,onUpdate:s,onDelete:d,folders:c=[],onSetFolder:u,onToggleFavorite:p}=e,m=(0,x.A)(),[h,W]=(0,K.Xk)("flujo-ui:models:sort","name-asc"),[B,E]=(0,K.Xk)("flujo-ui:models:group",O.FM),[D,R]=(0,a.useState)(null),[_,q]=(0,a.useState)(null),[X,G]=(0,K.Xk)("flujo-ui:models:collapsed",[]),J=(0,a.useMemo)(()=>new Set(X),[X]),Z=e=>{W(e),R(null)},$=e=>{E(e),q(null)},H=async e=>{let t=await s(e);t.success||z.error("Failed to update model in ModelList",t.error)},V=(0,a.useMemo)(()=>(0,F.CR)(t,h),[t,h]),Y=(0,a.useMemo)(()=>"folder"===B?(0,O.Je)(V,e=>e.folder):"sort"===B?(0,O.Az)(V,e=>(0,F.eZ)(e,h)):[],[B,V,h]);if(l)return(0,r.jsx)(o.default,{display:"flex",justifyContent:"center",py:4,children:(0,r.jsx)(f.default,{})});let Q=e=>(0,r.jsx)(v.Ay,{container:!0,spacing:2,children:e.map(e=>(0,r.jsx)(v.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,r.jsx)(P.A,{model:e,onEdit:()=>H(e),onDelete:()=>d(e.id),folder:e.folder,folders:c,onSetFolder:u?t=>u(e.id,t):void 0,onToggleFavorite:p})},e.id))});return(0,r.jsxs)(o.default,{children:[(0,r.jsx)(n.A,{elevation:1,sx:{mb:2,p:1},children:(0,r.jsxs)(o.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[(0,r.jsxs)(g.default,{variant:"body2",color:"textSecondary",children:[t.length," model",1===t.length?"":"s",(0,r.jsx)(o.default,{component:"span",sx:{mx:1,opacity:.5},children:"\xb7"}),"Sorted by: ",F.fC[h]]}),(0,r.jsxs)(o.default,{sx:{display:"flex",gap:1,alignItems:"center"},children:[(0,r.jsx)(b.A,{size:"small",onClick:e=>q(e.currentTarget),color:"none"!==B?"primary":"default",sx:{border:"1px solid ".concat(m.palette.divider),backgroundColor:m.palette.background.default},title:"Group cards",children:(0,r.jsx)(L.A,{fontSize:"small"})}),(0,r.jsx)(b.A,{size:"small",onClick:e=>R(e.currentTarget),sx:{border:"1px solid ".concat(m.palette.divider),backgroundColor:m.palette.background.default},title:"Sort models",children:(0,r.jsx)(w.A,{fontSize:"small"})})]})]})}),t&&0!==t.length?"none"===B?Q(V):Y.map(e=>(0,r.jsx)(I.A,{label:e.label,count:e.items.length,expanded:!J.has(e.key),onToggle:()=>(e=>{G(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])})(e.key),showFolderIcon:"folder"===B,children:Q(e.items)},e.key)):(0,r.jsx)(o.default,{textAlign:"center",py:4,children:"No models found"}),(0,r.jsxs)(y.A,{anchorEl:_,open:!!_,onClose:()=>q(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,r.jsxs)(A.A,{selected:"none"===B,onClick:()=>$("none"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(N.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"No grouping"})]}),(0,r.jsxs)(A.A,{selected:"folder"===B,onClick:()=>$("folder"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(M.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"By folder"})]}),(0,r.jsxs)(A.A,{selected:"sort"===B,onClick:()=>$("sort"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(L.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"By sort setting"})]})]}),(0,r.jsxs)(y.A,{anchorEl:D,open:!!D,onClose:()=>R(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,r.jsxs)(A.A,{selected:"name-asc"===h,onClick:()=>Z("name-asc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(S.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"Name (A-Z)"})]}),(0,r.jsxs)(A.A,{selected:"name-desc"===h,onClick:()=>Z("name-desc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(S.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,r.jsx)(k.A,{primary:"Name (Z-A)"})]}),(0,r.jsx)(C.A,{}),(0,r.jsxs)(A.A,{selected:"provider"===h,onClick:()=>Z("provider"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(T.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"Provider"})]}),(0,r.jsx)(C.A,{}),(0,r.jsxs)(A.A,{selected:"context-desc"===h,onClick:()=>Z("context-desc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(U.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"Context (largest)"})]}),(0,r.jsxs)(A.A,{selected:"context-asc"===h,onClick:()=>Z("context-asc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(U.A,{fontSize:"small",sx:{transform:"scaleY(-1)"}})}),(0,r.jsx)(k.A,{primary:"Context (smallest)"})]})]})]})};var E=l(2778),D=l(52363),R=l(65036),_=l(52641),q=l(95436),X=l(55606),G=l(63109),J=l(75912),Z=l(12857),$=l(48363),H=l(9164),V=l(95480),Y=l(88107),Q=l(52397),ee=l(43076);let et=(0,W.h)("frontend/components/models/modal"),el=e=>{var t,l,n,d,p,m;let{open:h,model:x,onSave:y,onClose:j}=e,k=(0,i.useRouter)(),{globalEnvVars:C}=(0,H.useStorage)(),[w,S]=(0,a.useState)({}),[T,U]=(0,a.useState)({}),[L,N]=(0,a.useState)(null),[M,P]=(0,a.useState)(!1),[I,O]=(0,a.useState)(null),[K,F]=(0,a.useState)(!1),[W,z]=(0,a.useState)([]),[B,el]=(0,a.useState)(!1),er=(0,a.useRef)(null),ea=(0,a.useRef)(null);(0,a.useEffect)(()=>{h&&z([])},[h]),(0,a.useEffect)(()=>{w.baseUrl&&(et.debug("Base URL or API Key changed",{baseUrl:w.baseUrl}),z([]))},[w.baseUrl,w.ApiKey]),(0,a.useEffect)(()=>(ea.current&&clearTimeout(ea.current),w.baseUrl&&(ea.current=setTimeout(()=>{et.debug("Debounced fetchModels triggered",{name:w.name,baseUrl:w.baseUrl,searchTerm:w.name?'"'.concat(w.name,'"'):"none"}),ei(w.baseUrl,w.name)},100)),()=>{ea.current&&clearTimeout(ea.current)}),[w.name,w.baseUrl]),(0,a.useEffect)(()=>()=>{ea.current&&clearTimeout(ea.current)},[]);let ei=async(e,t)=>{et.debug("fetchModels called",{baseUrl:e,searchTerm:t?'"'.concat(t,'"'):"none",apiKey:w.ApiKey?"present":"not present",isApiKeyBound:M}),el(!0),U({});try{let l=M&&I?"${global:".concat(I,"}"):w.ApiKey&&w.ApiKey!==Q.RJ?w.ApiKey:void 0,r=await ee.N.fetchProviderModels(e,x.id,t,l);et.debug("Models fetched successfully",{count:null==r?void 0:r.length,searchTerm:t?'"'.concat(t,'"'):"none"}),Array.isArray(r)?(z(r),et.info("Models set in state",{count:r.length,searchTerm:t?'"'.concat(t,'"'):"none"})):(et.warn("Unexpected API response format",{models:r}),z([]))}catch(l){et.warn("Error fetching models",{baseUrl:e,searchTerm:t,error:l}),z([])}finally{el(!1)}};(0,a.useEffect)(()=>{if(h){S({...x,displayName:x.displayName||x.name});let e=(x.ApiKey||"").match(/\$\{global:([^}]+)\}/);e?(P(!0),O(e[1])):(P(!1),O(null),S(e=>({...e,ApiKey:x.name?Q.RJ:""})))}else S({name:"",displayName:"",description:"",ApiKey:"",baseUrl:"https://api.openai.com/v1",provider:"openai",adapter:"openai",promptTemplate:"",temperature:"0.0"}),P(!1),O(null);U({}),N(null)},[h,x]);let en=(0,Y.T_)(w.provider,w.adapter),eo=(0,Y.g3)(w.provider,w.adapter,w.name),es=(e,t)=>{S(l=>({...l,[e]:t})),U(t=>({...t,[e]:""}))},ed=async e=>{var t,l,r,a,i,n;e.preventDefault();let o={};if((null==(t=w.name)?void 0:t.trim())||(o.name="Name is required"),(null==(l=w.displayName)?void 0:l.trim())||(o.displayName="Display Name is required"),eo.creativity&&(null==(r=w.temperature)?void 0:r.trim())){let e=Number(w.temperature);(!Number.isFinite(e)||e<eo.creativity.min||e>eo.creativity.max)&&(o.temperature="Creativity must be between ".concat(eo.creativity.min," and ").concat(eo.creativity.max))}if(M||(null==(a=w.ApiKey)?void 0:a.trim())||"codex-cli"===en.adapter||(o.ApiKey="API key is required"),Object.keys(o).length>0)return void U(o);try{let e=await y({id:x.id,name:w.name,displayName:w.displayName,description:w.description,ApiKey:w.ApiKey,baseUrl:w.baseUrl,provider:w.provider,adapter:w.adapter||"openai",promptTemplate:w.promptTemplate,temperature:eo.creativity?w.temperature:void 0,reasoningEffort:(null==(i=eo.effortLevels)?void 0:i.includes(w.reasoningEffort))?w.reasoningEffort:void 0,thinkingLevel:(null==(n=eo.thinkingLevels)?void 0:n.includes(w.thinkingLevel))?w.thinkingLevel:void 0,thinkingBudget:eo.thinkingBudget?w.thinkingBudget:void 0,serviceTier:eo.priority?w.serviceTier||"default":void 0,contextWindow:w.contextWindow,maxTurns:w.maxTurns,maxTokens:eo.maxOutputTokens?w.maxTokens:void 0});e.success?k.refresh():U({submit:e.error||"Failed to save model"})}catch(e){et.error("Failed to save model",{error:e}),U({submit:(null==e?void 0:e.message)||"Failed to save model"})}};return(0,r.jsx)(E.A,{open:h,onClose:j,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:(0,r.jsxs)("form",{onSubmit:ed,children:[(0,r.jsx)(D.A,{children:x?"Edit Model":"Add Model"}),(0,r.jsxs)(R.A,{sx:{display:"flex",flexDirection:"column",height:"calc(90vh - 130px)"},children:[T.submit&&(0,r.jsx)(u.A,{severity:"error",sx:{mb:2},children:T.submit}),L&&(0,r.jsx)(u.A,{severity:"info",sx:{mb:2},children:L}),(0,r.jsxs)(v.Ay,{container:!0,spacing:2,sx:{flexGrow:1},children:[(0,r.jsx)(v.Ay,{item:!0,xs:6,sx:{height:"100%"},children:(0,r.jsxs)(o.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pr:2,overflowY:"auto"},children:[(0,r.jsx)(g.default,{variant:"h6",gutterBottom:!0,children:"Model Configuration"}),(0,r.jsx)(s.A,{autoFocus:!0,margin:"dense",label:"Display Name",fullWidth:!0,required:!0,value:w.displayName||"",onChange:e=>es("displayName",e.target.value),error:!!T.displayName,helperText:T.displayName||"The name shown in the UI"}),(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"provider-profile-label",children:"Provider"}),(0,r.jsx)(X.A,{labelId:"provider-profile-label",label:"Provider",value:en.id,onChange:e=>(e=>{let t=Y.xx.find(t=>t.id===e);t&&(S(e=>({...e,provider:t.provider,adapter:t.adapter,baseUrl:t.baseUrl})),U(e=>({...e,baseUrl:""})))})(e.target.value),children:Y.xx.map(e=>(0,r.jsx)(A.A,{value:e.id,children:e.label},e.id))})]}),(0,r.jsxs)(g.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mb:1,display:"block"},children:["Uses the ",(0,r.jsx)("strong",{children:en.sdkLabel}),"claude-cli"===en.adapter?". Paste an OAuth token from `claude setup-token` into the API Key field.":"codex-cli"===en.adapter?". Paste an OpenAI API key — or leave it empty to use your ChatGPT plan via `codex login`.":""]}),en.showBaseUrl&&(0,r.jsx)(s.A,{margin:"dense",label:"Base URL",fullWidth:!0,value:w.baseUrl||"",onChange:e=>es("baseUrl",e.target.value),helperText:"Endpoint for the OpenAI-compatible API."}),(0,r.jsx)(o.default,{sx:{position:"relative",mt:1,mb:1},children:(0,r.jsx)(s.A,{margin:"dense",label:"API Key",fullWidth:!0,required:!M&&"codex-cli"!==en.adapter,type:M?"text":"password",value:w.ApiKey||"",onChange:e=>es("ApiKey",e.target.value),error:!!T.ApiKey,helperText:T.ApiKey||("codex-cli"===en.adapter?"Optional — leave empty to use your ChatGPT plan (codex login)":"API key is required for this provider"),InputProps:{readOnly:M,endAdornment:(0,r.jsx)(o.default,{sx:{display:"flex",alignItems:"center"},children:M?(0,r.jsx)(b.A,{onClick:()=>{P(!1),O(null),S(e=>({...e,ApiKey:""}))},size:"small",title:"Unbind from global variable",children:(0,r.jsx)(Z.A,{})}):(0,r.jsx)(b.A,{onClick:()=>{F(!0)},size:"small",title:"Bind to global variable",children:(0,r.jsx)($.A,{})})})}})}),(0,r.jsx)(G.A,{freeSolo:!0,loading:B,options:en.showBaseUrl?W.map(e=>e.id):null!=(t=en.defaultModels)?t:[],value:w.name||"",onChange:(e,t)=>{es("name",t||"")},onInputChange:(e,t)=>{es("name",t)},filterOptions:(e,t)=>{let l=t.inputValue.toLowerCase();return l?e.filter(e=>{let t=e.toLowerCase();if(t.includes(l))return!0;let r=0,a=0;for(;r<t.length&&a<l.length;)t[r]===l[a]&&a++,r++;return a===l.length}):e},ListboxProps:{style:{maxHeight:"300px",overflow:"auto"}},renderInput:e=>(0,r.jsx)(s.A,{...e,margin:"dense",label:"Technical Name",required:!0,error:!!T.name,helperText:T.name||"Used for API calls to the LLM. Type to search available models.",InputProps:{...e.InputProps,endAdornment:(0,r.jsxs)(r.Fragment,{children:[B?(0,r.jsx)(f.default,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}}),renderOption:(e,t)=>{let l=W.find(e=>e.id===t),{key:a,...i}=e;return(0,r.jsx)("li",{...i,style:{borderBottom:"1px solid rgba(0,0,0,0.1)",padding:"8px 16px"},children:(0,r.jsxs)(o.default,{children:[(0,r.jsx)(g.default,{variant:"body1",fontWeight:"bold",children:t}),(null==l?void 0:l.description)&&(0,r.jsx)(g.default,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.75rem"},children:l.description})]})},a)},noOptionsText:"No matching models found",loadingText:"Loading models..."}),(0,r.jsx)(s.A,{margin:"dense",label:"Description",fullWidth:!0,multiline:!0,rows:3,value:w.description||"",onChange:e=>es("description",e.target.value)}),eo.creativity&&(0,r.jsx)(s.A,{margin:"dense",label:"Creativity",fullWidth:!0,type:"number",value:null!=(l=w.temperature)?l:"",onChange:e=>es("temperature",e.target.value),error:!!T.temperature,inputProps:eo.creativity,helperText:T.temperature||"Sampling temperature (".concat(eo.creativity.min,"–").concat(eo.creativity.max,"). Blank uses FLUJO's deterministic default (0).")}),eo.effortLevels&&(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"reasoning-effort-label",children:"Effort"}),(0,r.jsxs)(X.A,{labelId:"reasoning-effort-label",label:"Effort",value:w.reasoningEffort||"",onChange:e=>S(t=>({...t,reasoningEffort:e.target.value?e.target.value:void 0})),children:[(0,r.jsx)(A.A,{value:"",children:(0,r.jsx)("em",{children:"Provider default"})}),eo.effortLevels.map(e=>(0,r.jsx)(A.A,{value:e,children:"xhigh"===e?"Extra high":e.charAt(0).toUpperCase()+e.slice(1)},e))]}),(0,r.jsx)(g.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,ml:1.75},children:"Controls how much reasoning the model performs."})]}),eo.thinkingLevels&&(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"thinking-level-label",children:"Thinking Level"}),(0,r.jsxs)(X.A,{labelId:"thinking-level-label",label:"Thinking Level",value:w.thinkingLevel||"",onChange:e=>S(t=>({...t,thinkingLevel:e.target.value?e.target.value:void 0})),children:[(0,r.jsx)(A.A,{value:"",children:(0,r.jsx)("em",{children:"Provider default"})}),eo.thinkingLevels.map(e=>(0,r.jsx)(A.A,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]})]}),eo.thinkingBudget&&(0,r.jsx)(s.A,{margin:"dense",label:"Thinking Budget",fullWidth:!0,type:"number",value:null!=(n=w.thinkingBudget)?n:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,thinkingBudget:void 0!==l&&Number.isFinite(l)&&l>=-1?Math.floor(l):void 0}))},inputProps:{min:-1,step:1},helperText:"Gemini 2.5 thinking tokens. -1 = adaptive, 0 = disabled where supported, blank = provider default."}),eo.priority&&(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"service-tier-label",children:"Priority"}),(0,r.jsxs)(X.A,{labelId:"service-tier-label",label:"Priority",value:w.serviceTier||"default",onChange:e=>S(t=>({...t,serviceTier:e.target.value})),children:[(0,r.jsx)(A.A,{value:"default",children:"Standard"}),(0,r.jsx)(A.A,{value:"priority",children:"Priority (faster)"})]}),(0,r.jsx)(g.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,ml:1.75},children:"Priority uses Codex Fast mode and may consume more plan usage."})]}),(0,r.jsx)(s.A,{margin:"dense",label:"Context Window (tokens)",fullWidth:!0,type:"number",value:null!=(d=w.contextWindow)?d:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,contextWindow:void 0!==l&&Number.isFinite(l)&&l>0?Math.floor(l):void 0}))},helperText:"Optional. Enables the context-usage meter in chat (e.g. 200000 for Claude, 128000 for GPT-4o)."}),(0,r.jsx)(s.A,{margin:"dense",label:"Max Turns",fullWidth:!0,type:"number",value:null!=(p=w.maxTurns)?p:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,maxTurns:void 0!==l&&Number.isFinite(l)&&l>0?Math.floor(l):void 0}))},inputProps:{min:1},helperText:"Max agentic turns before a run stops (default 50). Process nodes can override this per-node."}),eo.maxOutputTokens&&(0,r.jsx)(s.A,{margin:"dense",label:"Max Output Tokens (optional)",fullWidth:!0,type:"number",value:null!=(m=w.maxTokens)?m:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,maxTokens:void 0!==l&&Number.isFinite(l)&&l>0?Math.floor(l):void 0}))},inputProps:{min:1},helperText:"Optional. Default cap on generated tokens. A request's max_tokens overrides this. Anthropic uses 8192 when unset."})]})}),(0,r.jsx)(v.Ay,{item:!0,xs:6,sx:{height:"100%"},children:(0,r.jsxs)(o.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pl:2},children:[(0,r.jsx)(g.default,{variant:"h6",gutterBottom:!0,children:"Prompt Template"}),(0,r.jsx)(o.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 32px)"},children:(0,r.jsx)(V.A,{ref:er,value:w.promptTemplate||"",onChange:e=>es("promptTemplate",e),label:"",height:"100%"})})]})})]}),K&&(0,r.jsxs)(o.default,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",boxShadow:24,p:4,borderRadius:1,zIndex:9999},children:[(0,r.jsx)(g.default,{variant:"h6",component:"h2",sx:{mb:2},children:"Bind to Global Variable"}),0===Object.keys(C).length?(0,r.jsx)(g.default,{sx:{mb:2},children:"No global variables available. Add some in Settings first."}):(0,r.jsx)(o.default,{sx:{maxHeight:300,overflow:"auto",mb:2},children:Object.entries(C).map(e=>{let[t,l]=e;return(0,r.jsx)(c.A,{onClick:()=>(e=>{P(!0),O(e),S(t=>({...t,ApiKey:"${global:".concat(e,"}")})),F(!1)})(t),fullWidth:!0,sx:{justifyContent:"flex-start",textAlign:"left",mb:1,p:1,"&:hover":{bgcolor:"action.hover"}},children:(0,r.jsxs)(o.default,{sx:{display:"flex",justifyContent:"space-between",width:"100%"},children:[(0,r.jsx)(g.default,{children:t}),(0,r.jsx)(g.default,{variant:"body2",color:"text.secondary",children:t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token")||t.toLowerCase().includes("password")?"********":"object"==typeof l&&null!==l&&"value"in l?l.value:l})]})},t)})}),(0,r.jsx)(o.default,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(c.A,{onClick:()=>F(!1),children:"Cancel"})})]})]}),(0,r.jsxs)(J.A,{children:[(0,r.jsx)(c.A,{onClick:j,children:"Cancel"}),(0,r.jsx)(c.A,{type:"submit",variant:"contained",color:"primary",children:"Save"})]})]})})};var er=l(94929);let ea=(0,W.h)("app/models/ModelClient");function ei(e){var t;let{initialModels:l}=e,x=(0,i.useRouter)(),f=(0,i.useSearchParams)(),[v,g]=(0,a.useState)(l),[b,y]=(0,a.useState)(""),[A,j]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[w,S]=(0,a.useState)(!1),[T,U]=(0,a.useState)(null),L="1"===f.get("add");if((0,a.useEffect)(()=>{L?U(e=>null!=e?e:{id:(0,h.A)(),name:"",displayName:"",description:"",ApiKey:"",baseUrl:"",provider:"openai",promptTemplate:"",temperature:"0.0"}):U(null)},[L]),(0,a.useEffect)(()=>{try{let e=(0,ee.X)();e&&"function"==typeof e.loadModels&&(S(!0),ea.debug("Model service is ready"))}catch(t){ea.warn("Model service not ready, retrying...",t);let e=setTimeout(()=>{try{let e=(0,ee.X)();e&&"function"==typeof e.loadModels&&(S(!0),ea.debug("Model service is now ready"))}catch(e){ea.warn("Model service still not ready",e)}},100);return()=>clearTimeout(e)}},[]),!w)return ea.debug("Waiting for model service to be ready..."),(0,r.jsx)(er.default,{});let N=f.get("edit"),M=L?T:N&&null!=(t=v.find(e=>e.id===N))?t:null,P=L?!!T:!!N,I=async e=>{ea.info("Saving model",{modelId:e.id,modelName:e.name,mode:L?"add":"update"}),C(!0);try{let t=(0,ee.X)(),l=L?await t.addModel(e):await t.updateModel(e);if(!l.success)return j(l.error||"Failed to save model."),{success:!1,error:l.error};{let e=await t.loadModels();return g(e),U(null),x.push("/models"),{success:!0,model:l.model}}}catch(e){return ea.error("Failed to save model",e),j((null==e?void 0:e.message)||"Failed to save model. Please try again."),{success:!1,error:(null==e?void 0:e.message)||"Failed to save model"}}finally{C(!1)}},K=async e=>(ea.info("Editing model",{modelId:e.id,modelName:e.name}),x.push("/models?edit=".concat(e.id)),{success:!0}),F=async()=>{ea.info("Opening add-model modal"),x.push("/models?add=1")},W=async e=>{ea.info("Deleting model",{modelId:e}),C(!0);try{let t=(0,ee.X)();await t.deleteModel(e);let l=await t.loadModels();g(l)}catch(e){ea.error("Failed to delete model",e),j("Failed to delete model. Please try again.")}finally{C(!1)}},z=async(e,t)=>{ea.info("Setting model folder",{modelId:e,folder:t}),C(!0);try{let l=(0,ee.X)(),r=await l.getModel(e);if(!r)return void j("Model not found.");let a=await l.updateModel({...r,folder:t});if(!a.success)return void j(a.error||"Failed to move model to folder.");let i=await l.loadModels();g(i)}catch(e){ea.error("Failed to set model folder",e),j((null==e?void 0:e.message)||"Failed to move model to folder. Please try again.")}finally{C(!1)}},E=async e=>{ea.info("Toggling model favorite",{modelId:e}),C(!0);try{let t=(0,ee.X)(),l=await t.getModel(e);if(!l)return void j("Model not found.");let r=!l.favorite,a=await t.updateModel({...l,favorite:r||void 0});if(!a.success)return void j(a.error||"Failed to update favorite.");let i=await t.loadModels();g(i)}catch(e){ea.error("Failed to toggle model favorite",e),j((null==e?void 0:e.message)||"Failed to update favorite. Please try again.")}finally{C(!1)}},D=async()=>{U(null),x.push("/models")},R=b.trim()?v.filter(e=>{let t=b.toLowerCase();return(e.displayName||"").toLowerCase().includes(t)||(e.name||"").toLowerCase().includes(t)}):v;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.A,{elevation:1,sx:{mb:2,p:1},children:(0,r.jsxs)(o.default,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:1,alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[(0,r.jsx)(s.A,{placeholder:"Search models...",variant:"outlined",size:"small",value:b,onChange:e=>y(e.target.value),InputProps:{startAdornment:(0,r.jsx)(d.A,{position:"start",children:(0,r.jsx)(m.A,{fontSize:"small"})})},sx:{maxWidth:{sm:300},width:"100%"}}),(0,r.jsx)(c.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(p.A,{}),onClick:F,"data-tour":"add-model",children:"Add Model"})]})}),A&&(0,r.jsx)(o.default,{sx:{mb:2},children:(0,r.jsx)(u.A,{severity:"error",onClose:()=>j(null),children:A})}),(0,r.jsx)(B,{models:R,isLoading:k,onAdd:F,onUpdate:K,onDelete:W,folders:(0,O.yF)(v,e=>e.folder),onSetFolder:z,onToggleFavorite:E}),P&&M?(0,r.jsx)(el,{open:P,model:M,onSave:I,onClose:D}):null]})}},48072:(e,t,l)=>{"use strict";l.d(t,{CR:()=>d,Lg:()=>n,eZ:()=>s,fC:()=>i});var r=l(88107),a=l(38459);let i={"name-asc":"Name (A-Z)","name-desc":"Name (Z-A)",provider:"Provider","context-desc":"Context (largest)","context-asc":"Context (smallest)"},n=e=>e.displayName||e.name||"",o=e=>(0,r.T_)(e.provider,e.adapter).label;function s(e,t){switch(t){case"provider":{let t=o(e);return{key:"provider:".concat(t),label:t}}case"context-asc":case"context-desc":var l;return"number"!=typeof(l=e.contextWindow)||Number.isNaN(l)?{key:"ctx:unknown",label:"Unknown context"}:l<=8e3?{key:"ctx:<=8k",label:"≤ 8K tokens"}:l<=32e3?{key:"ctx:8k-32k",label:"8K–32K tokens"}:l<=128e3?{key:"ctx:32k-128k",label:"32K–128K tokens"}:l<=1e6?{key:"ctx:128k-1m",label:"128K–1M tokens"}:{key:"ctx:>1m",label:"> 1M tokens"};default:return(0,a.po)(n(e))}}function d(e,t){let l=(e,l)=>{switch(t){case"name-asc":return n(e).localeCompare(n(l));case"name-desc":return n(l).localeCompare(n(e));case"provider":return o(e).localeCompare(o(l))||n(e).localeCompare(n(l));case"context-desc":case"context-asc":{let r="number"!=typeof e.contextWindow||Number.isNaN(e.contextWindow)?void 0:e.contextWindow,a="number"!=typeof l.contextWindow||Number.isNaN(l.contextWindow)?void 0:l.contextWindow;if(void 0===r&&void 0===a)return n(e).localeCompare(n(l));if(void 0===r)return 1;if(void 0===a)return -1;let i="context-desc"===t?a-r:r-a;return 0!==i?i:n(e).localeCompare(n(l))}default:return 0}};return[...e].sort((e,t)=>{let r=Number(!!t.favorite)-Number(!!e.favorite);return 0!==r?r:l(e,t)})}},52397:(e,t,l)=>{"use strict";l.d(t,{RJ:()=>a,gF:()=>r});let r="masked:********",a="********"},81956:(e,t,l)=>{"use strict";l.d(t,{A:()=>y});var r=l(95155),a=l(12115),i=l(36314),n=l(86973),o=l(49501),s=l(17681),d=l(21067),c=l(2778),u=l(52363),p=l(65036),m=l(9562),h=l(75912),x=l(91871),f=l(9693),v=l(91665),g=l(7517),b=l(8190);let y=e=>{let{anchorEl:t,open:l,currentFolder:y,folders:A,onClose:j,onAssign:k}=e,[C,w]=(0,a.useState)(!1),[S,T]=(0,a.useState)(""),U=e=>{k(e),j()},L=()=>{let e=S.trim();e&&(w(!1),U(e))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.A,{anchorEl:t,open:l,onClose:j,children:[A.length>0&&A.map(e=>(0,r.jsxs)(n.A,{onClick:()=>U(e),selected:e===y,children:[(0,r.jsx)(o.A,{children:e===y?(0,r.jsx)(f.A,{fontSize:"small"}):(0,r.jsx)(v.A,{fontSize:"small"})}),(0,r.jsx)(s.A,{primary:e})]},e)),A.length>0&&(0,r.jsx)(d.A,{}),(0,r.jsxs)(n.A,{onClick:()=>{T(""),w(!0)},children:[(0,r.jsx)(o.A,{children:(0,r.jsx)(g.A,{fontSize:"small"})}),(0,r.jsx)(s.A,{primary:"New folder…"})]}),y&&(0,r.jsxs)(n.A,{onClick:()=>U(void 0),children:[(0,r.jsx)(o.A,{children:(0,r.jsx)(b.A,{fontSize:"small"})}),(0,r.jsx)(s.A,{primary:"Remove from folder"})]})]}),(0,r.jsxs)(c.A,{open:C,onClose:()=>w(!1),maxWidth:"xs",fullWidth:!0,children:[(0,r.jsx)(u.A,{children:"New folder"}),(0,r.jsx)(p.A,{children:(0,r.jsx)(m.A,{autoFocus:!0,margin:"dense",label:"Folder name",fullWidth:!0,value:S,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),L())}})}),(0,r.jsxs)(h.A,{children:[(0,r.jsx)(x.A,{onClick:()=>w(!1),children:"Cancel"}),(0,r.jsx)(x.A,{variant:"contained",disabled:!S.trim(),onClick:L,children:"Create"})]})]})]})}},88107:(e,t,l)=>{"use strict";l.d(t,{T_:()=>s,g3:()=>n,xx:()=>o});let r=/(^|[/_-])(o[1-9]|gpt-5)(?:[./_-]|$)/i,a=/claude-(?:fable|mythos)-5|claude-opus-4-(?:[7-9]|\d{2,})|claude-sonnet-5/i,i=/^(?:opus|sonnet|fable)$|claude-(?:fable|mythos)-5|claude-opus-4-(?:[6-9]|\d{2,})|claude-sonnet-4-6/i;function n(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=t||"openai",o=l.trim();if("codex-cli"===n)return{effortLevels:/^gpt-5\.6-(?:sol|terra)$/i.test(o)?["low","medium","high","xhigh","max","ultra"]:/^gpt-5\.6-/i.test(o)?["low","medium","high","xhigh","max"]:["low","medium","high","xhigh"],priority:!/(?:mini|spark|review)/i.test(o),maxOutputTokens:!1};if("claude-cli"===n)return{...i.test(o)?{effortLevels:["low","medium","high","xhigh","max"]}:{},maxOutputTokens:!1};if("anthropic"===n)return{...!a.test(o)?{creativity:{min:0,max:1,step:.1}}:{},...i.test(o)?{effortLevels:["low","medium","high","xhigh","max"]}:{},maxOutputTokens:!0};if("gemini"===n)return{creativity:{min:0,max:2,step:.1},.../^gemini-2\.5/i.test(o)?{thinkingBudget:!0}:!/^gemini-2\.0/i.test(o)?{thinkingLevels:["minimal","low","medium","high"]}:{},maxOutputTokens:!0};let s="openai"===(e||"openai")&&r.test(o);return{...!s?{creativity:{min:0,max:2,step:.1}}:{},...s?{effortLevels:["low","medium","high"]}:{},maxOutputTokens:!0}}let o=[{id:"openai",label:"OpenAI",provider:"openai",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://api.openai.com/v1",showBaseUrl:!0},{id:"openai-responses",label:"OpenAI (Responses API)",provider:"openai",adapter:"openai-responses",sdkLabel:"OpenAI SDK (Responses)",baseUrl:"https://api.openai.com/v1",showBaseUrl:!0,defaultModels:["gpt-5","gpt-5-mini","o4-mini","o3"]},{id:"openrouter",label:"OpenRouter",provider:"openrouter",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://openrouter.ai/api/v1",showBaseUrl:!0},{id:"requesty",label:"Requesty",provider:"requesty",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://router.requesty.ai/v1",showBaseUrl:!0},{id:"xai",label:"X.ai",provider:"xai",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://api.x.ai/v1",showBaseUrl:!0},{id:"ollama",label:"Ollama",provider:"ollama",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"http://localhost:11434/v1",showBaseUrl:!0},{id:"litellm",label:"LiteLLM",provider:"litellm",adapter:"openai",sdkLabel:"OpenAI SDK (via LiteLLM Proxy)",baseUrl:"http://localhost:4000/v1",showBaseUrl:!0},{id:"gemini-openai",label:"Gemini (OpenAI Format)",provider:"gemini",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://generativelanguage.googleapis.com/v1beta/openai/",showBaseUrl:!0},{id:"gemini-native",label:"Gemini (Native)",provider:"gemini",adapter:"gemini",sdkLabel:"GenAI SDK",baseUrl:"",showBaseUrl:!1,defaultModels:["gemini-2.5-pro","gemini-2.5-flash","gemini-2.5-flash-lite","gemini-2.0-flash"]},{id:"anthropic-openai",label:"Anthropic (OpenAI Format)",provider:"anthropic",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://api.anthropic.com/v1/",showBaseUrl:!0},{id:"anthropic-native",label:"Anthropic (Native)",provider:"anthropic",adapter:"anthropic",sdkLabel:"Anthropic SDK",baseUrl:"",showBaseUrl:!1,defaultModels:["claude-opus-4-8","claude-sonnet-4-6","claude-haiku-4-5-20251001","claude-fable-5"]},{id:"claude-subscription",label:"Claude Subscription",provider:"claude-subscription",adapter:"claude-cli",sdkLabel:"Claude CLI",baseUrl:"",showBaseUrl:!1,defaultModels:["opus","sonnet","haiku","fable"]},{id:"codex",label:"Codex (OpenAI)",provider:"codex",adapter:"codex-cli",sdkLabel:"Codex SDK",baseUrl:"",showBaseUrl:!1,defaultModels:["gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","gpt-5.5","gpt-5.4","gpt-5.4-mini"]}];function s(e,t){let l=e||"openai",r=t||"openai";return o.find(e=>e.provider===l&&e.adapter===r)||o.find(e=>e.provider===l)||o[0]}},97104:(e,t,l)=>{"use strict";l.d(t,{Aq:()=>a,Xk:()=>n,vi:()=>i});var r=l(12115);function a(e,t){try{let l=window.localStorage.getItem(e);if(null===l)return t;return JSON.parse(l)}catch(e){return t}}function i(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch(e){}}function n(e,t){let[l,n]=(0,r.useState)(()=>a(e,t));return[l,(0,r.useCallback)(t=>{n(l=>{let r="function"==typeof t?t(l):t;return i(e,r),r})},[e])]}}},e=>{e.O(0,[1137,7926,2678,4754,9244,3392,1871,981,2003,9562,488,3272,3077,8470,9581,7328,1675,289,8041,6539,9164,3772,7445,8441,1255,7358],()=>e(e.s=15894)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8329],{15894:(e,t,l)=>{Promise.resolve().then(l.bind(l,94049)),Promise.resolve().then(l.bind(l,25635)),Promise.resolve().then(l.bind(l,24437)),Promise.resolve().then(l.bind(l,36552)),Promise.resolve().then(l.bind(l,43856)),Promise.resolve().then(l.bind(l,36982)),Promise.resolve().then(l.bind(l,94929))},22573:(e,t,l)=>{"use strict";l.d(t,{A:()=>p});var r=l(95155);l(12115);var a=l(33567),i=l(94049),n=l(41983),o=l(25635),s=l(28548),d=l(50430),c=l(63186),u=l(91665);let p=e=>{let{label:t,count:l,expanded:p,onToggle:m,showFolderIcon:h=!1,children:x}=e,f=(0,a.A)();return(0,r.jsxs)(i.default,{sx:{mb:1.5},children:[(0,r.jsxs)(i.default,{role:"button",tabIndex:0,"aria-expanded":p,onClick:m,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),m())},sx:{display:"flex",alignItems:"center",gap:1,px:1,py:.75,borderRadius:1,cursor:"pointer",userSelect:"none",backgroundColor:f.palette.background.default,border:"1px solid ".concat(f.palette.divider),"&:hover":{backgroundColor:f.palette.action.hover}},children:[(0,r.jsx)(n.A,{size:"small","aria-label":p?"Collapse section":"Expand section",onClick:e=>{e.stopPropagation(),m()},sx:{transition:"transform 0.2s",transform:p?"rotate(0deg)":"rotate(-90deg)"},children:(0,r.jsx)(c.A,{fontSize:"small"})}),h&&(0,r.jsx)(u.A,{fontSize:"small",sx:{color:"text.secondary"}}),(0,r.jsx)(o.default,{variant:"subtitle2",sx:{fontWeight:600},children:t}),(0,r.jsx)(s.A,{label:l,size:"small",sx:{height:20,fontSize:"0.7rem"}})]}),(0,r.jsx)(d.A,{in:p,unmountOnExit:!0,children:(0,r.jsx)(i.default,{sx:{pt:1.5},children:x})})]})}},36982:(e,t,l)=>{"use strict";l.d(t,{default:()=>o});var r=l(95155);l(12115);var a=l(94049),i=l(64598),n=l(23201);function o(e){let{storageKey:t,sx:l,threshold:o,deps:s,children:d}=e,{ref:c,showBackToTop:u,scrollToTop:p}=(0,i.R)(t,{threshold:o,deps:s});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.default,{ref:c,sx:{...l,overflow:"auto"},children:d}),(0,r.jsx)(n.A,{show:u,onClick:p})]})}},38459:(e,t,l)=>{"use strict";l.d(t,{Az:()=>a,FM:()=>r,Je:()=>n,po:()=>i,yF:()=>o});let r="folder";function a(e,t){let l=[],r=new Map;for(let a of e){let{key:e,label:i}=t(a),n=r.get(e);n||(n={key:e,label:i,items:[]},r.set(e,n),l.push(n)),n.items.push(a)}return l}function i(e){let t=(null!=e?e:"").trim().charAt(0).toUpperCase();return t>="A"&&t<="Z"?{key:"letter:".concat(t),label:t}:{key:"letter:#",label:"#"}}function n(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Ungrouped",r=new Map,a=[];for(let l of e){var i;let e=null==(i=t(l))?void 0:i.trim();if(e){let t=r.get(e);t?t.push(l):r.set(e,[l])}else a.push(l)}let n=Array.from(r.keys()).sort((e,t)=>e.localeCompare(t)).map(e=>({key:"folder:".concat(e),label:e,items:r.get(e)}));return a.length>0&&n.push({key:"folder:__ungrouped__",label:l,items:a}),n}function o(e,t){let l=new Set;for(let a of e){var r;let e=null==(r=t(a))?void 0:r.trim();e&&l.add(e)}return Array.from(l).sort((e,t)=>e.localeCompare(t))}},43856:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>ei});var r=l(95155),a=l(12115),i=l(20063),n=l(2300),o=l(94049),s=l(9562),d=l(56422),c=l(91871),u=l(22003),p=l(86946),m=l(51611),h=l(74879),x=l(33567),f=l(4474),v=l(33077),g=l(25635),b=l(41983),y=l(36314),A=l(86973),j=l(49501),k=l(17681),C=l(21067),w=l(64419),S=l(28466),T=l(45587),U=l(81952),L=l(94885),N=l(15686),M=l(91665),P=l(61267),I=l(22573),O=l(38459),K=l(97104),F=l(48072),W=l(87021);let z=(0,W.h)("frontend/components/models/list/ModelList"),B=e=>{let{models:t,isLoading:l,onAdd:i,onUpdate:s,onDelete:d,folders:c=[],onSetFolder:u,onToggleFavorite:p}=e,m=(0,x.A)(),[h,W]=(0,K.Xk)("flujo-ui:models:sort","name-asc"),[B,E]=(0,K.Xk)("flujo-ui:models:group",O.FM),[D,R]=(0,a.useState)(null),[_,q]=(0,a.useState)(null),[X,G]=(0,K.Xk)("flujo-ui:models:collapsed",[]),J=(0,a.useMemo)(()=>new Set(X),[X]),Z=e=>{W(e),R(null)},$=e=>{E(e),q(null)},H=async e=>{let t=await s(e);t.success||z.error("Failed to update model in ModelList",t.error)},V=(0,a.useMemo)(()=>(0,F.CR)(t,h),[t,h]),Y=(0,a.useMemo)(()=>"folder"===B?(0,O.Je)(V,e=>e.folder):"sort"===B?(0,O.Az)(V,e=>(0,F.eZ)(e,h)):[],[B,V,h]);if(l)return(0,r.jsx)(o.default,{display:"flex",justifyContent:"center",py:4,children:(0,r.jsx)(f.default,{})});let Q=e=>(0,r.jsx)(v.Ay,{container:!0,spacing:2,children:e.map(e=>(0,r.jsx)(v.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,r.jsx)(P.A,{model:e,onEdit:()=>H(e),onDelete:()=>d(e.id),folder:e.folder,folders:c,onSetFolder:u?t=>u(e.id,t):void 0,onToggleFavorite:p})},e.id))});return(0,r.jsxs)(o.default,{children:[(0,r.jsx)(n.A,{elevation:1,sx:{mb:2,p:1},children:(0,r.jsxs)(o.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[(0,r.jsxs)(g.default,{variant:"body2",color:"textSecondary",children:[t.length," model",1===t.length?"":"s",(0,r.jsx)(o.default,{component:"span",sx:{mx:1,opacity:.5},children:"\xb7"}),"Sorted by: ",F.fC[h]]}),(0,r.jsxs)(o.default,{sx:{display:"flex",gap:1,alignItems:"center"},children:[(0,r.jsx)(b.A,{size:"small",onClick:e=>q(e.currentTarget),color:"none"!==B?"primary":"default",sx:{border:"1px solid ".concat(m.palette.divider),backgroundColor:m.palette.background.default},title:"Group cards",children:(0,r.jsx)(L.A,{fontSize:"small"})}),(0,r.jsx)(b.A,{size:"small",onClick:e=>R(e.currentTarget),sx:{border:"1px solid ".concat(m.palette.divider),backgroundColor:m.palette.background.default},title:"Sort models",children:(0,r.jsx)(w.A,{fontSize:"small"})})]})]})}),t&&0!==t.length?"none"===B?Q(V):Y.map(e=>(0,r.jsx)(I.A,{label:e.label,count:e.items.length,expanded:!J.has(e.key),onToggle:()=>(e=>{G(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])})(e.key),showFolderIcon:"folder"===B,children:Q(e.items)},e.key)):(0,r.jsx)(o.default,{textAlign:"center",py:4,children:"No models found"}),(0,r.jsxs)(y.A,{anchorEl:_,open:!!_,onClose:()=>q(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,r.jsxs)(A.A,{selected:"none"===B,onClick:()=>$("none"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(N.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"No grouping"})]}),(0,r.jsxs)(A.A,{selected:"folder"===B,onClick:()=>$("folder"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(M.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"By folder"})]}),(0,r.jsxs)(A.A,{selected:"sort"===B,onClick:()=>$("sort"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(L.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"By sort setting"})]})]}),(0,r.jsxs)(y.A,{anchorEl:D,open:!!D,onClose:()=>R(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,r.jsxs)(A.A,{selected:"name-asc"===h,onClick:()=>Z("name-asc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(S.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"Name (A-Z)"})]}),(0,r.jsxs)(A.A,{selected:"name-desc"===h,onClick:()=>Z("name-desc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(S.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,r.jsx)(k.A,{primary:"Name (Z-A)"})]}),(0,r.jsx)(C.A,{}),(0,r.jsxs)(A.A,{selected:"provider"===h,onClick:()=>Z("provider"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(T.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"Provider"})]}),(0,r.jsx)(C.A,{}),(0,r.jsxs)(A.A,{selected:"context-desc"===h,onClick:()=>Z("context-desc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(U.A,{fontSize:"small"})}),(0,r.jsx)(k.A,{primary:"Context (largest)"})]}),(0,r.jsxs)(A.A,{selected:"context-asc"===h,onClick:()=>Z("context-asc"),children:[(0,r.jsx)(j.A,{children:(0,r.jsx)(U.A,{fontSize:"small",sx:{transform:"scaleY(-1)"}})}),(0,r.jsx)(k.A,{primary:"Context (smallest)"})]})]})]})};var E=l(2778),D=l(52363),R=l(65036),_=l(52641),q=l(95436),X=l(55606),G=l(63109),J=l(75912),Z=l(12857),$=l(48363),H=l(9164),V=l(95480),Y=l(88107),Q=l(52397),ee=l(43076);let et=(0,W.h)("frontend/components/models/modal"),el=e=>{var t,l,n,d,p,m;let{open:h,model:x,onSave:y,onClose:j}=e,k=(0,i.useRouter)(),{globalEnvVars:C}=(0,H.useStorage)(),[w,S]=(0,a.useState)({}),[T,U]=(0,a.useState)({}),[L,N]=(0,a.useState)(null),[M,P]=(0,a.useState)(!1),[I,O]=(0,a.useState)(null),[K,F]=(0,a.useState)(!1),[W,z]=(0,a.useState)([]),[B,el]=(0,a.useState)(!1),er=(0,a.useRef)(null),ea=(0,a.useRef)(null);(0,a.useEffect)(()=>{h&&z([])},[h]),(0,a.useEffect)(()=>{w.baseUrl&&(et.debug("Base URL or API Key changed",{baseUrl:w.baseUrl}),z([]))},[w.baseUrl,w.ApiKey]),(0,a.useEffect)(()=>(ea.current&&clearTimeout(ea.current),w.baseUrl&&(ea.current=setTimeout(()=>{et.debug("Debounced fetchModels triggered",{name:w.name,baseUrl:w.baseUrl,searchTerm:w.name?'"'.concat(w.name,'"'):"none"}),ei(w.baseUrl,w.name)},100)),()=>{ea.current&&clearTimeout(ea.current)}),[w.name,w.baseUrl]),(0,a.useEffect)(()=>()=>{ea.current&&clearTimeout(ea.current)},[]);let ei=async(e,t)=>{et.debug("fetchModels called",{baseUrl:e,searchTerm:t?'"'.concat(t,'"'):"none",apiKey:w.ApiKey?"present":"not present",isApiKeyBound:M}),el(!0),U({});try{let l=M&&I?"${global:".concat(I,"}"):w.ApiKey&&w.ApiKey!==Q.RJ?w.ApiKey:void 0,r=await ee.N.fetchProviderModels(e,x.id,t,l);et.debug("Models fetched successfully",{count:null==r?void 0:r.length,searchTerm:t?'"'.concat(t,'"'):"none"}),Array.isArray(r)?(z(r),et.info("Models set in state",{count:r.length,searchTerm:t?'"'.concat(t,'"'):"none"})):(et.warn("Unexpected API response format",{models:r}),z([]))}catch(l){et.warn("Error fetching models",{baseUrl:e,searchTerm:t,error:l}),z([])}finally{el(!1)}};(0,a.useEffect)(()=>{if(h){S({...x,displayName:x.displayName||x.name});let e=(x.ApiKey||"").match(/\$\{global:([^}]+)\}/);e?(P(!0),O(e[1])):(P(!1),O(null),S(e=>({...e,ApiKey:x.name?Q.RJ:""})))}else S({name:"",displayName:"",description:"",ApiKey:"",baseUrl:"https://api.openai.com/v1",provider:"openai",adapter:"openai",promptTemplate:"",temperature:"0.0"}),P(!1),O(null);U({}),N(null)},[h,x]);let en=(0,Y.T_)(w.provider,w.adapter),eo=(0,Y.g3)(w.provider,w.adapter,w.name),es=(e,t)=>{S(l=>({...l,[e]:t})),U(t=>({...t,[e]:""}))},ed=async e=>{var t,l,r,a,i,n;e.preventDefault();let o={};if((null==(t=w.name)?void 0:t.trim())||(o.name="Name is required"),(null==(l=w.displayName)?void 0:l.trim())||(o.displayName="Display Name is required"),eo.creativity&&(null==(r=w.temperature)?void 0:r.trim())){let e=Number(w.temperature);(!Number.isFinite(e)||e<eo.creativity.min||e>eo.creativity.max)&&(o.temperature="Creativity must be between ".concat(eo.creativity.min," and ").concat(eo.creativity.max))}if(M||(null==(a=w.ApiKey)?void 0:a.trim())||"codex-cli"===en.adapter||(o.ApiKey="API key is required"),Object.keys(o).length>0)return void U(o);try{let e=await y({id:x.id,name:w.name,displayName:w.displayName,description:w.description,ApiKey:w.ApiKey,baseUrl:w.baseUrl,provider:w.provider,adapter:w.adapter||"openai",promptTemplate:w.promptTemplate,temperature:eo.creativity?w.temperature:void 0,reasoningEffort:(null==(i=eo.effortLevels)?void 0:i.includes(w.reasoningEffort))?w.reasoningEffort:void 0,thinkingLevel:(null==(n=eo.thinkingLevels)?void 0:n.includes(w.thinkingLevel))?w.thinkingLevel:void 0,thinkingBudget:eo.thinkingBudget?w.thinkingBudget:void 0,serviceTier:eo.priority?w.serviceTier||"default":void 0,contextWindow:w.contextWindow,maxTurns:w.maxTurns,maxTokens:eo.maxOutputTokens?w.maxTokens:void 0});e.success?k.refresh():U({submit:e.error||"Failed to save model"})}catch(e){et.error("Failed to save model",{error:e}),U({submit:(null==e?void 0:e.message)||"Failed to save model"})}};return(0,r.jsx)(E.A,{open:h,onClose:j,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:(0,r.jsxs)("form",{onSubmit:ed,children:[(0,r.jsx)(D.A,{children:x?"Edit Model":"Add Model"}),(0,r.jsxs)(R.A,{sx:{display:"flex",flexDirection:"column",height:"calc(90vh - 130px)"},children:[T.submit&&(0,r.jsx)(u.A,{severity:"error",sx:{mb:2},children:T.submit}),L&&(0,r.jsx)(u.A,{severity:"info",sx:{mb:2},children:L}),(0,r.jsxs)(v.Ay,{container:!0,spacing:2,sx:{flexGrow:1},children:[(0,r.jsx)(v.Ay,{item:!0,xs:6,sx:{height:"100%"},children:(0,r.jsxs)(o.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pr:2,overflowY:"auto"},children:[(0,r.jsx)(g.default,{variant:"h6",gutterBottom:!0,children:"Model Configuration"}),(0,r.jsx)(s.A,{autoFocus:!0,margin:"dense",label:"Display Name",fullWidth:!0,required:!0,value:w.displayName||"",onChange:e=>es("displayName",e.target.value),error:!!T.displayName,helperText:T.displayName||"The name shown in the UI"}),(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"provider-profile-label",children:"Provider"}),(0,r.jsx)(X.A,{labelId:"provider-profile-label",label:"Provider",value:en.id,onChange:e=>(e=>{let t=Y.xx.find(t=>t.id===e);t&&(S(e=>({...e,provider:t.provider,adapter:t.adapter,baseUrl:t.baseUrl})),U(e=>({...e,baseUrl:""})))})(e.target.value),children:Y.xx.map(e=>(0,r.jsx)(A.A,{value:e.id,children:e.label},e.id))})]}),(0,r.jsxs)(g.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mb:1,display:"block"},children:["Uses the ",(0,r.jsx)("strong",{children:en.sdkLabel}),"claude-cli"===en.adapter?". Paste an OAuth token from `claude setup-token` into the API Key field.":"codex-cli"===en.adapter?". Paste an OpenAI API key — or leave it empty to use your ChatGPT plan via `codex login`.":""]}),en.showBaseUrl&&(0,r.jsx)(s.A,{margin:"dense",label:"Base URL",fullWidth:!0,value:w.baseUrl||"",onChange:e=>es("baseUrl",e.target.value),helperText:"Endpoint for the OpenAI-compatible API."}),(0,r.jsx)(o.default,{sx:{position:"relative",mt:1,mb:1},children:(0,r.jsx)(s.A,{margin:"dense",label:"API Key",fullWidth:!0,required:!M&&"codex-cli"!==en.adapter,type:M?"text":"password",value:w.ApiKey||"",onChange:e=>es("ApiKey",e.target.value),error:!!T.ApiKey,helperText:T.ApiKey||("codex-cli"===en.adapter?"Optional — leave empty to use your ChatGPT plan (codex login)":"API key is required for this provider"),InputProps:{readOnly:M,endAdornment:(0,r.jsx)(o.default,{sx:{display:"flex",alignItems:"center"},children:M?(0,r.jsx)(b.A,{onClick:()=>{P(!1),O(null),S(e=>({...e,ApiKey:""}))},size:"small",title:"Unbind from global variable",children:(0,r.jsx)(Z.A,{})}):(0,r.jsx)(b.A,{onClick:()=>{F(!0)},size:"small",title:"Bind to global variable",children:(0,r.jsx)($.A,{})})})}})}),(0,r.jsx)(G.A,{freeSolo:!0,loading:B,options:en.showBaseUrl?W.map(e=>e.id):null!=(t=en.defaultModels)?t:[],value:w.name||"",onChange:(e,t)=>{es("name",t||"")},onInputChange:(e,t)=>{es("name",t)},filterOptions:(e,t)=>{let l=t.inputValue.toLowerCase();return l?e.filter(e=>{let t=e.toLowerCase();if(t.includes(l))return!0;let r=0,a=0;for(;r<t.length&&a<l.length;)t[r]===l[a]&&a++,r++;return a===l.length}):e},ListboxProps:{style:{maxHeight:"300px",overflow:"auto"}},renderInput:e=>(0,r.jsx)(s.A,{...e,margin:"dense",label:"Technical Name",required:!0,error:!!T.name,helperText:T.name||"Used for API calls to the LLM. Type to search available models.",InputProps:{...e.InputProps,endAdornment:(0,r.jsxs)(r.Fragment,{children:[B?(0,r.jsx)(f.default,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}}),renderOption:(e,t)=>{let l=W.find(e=>e.id===t),{key:a,...i}=e;return(0,r.jsx)("li",{...i,style:{borderBottom:"1px solid rgba(0,0,0,0.1)",padding:"8px 16px"},children:(0,r.jsxs)(o.default,{children:[(0,r.jsx)(g.default,{variant:"body1",fontWeight:"bold",children:t}),(null==l?void 0:l.description)&&(0,r.jsx)(g.default,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.75rem"},children:l.description})]})},a)},noOptionsText:"No matching models found",loadingText:"Loading models..."}),(0,r.jsx)(s.A,{margin:"dense",label:"Description",fullWidth:!0,multiline:!0,rows:3,value:w.description||"",onChange:e=>es("description",e.target.value)}),eo.creativity&&(0,r.jsx)(s.A,{margin:"dense",label:"Creativity",fullWidth:!0,type:"number",value:null!=(l=w.temperature)?l:"",onChange:e=>es("temperature",e.target.value),error:!!T.temperature,inputProps:eo.creativity,helperText:T.temperature||"Sampling temperature (".concat(eo.creativity.min,"–").concat(eo.creativity.max,"). Blank uses FLUJO's deterministic default (0).")}),eo.effortLevels&&(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"reasoning-effort-label",children:"Effort"}),(0,r.jsxs)(X.A,{labelId:"reasoning-effort-label",label:"Effort",value:w.reasoningEffort||"",onChange:e=>S(t=>({...t,reasoningEffort:e.target.value?e.target.value:void 0})),children:[(0,r.jsx)(A.A,{value:"",children:(0,r.jsx)("em",{children:"Provider default"})}),eo.effortLevels.map(e=>(0,r.jsx)(A.A,{value:e,children:"xhigh"===e?"Extra high":e.charAt(0).toUpperCase()+e.slice(1)},e))]}),(0,r.jsx)(g.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,ml:1.75},children:"Controls how much reasoning the model performs."})]}),eo.thinkingLevels&&(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"thinking-level-label",children:"Thinking Level"}),(0,r.jsxs)(X.A,{labelId:"thinking-level-label",label:"Thinking Level",value:w.thinkingLevel||"",onChange:e=>S(t=>({...t,thinkingLevel:e.target.value?e.target.value:void 0})),children:[(0,r.jsx)(A.A,{value:"",children:(0,r.jsx)("em",{children:"Provider default"})}),eo.thinkingLevels.map(e=>(0,r.jsx)(A.A,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]})]}),eo.thinkingBudget&&(0,r.jsx)(s.A,{margin:"dense",label:"Thinking Budget",fullWidth:!0,type:"number",value:null!=(n=w.thinkingBudget)?n:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,thinkingBudget:void 0!==l&&Number.isFinite(l)&&l>=-1?Math.floor(l):void 0}))},inputProps:{min:-1,step:1},helperText:"Gemini 2.5 thinking tokens. -1 = adaptive, 0 = disabled where supported, blank = provider default."}),eo.priority&&(0,r.jsxs)(_.A,{fullWidth:!0,margin:"dense",children:[(0,r.jsx)(q.A,{id:"service-tier-label",children:"Priority"}),(0,r.jsxs)(X.A,{labelId:"service-tier-label",label:"Priority",value:w.serviceTier||"default",onChange:e=>S(t=>({...t,serviceTier:e.target.value})),children:[(0,r.jsx)(A.A,{value:"default",children:"Standard"}),(0,r.jsx)(A.A,{value:"priority",children:"Priority (faster)"})]}),(0,r.jsx)(g.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,ml:1.75},children:"Priority uses Codex Fast mode and may consume more plan usage."})]}),(0,r.jsx)(s.A,{margin:"dense",label:"Context Window (tokens)",fullWidth:!0,type:"number",value:null!=(d=w.contextWindow)?d:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,contextWindow:void 0!==l&&Number.isFinite(l)&&l>0?Math.floor(l):void 0}))},helperText:"Optional. Enables the context-usage meter in chat (e.g. 200000 for Claude, 128000 for GPT-4o)."}),(0,r.jsx)(s.A,{margin:"dense",label:"Max Turns",fullWidth:!0,type:"number",value:null!=(p=w.maxTurns)?p:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,maxTurns:void 0!==l&&Number.isFinite(l)&&l>0?Math.floor(l):void 0}))},inputProps:{min:1},helperText:"Max agentic turns before a run stops (default 50). Process nodes can override this per-node."}),eo.maxOutputTokens&&(0,r.jsx)(s.A,{margin:"dense",label:"Max Output Tokens (optional)",fullWidth:!0,type:"number",value:null!=(m=w.maxTokens)?m:"",onChange:e=>{let t=e.target.value,l=""===t?void 0:Number(t);S(e=>({...e,maxTokens:void 0!==l&&Number.isFinite(l)&&l>0?Math.floor(l):void 0}))},inputProps:{min:1},helperText:"Optional. Default cap on generated tokens. A request's max_tokens overrides this. Anthropic uses 8192 when unset."})]})}),(0,r.jsx)(v.Ay,{item:!0,xs:6,sx:{height:"100%"},children:(0,r.jsxs)(o.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pl:2},children:[(0,r.jsx)(g.default,{variant:"h6",gutterBottom:!0,children:"Prompt Template"}),(0,r.jsx)(o.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 32px)"},children:(0,r.jsx)(V.A,{ref:er,value:w.promptTemplate||"",onChange:e=>es("promptTemplate",e),label:"",height:"100%"})})]})})]}),K&&(0,r.jsxs)(o.default,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",boxShadow:24,p:4,borderRadius:1,zIndex:9999},children:[(0,r.jsx)(g.default,{variant:"h6",component:"h2",sx:{mb:2},children:"Bind to Global Variable"}),0===Object.keys(C).length?(0,r.jsx)(g.default,{sx:{mb:2},children:"No global variables available. Add some in Settings first."}):(0,r.jsx)(o.default,{sx:{maxHeight:300,overflow:"auto",mb:2},children:Object.entries(C).map(e=>{let[t,l]=e;return(0,r.jsx)(c.A,{onClick:()=>(e=>{P(!0),O(e),S(t=>({...t,ApiKey:"${global:".concat(e,"}")})),F(!1)})(t),fullWidth:!0,sx:{justifyContent:"flex-start",textAlign:"left",mb:1,p:1,"&:hover":{bgcolor:"action.hover"}},children:(0,r.jsxs)(o.default,{sx:{display:"flex",justifyContent:"space-between",width:"100%"},children:[(0,r.jsx)(g.default,{children:t}),(0,r.jsx)(g.default,{variant:"body2",color:"text.secondary",children:t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token")||t.toLowerCase().includes("password")?"********":"object"==typeof l&&null!==l&&"value"in l?l.value:l})]})},t)})}),(0,r.jsx)(o.default,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(c.A,{onClick:()=>F(!1),children:"Cancel"})})]})]}),(0,r.jsxs)(J.A,{children:[(0,r.jsx)(c.A,{onClick:j,children:"Cancel"}),(0,r.jsx)(c.A,{type:"submit",variant:"contained",color:"primary",children:"Save"})]})]})})};var er=l(94929);let ea=(0,W.h)("app/models/ModelClient");function ei(e){var t;let{initialModels:l}=e,x=(0,i.useRouter)(),f=(0,i.useSearchParams)(),[v,g]=(0,a.useState)(l),[b,y]=(0,a.useState)(""),[A,j]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[w,S]=(0,a.useState)(!1),[T,U]=(0,a.useState)(null),L="1"===f.get("add");if((0,a.useEffect)(()=>{L?U(e=>null!=e?e:{id:(0,h.A)(),name:"",displayName:"",description:"",ApiKey:"",baseUrl:"",provider:"openai",promptTemplate:"",temperature:"0.0"}):U(null)},[L]),(0,a.useEffect)(()=>{try{let e=(0,ee.X)();e&&"function"==typeof e.loadModels&&(S(!0),ea.debug("Model service is ready"))}catch(t){ea.warn("Model service not ready, retrying...",t);let e=setTimeout(()=>{try{let e=(0,ee.X)();e&&"function"==typeof e.loadModels&&(S(!0),ea.debug("Model service is now ready"))}catch(e){ea.warn("Model service still not ready",e)}},100);return()=>clearTimeout(e)}},[]),!w)return ea.debug("Waiting for model service to be ready..."),(0,r.jsx)(er.default,{});let N=f.get("edit"),M=L?T:N&&null!=(t=v.find(e=>e.id===N))?t:null,P=L?!!T:!!N,I=async e=>{ea.info("Saving model",{modelId:e.id,modelName:e.name,mode:L?"add":"update"}),C(!0);try{let t=(0,ee.X)(),l=L?await t.addModel(e):await t.updateModel(e);if(!l.success)return j(l.error||"Failed to save model."),{success:!1,error:l.error};{let e=await t.loadModels();return g(e),U(null),x.push("/models"),{success:!0,model:l.model}}}catch(e){return ea.error("Failed to save model",e),j((null==e?void 0:e.message)||"Failed to save model. Please try again."),{success:!1,error:(null==e?void 0:e.message)||"Failed to save model"}}finally{C(!1)}},K=async e=>(ea.info("Editing model",{modelId:e.id,modelName:e.name}),x.push("/models?edit=".concat(e.id)),{success:!0}),F=async()=>{ea.info("Opening add-model modal"),x.push("/models?add=1")},W=async e=>{ea.info("Deleting model",{modelId:e}),C(!0);try{let t=(0,ee.X)();await t.deleteModel(e);let l=await t.loadModels();g(l)}catch(e){ea.error("Failed to delete model",e),j("Failed to delete model. Please try again.")}finally{C(!1)}},z=async(e,t)=>{ea.info("Setting model folder",{modelId:e,folder:t}),C(!0);try{let l=(0,ee.X)(),r=await l.getModel(e);if(!r)return void j("Model not found.");let a=await l.updateModel({...r,folder:t});if(!a.success)return void j(a.error||"Failed to move model to folder.");let i=await l.loadModels();g(i)}catch(e){ea.error("Failed to set model folder",e),j((null==e?void 0:e.message)||"Failed to move model to folder. Please try again.")}finally{C(!1)}},E=async e=>{ea.info("Toggling model favorite",{modelId:e}),C(!0);try{let t=(0,ee.X)(),l=await t.getModel(e);if(!l)return void j("Model not found.");let r=!l.favorite,a=await t.updateModel({...l,favorite:r||void 0});if(!a.success)return void j(a.error||"Failed to update favorite.");let i=await t.loadModels();g(i)}catch(e){ea.error("Failed to toggle model favorite",e),j((null==e?void 0:e.message)||"Failed to update favorite. Please try again.")}finally{C(!1)}},D=async()=>{U(null),x.push("/models")},R=b.trim()?v.filter(e=>{let t=b.toLowerCase();return(e.displayName||"").toLowerCase().includes(t)||(e.name||"").toLowerCase().includes(t)}):v;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.A,{elevation:1,sx:{mb:2,p:1},children:(0,r.jsxs)(o.default,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:1,alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[(0,r.jsx)(s.A,{placeholder:"Search models...",variant:"outlined",size:"small",value:b,onChange:e=>y(e.target.value),InputProps:{startAdornment:(0,r.jsx)(d.A,{position:"start",children:(0,r.jsx)(m.A,{fontSize:"small"})})},sx:{maxWidth:{sm:300},width:"100%"}}),(0,r.jsx)(c.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(p.A,{}),onClick:F,"data-tour":"add-model",children:"Add Model"})]})}),A&&(0,r.jsx)(o.default,{sx:{mb:2},children:(0,r.jsx)(u.A,{severity:"error",onClose:()=>j(null),children:A})}),(0,r.jsx)(B,{models:R,isLoading:k,onAdd:F,onUpdate:K,onDelete:W,folders:(0,O.yF)(v,e=>e.folder),onSetFolder:z,onToggleFavorite:E}),P&&M?(0,r.jsx)(el,{open:P,model:M,onSave:I,onClose:D}):null]})}},48072:(e,t,l)=>{"use strict";l.d(t,{CR:()=>d,Lg:()=>n,eZ:()=>s,fC:()=>i});var r=l(88107),a=l(38459);let i={"name-asc":"Name (A-Z)","name-desc":"Name (Z-A)",provider:"Provider","context-desc":"Context (largest)","context-asc":"Context (smallest)"},n=e=>e.displayName||e.name||"",o=e=>(0,r.T_)(e.provider,e.adapter).label;function s(e,t){switch(t){case"provider":{let t=o(e);return{key:"provider:".concat(t),label:t}}case"context-asc":case"context-desc":var l;return"number"!=typeof(l=e.contextWindow)||Number.isNaN(l)?{key:"ctx:unknown",label:"Unknown context"}:l<=8e3?{key:"ctx:<=8k",label:"≤ 8K tokens"}:l<=32e3?{key:"ctx:8k-32k",label:"8K–32K tokens"}:l<=128e3?{key:"ctx:32k-128k",label:"32K–128K tokens"}:l<=1e6?{key:"ctx:128k-1m",label:"128K–1M tokens"}:{key:"ctx:>1m",label:"> 1M tokens"};default:return(0,a.po)(n(e))}}function d(e,t){let l=(e,l)=>{switch(t){case"name-asc":return n(e).localeCompare(n(l));case"name-desc":return n(l).localeCompare(n(e));case"provider":return o(e).localeCompare(o(l))||n(e).localeCompare(n(l));case"context-desc":case"context-asc":{let r="number"!=typeof e.contextWindow||Number.isNaN(e.contextWindow)?void 0:e.contextWindow,a="number"!=typeof l.contextWindow||Number.isNaN(l.contextWindow)?void 0:l.contextWindow;if(void 0===r&&void 0===a)return n(e).localeCompare(n(l));if(void 0===r)return 1;if(void 0===a)return -1;let i="context-desc"===t?a-r:r-a;return 0!==i?i:n(e).localeCompare(n(l))}default:return 0}};return[...e].sort((e,t)=>{let r=Number(!!t.favorite)-Number(!!e.favorite);return 0!==r?r:l(e,t)})}},52397:(e,t,l)=>{"use strict";l.d(t,{RJ:()=>a,gF:()=>r});let r="masked:********",a="********"},81956:(e,t,l)=>{"use strict";l.d(t,{A:()=>y});var r=l(95155),a=l(12115),i=l(36314),n=l(86973),o=l(49501),s=l(17681),d=l(21067),c=l(2778),u=l(52363),p=l(65036),m=l(9562),h=l(75912),x=l(91871),f=l(9693),v=l(91665),g=l(7517),b=l(8190);let y=e=>{let{anchorEl:t,open:l,currentFolder:y,folders:A,onClose:j,onAssign:k}=e,[C,w]=(0,a.useState)(!1),[S,T]=(0,a.useState)(""),U=e=>{k(e),j()},L=()=>{let e=S.trim();e&&(w(!1),U(e))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.A,{anchorEl:t,open:l,onClose:j,children:[A.length>0&&A.map(e=>(0,r.jsxs)(n.A,{onClick:()=>U(e),selected:e===y,children:[(0,r.jsx)(o.A,{children:e===y?(0,r.jsx)(f.A,{fontSize:"small"}):(0,r.jsx)(v.A,{fontSize:"small"})}),(0,r.jsx)(s.A,{primary:e})]},e)),A.length>0&&(0,r.jsx)(d.A,{}),(0,r.jsxs)(n.A,{onClick:()=>{T(""),w(!0)},children:[(0,r.jsx)(o.A,{children:(0,r.jsx)(g.A,{fontSize:"small"})}),(0,r.jsx)(s.A,{primary:"New folder…"})]}),y&&(0,r.jsxs)(n.A,{onClick:()=>U(void 0),children:[(0,r.jsx)(o.A,{children:(0,r.jsx)(b.A,{fontSize:"small"})}),(0,r.jsx)(s.A,{primary:"Remove from folder"})]})]}),(0,r.jsxs)(c.A,{open:C,onClose:()=>w(!1),maxWidth:"xs",fullWidth:!0,children:[(0,r.jsx)(u.A,{children:"New folder"}),(0,r.jsx)(p.A,{children:(0,r.jsx)(m.A,{autoFocus:!0,margin:"dense",label:"Folder name",fullWidth:!0,value:S,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),L())}})}),(0,r.jsxs)(h.A,{children:[(0,r.jsx)(x.A,{onClick:()=>w(!1),children:"Cancel"}),(0,r.jsx)(x.A,{variant:"contained",disabled:!S.trim(),onClick:L,children:"Create"})]})]})]})}},88107:(e,t,l)=>{"use strict";l.d(t,{T_:()=>s,g3:()=>n,xx:()=>o});let r=/(^|[/_-])(o[1-9]|gpt-5)(?:[./_-]|$)/i,a=/claude-(?:fable|mythos)-5|claude-opus-4-(?:[7-9]|\d{2,})|claude-sonnet-5/i,i=/^(?:opus|sonnet|fable)$|claude-(?:fable|mythos)-5|claude-opus-4-(?:[6-9]|\d{2,})|claude-sonnet-4-6/i;function n(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=t||"openai",o=l.trim();if("codex-cli"===n)return{effortLevels:/^gpt-5\.6-(?:sol|terra)$/i.test(o)?["low","medium","high","xhigh","max","ultra"]:/^gpt-5\.6-/i.test(o)?["low","medium","high","xhigh","max"]:["low","medium","high","xhigh"],priority:!/(?:mini|spark|review)/i.test(o),maxOutputTokens:!1};if("claude-cli"===n)return{...i.test(o)?{effortLevels:["low","medium","high","xhigh","max"]}:{},maxOutputTokens:!1};if("anthropic"===n)return{...!a.test(o)?{creativity:{min:0,max:1,step:.1}}:{},...i.test(o)?{effortLevels:["low","medium","high","xhigh","max"]}:{},maxOutputTokens:!0};if("gemini"===n)return{creativity:{min:0,max:2,step:.1},.../^gemini-2\.5/i.test(o)?{thinkingBudget:!0}:!/^gemini-2\.0/i.test(o)?{thinkingLevels:["minimal","low","medium","high"]}:{},maxOutputTokens:!0};let s="openai"===(e||"openai")&&r.test(o);return{...!s?{creativity:{min:0,max:2,step:.1}}:{},...s?{effortLevels:["low","medium","high"]}:{},maxOutputTokens:!0}}let o=[{id:"openai",label:"OpenAI",provider:"openai",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://api.openai.com/v1",showBaseUrl:!0},{id:"openai-responses",label:"OpenAI (Responses API)",provider:"openai",adapter:"openai-responses",sdkLabel:"OpenAI SDK (Responses)",baseUrl:"https://api.openai.com/v1",showBaseUrl:!0,defaultModels:["gpt-5","gpt-5-mini","o4-mini","o3"]},{id:"openrouter",label:"OpenRouter",provider:"openrouter",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://openrouter.ai/api/v1",showBaseUrl:!0},{id:"requesty",label:"Requesty",provider:"requesty",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://router.requesty.ai/v1",showBaseUrl:!0},{id:"xai",label:"X.ai",provider:"xai",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://api.x.ai/v1",showBaseUrl:!0},{id:"ollama",label:"Ollama",provider:"ollama",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"http://localhost:11434/v1",showBaseUrl:!0},{id:"litellm",label:"LiteLLM",provider:"litellm",adapter:"openai",sdkLabel:"OpenAI SDK (via LiteLLM Proxy)",baseUrl:"http://localhost:4000/v1",showBaseUrl:!0},{id:"gemini-openai",label:"Gemini (OpenAI Format)",provider:"gemini",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://generativelanguage.googleapis.com/v1beta/openai/",showBaseUrl:!0},{id:"gemini-native",label:"Gemini (Native)",provider:"gemini",adapter:"gemini",sdkLabel:"GenAI SDK",baseUrl:"",showBaseUrl:!1,defaultModels:["gemini-2.5-pro","gemini-2.5-flash","gemini-2.5-flash-lite","gemini-2.0-flash"]},{id:"anthropic-openai",label:"Anthropic (OpenAI Format)",provider:"anthropic",adapter:"openai",sdkLabel:"OpenAI SDK",baseUrl:"https://api.anthropic.com/v1/",showBaseUrl:!0},{id:"anthropic-native",label:"Anthropic (Native)",provider:"anthropic",adapter:"anthropic",sdkLabel:"Anthropic SDK",baseUrl:"",showBaseUrl:!1,defaultModels:["claude-opus-4-8","claude-sonnet-4-6","claude-haiku-4-5-20251001","claude-fable-5"]},{id:"claude-subscription",label:"Claude Subscription",provider:"claude-subscription",adapter:"claude-cli",sdkLabel:"Claude CLI",baseUrl:"",showBaseUrl:!1,defaultModels:["opus","sonnet","haiku","fable"]},{id:"codex",label:"Codex (OpenAI)",provider:"codex",adapter:"codex-cli",sdkLabel:"Codex SDK",baseUrl:"",showBaseUrl:!1,defaultModels:["gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","gpt-5.5","gpt-5.4","gpt-5.4-mini"]}];function s(e,t){let l=e||"openai",r=t||"openai";return o.find(e=>e.provider===l&&e.adapter===r)||o.find(e=>e.provider===l)||o[0]}},97104:(e,t,l)=>{"use strict";l.d(t,{Aq:()=>a,Xk:()=>n,vi:()=>i});var r=l(12115);function a(e,t){try{let l=window.localStorage.getItem(e);if(null===l)return t;return JSON.parse(l)}catch(e){return t}}function i(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch(e){}}function n(e,t){let[l,n]=(0,r.useState)(()=>a(e,t));return[l,(0,r.useCallback)(t=>{n(l=>{let r="function"==typeof t?t(l):t;return i(e,r),r})},[e])]}}},e=>{e.O(0,[1137,7926,2678,4754,9244,3392,1871,981,2003,9562,488,3272,3077,8470,9581,7328,1675,3429,4919,6539,9164,3772,7445,8441,1255,7358],()=>e(e.s=15894)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7262],{70479:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>e0});var n=a(95155),r=a(12115),s=a(94049),l=a(20063),i=a(80777),o=a(25635),c=a(28548),d=a(91871),u=a(2300),h=a(86946),p=a(40047),m=a(33567),x=a(15712),g=a(9562),f=a(56422),y=a(41602),v=a(23820),w=a(73707),j=a(49501),b=a(22822),A=a(17681),k=a(4474),S=a(22003),C=a(41275),E=a(21067),I=a(55606),T=a(86973),F=a(99944),P=a(9957),N=a(2778),W=a(52363),z=a(65036),R=a(95844),O=a(71908),U=a(64246),L=a(75912),H=a(51611),M=a(66087),D=a(57813),J=a(26466),q=a(87021);let G=(0,q.h)("frontend/services/registry");async function _(e){return await e.json().catch(()=>({}))}class B{async getStatus(){let e=await fetch("/api/registry/auth",{method:"GET"});if(!e.ok)throw Error("HTTP ".concat(e.status));return _(e)}async auth(e,t,a,n){let r=await fetch("/api/registry/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,email:t,password:a,...n?{handle:n}:{}})}),s=await _(r);if(!r.ok&&(null==s?void 0:s.status)===void 0)throw Error((null==s?void 0:s.error)||"HTTP ".concat(r.status));return s}signup(e,t,a){return this.auth("signup",e,t,a)}login(e,t){return this.auth("login",e,t)}async logout(){let e=await fetch("/api/registry/auth",{method:"DELETE"});if(!e.ok)throw Error("HTTP ".concat(e.status))}async beginOAuth(e){let t=await fetch("/api/registry/oauth/initiate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})}),a=await _(t);if(!t.ok||!(null==a?void 0:a.authorizationUrl))throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return{authorizationUrl:a.authorizationUrl}}async resendConfirmation(e){return _(await fetch("/api/registry/auth/resend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{email:e}:{})}))}async requestPasswordReset(e){return _(await fetch("/api/registry/auth/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})}))}async getSettings(){let e=await fetch("/api/registry/settings",{method:"GET"});if(!e.ok)throw Error("HTTP ".concat(e.status));return _(e)}async saveSettings(e){return _(await fetch("/api/registry/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e})}))}async publish(e){let t=await fetch("/api/registry/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manifest:e})}),a=await _(t);return(null==a?void 0:a.ok)===void 0?(G.warn("Unexpected publish response shape",{status:t.status}),{ok:!1,code:"error",error:"HTTP ".concat(t.status)}):a}async deletePackage(e){let t=await fetch("/api/registry/packages",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({packageId:e})}),a=await _(t);return(null==a?void 0:a.ok)===void 0?(G.warn("Unexpected package deletion response shape",{status:t.status}),{ok:!1,code:"error",error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)}):a}}let V=null,Z=()=>(V||(V=new B),V),K=new Proxy({},{get(e,t){let a=Z(),n=a[t];return"function"==typeof n?n.bind(a):n}}),$=(0,q.h)("frontend/components/Packages/RegistryAccountSettings");function Y(){let[e,t]=(0,r.useState)(null),[a,l]=(0,r.useState)(!0),[u,h]=(0,r.useState)(!1),[p,m]=(0,r.useState)(null),[x,f]=(0,r.useState)("login"),[y,v]=(0,r.useState)(""),[w,j]=(0,r.useState)(""),[b,A]=(0,r.useState)(""),[C,I]=(0,r.useState)(""),[T,F]=(0,r.useState)(""),P=(0,r.useCallback)(async()=>{try{let[e,a]=await Promise.all([K.getStatus(),K.getSettings()]);t(e),F(a.defaultUrl),I(a.usingDefault?"":a.baseUrl)}catch(e){$.warn("Failed to load registry account status",e)}finally{l(!1)}},[]);(0,r.useEffect)(()=>{P()},[P]),(0,r.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get("registry_oauth");if(!t)return;m("success"===t?{type:"success",text:"Signed in to the package registry."}:{type:"error",text:"OAuth sign-in did not complete. Please try again."}),P(),e.delete("registry_oauth");let a=e.toString();window.history.replaceState({},"",window.location.pathname+(a?"?".concat(a):""))},[P]);let N=async()=>{h(!0),m(null);try{let e="signup"===x?await K.signup(y.trim(),w,b.trim()):await K.login(y.trim(),w);"authenticated"===e.status?(m({type:"success",text:"Signed in to the package registry."}),j("")):"confirmation_required"===e.status?(m({type:"info",text:e.message||"Check your inbox to confirm your email."}),j("")):m({type:"error",text:e.message||"Authentication failed."}),e.account?t(e.account):await P()}catch(e){m({type:"error",text:e instanceof Error?e.message:"Authentication failed."})}finally{h(!1)}},W=async()=>{h(!0),m(null);try{await K.logout(),await P(),m({type:"success",text:"Logged out."})}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to log out."})}finally{h(!1)}},z=async e=>{h(!0),m(null);try{let{authorizationUrl:t}=await K.beginOAuth(e);window.location.assign(t)}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to start OAuth sign-in."}),h(!1)}},R=async()=>{h(!0),m(null);try{let e=await K.resendConfirmation();m(e.success?{type:"success",text:"Confirmation email sent."}:{type:"error",text:e.message||"Failed to resend confirmation."})}finally{h(!1)}},O=async()=>{let e=y.trim();if(!e)return void m({type:"info",text:"Enter your account email above, then tap “Forgot password?”."});h(!0),m(null);try{await K.requestPasswordReset(e),m({type:"info",text:"If an account exists for that email, a password-reset link is on its way. Follow the link to set a new password."})}catch(e){m({type:"error",text:e instanceof Error?e.message:"Failed to request a password reset."})}finally{h(!1)}},U=async()=>{h(!0),m(null);try{let e=await K.saveSettings(C.trim());m(e.success?{type:"success",text:"Registry URL saved."}:{type:"error",text:e.message||"Invalid registry URL."})}finally{h(!1)}};if(a)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,n.jsx)(k.default,{size:28})});let L=!!(null==e?void 0:e.signedIn),H=!!((null==e?void 0:e.email)&&!L&&e&&!e.isConfirmed);return(0,n.jsxs)(s.default,{sx:{width:"100%"},children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Sign in to the FLUJO package registry to publish packages. Browsing and installing packages does not require an account — only publishing does, and your email must be confirmed first. Your registry tokens are encrypted at rest and never shown here."}),p&&(0,n.jsx)(S.A,{severity:p.type,sx:{mb:2},onClose:()=>m(null),children:p.text}),L?(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(o.default,{variant:"subtitle1",children:null==e?void 0:e.email}),(null==e?void 0:e.publisherHandle)&&(0,n.jsx)(c.A,{size:"small",label:"@".concat(e.publisherHandle)}),(null==e?void 0:e.isConfirmed)?(0,n.jsx)(c.A,{size:"small",color:"success",label:"Confirmed"}):(0,n.jsx)(c.A,{size:"small",color:"warning",label:"Unconfirmed"})]}),(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"outlined",onClick:W,disabled:u,children:"Log out"})})]}):H?(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(S.A,{severity:"info",children:["We sent a confirmation link to ",(0,n.jsx)("strong",{children:null==e?void 0:e.email}),". Confirm your email, then log in to start publishing."]}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,children:[(0,n.jsx)(d.A,{variant:"outlined",onClick:R,disabled:u,children:"Resend confirmation email"}),(0,n.jsx)(d.A,{onClick:W,disabled:u,children:"Use a different account"})]})]}):(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(D.A,{value:x,onChange:(e,t)=>f(t),children:[(0,n.jsx)(J.A,{value:"login",label:"Log in"}),(0,n.jsx)(J.A,{value:"signup",label:"Sign up"})]}),(0,n.jsx)(g.A,{label:"Email",type:"email",value:y,onChange:e=>v(e.target.value),fullWidth:!0,autoComplete:"username"}),(0,n.jsx)(g.A,{label:"Password",type:"password",value:w,onChange:e=>j(e.target.value),fullWidth:!0,autoComplete:"signup"===x?"new-password":"current-password"}),"signup"===x&&(0,n.jsx)(g.A,{label:"Publisher handle",value:b,onChange:e=>A(e.target.value),fullWidth:!0,autoComplete:"username",helperText:"A unique handle for publishing packages, e.g. your-name"}),(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"contained",onClick:N,disabled:u||!y.trim()||!w||"signup"===x&&!b.trim(),children:"signup"===x?"Sign up":"Log in"})}),"login"===x&&(0,n.jsx)(s.default,{children:(0,n.jsx)(d.A,{variant:"text",size:"small",onClick:O,disabled:u,sx:{textTransform:"none",px:0},children:"Forgot password?"})}),(0,n.jsx)(E.A,{children:"or"}),(0,n.jsx)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:(0,n.jsx)(d.A,{variant:"outlined",onClick:()=>z("github"),disabled:u,children:"Continue with GitHub"})})]}),(0,n.jsx)(E.A,{sx:{my:3}}),(0,n.jsx)(o.default,{variant:"subtitle2",gutterBottom:!0,children:"Registry URL"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1},children:["Leave blank to use the default (",T,")."]}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(g.A,{size:"small",placeholder:T,value:C,onChange:e=>I(e.target.value),sx:{minWidth:320}}),(0,n.jsx)(d.A,{variant:"outlined",onClick:U,disabled:u,children:"Save"})]})]})}var Q=a(90057),X=a(43076),ee=a(17897),et=a(93632);let ea=(0,q.h)("frontend/services/packages");class en{async resolve(e){let t=await fetch("/api/packages/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return a}async deriveSecrets(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=await fetch("/api/packages/derive-secrets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e,modelIdentifier:t.modelIdentifier,enableEntropy:t.enableEntropy,enableRepoSlug:t.enableRepoSlug})}),n=await a.json();if(!a.ok)throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return n}async scanTargets(e){var t;let a=await fetch("/api/packages/scan-targets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e})}),n=await a.json();if(!a.ok)throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return null!=(t=null==n?void 0:n.candidates)?t:[]}async searchRegistry(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;e.q&&t.set("q",e.q),e.tag&&t.set("tag",e.tag),e.page&&t.set("page",String(e.page)),e.pageSize&&t.set("pageSize",String(e.pageSize));let a=await fetch("/api/packages/search".concat(t.toString()?"?".concat(t.toString()):"")),n=await a.json();if(!a.ok&&!(null==n?void 0:n.items))throw Error((null==n?void 0:n.error)||"HTTP ".concat(a.status));return n}async installFromRegistry(e){let t=await fetch("/api/packages/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"registry",...e})}),a=await t.json();if(!t.ok&&(null==a?void 0:a.ok)===void 0)throw Error((null==a?void 0:a.error)||"HTTP ".concat(t.status));return a}async build(e,t){var a;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=await fetch("/api/packages/build",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selection:e,metadata:t,acceptedSecrets:n,globals:r,excludedSecrets:s})}),i=null!=(a=l.headers.get("content-type"))?a:"";if(!i.includes("application/json")){let e=await l.text();throw ea.error("Package build returned a non-JSON response",{status:l.status,contentType:i,preview:e.slice(0,200)}),Error("Package build failed: HTTP ".concat(l.status," returned a non-JSON response"))}let o=await l.json();if(!l.ok&&(null==o?void 0:o.ok)===void 0)throw Error((null==o?void 0:o.error)||"HTTP ".concat(l.status));return o}}let er=null,es=()=>(er||(er=new en),er),el=new Proxy({},{get(e,t){let a=es(),n=a[t];return"function"==typeof n?n.bind(a):n}}),ei=/\{\{secret\.([A-Za-z0-9_.-]+)\}\}/g,eo="encrypted:",ec=/^[A-Za-z0-9_.-]+$/,ed=["path","repo","token","email","url-cred","name","other"];function eu(e){let t=new Set,a=e=>{if("string"==typeof e){for(let a of function(e){let t;if("string"!=typeof e)return[];let a=[],n=RegExp(ei.source,"g");for(;null!==(t=n.exec(e));)a.includes(t[1])||a.push(t[1]);return a}(e))t.add(a);return}if(Array.isArray(e)){for(let t of e)a(t);return}if(e&&"object"==typeof e)for(let t of Object.values(e))a(t)};return a(e),Array.from(t)}var eh=a(2750);let ep=eh.object({name:eh.string().min(1).regex(ec,"invalid secret name"),description:eh.string().optional(),required:eh.boolean(),default:eh.string().optional()}).strict(),em=eh.object({name:eh.string().min(1).regex(ec,"invalid global variable name"),description:eh.string().optional(),required:eh.boolean(),isSecret:eh.boolean().optional()}).strict(),ex=eh.discriminatedUnion("kind",[eh.object({kind:eh.literal("secret"),secret:eh.string().min(1)}).strict(),eh.object({kind:eh.literal("global"),var:eh.string().min(1)}).strict(),eh.object({kind:eh.literal("none")}).strict()]),eg=eh.object({id:eh.string().min(1),name:eh.string().min(1),displayName:eh.string().optional(),description:eh.string().optional(),baseUrl:eh.string().optional(),provider:eh.string().optional(),adapter:eh.string().optional(),promptTemplate:eh.string().optional(),reasoningSchema:eh.string().optional(),temperature:eh.string().optional(),reasoningEffort:eh.enum(["minimal","low","medium","high","xhigh","max","ultra"]).optional(),thinkingLevel:eh.enum(["minimal","low","medium","high"]).optional(),thinkingBudget:eh.number().int().min(-1).optional(),serviceTier:eh.enum(["default","priority"]).optional(),functionCallingSchema:eh.string().optional(),contextWindow:eh.number().optional(),maxTurns:eh.number().optional(),maxTokens:eh.number().optional(),folder:eh.string().optional(),favorite:eh.boolean().optional(),apiKeyRef:ex}).strict(),ef=eh.object({sourceType:eh.enum(["github","registry","marketplace","remote"]),ref:eh.string().optional(),url:eh.string().optional(),name:eh.string().optional()}).strict().superRefine((e,t)=>{"remote"!==e.sourceType||e.url||t.addIssue({code:"custom",message:"installOrigin 'remote' requires a url"}),"github"!==e.sourceType&&"registry"!==e.sourceType||e.ref||t.addIssue({code:"custom",message:"installOrigin '".concat(e.sourceType,"' requires a ref")})}),ey=eh.object({name:eh.string().min(1),isSecret:eh.boolean(),secretRef:eh.string().optional(),globalVar:eh.string().optional()}).strict(),ev=eh.object({name:eh.string().min(1),transport:eh.enum(["stdio","sse","streamable","websocket"]),disabled:eh.boolean().optional(),autoApprove:eh.array(eh.string()).optional(),folder:eh.string().optional(),installOrigin:ef,envDeclarations:eh.array(ey),headerDeclarations:eh.array(ey).optional()}).strict(),ew=eh.object({flow:eh.object({id:eh.string().min(1),name:eh.string().min(1),nodes:eh.array(eh.any()),edges:eh.array(eh.any())}).catchall(eh.unknown()),references:eh.object({flowIds:eh.array(eh.string()).optional(),modelIds:eh.array(eh.string()).optional(),mcpServerNames:eh.array(eh.string()).optional()}).optional()}),ej=eh.object({id:eh.string().min(1),name:eh.string().min(1),enabled:eh.boolean(),flowId:eh.string().min(1),prompt:eh.string(),trigger:eh.any()}).catchall(eh.unknown()),eb=eh.object({schemaVersion:eh.literal(1),id:eh.string().min(1),name:eh.string().min(1),description:eh.string().optional(),version:eh.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/,"version must be valid semver"),author:eh.string().optional(),publisher:eh.string().optional(),tags:eh.array(eh.string()).optional(),requiredGlobals:eh.array(eh.string()).optional(),globals:eh.array(em).optional(),secrets:eh.array(ep),models:eh.array(eg),mcpServers:eh.array(ev),flows:eh.array(ew),plannedExecutions:eh.array(ej)}).superRefine((e,t)=>{(function e(t){return"string"==typeof t?t.startsWith(eo):Array.isArray(t)?t.some(e):!!t&&"object"==typeof t&&Object.values(t).some(e)})(e)&&t.addIssue({code:"custom",message:"package contains an '".concat(eo,"' value; secret material must never be serialized")});let a=new Set(e.secrets.map(e=>e.name)),n=new Set(eu(e));for(let t of e.models)"secret"===t.apiKeyRef.kind&&n.add(t.apiKeyRef.secret);for(let t of e.mcpServers){var r;for(let e of[...t.envDeclarations,...null!=(r=t.headerDeclarations)?r:[]])e.secretRef&&n.add(e.secretRef)}for(let e of n)a.has(e)||t.addIssue({code:"custom",message:'secret "'.concat(e,'" is referenced but not declared in secrets[]')});let s=new Set(e.flows.map(e=>e.flow.id));e.plannedExecutions.forEach((e,a)=>{s.has(e.flowId)||t.addIssue({code:"custom",path:["plannedExecutions",a,"flowId"],message:'plannedExecution "'.concat(e.name,'" references unknown flow id "').concat(e.flowId,'"')})}),e.flows.forEach((e,a)=>{var n,r;for(let l of null!=(r=null==(n=e.references)?void 0:n.flowIds)?r:[])s.has(l)||t.addIssue({code:"custom",path:["flows",a,"references","flowIds"],message:'flow "'.concat(e.flow.name,'" references unknown subflow id "').concat(l,'"')})})}),eA=(0,q.h)("frontend/components/Packages/PackageWizard"),ek=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/,eS=["Select contents","Resolve & validate","Secret review","Metadata","Export"];function eC(e){return e.replace(/^SECRET_/,"")}function eE(e){let{open:t,onClose:a}=e,l=(0,m.A)(),u=(0,x.A)(l.breakpoints.down("sm")),[h,p]=(0,r.useState)(0),[D,J]=(0,r.useState)({flows:[],models:[],mcpServers:[],plannedExecutions:[]}),[q,G]=(0,r.useState)(!0),[_,B]=(0,r.useState)(new Set),[V,K]=(0,r.useState)(new Set),[$,ea]=(0,r.useState)(new Set),[en,er]=(0,r.useState)(new Set),[el,ei]=(0,r.useState)(""),[eo,eh]=(0,r.useState)(""),[ep,em]=(0,r.useState)(""),[ex,eg]=(0,r.useState)(""),[ef,ey]=(0,r.useState)(null),[ev,ew]=(0,r.useState)([]),[ej,eE]=(0,r.useState)(!1),[eI,eT]=(0,r.useState)(null),[eF,eP]=(0,r.useState)(null),[eN,eW]=(0,r.useState)({}),[ez,eR]=(0,r.useState)(new Set),[eO,eU]=(0,r.useState)([]),[eL,eH]=(0,r.useState)(!1),[eM,eD]=(0,r.useState)(!1),[eJ,eq]=(0,r.useState)(null),[eG,e_]=(0,r.useState)([]),[eB,eV]=(0,r.useState)(""),[eZ,eK]=(0,r.useState)(""),[e$,eY]=(0,r.useState)(!1),[eQ,eX]=(0,r.useState)(!1),[e0,e1]=(0,r.useState)(""),[e2,e5]=(0,r.useState)(""),[e4,e3]=(0,r.useState)("other"),[e6,e7]=(0,r.useState)(null),[e8,e9]=(0,r.useState)(!1),[te,tt]=(0,r.useState)(!1),[ta,tn]=(0,r.useState)(null),[tr,ts]=(0,r.useState)([]),[tl,ti]=(0,r.useState)(""),[to,tc]=(0,r.useState)(!1),[td,tu]=(0,r.useState)(""),[th,tp]=(0,r.useState)("1.0.0"),[tm,tx]=(0,r.useState)(""),[tg,tf]=(0,r.useState)(""),[ty,tv]=(0,r.useState)(!1),[tw,tj]=(0,r.useState)(null),[tb,tA]=(0,r.useState)(null),[tk,tS]=(0,r.useState)(!1),[tC,tE]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{G(!0);try{var t;let[a,n,r,s]=await Promise.all([Q.g.loadFlows(),X.N.loadModels(),ee.S.loadServerConfigs(),et.P.list()]);if(e)return;let l=Array.isArray(r)?r:[];J({flows:(null!=a?a:[]).map(e=>({id:e.id,label:e.name||e.id})),models:(null!=n?n:[]).map(e=>({id:e.id,label:e.displayName||e.name||e.id})),mcpServers:l.map(e=>({id:e.name,label:e.name})),plannedExecutions:(null!=(t=null==s?void 0:s.executions)?t:[]).map(e=>({id:e.execution.id,label:e.execution.name||e.execution.id}))})}catch(e){eA.warn("Failed to load packageable entities",e)}finally{e||G(!1)}})(),()=>{e=!0}},[t]);let tI=(0,r.useMemo)(()=>({flowIds:Array.from(_),modelIds:Array.from(V),mcpServerNames:Array.from($),plannedExecutionIds:Array.from(en)}),[_,V,$,en]),tT=0===_.size&&0===V.size&&0===$.size&&0===en.size,tF=e=>t=>{e(e=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a})},tP=(0,r.useCallback)(async e=>{let t;ew([]);try{t=await e.text()}catch(e){ew([e instanceof Error?e.message:"Failed to read the file"]);return}let a=function(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,errors:["Not valid JSON: ".concat(e instanceof Error?e.message:String(e))]}}let a=function(e){let t=eb.safeParse(e);if(!t.success)return{success:!1,errors:t.error.issues.map(e=>{let t=e.path.join(".");return t?"".concat(t,": ").concat(e.message):e.message})};let a=t.data;return{success:!0,data:a,warnings:function(e){let t=new Set(eu(e));for(let a of e.models)"secret"===a.apiKeyRef.kind&&t.add(a.apiKeyRef.secret);for(let n of e.mcpServers){var a;for(let e of[...n.envDeclarations,...null!=(a=n.headerDeclarations)?a:[]])e.secretRef&&t.add(e.secretRef)}return e.secrets.filter(e=>!t.has(e.name)).map(e=>'secret "'.concat(e.name,'" is declared but never referenced'))}(a)}}(t);if(!a.success||!a.data){var n;return{ok:!1,errors:null!=(n=a.errors)?n:["Not a valid FLUJO package manifest"]}}return{ok:!0,package:a.data}}(t);if(!a.ok){ey(null),ew(a.errors.slice(0,8));return}let n=function(e,t){var a,n,r,s,l,i,o,c,d,u;let h=new Set(t.flowIds),p=new Set(t.modelIds),m=new Set(t.mcpServerNames),x=new Set(t.plannedExecutionIds),g=[],f={flowIds:[],modelIds:[],mcpServerNames:[],plannedExecutionIds:[]};for(let t of null!=(a=e.flows)?a:[]){let e=null==t||null==(n=t.flow)?void 0:n.id;e&&(h.has(e)?f.flowIds.push(e):g.push({type:"flow",label:(null==(r=t.flow)?void 0:r.name)?"".concat(t.flow.name," (").concat(e,")"):e}))}for(let t of null!=(s=e.models)?s:[])(null==t?void 0:t.id)&&(p.has(t.id)?f.modelIds.push(t.id):g.push({type:"model",label:t.displayName||t.name||t.id}));for(let t of null!=(l=e.mcpServers)?l:[])(null==t?void 0:t.name)&&(m.has(t.name)?f.mcpServerNames.push(t.name):g.push({type:"mcpServer",label:t.name}));for(let t of null!=(i=e.plannedExecutions)?i:[]){let e=null==t?void 0:t.id;e&&(x.has(e)?f.plannedExecutionIds.push(e):g.push({type:"plannedExecution",label:t.name||e}))}return{selection:f,metadata:{name:null!=(o=e.name)?o:"",version:null!=(c=e.version)?c:"",description:null!=(d=e.description)?d:"",tags:e.tags?[...e.tags]:[]},secretNames:(null!=(u=e.secrets)?u:[]).map(e=>e.name).filter(Boolean),missing:g}}(a.package,{flowIds:D.flows.map(e=>e.id),modelIds:D.models.map(e=>e.id),mcpServerNames:D.mcpServers.map(e=>e.id),plannedExecutionIds:D.plannedExecutions.map(e=>e.id)});B(new Set(n.selection.flowIds)),K(new Set(n.selection.modelIds)),ea(new Set(n.selection.mcpServerNames)),er(new Set(n.selection.plannedExecutionIds)),tu(n.metadata.name),tp(n.metadata.version),tx(n.metadata.description),tf(n.metadata.tags.join(", ")),eT(null),eP(null),eW({}),eR(new Set),eU([]),eD(!1),eq(null),e_([]),tj(null),tA(null),tE(null),ey(n),eA.info("Imported package manifest into the wizard",{name:n.metadata.name,version:n.metadata.version,missing:n.missing.length})},[D]),tN=(0,r.useCallback)(async()=>{eE(!0),eP(null),eT(null),eW({}),eR(new Set),eU([]),eD(!1),eq(null),e_([]);try{var e;let t=await es().resolve(tI);eT(t),eW(Object.fromEntries((null!=(e=t.globals)?e:[]).map(e=>{var t;return[e.name,null!=(t=e.description)?t:""]})))}catch(e){eP(e instanceof Error?e.message:"Failed to resolve dependencies")}finally{eE(!1)}},[tI]),tW=(0,r.useMemo)(()=>ef?new Set(ef.secretNames):null,[ef]),tz=(0,r.useCallback)(async e=>{eH(!0),eq(null);try{var t;let a=await es().deriveSecrets(tI,{modelIdentifier:e,enableEntropy:e$,enableRepoSlug:eQ});eU(e=>{let t=new Map(e.map(e=>[e.id,e.accepted])),n=new Map(e.map(e=>[e.id,e.suggestedSecretName])),r=e.filter(e=>"manual"===e.source),s=a.proposals.map(e=>{var a;return{...e,accepted:t.has(e.id)?t.get(e.id):tW?tW.has(e.suggestedSecretName):"low"!==e.confidence,suggestedSecretName:null!=(a=n.get(e.id))?a:e.suggestedSecretName}}),l=new Set(s.map(e=>e.id));return[...s,...r.filter(e=>!l.has(e.id))]}),e_(null!=(t=a.warnings)?t:[])}catch(e){eq(e instanceof Error?e.message:"Failed to derive secrets")}finally{eH(!1),eD(!0)}},[tI,e$,eQ,tW]),tR=e=>eU(t=>t.map(t=>({...t,accepted:e}))),tO=()=>{e7(null);let e=function(e){var t,a,n,r,s;let l=(null!=(a=e.excerpt)?a:"").trim();if(!l||l.length>2e3)return null;let i=(null!=(n=e.secretName)?n:"").trim();if(i.length>128)return null;let o=null!=(r=e.kind)?r:"other",c=ec.test(i)?i.toUpperCase():function(e,t){let a="".concat(e,"_").concat(t).toUpperCase().replace(/[^A-Z0-9_.-]+/g,"_").replace(/^[_.-]+|[_.-]+$/g,"")||"".concat(e,"_SECRET");return ec.test(a)?a:"".concat(e,"_SECRET")}("SECRET",i||l.slice(0,16)),d=(null!=(s=e.location)?s:"manual").trim()||"manual";return{id:"sp_".concat(function(e){let t=5381;for(let a=0;a<e.length;a++)t=(t<<5)+t^e.charCodeAt(a);return(t>>>0).toString(16).padStart(8,"0")}("".concat(d,"\0").concat(l))),location:d,excerpt:l,kind:o,source:"manual",confidence:"high",suggestedSecretName:c,suggestedDescription:(null==(t=e.description)?void 0:t.trim())||void 0,rationale:"Added manually",accepted:!0}}({excerpt:e0,secretName:e2,kind:e4});if(!e)return void e7("Enter a non-empty value to redact (under 2000 characters).");eU(t=>t.some(t=>t.id===e.id)?t:[e,...t]),e1(""),e5(""),e3("other")},tU=(0,r.useCallback)(async()=>{e9(!0),tn(null),ti(""),tt(!0);try{let e=await es().scanTargets(tI);ts(e)}catch(e){tn(e instanceof Error?e.message:"Failed to load candidate values"),ts([])}finally{tt(!1)}},[tI]),tL=(0,r.useMemo)(()=>{let e=tl.trim().toLowerCase();return e?tr.filter(t=>"".concat(t.text," ").concat(t.location," ").concat(t.source).toLowerCase().includes(e)):tr},[tr,tl]),tH=(0,r.useMemo)(()=>{let e=new Map;for(let t of eO){let a="".concat(t.kind,"::").concat(t.excerpt),n=e.get(a);n?(n.ids.push(t.id),n.locations.push(t.location)):e.set(a,{key:a,ids:[t.id],locations:[t.location],kind:t.kind,source:t.source,confidence:t.confidence,excerpt:t.excerpt,suggestedSecretName:t.suggestedSecretName,rationale:t.rationale,accepted:t.accepted})}return Array.from(e.values())},[eO]),tM=(0,r.useMemo)(()=>{let e=eZ.trim().toLowerCase();return e?tH.filter(t=>"".concat(t.excerpt," ").concat(t.locations.join(" ")," ").concat(t.kind," ").concat(t.suggestedSecretName).toLowerCase().includes(e)):tH},[tH,eZ]),tD=(0,r.useMemo)(()=>{var e;if(!ef||!eM)return[];let t=new Set([...(null!=(e=null==eI?void 0:eI.secrets)?e:[]).map(e=>e.name),...eO.map(e=>e.suggestedSecretName)]);return ef.secretNames.filter(e=>!t.has(e))},[ef,eM,eI,eO]),tJ=(0,r.useMemo)(()=>{var e;let t=new Map;for(let a of tH)t.set(a.kind,(null!=(e=t.get(a.kind))?e:0)+1);return Array.from(t.entries()).sort((e,t)=>t[1]-e[1])},[tH]);(0,r.useEffect)(()=>{2!==h||!eI||eM||eL||tz()},[h,eI,eM,eL,tz]);let tq=(0,r.useCallback)(async()=>{tv(!0),tA(null),tj(null);try{var e;let t=tg.split(",").map(e=>e.trim()).filter(Boolean),a=await es().build(tI,{id:"pkg-".concat(Date.now()),name:td.trim(),version:th.trim(),description:tm.trim()||void 0,tags:t.length?t:void 0},eO.filter(e=>e.accepted),(null!=(e=null==eI?void 0:eI.globals)?e:[]).map(e=>{var t;return{...e,description:(null==(t=eN[e.name])?void 0:t.trim())||e.description}}),Array.from(ez));tj(a),a.ok||tA(a.errors&&a.errors[0]||"Package build failed")}catch(e){tA(e instanceof Error?e.message:"Failed to build package")}finally{tv(!1)}},[tI,td,th,tm,tg,eO,eI,eN,ez]),tG=(0,r.useCallback)(async()=>{if(null==tw?void 0:tw.json){tS(!0),tE(null);try{let e=JSON.parse(tw.json),t=await Z().publish(e);tE(t)}catch(e){tE({ok:!1,code:"error",error:e instanceof Error?e.message:"Failed to publish package"})}finally{tS(!1)}}},[tw]),t_=()=>{if(!(null==tw?void 0:tw.json))return;let e=new Blob([tw.json],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t;let n=td.trim().replace(/[^A-Za-z0-9_.-]+/g,"-").replace(/^-+|-+$/g,"")||"package";a.download="".concat(n,"-").concat(th.trim(),".flujo-package.json"),document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(t)},tB=async()=>{if(0===h){await tN(),p(1);return}if(3===h){p(4),await tq();return}p(e=>Math.min(e+1,eS.length-1))},tV=ek.test(th.trim()),tZ=td.trim().length>0&&tV,tK=!!(eI&&!eI.mcp.ok),t$=0===h?tT||ej:1===h?ej||!!eF||tK:3===h?!tZ:4===h,tY=(e,t,a,r,l,i)=>{let d=l.trim().toLowerCase(),u=d?t.filter(e=>e.label.toLowerCase().includes(d)):t;return(0,n.jsxs)(s.default,{sx:{flex:1,minWidth:240},children:[(0,n.jsxs)(o.default,{variant:"subtitle2",gutterBottom:!0,children:[e," ",a.size>0&&(0,n.jsx)(c.A,{label:a.size,size:"small"})]}),(0,n.jsx)(g.A,{size:"small",fullWidth:!0,placeholder:"Search ".concat(e.toLowerCase(),"…"),value:l,onChange:e=>i(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})})},sx:{mb:1}}),0===t.length?(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"None available"}):0===u.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No matches for “",l,"”."]}):(0,n.jsx)(y.A,{dense:!0,sx:{maxHeight:{xs:240,md:"45vh"},overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:u.map(e=>(0,n.jsx)(v.Ay,{disablePadding:!0,children:(0,n.jsxs)(w.A,{onClick:()=>r(e.id),dense:!0,children:[(0,n.jsx)(j.A,{sx:{minWidth:36},children:(0,n.jsx)(b.A,{edge:"start",checked:a.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,n.jsx)(A.A,{primary:e.label})]})},e.id))})]})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(N.A,{open:t,onClose:a,maxWidth:"lg",fullWidth:!0,fullScreen:u,PaperProps:{sx:{height:u?"100%":"90vh",maxHeight:u?"100%":"90vh"}},children:[(0,n.jsx)(W.A,{children:"Create package"}),(0,n.jsxs)(z.A,{dividers:!0,sx:{overflow:"auto"},children:[(0,n.jsx)(R.A,{activeStep:h,sx:{mb:3},children:eS.map(e=>(0,n.jsx)(O.A,{children:(0,n.jsx)(U.A,{children:e})},e))}),(()=>{switch(h){case 0:return q?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})}):(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Pick the entities to include. Dependencies (subflows, referenced models and MCP servers, planned-execution flows) are pulled in automatically in the next step."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsxs)(d.A,{component:"label",variant:"outlined",startIcon:(0,n.jsx)(M.A,{}),children:["Import manifest (.json)",(0,n.jsx)("input",{type:"file",accept:"application/json,.json",hidden:!0,onChange:e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];e.target.value="",a&&tP(a)}})]}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"Restores the selection, metadata and accepted secrets from a package you exported earlier."})]}),ev.length>0&&(0,n.jsxs)(S.A,{severity:"error",onClose:()=>ew([]),children:[(0,n.jsx)(C.A,{children:"Could not import that file"}),ev.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),ef&&(0,n.jsxs)(S.A,{severity:ef.missing.length>0?"warning":"success",children:[(0,n.jsxs)(C.A,{children:["Imported “",ef.metadata.name,"” v",ef.metadata.version]}),"Restored ",ef.selection.flowIds.length," flow(s),"," ",ef.selection.modelIds.length," model(s),"," ",ef.selection.mcpServerNames.length," MCP server(s),"," ",ef.selection.plannedExecutionIds.length," planned execution(s) and"," ",ef.secretNames.length," secret name(s).",ef.missing.length>0&&(0,n.jsxs)(s.default,{sx:{mt:1},children:["No longer on this host (left unselected):",ef.missing.map((e,t)=>(0,n.jsxs)("div",{children:[e.type,": ",e.label]},t))]})]}),(0,n.jsxs)(i.A,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[tY("Flows",D.flows,_,tF(B),el,ei),tY("Models",D.models,V,tF(K),eo,eh),tY("MCP servers",D.mcpServers,$,tF(ea),ep,em),tY("Planned executions",D.plannedExecutions,en,tF(er),ex,eg)]})]});case 1:if(ej)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})});if(eF)return(0,n.jsx)(S.A,{severity:"error",children:eF});if(!eI)return null;return(0,n.jsxs)(i.A,{spacing:2,children:[tK&&(0,n.jsxs)(S.A,{severity:"error",children:[(0,n.jsx)(C.A,{children:"Local MCP server(s) cannot be packaged"}),eI.mcp.errors.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),eI.resolved.autoAdded.length>0&&(0,n.jsxs)(S.A,{severity:"info",children:[(0,n.jsx)(C.A,{children:"Automatically included dependencies"}),eI.resolved.autoAdded.map((e,t)=>(0,n.jsxs)("div",{children:[e.type,": ",(0,n.jsx)("code",{children:e.id})," — ",e.reason]},t))]}),eI.resolved.warnings.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Warnings"}),eI.resolved.warnings.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(E.A,{}),(0,n.jsxs)(o.default,{variant:"body2",children:["Resolved: ",eI.resolved.flowIds.length," flow(s),"," ",eI.resolved.modelIds.length," model(s),"," ",eI.resolved.mcpServerNames.length," MCP server(s),"," ",eI.resolved.plannedExecutionIds.length," planned execution(s)."]}),eI.mcp.servers.length>0&&(0,n.jsx)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:eI.mcp.servers.map(e=>(0,n.jsx)(c.A,{label:"".concat(e.name," \xb7 ").concat(e.sourceType),size:"small",color:"success",variant:"outlined"},e.name))})]});case 2:var e;return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(o.default,{variant:"subtitle2",children:"Global variables"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Global variables referenced by the package. Add a useful description for each one; installers will supply values and FLUJO will create them in Global Variables."}),eI&&0!==(null!=(e=eI.globals)?e:[]).length?(0,n.jsx)(i.A,{spacing:1.5,children:eI.globals.map(e=>{var t;return(0,n.jsx)(g.A,{size:"small",label:e.name,value:null!=(t=eN[e.name])?t:"",onChange:t=>eW(a=>({...a,[e.name]:t.target.value})),helperText:"Description shown during package installation",fullWidth:!0},e.name)})}):(0,n.jsx)(S.A,{severity:"success",children:"No global variables referenced by this package."}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Declared secrets (entity keys)"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Secrets the package will declare from model API keys and MCP env/headers. Values are never included — whoever installs must supply them."}),eI&&0!==eI.secrets.length?(0,n.jsx)(y.A,{dense:!0,children:eI.secrets.map(e=>(0,n.jsxs)(v.Ay,{children:[(0,n.jsx)(b.A,{edge:"start",checked:!ez.has(e.name),onChange:t=>eR(a=>{let n=new Set(a);return t.target.checked?n.delete(e.name):n.add(e.name),n}),inputProps:{"aria-label":"Include ".concat(e.name," in package secrets")}}),(0,n.jsx)(A.A,{primary:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("code",{children:eC(e.name)})," ",e.required&&(0,n.jsx)(c.A,{label:"required",size:"small",color:"warning"})]}),secondary:ez.has(e.name)?"Excluded — the package will not request this value":e.description})]},e.name))}):(0,n.jsx)(S.A,{severity:"success",children:"No entity secrets to declare."}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Detected secrets in content"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Values that look secret or instance-specific (paths, repos, tokens, URLs, emails) found in flow prompts, node properties, model config and planned- execution prompts. Accepted rows are replaced with a"," ",(0,n.jsx)("code",{children:"{{secret.NAME}}"})," placeholder everywhere they occur."]}),eL&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,n.jsx)(k.default,{size:28})}),eJ&&(0,n.jsx)(S.A,{severity:"error",children:eJ}),!eL&&eM&&0===eO.length&&(0,n.jsx)(S.A,{severity:"success",children:"No likely secrets detected in the packaged content."}),eO.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.A,{direction:"row",spacing:.5,flexWrap:"wrap",useFlexGap:!0,children:tJ.map(e=>{let[t,a]=e;return(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"".concat(t,": ").concat(a)},t)})}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(d.A,{size:"small",onClick:()=>tR(!0),children:"Accept all"}),(0,n.jsx)(d.A,{size:"small",onClick:()=>tR(!1),children:"Reject all"}),(0,n.jsx)(g.A,{size:"small",placeholder:"Filter detected secrets…",value:eZ,onChange:e=>eK(e.target.value),sx:{minWidth:200,flex:1}}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",sx:{alignSelf:"center"},children:[tH.filter(e=>e.accepted).length," of ",tH.length," accepted"]})]}),(0,n.jsxs)(y.A,{dense:!0,sx:{border:1,borderColor:"divider",borderRadius:1,maxHeight:280,overflow:"auto"},children:[0===tM.length&&(0,n.jsx)(v.Ay,{children:(0,n.jsx)(A.A,{primary:(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No rows match “",eZ,"”."]})})}),tM.map(e=>(0,n.jsxs)(v.Ay,{alignItems:"flex-start",divider:!0,children:[(0,n.jsx)(j.A,{sx:{minWidth:36,mt:1},children:(0,n.jsx)(b.A,{edge:"start",checked:!!e.accepted,onChange:()=>{let t;return t=e.ids,eU(e=>{var a;let n=new Set(t),r=!(null==(a=e.find(e=>n.has(e.id)))?void 0:a.accepted);return e.map(e=>n.has(e.id)?{...e,accepted:r}:e)})},tabIndex:-1,disableRipple:!0})}),(0,n.jsx)(A.A,{primary:(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(c.A,{label:e.kind,size:"small"}),(0,n.jsx)(c.A,{label:e.source,size:"small",variant:"outlined",color:"model"===e.source?"secondary":"manual"===e.source?"primary":"default"}),e.confidence&&(0,n.jsx)(c.A,{label:e.confidence,size:"small",variant:"outlined",color:"high"===e.confidence?"success":"low"===e.confidence?"warning":"default"}),e.locations.length>1&&(0,n.jsx)(c.A,{label:"".concat(e.locations.length,"\xd7"),size:"small",variant:"outlined"}),(0,n.jsx)(s.default,{component:"code",sx:{wordBreak:"break-all"},children:e.excerpt.length>80?"".concat(e.excerpt.slice(0,80),"…"):e.excerpt})]}),secondary:(0,n.jsxs)(i.A,{spacing:.5,sx:{mt:.5},children:[(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[e.locations.length>1?"".concat(e.locations.length," locations: ").concat(e.locations.slice(0,3).join(", ")).concat(e.locations.length>3?", …":""):e.locations[0],e.rationale?" — ".concat(e.rationale):""]}),(0,n.jsx)(g.A,{size:"small",label:"Secret name",value:eC(e.suggestedSecretName),onChange:t=>{var a,n;let r,s;return r=e.ids,a=e.suggestedSecretName,n=t.target.value,s=a.startsWith("SECRET_")?"SECRET_".concat(n.replace(/^SECRET_/,"")):n,eU(e=>{let t=new Set(r);return e.map(e=>t.has(e.id)?{...e,suggestedSecretName:s}:e)})},disabled:!e.accepted,sx:{maxWidth:320}})]}),primaryTypographyProps:{component:"div"},secondaryTypographyProps:{component:"div"}})]},e.key))]})]}),tD.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Secrets from the imported manifest that need re-adding"}),"A manifest never carries secret values, so these declarations could not be matched to anything in the current content — re-add them below if they still apply: ",tD.map(eC).join(", "),"."]}),eG.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Notes"}),eG.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Add a secret manually"}),(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Enter any value that should be redacted from the package. It is treated purely as text to replace with a ",(0,n.jsx)("code",{children:"{{secret.NAME}}"})," placeholder — it is never executed."]}),e6&&(0,n.jsx)(S.A,{severity:"error",children:e6}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"flex-start",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(g.A,{size:"small",label:"Value to redact",value:e0,onChange:e=>e1(e.target.value),sx:{minWidth:240,flex:1}}),(0,n.jsx)(g.A,{size:"small",label:"Secret name",value:e2,onChange:e=>e5(e.target.value),sx:{minWidth:180}}),(0,n.jsx)(I.A,{size:"small",value:e4,onChange:e=>e3(e.target.value),sx:{minWidth:120},children:ed.map(e=>(0,n.jsx)(T.A,{value:e,children:e},e))}),(0,n.jsx)(d.A,{variant:"outlined",onClick:tO,disabled:!e0.trim(),children:"Add"}),(0,n.jsx)(d.A,{variant:"text",startIcon:(0,n.jsx)(H.A,{}),onClick:()=>void tU(),disabled:tT,children:"Pick from app"})]}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Advanced scan options"}),(0,n.jsxs)(i.A,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(F.A,{control:(0,n.jsx)(P.A,{checked:e$,onChange:e=>{eY(e.target.checked),eD(!1)}}),label:"Aggressive entropy scan"}),(0,n.jsx)(F.A,{control:(0,n.jsx)(P.A,{checked:eQ,onChange:e=>{eX(e.target.checked),eD(!1)}}),label:"Detect bare owner/repo slugs"}),(0,n.jsx)(d.A,{size:"small",variant:"text",onClick:()=>void tz(),disabled:eL,children:"Re-scan"})]}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Optional: model-driven scan"}),(0,n.jsx)(S.A,{severity:"info",children:"Running the model-driven pass sends the packaged content above to the selected model provider. The offline heuristic scan never leaves your machine."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsxs)(I.A,{size:"small",displayEmpty:!0,value:eB,onChange:e=>eV(e.target.value),sx:{minWidth:220},children:[(0,n.jsx)(T.A,{value:"",children:(0,n.jsx)("em",{children:"Select a model…"})}),D.models.map(e=>(0,n.jsx)(T.A,{value:e.id,children:e.label},e.id))]}),(0,n.jsx)(d.A,{variant:"outlined",disabled:!eB||eL,onClick:()=>void tz(eB),children:"Scan with model"})]})]});case 3:return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsx)(g.A,{label:"Package name",value:td,onChange:e=>tu(e.target.value),required:!0,fullWidth:!0,error:td.length>0&&0===td.trim().length}),(0,n.jsx)(g.A,{label:"Version",value:th,onChange:e=>tp(e.target.value),required:!0,fullWidth:!0,error:th.length>0&&!tV,helperText:th.length>0&&!tV?"Must be a semantic version (e.g. 1.0.0)":" "}),(0,n.jsx)(g.A,{label:"Description",value:tm,onChange:e=>tx(e.target.value),fullWidth:!0,multiline:!0,minRows:2}),(0,n.jsx)(g.A,{label:"Tags (comma-separated)",value:tg,onChange:e=>tf(e.target.value),fullWidth:!0})]});case 4:if(ty)return(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})});if(tb)return(0,n.jsx)(S.A,{severity:"error",children:tb});if(null==tw?void 0:tw.ok)return(0,n.jsxs)(i.A,{spacing:2,children:[(0,n.jsxs)(S.A,{severity:"success",children:[(0,n.jsx)(C.A,{children:"Package built"}),(0,n.jsx)("code",{children:td.trim()})," v",th.trim()," is ready to export."]}),tw.warnings.length>0&&(0,n.jsxs)(S.A,{severity:"warning",children:[(0,n.jsx)(C.A,{children:"Warnings"}),tw.warnings.map((e,t)=>(0,n.jsx)("div",{children:e},t))]}),(0,n.jsx)(d.A,{variant:"contained",onClick:t_,children:"Download package manifest (.json)"}),(0,n.jsx)(E.A,{}),(0,n.jsx)(o.default,{variant:"subtitle2",children:"Publish to the FLUJO package registry"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Publishing requires a confirmed registry account (set one up on the Packages page). Only the secret-safe manifest above is uploaded — no secret values ever leave your machine."}),(null==tC?void 0:tC.ok)?(0,n.jsxs)(S.A,{severity:"success",children:[(0,n.jsx)(C.A,{children:"Published"}),tC.name||td.trim()," v",tC.version||th.trim()," is live.",tC.url&&(0,n.jsx)("div",{children:(0,n.jsx)("a",{href:tC.url,target:"_blank",rel:"noreferrer",children:tC.url})})]}):(0,n.jsxs)(n.Fragment,{children:[tC&&!tC.ok&&(0,n.jsx)(S.A,{severity:"unconfirmed"===tC.code||"not_authenticated"===tC.code?"warning":"error",children:tC.error||"Failed to publish package."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:[(0,n.jsx)(d.A,{variant:"outlined",onClick:()=>void tG(),disabled:tk,children:tk?"Publishing…":"Publish to registry"}),tC&&!tC.ok&&("not_authenticated"===tC.code||"unconfirmed"===tC.code)&&(0,n.jsx)(d.A,{variant:"contained",onClick:()=>tc(!0),disabled:tk,children:"Log in to registry"})]})]})]});return null;default:return null}})()]}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:a,children:(null==tw?void 0:tw.ok)?"Close":"Cancel"}),(0,n.jsx)(s.default,{sx:{flex:1}}),(0,n.jsx)(d.A,{onClick:()=>p(e=>Math.max(e-1,0)),disabled:0===h||ty||ej,children:"Back"}),h<4&&(0,n.jsx)(d.A,{variant:"contained",onClick:tB,disabled:t$,children:3===h?"Build":"Next"})]})]}),(0,n.jsxs)(N.A,{open:to,onClose:()=>tc(!1),maxWidth:"sm",fullWidth:!0,children:[(0,n.jsx)(W.A,{children:"Log in to the package registry"}),(0,n.jsx)(z.A,{dividers:!0,children:(0,n.jsx)(Y,{})}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>tc(!1),children:"Done"}),(0,n.jsx)(d.A,{variant:"contained",onClick:()=>{tc(!1),tG()},disabled:tk,children:"Retry publish"})]})]}),(0,n.jsxs)(N.A,{open:e8,onClose:()=>e9(!1),maxWidth:"md",fullWidth:!0,children:[(0,n.jsx)(W.A,{children:"Pick a value to redact"}),(0,n.jsxs)(z.A,{dividers:!0,children:[(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"These are plaintext values found in the packaged flows, models and planned executions. Pick one to pre-fill the value to redact. API keys and MCP env/header values are never listed — they are already declared as secrets."}),(0,n.jsx)(g.A,{size:"small",fullWidth:!0,placeholder:"Search values…",value:tl,onChange:e=>ti(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})})},sx:{mb:2}}),te?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,n.jsx)(k.default,{})}):ta?(0,n.jsx)(S.A,{severity:"error",children:ta}):0===tr.length?(0,n.jsx)(S.A,{severity:"info",children:"No pickable plaintext values found in the packaged content."}):0===tL.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No values match “",tl,"”."]}):(0,n.jsx)(y.A,{dense:!0,sx:{border:1,borderColor:"divider",borderRadius:1,maxHeight:"50vh",overflow:"auto"},children:tL.map((e,t)=>(0,n.jsx)(v.Ay,{disablePadding:!0,divider:!0,children:(0,n.jsx)(w.A,{onClick:()=>{e1(e.text),e7(null),e9(!1)},alignItems:"flex-start",children:(0,n.jsx)(A.A,{primary:(0,n.jsx)(s.default,{component:"code",sx:{wordBreak:"break-all"},children:e.text.length>120?"".concat(e.text.slice(0,120),"…"):e.text}),secondary:(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,sx:{mt:.5},children:[(0,n.jsx)(c.A,{label:e.source,size:"small",variant:"outlined"}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:e.location})]}),primaryTypographyProps:{component:"div"},secondaryTypographyProps:{component:"div"}})})},"".concat(e.location,"-").concat(t)))})]}),(0,n.jsx)(L.A,{children:(0,n.jsx)(d.A,{onClick:()=>e9(!1),children:"Close"})})]})]})}var eI=a(50001),eT=a(51314),eF=a(76530);let eP=(0,q.h)("frontend/components/Packages/InstalledPackagesList");function eN(){let[e,t]=(0,r.useState)([]),[a,l]=(0,r.useState)(!0),[h,p]=(0,r.useState)(null),[m,x]=(0,r.useState)(null),[y,v]=(0,r.useState)(!1),[w,j]=(0,r.useState)(null),[b,A]=(0,r.useState)(""),C=(0,r.useCallback)(async()=>{l(!0),p(null);try{var e;let a=await fetch("/api/packages/installed");if(!a.ok)throw Error("Failed to load installed packages (".concat(a.status,")"));let n=await a.json();t(null!=(e=n.packages)?e:[])}catch(e){eP.warn("Failed to load installed packages",e),p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);let E=(0,r.useCallback)(async e=>{v(!0),j(null);try{let a=await fetch("/api/packages/uninstall",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({packageName:e.packageName})}),n=await a.json();if(!a.ok){var t;throw Error(null!=(t=n.error)?t:"Uninstall failed (".concat(a.status,")"))}j(n),await C()}catch(e){eP.warn("Uninstall failed",e),p(e instanceof Error?e.message:String(e))}finally{v(!1),x(null)}},[C]),I=(0,r.useMemo)(()=>{let t=b.trim().toLowerCase();return t?e.filter(e=>"".concat(e.packageName," ").concat(e.version).toLowerCase().includes(t)):e},[e,b]);return(0,n.jsxs)(s.default,{sx:{maxWidth:{xs:"100%",md:1100},mx:"auto",mt:3},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,n.jsx)(o.default,{variant:"h6",children:"Installed packages"}),(0,n.jsx)(d.A,{size:"small",startIcon:(0,n.jsx)(eF.A,{}),onClick:()=>void C(),disabled:a,children:"Refresh"})]}),e.length>0&&(0,n.jsx)(g.A,{size:"small",fullWidth:!0,placeholder:"Search installed packages…",value:b,onChange:e=>A(e.target.value),InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})})},sx:{mb:2}}),h&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>p(null),children:h}),w&&(0,n.jsxs)(S.A,{severity:w.hasErrors?"warning":"success",sx:{mb:2},onClose:()=>j(null),children:['Uninstalled "',w.packageName,'": ',w.removed.length," removed,"," ",w.skipped.length," preserved/skipped",w.hasErrors?", ".concat(w.errors.length," error(s)"):"","."]}),a?(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,n.jsx)(k.default,{size:24})}):0===e.length?(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No packages installed yet."}):0===I.length?(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No packages match “",b,"”."]}):(0,n.jsx)(i.A,{spacing:1,children:I.map(e=>(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(o.default,{variant:"subtitle1",children:e.packageName}),(0,n.jsx)(c.A,{label:"v".concat(e.version),size:"small",variant:"outlined"})]}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[e.entityCounts.flows," flows \xb7 ",e.entityCounts.models," models \xb7"," ",e.entityCounts.servers," servers \xb7 ",e.entityCounts.plannedExecutions," planned \xb7 installed ",new Date(e.installedAt).toLocaleString()]})]}),(0,n.jsx)(d.A,{color:"error",size:"small",startIcon:(0,n.jsx)(eT.A,{}),onClick:()=>x(e),disabled:y,children:"Uninstall"})]},e.packageName))}),(0,n.jsxs)(N.A,{open:null!==m,onClose:()=>y?void 0:x(null),children:[(0,n.jsxs)(W.A,{children:['Uninstall "',null==m?void 0:m.packageName,'"?']}),(0,n.jsx)(z.A,{children:(0,n.jsxs)(eI.A,{children:["This removes the flows, models, MCP servers and planned executions this package",(0,n.jsx)("strong",{children:" created"}),". Pre-existing entities the package merely updated in place are preserved. This cannot be undone."]})}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>x(null),disabled:y,children:"Cancel"}),(0,n.jsx)(d.A,{color:"error",variant:"contained",onClick:()=>m&&void E(m),disabled:y,startIcon:y?(0,n.jsx)(k.default,{size:16}):(0,n.jsx)(eT.A,{}),children:"Uninstall"})]})]})]})}var eW=a(33077),ez=a(29767),eR=a(53062),eO=a(84578),eU=a(1702),eL=a(41983),eH=a(23789),eM=a(17438),eD=a(14418),eJ=a(52550),eq=a(12402),eG=a(61563),e_=a(42063),eB=a(68212);let eV=(0,q.h)("frontend/components/Packages/InstallPackageCard");function eZ(e){var t,a,l,u,h;let{onInstalled:p}=e,[m,x]=(0,r.useState)(""),[y,v]=(0,r.useState)([]),[w,j]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,I]=(0,r.useState)(!1),[T,F]=(0,r.useState)(null),[P,M]=(0,r.useState)(null),[D,J]=(0,r.useState)(!1),[q,G]=(0,r.useState)(null),[_,B]=(0,r.useState)(null),[V,Z]=(0,r.useState)(!1),[$,Y]=(0,r.useState)(null),[Q,X]=(0,r.useState)(null),[ee,et]=(0,r.useState)({}),[ea,en]=(0,r.useState)({}),[er,es]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(!1),[ec,ed]=(0,r.useState)(0),[eu,eh]=(0,r.useState)(null),[ep,em]=(0,r.useState)({}),ex=(0,r.useCallback)(async e=>{j(!0),A(null);try{var t;let a=await el.searchRegistry({q:e.trim()||void 0,pageSize:24});v(null!=(t=a.items)?t:[]),I(!0)}catch(e){eV.warn("Failed to search package registry",e),A(e instanceof Error?e.message:String(e)),v([])}finally{j(!1)}},[]);(0,r.useEffect)(()=>{ex(""),K.getStatus().then(e=>F(e.signedIn?e.publisherHandle:null)).catch(e=>eV.debug("Registry account status unavailable",e))},[ex]);let eg=(0,r.useCallback)(async()=>{if(P){J(!0),G(null);try{let e=await K.deletePackage(P.id);if(!e.ok)return void G(e.error||"Failed to delete package.");v(e=>e.filter(e=>e.id!==P.id)),M(null),await ex(m)}catch(e){eV.warn("Package deletion failed",e),G(e instanceof Error?e.message:String(e))}finally{J(!1)}}},[P,m,ex]),ef=(0,r.useCallback)(async e=>{B(e),X(null),eh(null),et({}),en({}),es(null),eo(!1),ed(0),em({}),Y(null),Z(!0);try{var t,a,n;let r=await el.installFromRegistry({packageId:e.id,version:e.latestVersion,consentGranted:!1});if(!r.ok)return void Y((null==(a=r.errors)?void 0:a[0])||"Failed to fetch package preview.");X(r);let s=null==(t=r.preview)?void 0:t.models[0];es(null!=(n=null==s?void 0:s.id)?n:null),ed(+!s)}catch(e){eV.warn("Failed to fetch package preview",e),Y(e instanceof Error?e.message:String(e))}finally{Z(!1)}},[]),ey=(0,r.useCallback)(async()=>{if(_&&Q){Z(!0),Y(null);try{let e=await el.installFromRegistry({packageId:_.id,version:_.latestVersion,secrets:ee,modelMappings:Object.fromEntries(Object.entries(ea).filter(e=>{let[,t]=e;return""!==t})),consentGranted:!0});eh(e),X(null),e.ok&&(null==p||p())}catch(e){eV.warn("Install failed",e),Y(e instanceof Error?e.message:String(e))}finally{Z(!1)}}},[_,Q,ee,ea,p]),ev=(0,r.useCallback)(()=>{B(null),X(null),eh(null),et({}),en({}),es(null),eo(!1),ed(0),em({}),Y(null)},[]),ew=null==Q?void 0:Q.preview,ej=null!=(a=null==ew?void 0:ew.models.find(e=>e.id===er))?a:null==ew?void 0:ew.models[0],eb=null!=(l=null==ew?void 0:ew.models.filter(e=>Object.prototype.hasOwnProperty.call(ea,e.id)).length)?l:0,eA=null==(u=null==ew?void 0:ew.models.every(e=>Object.prototype.hasOwnProperty.call(ea,e.id)))||u,ek=(0,r.useCallback)(e=>{es(e),eo(!!ea[e])},[ea]),eS=(0,r.useCallback)(e=>{en(t=>({...t,[e]:""})),eo(!1)},[]),eC=(0,r.useCallback)((e,t)=>{en(a=>({...a,[e]:t}))},[]);return(0,n.jsxs)(s.default,{sx:{maxWidth:{xs:"100%",md:1100},mx:"auto",mt:3},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,n.jsx)(eq.A,{color:"action"}),(0,n.jsx)(o.default,{variant:"h6",children:"Browse registry"})]}),(0,n.jsx)(g.A,{size:"small",fullWidth:!0,placeholder:"Search published packages…",value:m,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ex(m)},InputProps:{startAdornment:(0,n.jsx)(f.A,{position:"start",children:(0,n.jsx)(H.A,{fontSize:"small"})}),endAdornment:w?(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(k.default,{size:16})}):void 0},sx:{mb:2}}),b&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>A(null),children:b}),C&&!w&&0===y.length&&!b&&(0,n.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["No packages match “",m,"”."]}),(0,n.jsx)(eW.Ay,{container:!0,spacing:2,children:y.map(e=>(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,n.jsxs)(ez.A,{variant:"outlined",sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsx)(eR.A,{onClick:()=>void ef(e),sx:{flex:1},children:(0,n.jsxs)(eO.A,{children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"baseline",justifyContent:"space-between",children:[(0,n.jsx)(o.default,{variant:"subtitle1",noWrap:!0,children:e.name}),(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"v".concat(e.latestVersion)})]}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",display:"block",children:e.handle}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,minHeight:"2.5em"},children:e.description||"No description provided."}),(0,n.jsx)(i.A,{direction:"row",spacing:.5,sx:{mt:1,flexWrap:"wrap",gap:.5},children:e.tags.map(e=>(0,n.jsx)(c.A,{size:"small",label:e},e))}),(0,n.jsxs)(i.A,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:1},children:[(0,n.jsx)(eG.A,{fontSize:"inherit",color:"disabled"}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:e.downloads})]})]})}),function(e,t){var a;let n=null==t?void 0:t.trim().replace(/^@/,"").toLocaleLowerCase();if(!n)return!1;let r=null==(a=e.handle)?void 0:a.trim().replace(/^@/,"");if(r)return r.split("/")[0].toLocaleLowerCase()===n;let s=e.id.trim().replace(/^@/,"");return s.includes("/")&&s.split("/")[0].toLocaleLowerCase()===n}(e,T)&&(0,n.jsx)(eU.A,{sx:{justifyContent:"flex-end",pt:0},children:(0,n.jsx)(eL.A,{size:"small",color:"error","aria-label":"Delete ".concat(e.name),onClick:()=>{G(null),M(e)},children:(0,n.jsx)(eT.A,{fontSize:"small"})})})]})},e.id))}),(0,n.jsxs)(N.A,{open:null!==P,onClose:D?void 0:()=>M(null),maxWidth:"xs",fullWidth:!0,children:[(0,n.jsx)(W.A,{children:"Delete package?"}),(0,n.jsxs)(z.A,{children:[q&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},children:q}),(0,n.jsxs)(o.default,{variant:"body2",children:["This permanently deletes ",(0,n.jsx)("strong",{children:null==P?void 0:P.name})," and all of its published versions from the registry. This action cannot be undone."]})]}),(0,n.jsxs)(L.A,{children:[(0,n.jsx)(d.A,{onClick:()=>M(null),disabled:D,children:"Cancel"}),(0,n.jsx)(d.A,{color:"error",variant:"contained",onClick:()=>void eg(),disabled:D,startIcon:D?(0,n.jsx)(k.default,{size:16,color:"inherit"}):(0,n.jsx)(eT.A,{}),children:"Delete package"})]})]}),(0,n.jsxs)(N.A,{open:null!==_,onClose:V?void 0:ev,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"min(1400px, calc(100vw - 32px))",maxWidth:"none",minHeight:{xs:"calc(100vh - 32px)",md:760},maxHeight:"calc(100vh - 32px)",borderRadius:{xs:2,md:3}}},children:[(0,n.jsxs)(W.A,{sx:{px:{xs:2,md:4},pt:{xs:2,md:3},pb:1},children:[(0,n.jsxs)(o.default,{component:"span",variant:"h5",fontWeight:700,children:["Install ",null==_?void 0:_.name]}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"Match the package to your FLUJO, then review and install it."})]}),(0,n.jsxs)(z.A,{sx:{px:{xs:2,md:4},pb:3},children:[$&&(0,n.jsx)(S.A,{severity:"error",sx:{mb:2},onClose:()=>Y(null),children:$}),V&&!Q&&!eu&&(0,n.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:420},children:(0,n.jsx)(k.default,{size:24})}),ew&&(null==Q?void 0:Q.package)&&(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},justifyContent:"space-between",sx:{mb:2.5},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:"v".concat(Q.package.version)}),Q.package.publisher&&(0,n.jsx)(c.A,{size:"small",variant:"outlined",label:Q.package.publisher}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:[ew.servers.length," server(s) \xb7 ",ew.models.length," model(s) \xb7"," ",ew.flows.length," flow(s) \xb7 ",ew.plannedExecutions.length," planned execution(s)"]})]}),(0,n.jsxs)(o.default,{variant:"caption",color:"text.secondary",children:["Step ",ec+1," of 2"]})]}),(0,n.jsxs)(R.A,{activeStep:ec,sx:{maxWidth:720,mx:"auto",mb:3},children:[(0,n.jsx)(O.A,{children:(0,n.jsx)(U.A,{children:"Match models"})}),(0,n.jsx)(O.A,{children:(0,n.jsx)(U.A,{children:"Review & install"})})]}),0===ec&&ew.models.length>0&&ej&&(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(s.default,{sx:{textAlign:"center",maxWidth:820,mx:"auto",mb:3},children:[(0,n.jsx)(o.default,{variant:"h4",fontWeight:750,sx:{mb:1},children:"The package was created with models that are not installed in your FLUJO."}),(0,n.jsx)(o.default,{variant:"h6",color:"text.secondary",fontWeight:400,children:"Let's replace or recreate them!"})]}),(0,n.jsxs)(s.default,{sx:{display:"grid",gridTemplateColumns:{xs:"minmax(0, 1fr)",md:"minmax(260px, 0.85fr) 88px minmax(420px, 1.35fr)"},gap:{xs:2,md:2.5},alignItems:"stretch"},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsxs)(i.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1.25},children:[(0,n.jsx)(o.default,{variant:"overline",color:"text.secondary",fontWeight:700,children:"Models in this package"}),(0,n.jsx)(c.A,{size:"small",color:eA?"success":"default",label:"".concat(eb,"/").concat(ew.models.length," ready")})]}),(0,n.jsx)(i.A,{spacing:1.25,children:ew.models.map(e=>{let t=e.id===ej.id,a=Object.prototype.hasOwnProperty.call(ea,e.id),r=ew.installedModels.find(t=>t.id===ea[e.id]);return(0,n.jsx)(ez.A,{variant:"outlined",sx:{borderWidth:t?2:1,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",transition:"border-color 120ms ease, background-color 120ms ease"},children:(0,n.jsx)(eR.A,{onClick:()=>ek(e.id),"aria-label":"Configure ".concat(e.displayName),sx:{minHeight:104,p:2},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,alignItems:"center",children:[(0,n.jsx)(s.default,{sx:{width:44,height:44,borderRadius:2,display:"grid",placeItems:"center",bgcolor:t?"primary.main":"action.hover",color:t?"primary.contrastText":"text.secondary",flex:"0 0 auto"},children:(0,n.jsx)(eJ.A,{})}),(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"subtitle1",fontWeight:700,noWrap:!0,children:e.displayName}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",display:"block",children:"Package model"}),a&&(0,n.jsxs)(i.A,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:.5},children:[(0,n.jsx)(eD.A,{color:"success",sx:{fontSize:16}}),(0,n.jsx)(o.default,{variant:"caption",color:"success.main",noWrap:!0,children:r?"Using ".concat(r.displayName):"Will be created"})]})]})]})})},e.id)})})]}),(0,n.jsx)(s.default,{"aria-hidden":!0,sx:{display:"grid",placeItems:"center",minHeight:{xs:64,md:360}},children:(0,n.jsx)(s.default,{sx:{width:64,height:64,borderRadius:"50%",display:"grid",placeItems:"center",bgcolor:"primary.main",color:"primary.contrastText",boxShadow:3,transform:{xs:"rotate(90deg)",md:"none"}},children:(0,n.jsx)(eM.A,{sx:{fontSize:38}})})}),(0,n.jsxs)(ez.A,{variant:"outlined",sx:{p:{xs:2,md:3},minHeight:{md:420},bgcolor:"background.default"},children:[(0,n.jsxs)(o.default,{variant:"overline",color:"text.secondary",fontWeight:700,children:["Replace ",ej.displayName]}),(0,n.jsx)(o.default,{variant:"h5",fontWeight:700,sx:{mt:.25,mb:2.5},children:"What would you like to do?"}),(0,n.jsxs)(eW.Ay,{container:!0,spacing:2,children:[(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(d.A,{fullWidth:!0,"aria-label":"Create new one",variant:Object.prototype.hasOwnProperty.call(ea,ej.id)&&""===ea[ej.id]?"contained":"outlined",onClick:()=>eS(ej.id),sx:{minHeight:154,p:2.5,textTransform:"none",alignItems:"stretch",justifyContent:"flex-start",textAlign:"left"},children:(0,n.jsxs)(i.A,{spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(eH.A,{sx:{fontSize:36}}),(0,n.jsx)(o.default,{variant:"h6",fontWeight:700,children:"Create new one"}),(0,n.jsx)(o.default,{variant:"body2",color:Object.prototype.hasOwnProperty.call(ea,ej.id)&&""===ea[ej.id]?"inherit":"text.secondary",children:"Recreate this model in your FLUJO with the package's configuration."})]})})}),(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(d.A,{fullWidth:!0,"aria-label":"Use one of yours",variant:ea[ej.id]?"contained":"outlined",onClick:()=>eo(!0),sx:{minHeight:154,p:2.5,textTransform:"none",alignItems:"stretch",justifyContent:"flex-start",textAlign:"left"},children:(0,n.jsxs)(i.A,{spacing:1,alignItems:"flex-start",children:[(0,n.jsx)(eJ.A,{sx:{fontSize:36}}),(0,n.jsx)(o.default,{variant:"h6",fontWeight:700,children:"Use one of yours"}),(0,n.jsx)(o.default,{variant:"body2",color:ea[ej.id]?"inherit":"text.secondary",children:"Connect the package to a model you already have installed."})]})})})]}),ei&&(0,n.jsxs)(s.default,{sx:{mt:2.5},children:[(0,n.jsx)(E.A,{sx:{mb:2}}),(0,n.jsx)(o.default,{variant:"subtitle1",fontWeight:700,sx:{mb:1},children:"Choose one of your installed models"}),ew.installedModels.length>0?(0,n.jsx)(eW.Ay,{container:!0,spacing:1.25,children:ew.installedModels.map(e=>{let t=ea[ej.id]===e.id;return(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(ez.A,{variant:"outlined",sx:{height:"100%",borderWidth:t?2:1,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper"},children:(0,n.jsx)(eR.A,{onClick:()=>eC(ej.id,e.id),"aria-label":"Use ".concat(e.displayName),sx:{minHeight:76,p:1.5},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,n.jsx)(eJ.A,{color:t?"primary":"action"}),(0,n.jsxs)(s.default,{sx:{minWidth:0},children:[(0,n.jsx)(o.default,{variant:"subtitle2",fontWeight:700,noWrap:!0,children:e.displayName}),(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",noWrap:!0,display:"block",children:e.name})]}),t&&(0,n.jsx)(eD.A,{color:"primary",sx:{ml:"auto !important",flex:"0 0 auto"}})]})})})},e.id)})}):(0,n.jsx)(S.A,{severity:"info",children:"You do not have any installed models yet. Create this package model as new instead."})]})]})]}),(0,n.jsx)(E.A,{sx:{my:3}}),(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(d.A,{onClick:ev,children:"Cancel"}),(0,n.jsxs)(i.A,{direction:"row",spacing:1.5,alignItems:"center",children:[!eA&&(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Choose an option for every model to continue."}),(0,n.jsx)(d.A,{variant:"contained",size:"large",disabled:!eA,endIcon:(0,n.jsx)(eM.A,{}),onClick:()=>ed(1),children:"Continue to review"})]})]})]}),1===ec&&(0,n.jsxs)(s.default,{sx:{maxWidth:980,mx:"auto"},children:[(0,n.jsxs)(i.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},justifyContent:"space-between",sx:{mb:2},children:[(0,n.jsxs)(s.default,{children:[(0,n.jsx)(o.default,{variant:"h4",fontWeight:750,children:"Review and install"}),(0,n.jsx)(o.default,{variant:"body1",color:"text.secondary",children:"Check your model choices and add any package secrets."})]}),ew.models.length>0&&(0,n.jsx)(d.A,{onClick:()=>{var e,t;ed(0),es(null!=(t=null==(e=ew.models.find(e=>!Object.prototype.hasOwnProperty.call(ea,e.id)))?void 0:e.id)?t:ew.models[0].id),eo(!1)},children:"Change model choices"})]}),ew.models.length>0&&(0,n.jsxs)(s.default,{sx:{mb:2.5},children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Model plan"}),(0,n.jsx)(eW.Ay,{container:!0,spacing:1.5,children:ew.models.map(e=>{var t;let a=ew.installedModels.find(t=>t.id===ea[e.id]);return(0,n.jsx)(eW.Ay,{item:!0,xs:12,sm:6,children:(0,n.jsx)(ez.A,{variant:"outlined",sx:{p:1.75,height:"100%"},children:(0,n.jsxs)(i.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"Package model"}),(0,n.jsx)(o.default,{variant:"subtitle2",noWrap:!0,children:e.displayName})]}),(0,n.jsx)(eM.A,{color:"action"}),(0,n.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,n.jsx)(o.default,{variant:"caption",color:"text.secondary",children:a?"Your model":"New model"}),(0,n.jsx)(o.default,{variant:"subtitle2",noWrap:!0,children:null!=(t=null==a?void 0:a.displayName)?t:e.displayName})]})]})})},e.id)})})]}),ew.servers.some(e=>e.requiredEnvMissing.length>0)&&(0,n.jsx)(S.A,{severity:"warning",sx:{mb:1.5},children:"Some MCP servers require environment values that aren't covered by a secret below — those servers will install disabled."}),ew.missingGlobals.length>0&&(0,n.jsxs)(S.A,{severity:"warning",sx:{mb:1.5},children:["This package expects host global variable(s) that aren't set yet:"," ",ew.missingGlobals.join(", "),". Set them in Settings after install, or the bound model(s)/server(s) won't have a working API key."]}),(0,n.jsx)(E.A,{sx:{my:2.5}}),ew.secrets.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.default,{variant:"subtitle2",sx:{mb:1},children:"Secrets requested by this package"}),(0,n.jsx)(i.A,{spacing:1.5,sx:{mb:2.5},children:ew.secrets.map(e=>{var t;return(0,n.jsx)(g.A,{size:"small",type:ep[e.key]?"text":"password",label:e.label||e.key,helperText:e.required?"Required — leave blank to install the dependent entity disabled":"Optional",value:null!=(t=ee[e.key])?t:"",onChange:t=>et(a=>({...a,[e.key]:t.target.value})),fullWidth:!0,InputProps:{endAdornment:(0,n.jsx)(f.A,{position:"end",children:(0,n.jsx)(eL.A,{size:"small",tabIndex:-1,"aria-label":ep[e.key]?"Hide secret":"Show secret",onClick:()=>em(t=>({...t,[e.key]:!t[e.key]})),children:ep[e.key]?(0,n.jsx)(eB.A,{fontSize:"small"}):(0,n.jsx)(e_.A,{fontSize:"small"})})})}},e.key)})})]}):(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2.5},children:"This package doesn't request any secrets."}),(0,n.jsxs)(i.A,{direction:"row",spacing:1,justifyContent:"space-between",children:[(0,n.jsx)(d.A,{onClick:ew.models.length>0?()=>ed(0):ev,disabled:V,children:ew.models.length>0?"Back":"Cancel"}),(0,n.jsx)(d.A,{variant:"contained",color:"primary",size:"large",onClick:()=>void ey(),disabled:V,startIcon:V?(0,n.jsx)(k.default,{size:16}):(0,n.jsx)(eq.A,{}),children:"Install package"})]})]})]}),eu&&(0,n.jsxs)(s.default,{children:[(0,n.jsx)(S.A,{severity:eu.ok?"success":"error",sx:{mb:1},children:eu.ok?'Installed "'.concat(null==(t=eu.package)?void 0:t.name,'": ').concat(eu.created.length," created, ").concat(eu.updated.length," updated, ").concat(eu.disabled.length," disabled."):"Install failed: ".concat(null!=(h=eu.errors[0])?h:"unknown error")}),eu.missingGlobals.length>0&&(0,n.jsxs)(S.A,{severity:"warning",sx:{mb:1},children:["Set these global variable(s) in Settings for the installed entities to work:"," ",eu.missingGlobals.join(", "),"."]}),(0,n.jsx)(d.A,{size:"small",onClick:ev,children:"Close"})]})]})]})]})}let eK=(0,q.h)("frontend/components/Packages");function e$(){let[e,t]=(0,r.useState)(!1),[a,l]=(0,r.useState)(0);return eK.debug("Rendering PackagesManager",{wizardOpen:e}),(0,n.jsxs)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)(s.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:1,borderColor:"divider"},children:[(0,n.jsxs)(i.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsx)(o.default,{variant:"h5",children:"Packages"}),(0,n.jsx)(c.A,{label:"experimental",size:"small",color:"warning",variant:"outlined"})]}),(0,n.jsx)(d.A,{variant:"contained",startIcon:(0,n.jsx)(h.A,{}),onClick:()=>t(!0),"data-tour":"packages-create",children:"Create package"})]}),(0,n.jsxs)(s.default,{sx:{flex:1,overflow:"auto",p:3},children:[(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:4,display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",gap:2,maxWidth:{xs:"100%",md:1100},mx:"auto"},children:[(0,n.jsx)(p.A,{sx:{fontSize:48,color:"text.secondary"}}),(0,n.jsx)(o.default,{variant:"h6",children:"Bundle your FLUJO setup into a shareable package"}),(0,n.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"A package bundles flows, models, MCP servers (by reference) and planned executions into a single manifest you can export and share. Secret values (API keys, tokens) are never included — only declarations of the secrets a recipient must supply at install time."}),(0,n.jsx)(d.A,{variant:"contained",startIcon:(0,n.jsx)(h.A,{}),onClick:()=>t(!0),children:"Create package"})]}),(0,n.jsxs)(u.A,{variant:"outlined",sx:{p:3,mt:3,maxWidth:{xs:"100%",md:1100},mx:"auto"},children:[(0,n.jsx)(o.default,{variant:"h6",gutterBottom:!0,children:"Package registry account"}),(0,n.jsx)(Y,{})]}),(0,n.jsx)(eZ,{onInstalled:()=>l(e=>e+1)}),(0,n.jsx)(eN,{},a)]}),e&&(0,n.jsx)(eE,{open:e,onClose:()=>t(!1)})]})}var eY=a(9164),eQ=a(94929);let eX=(0,q.h)("app/packages/page");function e0(){var e,t;let a=(0,l.useRouter)(),{settings:i,settingsHydrated:o}=(0,eY.useStorage)(),c=o&&null!=(t=null==i||null==(e=i.experimental)?void 0:e.enabled)&&t;return((0,r.useEffect)(()=>{o&&!c&&(eX.debug("Experimental features disabled — redirecting away from /packages"),a.replace("/settings"))},[o,c,a]),o&&c)?(0,n.jsx)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,n.jsx)(e$,{})}):(0,n.jsx)(eQ.default,{})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>l});var n=a(74879);let r=(0,a(87021).h)("frontend/services/flow/index");class s{async loadFlows(){r.debug("loadFlows: Entering method");try{if(this.flowsCache)return r.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return r.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return r.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){r.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return r.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return r.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return r.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return r.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){r.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),r.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return r.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async generateFlow(e,t,a){r.debug("generateFlow: Entering method",{modelId:t,allowInstall:null==a?void 0:a.allowInstall,allowSubflows:null==a?void 0:a.allowSubflows,maxDepth:null==a?void 0:a.maxDepth});try{var n,s,l,i,o,c,d;let u=await fetch("/api/flow/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:e,modelId:t,allowInstall:(null==a?void 0:a.allowInstall)===!0,allowSubflows:(null==a?void 0:a.allowSubflows)!==!1,..."number"==typeof(null==a?void 0:a.maxDepth)?{maxDepth:a.maxDepth}:{}})}),h=await u.json().catch(()=>null);if(!u.ok)return{success:!1,error:(null==h?void 0:h.error)||"Failed to generate flow"};let p=Array.isArray(h.flows)&&h.flows.length>0?h.flows:[{flow:h.flow,validation:h.validation}];return r.debug("generateFlow: Draft generated",{flowId:null==(n=h.flow)?void 0:n.id,flowCount:p.length,attempts:h.attempts,errorCount:null==(s=h.validation)?void 0:s.errorCount,installedServers:null!=(o=null==(l=h.installedServers)?void 0:l.length)?o:0}),{success:!0,flow:h.flow,validation:h.validation,flows:p,rootFlowId:null!=(c=h.rootFlowId)?c:null==(i=h.flow)?void 0:i.id,attempts:h.attempts,installedServers:null!=(d=h.installedServers)?d:[]}}catch(e){return r.warn("generateFlow: Failed to generate flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to generate flow"}}}async improveFlow(e,t,a,n){r.debug("improveFlow: Entering method",{flowId:null==e?void 0:e.id,modelId:a,allowInstall:null==n?void 0:n.allowInstall});try{var s,l,i,o,c,d,u;let h=await fetch("/api/flow/improve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flow:e,relatedFlows:null==n?void 0:n.relatedFlows,description:t,modelId:a,allowInstall:(null==n?void 0:n.allowInstall)===!0})}),p=await h.json().catch(()=>null);if(!h.ok)return{success:!1,error:(null==p?void 0:p.error)||"Failed to improve flow"};return r.debug("improveFlow: Draft revised",{flowId:null==(s=p.flow)?void 0:s.id,attempts:p.attempts,errorCount:null==(l=p.validation)?void 0:l.errorCount,installedServers:null!=(c=null==(i=p.installedServers)?void 0:i.length)?c:0}),{success:!0,flow:p.flow,validation:p.validation,flows:Array.isArray(p.flows)&&p.flows.length>0?p.flows:[{flow:p.flow,validation:p.validation}],rootFlowId:null!=(d=p.rootFlowId)?d:null==(o=p.flow)?void 0:o.id,attempts:p.attempts,installedServers:null!=(u=p.installedServers)?u:[]}}catch(e){return r.warn("improveFlow: Failed to improve flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to improve flow"}}}async updateFlow(e){r.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return r.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return r.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){r.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),r.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return r.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}async listFlowVersions(e){r.debug("listFlowVersions: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e),"/versions"));if(!t.ok){let e=await t.json().catch(()=>null);throw Error((null==e?void 0:e.error)||"Failed to list flow versions")}let a=await t.json();return Array.isArray(a.versions)?a.versions:[]}catch(t){return r.warn("listFlowVersions: Failed for flow ".concat(e,":"),t),[]}}async getFlowVersion(e,t){r.debug("getFlowVersion: Entering method",{flowId:e,versionId:t});try{let a=await fetch("/api/flow/".concat(encodeURIComponent(e),"/versions/").concat(encodeURIComponent(t)));if(!a.ok){if(404===a.status)return null;let e=await a.json().catch(()=>null);throw Error((null==e?void 0:e.error)||"Failed to get flow version")}return await a.json()}catch(a){return r.warn("getFlowVersion: Failed for ".concat(e,"/").concat(t,":"),a),null}}createNode(e,t){return r.debug("createNode: Entering method",{type:e,position:t}),{id:(0,n.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:"process"===e?{inputMode:"full-history"}:{}}}}createStartNode(){return{id:(0,n.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";r.debug("createNewFlow: Entering method",{name:e});let t=Date.now();return{id:(0,n.A)(),name:e,createdAt:t,updatedAt:t,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return r.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return r.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,n.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let l=new s},93632:(e,t,a)=>{"use strict";a.d(t,{P:()=>s});let n=(0,a(87021).h)("frontend/services/plannedExecutions");class r{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return n.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await a.json();if(!a.ok)return{success:!1,error:(null==n?void 0:n.error)||"HTTP ".concat(a.status)};return{success:!0,execution:n.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return n.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let s=new r},94460:(e,t,a)=>{Promise.resolve().then(a.bind(a,70479))}},e=>{e.O(0,[2678,4754,9244,3392,1871,981,2003,9562,488,3272,3077,9581,3659,7328,8551,6428,7264,9951,9164,3772,8441,1255,7358],()=>e(e.s=94460)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974,9195],{3195:(e,t,n)=>{Promise.resolve().then(n.bind(n,4969))},4969:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>C});var a=n(95155),r=n(97322),i=n(22003),o=n(91871),s=n(4474),l=n(94049),c=n(25635),d=n(33077),u=n(2300),h=n(52619),p=n.n(h),f=n(15239),m=n(12115),g=n(87021),y=n(9164),b=n(69195),x=n(14913),v=n(57883),w=n(9562),k=n(98142),j=n(37553),S=n(33411);function A(){let[e,t]=(0,m.useState)(null),[n,r]=(0,m.useState)(""),[s,d]=(0,m.useState)(!1),[h,p]=(0,m.useState)(!1),[f,g]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),A=Array.from(n).length,O=Array.from(n.trim()).length,E=null!==e&&O>=1&&O<=255,C=async()=>{if(e&&E){d(!0),g(null),b(!1);try{let t=await fetch("/api/registry/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notice:n.trim(),rating:"happy"===e?5:1})}),a=await t.json().catch(()=>({}));if(!t.ok){g("string"==typeof a.error?a.error:"Could not submit feedback."),b(t.status>=500);return}p(!0)}catch(e){g("The feedback service is temporarily unavailable."),b(!0)}finally{d(!1)}}};return h?(0,a.jsx)(i.A,{severity:"success",sx:{mb:4},children:"Thanks for helping improve FLUJO."}):(0,a.jsxs)(u.A,{component:"section","aria-labelledby":"feedback-banner-title",variant:"outlined",sx:{mb:4,p:{xs:2,sm:2.5}},children:[(0,a.jsxs)(l.default,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},alignItems:{xs:"stretch",md:"center"},gap:2},children:[(0,a.jsxs)(l.default,{sx:{flex:"0 0 auto"},children:[(0,a.jsx)(c.default,{id:"feedback-banner-title",variant:"subtitle1",fontWeight:600,children:"Are you happy with FLUJO?"}),(0,a.jsx)(c.default,{variant:"body2",color:"text.secondary",children:"Tell us what is working—or what could be better."})]}),(0,a.jsxs)(x.A,{exclusive:!0,value:e,onChange:(e,n)=>{n&&t(n)},"aria-label":"Are you happy with FLUJO?",size:"small",children:[(0,a.jsxs)(v.A,{value:"happy","aria-label":"Yes, I am happy",children:[(0,a.jsx)(j.A,{sx:{mr:.75}}),"Yes"]}),(0,a.jsxs)(v.A,{value:"unhappy","aria-label":"No, I am not happy",children:[(0,a.jsx)(k.A,{sx:{mr:.75}}),"Not really"]})]}),(0,a.jsx)(w.A,{value:n,onChange:e=>r(e.target.value),placeholder:"Share your feedback",size:"small",multiline:!0,maxRows:3,inputProps:{maxLength:255,"aria-label":"Feedback"},helperText:"".concat(A,"/255"),sx:{flex:"1 1 280px"}}),(0,a.jsx)(o.A,{variant:"contained",onClick:C,disabled:!E||s,sx:{alignSelf:{xs:"stretch",md:"flex-start"},minWidth:96},children:s?"Sending…":"Send"})]}),f&&(0,a.jsxs)(i.A,{severity:"error",sx:{mt:2},onClose:()=>{g(null),b(!1)},action:y?(0,a.jsx)(o.A,{color:"inherit",size:"small",onClick:()=>{e&&(0,S.tr)({title:"FLUJO feedback",body:"Sentiment: ".concat("happy"===e?"Happy":"Not really","\n\n").concat(n.trim())})},children:"Open on GitHub"}):void 0,children:[f,y&&" You can send it through a pre-filled GitHub issue instead."]})]})}let O=(0,g.h)("app/page"),E=[{title:"Model Management",description:"Securely store and manage your AI model configurations and API keys.",icon:"/file.svg",link:"/models"},{title:"MCP Integration",description:"Connect and manage MCP servers with environment variables and tool testing.",icon:"/globe.svg",link:"/mcp"},{title:"Flow Builder",description:"Create and manage visual flows for your AI applications.",icon:"/window.svg",link:"/flows"}];function C(){var e;O.debug("Rendering HomePage");let{settings:t}=(0,y.useStorage)(),{startTour:n}=(0,b.useTour)(),[h,g]=(0,m.useState)(!0),[x,v]=(0,m.useState)(!1),[w,k]=(0,m.useState)(null),[j,S]=(0,m.useState)(!1),[C,R]=(0,m.useState)(null),P=(0,m.useRef)(!1);(0,m.useEffect)(()=>{var e;(null==t||null==(e=t.update)?void 0:e.checkOnStartup)&&!P.current&&(P.current=!0,(async()=>{try{O.info("Checking for FLUJO updates");let e=await fetch("/api/update");if(!e.ok)return;let t=await e.json();t.updateAvailable&&k({behindBy:t.behindBy,branch:t.branch})}catch(e){O.warn("Update check failed",e)}})())},[null==t||null==(e=t.update)?void 0:e.checkOnStartup]);let T=async()=>{S(!0),R(null);try{let e=await fetch("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"apply"})}),t=await e.json();if(!e.ok||!1===t.success){R(t.error||"Update failed."),S(!1);return}if(t.restarting){let e=!1,t=async()=>{try{if((await fetch("/api/cwd",{cache:"no-store"})).ok&&e)return void window.location.reload()}catch(t){e=!0}setTimeout(t,3e3)};setTimeout(t,5e3)}else S(!1),k(null)}catch(e){O.error("Update failed",e),R("Update failed."),S(!1)}};return(0,m.useEffect)(()=>{O.info("Checking encryption status"),(async()=>{try{O.debug("Fetching encryption initialization status");let e=await fetch("/api/encryption/secure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"check_initialized"})});if(e.ok){let t=await e.json();if(O.debug("Encryption initialization status received",{initialized:t.initialized}),g(!0===t.initialized),!0===t.initialized){O.debug("Checking if user encryption is enabled");let e=await fetch("/api/encryption/secure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"check_user_encryption"})});if(e.ok){let t=await e.json();O.debug("User encryption status received",{userEncryption:t.userEncryption}),v(!0===t.userEncryption)}}}else O.error("Failed to check encryption status"),g(!1)}catch(e){O.error("Error checking encryption status",e),g(!1)}})()},[]),(0,a.jsxs)(r.A,{maxWidth:"lg",sx:{py:8},children:[w&&(0,a.jsx)(i.A,{severity:"info",sx:{mb:4},action:(0,a.jsx)(o.A,{color:"inherit",size:"small",onClick:T,disabled:j,startIcon:j?(0,a.jsx)(s.default,{size:16,color:"inherit"}):void 0,children:j?"Updating…":"Update now"}),children:j?"Updating FLUJO and restarting — the page will reload automatically.":"A FLUJO update is available (".concat(w.behindBy," new commit").concat(1===w.behindBy?"":"s"," on ").concat(w.branch,").")}),C&&(0,a.jsx)(i.A,{severity:"error",sx:{mb:4},onClose:()=>R(null),children:C}),h?x?null:(0,a.jsxs)(i.A,{severity:"info",sx:{mb:4},children:["Your data is protected with default encryption. For enhanced security, set a custom encryption password in the ",(0,a.jsx)(p(),{href:"/settings",children:"settings"}),"."]}):(0,a.jsxs)(i.A,{severity:"warning",sx:{mb:4},children:["Warning: Encryption is not initialized. Sensitive data may not be properly protected. Please visit the ",(0,a.jsx)(p(),{href:"/settings",children:"settings"})," page."]}),(0,a.jsx)(A,{}),(0,a.jsxs)(l.default,{sx:{textAlign:"center",mb:8},children:[(0,a.jsx)(c.default,{variant:"h2",component:"h1",gutterBottom:!0,children:"FLUJO"}),(0,a.jsx)(c.default,{variant:"h5",color:"text.secondary",sx:{mb:4},children:"A browser-based application for managing models, MCP servers, flows and chat interactions"}),(0,a.jsx)(o.A,{variant:"contained",size:"large",sx:{mr:2},onClick:n,children:"Get Started"})]}),(0,a.jsx)(d.Ay,{container:!0,spacing:4,children:E.map(e=>(0,a.jsx)(d.Ay,{item:!0,xs:12,md:4,children:(0,a.jsxs)(u.A,{component:p(),href:e.link,sx:{p:4,height:"100%",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",textDecoration:"none",color:"text.primary",transition:"transform 0.2s","&:hover":{transform:"translateY(-4px)"}},children:[(0,a.jsx)(l.default,{sx:{mb:2,width:48,height:48,position:"relative"},children:(0,a.jsx)(f.default,{src:e.icon,alt:e.title,fill:!0,style:{objectFit:"contain"}})}),(0,a.jsx)(c.default,{variant:"h5",component:"h2",gutterBottom:!0,children:e.title}),(0,a.jsx)(c.default,{color:"text.secondary",children:e.description})]})},e.title))})]})}},33411:(e,t,n)=>{"use strict";n.d(t,{tr:()=>i});var a=n(50432);let r="\n\n_(Report truncated to fit GitHub URL limits — please paste any remaining logs/details manually.)_";function i(e,t){let n=function(e){let{title:t,body:n,labels:i=[]}=e,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.BS,s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=a.gY,n=new Set,r=[];for(let a of e)"string"==typeof a&&t.includes(a)&&!n.has(a)&&(n.add(a),r.push(a));return r}(i),l="https://github.com/".concat(o,"/issues/new"),c=e=>{let n=new URLSearchParams;return t&&n.set("title",t),n.set("body",e),s.length&&n.set("labels",s.join(",")),"".concat(l,"?").concat(n.toString())},d=c(n);if(d.length<=8e3)return d;let u=n;for(d=c(u+r);d.length>8e3&&u.length>0;){let e=Math.max(16,Math.ceil(1.2*(d.length-8e3)));d=c((u=u.slice(0,Math.max(0,u.length-e)))+r)}return d}(e,t);return window.open(n,"_blank","noopener,noreferrer"),n}},50432:(e,t,n)=>{"use strict";n.d(t,{BS:()=>r,gY:()=>a,uV:()=>i});let a=["bug","ux","frontend","backend","github-integration","mcp","performance"],r="mario-andreschak/FLUJO";function i(e){return["### Environment\n```","App version: ".concat(e.appVersion),"Install mode: ".concat(e.installMode),"OS: ".concat(e.os),"Browser: ".concat(e.browser),"Page: ".concat(e.pageUrl),"Reported: ".concat(e.timestamp),"```"].join("\n")}},69195:(e,t,n)=>{"use strict";n.r(t),n.d(t,{TourProvider:()=>d,useTour:()=>c});var a=n(95155),r=n(12115),i=n(9164),o=n(77326);let s=(0,n(87021).h)("frontend/contexts/TourContext"),l=(0,r.createContext)({isActive:!1,stepIndex:0,startTour:()=>{},next:()=>{},back:()=>{},endTour:()=>{}}),c=()=>(0,r.useContext)(l),d=e=>{var t;let{children:n}=e,{settings:c,updateSettings:d,isLoading:u,settingsHydrated:h}=(0,i.useStorage)(),[p,f]=(0,r.useState)(!1),[m,g]=(0,r.useState)(0),y=(0,r.useRef)(!1),b=(0,r.useCallback)(()=>{var e;d({...c,onboarding:{...null!=(e=c.onboarding)?e:{},completed:!0}}).catch(e=>s.warn("Failed to persist onboarding completion",e))},[c,d]),x=(0,r.useCallback)(()=>{s.info("Starting guided tour"),g(0),f(!0)},[]),v=(0,r.useCallback)(()=>{s.info("Ending guided tour"),f(!1),b()},[b]),w=(0,r.useCallback)(()=>{g(e=>e>=o.$.length-1?(f(!1),b(),e):e+1)},[b]),k=(0,r.useCallback)(()=>{g(e=>Math.max(0,e-1))},[]);return(0,r.useEffect)(()=>{var e;u||!h||y.current||(y.current=!0,(null==(e=c.onboarding)?void 0:e.completed)!==!0&&(s.info("First run detected — auto-starting guided tour"),x()))},[u,h,null==(t=c.onboarding)?void 0:t.completed,x]),(0,a.jsx)(l.Provider,{value:{isActive:p,stepIndex:m,startTour:x,next:w,back:k,endTour:v},children:n})}},77326:(e,t,n)=>{"use strict";n.d(t,{$:()=>a});let a=[{id:"welcome",path:"/",placement:"center",title:"Welcome to FLUJO \uD83D\uDC4B",body:"This quick tour walks you through going from zero to a running AI flow.\n\nYou'll add a model, connect a tool server, build a flow, and run it in chat. It takes about a minute — you can skip any time."},{id:"add-model",path:"/models",target:'[data-tour="add-model"]',placement:"bottom",title:"1. Add a model",body:'FLUJO needs at least one AI model to think with. Click "Add Model" to configure one.\n\nTip: an OpenRouter API key gives you access to several free models — paste the key, name the model, pick a free one, and add a custom instruction.'},{id:"add-mcp-server",path:"/mcp",target:'[data-tour="add-mcp-server"]',placement:"bottom",title:"2. Connect a tool server (MCP)",body:'MCP servers give your model real tools — file access, image generation, web search, and more.\n\nClick "Add Server" and install the "Everything" reference server to try the full range of capabilities while you learn.'},{id:"new-flow",path:"/flows",target:'[data-tour="new-flow"]',placement:"bottom",title:"3. Build a flow",body:'A flow wires everything together. Click "New Flow" to open the builder.\n\nConnect Start → Process → Finish, attach your model to the Process node, and bind the Everything MCP server so the model can use its tools.'},{id:"chat-input",path:"/chat",target:'[data-tour="chat-input"]',placement:"top",title:"4. Run it in chat",body:"Pick your flow from the selector, then send a message here.\n\nTry asking it to generate an image with the MCP server and tell you a joke — you'll see the flow execute live, step by step."},{id:"docs",path:"/chat",target:'[data-tour="nav-docs"]',placement:"bottom",title:"Need the API?",body:"FLUJO exposes an OpenAI-compatible API and a full REST surface. The Docs page lists every endpoint with its method, parameters, and response shape.\n\nYou can re-run this tour any time from Settings → Onboarding."},{id:"finish",path:"/chat",placement:"center",title:"You're all set \uD83C\uDF89",body:"That's the whole loop: models, tools, flows, and chat.\n\nExplore at your own pace — and remember the Docs page and Settings are there when you need them."}]},87021:(e,t,n)=>{"use strict";n.d(t,{h:()=>l});let a={LOG_LEVEL:3},r={VERBOSE:-1,DEBUG:0,INFO:1,WARN:2,ERROR:3},i="number"==typeof a.LOG_LEVEL?a.LOG_LEVEL:r.ERROR;function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t>6)return String(e);if(!(e instanceof Error))return e;let n={name:e.name,message:e.message};for(let a of Object.getOwnPropertyNames(e)){if("name"===a||"message"===a)continue;let r=e[a];"function"!=typeof r&&("stack"===a?n.stack=r:"cause"===a?n.cause=o(r,t+1):"errors"===a&&Array.isArray(r)?n.errors=r.map(e=>o(e,t+1)):n[a]=r)}return n}function s(e,t,n,a,s){if(e>=("number"==typeof s?s:i)){if("function"==typeof a)try{a=a()}catch(e){a="[lazy log data threw]"}let i=new Date().toISOString(),s="[".concat(i,"] [").concat(t,"]"),l="".concat(s," ").concat(n);if(void 0!==a)if(a instanceof Error||"object"==typeof a)try{let e=a instanceof Error?o(a):a,t=JSON.stringify(e,(e,t)=>t instanceof Error?o(t):t,2);l+=":\n".concat(t)}catch(e){l+=": [Object cannot be stringified]"}else l+=": ".concat(a);switch(e){case r.VERBOSE:console.debug("[VERBOSE] ".concat(l));break;case r.DEBUG:console.debug(l);break;case r.INFO:console.info(l);break;case r.WARN:console.warn(l);break;case r.ERROR:console.error(l);break;default:console.log(l)}}}function l(e,t){let n,a=((n=e.replace(/^src\//,"")).startsWith("/")&&(n=n.substring(1)),n);return{verbose:(e,n)=>{s(r.VERBOSE,a,e,n,t)},debug:(e,n)=>{s(r.DEBUG,a,e,n,t)},info:(e,n)=>{s(r.INFO,a,e,n,t)},warn:(e,n)=>{s(r.WARN,a,e,n,t)},error:(e,n)=>{s(r.ERROR,a,e,n,t)}}}}},e=>{e.O(0,[2678,4754,9244,3392,1871,981,2003,9562,3077,1675,4523,4929,9164,8441,1255,7358],()=>e(e.s=3195)),_N_E=e.O()}]);