flujo-ai 3.16.0 → 3.17.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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +36 -36
- package/.next/app-path-routes-manifest.json +7 -7
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +6 -6
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/backup/route.js +1 -1
- package/.next/server/app/api/backup/route.js.nft.json +1 -1
- package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/encryption/secure/route.js.nft.json +1 -1
- package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/route.js +1 -1
- package/.next/server/app/api/flow/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/compile/route.js +1 -1
- package/.next/server/app/api/flow/compile/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generate/route.js +4 -2
- package/.next/server/app/api/flow/generate/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route.js +2 -2
- package/.next/server/app/api/flow/prompt-renderer/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/route.js +1 -1
- package/.next/server/app/api/flow/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/init/route.js.nft.json +1 -1
- package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/cancel/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/get/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/read/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/status/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/provider/route.js.nft.json +1 -1
- package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/route.js.nft.json +1 -1
- package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/test/route.js.nft.json +1 -1
- package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/reset/route.js.nft.json +1 -1
- package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restore/route.js +1 -1
- package/.next/server/app/api/restore/route.js.nft.json +1 -1
- package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/webhooks/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +1 -1
- package/.next/server/app/docs/page.js +2 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +2 -2
- package/.next/server/app/executions/page.js +1 -1
- package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/executions.html +1 -1
- package/.next/server/app/executions.rsc +1 -1
- package/.next/server/app/flows/page.js +2 -2
- package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/flows.html +1 -1
- package/.next/server/app/flows.rsc +2 -2
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-flows/route.js +2 -2
- package/.next/server/app/mcp-flows/route.js.nft.json +1 -1
- package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route.js.nft.json +1 -1
- package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp.html +1 -1
- package/.next/server/app/mcp.rsc +1 -1
- package/.next/server/app/models/page.js +1 -1
- package/.next/server/app/models/page.js.nft.json +1 -1
- package/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +1 -1
- package/.next/server/app/v1/chat/completions/route.js +1 -2
- package/.next/server/app/v1/chat/completions/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js +2 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js +2 -2
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js +2 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js +2 -2
- package/.next/server/app/v1/chat/conversations/[conversationId]/events/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/route.js +2 -2
- package/.next/server/app/v1/chat/conversations/[conversationId]/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/route.js +2 -2
- package/.next/server/app/v1/chat/conversations/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/models/route.js.nft.json +1 -1
- package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +7 -7
- package/.next/server/chunks/1403.js +2 -2
- package/.next/server/chunks/1519.js +1 -0
- package/.next/server/chunks/1877.js +2 -1
- package/.next/server/chunks/2776.js +1 -1
- package/.next/server/chunks/2859.js +3 -3
- package/.next/server/chunks/3243.js +1 -1
- package/.next/server/chunks/{9688.js → 3309.js} +2 -2
- package/.next/server/chunks/3370.js +38 -0
- package/.next/server/chunks/3984.js +4 -4
- package/.next/server/chunks/{8367.js → 407.js} +6 -2
- package/.next/server/chunks/4681.js +1 -1
- package/.next/server/chunks/5504.js +1 -1
- package/.next/server/chunks/6936.js +4 -4
- package/.next/server/chunks/7214.js +1 -1
- package/.next/server/chunks/724.js +1 -1
- package/.next/server/chunks/7362.js +3 -3
- package/.next/server/chunks/7506.js +1 -1
- package/.next/server/chunks/7635.js +2 -2
- package/.next/server/chunks/7821.js +1 -0
- package/.next/server/chunks/7982.js +1 -0
- package/.next/server/chunks/9509.js +2 -2
- package/.next/server/chunks/9957.js +1 -1
- package/.next/server/instrumentation.js.nft.json +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/app/docs/page-fca894f60b9174e9.js +1 -0
- package/.next/static/chunks/app/flows/page-4e1ec20653e5dc86.js +1 -0
- package/.next/trace +7 -7
- package/README.md +1 -1
- package/package.json +1 -1
- package/.next/server/chunks/6195.js +0 -37
- package/.next/server/chunks/8126.js +0 -1
- package/.next/server/chunks/8312.js +0 -5
- package/.next/server/chunks/9989.js +0 -1
- package/.next/static/chunks/app/docs/page-1d349e2d82f7b104.js +0 -1
- package/.next/static/chunks/app/flows/page-375150edff9134a3.js +0 -1
- /package/.next/static/{z7fsG7kblb_yxkUhOxn-G → KMEKXonxBXI3WzCfozXx4}/_buildManifest.js +0 -0
- /package/.next/static/{z7fsG7kblb_yxkUhOxn-G → KMEKXonxBXI3WzCfozXx4}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"node":{"40520b537d1d43f510acbccd60e3e7d42ce215c157":{"workers":{"app/api/backup/route":{"moduleId":"947","async":false},"app/api/encryption/secure/route":{"moduleId":"947","async":false},"app/api/env/route":{"moduleId":"947","async":false},"app/api/flow/[id]/route":{"moduleId":"947","async":false},"app/api/flow/compile/route":{"moduleId":"947","async":false},"app/api/flow/generate/route":{"moduleId":"947","async":false},"app/api/flow/prompt-renderer/route":{"moduleId":"947","async":false},"app/api/flow/route":{"moduleId":"947","async":false},"app/api/init/route":{"moduleId":"947","async":false},"app/api/mcp/cancel/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/get/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/read/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/status/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/[toolName]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/route":{"moduleId":"947","async":false},"app/api/mcp/servers/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/route":{"moduleId":"947","async":false},"app/api/model/[id]/route":{"moduleId":"947","async":false},"app/api/model/provider/route":{"moduleId":"947","async":false},"app/api/model/route":{"moduleId":"947","async":false},"app/api/oauth/callback/route":{"moduleId":"947","async":false},"app/api/oauth/initiate/route":{"moduleId":"947","async":false},"app/api/oauth/reset/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/run/route":{"moduleId":"947","async":false},"app/api/model/test/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/runs/route":{"moduleId":"947","async":false},"app/api/planned-executions/route":{"moduleId":"947","async":false},"app/api/restore/route":{"moduleId":"947","async":false},"app/api/webhooks/[id]/route":{"moduleId":"947","async":false},"app/v1/chat/completions/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/cancel/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/breakpoints/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/continue/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/step/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/edit-state/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/respond/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/route":{"moduleId":"947","async":false},"app/v1/models/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/stream/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/events/route":{"moduleId":"947","async":false},"app/mcp-proxy/[server]/route":{"moduleId":"947","async":false},"app/mcp-flows/route":{"moduleId":"947","async":false},"app/models/page":{"moduleId":"947","async":false},"app/mcp/page":{"moduleId":"9047","async":false},"app/settings/page":{"moduleId":"9047","async":false}},"layer":{"app/api/backup/route":"rsc","app/api/encryption/secure/route":"rsc","app/api/env/route":"rsc","app/api/flow/[id]/route":"rsc","app/api/flow/compile/route":"rsc","app/api/flow/generate/route":"rsc","app/api/flow/prompt-renderer/route":"rsc","app/api/flow/route":"rsc","app/api/init/route":"rsc","app/api/mcp/cancel/route":"rsc","app/api/mcp/servers/[name]/prompts/route":"rsc","app/api/mcp/servers/[name]/prompts/get/route":"rsc","app/api/mcp/servers/[name]/resources/read/route":"rsc","app/api/mcp/servers/[name]/resources/route":"rsc","app/api/mcp/servers/[name]/route":"rsc","app/api/mcp/servers/[name]/status/route":"rsc","app/api/mcp/servers/[name]/tools/[toolName]/route":"rsc","app/api/mcp/servers/[name]/tools/route":"rsc","app/api/mcp/servers/route":"rsc","app/api/mcp/test-connection/route":"rsc","app/api/model/[id]/route":"rsc","app/api/model/provider/route":"rsc","app/api/model/route":"rsc","app/api/oauth/callback/route":"rsc","app/api/oauth/initiate/route":"rsc","app/api/oauth/reset/route":"rsc","app/api/planned-executions/[id]/route":"rsc","app/api/planned-executions/[id]/run/route":"rsc","app/api/model/test/route":"rsc","app/api/planned-executions/[id]/runs/route":"rsc","app/api/planned-executions/route":"rsc","app/api/restore/route":"rsc","app/api/webhooks/[id]/route":"rsc","app/v1/chat/completions/route":"rsc","app/v1/chat/conversations/[conversationId]/cancel/route":"rsc","app/v1/chat/conversations/[conversationId]/breakpoints/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/continue/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/step/route":"rsc","app/v1/chat/conversations/[conversationId]/edit-state/route":"rsc","app/v1/chat/conversations/[conversationId]/respond/route":"rsc","app/v1/chat/conversations/[conversationId]/route":"rsc","app/v1/chat/conversations/route":"rsc","app/v1/models/route":"rsc","app/api/mcp/test-connection/stream/route":"rsc","app/v1/chat/conversations/[conversationId]/events/route":"rsc","app/mcp-proxy/[server]/route":"rsc","app/mcp-flows/route":"rsc","app/models/page":"rsc","app/mcp/page":"action-browser","app/settings/page":"action-browser"},"filename":"../C:\\Users\\MarioAndreschak\\Documents\\GitHub\\FLUJO\\src\\backend\\utils\\resolveGlobalVars.ts","exportedName":"resolveGlobalVars"},"60de87c4c5950c080550cb766970e88ae9c9a0ca25":{"workers":{"app/api/backup/route":{"moduleId":"947","async":false},"app/api/encryption/secure/route":{"moduleId":"947","async":false},"app/api/env/route":{"moduleId":"947","async":false},"app/api/flow/[id]/route":{"moduleId":"947","async":false},"app/api/flow/compile/route":{"moduleId":"947","async":false},"app/api/flow/generate/route":{"moduleId":"947","async":false},"app/api/flow/prompt-renderer/route":{"moduleId":"947","async":false},"app/api/flow/route":{"moduleId":"947","async":false},"app/api/init/route":{"moduleId":"947","async":false},"app/api/mcp/cancel/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/get/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/read/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/status/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/[toolName]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/route":{"moduleId":"947","async":false},"app/api/mcp/servers/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/route":{"moduleId":"947","async":false},"app/api/model/[id]/route":{"moduleId":"947","async":false},"app/api/model/provider/route":{"moduleId":"947","async":false},"app/api/model/route":{"moduleId":"947","async":false},"app/api/oauth/callback/route":{"moduleId":"947","async":false},"app/api/oauth/initiate/route":{"moduleId":"947","async":false},"app/api/oauth/reset/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/run/route":{"moduleId":"947","async":false},"app/api/model/test/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/runs/route":{"moduleId":"947","async":false},"app/api/planned-executions/route":{"moduleId":"947","async":false},"app/api/restore/route":{"moduleId":"947","async":false},"app/api/webhooks/[id]/route":{"moduleId":"947","async":false},"app/v1/chat/completions/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/cancel/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/breakpoints/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/continue/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/step/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/edit-state/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/respond/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/route":{"moduleId":"947","async":false},"app/v1/models/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/stream/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/events/route":{"moduleId":"947","async":false},"app/mcp-proxy/[server]/route":{"moduleId":"947","async":false},"app/mcp-flows/route":{"moduleId":"947","async":false},"app/models/page":{"moduleId":"947","async":false},"app/mcp/page":{"moduleId":"9047","async":false},"app/settings/page":{"moduleId":"9047","async":false}},"layer":{"app/api/backup/route":"rsc","app/api/encryption/secure/route":"rsc","app/api/env/route":"rsc","app/api/flow/[id]/route":"rsc","app/api/flow/compile/route":"rsc","app/api/flow/generate/route":"rsc","app/api/flow/prompt-renderer/route":"rsc","app/api/flow/route":"rsc","app/api/init/route":"rsc","app/api/mcp/cancel/route":"rsc","app/api/mcp/servers/[name]/prompts/route":"rsc","app/api/mcp/servers/[name]/prompts/get/route":"rsc","app/api/mcp/servers/[name]/resources/read/route":"rsc","app/api/mcp/servers/[name]/resources/route":"rsc","app/api/mcp/servers/[name]/route":"rsc","app/api/mcp/servers/[name]/status/route":"rsc","app/api/mcp/servers/[name]/tools/[toolName]/route":"rsc","app/api/mcp/servers/[name]/tools/route":"rsc","app/api/mcp/servers/route":"rsc","app/api/mcp/test-connection/route":"rsc","app/api/model/[id]/route":"rsc","app/api/model/provider/route":"rsc","app/api/model/route":"rsc","app/api/oauth/callback/route":"rsc","app/api/oauth/initiate/route":"rsc","app/api/oauth/reset/route":"rsc","app/api/planned-executions/[id]/route":"rsc","app/api/planned-executions/[id]/run/route":"rsc","app/api/model/test/route":"rsc","app/api/planned-executions/[id]/runs/route":"rsc","app/api/planned-executions/route":"rsc","app/api/restore/route":"rsc","app/api/webhooks/[id]/route":"rsc","app/v1/chat/completions/route":"rsc","app/v1/chat/conversations/[conversationId]/cancel/route":"rsc","app/v1/chat/conversations/[conversationId]/breakpoints/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/continue/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/step/route":"rsc","app/v1/chat/conversations/[conversationId]/edit-state/route":"rsc","app/v1/chat/conversations/[conversationId]/respond/route":"rsc","app/v1/chat/conversations/[conversationId]/route":"rsc","app/v1/chat/conversations/route":"rsc","app/v1/models/route":"rsc","app/api/mcp/test-connection/stream/route":"rsc","app/v1/chat/conversations/[conversationId]/events/route":"rsc","app/mcp-proxy/[server]/route":"rsc","app/mcp-flows/route":"rsc","app/models/page":"rsc","app/mcp/page":"action-browser","app/settings/page":"action-browser"},"filename":"../C:\\Users\\MarioAndreschak\\Documents\\GitHub\\FLUJO\\src\\backend\\utils\\resolveGlobalVars.ts","exportedName":"resolveAndDecryptApiKey"}},"edge":{},"encryptionKey":"d34suOUYcHmh7KN6f1Lco7DLyXwlel7jYb4XH/DNEks="}
|
|
1
|
+
{"node":{"40520b537d1d43f510acbccd60e3e7d42ce215c157":{"workers":{"app/api/backup/route":{"moduleId":"947","async":false},"app/api/encryption/secure/route":{"moduleId":"947","async":false},"app/api/env/route":{"moduleId":"947","async":false},"app/api/flow/[id]/route":{"moduleId":"947","async":false},"app/api/flow/compile/route":{"moduleId":"947","async":false},"app/api/flow/generate/route":{"moduleId":"947","async":false},"app/api/flow/prompt-renderer/route":{"moduleId":"947","async":false},"app/api/flow/route":{"moduleId":"947","async":false},"app/api/init/route":{"moduleId":"947","async":false},"app/api/mcp/cancel/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/get/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/read/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/status/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/[toolName]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/route":{"moduleId":"947","async":false},"app/api/mcp/servers/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/route":{"moduleId":"947","async":false},"app/api/model/[id]/route":{"moduleId":"947","async":false},"app/api/model/provider/route":{"moduleId":"947","async":false},"app/api/model/route":{"moduleId":"947","async":false},"app/api/model/test/route":{"moduleId":"947","async":false},"app/api/oauth/callback/route":{"moduleId":"947","async":false},"app/api/oauth/initiate/route":{"moduleId":"947","async":false},"app/api/oauth/reset/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/run/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/runs/route":{"moduleId":"947","async":false},"app/api/planned-executions/route":{"moduleId":"947","async":false},"app/api/restore/route":{"moduleId":"947","async":false},"app/api/webhooks/[id]/route":{"moduleId":"947","async":false},"app/v1/chat/completions/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/breakpoints/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/cancel/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/continue/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/step/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/edit-state/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/respond/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/route":{"moduleId":"947","async":false},"app/v1/models/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/stream/route":{"moduleId":"947","async":false},"app/mcp-proxy/[server]/route":{"moduleId":"947","async":false},"app/mcp-flows/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/events/route":{"moduleId":"947","async":false},"app/models/page":{"moduleId":"947","async":false},"app/mcp/page":{"moduleId":"9047","async":false},"app/settings/page":{"moduleId":"9047","async":false}},"layer":{"app/api/backup/route":"rsc","app/api/encryption/secure/route":"rsc","app/api/env/route":"rsc","app/api/flow/[id]/route":"rsc","app/api/flow/compile/route":"rsc","app/api/flow/generate/route":"rsc","app/api/flow/prompt-renderer/route":"rsc","app/api/flow/route":"rsc","app/api/init/route":"rsc","app/api/mcp/cancel/route":"rsc","app/api/mcp/servers/[name]/prompts/get/route":"rsc","app/api/mcp/servers/[name]/prompts/route":"rsc","app/api/mcp/servers/[name]/resources/read/route":"rsc","app/api/mcp/servers/[name]/resources/route":"rsc","app/api/mcp/servers/[name]/route":"rsc","app/api/mcp/servers/[name]/status/route":"rsc","app/api/mcp/servers/[name]/tools/[toolName]/route":"rsc","app/api/mcp/servers/[name]/tools/route":"rsc","app/api/mcp/servers/route":"rsc","app/api/mcp/test-connection/route":"rsc","app/api/model/[id]/route":"rsc","app/api/model/provider/route":"rsc","app/api/model/route":"rsc","app/api/model/test/route":"rsc","app/api/oauth/callback/route":"rsc","app/api/oauth/initiate/route":"rsc","app/api/oauth/reset/route":"rsc","app/api/planned-executions/[id]/route":"rsc","app/api/planned-executions/[id]/run/route":"rsc","app/api/planned-executions/[id]/runs/route":"rsc","app/api/planned-executions/route":"rsc","app/api/restore/route":"rsc","app/api/webhooks/[id]/route":"rsc","app/v1/chat/completions/route":"rsc","app/v1/chat/conversations/[conversationId]/breakpoints/route":"rsc","app/v1/chat/conversations/[conversationId]/cancel/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/continue/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/step/route":"rsc","app/v1/chat/conversations/[conversationId]/edit-state/route":"rsc","app/v1/chat/conversations/[conversationId]/respond/route":"rsc","app/v1/chat/conversations/[conversationId]/route":"rsc","app/v1/chat/conversations/route":"rsc","app/v1/models/route":"rsc","app/api/mcp/test-connection/stream/route":"rsc","app/mcp-proxy/[server]/route":"rsc","app/mcp-flows/route":"rsc","app/v1/chat/conversations/[conversationId]/events/route":"rsc","app/models/page":"rsc","app/mcp/page":"action-browser","app/settings/page":"action-browser"},"filename":"../C:\\Users\\MarioAndreschak\\Documents\\GitHub\\FLUJO\\src\\backend\\utils\\resolveGlobalVars.ts","exportedName":"resolveGlobalVars"},"60de87c4c5950c080550cb766970e88ae9c9a0ca25":{"workers":{"app/api/backup/route":{"moduleId":"947","async":false},"app/api/encryption/secure/route":{"moduleId":"947","async":false},"app/api/env/route":{"moduleId":"947","async":false},"app/api/flow/[id]/route":{"moduleId":"947","async":false},"app/api/flow/compile/route":{"moduleId":"947","async":false},"app/api/flow/generate/route":{"moduleId":"947","async":false},"app/api/flow/prompt-renderer/route":{"moduleId":"947","async":false},"app/api/flow/route":{"moduleId":"947","async":false},"app/api/init/route":{"moduleId":"947","async":false},"app/api/mcp/cancel/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/get/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/prompts/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/read/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/resources/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/status/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/[toolName]/route":{"moduleId":"947","async":false},"app/api/mcp/servers/[name]/tools/route":{"moduleId":"947","async":false},"app/api/mcp/servers/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/route":{"moduleId":"947","async":false},"app/api/model/[id]/route":{"moduleId":"947","async":false},"app/api/model/provider/route":{"moduleId":"947","async":false},"app/api/model/route":{"moduleId":"947","async":false},"app/api/model/test/route":{"moduleId":"947","async":false},"app/api/oauth/callback/route":{"moduleId":"947","async":false},"app/api/oauth/initiate/route":{"moduleId":"947","async":false},"app/api/oauth/reset/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/run/route":{"moduleId":"947","async":false},"app/api/planned-executions/[id]/runs/route":{"moduleId":"947","async":false},"app/api/planned-executions/route":{"moduleId":"947","async":false},"app/api/restore/route":{"moduleId":"947","async":false},"app/api/webhooks/[id]/route":{"moduleId":"947","async":false},"app/v1/chat/completions/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/breakpoints/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/cancel/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/continue/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/debug/step/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/edit-state/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/respond/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/route":{"moduleId":"947","async":false},"app/v1/models/route":{"moduleId":"947","async":false},"app/api/mcp/test-connection/stream/route":{"moduleId":"947","async":false},"app/mcp-proxy/[server]/route":{"moduleId":"947","async":false},"app/mcp-flows/route":{"moduleId":"947","async":false},"app/v1/chat/conversations/[conversationId]/events/route":{"moduleId":"947","async":false},"app/models/page":{"moduleId":"947","async":false},"app/mcp/page":{"moduleId":"9047","async":false},"app/settings/page":{"moduleId":"9047","async":false}},"layer":{"app/api/backup/route":"rsc","app/api/encryption/secure/route":"rsc","app/api/env/route":"rsc","app/api/flow/[id]/route":"rsc","app/api/flow/compile/route":"rsc","app/api/flow/generate/route":"rsc","app/api/flow/prompt-renderer/route":"rsc","app/api/flow/route":"rsc","app/api/init/route":"rsc","app/api/mcp/cancel/route":"rsc","app/api/mcp/servers/[name]/prompts/get/route":"rsc","app/api/mcp/servers/[name]/prompts/route":"rsc","app/api/mcp/servers/[name]/resources/read/route":"rsc","app/api/mcp/servers/[name]/resources/route":"rsc","app/api/mcp/servers/[name]/route":"rsc","app/api/mcp/servers/[name]/status/route":"rsc","app/api/mcp/servers/[name]/tools/[toolName]/route":"rsc","app/api/mcp/servers/[name]/tools/route":"rsc","app/api/mcp/servers/route":"rsc","app/api/mcp/test-connection/route":"rsc","app/api/model/[id]/route":"rsc","app/api/model/provider/route":"rsc","app/api/model/route":"rsc","app/api/model/test/route":"rsc","app/api/oauth/callback/route":"rsc","app/api/oauth/initiate/route":"rsc","app/api/oauth/reset/route":"rsc","app/api/planned-executions/[id]/route":"rsc","app/api/planned-executions/[id]/run/route":"rsc","app/api/planned-executions/[id]/runs/route":"rsc","app/api/planned-executions/route":"rsc","app/api/restore/route":"rsc","app/api/webhooks/[id]/route":"rsc","app/v1/chat/completions/route":"rsc","app/v1/chat/conversations/[conversationId]/breakpoints/route":"rsc","app/v1/chat/conversations/[conversationId]/cancel/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/continue/route":"rsc","app/v1/chat/conversations/[conversationId]/debug/step/route":"rsc","app/v1/chat/conversations/[conversationId]/edit-state/route":"rsc","app/v1/chat/conversations/[conversationId]/respond/route":"rsc","app/v1/chat/conversations/[conversationId]/route":"rsc","app/v1/chat/conversations/route":"rsc","app/v1/models/route":"rsc","app/api/mcp/test-connection/stream/route":"rsc","app/mcp-proxy/[server]/route":"rsc","app/mcp-flows/route":"rsc","app/v1/chat/conversations/[conversationId]/events/route":"rsc","app/models/page":"rsc","app/mcp/page":"action-browser","app/settings/page":"action-browser"},"filename":"../C:\\Users\\MarioAndreschak\\Documents\\GitHub\\FLUJO\\src\\backend\\utils\\resolveGlobalVars.ts","exportedName":"resolveAndDecryptApiKey"}},"edge":{},"encryptionKey":"d34suOUYcHmh7KN6f1Lco7DLyXwlel7jYb4XH/DNEks="}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9040],{32651:(e,t,a)=>{Promise.resolve().then(a.bind(a,71113))},71113:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>x});var o=a(95155),s=a(94049),n=a(12115),r=a(28548),i=a(2300),d=a(25635),l=a(97322),p=a(9562),c=a(56422),m=a(21067),u=a(32683),h=a(51611);let y=[{id:"openai",name:"Chat — OpenAI-compatible",description:'A drop-in OpenAI-compatible surface. In OpenAI-compatible clients (Roo Code, Cline, Cursor, the OpenAI SDK, …) set the Base URL to this instance + "/v1" (e.g. http://localhost:4200/v1) and the model to a flow id (format flow-<NAME>, as listed by /v1/models).',endpoints:[{method:"POST",alsoMethods:["GET","OPTIONS"],path:"/v1/chat/completions",summary:"OpenAI-compatible chat completion. Runs a FLUJO flow as the model. Supports streaming and non-streaming. CORS-enabled; rate-limited (~6000 req/min).",paramsLabel:"Body",params:[{name:"model",type:"string",required:!0,description:"Flow to run, as flow-<NAME>."},{name:"messages",type:"ChatMessage[]",required:!0,description:"Conversation messages (OpenAI shape)."},{name:"stream",type:"boolean",description:"Stream the response as SSE chunks."},{name:"flujo",type:"boolean",description:"Enable FLUJO-specific behavior."},{name:"conversation_id",type:"string",description:"Reuse/continue an existing conversation."},{name:"requireApproval",type:"boolean",description:"Pause for manual tool-call approval."},{name:"flujodebug",type:"boolean",description:"Run in the visual debugger (single-step)."}],response:"OpenAI ChatCompletion object, or an SSE stream of chunks when stream=true."},{method:"GET",path:"/v1/models",summary:"List all flows as OpenAI-style models.",response:'{ object: "list", data: [{ id: "flow-<NAME>", object: "model" }, ...] }'}]},{id:"conversations",name:"Conversations & Execution",description:"Manage conversations and drive flow execution: live event streaming (SSE), tool-call approval, cancellation, and visual-debugger stepping.",endpoints:[{method:"GET",path:"/v1/chat/conversations",summary:"List all conversations (id, title, flowId, createdAt, updatedAt, status), newest first.",response:"Conversation summary array."},{method:"POST",path:"/v1/chat/conversations",summary:"Create a new conversation and initialize its execution state.",paramsLabel:"Body",params:[{name:"id",type:"string",required:!0,description:"Client-generated conversation id."},{name:"title",type:"string",required:!0,description:"Display title."},{name:"flowId",type:"string",required:!0,description:"Flow bound to this conversation."},{name:"createdAt",type:"number",required:!0,description:"Unix ms timestamp."},{name:"updatedAt",type:"number",required:!0,description:"Unix ms timestamp."}]},{method:"GET",alsoMethods:["PATCH","DELETE"],path:"/v1/chat/conversations/{conversationId}",summary:"GET the displayed conversation (messages + metadata); PATCH updates flowId; DELETE removes the conversation and its event log.",paramsLabel:"Body",params:[{name:"flowId",type:"string",description:"New flow id (PATCH only)."}],response:"Conversation with messages, plus usage (token totals, per-node breakdown), status, and contextInfo (latest prompt-token count + the bound model's context window — what the chat token counter and context meter display).",notes:["Messages are a projection of the append-only conversation log when one exists (legacy conversations without a log are served as stored). Node system prompts are never included.","Subflow steps appear inline as depth-tagged, display-only messages (nested in the chat UI); they are never part of the parent's model context."]},{method:"GET",path:"/v1/chat/conversations/{conversationId}/events",summary:"Server-Sent Events stream of execution events (node:enter/exit, message, usage, run:*). Supports Last-Event-ID reconnect.",paramsLabel:"Query",params:[{name:"fromSeq",type:"number",description:"Replay events from this sequence number."}],response:"text/event-stream of ExecutionEvent objects with monotonic seq ids."},{method:"POST",path:"/v1/chat/conversations/{conversationId}/respond",summary:"Approve or reject a pending tool call; resumes execution when all pending calls are handled.",paramsLabel:"Body",params:[{name:"action",type:'"approve" | "reject"',required:!0,description:"Decision for the tool call."},{name:"toolCallId",type:"string",required:!0,description:"Which pending tool call."}]},{method:"POST",path:"/v1/chat/conversations/{conversationId}/cancel",summary:"Request cancellation of an in-progress run (sets the isCancelled flag)."},{method:"PUT",path:"/v1/chat/conversations/{conversationId}/breakpoints",summary:"Set the visual-debugger breakpoint node ids.",paramsLabel:"Body",params:[{name:"breakpoints",type:"string[]",required:!0,description:"Node ids to break on."}]},{method:"POST",path:"/v1/chat/conversations/{conversationId}/debug/step",summary:"Execute exactly one productive step (only when status is paused_debug); pauses after advancing."},{method:"POST",path:"/v1/chat/conversations/{conversationId}/debug/continue",summary:"Resume a debug session — run freely to the next pause, tool approval, or completion."},{method:"PATCH",path:"/v1/chat/conversations/{conversationId}/edit-state",summary:"Edit paused debug state (a message's content, or the next node to run). Only when paused_debug.",paramsLabel:"Body",params:[{name:"messageId",type:"string",description:"Message to edit."},{name:"content",type:"string",description:"New message content."},{name:"currentNodeId",type:"string",description:"Override the next node."}]}]},{id:"model",name:"Models",description:"CRUD for model configurations and provider model discovery. API keys are encrypted at rest and never returned to the browser in clear text.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/model",summary:"GET lists all models; POST creates a model (409 on duplicate name, 201 on success).",paramsLabel:"Body",params:[{name:"model",type:"Model",required:!0,description:"Model config (POST). Secrets are stored encrypted."}],notes:["Stored API keys are masked before reaching the frontend — never expect a clear-text key in a response."]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/model/{id}",summary:"GET / PUT / DELETE a single model. The path id is authoritative on PUT. DELETE returns 204."},{method:"POST",path:"/api/model/provider",summary:"Fetch available models from a provider, using a supplied or stored API key (resolved server-side).",paramsLabel:"Body",params:[{name:"baseUrl",type:"string",required:!0,description:"Provider base URL."},{name:"modelId",type:"string",description:"Existing model whose stored key to reuse."},{name:"searchTerm",type:"string",description:"Filter the returned model list."}],notes:["Accepts an apiKey only inbound to query the provider; keys are never echoed back to the client."]}]},{id:"flow",name:"Flows",description:"CRUD for flow definitions, programmatic flow authoring (FlowSpec), LLM flow generation, and prompt rendering for individual nodes. For creating flows programmatically, prefer POST /api/flow/compile with a FlowSpec — the raw Flow format (ReactFlow JSON) is the internal canvas representation and easy to get subtly wrong.",endpoints:[{method:"POST",path:"/api/flow/compile",summary:"Compile a FlowSpec (the semantic authoring format — see below) into a complete flow, validate it, and optionally save it. Deterministic, no LLM: layout, ids, handles, and MCP wiring are generated for you. THE recommended way for external apps and agents to create flows. Also exposed as MCP tools (create_flow / validate_flow_spec) on /mcp-flows.",paramsLabel:"Body",params:[{name:"spec",type:"FlowSpec",required:!0,description:"The flow specification (format below)."},{name:"save",type:"boolean",description:"Persist the flow — only happens when validation finds ZERO errors."}],response:"{ flow, validation: { issues, errorCount, warningCount, isRunnable }, saved } — 201 when saved, 200 otherwise. Iterate on the issues until clean.",details:'A FlowSpec is a JSON object describing a FLUJO flow semantically — node keys and edges, no coordinates, no ids, no layout:\n{\n "name": "short_flow_name", // letters/digits/_/- only\n "description": "what the flow does",\n "nodes": [ ... ],\n "edges": [ ... ]\n}\n\nNODE TYPES:\n- { "key": "unique_key", "type": "start", "label": "...", "prompt": "system-level instructions for the whole flow" }\n- { "key": "...", "type": "process", "label": "...", "description": "what this step does",\n "model": "<model id or name from the catalog>",\n "prompt": "instructions for this step",\n "servers": [ { "name": "<server name>", "tools": ["tool_a"] } ], // optional; omit "tools" to enable all\n "inputMode": "full-history" | "latest-message" | "isolated", // optional, default full-history\n "isolatedPrompt": "...", // only with inputMode "isolated"\n "outputMode": "full-conversation" | "latest-message" } // optional, default full-conversation; latest-message hides this step\'s tool calls/results from later steps (they see only its final response)\n- { "key": "...", "type": "subflow", "label": "...", "flow": "<existing flow name or id>",\n "inputMode": "full-history" | "latest-message" | "isolated",\n "outputMode": "steps" | "final-only" }\n- { "key": "...", "type": "finish", "label": "..." }\n\nEDGES: { "from": "<node key>", "to": "<node key>", "bidirectional": true|false }\n\nRULES:\n1. Exactly ONE start node; at least one finish node reachable from it.\n2. Every process node MUST reference a configured model (by id, display name, or name).\n3. A process step uses MCP tools ONLY via its "servers" list — never emit nodes of type "mcp".\n4. Do not embed ${tool:...} or ${resource:...} references in prompts — tools are wired through "servers".\n5. Branching: give a process node multiple outgoing edges; its model decides where to hand off at runtime. "bidirectional": true lets the target hand back to the source (agent <-> agent).\n6. A subflow node may have only ONE outgoing edge, and its "flow" must name an existing flow.\n7. Keep flows minimal — only the steps the task needs. Write clear, specific prompts and labels; fill "description" on process nodes.'},{method:"POST",path:"/api/flow/generate",summary:"Generate a draft flow from a natural-language description using one of your configured models. The model authors a FlowSpec, FLUJO compiles + validates it and feeds problems back for a bounded number of repair rounds. The generator can always SEARCH the public MCP registry; with allowInstall it can also INSTALL servers it needs. Returns an UNSAVED draft (the UI opens it in the builder for review); persist via the normal save path or /api/flow/compile.",paramsLabel:"Body",params:[{name:"description",type:"string",required:!0,description:"What the flow should do, in plain language."},{name:"modelId",type:"string",required:!0,description:"Configured model that does the generating."},{name:"maxRepairs",type:"number",description:"Repair rounds after the first attempt (default 1, max 2)."},{name:"allowInstall",type:"boolean",description:"Let the generator install MCP servers from the public registry (downloads + RUNS third-party packages on this machine). Off by default."}],response:"{ flow, validation, attempts, installedServers } — the flow is a draft; nothing flow-related is persisted by this endpoint (installed servers ARE persisted).",notes:["allowInstall executes third-party code with this machine's user permissions — opt in deliberately."]},{method:"GET",alsoMethods:["POST"],path:"/api/flow",summary:"GET lists all flow definitions; POST creates a flow (create-only; 409 if the id exists). POST takes the raw internal Flow format — prefer /api/flow/compile for programmatic creation.",paramsLabel:"Body",params:[{name:"flow",type:"Flow",required:!0,description:"Flow object including id (POST)."}]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/flow/{id}",summary:"GET / PUT / DELETE a single flow. On PUT the path id wins over the body id (404 if missing)."},{method:"POST",path:"/api/flow/prompt-renderer",summary:"Render the assembled prompt for a node within a flow.",paramsLabel:"Body",params:[{name:"flowId",type:"string",required:!0,description:"Flow containing the node."},{name:"nodeId",type:"string",required:!0,description:"Node to render."},{name:"options",type:"object",description:"Render options."}]}]},{id:"planned-executions",name:"Planned Executions",description:"Run flows headlessly on triggers: schedules (cron), inbound webhooks, and more. Managed from the Executions page; each run is recorded in a per-execution run history.",endpoints:[{method:"GET",alsoMethods:["POST","PATCH"],path:"/api/planned-executions",summary:"GET lists all planned executions with live trigger status and last run; POST creates one; PATCH toggles the global pause switch ({ paused: boolean }).",response:"GET: { paused, executions: [{ execution, status, lastRun }] }."},{method:"GET",alsoMethods:["PATCH","DELETE"],path:"/api/planned-executions/{id}",summary:"GET / PATCH / DELETE a single planned execution. PATCH takes a partial config and re-arms the trigger."},{method:"POST",path:"/api/planned-executions/{id}/run",summary:"Run now: fire the execution immediately (even while disabled or paused) and wait for the run.",response:"{ record: RunRecord } with status, output preview, and token usage."},{method:"GET",path:"/api/planned-executions/{id}/runs",summary:"The execution’s run history (newest 100 runs, oldest first)."},{method:"POST",path:"/api/planned-executions/preview-schedule",summary:"Validate a cron pattern and preview its next fire times (editor helper).",paramsLabel:"Body",params:[{name:"cron",type:"string",required:!0,description:"Cron pattern (5 or 6 fields)."},{name:"timezone",type:"string",description:"IANA timezone name."}],response:"{ valid, error?, nextRuns: string[] }."},{method:"POST",path:"/api/webhooks/{id}",summary:"Inbound webhook trigger. Fires the planned execution with the request body as trigger context and responds 202 { runId } immediately (the flow runs in the background). For a synchronous answer use /v1/chat/completions instead.",paramsLabel:"Query",params:[{name:"token",type:"string",required:!0,description:"Per-execution secret (alternatively send the X-Flujo-Token header)."}],notes:["Localhost-only by default; external callers must be explicitly allowed per execution.","The webhook body is untrusted input to the flow — prompts should treat it as data."]}]},{id:"mcp",name:"MCP Servers",description:"Manage MCP server configurations, connection state, tool discovery, and tool invocation.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/mcp/servers",summary:"GET lists all MCP server configs; POST registers a new one (409 on duplicate name).",paramsLabel:"Body",params:[{name:"config",type:"MCPServerConfig",required:!0,description:"Server config (POST)."}]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/mcp/servers/{name}",summary:"GET / PUT / DELETE a server config. PUT merges fields; toggling disabled connects/disconnects; a new name triggers a validated rename."},{method:"GET",path:"/api/mcp/servers/{name}/status",summary:"Live connection status. Always 200, even when the server is down.",response:"{ status, ... }"},{method:"GET",path:"/api/mcp/servers/{name}/tools",summary:"List tools exposed by a connected server.",response:"{ tools, error? } (empty tools + error when disconnected)."},{method:"POST",path:"/api/mcp/servers/{name}/tools/{toolName}",summary:"Invoke a tool on a server. Status may reflect the tool itself (408 on timeout).",paramsLabel:"Body",params:[{name:"args",type:"Record<string, unknown>",required:!0,description:"Tool arguments."},{name:"timeout",type:"number",description:"Optional timeout (ms)."}]},{method:"POST",path:"/api/mcp/test-connection",summary:"Run a real MCP handshake against an unsaved config (tests custom CAs and headers) without registering it.",paramsLabel:"Body",params:[{name:"config",type:"MCPServerConfig",required:!0,description:"Config to test."}]},{method:"POST",path:"/api/mcp/cancel",summary:"Cancel an in-progress tool execution; force-reconnects if no token is supplied.",paramsLabel:"Body",params:[{name:"reason",type:"string",required:!0,description:"Cancellation reason."}]}]},{id:"mcp-proxy",name:"FLUJO as an MCP server (proxy)",description:'Re-expose a configured MCP server to EXTERNAL MCP clients (Claude Desktop, Cursor, Cline, mcp-inspector, …) so you configure the server once in FLUJO and reach it everywhere. Enable per server via the "Expose to external apps" toggle on its card. In your MCP client, add a Streamable-HTTP server with the URL below. One downstream server per endpoint, so tool names are unchanged. Localhost-only for now (no auth token in this version — see the security roadmap).',endpoints:[{method:"POST",alsoMethods:["GET","DELETE"],path:"/mcp-proxy/{server}",summary:'A Streamable-HTTP MCP endpoint that forwards tools/list and tools/call to the named downstream MCP server. {server} is the configured server name; it must have "Expose to external apps" enabled (otherwise 404). Rejects non-localhost requests.',response:"MCP JSON-RPC over Streamable HTTP (handled by your MCP client, not called directly)."}]},{id:"mcp-flows",name:"FLUJO as an MCP server (flows + authoring)",description:"A Streamable-HTTP MCP endpoint that exposes FLUJO itself to external MCP clients. Every saved flow is a callable tool (running it ephemerally and returning its output), and three authoring tools let an external agent CREATE flows by sending a semantic FlowSpec — no raw ReactFlow JSON required. Localhost-only (same posture as the proxy).",endpoints:[{method:"POST",alsoMethods:["GET","DELETE"],path:"/mcp-flows",summary:'MCP server with two tool families. Flow tools: one per saved flow (name = slug of the flow name; input = a single "input" string sent as the user turn; runs are ephemeral and never appear in the chat sidebar). Authoring tools: list_flow_building_blocks (models, MCP servers + tools, and existing flows a spec may reference — call first), validate_flow_spec (compile + validate without saving; iterate on the returned issues), create_flow (compile + validate + save; only saves when validation finds zero errors), plus capability acquisition: search_mcp_marketplace (search the public registry) and install_mcp_server (install + connect a registry server — downloads and RUNS third-party packages on the FLUJO host; required keys can be passed via its env argument). The FlowSpec format is documented on POST /api/flow/compile above and inside the tools\' own descriptions.',response:"MCP JSON-RPC over Streamable HTTP (handled by your MCP client, not called directly)."}]},{id:"oauth",name:"OAuth (for MCP)",description:"OAuth authorization flow for MCP servers that require it. Tokens are stored server-side and never sent to the browser.",endpoints:[{method:"POST",path:"/api/oauth/initiate",summary:"Begin the OAuth flow for a server; dynamically registers a client and returns an authorization URL.",paramsLabel:"Body",params:[{name:"serverName",type:"string",required:!0,description:"MCP server to authorize."}]},{method:"GET",alsoMethods:["POST"],path:"/api/oauth/callback",summary:"OAuth redirect target; exchanges the code for tokens, updates the config, and redirects to /mcp.",notes:["Tokens are persisted server-side only."]},{method:"POST",path:"/api/oauth/reset",summary:"Clear a server's OAuth tokens and force re-authentication on the next connection.",paramsLabel:"Body",params:[{name:"serverName",type:"string",required:!0,description:"Server to reset."}]}]},{id:"env",name:"Environment & Secrets",description:"Global environment variables and server-side encryption operations. Secret values are encrypted at rest and masked as ******** in responses.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/env",summary:"GET reads env vars (secrets masked); POST sets/deletes vars (secrets encrypted server-side).",paramsLabel:"Body",params:[{name:"action",type:'"set" | "setAll" | "delete"',required:!0,description:"Operation."},{name:"key",type:"string",description:"Variable name (set/delete)."},{name:"value",type:"string",description:"Value; the placeholder ******** is ignored."},{name:"metadata",type:"{ isSecret: boolean }",description:"Marks a value for encryption."}],notes:["GET masks secret values unless an internal includeSecrets flag is set; the browser never receives clear-text secrets."]},{method:"POST",path:"/api/encryption/secure",summary:"Server-side encryption operations: initialize, authenticate, change_password, encrypt, verify_password, check_initialized, and status queries.",paramsLabel:"Body",params:[{name:"action",type:"string",required:!0,description:"One of the encryption actions."}],notes:["Passwords and tokens are handled here and stay server-side — never log or surface them in the UI."]}]},{id:"storage",name:"Storage & Backup",description:"Generic key-value storage plus zip backup/restore of selected data.",endpoints:[{method:"GET",alsoMethods:["POST","DELETE"],path:"/api/storage",summary:"GET loads an item by StorageKey (with optional default); POST saves; DELETE clears.",paramsLabel:"Query",params:[{name:"key",type:"StorageKey",required:!0,description:"Storage key."},{name:"defaultValue",type:"JSON",description:"Returned when the key is missing (GET)."}]},{method:"POST",path:"/api/backup",summary:"Create a zip backup of selected items and download it.",paramsLabel:"Body",params:[{name:"selections",type:"string[]",required:!0,description:"e.g. models, mcpServers, flows, chatHistory, settings."}],notes:["A backup may include the encryption key and secrets — handle the downloaded file carefully."]},{method:"POST",path:"/api/restore",summary:"Restore data from a backup zip.",paramsLabel:"Form data",params:[{name:"file",type:"File (zip)",required:!0,description:"Backup archive."},{name:"selections",type:"JSON string[]",required:!0,description:"Which items to restore."}]}]},{id:"system",name:"System & Updates",description:"App initialization, working-directory info, repository operations, and self-update.",endpoints:[{method:"GET",path:"/api/init",summary:"Server-side initialization: verify storage and start enabled MCP servers."},{method:"GET",path:"/api/cwd",summary:"Return the current working directory and the mcp-servers directory path."},{method:"GET",path:"/api/browse",summary:"List a directory of the machine running FLUJO, for the folder-picker dialogs (file-watch triggers, MCP server paths). Defaults to the home directory; includes available drives on Windows.",paramsLabel:"Query",params:[{name:"path",type:"string",description:"Absolute directory path to list."}],response:"{ path, parent, home, sep, drives, entries: [{ name, path, isDirectory }] }",notes:["Exposes backend filesystem listings — like the rest of the API it assumes a single trusted user."]},{method:"POST",path:"/api/git",summary:"Repository operations for MCP servers: clone, install, build, run, exists, readFile, listDir, list, checkUpdates, checkUpdatesBatch, pullUpdates.",paramsLabel:"Body",params:[{name:"action",type:"string",required:!0,description:"Operation to perform."}]},{method:"GET",alsoMethods:["POST"],path:"/api/update",summary:'GET checks for a newer version (git fetch + behind count); POST { action: "apply" } pulls, rebuilds, and restarts.',response:"{ success, isGitRepo, updateAvailable, behindBy?, branch?, currentVersion }"}]}],f={GET:"#2e7d32",POST:"#1565c0",PUT:"#ed6c02",PATCH:"#9c27b0",DELETE:"#c62828",OPTIONS:"#616161"};function g(e){let{method:t}=e;return(0,o.jsx)(r.A,{label:t,size:"small",sx:{bgcolor:f[t],color:"#fff",fontWeight:700,fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.7rem",height:22}})}function v(e){var t,a,n,r;let{endpoint:l}=e;return(0,o.jsxs)(i.A,{variant:"outlined",sx:{p:2,mb:1.5},children:[(0,o.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap",mb:1},children:[(0,o.jsx)(g,{method:l.method}),null==(t=l.alsoMethods)?void 0:t.map(e=>(0,o.jsx)(g,{method:e},e)),(0,o.jsx)(d.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.9rem",wordBreak:"break-all"},children:l.path})]}),(0,o.jsx)(d.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5*(null!=(a=l.params)&&!!a.length)},children:l.summary}),l.params&&l.params.length>0&&(0,o.jsxs)(s.default,{sx:{mb:1},children:[(0,o.jsx)(d.default,{variant:"caption",sx:{fontWeight:700,textTransform:"uppercase",color:"text.secondary"},children:null!=(r=l.paramsLabel)?r:"Parameters"}),(0,o.jsx)(s.default,{component:"ul",sx:{m:0,mt:.5,pl:2.5},children:l.params.map(e=>(0,o.jsx)(s.default,{component:"li",sx:{mb:.25},children:(0,o.jsxs)(d.default,{variant:"body2",component:"span",children:[(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontWeight:600},children:e.name}),(0,o.jsxs)(s.default,{component:"span",sx:{color:"text.secondary"},children:[" ",e.type,e.required?" \xb7 required":""," — ",e.description]})]})},e.name))})]}),l.response&&(0,o.jsxs)(d.default,{variant:"body2",sx:{mt:.5},children:[(0,o.jsxs)(s.default,{component:"span",sx:{fontWeight:600},children:["Response:"," "]}),(0,o.jsx)(s.default,{component:"span",sx:{color:"text.secondary"},children:l.response})]}),null==(n=l.notes)?void 0:n.map((e,t)=>(0,o.jsxs)(d.default,{variant:"caption",sx:{display:"block",mt:1,color:"warning.main"},children:["⚠ ",e]},t)),l.details&&(0,o.jsx)(s.default,{component:"pre",sx:{mt:1.5,p:1.5,bgcolor:"action.hover",borderRadius:1,fontSize:"0.75rem",fontFamily:"monospace",whiteSpace:"pre-wrap",overflowX:"auto",m:0,mb:0},children:l.details})]})}function b(){let[e,t]=(0,n.useState)(""),[a,r]=(0,n.useState)("");n.useEffect(()=>{r(window.location.origin)},[]);let f=(0,n.useMemo)(()=>{let t=e.trim().toLowerCase();return t?y.map(e=>{let a=e.endpoints.filter(a=>{var o;return"".concat(a.method," ").concat((null!=(o=a.alsoMethods)?o:[]).join(" ")," ").concat(a.path," ").concat(a.summary).toLowerCase().includes(t)||e.name.toLowerCase().includes(t)});return{...e,endpoints:a}}).filter(e=>e.endpoints.length>0):y},[e]);return(0,o.jsxs)(l.A,{maxWidth:"md",sx:{py:5},children:[(0,o.jsx)(d.default,{variant:"h4",gutterBottom:!0,children:"API Documentation"}),(0,o.jsx)(d.default,{variant:"body1",color:"text.secondary",sx:{mb:2},children:"FLUJO exposes an OpenAI-compatible chat API and a REST surface for managing models, MCP servers, flows, and conversations. All endpoints are served from this instance."}),(0,o.jsxs)(i.A,{variant:"outlined",sx:{p:2,mb:3},children:[(0,o.jsx)(d.default,{variant:"subtitle2",gutterBottom:!0,children:"Base URL"}),(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.9rem"},children:a||"http://localhost:4200"}),(0,o.jsxs)(d.default,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["Point any OpenAI SDK at"," ",(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace"},children:(a||"http://localhost:4200")+"/v1"})," ","and set the model to"," ",(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace"},children:"flow-<NAME>"}),". Any API key value is accepted locally."]})]}),(0,o.jsx)(p.A,{fullWidth:!0,size:"small",placeholder:"Search endpoints (path, method, description)…",value:e,onChange:e=>t(e.target.value),sx:{mb:3},InputProps:{startAdornment:(0,o.jsx)(c.A,{position:"start",children:(0,o.jsx)(h.A,{fontSize:"small"})})}}),0===f.length&&(0,o.jsxs)(d.default,{color:"text.secondary",children:["No endpoints match “",e,"”."]}),f.map(e=>(0,o.jsxs)(s.default,{sx:{mb:4},id:e.id,children:[(0,o.jsx)(d.default,{variant:"h6",gutterBottom:!0,children:e.name}),(0,o.jsx)(d.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:e.description}),e.endpoints.map(e=>(0,o.jsx)(v,{endpoint:e},"".concat(e.method," ").concat(e.path)))]},e.id)),(0,o.jsx)(m.A,{sx:{my:3}}),(0,o.jsxs)(d.default,{variant:"caption",color:"text.secondary",children:["Secrets (API keys, encryption passwords, OAuth tokens) are encrypted at rest and never returned to the browser in clear text. See the project"," ",(0,o.jsx)(u.A,{href:"https://github.com/mario-andreschak/FLUJO",target:"_blank",rel:"noopener",children:"repository"})," ","for source-level details."]})]})}let w=(0,a(87021).h)("app/docs/page");function x(){return w.debug("Rendering DocsPage"),(0,o.jsx)(s.default,{component:"main",sx:{minHeight:"100vh"},children:(0,o.jsx)(b,{})})}},87021:(e,t,a)=>{"use strict";a.d(t,{h:()=>d});let o={LOG_LEVEL:3},s={VERBOSE:-1,DEBUG:0,INFO:1,WARN:2,ERROR:3},n="number"==typeof o.LOG_LEVEL?o.LOG_LEVEL:s.ERROR;function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t>6)return String(e);if(!(e instanceof Error))return e;let a={name:e.name,message:e.message};for(let o of Object.getOwnPropertyNames(e)){if("name"===o||"message"===o)continue;let s=e[o];"function"!=typeof s&&("stack"===o?a.stack=s:"cause"===o?a.cause=r(s,t+1):"errors"===o&&Array.isArray(s)?a.errors=s.map(e=>r(e,t+1)):a[o]=s)}return a}function i(e,t,a,o,i){if(e>=("number"==typeof i?i:n)){if("function"==typeof o)try{o=o()}catch(e){o="[lazy log data threw]"}let n=new Date().toISOString(),i="[".concat(n,"] [").concat(t,"]"),d="".concat(i," ").concat(a);if(void 0!==o)if(o instanceof Error||"object"==typeof o)try{let e=o instanceof Error?r(o):o,t=JSON.stringify(e,(e,t)=>t instanceof Error?r(t):t,2);d+=":\n".concat(t)}catch(e){d+=": [Object cannot be stringified]"}else d+=": ".concat(o);switch(e){case s.VERBOSE:console.debug("[VERBOSE] ".concat(d));break;case s.DEBUG:console.debug(d);break;case s.INFO:console.info(d);break;case s.WARN:console.warn(d);break;case s.ERROR:console.error(d);break;default:console.log(d)}}}function d(e,t){let a,o=((a=e.replace(/^src\//,"")).startsWith("/")&&(a=a.substring(1)),a);return{verbose:(e,a)=>{i(s.VERBOSE,o,e,a,t)},debug:(e,a)=>{i(s.DEBUG,o,e,a,t)},info:(e,a)=>{i(s.INFO,o,e,a,t)},warn:(e,a)=>{i(s.WARN,o,e,a,t)},error:(e,a)=>{i(s.ERROR,o,e,a,t)}}}}},e=>{e.O(0,[2678,4754,9244,8548,9562,488,8989,8441,1255,7358],()=>e(e.s=32651)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3080],{18244:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>nf});var o=n(95155),r=n(12115),l=n(33567),a=n(94049),s=n(25635),i=n(70690),d=n(5421),c=n(41983),u=n(78470),p=n(50430),h=n(22003),f=n(2778),m=n(52363),x=n(65036),g=n(50001),v=n(9562),b=n(75912),y=n(14287),j=n(86946),w=n(72167),C=n(48116),A=n(2300),S=n(21067),k=n(87021),N=n(22539),T=n(74879),I=n(90057),M=n(17897),P=n(76122);P.TG.ArrowClosed;let F={type:"mcpEdge",animated:!1,style:{stroke:"#1976d2",strokeWidth:2},markerEnd:{type:P.TG.ArrowClosed,width:20,height:20,color:"#1976d2"},markerStart:{type:P.TG.ArrowClosed,width:20,height:20,color:"#1976d2"}};function E(e){return!!e&&e.includes("mcp")}function D(e,t,n,o){if("start"===n)return"Start nodes cannot have incoming connections";if("finish"===e)return"Finish nodes cannot have outgoing connections";if("mcp"===e||"mcp"===n||E(t)||E(o)){if(("mcp"!==e||"process"!==n)&&("process"!==e||"mcp"!==n))return"MCP connections must link an MCP node to a Process node via MCP handles";if("process"===e&&!E(t))return"Connect MCP nodes from the Process node's left/right MCP handles"}return null}function z(e){return"".concat(e,"-top")}function R(e,t,n){return t.filter(t=>{var o,r;return(null==(r=t.data)?void 0:r.edgeType)!=="mcp"&&(t.source===e?t.target!==n:t.target===e&&null!=(o=t.data)&&!!o.bidirectional&&t.source!==n)})}function W(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return console.error("Invalid connection: Missing source, target, or handles",e),!1;let o=t.find(t=>t.id===e.source),r=t.find(t=>t.id===e.target);if(!o||!r)return console.error("Invalid connection: Source or target node not found",e),!1;let l=D(o.type,e.sourceHandle,r.type,e.targetHandle);return l?(console.error("Invalid connection: ".concat(l)),!1):"subflow"!==o.type||!(R(o.id,n,e.target).length>0)||(console.error("Invalid connection: Subflow nodes can only have one outgoing connection"),!1)}function L(e,t){let n=t.find(t=>t.id===e.source),o=t.find(t=>t.id===e.target),r=e.sourceHandle,l=e.targetHandle,a=(null==n?void 0:n.type)==="mcp"||(null==o?void 0:o.type)==="mcp"||E(r)||E(l),s="".concat(e.source,":").concat(r,"->").concat(e.target,":").concat(l);return a?{id:s,...e,type:"mcpEdge",data:{edgeType:"mcp"},animated:!1,markerEnd:F.markerEnd,markerStart:F.markerStart,style:F.style}:{id:s,...e,type:"custom",data:{edgeType:"standard"},animated:!0}}function B(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=t.find(t=>t.id===e.source),r=t.find(t=>t.id===e.target);return!!o&&!!r&&("subflow"!==r.type||!(R(r.id,n,e.source).length>0))&&null===D(r.type,null,o.type,null)}function O(e,t){let n=e=>{var t;return(null==(t=e.data)?void 0:t.edgeType)==="mcp"};return t.filter(t=>t.id===e.id||(n(e)?n(t)&&(t.source===e.source&&t.target===e.target||t.source===e.target&&t.target===e.source):!n(t)&&t.source===e.source&&t.target===e.target)).map(e=>e.id)}var H=n(56682),_=n(33420),G=n(86973),U=n(49501),J=n(17681),Y=n(36314),$=n(4484),V=n(52277),X=n(78095),Z=n(14915);let q=e=>{let{open:t,position:n,onClose:r,onDelete:l,onEditProperties:a,onCopy:s,onPaste:i,canPaste:d,canCopy:c,nodeId:u,selection:p,edgeId:h}=e,f=[];return u&&!p&&f.push((0,o.jsxs)(G.A,{onClick:()=>{a&&a(),r()},children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(Z.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{children:"Edit Properties"})]},"edit")),s&&(u||p)&&f.push((0,o.jsxs)(G.A,{onClick:()=>{s&&s(),r()},disabled:!c,children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(V.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{children:"Copy"})]},"copy")),i&&f.push((0,o.jsxs)(G.A,{onClick:()=>{i&&i(),r()},disabled:!d,children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(X.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{children:"Paste"})]},"paste")),(u||h||p)&&f.push((0,o.jsx)(S.A,{},"delete-divider"),(0,o.jsxs)(G.A,{onClick:()=>{l(),r()},sx:{color:"error.main"},children:[(0,o.jsx)(U.A,{sx:{color:"error.main"},children:(0,o.jsx)($.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{children:"Delete"})]},"delete")),(0,o.jsx)(Y.A,{open:t,onClose:r,anchorReference:"anchorPosition",anchorPosition:null!==n.y&&null!==n.x?{top:n.y,left:n.x}:void 0,children:f})};var K=n(80685),Q=n(71738);function ee(e,t){return t.find(t=>t.id===e)}let et=(0,k.h)("components/flow/FlowBuilder/Canvas/hooks/useCanvasEvents.ts");var en=n(39047),eo=n(81464),er=n(12142);let el=(0,C.Ay)(i.A)(e=>{let{theme:t}=e;return{minWidth:"36px",padding:"6px",margin:"0 4px",backgroundColor:"dark"===t.palette.mode?"rgba(255, 255, 255, 0.05)":"rgba(0, 0, 0, 0.02)","&:hover":{backgroundColor:"dark"===t.palette.mode?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"}}}),ea=()=>{let{zoomIn:e,zoomOut:t,fitView:n}=(0,N.VH)();return(0,o.jsx)(N.Zk,{position:"top-right",style:{margin:"10px"},children:(0,o.jsxs)("div",{style:{display:"flex",gap:"5px"},children:[(0,o.jsx)(u.A,{title:"Zoom In",children:(0,o.jsx)(el,{variant:"outlined",size:"small",onClick:()=>e(),children:(0,o.jsx)(en.A,{fontSize:"small"})})}),(0,o.jsx)(u.A,{title:"Zoom Out",children:(0,o.jsx)(el,{variant:"outlined",size:"small",onClick:()=>t(),children:(0,o.jsx)(eo.A,{fontSize:"small"})})}),(0,o.jsx)(u.A,{title:"Fit View",children:(0,o.jsx)(el,{variant:"outlined",size:"small",onClick:()=>n(),children:(0,o.jsx)(er.A,{fontSize:"small"})})})]})})},es=e=>{let{showMiniMap:t=!0,showControls:n=!0,showBackground:r=!0}=e,a=(0,l.A)(),s="dark"===a.palette.mode;return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(N.VS,{color:s?a.palette.text.disabled:a.palette.divider,gap:20,size:1}),n&&(0,o.jsx)(N.H2,{}),t&&(0,o.jsx)(N.of,{nodeColor:s?a.palette.primary.dark:a.palette.primary.light,maskColor:s?"rgba(0, 0, 0, 0.4)":"rgba(255, 255, 255, 0.6)"})]})},ei=(0,k.h)("components/flow/FlowBuilder/Canvas/Canvas.tsx"),ed="flujo:flowClipboard",ec=null;function eu(e){ec=e;try{localStorage.setItem(ed,JSON.stringify(e))}catch(e){ei.warn("Could not persist flow clipboard to localStorage",e)}}let ep={start:_.vm,process:_.Uw,finish:_.IK,mcp:_.v2,subflow:_.lA},eh={custom:K.jY,mcpEdge:K.oY},ef=e=>{let{open:t,position:n,onClose:r,onSelectNodeType:i,sourceNodeType:d,sourceHandleId:c}=e,u=(0,l.A)(),p=function(e,t){let n=["process","finish","mcp","subflow"];return e&&t?n.filter(n=>null===D(e,t,n,z(n))):n}(d,c);ei.debug("NodeSelectionModal: Source node type: ".concat(d,", Source handle ID: ").concat(c)),ei.debug("NodeSelectionModal: Valid node types: ".concat(p.join(", ")));let h=[{type:"process",label:"Process Node",description:"Let a LLM do your work"},{type:"finish",label:"Finish Node",description:"End your flow here"},{type:"mcp",label:"MCP Node",description:"Add functionality"},{type:"subflow",label:"Subflow Node",description:"Run another flow"}].filter(e=>p.includes(e.type));return n?(0,o.jsx)(H.A,{open:t,onClose:r,"aria-labelledby":"node-selection-modal",children:(0,o.jsxs)(a.default,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:300,bgcolor:"background.paper",borderRadius:2,boxShadow:24,p:4},children:[(0,o.jsx)(s.default,{variant:"h6",component:"h2",gutterBottom:!0,children:"Select Node Type"}),(0,o.jsx)(a.default,{display:"flex",flexDirection:"column",gap:2,children:h.map(e=>(0,o.jsxs)(a.default,{sx:{padding:2,borderRadius:1,border:"2px solid ".concat("process"===e.type?u.palette.secondary.main:"finish"===e.type?u.palette.success.main:"subflow"===e.type?u.palette.warning.main:u.palette.info.main),cursor:"pointer","&:hover":{boxShadow:3}},onClick:()=>i(e.type,n),children:[(0,o.jsxs)(a.default,{display:"flex",alignItems:"center",gap:1,mb:1,children:[(e=>{switch(e){case"process":default:return(0,o.jsx)("div",{style:{width:24,height:24,backgroundColor:u.palette.secondary.main,borderRadius:"50%"}});case"finish":return(0,o.jsx)("div",{style:{width:24,height:24,backgroundColor:u.palette.success.main,borderRadius:"50%"}});case"mcp":return(0,o.jsx)("div",{style:{width:24,height:24,backgroundColor:u.palette.info.main,borderRadius:"50%"}});case"subflow":return(0,o.jsx)("div",{style:{width:24,height:24,backgroundColor:u.palette.warning.main,borderRadius:"50%"}})}})(e.type),(0,o.jsx)(s.default,{variant:"subtitle1",fontWeight:"bold",children:e.label})]}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",children:e.description})]},e.type))})]})}):null},em=(0,C.Ay)("div")(e=>{let{theme:t}=e;return{width:"100%",height:"80vh",border:"1px solid ".concat(t.palette.divider),borderRadius:"4px",background:t.palette.background.paper,position:"relative"}}),ex=(0,r.forwardRef)((e,t)=>{let n=(0,l.A)(),{nodes:a,edges:s,onNodesChange:i,onEdgesChange:d,onDrop:c,onDragOver:u,onInit:p,reactFlowWrapper:h,onEditNode:f}=e,{contextMenu:m,selectedElements:x,closeContextMenu:g,handleDelete:v,onNodeContextMenu:b,onEdgeContextMenu:y,onPaneContextMenu:j,onSelectionContextMenu:w}=function(e){let{deleteElements:t}=(0,N.VH)(),[n,o]=(0,r.useState)({open:!1,position:{x:0,y:0}}),[l,a]=(0,r.useState)({nodes:[],edges:[]});(0,N.p4)({onChange:e=>{let{nodes:t,edges:n}=e,o=t.map(e=>e.id),r=n.map(e=>e.id);et.debug("Selection changed: ".concat(o.length," nodes, ").concat(r.length," edges selected")),a({nodes:o,edges:r})}});let s=(0,r.useCallback)((e,t,n,r)=>{e.preventDefault(),t?et.debug("Context menu opened for node: ".concat(t)):n?et.debug("Context menu opened for edge: ".concat(n)):r?et.debug("Context menu opened for the current selection"):et.debug("Context menu opened on canvas at (".concat(e.clientX,", ").concat(e.clientY,")")),o({open:!0,position:{x:e.clientX,y:e.clientY},nodeId:t,edgeId:n,selection:r})},[]),i=(0,r.useCallback)(()=>{et.debug("Context menu closed"),o(e=>({...e,open:!1}))},[]),d=(0,r.useCallback)(()=>{if(n.selection)et.debug("handleDelete: Deleting the current selection"),t({nodes:l.nodes.map(e=>({id:e})),edges:l.edges.map(e=>({id:e}))});else if(n.nodeId){if(et.debug("handleDelete: Attempting to delete node ".concat(n.nodeId)),!function(e,t){let n=ee(e,t);return!!n&&"start"!==n.type}(n.nodeId,e)){et.warn("Cannot delete Start node: ".concat(n.nodeId)),alert("Start nodes cannot be deleted");return}t({nodes:[{id:n.nodeId}]})}else n.edgeId&&(et.debug("handleDelete: Deleting edge ".concat(n.edgeId)),t({edges:[{id:n.edgeId}]}))},[n,t,e,l]),c=(0,r.useCallback)((e,t)=>{s(e,t.id)},[s]),u=(0,r.useCallback)((e,t)=>{s(e,void 0,t.id)},[s]),p=(0,r.useCallback)(e=>{s(e)},[s]),h=(0,r.useCallback)(e=>{s(e,void 0,void 0,!0)},[s]);return{contextMenu:n,selectedElements:l,onContextMenu:s,closeContextMenu:i,handleDelete:d,onNodeContextMenu:c,onEdgeContextMenu:u,onPaneContextMenu:p,onSelectionContextMenu:h}}(a),{deleteElements:C}=(0,N.VH)(),A=(0,N.PI)(),S=(0,r.useRef)(null),[k,M]=(0,r.useState)(null),[F,D]=(0,r.useState)({open:!1,position:null}),R=(0,r.useCallback)(e=>[...a.filter(e=>e.selected).map(e=>({type:"select",id:e.id,selected:!1})),{type:"add",item:{...e,selected:!0}}],[a]);(0,r.useEffect)(()=>{if(!f)return;let e=e=>{if(e.detail&&e.detail.nodeId){let t=ee(e.detail.nodeId,a);t&&f(t)}};return document.addEventListener("editNode",e),()=>{document.removeEventListener("editNode",e)}},[a,f]);let H=(0,r.useCallback)(e=>{var t,o;if(!e.sourceHandle||!e.targetHandle)return void ei.error("Invalid connection: Missing source or target handle",e);let r=(null==(t=A.getState().connection.fromHandle)?void 0:t.type)==="target";if(!W(e,a,s))return;let l=L(e,a);if((null==(o=l.data)?void 0:o.edgeType)==="standard"){let t=e=>{var t;return(null==(t=e.data)?void 0:t.edgeType)!=="mcp"},o=e=>{var t;return!!(null==(t=e.data)?void 0:t.bidirectional)},l=s.find(n=>t(n)&&n.source===e.source&&n.target===e.target),i=s.find(n=>t(n)&&n.source===e.target&&n.target===e.source),c=e=>{ei.info("Merging reverse connection into bidirectional edge ".concat(e.id)),d([{type:"replace",id:e.id,item:{...e,data:{...e.data,bidirectional:!0},markerStart:{type:P.TG.ArrowClosed,width:20,height:20,color:n.palette.text.secondary}}}])};if(r){let e=null!=l?l:i;return e?void(!o(e)&&B(e,a,s)&&c(e)):void ei.info("Connection drawn from a top handle is only allowed to convert an existing edge to bidirectional")}if(l&&o(l))return;if(i){!o(i)&&B(i,a,s)&&c(i);return}}d([...O(l,s).map(e=>({type:"remove",id:e})),{type:"add",item:l}])},[a,s,d,A,n.palette.text.secondary]);(0,r.useEffect)(()=>{let e=e=>{var t;let{edgeId:n,waypoints:o}=e.detail,r=s.find(e=>e.id===n);if(!r)return;let{waypoint:l,...a}=null!=(t=r.data)?t:{};d([{type:"replace",id:n,item:{...r,data:{...a,waypoints:null!=o?o:void 0}}}])};return document.addEventListener(Q.R,e),()=>document.removeEventListener(Q.R,e)},[s,d]);let _=(0,r.useCallback)(async e=>{let{nodes:t,edges:n}=e,o=t.filter(e=>"start"!==e.type),r=new Set(o.map(e=>e.id)),l=new Set(t.map(e=>e.id)),a=n.filter(e=>!!(e.selected||r.has(e.source)||r.has(e.target))||!(l.has(e.source)||l.has(e.target)));return(0!==o.length||0!==a.length)&&{nodes:o,edges:a}},[]),G=(0,r.useCallback)(e=>{M(e),p&&p(e)},[p]);(0,r.useEffect)(()=>{let e=e=>{if(!e.detail||!k)return;let{nodeType:t,position:n}=e.detail,o=I.g.createNode(t,n);i(R(o)),f&&f(o)};return document.addEventListener("addNodeFromPalette",e),()=>{document.removeEventListener("addNodeFromPalette",e)}},[k,i,R,f]);let U=(0,r.useCallback)(()=>{if(m.nodeId&&f){let e=ee(m.nodeId,a);e&&f(e)}},[m.nodeId,a,f]),J=(0,r.useCallback)((e,t)=>{e.preventDefault(),f&&f(t)},[f]),Y=(0,r.useCallback)((e,t)=>{let{fromNode:n,fromHandle:o}=t;if(!n||!(null==o?void 0:o.id)||!k)return void ei.debug("onConnectEnd: No valid connection start data");if(ei.debug("onConnectEnd: Connection ended from node ".concat(n.id,", handle ").concat(o.id)),"target"===o.type&&!E(o.id))return void ei.debug("onConnectEnd: Drag from a target handle cannot create a new node");if("subflow"===n.type&&"source"===o.type&&s.some(e=>{let t=e.data;return(null==t?void 0:t.edgeType)!=="mcp"&&(e.source===n.id||e.target===n.id&&!!(null==t?void 0:t.bidirectional))}))return void ei.debug("onConnectEnd: Subflow already has an outgoing connection; not offering a new node");if(!e.target.classList.contains("react-flow__pane"))return;let r=e instanceof MouseEvent?e:e.changedTouches[0],l=k.screenToFlowPosition({x:r.clientX,y:r.clientY});ei.debug("onConnectEnd: Connection dropped on pane at position (".concat(l.x,", ").concat(l.y,")")),D({open:!0,position:l,sourceNodeId:n.id,sourceNodeType:n.type,sourceHandleId:o.id})},[k,s]),$=(0,r.useCallback)((e,t)=>{ei.debug("handleNodeTypeSelection: Selected node type ".concat(e," at position (").concat(t.x,", ").concat(t.y,")"));let n=I.g.createNode(e,t);i(R(n));let{sourceNodeId:o,sourceHandleId:r}=F,l=o?ee(o,a):void 0;if(l&&r){let t=z(e),o={source:l.id,sourceHandle:r,target:n.id,targetHandle:t};if(ei.debug("handleNodeTypeSelection: Creating connection from ".concat(o.source," to ").concat(o.target)),W(o,[...a,n],s)){let e=L(o,[...a,n]);d([...O(e,s).map(e=>({type:"remove",id:e})),{type:"add",item:e}]),ei.debug("handleNodeTypeSelection: Edge created with id ".concat(e.id))}}D({open:!1,position:null}),f&&f(n)},[F,a,s,R,i,d,f]),V=(0,r.useCallback)(()=>{ei.debug("handleCloseNodeSelectionModal: Closing node selection modal"),D({open:!1,position:null})},[]),X=(0,r.useCallback)(()=>{let e=new Set(x.nodes),t=a.filter(t=>e.has(t.id)&&"start"!==t.type);if(0===t.length)return!1;let n=new Set(t.map(e=>e.id)),o=s.filter(e=>n.has(e.source)&&n.has(e.target));return eu({nodes:JSON.parse(JSON.stringify(t)),edges:JSON.parse(JSON.stringify(o))}),ei.debug("Copied ".concat(t.length," node(s) and ").concat(o.length," edge(s)")),!0},[x,a,s]),Z=(0,r.useCallback)(()=>{let e=ec;if(!e)try{let t=localStorage.getItem(ed);t&&(e=JSON.parse(t))}catch(e){ei.warn("Could not read flow clipboard from localStorage",e)}if(!e||!e.nodes||0===e.nodes.length)return void ei.debug("Paste requested but clipboard is empty");let t=new Map;e.nodes.forEach(e=>t.set(e.id,(0,T.A)()));let n=e.nodes.map(e=>{var n,o,r,l;return{...e,id:t.get(e.id),position:{x:(null!=(r=null==(n=e.position)?void 0:n.x)?r:0)+40,y:(null!=(l=null==(o=e.position)?void 0:o.y)?l:0)+40},selected:!0,data:{...e.data}}}),o=(e.edges||[]).filter(e=>t.has(e.source)&&t.has(e.target)).map(e=>({...e,id:(0,T.A)(),source:t.get(e.source),target:t.get(e.target),selected:!1}));i([...a.filter(e=>e.selected).map(e=>({type:"select",id:e.id,selected:!1})),...n.map(e=>({type:"add",item:e}))]),o.length>0&&d(o.map(e=>({type:"add",item:e}))),ei.info("Pasted ".concat(n.length," node(s) and ").concat(o.length," edge(s)"))},[a,i,d]),K=(0,r.useCallback)(e=>{let t=e.ctrlKey||e.metaKey,n=e.key.toLowerCase();if(t&&"c"===n){X()&&e.preventDefault();return}if(t&&"x"===n){X()&&(e.preventDefault(),C({nodes:x.nodes.map(e=>({id:e})),edges:x.edges.map(e=>({id:e}))}));return}if(t&&"v"===n){e.preventDefault(),Z();return}},[X,Z,C,x]),en=(0,r.useCallback)(()=>{if(m.nodeId&&!x.nodes.includes(m.nodeId)){let e=a.find(e=>e.id===m.nodeId);e&&"start"!==e.type&&(eu({nodes:JSON.parse(JSON.stringify([e])),edges:[]}),ei.debug("Copied right-clicked node to clipboard"));return}X()},[m.nodeId,x,a,X]),eo=(0,r.useMemo)(()=>{if(ec)return!0;try{return!!localStorage.getItem(ed)}catch(e){return!1}},[m.open]),er=(0,r.useMemo)(()=>{if(m.selection){let e=new Set(x.nodes);return a.some(t=>e.has(t.id)&&"start"!==t.type)}if(m.nodeId){let e=a.find(e=>e.id===m.nodeId);return!!e&&"start"!==e.type}return!1},[m.selection,m.nodeId,x,a]);return(0,o.jsxs)(em,{ref:e=>{t&&("function"==typeof t?t(e):t.current=e),h&&(h.current=e),S.current=e},children:[(0,o.jsxs)(N.Gc,{nodes:a,edges:s,nodeTypes:ep,edgeTypes:eh,defaultEdgeOptions:(0,r.useMemo)(()=>({type:"custom",animated:!0,style:{stroke:n.palette.text.secondary,strokeWidth:2},markerEnd:{type:P.TG.ArrowClosed,width:20,height:20,color:n.palette.text.secondary}}),[n.palette.text.secondary]),connectionLineType:P.Do.SmoothStep,onNodesChange:i,onEdgesChange:d,onConnect:H,onBeforeDelete:_,deleteKeyCode:["Backspace","Delete"],onDrop:c,onDragOver:u,onInit:G,onNodeContextMenu:b,onEdgeContextMenu:y,onPaneContextMenu:j,onSelectionContextMenu:w,onKeyDown:K,onNodeDoubleClick:J,onConnectEnd:Y,tabIndex:0,fitView:!0,attributionPosition:"bottom-right",minZoom:.1,maxZoom:2,snapToGrid:!0,snapGrid:[15,15],connectOnClick:!1,children:[(0,o.jsx)(ea,{}),(0,o.jsx)(es,{})]}),(0,o.jsx)(q,{open:m.open,position:m.position,onClose:g,onDelete:v,onEditProperties:U,onCopy:en,onPaste:Z,canPaste:eo,canCopy:er,nodeId:m.nodeId,selection:m.selection,edgeId:m.edgeId}),(0,o.jsx)(ef,{open:F.open,position:F.position,onClose:V,onSelectNodeType:$,sourceNodeType:F.sourceNodeType,sourceHandleId:F.sourceHandleId})]})});ex.displayName="Canvas";var eg=n(56350),ev=n(77842),eb=n(55930);let ey=(0,k.h)("components/flow/FlowBuilder/NodePalette.tsx"),ej="NodePalette",ew=(0,C.Ay)(A.A)(e=>{let{theme:t}=e;return{padding:t.spacing(2),width:"200px",height:"80vh",display:"flex",flexDirection:"column",gap:t.spacing(2)}}),eC=(0,C.Ay)(A.A,{shouldForwardProp:e=>"nodeType"!==e})(e=>{let{theme:t,nodeType:n}=e;return{padding:t.spacing(1.5),minWidth:"180px",borderRadius:"8px",backgroundColor:t.palette.background.paper,border:"2px solid ".concat("process"===n?t.palette.secondary.main:"finish"===n?t.palette.success.main:"subflow"===n?t.palette.warning.main:t.palette.info.main),boxShadow:t.shadows[2],transition:"all 0.2s ease",cursor:"grab","&:hover":{boxShadow:"0 0 0 1px ".concat("process"===n?t.palette.secondary.main:"finish"===n?t.palette.success.main:"subflow"===n?t.palette.warning.main:t.palette.info.main,", 0 3px 10px rgba(0,0,0,0.1)")},"&:active":{cursor:"grabbing"}}}),eA=(0,C.Ay)(a.default,{shouldForwardProp:e=>"nodeType"!==e})(e=>{let{theme:t,nodeType:n}=e;return{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid ".concat("process"===n?t.palette.secondary.light:"finish"===n?t.palette.success.light:"subflow"===n?t.palette.warning.light:t.palette.info.light),marginBottom:t.spacing(1),paddingBottom:t.spacing(.5)}}),eS=(0,C.Ay)(a.default)({display:"flex",alignItems:"center",gap:"8px"}),ek=[{type:"process",label:"Process Node",description:"Let a LLM do your work"},{type:"finish",label:"Finish Node",description:"End your flow here"},{type:"mcp",label:"MCP Node",description:"Add functionality"},{type:"subflow",label:"Subflow Node",description:"Run another flow as a step"}],eN=()=>{ey.debug("".concat(ej,": Entering component")),(0,l.A)();let e=(0,r.useCallback)(e=>{ey.debug("".concat(ej,".onNodeDoubleClick: Double-clicked on ").concat(e," node"));let t=new CustomEvent("addNodeFromPalette",{detail:{nodeType:e,position:{x:250,y:150}}});document.dispatchEvent(t),ey.info("".concat(ej,".onNodeDoubleClick: Dispatched addNodeFromPalette event for ").concat(e," node"))},[]);return ey.debug("".concat(ej,": Rendering component")),(0,o.jsxs)(ew,{elevation:2,children:[(0,o.jsx)(s.default,{variant:"h6",gutterBottom:!0,children:"Node Types"}),(0,o.jsx)(a.default,{display:"flex",flexDirection:"column",gap:2,children:ek.map(t=>(0,o.jsxs)(eC,{nodeType:t.type,elevation:1,draggable:!0,onDragStart:e=>((e,t)=>{ey.debug("".concat(ej,".onDragStart: Entering method with nodeType=").concat(t)),e.dataTransfer.setData("application/reactflow",t),e.dataTransfer.effectAllowed="move";let n=document.createElement("div");n.innerHTML='<div style="padding: 10px; background: white; border: 1px solid #ccc; border-radius: 4px;">'.concat(t," Node</div>"),document.body.appendChild(n),ey.debug("".concat(ej,".onDragStart: Created drag preview element"));try{e.dataTransfer.setDragImage(n,75,25),ey.debug("".concat(ej,".onDragStart: Set drag image with offset (75, 25)"))}catch(e){ey.error("".concat(ej,".onDragStart: Error setting drag image:"),e)}setTimeout(()=>{document.body.removeChild(n),ey.debug("".concat(ej,".onDragStart: Removed drag preview element"))},0),ey.debug("".concat(ej,".onDragStart: Drag operation initialized"))})(e,t.type),onDragEnd:e=>{var n;return n=t.type,void ey.debug("".concat(ej,".onDragEnd: Drag operation ended for nodeType=").concat(n))},onDoubleClick:()=>e(t.type),children:[(0,o.jsx)(eA,{nodeType:t.type,children:(0,o.jsxs)(eS,{children:[(e=>{switch(e){case"process":default:return(0,o.jsx)(eg.A,{color:"secondary"});case"finish":return(0,o.jsx)(ev.A,{color:"success"});case"mcp":return(0,o.jsx)(eg.A,{color:"info"});case"subflow":return(0,o.jsx)(eb.A,{color:"warning"})}})(t.type),(0,o.jsx)(s.default,{variant:"subtitle2",fontWeight:"bold",children:t.label})]})}),(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",children:t.description})]},t.type))})]})};var eT=n(28548),eI=n(4474),eM=n(41602),eP=n(73707),eF=n(23820),eE=n(5155),eD=n(60691),ez=n(76808),eR=n(36741),eW=n(61033);function eL(e){var t,n,o;return null!=(o=null!=(n=null==(t=e.data)?void 0:t.type)?n:e.type)?o:"unknown"}function eB(e){var t;return(null==(t=e.data)?void 0:t.label)||e.id}function eO(e){var t;return(null==(t=e.data)?void 0:t.edgeType)==="mcp"}function eH(e){var t,n,o,r,l,a,s,i,d;let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=[],p=Array.isArray(null==e?void 0:e.nodes)?e.nodes:[],h=Array.isArray(null==e?void 0:e.edges)?e.edges:[],f=(e,t,n,o)=>u.push({severity:e,code:t,message:n,nodeId:null==o?void 0:o.id,nodeLabel:o?eB(o):void 0}),m=new Map((null!=(t=c.models)?t:[]).map(e=>[e.id,e])),x=new Map((null!=(n=c.servers)?n:[]).map(e=>[e.name,e])),g=!!c.models,v=!!c.servers,b=p.filter(e=>"start"===eL(e)),y=p.filter(e=>"finish"===eL(e)),j=p.filter(e=>"process"===eL(e)),w=p.filter(e=>"mcp"===eL(e));if(0===b.length)f("error","no-start-node","The flow has no Start node, so it has no entry point.");else if(b.length>1)for(let e of b.slice(1))f("error","multiple-start-nodes","The flow has more than one Start node; only one is allowed.",e);for(let e of(0===y.length&&f("warning","no-finish-node","The flow has no Finish node; it will run but never reaches a defined end."),j)){let t=null!=(r=null==(o=e.data)?void 0:o.properties)?r:{},n=t.boundModel;if(n){if(g&&!m.has(n)){let n="string"==typeof t.modelName&&t.modelName?' (was "'.concat(t.modelName,'")'):"";f("error","process-model-missing",'Process node "'.concat(eB(e),'" is bound to a model that no longer exists').concat(n,"."),e)}}else f("error","process-missing-model",'Process node "'.concat(eB(e),'" has no model bound.'),e)}for(let e of w){let t=(null!=(a=null==(l=e.data)?void 0:l.properties)?a:{}).boundServer;if(t){if(v&&!x.has(t))f("warning","mcp-server-missing",'MCP node "'.concat(eB(e),'" is bound to server "').concat(t,"\", which isn't in your current MCP server list. It may be offline (e.g. not connected), renamed, or removed — if it was renamed or removed, rebind this node."),e);else if(v){let n=x.get(t);if(n.status&&"connected"!==n.status){let o="disabled"===n.status?"disabled":"not connected (".concat(n.status,")");f("warning","mcp-server-disconnected",'MCP node "'.concat(eB(e),'" is bound to server "').concat(t,'", which is currently ').concat(o,". It will provide tools again once it reconnects."),e)}}}else f("warning","mcp-missing-server",'MCP node "'.concat(eB(e),'" is not bound to a server.'),e);h.some(t=>eO(t)&&(t.source===e.id||t.target===e.id))||f("warning","mcp-node-unconnected",'MCP node "'.concat(eB(e),'" is not connected to any Process node.'),e)}if(b.length>0){let e=function(e){let t=new Map,n=(e,n)=>{t.has(e)||t.set(e,[]),t.get(e).push(n)};for(let t of e){var o;!eO(t)&&(n(t.source,t.target),(null==(o=t.data)?void 0:o.bidirectional)&&n(t.target,t.source))}return t}(h);for(let t of b)(null==(s=e.get(t.id))?void 0:s.length)||f("error","start-no-outgoing","The Start node is not connected to anything; the flow cannot run.",t);let t=function(e,t){let n=new Set(e),o=[...e];for(;o.length;){var r;let e=o.shift();for(let l of null!=(r=t.get(e))?r:[])n.has(l)||(n.add(l),o.push(l))}return n}(b.map(e=>e.id),e);for(let e of[...j,...y])t.has(e.id)||f("warning","unreachable-node","".concat("finish"===eL(e)?"Finish":"Process",' node "').concat(eB(e),'" is not reachable from the Start node.'),e)}for(let e of p.filter(e=>"subflow"===eL(e))){let t=h.filter(t=>{var n;return!eO(t)&&(t.source===e.id||t.target===e.id&&!!(null==(n=t.data)?void 0:n.bidirectional))});t.length>1&&f("error","subflow-multiple-outgoing",'Subflow node "'.concat(eB(e),'" has ').concat(t.length," outgoing connections; a subflow can only have one (either A > B > C or a bidirectional A <> B)."),e)}for(let e of j){let t=null==(d=e.data)||null==(i=d.properties)?void 0:i.promptTemplate;if("string"!=typeof t||!t)continue;let n=function(e,t,n){let o=new Map(t.map(e=>[e.id,e])),r=new Set;for(let t of n){var l,a;if(!eO(t))continue;let n=null;if(t.source===e?n=t.target:t.target===e&&(n=t.source),!n)continue;let s=o.get(n);if(!s||"mcp"!==eL(s))continue;let i=null==(a=s.data)||null==(l=a.properties)?void 0:l.boundServer;"string"==typeof i&&i&&r.add(i)}return r}(e.id,p,h),o=new Set;for(let r of(0,eW.A$)(t)){if("handoff"===r.server)continue;let t="".concat(r.kind,":").concat(r.server,":").concat(r.name);!o.has(t)&&(o.add(t),n.has(r.server)?"tool"===r.kind&&c.serverTools&&c.serverTools[r.server]&&!c.serverTools[r.server].includes(r.name)&&f("warning","tool-unavailable",'Process node "'.concat(eB(e),'" references tool "').concat(r.name,'" which server "').concat(r.server,'" no longer provides.'),e):f("error","tool-pill-disconnected",'Process node "'.concat(eB(e),'" references ').concat(r.kind,' "').concat(r.name,'" from server "').concat(r.server,'", but it is not connected to that server (the MCP node was removed or the server was renamed).'),e))}}let C=u.filter(e=>"error"===e.severity).length,A=u.length-C;return{issues:u,errorCount:C,warningCount:A,isRunnable:0===C}}var e_=n(43076);let eG=(0,k.h)("components/flow/FlowBuilder/FlowValidationButton"),eU=e=>{var t,n;let{nodes:l,edges:d}=e,[c,u]=(0,r.useState)(!1),[p,h]=(0,r.useState)(!1),[g,v]=(0,r.useState)(null),y=(0,r.useCallback)(async()=>{h(!0);try{var e;let t=null!=(e=await e_.N.tryLoadModels())?e:void 0,n=await M.S.loadServerConfigs(),o=Array.isArray(n)?n.map(e=>({name:e.name,status:e.disabled?"disabled":void 0})):void 0,r=eH({nodes:l,edges:d},{models:t,servers:o});v(r.issues)}catch(e){eG.warn("Flow validation failed to run",e),v([])}finally{h(!1)}},[l,d]),j=(0,r.useCallback)(()=>{u(!0),v(null),y()},[y]),w=(0,r.useCallback)(e=>{e&&(u(!1),document.dispatchEvent(new CustomEvent("editNode",{detail:{nodeId:e}})))},[]),C=null!=(t=null==g?void 0:g.filter(e=>"error"===e.severity).length)?t:0,A=(null!=(n=null==g?void 0:g.length)?n:0)-C;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{variant:"outlined",color:"primary",onClick:j,startIcon:(0,o.jsx)(eE.A,{}),sx:{textTransform:"none"},children:"Check Flow"}),(0,o.jsxs)(f.A,{open:c,onClose:()=>u(!1),maxWidth:"sm",fullWidth:!0,children:[(0,o.jsxs)(m.A,{component:"div",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)("span",{children:"Flow Check"}),g&&(0,o.jsxs)(a.default,{sx:{display:"flex",gap:1,ml:1},children:[C>0&&(0,o.jsx)(eT.A,{size:"small",color:"error",label:"".concat(C," error").concat(1===C?"":"s")}),A>0&&(0,o.jsx)(eT.A,{size:"small",color:"warning",label:"".concat(A," warning").concat(1===A?"":"s")})]})]}),(0,o.jsx)(x.A,{dividers:!0,children:p?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:2,py:3,justifyContent:"center"},children:[(0,o.jsx)(eI.default,{size:22}),(0,o.jsx)(s.default,{color:"text.secondary",children:"Checking flow…"})]}):g&&0===g.length?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1.5,py:3,justifyContent:"center"},children:[(0,o.jsx)(eR.A,{color:"success"}),(0,o.jsx)(s.default,{children:"No problems found — this flow looks runnable."})]}):(0,o.jsx)(eM.A,{dense:!0,disablePadding:!0,children:(null!=g?g:[]).map((e,t)=>{var n;let r=!!e.nodeId,l=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(U.A,{sx:{minWidth:36},children:"error"===e.severity?(0,o.jsx)(eD.A,{color:"error",fontSize:"small"}):(0,o.jsx)(ez.A,{color:"warning",fontSize:"small"})}),(0,o.jsx)(J.A,{primary:e.message,secondary:r?"Node: ".concat(null!=(n=e.nodeLabel)?n:e.nodeId," — click to open"):void 0})]});return r?(0,o.jsx)(eP.A,{onClick:()=>w(e.nodeId),alignItems:"flex-start",children:l},t):(0,o.jsx)(eF.Ay,{alignItems:"flex-start",children:l},t)})})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:y,disabled:p,children:"Re-check"}),(0,o.jsx)(i.A,{onClick:()=>u(!1),variant:"contained",children:"Close"})]})]})]})};var eJ=n(33077),eY=n(57813),e$=n(26466),eV=n(77073);function eX(e){let{currentLabel:t,nameIsCustom:n,defaultLabel:o,previousAutoLabel:r,nextAutoLabel:l}=e;return!0===n?t&&t.length>0?t:l:!t||0===t.length||t===o||void 0!==r&&r.length>0&&t===r?l:t}let eZ=(0,k.h)("components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useModelManagement.ts");var eq=n(9898);let eK=(0,k.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useServerConnection"),eQ="handoff_to_";function e0(e,t){let n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;let o=n.slice(0,t),r=o.lastIndexOf(" ");return"".concat((r>.6*t?o.slice(0,r):o).trimEnd(),"…")}let e1=(0,k.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useHandoffTools"),e2=e=>{let{nodeData:t,setNodeData:n}=e;return t?(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pr:2},children:[(0,o.jsx)(s.default,{variant:"h6",gutterBottom:!0,children:"Node Configuration"}),(0,o.jsx)(v.A,{fullWidth:!0,label:"Node Label",value:t.label||"",onChange:e=>n(t=>({...t,label:e.target.value,properties:{...null==t?void 0:t.properties,nameIsCustom:!0}})),margin:"normal"}),(0,o.jsx)(v.A,{fullWidth:!0,label:"Description",value:t.description||"",onChange:e=>n({...t,description:e.target.value}),margin:"normal",multiline:!0,rows:2,helperText:"This description will be displayed on the node"})]}):null};var e5=n(52641),e4=n(43861),e6=n(99944),e8=n(75656),e3=n(18369),e7=n(12857);let e9=e=>{let{isLoadingModels:t,loadError:n,models:r,selectedModelId:l,handleModelSelect:d,isModelBound:c,handleUnbindModel:u}=e;return(0,o.jsxs)(a.default,{sx:{mt:4},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Bind to Model"}),t?(0,o.jsx)(s.default,{color:"text.secondary",children:"Loading models..."}):n?(0,o.jsx)(s.default,{color:"error",children:n}):0===r.length?(0,o.jsx)(s.default,{color:"text.secondary",children:"No models available. Add some in the Model Manager."}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(e5.A,{component:"fieldset",fullWidth:!0,children:[(0,o.jsx)(e4.A,{value:l,onChange:e=>d(e.target.value),children:(0,o.jsx)(eJ.Ay,{container:!0,spacing:2,children:r.map(e=>(0,o.jsx)(eJ.Ay,{item:!0,xs:12,sm:6,children:(0,o.jsx)(A.A,{elevation:1,sx:{p:2,border:2*(l===e.id),borderColor:"primary.main"},children:(0,o.jsx)(e6.A,{value:e.id,control:(0,o.jsx)(e8.A,{}),label:(0,o.jsxs)(a.default,{children:[(0,o.jsx)(s.default,{variant:"subtitle2",children:e.displayName||e.name}),e.description&&(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",display:"block",children:e.description}),e.baseUrl&&(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",children:e.baseUrl})]}),sx:{width:"100%",m:0}})})},e.id))})}),(0,o.jsx)(e3.A,{children:l?"This node will use the selected model for processing.":"Select a model to bind this node to."})]}),c&&(0,o.jsx)(a.default,{sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:(0,o.jsx)(i.A,{startIcon:(0,o.jsx)(e7.A,{}),onClick:u,color:"primary",variant:"outlined",size:"small",children:"Unbind Model"})})]})]})};var te=n(66177),tt=n(56422),tn=n(29767),to=n(84578),tr=n(76530),tl=n(25541),ta=n(51611),ts=n(89218);let ti=(0,k.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerTools"),td=e=>{var t,n,l;let{isLoadingServers:d,connectedMcpNodes:p,availableServers:h,onConnectMcpServer:f,serverToolsMap:m,serverStatuses:x,isLoadingTools:g,handleSelectToolServer:b,handleInsertToolBinding:y,selectedToolServerNodeId:w,selectedNodeId:C,isLoadingSelectedServerTools:S,promptBuilderRef:k,handleRetryServer:N,handleRestartServer:T}=e,I=null!=(l=null!=w?w:null==(t=p[0])?void 0:t.nodeId)?l:null,[M,P]=(0,r.useState)({}),[F,E]=(0,r.useState)(null),D=(null!=h?h:[]).filter(e=>!p.some(t=>t.serverName===e.name)),z=!!f&&D.length>0,R=(0,o.jsx)(Y.A,{open:!!F,anchorEl:F,onClose:()=>E(null),children:D.map(e=>(0,o.jsxs)(G.A,{onClick:()=>{var t;return t=e.name,void(E(null),null==f||f(t))},children:[(0,o.jsx)(a.default,{sx:{width:8,height:8,borderRadius:"50%",mr:1,bgcolor:"connected"===e.status?"success.main":"text.disabled"}}),e.name]},e.name))}),[W,L]=(0,r.useState)(""),B=e=>{try{let t=p.find(t=>t.nodeId===e);if(!t)return ti.warn("Could not find connected MCP node with ID ".concat(e)),[];let n=t.enabledTools||[];return ti.debug("Enabled tools for node ".concat(e,": ").concat(JSON.stringify(n))),Array.isArray(n)?n:[]}catch(t){return ti.error("Error getting enabled tools for node ".concat(e,":"),t),[]}},O=(e,t,n)=>{try{if(!n||!Array.isArray(n))return ti.warn("Tools array is not available or not an array for server ".concat(t)),[];let o=B(e),r=n;if(o.length>0?r=n.filter(e=>e&&e.name&&o.includes(e.name)):(ti.debug("No tools explicitly enabled for node ".concat(e,", showing none.")),r=[]),W.trim()){let e=W.toLowerCase().trim();r=r.filter(t=>t.name&&t.name.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)||t.inputSchema&&JSON.stringify(t.inputSchema).toLowerCase().includes(e))}return r}catch(o){return ti.error("Error filtering tools for node ".concat(e," (server ").concat(t,"):"),o),n||[]}},H=e=>{b(e)},_=async(e,t)=>{t.stopPropagation(),ti.debug("Retry button clicked for server: ".concat(e)),P(t=>({...t,[e]:!0}));try{N&&await N(e)}finally{setTimeout(()=>{P(t=>({...t,[e]:!1}))},500)}},U=async(e,t)=>{t.stopPropagation(),ti.debug("Restart button clicked for server: ".concat(e)),P(t=>({...t,[e]:!0}));try{T&&await T(e)}finally{setTimeout(()=>{P(t=>({...t,[e]:!1}))},500)}};(0,r.useEffect)(()=>{p.length>0&&!w&&b(p[0].nodeId)},[p,w,b]);let J=p.find(e=>e.nodeId===I),$=null==J?void 0:J.serverName;return(0,o.jsxs)(a.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Connected MCP Servers and Tools"}),d?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(eI.default,{size:20}),(0,o.jsx)(s.default,{color:"text.secondary",children:"Loading connected MCP nodes..."})]}):0===p.length?(0,o.jsxs)(a.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,o.jsx)(s.default,{color:"text.secondary",align:"center",children:"No MCP nodes connected to this Process node."}),(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:z?"Pick a server below — the MCP node is added to the flow and wired up for you.":"Connect MCP nodes to this Process node using the side handles to access their tools."}),z&&(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",mt:2},children:(0,o.jsx)(i.A,{variant:"contained",size:"small",startIcon:(0,o.jsx)(j.A,{}),onClick:e=>E(e.currentTarget),children:"Connect MCP Server"})}),R]}):(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",mb:2,borderBottom:1,borderColor:"divider"},children:[(0,o.jsx)(eY.A,{value:I||(null==(n=p[0])?void 0:n.nodeId)||"",onChange:(e,t)=>H(t),variant:"scrollable",scrollButtons:"auto",sx:{flexGrow:1},children:p.map(e=>{if(!e||!e.nodeId||!e.serverName)return ti.warn("Skipping invalid MCP node in tabs:",e),null;let t=e.serverName,n=e.nodeId,r=e.status;M[t],g[t];let l=m[t]||[],i=B(n);return O(n,t,l).length,(0,o.jsx)(e$.A,{value:n,label:(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(s.default,{variant:"body2",sx:{color:"connected"===r?"success.main":"error"===r?"error.main":"text.secondary"},children:t}),i.length>0&&(0,o.jsx)(te.A,{badgeContent:i.length,color:"primary",sx:{ml:1}})]}),sx:{textTransform:"none",minHeight:"48px",opacity:"connected"!==r?.7:1}},n)})}),z&&(0,o.jsx)(u.A,{title:"Connect another MCP server",children:(0,o.jsx)(c.A,{size:"small",onClick:e=>E(e.currentTarget),sx:{ml:1},children:(0,o.jsx)(j.A,{fontSize:"small"})})}),R]}),J&&$&&(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"flex-end",mb:2},children:[(0,o.jsx)(u.A,{title:"Retry connection for ".concat($),children:(0,o.jsx)("span",{children:(0,o.jsx)(c.A,{size:"small",onClick:e=>_($,e),disabled:M[$]||g[$],children:M[$]?(0,o.jsx)(eI.default,{size:16}):(0,o.jsx)(tr.A,{fontSize:"small"})})})}),"connected"===J.status&&T&&(0,o.jsx)(u.A,{title:"Restart server ".concat($),children:(0,o.jsx)("span",{children:(0,o.jsx)(c.A,{size:"small",onClick:e=>U($,e),disabled:M[$],sx:{ml:1},children:(0,o.jsx)(tl.A,{fontSize:"small"})})})})]}),(0,o.jsx)(v.A,{placeholder:"Search enabled tools...",variant:"outlined",size:"small",fullWidth:!0,value:W,onChange:e=>L(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,o.jsx)(tt.A,{position:"start",children:(0,o.jsx)(ta.A,{fontSize:"small"})})}}),(0,o.jsx)(A.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 140px)"},children:J&&$&&(()=>{let e=J.nodeId,t=J.serverName;if("connected"!==J.status)return(0,o.jsx)(a.default,{sx:{p:2,textAlign:"center"},children:(0,o.jsxs)(s.default,{color:"text.secondary",children:["Server '",t,"' is not connected. Connect to view tools."]})},e);if(g[t])return(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,o.jsx)(eI.default,{size:24})},e);let n=m[t]||[],r=O(e,t,n);if(0===r.length){let t=B(e).length;return(0,o.jsx)(a.default,{sx:{p:2,textAlign:"center"},children:(0,o.jsx)(s.default,{color:"text.secondary",children:W.trim()?'No enabled tools match "'.concat(W,'" for this node.'):0===t?"No tools are enabled for this node instance. Enable tools in the MCP Node properties.":"No tools available or enabled for this node instance."})},e)}return(0,o.jsx)(eM.A,{disablePadding:!0,children:r.map(n=>(0,o.jsxs)(tn.A,{variant:"outlined",onClick:()=>{e!==I?(ti.debug("Node tab not selected, selecting node first",{selectedNodeId:e,serverName:t,toolName:n.name}),H(e)):t&&n.name?(ti.debug("Inserting tool binding",{serverName:t,toolName:n.name}),y(t,n.name)):ti.warn("Cannot insert tool binding, server or tool name is undefined",{serverName:t,toolName:n.name})},sx:{mb:1,mx:1,mt:1,cursor:"pointer",position:"relative","&:hover":{boxShadow:1,bgcolor:"action.hover"}},children:[(0,o.jsx)(to.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:(0,o.jsxs)(a.default,{sx:{width:"100%"},children:[(0,o.jsxs)(s.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(ts.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),n.name]}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:n.description||"No description available"}),n.inputSchema&&(e=>e&&e.properties?(0,o.jsxs)(a.default,{sx:{mt:1},children:[(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",sx:{fontWeight:"medium"},children:"Parameters:"}),(0,o.jsx)(a.default,{sx:{pl:1,mt:.5},children:Object.entries(e.properties).map(t=>{var n;let[r,l]=t;return(0,o.jsxs)(a.default,{sx:{mb:.5},children:[(0,o.jsxs)(s.default,{variant:"caption",component:"span",sx:{fontWeight:"medium"},children:[r,(null==(n=e.required)?void 0:n.includes(r))&&(0,o.jsx)(s.default,{variant:"caption",component:"span",color:"error.main",children:" *"}),": "]}),(0,o.jsx)(s.default,{variant:"caption",component:"span",color:"text.secondary",children:l.description||l.type||"No description"})]},r)})})]}):null)(n.inputSchema)]})})}),(0,o.jsx)(u.A,{title:"Add ".concat(n.name," from ").concat(t," to prompt"),children:(0,o.jsx)(a.default,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0}})})]},n.name))},e)})()})]})]})};var tc=n(59323);let tu=(0,k.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerResources"),tp=e=>{let{primary:t,secondary:n,chip:r,onClick:l}=e;return(0,o.jsx)(tn.A,{variant:"outlined",onClick:l,sx:{mb:1,mx:1,mt:1,cursor:"pointer","&:hover":{boxShadow:1,bgcolor:"action.hover"}},children:(0,o.jsx)(to.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,o.jsxs)(a.default,{sx:{width:"100%"},children:[(0,o.jsxs)(s.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(tc.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),t]}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,wordBreak:"break-all"},children:n})]}),r&&(0,o.jsx)(eT.A,{size:"small",label:r,sx:{ml:1,flexShrink:0}})]})})})},th=e=>{var t;let{connectedMcpNodes:n,handleInsertResourceBinding:l,promptBuilderRef:i}=e,[d,c]=(0,r.useState)(null),[u,p]=(0,r.useState)([]),[f,m]=(0,r.useState)([]),[x,g]=(0,r.useState)(!1),[b,y]=(0,r.useState)(),[j,w]=(0,r.useState)(""),C=n.find(e=>e.nodeId===d),S=null==C?void 0:C.serverName;(0,r.useEffect)(()=>{n.length>0&&!d&&c(n[0].nodeId)},[n,d]);let k=(0,r.useCallback)(async e=>{g(!0),y(void 0);try{let t=await M.S.listServerResources(e);p(t.resources||[]),m(t.resourceTemplates||[]),y(t.error)}catch(t){tu.warn("Failed to load resources for ".concat(e),t),y(t instanceof Error?t.message:"Failed to load resources")}finally{g(!1)}},[]);(0,r.useEffect)(()=>{S?k(S):(p([]),m([]))},[S,k]);let N=e=>e.toLowerCase().includes(j.toLowerCase().trim()),T=j.trim()?u.filter(e=>N(e.name||"")||N(e.uri)||N(e.description||"")):u,I=j.trim()?f.filter(e=>N(e.name||"")||N(e.uriTemplate)||N(e.description||"")):f,P=e=>{S&&e&&l(S,e)};return(0,o.jsxs)(a.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Give this step access to…"}),(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",sx:{mb:1},children:"Pick a resource to insert. Its contents are read and placed into the prompt each time the step runs."}),0===n.length?(0,o.jsxs)(a.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,o.jsx)(s.default,{color:"text.secondary",align:"center",children:"No MCP nodes connected to this Process node."}),(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:"Connect MCP nodes using the side handles to access their resources."})]}):(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,o.jsx)(eY.A,{value:d||(null==(t=n[0])?void 0:t.nodeId)||"",onChange:(e,t)=>c(t),variant:"scrollable",scrollButtons:"auto",sx:{mb:2,borderBottom:1,borderColor:"divider"},children:n.map(e=>(0,o.jsx)(e$.A,{value:e.nodeId,label:(0,o.jsx)(s.default,{variant:"body2",sx:{color:"connected"===e.status?"success.main":"error"===e.status?"error.main":"text.secondary"},children:e.serverName}),sx:{textTransform:"none",minHeight:48,opacity:"connected"!==e.status?.7:1}},e.nodeId))}),(0,o.jsx)(v.A,{placeholder:"Search resources…",variant:"outlined",size:"small",fullWidth:!0,value:j,onChange:e=>w(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,o.jsx)(tt.A,{position:"start",children:(0,o.jsx)(ta.A,{fontSize:"small"})})}}),b&&(0,o.jsx)(h.A,{severity:"warning",sx:{mb:2},children:b}),(0,o.jsx)(A.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 140px)"},children:C&&"connected"!==C.status?(0,o.jsx)(a.default,{sx:{p:2,textAlign:"center"},children:(0,o.jsxs)(s.default,{color:"text.secondary",children:["Server '",S,"' is not connected. Connect to view resources."]})}):x?(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,o.jsx)(eI.default,{size:24})}):0===T.length&&0===I.length?(0,o.jsx)(a.default,{sx:{p:2,textAlign:"center"},children:(0,o.jsx)(s.default,{color:"text.secondary",children:j.trim()?'No resources match "'.concat(j,'".'):"This server does not publish any resources."})}):(0,o.jsxs)(eM.A,{disablePadding:!0,children:[T.map(e=>(0,o.jsx)(tp,{primary:e.name||e.uri,secondary:e.description||e.uri,chip:e.mimeType,tooltip:"Add ".concat(e.name||e.uri," to prompt"),onClick:()=>P(e.uri)},e.uri)),I.map(e=>(0,o.jsx)(tp,{primary:e.name||e.uriTemplate,secondary:e.description||e.uriTemplate,chip:"template",tooltip:"Add template ".concat(e.uriTemplate," to prompt (fill in variables, e.g. with ${global:VAR})"),onClick:()=>P(e.uriTemplate)},e.uriTemplate))]})})]})]})},tf=(0,k.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerTools/AgentTools"),tm=e=>{let{handoffTools:t,isLoadingHandoffTools:n,handleInsertToolBinding:l,promptBuilderRef:i}=e,[d,c]=(0,r.useState)(""),p=t.filter(e=>{if(!d.trim())return!0;let t=d.toLowerCase().trim();return e.name&&e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)});return(0,o.jsxs)(a.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Agent Handoff Tools"}),n?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(eI.default,{size:20}),(0,o.jsx)(s.default,{color:"text.secondary",children:"Loading handoff tools..."})]}):0===t.length?(0,o.jsxs)(a.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,o.jsx)(s.default,{color:"text.secondary",align:"center",children:"No handoff tools available for this node."}),(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:"Connect this Process node to other nodes to enable handoff tools."})]}):(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,o.jsx)(v.A,{placeholder:"Search handoff tools...",variant:"outlined",size:"small",fullWidth:!0,value:d,onChange:e=>c(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,o.jsx)(tt.A,{position:"start",children:(0,o.jsx)(ta.A,{fontSize:"small"})})}}),(0,o.jsx)(A.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 56px)"},children:0===p.length?(0,o.jsx)(a.default,{sx:{p:2,textAlign:"center"},children:(0,o.jsx)(s.default,{color:"text.secondary",children:d.trim()?'No handoff tools match "'.concat(d,'".'):"No handoff tools available."})}):(0,o.jsx)(eM.A,{disablePadding:!0,children:p.map(e=>(0,o.jsxs)(tn.A,{variant:"outlined",onClick:()=>{e.name?(tf.debug("Inserting handoff tool binding",{toolType:"handoff",toolName:e.name}),l("handoff",e.name)):tf.warn("Cannot insert handoff tool binding, tool name is undefined",{toolName:e.name})},sx:{mb:1,mx:1,mt:1,cursor:"pointer",position:"relative",bgcolor:"rgba(0, 0, 0, 0.04)","&:hover":{boxShadow:1,bgcolor:"rgba(0, 0, 0, 0.08)"}},children:[(0,o.jsx)(to.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:(0,o.jsxs)(a.default,{sx:{width:"100%"},children:[(0,o.jsxs)(s.default,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(ts.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),e.name]}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:e.description||"No description available"}),e.inputSchema&&(e=>e&&e.properties&&0!==Object.keys(e.properties).length?(0,o.jsxs)(a.default,{sx:{mt:1},children:[(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",sx:{fontWeight:"medium"},children:"Parameters:"}),(0,o.jsx)(a.default,{sx:{pl:1,mt:.5},children:Object.entries(e.properties).map(t=>{var n;let[r,l]=t;return(0,o.jsxs)(a.default,{sx:{mb:.5},children:[(0,o.jsxs)(s.default,{variant:"caption",component:"span",sx:{fontWeight:"medium"},children:[r,(null==(n=e.required)?void 0:n.includes(r))&&(0,o.jsx)(s.default,{variant:"caption",component:"span",color:"error.main",children:" *"}),": "]}),(0,o.jsx)(s.default,{variant:"caption",component:"span",color:"text.secondary",children:l.description||l.type||"No description"}),l.enum&&(0,o.jsx)(a.default,{sx:{pl:2,mt:.5},children:(0,o.jsxs)(s.default,{variant:"caption",color:"text.secondary",children:["Options: ",l.enum.join(", ")]})})]},r)})})]}):(0,o.jsx)(a.default,{sx:{mt:1},children:(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",sx:{fontStyle:"italic"},children:"No parameters required."})}))(e.inputSchema)]})})}),(0,o.jsx)(u.A,{title:"Add ".concat(e.name," handoff tool to prompt"),children:(0,o.jsx)(a.default,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0}})})]},e.name))})})]})]})};var tx=n(9957),tg=n(16757),tv=n(46496),tb=n(54043),ty=n(54178),tj=n(26811),tw=n(95480);let tC=e=>{let{selected:t,icon:n,title:r,description:l,onClick:i}=e;return(0,o.jsxs)(a.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:i,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},sx:{flex:1,minWidth:180,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,o.jsx)(eR.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[n,(0,o.jsx)(s.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:r})]}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",children:l})]})},tA=(0,k.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ProcessNodePropertiesModal/PromptTemplateEditor"),tS=(0,r.forwardRef)((e,t)=>{let{promptTemplate:n,handlePromptChange:l,excludeModelPrompt:d,setExcludeModelPrompt:c,excludeStartNodePrompt:u,setExcludeStartNodePrompt:p,excludeSystemPrompt:f,setExcludeSystemPrompt:m,inputMode:x,setInputMode:g,isolatedPrompt:b,setIsolatedPrompt:y,outputMode:j,setOutputMode:w,isModelBound:C,models:S,nodeData:k,flowId:N}=e,[T,I]=(0,r.useState)(""),[M,P]=(0,r.useState)(!1),[F,E]=(0,r.useState)(null),D=(0,r.useRef)(null);(0,r.useImperativeHandle)(t,()=>({insertText:e=>{D.current&&D.current.insertText(e)},getMode:()=>D.current?D.current.getMode():"raw"}));let z=async()=>{if(tA.debug("fetchRenderedPrompt called with:",{flowId:N,nodeId:null==k?void 0:k.id}),!N||!k||!k.id)return void E("Flow ID or Node ID is missing");P(!0),E(null);try{var e;let t=await fetch("/api/flow/prompt-renderer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:N,nodeId:k.id,options:{renderMode:"rendered",includeConversationHistory:!1,excludeModelPrompt:d,excludeStartNodePrompt:u,excludeSystemPrompt:f}})}),n=await t.json();if(!t.ok)throw Error(n.error||"Failed to render prompt");tA.debug("Rendered prompt received",{promptLength:null==(e=n.prompt)?void 0:e.length}),I(n.prompt+"\n\n [Messages sent by User]")}catch(e){tA.error("Error fetching rendered prompt",e),E(e instanceof Error?e.message:"An unknown error occurred")}finally{P(!1)}};return(0,r.useEffect)(()=>{D.current&&"preview"===D.current.getMode()&&z()},[n,d,u,f,N,null==k?void 0:k.id]),(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pl:2},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,o.jsx)(s.default,{variant:"h6",children:"Prompt Template"}),(0,o.jsxs)(a.default,{sx:{display:"flex",gap:2},children:[(0,o.jsx)(e6.A,{control:(0,o.jsx)(tx.A,{checked:d,onChange:e=>c(e.target.checked),color:"primary",size:"small"}),label:"Exclude Model Prompt"}),(0,o.jsx)(e6.A,{control:(0,o.jsx)(tx.A,{checked:u,onChange:e=>p(e.target.checked),color:"primary",size:"small"}),label:"Exclude Start Node Prompt"}),(0,o.jsx)(e6.A,{control:(0,o.jsx)(tx.A,{checked:f,onChange:e=>m(e.target.checked),color:"primary",size:"small"}),label:"Exclude System Prompt"})]})]}),(0,o.jsxs)(a.default,{sx:{mb:2,p:2,bgcolor:"rgba(0, 0, 0, 0.03)",borderRadius:1,fontSize:"0.85rem"},children:[(0,o.jsx)(s.default,{variant:"caption",sx:{display:"block",mb:1,fontWeight:"bold"},children:"Prompt Rendering Order:"}),(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[!u&&(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(s.default,{variant:"caption",sx:{color:"primary.main",fontWeight:"medium"},children:"1. Start Node Prompt"}),(0,o.jsx)(s.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"(from the Start node in this flow)"})]}),!d&&C&&(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsxs)(s.default,{variant:"caption",sx:{color:"secondary.main",fontWeight:"medium"},children:[u?"1.":"2."," Model Prompt"]}),(0,o.jsxs)(s.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:["(from the selected model: ",(()=>{var e,t;let n=null==(e=k.properties)?void 0:e.boundModel;if(!n)return"None";let o=S.find(e=>e.id===n);return o?o.displayName||o.name:(null==(t=k.properties)?void 0:t.modelName)||"None"})(),")"]})]}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsxs)(s.default,{variant:"caption",sx:{fontWeight:"medium"},children:[u||d||!C?u&&(d||!C)?"1.":"2.":"3."," This Node's Prompt"]}),(0,o.jsx)(s.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"(defined below)"})]}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsxs)(s.default,{variant:"caption",sx:{fontWeight:"medium"},children:[u||d||!C?u&&(d||!C)?"2.":"3.":"4."," ","isolated"===x?"Isolated prompt":"latest-message"===x?"Latest message only":"Conversation History"]}),(0,o.jsx)(s.default,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"isolated"===x?"(the prompt below, as the user message)":"latest-message"===x?"(only the most recent user message)":"(coming from ChatCompletion endpoint)"})]})]})]}),(0,o.jsxs)(a.default,{sx:{mb:2},children:[(0,o.jsx)(s.default,{variant:"subtitle2",sx:{mb:1},children:"What does the model receive?"}),(0,o.jsxs)(a.default,{role:"radiogroup","aria-label":"Model input",sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[(0,o.jsx)(tC,{selected:"full-history"===x,onClick:()=>g("full-history"),icon:(0,o.jsx)(tg.A,{fontSize:"small"}),title:"Full conversation",description:"The model sees this node's prompt plus the whole conversation so far. The default."}),(0,o.jsx)(tC,{selected:"latest-message"===x,onClick:()=>g("latest-message"),icon:(0,o.jsx)(tv.A,{fontSize:"small"}),title:"Latest message only",description:"The model sees this node's prompt plus only the most recent user message."}),(0,o.jsx)(tC,{selected:"isolated"===x,onClick:()=>g("isolated"),icon:(0,o.jsx)(tb.A,{fontSize:"small"}),title:"Isolated",description:"The conversation is ignored. The model sees this node's prompt plus the prompt below, sent as the user message."})]}),"isolated"===x&&(0,o.jsx)(v.A,{fullWidth:!0,label:"Isolated prompt",value:b,onChange:e=>y(e.target.value),margin:"normal",multiline:!0,rows:2,helperText:"Sent to the model as the user message. The prior conversation is not shown to the model (it is still kept in the transcript for later nodes)."})]}),(0,o.jsxs)(a.default,{sx:{mb:2},children:[(0,o.jsx)(s.default,{variant:"subtitle2",sx:{mb:1},children:"What do later steps see of this step's work?"}),(0,o.jsxs)(a.default,{role:"radiogroup","aria-label":"Model output",sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[(0,o.jsx)(tC,{selected:"full-conversation"===j,onClick:()=>w("full-conversation"),icon:(0,o.jsx)(ty.A,{fontSize:"small"}),title:"Full conversation",description:"Later steps see everything this step did — tool calls, tool results, and intermediate turns. The default."}),(0,o.jsx)(tC,{selected:"latest-message"===j,onClick:()=>w("latest-message"),icon:(0,o.jsx)(tj.A,{fontSize:"small"}),title:"Latest message only",description:"Later steps see only this step's final response. Its tool calls and results are hidden from later models to save context tokens (they stay visible in the chat and log)."})]})]}),(0,o.jsx)(a.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 120px)"},children:(0,o.jsx)(tw.A,{ref:D,value:n,onChange:l,label:"",height:"100%",onModeChange:e=>{"preview"===e&&z()},customPreviewRenderer:()=>M?(0,o.jsx)(a.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(eI.default,{size:40})}):F?(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",p:2},children:[(0,o.jsx)(h.A,{severity:"error",sx:{mb:2},action:(0,o.jsx)(i.A,{color:"inherit",size:"small",onClick:z,children:"Retry"}),children:F}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mb:2,textAlign:"center"},children:N?"Check that the flow and node IDs are valid and try again.":"This flow hasn't been saved yet. Save the flow first to enable complete preview."})]}):(0,o.jsxs)(a.default,{sx:{p:2},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,sx:{fontWeight:"medium"},children:"Complete Rendered Prompt"}),(0,o.jsx)(A.A,{elevation:0,sx:{p:2,overflow:"auto",bgcolor:"rgba(0, 0, 0, 0.02)",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:1},children:(0,o.jsx)(a.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"0.875rem",m:0},children:T||"No rendered prompt available. Please check your flow configuration."})})]})})})]})});tS.displayName="PromptTemplateEditor";var tk=n(51221),tN=n(55606);let tT=e=>{let{nodeData:t,handlePropertyChange:n,properties:r}=e;return(0,o.jsx)(o.Fragment,{children:r.length>0&&(0,o.jsxs)(a.default,{sx:{mt:3},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Node Properties"}),r.map(e=>(e=>{var r,l,a;if(!t)return null;let s=null!=(l=null==(r=t.properties)?void 0:r[e.key])?l:"";switch(e.type){case"text":return(0,o.jsx)(v.A,{fullWidth:!0,label:e.label,multiline:e.multiline,rows:e.multiline?4:1,value:s,onChange:t=>n(e.key,t.target.value),margin:"normal",helperText:e.helperText},e.key);case"number":return(0,o.jsx)(v.A,{fullWidth:!0,type:"number",label:e.label,value:s,inputProps:{min:e.min,max:e.max,step:e.step},onChange:t=>{let o=t.target.value;n(e.key,""===o?void 0:Number(o))},margin:"normal",helperText:e.helperText},e.key);case"select":return(0,o.jsxs)(e5.A,{fullWidth:!0,margin:"normal",children:[(0,o.jsx)(tk.A,{children:e.label}),(0,o.jsx)(tN.A,{value:s||"",label:e.label,onChange:t=>n(e.key,t.target.value),children:null==(a=e.options)?void 0:a.map(e=>(0,o.jsx)(G.A,{value:e,children:e},e))})]},e.key);case"boolean":return(0,o.jsx)(e6.A,{control:(0,o.jsx)(tx.A,{checked:s||!1,onChange:t=>n(e.key,t.target.checked)}),label:e.label,sx:{my:1}},e.key);default:return null}})(e))]})})},tI=(0,k.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ProcessNodePropertiesModal"),tM=e=>{var t;let{open:n,node:l,onClose:d,onSave:u,flowEdges:p=[],flowNodes:h=[],flowId:g,onConnectMcpServer:v}=e;tI.debug("ProcessNodePropertiesModal rendered with:",{node:l,flowId:g});let{nodeData:y,setNodeData:j,handlePropertyChange:w}=(e=>{let[t,n]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&n({id:e.id,...e.data,properties:{...e.data.properties}})},[e]);let o=(0,r.useCallback)((e,t)=>{n(n=>n?{...n,properties:{...n.properties,[e]:t}}:null)},[]);return{nodeData:t,setNodeData:n,handlePropertyChange:o}})(l),[C,A]=(0,r.useState)(""),[k,N]=(0,r.useState)(!1),[T,I]=(0,r.useState)(!1),[P,F]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[z,R]=(0,r.useState)("full-history"),[W,L]=(0,r.useState)(""),[B,O]=(0,r.useState)("full-conversation"),[H,_]=(0,r.useState)("server"),{models:G,isLoadingModels:U,loadError:J,handleModelSelect:Y,handleUnbindModel:$}=((e,t,n,o,l)=>{var a,s;eZ.debug("useModelManagement: Entering hook");let[i,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),[p,h]=(0,r.useState)(null);(0,r.useEffect)(()=>{eZ.debug("useModelManagement useEffect: Checking if modal is open",{open:e}),e&&f()},[e]),(0,r.useEffect)(()=>{var e,o;if(0===i.length)return;let r=null==t||null==(e=t.properties)?void 0:e.boundModel;if(!r)return;let l=i.find(e=>e.id===r);l&&l.name&&(null==t||null==(o=t.properties)?void 0:o.modelName)!==l.name&&n(e=>{var t;return e&&(null==(t=e.properties)?void 0:t.modelName)!==l.name?{...e,properties:{...e.properties,modelName:l.name}}:e})},[i,null==t||null==(a=t.properties)?void 0:a.boundModel,null==t||null==(s=t.properties)?void 0:s.modelName,n]);let f=async()=>{eZ.debug("loadModels: Entering method"),u(!0),h(null);try{let e=await e_.N.loadModels();d(e)}catch(e){eZ.warn("loadModels: Failed to load models:",e),h("Failed to load models")}u(!1)},m=(0,r.useCallback)(e=>{eZ.debug("handleModelSelect: Entering method",{modelId:e});let t=i.find(t=>t.id===e);t&&(n(n=>{var o;if(!n)return null;let r=i.find(e=>{var t;return e.id===(null==(t=n.properties)?void 0:t.boundModel)}),l=eX({currentLabel:n.label,nameIsCustom:null==(o=n.properties)?void 0:o.nameIsCustom,defaultLabel:"Process Node",previousAutoLabel:r?r.displayName||r.name:void 0,nextAutoLabel:t.displayName||t.name});return{...n,label:l,properties:{...n.properties,boundModel:e,modelName:t.name}}}),l(!0))},[i,n,o,l]);return{models:i,isLoadingModels:c,loadError:p,handleModelSelect:m,handleUnbindModel:(0,r.useCallback)(()=>{eZ.debug("handleUnbindModel: Entering method"),n(e=>{if(!e)return null;let{boundModel:t,modelName:n,...o}=e.properties;return{...e,properties:{...o,promptTemplate:o.promptTemplate||""}}}),l(!1)},[n,l])}})(n,y,j,A,N),{connectedMcpNodes:V,allServers:X,isLoadingServers:Z,selectedToolServerNodeId:q,serverToolsMap:K,serverStatuses:Q,isLoadingTools:ee,handleSelectToolServer:et,isLoadingSelectedServerTools:en,handleRetryServer:eo,handleRestartServer:er}=((e,t,n,o)=>{let l=(0,eq.v)(),a=l.servers||[],s=l.isLoading||!1,[i,d]=(0,r.useState)({}),[c,u]=(0,r.useState)({}),[p,h]=(0,r.useState)({}),[f,m]=(0,r.useState)(null),[x,g]=(0,r.useState)(!1),v=(0,r.useMemo)(()=>t?((e,t)=>[...new Set(t.filter(t=>{var n,o;return t.source===e&&(null==(n=t.data)?void 0:n.edgeType)==="mcp"||t.target===e&&(null==(o=t.data)?void 0:o.edgeType)==="mcp"}).map(t=>t.source===e?t.target:t.source))])(t.id,n):[],[t,n]),b=(0,r.useMemo)(()=>{if(!t||0===v.length)return[];if(!o||!Array.isArray(o))return eK.warn("flowNodes is not available or not an array when filtering connected servers"),[];try{let e=[],t=new Set;return v.forEach(n=>{if(t.has(n))return;let r=o.find(e=>e&&e.id===n);if(!r||!r.data||!r.data.properties)return void eK.warn("Could not find valid MCP node data for ID ".concat(n));let l=r.data.properties.boundServer;if(!l)return void eK.warn("MCP node ".concat(n," is not bound to any server."));let s=a.find(e=>e.name===l),i=(null==s?void 0:s.status)||"unknown",d=r.data.properties.enabledTools||[];e.push({nodeId:n,serverName:l,status:i,enabledTools:Array.isArray(d)?d:[]}),t.add(n)}),eK.debug("Generated connectedMcpNodes:",JSON.stringify(e)),e}catch(e){return eK.error("Error preparing connected MCP nodes:",e),[]}},[t,v,a,o]);(0,r.useEffect)(()=>{if(b&&b.length>0){let e={};b.forEach(t=>{let n=a.find(e=>e.name===t.serverName);e[t.serverName]=(null==n?void 0:n.status)||t.status||"unknown"}),d(e)}},[b,a]),(0,r.useEffect)(()=>{if(e&&b.length>0){let e=Array.from(new Set(b.map(e=>e.serverName)));(async()=>{let t={},n={...c},o=e.filter(e=>{let t=a.find(t=>t.name===e);return(null==t?void 0:t.status)==="connected"&&!c[e]&&!p[e]});0!==o.length&&(o.forEach(e=>{t[e]=!0}),h(e=>({...e,...t})),await Promise.all(o.map(async e=>{try{eK.debug("Loading tools for server: ".concat(e));let t=await M.S.listServerTools(e);if(t.error)eK.warn("Error loading tools for ".concat(e,":"),t.error),n[e]=[];else{let o=t.tools||[];eK.debug("Loaded ".concat(o.length," tools for ").concat(e)),n[e]=o}}catch(t){eK.warn("Failed to load tools for server ".concat(e,":"),t),n[e]=[]}finally{h(t=>({...t,[e]:!1}))}})),u(n))})()}},[e,b,a]);let y=(0,r.useRef)(c);(0,r.useEffect)(()=>{y.current=c},[c]);let j=(0,r.useCallback)(e=>{eK.debug("Selected MCP Node ID: ".concat(e)),m(e);let t=b.find(t=>t.nodeId===e),n=null==t?void 0:t.serverName;!n||y.current[n]||p[n]?g(p[n||""]||!1):(eK.debug("Tools not loaded for server ".concat(n,", loading now.")),g(!0),h(e=>({...e,[n]:!0})),M.S.listServerTools(n).then(e=>{let t=e.tools||[];e.error?eK.warn("Error loading tools for ".concat(n,":"),e.error):eK.debug("Loaded ".concat(t.length," tools for ").concat(n)),u(e=>({...e,[n]:t}))}).catch(e=>{eK.warn("Failed to load tools for server ".concat(n,":"),e),u(e=>({...e,[n]:[]}))}).finally(()=>{g(!1),h(e=>({...e,[n]:!1}))}))},[b,p]),w=(0,r.useRef)(l);return(0,r.useEffect)(()=>{w.current=l},[l]),{connectedMcpNodes:b,allServers:a,isLoadingServers:s,selectedToolServerNodeId:f,serverToolsMap:c,serverStatuses:i,isLoadingTools:p,handleSelectToolServer:j,isLoadingSelectedServerTools:x,handleRetryServer:(0,r.useCallback)(async e=>{eK.debug("Retrying server: ".concat(e)),h(t=>({...t,[e]:!0}));try{await w.current.retryServer(e);let t=await M.S.listServerTools(e);if(t.error)return eK.warn("Error loading tools for ".concat(e," after retry:"),t.error),!1;{let n=t.tools||[];return eK.debug("Loaded ".concat(n.length," tools for ").concat(e," after retry")),u(t=>({...t,[e]:n})),!0}}catch(t){return eK.warn("Failed to retry or load tools for server ".concat(e,":"),t),!1}finally{h(t=>({...t,[e]:!1}))}},[]),handleRestartServer:(0,r.useCallback)(async e=>{eK.debug("Restarting server: ".concat(e)),h(t=>({...t,[e]:!0}));try{await M.S.restartServer(e),await new Promise(e=>setTimeout(e,1e3));let t=await M.S.listServerTools(e);if(t.error)return eK.warn("Error loading tools for ".concat(e," after restart:"),t.error),!1;{let n=t.tools||[];return eK.debug("Loaded ".concat(n.length," tools for ").concat(e," after restart")),u(t=>({...t,[e]:n})),!0}}catch(t){return eK.warn("Failed to restart or load tools for server ".concat(e,":"),t),!1}finally{h(t=>({...t,[e]:!1}))}},[])}})(n,l,p,h),el=((e,t,n,o)=>{let[l,a]=(0,r.useState)([]),[s,i]=(0,r.useState)(!1),d=(0,r.useMemo)(()=>t?function(e,t){let n=[];for(let l of t){var o,r;!("string"==typeof(null==(o=l.data)?void 0:o.edgeType)&&l.data.edgeType.includes("mcp"))&&(l.source===e?n.push(l.target):l.target===e&&(null==(r=l.data)?void 0:r.bidirectional)&&n.push(l.source))}return[...new Set(n)]}(t.id,n):[],[t,n]);return(0,r.useEffect)(()=>{if(e&&t){i(!0);try{let e=d.map(e=>o.find(t=>t.id===e)).filter(e=>!!e),t=function(e){let t=new Set,n=new Map;for(let o of e){if(n.has(o.id))continue;let e=function(e,t){let n=(e&&e.trim()||t&&t.trim()||"node").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"");return n.length>48&&(n=n.slice(0,48).replace(/_+$/g,"")),n||(n=t&&t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_")||"node"),n||"node"}(o.label,o.type),r="".concat(eQ).concat(e);if(t.has(r)){let n=2;for(;t.has("".concat(eQ).concat(e,"_").concat(n));)n++;r="".concat(eQ).concat(e,"_").concat(n)}t.add(r),n.set(o.id,r)}return n}(e.map(e=>({id:e.id,label:e.data.label,type:e.type||e.data.type}))),n=e.map(e=>({name:t.get(e.id)||"handoff_to_".concat(e.id),description:function(e){if(e.userDescription&&e.userDescription.trim())return e0(e.userDescription,1500);let t="Hand off execution to ".concat(e.label," (").concat(e.type,")."),n=[];!function e(t,n,o){let r=" ".repeat(n);if(t.userDescription&&t.userDescription.trim())return void o.push("".concat(r).concat(e0(t.userDescription,200)));if("subflow"===t.type){var l,a;if(t.subflowMissing)return void o.push("".concat(r,"Runs a subflow (referenced flow not found)."));if(t.subflowDetailsUnavailable){let e=t.subflowName?' "'.concat(t.subflowName,'"'):"";o.push("".concat(r,"Runs a subflow").concat(e," (contents summarised when the flow runs)."));return}if(o.push("".concat(r,'Runs the subflow "').concat(null!=(l=t.subflowName)?l:"unknown",'", which contains:')),t.depthCapReached)return void o.push("".concat(r," (nested subflows omitted — recursion depth limit reached)"));let s=null!=(a=t.children)?a:[];if(0===s.length)return void o.push("".concat(r," (no process or subflow steps)"));for(let t of s.slice(0,10))o.push("".concat(r," - ").concat(t.label,":")),e(t,n+2,o);return void(s.length>10&&o.push("".concat(r," - …and ").concat(s.length-10," more step(s)")))}if(t.modelName&&o.push("".concat(r,"Model: ").concat(t.modelName)),t.promptSummary&&o.push("".concat(r,"Role: ").concat(e0(t.promptSummary,200))),t.servers&&t.servers.length>0)for(let e of t.servers)if(e.connected&&e.tools&&e.tools.length>0){let t=e.tools.slice(0,10),n=e.tools.length-t.length,l=n>0?", +".concat(n," more"):"";o.push("".concat(r,"Tools (").concat(e.name,"): ").concat(t.join(", ")).concat(l))}else o.push("".concat(r,"Tools (").concat(e.name,"): server not connected"))}(e,0,n);let o=n.join("\n").trim(),r=o?"".concat(t,"\n").concat(o):t;if(r.length<=1500)return r;let l=1500-t.length-2;return l<=0?t:"".concat(t,"\n").concat(e0(o,l))}(function(e){let t=e.type||e.data.type||"unknown",n=e.data.label||"Unknown Node",o=e.data.description,r=e.data.properties||{},l={label:n,type:t,userDescription:o};if(o&&o.trim())return l;if("subflow"===t)return l.subflowDetailsUnavailable=!0,l;"string"==typeof r.boundModel&&r.boundModel&&(l.modelName=r.boundModel),"string"==typeof r.promptTemplate&&r.promptTemplate.trim()&&(l.promptSummary=r.promptTemplate);let a=Array.isArray(r.mcpNodes)?r.mcpNodes:[],s=[],i=new Set;for(let e of a){var d,c;let t=null==e||null==(d=e.properties)?void 0:d.boundServer;if(!t||i.has(t))continue;i.add(t);let n=Array.isArray(null==e||null==(c=e.properties)?void 0:c.enabledTools)?e.properties.enabledTools:[];s.push({name:t,connected:!0,tools:n})}return s.length>0&&(l.servers=s),l}(e)),inputSchema:{type:"object",properties:{},required:[]}}));a(n),e1.debug("Generated handoff tools",{toolsCount:n.length})}catch(e){e1.error("Error generating handoff tools",e),a([])}finally{i(!1)}}else a([])},[e,t,d,n,o]),{handoffTools:l,isLoadingHandoffTools:s}})(n,l,p,h),ea=(null==el?void 0:el.handoffTools)||[],es=(null==el?void 0:el.isLoadingHandoffTools)||!1;(0,r.useEffect)(()=>{n&&l&&tI.debug("Handoff tools:",{count:ea.length,tools:ea.map(e=>e.name)})},[n,l,ea]),(0,r.useEffect)(()=>{if(l){var e,t,n,o,r,a,s,i;A((null==(e=l.data.properties)?void 0:e.promptTemplate)||""),(null==(t=l.data.properties)?void 0:t.boundModel)?N(!0):N(!1),I((null==(n=l.data.properties)?void 0:n.excludeModelPrompt)||!1),F((null==(o=l.data.properties)?void 0:o.excludeStartNodePrompt)||!1),D((null==(r=l.data.properties)?void 0:r.excludeSystemPrompt)||!1),R((null==(a=l.data.properties)?void 0:a.inputMode)||"full-history"),L((null==(s=l.data.properties)?void 0:s.isolatedPrompt)||""),O((null==(i=l.data.properties)?void 0:i.outputMode)||"full-conversation")}},[l,n]);let ei=(0,r.useRef)(null),ed=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"server";if(tI.debug("handleInsertToolBinding called with:",JSON.stringify({serverName:e,toolName:t})),!e||!t)return void tI.warn("Invalid parameters for handleInsertToolBinding:",{serverName:e,toolName:t});let o=(K[e]||[]).find(e=>e.name===t);null==o||o.description;let r="handoff"===n?(0,eW.X8)("tool","handoff",t):(0,eW.X8)("tool",e,t),l=(!(C.length>0)||C.endsWith(" ")||C.endsWith("\n")?"":" ")+r;ei.current?(tI.debug("Inserting text into PromptBuilder:",JSON.stringify({textToInsert:l})),ei.current.insertText(l),tI.debug("Tool binding inserted successfully")):tI.warn("promptBuilderRef.current is null, cannot insert text")};if(!l||!y)return null;let ec=(null==(t=y.properties)?void 0:t.boundModel)||"";return(0,o.jsxs)(f.A,{open:n,onClose:d,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"secondary.main",width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,o.jsx)(m.A,{component:"div",children:(0,o.jsxs)(a.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,o.jsxs)(s.default,{variant:"h6",children:[y.label||"Process Node"," Properties"]}),(0,o.jsx)(c.A,{edge:"end",color:"inherit",onClick:d,"aria-label":"close",children:(0,o.jsx)(eV.A,{})})]})}),(0,o.jsx)(S.A,{}),(0,o.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto",height:"calc(90vh - 130px)"},children:(0,o.jsxs)(eJ.Ay,{container:!0,spacing:2,sx:{flexGrow:1,height:"100%"},children:[(0,o.jsxs)(eJ.Ay,{item:!0,xs:6,sx:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:[(0,o.jsx)(a.default,{sx:{mb:3},children:(0,o.jsx)(e2,{nodeData:y,setNodeData:j})}),(0,o.jsx)(a.default,{sx:{mb:3},children:(0,o.jsx)(e9,{isLoadingModels:U,loadError:J,models:G,selectedModelId:ec,handleModelSelect:Y,isModelBound:k,handleUnbindModel:$})}),(0,o.jsxs)(a.default,{sx:{mb:3},children:[(0,o.jsx)(a.default,{sx:{borderBottom:1,borderColor:"divider",mb:2},children:(0,o.jsxs)(eY.A,{value:H,onChange:(e,t)=>_(t),children:[(0,o.jsx)(e$.A,{label:"Server Tools",value:"server"}),(0,o.jsx)(e$.A,{label:"Resources",value:"resources"}),(0,o.jsx)(e$.A,{label:"Agent Tools",value:"agent"})]})}),"server"===H&&(0,o.jsx)(td,{isLoadingServers:Z,connectedMcpNodes:V,availableServers:X,onConnectMcpServer:v,serverStatuses:Q,serverToolsMap:K,isLoadingTools:ee,handleInsertToolBinding:ed,selectedToolServerNodeId:q,selectedNodeId:(null==l?void 0:l.id)||null,handleSelectToolServer:et,isLoadingSelectedServerTools:en,promptBuilderRef:ei,handleRetryServer:eo,handleRestartServer:er}),"resources"===H&&(0,o.jsx)(th,{connectedMcpNodes:V,handleInsertResourceBinding:(e,t)=>{if(!e||!t)return void tI.warn("Invalid parameters for handleInsertResourceBinding:",{serverName:e,uri:t});let n=(0,eW.X8)("resource",e,t),o=C.length>0&&!C.endsWith(" ")&&!C.endsWith("\n");ei.current?ei.current.insertText((o?" ":"")+n):tI.warn("promptBuilderRef.current is null, cannot insert resource binding")},promptBuilderRef:ei}),"agent"===H&&(0,o.jsx)(tm,{handoffTools:ea,isLoadingHandoffTools:es,handleInsertToolBinding:(e,t)=>ed(e,t,"handoff"),promptBuilderRef:ei})]}),(0,o.jsx)(a.default,{children:(0,o.jsx)(tT,{nodeData:y,handlePropertyChange:w,properties:[{key:"maxTurns",label:"Max Turns (override)",type:"number",min:1,helperText:"Optional. Overrides the bound model's Max Turns for this node. Leave empty to inherit the model setting (default 50)."}]})})]}),(0,o.jsx)(eJ.Ay,{item:!0,xs:6,sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,o.jsx)(tS,{ref:ei,promptTemplate:C,handlePromptChange:e=>{A(e),j(t=>t?{...t,properties:{...t.properties,promptTemplate:e}}:null)},excludeModelPrompt:T,setExcludeModelPrompt:I,excludeStartNodePrompt:P,setExcludeStartNodePrompt:F,excludeSystemPrompt:E,setExcludeSystemPrompt:D,inputMode:z,setInputMode:R,isolatedPrompt:W,setIsolatedPrompt:L,outputMode:B,setOutputMode:O,isModelBound:k,models:G,nodeData:y,flowId:g})})]})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:d,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:()=>{if(l&&y){let e={...y,properties:{...y.properties,promptTemplate:C,excludeModelPrompt:T,excludeStartNodePrompt:P,excludeSystemPrompt:E,inputMode:z,isolatedPrompt:W,outputMode:B}};u(l.id,e),d()}},variant:"contained",color:"primary",children:"Save Changes"})]})]})};var tP=n(71651),tF=n(94035);let tE=(0,k.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/MCPNodePropertiesModal"),tD=e=>{var t,n,l,d,p,h,g,y;let{open:j,node:w,onClose:C,onSave:k}=e,[N,T]=(0,r.useState)(null),{servers:I,isLoading:M,loadError:P,retryServer:F}=(0,eq.v)(),[E,D]=(0,r.useState)({}),{tools:z,isLoading:R,error:W,loadTools:L}=(0,tF.O)((null==N||null==(t=N.properties)?void 0:t.boundServer)||"");(0,r.useEffect)(()=>{w&&T({...w.data,properties:{...w.data.properties}})},[w,j]);let B=(null==N||null==(n=N.properties)?void 0:n.boundServer)||"";(0,r.useEffect)(()=>{z&&z.length>0&&(e=>{N&&0===(N.properties.enabledTools||[]).length&&e.length>0&&(tE.debug("Enabling all tools by default"),T(t=>t?{...t,properties:{...t.properties,enabledTools:e.map(e=>e.name)}}:null))})(z)},[z]);let O=(e,t)=>{T(n=>n?{...n,properties:{...n.properties,[e]:t}}:null)},H=async(e,t)=>{t&&t.stopPropagation(),tE.debug("Retrying server: ".concat(e)),D(t=>({...t,[e]:!0}));try{return await F(e),e===B&&L(!0),!0}catch(t){return tE.warn("Failed to retry server ".concat(e,": ").concat(t)),!1}finally{setTimeout(()=>{D(t=>({...t,[e]:!1}))},500)}};if(!w||!N)return null;let _=(null==(l=N.properties)?void 0:l.boundServer)||"",G=(null==(d=N.properties)?void 0:d.enabledTools)||[],Y=null==(p=N.properties)?void 0:p.toolTimeout,$=-1===Y;return(0,o.jsxs)(f.A,{open:j,onClose:C,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"info.main",height:"80vh",maxHeight:"80vh"}},children:[(0,o.jsx)(m.A,{component:"div",children:(0,o.jsxs)(a.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,o.jsxs)(s.default,{variant:"h6",children:[N.label||"MCP Node"," Properties"]}),(0,o.jsx)(c.A,{edge:"end",color:"inherit",onClick:C,"aria-label":"close",children:(0,o.jsx)(eV.A,{})})]})}),(0,o.jsx)(S.A,{}),(0,o.jsxs)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto"},children:[(0,o.jsx)(v.A,{fullWidth:!0,label:"Node Label",value:N.label||"",onChange:e=>{T(t=>t?{...t,label:e.target.value,properties:{...t.properties,nameIsCustom:!0}}:null)},margin:"normal",helperText:"The display name for this node on the canvas",sx:{mb:2}}),(0,o.jsxs)(a.default,{sx:{mb:4},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Bind to MCP Server"}),M?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(eI.default,{size:20}),(0,o.jsx)(s.default,{color:"text.secondary",children:"Loading MCP servers..."})]}):P?(0,o.jsx)(s.default,{color:"error",children:P}):0===I.length?(0,o.jsx)(s.default,{color:"text.secondary",children:"No MCP servers available. Add some in the MCP Manager."}):(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(e5.A,{component:"fieldset",fullWidth:!0,children:[(0,o.jsx)(e4.A,{value:_,onChange:e=>(e=>{tE.debug("Server selected: ".concat(e)),tE.debug("Server selected: ".concat(e)),T(t=>{var n,o;if(!t)return null;let r=eX({currentLabel:t.label,nameIsCustom:null==(n=t.properties)?void 0:n.nameIsCustom,defaultLabel:"MCP Node",previousAutoLabel:(null==(o=t.properties)?void 0:o.boundServer)||void 0,nextAutoLabel:e});return{...t,label:r,properties:{...t.properties,boundServer:e}}})})(e.target.value),children:(0,o.jsx)(eJ.Ay,{container:!0,spacing:2,children:I.map(e=>(0,o.jsx)(eJ.Ay,{item:!0,xs:12,sm:6,children:(0,o.jsx)(A.A,{elevation:1,sx:{p:2,border:2*(_===e.name),borderColor:"primary.main",opacity:"connected"===e.status?1:.6},children:(0,o.jsxs)(a.default,{sx:{display:"flex",width:"100%",alignItems:"flex-start"},children:[(0,o.jsx)(e6.A,{value:e.name,control:(0,o.jsx)(e8.A,{}),label:(0,o.jsxs)(a.default,{children:[(0,o.jsx)(s.default,{variant:"subtitle2",children:e.name}),(0,o.jsx)(s.default,{variant:"caption",color:"text.secondary",display:"block",children:e.path}),(0,o.jsxs)(s.default,{variant:"caption",color:"connected"===e.status?"success.main":"error"===e.status?"error.main":"text.secondary",children:["Status: ",e.status]})]}),sx:{width:"calc(100% - 40px)",m:0}}),(0,o.jsx)(u.A,{title:"Retry connection",children:(0,o.jsx)(c.A,{size:"small",onClick:t=>H(e.name,t),disabled:E[e.name],sx:{mt:1},children:E[e.name]?(0,o.jsx)(eI.default,{size:16}):(0,o.jsx)(tr.A,{fontSize:"small"})})})]})})},e.name))})}),(0,o.jsx)(e3.A,{children:_?'This node will use the "'.concat(_,'" MCP server for processing.'):"Select an MCP server to bind this node to."})]})})]}),(0,o.jsx)(v.A,{fullWidth:!0,label:"Description",value:N.description||"",onChange:e=>T({...N,description:e.target.value}),margin:"normal",multiline:!0,rows:2,helperText:"This description will be displayed on the node"}),_&&(0,o.jsxs)(a.default,{sx:{mt:4},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Tool Call Timeout"}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"How long a single tool call on this server may run before it is aborted. Tools that report progress keep the timeout alive while they work."}),(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,o.jsx)(v.A,{label:"Timeout (seconds)",type:"number",size:"small",sx:{width:200},value:$?"":null!=Y?Y:"",placeholder:String(300),disabled:$,inputProps:{min:1},onChange:e=>{let t=e.target.value;if(""===t)return void O("toolTimeout",void 0);let n=parseInt(t,10);!isNaN(n)&&n>0&&O("toolTimeout",n)},helperText:$?"No timeout — tool calls run until they finish.":"Empty = default (".concat(300," seconds / 5 minutes).")}),(0,o.jsx)(e6.A,{control:(0,o.jsx)(tx.A,{checked:$,onChange:e=>O("toolTimeout",e.target.checked?-1:void 0)}),label:"No timeout (infinite)"})]})]}),_&&(0,o.jsxs)(a.default,{sx:{mt:4},children:[(0,o.jsx)(s.default,{variant:"subtitle1",gutterBottom:!0,children:"Allowed Tools"}),(null==(h=I.find(e=>e.name===_))?void 0:h.status)!=="connected"&&(0,o.jsxs)(a.default,{sx:{mb:2,p:2,bgcolor:"error.light",borderRadius:1},children:[(0,o.jsx)(s.default,{color:"error.dark",children:"Server is disconnected. Tools cannot be fetched. Please retry the connection."}),(0,o.jsx)(i.A,{variant:"outlined",size:"small",color:"primary",startIcon:E[_]?(0,o.jsx)(eI.default,{size:16}):(0,o.jsx)(tr.A,{}),onClick:()=>H(_),disabled:E[_],sx:{mt:1},children:"Retry Connection"})]}),R?(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(eI.default,{size:20}),(0,o.jsx)(s.default,{color:"text.secondary",children:"Loading tools..."})]}):W?(0,o.jsx)(s.default,{color:"error",children:W}):z&&0!==z.length?(0,o.jsxs)(a.default,{sx:{mt:2},children:[(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Select which tools this node will have access to. This helps limit the tools available to connected process nodes."}),(0,o.jsx)(eM.A,{children:z.map(e=>(0,o.jsxs)(eF.Ay,{sx:{py:0},children:[(0,o.jsx)(U.A,{sx:{minWidth:42},children:(0,o.jsx)(tx.A,{edge:"start",checked:G.includes(e.name),onChange:()=>(e=>{tE.debug("Tool toggled: ".concat(e)),T(t=>{let n;if(!t)return null;let o=t.properties.enabledTools||[];return n=o.includes(e)?o.filter(t=>t!==e):[...o,e],{...t,properties:{...t.properties,enabledTools:n}}})})(e.name)})}),(0,o.jsx)(J.A,{primary:e.name,secondary:e.description,primaryTypographyProps:{fontWeight:"medium"}})]},e.name))})]}):(0,o.jsx)(s.default,{color:"text.secondary",children:(null==(g=I.find(e=>e.name===_))?void 0:g.status)==="connected"?"No tools available for this MCP server.":"Connect to the server to view available tools."})]}),_&&(0,o.jsxs)(a.default,{sx:{mt:4},children:[(0,o.jsx)(tP.A,{roots:(null==(y=N.properties)?void 0:y.roots)||[],onChange:e=>O("roots",e)}),(0,o.jsxs)(s.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:["These folders apply to this node only and are ",(0,o.jsx)("strong",{children:"added to"}),' the workspace folders configured on the "',_,'" server itself. When neither is set, the server sees its own root dir as its workspace folder.']})]})]}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:C,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:()=>{w&&N&&(k(w.id,N),C())},variant:"contained",color:"primary",children:"Save Changes"})]})]})},tz=e=>{let{open:t,node:n,onClose:l,onSave:d}=e,[u,p]=(0,r.useState)(null),[h,g]=(0,r.useState)("");return((0,r.useEffect)(()=>{if(n){var e;p({...n.data,properties:{...n.data.properties}}),g((null==(e=n.data.properties)?void 0:e.promptTemplate)||"")}},[n,t]),n&&u)?(0,o.jsxs)(f.A,{open:t,onClose:l,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,o.jsx)(m.A,{component:"div",children:(0,o.jsxs)(a.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,o.jsxs)(s.default,{variant:"h6",children:[u.label||"Start Node"," Properties"]}),(0,o.jsx)(c.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,o.jsx)(eV.A,{})})]})}),(0,o.jsx)(S.A,{}),(0,o.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto",height:"calc(90vh - 130px)"},children:(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,o.jsx)(s.default,{variant:"h6",gutterBottom:!0,children:"Prompt Template"}),(0,o.jsx)(a.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 40px)"},children:(0,o.jsx)(tw.A,{value:h,onChange:e=>{g(e),p(t=>t?{...t,properties:{...t.properties,promptTemplate:e}}:null)},label:"",height:"100%"})})]})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:l,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:()=>{if(n&&u){let e={...u,properties:{...u.properties,promptTemplate:h}};d(n.id,e),l()}},variant:"contained",color:"primary",children:"Save Changes"})]})]}):null},tR=e=>{let{open:t,node:n,onClose:l,onSave:d}=e,[u,p]=(0,r.useState)(null);return((0,r.useEffect)(()=>{n&&p({...n.data,properties:{...n.data.properties}})},[n,t]),n&&u)?(0,o.jsxs)(f.A,{open:t,onClose:l,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"success.main",width:"600px",height:"400px",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,o.jsx)(m.A,{component:"div",children:(0,o.jsxs)(a.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,o.jsxs)(s.default,{variant:"h6",children:[u.label||"Finish Node"," Properties"]}),(0,o.jsx)(c.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,o.jsx)(eV.A,{})})]})}),(0,o.jsx)(S.A,{}),(0,o.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto"},children:(0,o.jsx)(a.default,{sx:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"center",alignItems:"center",py:4},children:(0,o.jsxs)(A.A,{elevation:0,sx:{p:4,textAlign:"center",backgroundColor:"rgba(76, 175, 80, 0.08)",borderRadius:2,width:"100%"},children:[(0,o.jsx)(s.default,{variant:"h6",color:"success.main",gutterBottom:!0,children:"Finish Node"}),(0,o.jsx)(s.default,{variant:"body1",color:"text.secondary",children:"This is the end point of your flow. No additional configuration is needed."}),(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mt:2,fontStyle:"italic"},children:"Future versions will support output formatting options."})]})})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:l,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:()=>{n&&u&&(d(n.id,u),l())},variant:"contained",color:"primary",children:"Save"})]})]}):null},tW=(0,k.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/SubflowNodePropertiesModal"),tL=e=>{var t,n,l,d,u;let{open:p,node:g,onClose:y,onSave:j,flowId:w}=e,[C,A]=(0,r.useState)(null),[k,N]=(0,r.useState)([]),[T,M]=(0,r.useState)(!1);(0,r.useEffect)(()=>{g&&A({...g.data,properties:{...g.data.properties}})},[g,p]),(0,r.useEffect)(()=>{if(!p)return;let e=!1;return M(!0),I.g.loadFlows().then(t=>{e||N(t||[])}).catch(t=>{tW.warn("Failed to load flows for subflow picker",t),e||N([])}).finally(()=>{e||M(!1)}),()=>{e=!0}},[p]);let P=(e,t)=>{A(n=>n?{...n,properties:{...n.properties,[e]:t}}:null)};if(!g||!C)return null;let F=k.filter(e=>e.id!==w),E=(null==(t=C.properties)?void 0:t.subflowId)||"",D=!!E&&!k.some(e=>e.id===E),z=(null==(n=C.properties)?void 0:n.promptTemplate)||"",R=(null==(l=C.properties)?void 0:l.inputMode)||(z.trim()?"isolated":"full-history");return(0,o.jsxs)(f.A,{open:p,onClose:y,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"warning.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,o.jsx)(m.A,{component:"div",children:(0,o.jsxs)(a.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,o.jsxs)(s.default,{variant:"h6",children:[C.label||"Subflow Node"," Properties"]}),(0,o.jsx)(c.A,{edge:"end",color:"inherit",onClick:y,"aria-label":"close",children:(0,o.jsx)(eV.A,{})})]})}),(0,o.jsx)(S.A,{}),(0,o.jsxs)(x.A,{sx:{p:3},children:[(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This step runs another flow inside this one — like calling a helper. When it finishes, its answer becomes part of this conversation and the flow continues to the next node."}),(0,o.jsx)(v.A,{fullWidth:!0,label:"Node Label",value:C.label||"",onChange:e=>A({...C,label:e.target.value}),margin:"normal"}),(0,o.jsxs)(e5.A,{fullWidth:!0,margin:"normal",children:[(0,o.jsx)(tk.A,{id:"subflow-select-label",children:"Flow to run"}),(0,o.jsxs)(tN.A,{labelId:"subflow-select-label",label:"Flow to run",value:D?"":E,onChange:e=>P("subflowId",e.target.value),displayEmpty:!0,children:[0===F.length&&(0,o.jsx)(G.A,{value:"",disabled:!0,children:T?"Loading flows…":"No other flows available"}),F.map(e=>(0,o.jsx)(G.A,{value:e.id,children:e.name},e.id))]})]}),D&&(0,o.jsx)(h.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),(0,o.jsx)(s.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"What does the subflow receive?"}),(0,o.jsxs)(a.default,{role:"radiogroup","aria-label":"Subflow input",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,o.jsx)(tC,{selected:"full-history"===R,onClick:()=>P("inputMode","full-history"),icon:(0,o.jsx)(tg.A,{}),title:"Full conversation",description:"The subflow sees the whole conversation so far. Best for a helper that should continue with all the context."}),(0,o.jsx)(tC,{selected:"latest-message"===R,onClick:()=>P("inputMode","latest-message"),icon:(0,o.jsx)(tv.A,{}),title:"Latest message only",description:"The subflow sees only the most recent message. Best for an orchestrator that hands off one task at a time, so old tasks don't leak in."}),(0,o.jsx)(tC,{selected:"isolated"===R,onClick:()=>P("inputMode","isolated"),icon:(0,o.jsx)(tb.A,{}),title:"Isolated",description:"The conversation is ignored. The subflow receives only the prompt you write below, as its first message."})]}),"isolated"===R&&(0,o.jsx)(v.A,{fullWidth:!0,label:"Isolated prompt",value:z,onChange:e=>P("promptTemplate",e.target.value),margin:"normal",multiline:!0,rows:3,helperText:"Sent to the subflow as its single user message. The parent conversation is not passed."}),(0,o.jsx)(s.default,{variant:"subtitle2",sx:{mt:3,mb:1},children:"What do you see in the chat while the subflow runs?"}),(0,o.jsxs)(a.default,{role:"radiogroup","aria-label":"Subflow output",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,o.jsx)(tC,{selected:"final-only"!==((null==(d=C.properties)?void 0:d.outputMode)||"steps"),onClick:()=>P("outputMode","steps"),icon:(0,o.jsx)(ty.A,{}),title:"Full",description:"You see all of the subflow's messages in the chat, indented under this step — like watching it work."}),(0,o.jsx)(tC,{selected:(null==(u=C.properties)?void 0:u.outputMode)==="final-only",onClick:()=>P("outputMode","final-only"),icon:(0,o.jsx)(tj.A,{}),title:"Condensed",description:"You only see the subflow's final answer as a single message. Its inner steps stay hidden."})]})]}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:y,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:()=>{g&&C&&(j(g.id,C),y())},variant:"contained",color:"primary",children:"Save"})]})]})};var tB=n(31102),tO=n(18581),tH=n(13179);let t_=(0,k.h)("components/flow/FlowBuilder/index.tsx"),tG=(0,C.Ay)(a.default)(e=>{let{theme:t}=e;return{display:"flex",height:"calc(100vh - 64px)",gap:"16px",padding:"16px",backgroundColor:t.palette.background.default}}),tU=(0,C.Ay)(A.A)(e=>{let{theme:t}=e;return{padding:t.spacing(1),display:"flex",gap:t.spacing(1),borderBottom:"1px solid",borderColor:t.palette.divider,alignItems:"center",marginBottom:t.spacing(1),backgroundColor:t.palette.background.paper,boxShadow:t.shadows[1]}}),tJ=(0,C.Ay)(a.default)({flex:1,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"}),tY=r.forwardRef((e,t)=>{let{initialFlow:n,onSave:l,onDelete:s,allFlows:d}=e;t_.debug("FlowBuilder rendered with initialFlow:",n);let[u,p]=(0,r.useState)((null==n?void 0:n.nodes)||[]),[h,y]=(0,r.useState)(((null==n?void 0:n.edges)||[]).filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle)),[j,w]=(0,r.useState)((null==n?void 0:n.name)||"NewFlow"),[C,A]=(0,r.useState)(null),[k,P]=(0,r.useState)((null==n?void 0:n.description)||""),[F,E]=(0,r.useState)(!1),[D,z]=(0,r.useState)("none"),[R,W]=(0,r.useState)(""),[B,O]=(0,r.useState)(null),[H,_]=(0,r.useState)(!1),[G,U]=(0,r.useState)(!1),[J,Y]=(0,r.useState)(!1),[$,V]=(0,r.useState)(!1),[X,Z]=(0,r.useState)(!1),[q,K]=(0,r.useState)(null),[Q,ee]=(0,r.useState)([]),[et,en]=(0,r.useState)(-1),[eo,er]=(0,r.useState)(!1),[el,ea]=(0,r.useState)(!1),es=(0,r.useRef)(null),ei=(0,r.useRef)(!1),ed=(0,r.useRef)(!0),ec=(0,r.useCallback)(e=>e.filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle),[]);(0,r.useEffect)(()=>{if(ed.current=!0,n){p(n.nodes||[]);let e=ec(n.edges||[]);e.length!==n.edges.length&&console.warn("Filtered out ".concat(n.edges.length-e.length," invalid edges")),y(e),w(n.name),P(n.description||""),ee([{nodes:n.nodes||[],edges:e}]),en(0)}else{let e=I.g.createStartNode();p([e]),y([]),w("NewFlow"),P(""),ee([{nodes:[e],edges:[]}]),en(0)}},[n]);let eu=e=>JSON.stringify(e,(e,t)=>"selected"===e||"dragging"===e||"measured"===e||"width"===e||"height"===e||"positionAbsolute"===e||"resizing"===e?void 0:t);(0,r.useEffect)(()=>{if(eo)return void er(!1);if(ed.current){ed.current=!1;return}if(ei.current)return;let e={nodes:[...u],edges:[...h]},t=Q.slice(0,et+1);(et<0||eu(e)!==eu(t[et]))&&(ee([...t,e]),en(et+1),ea(!0))},[u,h]),(0,r.useEffect)(()=>{let e=e=>{if(el)return e.preventDefault(),e.returnValue="",""};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[el]);let ep=e=>e.trim()?/^[\w-]+$/.test(e)?(!n||n&&n.name!==e)&&d.some(t=>t.id!==((null==n?void 0:n.id)||"")&&t.name.toLowerCase()===e.toLowerCase())?"A flow with this name already exists":null:"Flow name can only contain letters, numbers, underscores, and dashes":"Flow name cannot be empty",eh=(0,r.useCallback)(()=>{t_.debug('handleSave: Attempting to save flow "'.concat(j,'"'));let e=ep(j);if(e)return t_.warn("handleSave: Invalid flow name - ".concat(e)),A(e),"invalid-name";let t=[...u];if(0===t.length&&(t_.debug("handleSave: No nodes found, adding a default Start node"),p(t=[I.g.createStartNode()])),n&&n.name!==j)return t_.debug('handleSave: Flow name changed from "'.concat(n.name,'" to "').concat(j,'", opening rename dialog')),z("rename"),W(j),E(!0),"rename-dialog";let o={id:(null==n?void 0:n.id)||(0,T.A)(),name:j,description:k,nodes:t,edges:h};return t_.info('handleSave: Saving flow "'.concat(j,'" with ').concat(t.length," nodes and ").concat(h.length," edges")),l(o),ea(!1),"saved"},[j,k,u,h,n,l,d]);r.useImperativeHandle(t,()=>({requestNavigation:e=>{el?(es.current=e,z("unsaved"),E(!0)):e()}}),[el]);let ef=(0,r.useCallback)(()=>{n?(t_.info('handleDelete: Deleting flow "'.concat(n.name,'" (ID: ').concat(n.id,")")),s(n.id)):t_.warn("handleDelete: Attempted to delete flow but no initialFlow is available")},[n,s]),em=(0,r.useCallback)((e,t)=>{t_.debug('handleCopyFlow: Copying flow "'.concat(e.name,'" to "').concat(t,'"'));let n={id:(0,T.A)(),name:t,description:e.description,nodes:e.nodes,edges:e.edges};t_.info('handleCopyFlow: Created copy of flow "'.concat(e.name,'" with new name "').concat(t,'" (').concat(e.nodes.length," nodes, ").concat(e.edges.length," edges)")),l(n)},[l]),eg=()=>{let e=es.current;es.current=null,e&&e()},ev=()=>{es.current=null,E(!1),z("none"),W(""),O(null)},eb=()=>{let e=ep(R);if(e)return void O(e);"duplicate"===D?n&&em(n,R):"rename"===D&&(l({id:(null==n?void 0:n.id)||(0,T.A)(),name:R,description:k,nodes:u,edges:h}),ea(!1),eg()),ev()},ey=et>0,ej=et<Q.length-1,ew=(0,r.useCallback)(()=>{if(ey){t_.debug("handleUndo: Performing undo operation, moving from history index ".concat(et," to ").concat(et-1)),er(!0);let e=et-1,t=Q[e];p(t.nodes),y(t.edges),en(e),t_.info("handleUndo: Restored flow state to previous version (".concat(t.nodes.length," nodes, ").concat(t.edges.length," edges)"))}},[Q,et,ey]),eC=(0,r.useCallback)(()=>{if(ej){t_.debug("handleRedo: Performing redo operation, moving from history index ".concat(et," to ").concat(et+1)),er(!0);let e=et+1,t=Q[e];p(t.nodes),y(t.edges),en(e),t_.info("handleRedo: Restored flow state to next version (".concat(t.nodes.length," nodes, ").concat(t.edges.length," edges)"))}},[Q,et,ej]),eA=(0,r.useCallback)(e=>{for(let t of e)"position"===t.type&&(ei.current=!0===t.dragging);p(t=>(0,N._0)(e,t))},[]),eS=(0,r.useCallback)(e=>{t_.debug("onEdgesChange: Processing ".concat(e.length," edge changes")),e.forEach(e=>{"remove"===e.type?t_.info("onEdgesChange: Edge ".concat(e.id," removed")):"select"===e.type&&t_.debug("onEdgesChange: Edge ".concat(e.id," selection changed to ").concat(e.selected))}),y(t=>(0,N.zW)(e,t))},[]),ek=(0,r.useRef)(null),[eT,eI]=(0,r.useState)(null),eM=(0,r.useCallback)((e,t)=>{t_.debug("handleNodeUpdate: Updating node ".concat(e," properties")),p(n=>n.map(n=>n.id===e?(t_.info("handleNodeUpdate: Node ".concat(e," properties updated")),{...n,data:t}):n)),_(!1),U(!1),Y(!1),V(!1),Z(!1),K(null),t_.debug("handleNodeUpdate: Closed property modals")},[]),eP=(0,r.useCallback)(async(e,t)=>{var n;let o=u.find(t=>t.id===e);if(!o)return void t_.warn("handleConnectMcpServer: process node ".concat(e," not found"));let r=[];try{let e=await M.S.listServerTools(t);!e.error&&Array.isArray(e.tools)&&(r=e.tools.map(e=>e.name))}catch(e){t_.warn("handleConnectMcpServer: could not load tools for ".concat(t),e)}let l=h.filter(t=>{var n;return(null==(n=t.data)?void 0:n.edgeType)==="mcp"&&(t.source===e||t.target===e)}).length,a=I.g.createNode("mcp",{x:o.position.x+350,y:o.position.y+120*l});a.data.label=t,a.data.properties={...null!=(n=a.data.properties)?n:{},boundServer:t,enabledTools:r};let s=L({source:e,sourceHandle:"process-right-mcp",target:a.id,targetHandle:"mcp-left"},[...u,a]);p(e=>[...e,a]),y(e=>[...e,s]),t_.info('Connected MCP server "'.concat(t,'" to process node ').concat(e))},[u,h]),eF=(0,r.useCallback)(e=>{t_.debug("Opening properties for node:",e),K(e),"mcp"===e.data.type?U(!0):"start"===e.data.type?Y(!0):"finish"===e.data.type?V(!0):"subflow"===e.data.type?Z(!0):_(!0)},[]),eE=(0,r.useCallback)(e=>{t_.debug("onDrop: Node dropped on canvas"),e.preventDefault();let t=e.dataTransfer.getData("application/reactflow");if(t_.debug("onDrop: Node type from data transfer: ".concat(t)),!t||!eT)return void t_.debug("onDrop: Missing required data - type: ".concat(!!t,", reactFlowInstance: ").concat(!!eT));let n=eT.screenToFlowPosition({x:e.clientX,y:e.clientY});t_.debug("onDrop: Calculated position: (".concat(n.x,", ").concat(n.y,")"));let o=I.g.createNode(t,n);t_.info("onDrop: Created new ".concat(t," node with ID: ").concat(o.id)),p(e=>[...e.map(e=>({...e,selected:!1})),{...o,selected:!0}]),eF(o),t_.debug("onDrop: Opened properties modal for new node: ".concat(o.id))},[eT,eF]),eD=(0,r.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},[]),ez=(0,r.useCallback)(e=>{t_.debug("onInit: ReactFlow instance initialized"),eI(e)},[]);return(0,o.jsxs)(tG,{children:[(0,o.jsx)(eN,{}),(0,o.jsx)(N.Ln,{children:(0,o.jsxs)(tJ,{children:[(0,o.jsxs)(tU,{elevation:1,children:[(0,o.jsx)(v.A,{size:"small",label:"Flow Name",value:j,onChange:e=>{let t=e.target.value;w(t),A(ep(t))},sx:{minWidth:300},error:!!C,helperText:C}),(0,o.jsx)(v.A,{size:"small",label:"Description",value:k,onChange:e=>{P(e.target.value),ea(!0)},multiline:!0,maxRows:3,sx:{minWidth:300,flex:1},placeholder:"Optional — shown on the flow card"}),(0,o.jsx)(i.A,{variant:"contained",color:"primary",onClick:eh,startIcon:(0,o.jsx)(tB.A,{}),disabled:!!C,children:"Save Flow"}),(0,o.jsx)(eU,{nodes:u,edges:h}),n&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{variant:"outlined",color:"primary",onClick:()=>{z("duplicate"),W("".concat(n.name,"_copy")),E(!0)},children:"Copy Flow"}),(0,o.jsx)(i.A,{variant:"outlined",color:"error",onClick:ef,children:"Delete Flow"})]}),(0,o.jsx)(S.A,{orientation:"vertical",flexItem:!0}),(0,o.jsx)(c.A,{onClick:ew,disabled:!ey,color:"primary",size:"small",children:(0,o.jsx)(tO.A,{})}),(0,o.jsx)(c.A,{onClick:eC,disabled:!ej,color:"primary",size:"small",children:(0,o.jsx)(tH.A,{})}),(0,o.jsx)(a.default,{sx:{flex:1}})]}),(0,o.jsx)(a.default,{sx:{flex:1,position:"relative"},children:(0,o.jsx)(ex,{ref:ek,nodes:u,edges:h,onNodesChange:eA,onEdgesChange:eS,onDrop:eE,onDragOver:eD,onInit:ez,reactFlowWrapper:ek,onEditNode:eF})})]})}),(0,o.jsx)(tM,{open:H,node:q,onClose:()=>_(!1),onSave:eM,flowEdges:h,flowNodes:u,flowId:null==n?void 0:n.id,onConnectMcpServer:e=>{q&&eP(q.id,e)}}),(0,o.jsx)(tD,{open:G,node:q,onClose:()=>U(!1),onSave:eM}),(0,o.jsx)(tz,{open:J,node:q,onClose:()=>Y(!1),onSave:eM}),(0,o.jsx)(tR,{open:$,node:q,onClose:()=>V(!1),onSave:eM}),(0,o.jsx)(tL,{open:X,node:q,onClose:()=>Z(!1),onSave:eM,flowId:null==n?void 0:n.id}),(0,o.jsxs)(f.A,{open:F,onClose:ev,children:[(0,o.jsx)(m.A,{children:"duplicate"===D?"Copy Flow":"rename"===D?"Rename Flow":"Unsaved Changes"}),(0,o.jsx)(x.A,{children:"unsaved"===D?(0,o.jsx)(g.A,{children:"You have unsaved changes in the current flow. What would you like to do?"}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(g.A,{children:"duplicate"===D?"Enter a name for the copied flow:":"You are changing the name of this flow. Do you want to rename it or create a copy with the new name?"}),(0,o.jsx)(v.A,{autoFocus:!0,margin:"dense",label:"Flow Name",type:"text",fullWidth:!0,value:R,onChange:e=>{let t=e.target.value;W(t),O(ep(t))},error:!!B,helperText:B,sx:{mt:2}})]})}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:ev,children:"Cancel"}),"unsaved"===D&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{onClick:()=>{ea(!1),eg(),ev()},color:"error",children:"Discard Changes"}),(0,o.jsx)(i.A,{onClick:()=>{let e=eh();"saved"===e?(eg(),ev()):"invalid-name"===e&&ev()},variant:"contained",color:"primary",children:"Save Changes"})]}),"rename"===D&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{onClick:()=>{let e=ep(R);if(e)return void O(e);n&&em(n,R),ev()},children:"Copy"}),(0,o.jsx)(i.A,{onClick:eb,variant:"contained",color:"primary",disabled:!!B,children:"Rename"})]}),"duplicate"===D&&(0,o.jsx)(i.A,{onClick:eb,variant:"contained",color:"primary",disabled:!!B,children:"Copy"})]})]})]})});tY.displayName="FlowBuilder";var t$=n(22822);let tV=(0,k.h)("frontend/components/Flow/FlowManager/GenerateFlowDialog"),tX=e=>{let{open:t,onClose:n,onGenerated:l}=e,[s,d]=(0,r.useState)(""),[c,u]=(0,r.useState)([]),[p,y]=(0,r.useState)(""),[j,C]=(0,r.useState)(!1),[A,S]=(0,r.useState)(!1),[k,N]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!t)return;let e=!1;return e_.N.loadModels().then(t=>{e||(u(t),y(e=>{var n,o;return t.some(t=>t.id===e)?e:null!=(o=null==(n=t[0])?void 0:n.id)?o:""}))}).catch(t=>{tV.warn("Failed to load models for the generate dialog",t),e||N("Could not load your models. Configure a model first.")}),()=>{e=!0}},[t]);let T=(0,r.useCallback)(()=>{A||(N(null),n())},[A,n]),M=(0,r.useCallback)(async()=>{N(null),S(!0);try{let e=await I.g.generateFlow(s.trim(),p,{allowInstall:j});if(!e.success)return void N(e.error);tV.info("Draft flow generated",{flowId:e.flow.id,attempts:e.attempts,errors:e.validation.errorCount,warnings:e.validation.warningCount,installedServers:e.installedServers.length}),d(""),l({flow:e.flow,errorCount:e.validation.errorCount,warningCount:e.validation.warningCount,attempts:e.attempts,installedServers:e.installedServers})}finally{S(!1)}},[s,p,j,l]),P=!A&&s.trim().length>0&&!!p;return(0,o.jsxs)(f.A,{open:t,onClose:T,maxWidth:"sm",fullWidth:!0,children:[(0,o.jsx)(m.A,{children:"Generate a flow"}),(0,o.jsxs)(x.A,{children:[(0,o.jsx)(g.A,{sx:{mb:2},children:"Describe what the flow should do — which steps, which tools, what the result is. The generated flow opens in the builder as a draft for you to review before saving."}),k&&(0,o.jsx)(h.A,{severity:"error",sx:{mb:2},onClose:()=>N(null),children:k}),(0,o.jsx)(v.A,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:4,label:"What should this flow do?",placeholder:"e.g. Research a topic on the web, then summarize the findings as bullet points",value:s,onChange:e=>d(e.target.value),disabled:A,sx:{mb:2}}),(0,o.jsxs)(e5.A,{fullWidth:!0,disabled:A||0===c.length,children:[(0,o.jsx)(tk.A,{id:"generate-flow-model-label",children:"Generator model"}),(0,o.jsx)(tN.A,{labelId:"generate-flow-model-label",label:"Generator model",value:p,onChange:e=>y(e.target.value),children:c.map(e=>{var t;return(0,o.jsx)(G.A,{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),(0,o.jsx)(e6.A,{sx:{mt:2},control:(0,o.jsx)(t$.A,{checked:j,onChange:e=>C(e.target.checked),disabled:A}),label:"Let the generator install MCP servers it needs (self-improve)"}),j&&(0,o.jsxs)(h.A,{severity:"warning",sx:{mt:1},children:["The generator may ",(0,o.jsx)("strong",{children:"download, install, and run third-party MCP servers"})," from the public registry on this machine — without asking again. It prefers servers that need no API keys, but anything it installs executes real code with your user's permissions. Installed servers stay configured afterwards (remove them on the MCP page)."]}),A&&(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center",gap:1.5,mt:2},children:[(0,o.jsx)(eI.default,{size:20}),(0,o.jsx)(g.A,{children:j?"Generating… the model may search the marketplace and install servers (this can take a few minutes).":"Generating… the model designs the flow and FLUJO checks it (this can take up to a minute)."})]})]}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:T,disabled:A,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:M,variant:"contained",color:"primary",startIcon:(0,o.jsx)(w.A,{}),disabled:!P,children:"Generate"})]})]})};var tZ=n(60530),tq=n(15712),tK=n(64419),tQ=n(98405),t0=n(7302),t1=n(70822),t2=n(28466),t5=n(3986),t4=n(94885),t6=n(15686),t8=n(91665),t3=n(8532),t7=n(53062),t9=n(1702),ne=n(20699),nt=n(89296),nn=n(81956);let no=(0,k.h)("components/Flow/FlowDashboard/FlowCard"),nr=(0,C.Ay)(tn.A,{shouldForwardProp:e=>"selected"!==e})(e=>{let{theme:t,selected:n}=e;return{display:"flex",flexDirection:"column",height:"100%",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",position:"relative",border:n?"2px solid ".concat(t.palette.primary.main):"none",boxShadow:n?t.shadows[4]:t.shadows[1],"&:hover":{boxShadow:t.shadows[6],transform:"translateY(-4px)"},"&::before":n?{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"4px",backgroundColor:t.palette.primary.main}:{}}}),nl=(0,C.Ay)(a.default)(e=>{let{theme:t}=e;return{height:"140px",backgroundColor:(0,t3.X4)(t.palette.background.default,.7),borderRadius:t.shape.borderRadius,display:"flex",alignItems:"center",justifyContent:"center",margin:t.spacing(1),overflow:"hidden",position:"relative"}}),na=()=>(0,o.jsxs)(tn.A,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,o.jsx)(a.default,{sx:{p:1},children:(0,o.jsx)(ne.A,{variant:"rectangular",height:140})}),(0,o.jsxs)(to.A,{sx:{flexGrow:1},children:[(0,o.jsx)(ne.A,{variant:"text",width:"80%",height:30}),(0,o.jsxs)(a.default,{sx:{display:"flex",gap:1,mt:1},children:[(0,o.jsx)(ne.A,{variant:"rectangular",width:60,height:20}),(0,o.jsx)(ne.A,{variant:"rectangular",width:90,height:20})]})]}),(0,o.jsxs)(t9.A,{sx:{justifyContent:"flex-end",p:1},children:[(0,o.jsx)(ne.A,{variant:"circular",width:28,height:28}),(0,o.jsx)(ne.A,{variant:"circular",width:28,height:28}),(0,o.jsx)(ne.A,{variant:"circular",width:28,height:28})]})]}),ns=e=>{var t,n;let{flow:i,selected:d,onSelect:p,onDelete:h,onCopy:f,onEdit:m,onSetFolder:x,folders:g=[],validation:v}=e;no.debug("Rendering FlowCard",{flowId:i.id,flowName:i.name});let b=(0,l.A)(),[y,j]=(0,r.useState)(null),w=null!=(t=null==v?void 0:v.errorCount)?t:0,C=null!=(n=null==v?void 0:v.warningCount)?n:0,A=w>0?"error":C>0?"warning":null,S=v?(0,o.jsxs)(a.default,{children:[(0,o.jsx)(s.default,{variant:"caption",sx:{fontWeight:600,display:"block",mb:.5},children:w>0?"".concat(w," problem").concat(1===w?"":"s"," — won't run"):"".concat(C," warning").concat(1===C?"":"s")}),v.issues.slice(0,5).map((e,t)=>(0,o.jsxs)(s.default,{variant:"caption",sx:{display:"block"},children:["• ",e.message]},t)),v.issues.length>5&&(0,o.jsxs)(s.default,{variant:"caption",sx:{display:"block",fontStyle:"italic"},children:["…and ",v.issues.length-5," more"]})]}):null;return(0,o.jsxs)(nr,{selected:d,children:[A&&(0,o.jsx)(u.A,{title:S,arrow:!0,placement:"top",children:(0,o.jsxs)(a.default,{sx:{position:"absolute",top:8,right:8,zIndex:2,display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:1,color:"#fff",backgroundColor:"error"===A?b.palette.error.main:b.palette.warning.main,boxShadow:b.shadows[2],pointerEvents:"auto"},children:["error"===A?(0,o.jsx)(eD.A,{sx:{fontSize:16}}):(0,o.jsx)(ez.A,{sx:{fontSize:16}}),(0,o.jsx)(s.default,{variant:"caption",sx:{fontWeight:700,lineHeight:1},children:"error"===A?w:C})]})}),(0,o.jsxs)(t7.A,{onClick:()=>p(i.id),sx:{display:"flex",flexDirection:"column",alignItems:"stretch",height:"100%",position:"relative"},children:[(0,o.jsx)(nl,{children:(()=>{if(0===i.nodes.length)return(0,o.jsx)(a.default,{sx:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,o.jsx)(s.default,{color:"textSecondary",align:"center",children:"Empty Flow"})});let e=i.nodes.map(e=>{var t,n;return null!=(n=null==(t=e.position)?void 0:t.x)?n:0}),t=i.nodes.map(e=>{var t,n;return null!=(n=null==(t=e.position)?void 0:t.y)?n:0}),n=Math.min(...e),r=Math.min(...t),l=Math.max(...e)+180,d=Math.max(...t)+70,c="".concat(n-40," ").concat(r-40," ").concat(l-n+80," ").concat(d-r+80),u=e=>{var t,n,o,r;return{cx:(null!=(o=null==(t=e.position)?void 0:t.x)?o:0)+90,cy:(null!=(r=null==(n=e.position)?void 0:n.y)?r:0)+35}};return(0,o.jsx)(a.default,{sx:{width:"100%",height:"100%",p:1},children:(0,o.jsxs)("svg",{width:"100%",height:"100%",viewBox:c,preserveAspectRatio:"xMidYMid meet",style:{display:"block"},children:[i.edges.map((e,t)=>{let n=i.nodes.find(t=>t.id===e.source),r=i.nodes.find(t=>t.id===e.target);if(!n||!r)return null;let l=u(n),a=u(r);return(0,o.jsx)("line",{x1:l.cx,y1:l.cy,x2:a.cx,y2:a.cy,stroke:b.palette.text.secondary,strokeWidth:2,opacity:.5,vectorEffect:"non-scaling-stroke"},e.id||t)}),i.nodes.map(e=>{var t,n,r,l,a,s;let i=null!=(l=null==(t=e.position)?void 0:t.x)?l:0,d=null!=(a=null==(n=e.position)?void 0:n.y)?a:0,c=null!=(s=null==(r=e.data)?void 0:r.type)?s:"process",u=(0,_.M6)(c,b);return(0,o.jsxs)("g",{children:[(0,o.jsx)("rect",{x:i,y:d,width:180,height:70,rx:12,fill:u,opacity:.85,stroke:b.palette.background.paper,strokeWidth:2,vectorEffect:"non-scaling-stroke"}),(0,o.jsx)("text",{x:i+90,y:d+35,textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:35,fontWeight:"bold",children:c.substring(0,1).toUpperCase()})]},e.id)})]})})})()}),(0,o.jsxs)(to.A,{sx:{flexGrow:1,pb:0},children:[(0,o.jsx)(s.default,{variant:"h6",component:"div",noWrap:!0,children:i.name}),i.description&&(0,o.jsx)(u.A,{title:i.description,placement:"bottom-start",children:(0,o.jsx)(s.default,{variant:"body2",color:"text.secondary",sx:{mt:.5,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:i.description})}),(0,o.jsxs)(a.default,{sx:{display:"flex",gap:.5,mt:1,flexWrap:"wrap"},children:[(0,o.jsx)(eT.A,{size:"small",label:"".concat(i.nodes.length," nodes"),color:"primary",variant:"outlined",sx:{fontSize:"0.7rem",height:20}}),(0,o.jsx)(eT.A,{size:"small",label:"".concat(i.edges.length," connections"),color:"secondary",variant:"outlined",sx:{fontSize:"0.7rem",height:20}})]})]})]}),(0,o.jsxs)(t9.A,{sx:{justifyContent:"flex-end",p:1,opacity:.7,"&:hover":{opacity:1}},children:[m&&(0,o.jsx)(u.A,{title:"Edit flow metadata",children:(0,o.jsx)(c.A,{size:"small",onClick:e=>{e.stopPropagation(),m&&m(i.id)},children:(0,o.jsx)(Z.A,{fontSize:"small"})})}),f&&(0,o.jsx)(u.A,{title:"Copy flow",children:(0,o.jsx)(c.A,{size:"small",onClick:e=>{e.stopPropagation(),f&&f(i.id)},children:(0,o.jsx)(V.A,{fontSize:"small"})})}),x&&(0,o.jsx)(u.A,{title:i.folder?"Folder: ".concat(i.folder):"Move to folder",children:(0,o.jsx)(c.A,{size:"small",onClick:e=>{e.stopPropagation(),j(e.currentTarget)},color:i.folder?"primary":"default",children:(0,o.jsx)(nt.A,{fontSize:"small"})})}),(0,o.jsx)(u.A,{title:"Delete flow",children:(0,o.jsx)(c.A,{size:"small",onClick:e=>{e.stopPropagation(),h(i.id)},color:"error",children:(0,o.jsx)($.A,{fontSize:"small"})})})]}),x&&(0,o.jsx)(nn.A,{anchorEl:y,open:!!y,currentFolder:i.folder,folders:g,onClose:()=>j(null),onAssign:e=>x(i.id,e)})]})};var ni=n(22573),nd=n(38459);let nc=(0,k.h)("components/Flow/FlowDashboard/FlowDashboard");function nu(e,t){return e+Math.round(255*t).toString(16).padStart(2,"0")}let np=e=>{let{flows:t,selectedFlow:n,onSelectFlow:d,onDeleteFlow:u,onCopyFlow:p,onEditFlow:h,onCreateFlow:f,onSetFolder:m,isLoading:x=!1}=e,[g,b]=(0,r.useState)(""),[y,w]=(0,r.useState)("name-asc"),[C,k]=(0,r.useState)("grid"),[N,T]=(0,r.useState)(null),[I,M]=(0,r.useState)("none"),[P,F]=(0,r.useState)(null),[E,D]=(0,r.useState)(new Set),[z,R]=(0,r.useState)({});(0,r.useEffect)(()=>{let e=!1;return(async()=>{let t={};try{let e=await fetch("/api/model");if(e.ok){let n=await e.json();Array.isArray(n)&&(t.models=n)}}catch(e){nc.warn("Could not load models for flow badges",e)}try{let e=await fetch("/api/mcp/servers");if(e.ok){let n=await e.json();Array.isArray(n)&&(t.servers=n.map(e=>({name:e.name,status:e.disabled?"disabled":void 0})))}}catch(e){nc.warn("Could not load servers for flow badges",e)}e||R(t)})(),()=>{e=!0}},[]);let W=(0,r.useMemo)(()=>{let e={};for(let n of t)try{e[n.id]=eH(n,z)}catch(e){nc.warn("Failed to validate flow for badge",{flowId:n.id,error:e})}return e},[t,z]),L=(0,l.A)(),B=(0,tq.A)(L.breakpoints.down("sm")),O=(0,tq.A)(L.breakpoints.down("md")),H=()=>{T(null)},_=e=>{w(e),H()},$=e=>{M(e),F(null)},V=(0,r.useMemo)(()=>{nc.debug("Filtering and sorting flows",{searchTerm:g,sortOption:y});let e=t;if(""!==g.trim()){let n=g.toLowerCase();e=t.filter(e=>e.name.toLowerCase().includes(n))}return[...e].sort((e,t)=>{switch(y){case"name-asc":return e.name.localeCompare(t.name);case"name-desc":return t.name.localeCompare(e.name);case"most-nodes":return t.nodes.length-e.nodes.length;case"least-nodes":return e.nodes.length-t.nodes.length;case"newest":return t.id.localeCompare(e.id);case"oldest":return e.id.localeCompare(t.id);default:return 0}})},[t,g,y]),X=(0,r.useMemo)(()=>(0,nd.yF)(t,e=>e.folder),[t]),Z=(0,r.useMemo)(()=>"folder"===I?(0,nd.Je)(V,e=>e.folder):"sort"===I?(0,nd.Az)(V,e=>(function(e,t){switch(t){case"name-asc":case"name-desc":return(0,nd.po)(e.name);case"most-nodes":case"least-nodes":var n;return 0===(n=e.nodes.length)?{key:"nodes:0",label:"0 nodes"}:n<=2?{key:"nodes:1-2",label:"1–2 nodes"}:n<=5?{key:"nodes:3-5",label:"3–5 nodes"}:n<=10?{key:"nodes:6-10",label:"6–10 nodes"}:{key:"nodes:11+",label:"11+ nodes"};default:return{key:"all",label:"All flows"}}})(e,y)):[],[I,V,y]),q=e=>(0,o.jsx)(eJ.Ay,{container:!0,spacing:2,children:e.map(e=>(0,o.jsx)(eJ.Ay,{item:!0,xs:12,sm:"compact"===C?12:6,md:"compact"===C?12:3==("compact"===C||B?1:O?2:3)?4:6,children:(0,o.jsx)(ns,{flow:e,selected:n===e.id,onSelect:d,onDelete:u,onCopy:p,onEdit:h,onSetFolder:m,folders:X,validation:W[e.id]})},e.id))});return(0,o.jsxs)(a.default,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,o.jsx)(A.A,{elevation:1,sx:{mb:2,p:1},children:(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:1,alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[(0,o.jsx)(v.A,{placeholder:"Search flows...",variant:"outlined",size:"small",fullWidth:!0,value:g,onChange:e=>{b(e.target.value)},InputProps:{startAdornment:(0,o.jsx)(tt.A,{position:"start",children:(0,o.jsx)(ta.A,{fontSize:"small"})})},sx:{maxWidth:{sm:300}}}),(0,o.jsxs)(a.default,{sx:{display:"flex",gap:1,alignItems:"center"},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",backgroundColor:L.palette.background.default,borderRadius:1,border:"1px solid ".concat(L.palette.divider),overflow:"hidden"},children:[(0,o.jsx)(c.A,{size:"small",onClick:()=>k("grid"),color:"grid"===C?"primary":"default",sx:{borderRadius:0,backgroundColor:"grid"===C?nu(L.palette.primary.main,.1):"transparent"},children:(0,o.jsx)(t1.A,{fontSize:"small"})}),(0,o.jsx)(c.A,{size:"small",onClick:()=>k("compact"),color:"compact"===C?"primary":"default",sx:{borderRadius:0,backgroundColor:"compact"===C?nu(L.palette.primary.main,.1):"transparent"},children:(0,o.jsx)(t0.A,{fontSize:"small"})})]}),(0,o.jsx)(c.A,{size:"small",onClick:e=>F(e.currentTarget),color:"none"!==I?"primary":"default",sx:{border:"1px solid ".concat(L.palette.divider),backgroundColor:L.palette.background.default},title:"Group cards",children:(0,o.jsx)(t4.A,{fontSize:"small"})}),(0,o.jsx)(c.A,{size:"small",onClick:e=>{T(e.currentTarget)},sx:{border:"1px solid ".concat(L.palette.divider),backgroundColor:L.palette.background.default},children:(0,o.jsx)(tK.A,{fontSize:"small"})})]})]})}),(0,o.jsxs)(a.default,{sx:{display:"flex",justifyContent:"space-between",mb:2,px:1},children:[(0,o.jsxs)(s.default,{variant:"body2",color:"textSecondary",children:[V.length," of ",t.length," flows",g&&' matching "'.concat(g,'"')]}),(0,o.jsxs)(s.default,{variant:"body2",color:"textSecondary",children:["Sorted by: ","name-asc"===y?"Name (A-Z)":"name-desc"===y?"Name (Z-A)":"newest"===y?"Newest first":"oldest"===y?"Oldest first":"most-nodes"===y?"Most nodes":"Least nodes"]})]}),(0,o.jsx)(a.default,{sx:{flex:1,overflow:"auto",px:1,pb:2},children:x?(0,o.jsx)(eJ.Ay,{container:!0,spacing:2,children:Array(6).fill(0).map((e,t)=>(0,o.jsx)(eJ.Ay,{item:!0,xs:12,sm:"compact"===C?12:6,md:"compact"===C?12:4,children:(0,o.jsx)(na,{})},"skeleton-".concat(t)))}):V.length>0?"none"===I?q(V):Z.map(e=>(0,o.jsx)(ni.A,{label:e.label,count:e.items.length,expanded:!E.has(e.key),onToggle:()=>(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})(e.key),showFolderIcon:"folder"===I,children:q(e.items)},e.key)):(0,o.jsxs)(a.default,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",p:4,backgroundColor:L.palette.background.paper,borderRadius:1,border:"1px dashed ".concat(L.palette.divider),height:"100%",minHeight:200},children:[(0,o.jsx)(s.default,{variant:"h6",gutterBottom:!0,color:"textSecondary",children:"No flows found"}),g?(0,o.jsxs)(s.default,{variant:"body2",color:"textSecondary",align:"center",children:["No flows match your search criteria.",(0,o.jsxs)(a.default,{component:"span",display:"block",mt:1,children:["Try a different search term or ",(0,o.jsx)(i.A,{size:"small",onClick:()=>b(""),children:"clear the search"})]})]}):(0,o.jsxs)(s.default,{variant:"body2",color:"textSecondary",align:"center",children:["Get started by creating your first flow.",f&&(0,o.jsx)(a.default,{component:"span",display:"block",mt:2,children:(0,o.jsx)(i.A,{variant:"contained",color:"primary",startIcon:(0,o.jsx)(j.A,{}),onClick:f,children:"Create New Flow"})})]})]})}),(0,o.jsxs)(Y.A,{anchorEl:P,open:!!P,onClose:()=>F(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,o.jsxs)(G.A,{selected:"none"===I,onClick:()=>$("none"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t6.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{primary:"No grouping"})]}),(0,o.jsxs)(G.A,{selected:"folder"===I,onClick:()=>$("folder"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t8.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{primary:"By folder"})]}),(0,o.jsxs)(G.A,{selected:"sort"===I,onClick:()=>$("sort"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t4.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{primary:"By sort setting"})]})]}),(0,o.jsxs)(Y.A,{anchorEl:N,open:!!N,onClose:H,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,o.jsxs)(G.A,{onClick:()=>_("name-asc"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t2.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{primary:"Name (A-Z)"})]}),(0,o.jsxs)(G.A,{onClick:()=>_("name-desc"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t2.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,o.jsx)(J.A,{primary:"Name (Z-A)"})]}),(0,o.jsx)(S.A,{}),(0,o.jsxs)(G.A,{onClick:()=>_("newest"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t5.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{primary:"Newest first"})]}),(0,o.jsxs)(G.A,{onClick:()=>_("oldest"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(t5.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,o.jsx)(J.A,{primary:"Oldest first"})]}),(0,o.jsx)(S.A,{}),(0,o.jsxs)(G.A,{onClick:()=>_("most-nodes"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(tQ.A,{fontSize:"small"})}),(0,o.jsx)(J.A,{primary:"Most nodes"})]}),(0,o.jsxs)(G.A,{onClick:()=>_("least-nodes"),children:[(0,o.jsx)(U.A,{children:(0,o.jsx)(tQ.A,{fontSize:"small",sx:{transform:"scaleY(-1)"}})}),(0,o.jsx)(J.A,{primary:"Least nodes"})]})]})]})},nh=(0,k.h)("app/flows/page"),nf=()=>{var e;nh.debug("Rendering FlowsPage"),(0,l.A)();let[t,n]=(0,r.useState)([]),[C,A]=(0,r.useState)(null),[S,k]=(0,r.useState)(!0),[N,M]=(0,r.useState)(!1),P=(0,r.useRef)(null),[F,E]=(0,r.useState)(null),[D,z]=(0,r.useState)(!1),[R,W]=(0,r.useState)(!1),[L,B]=(0,r.useState)(null),[O,H]=(0,r.useState)(""),[_,G]=(0,r.useState)(null),[U,J]=(0,r.useState)({open:!1,message:"",severity:"info"});(0,r.useEffect)(()=>{nh.info("Loading flows"),(async()=>{k(!0);try{let e=await I.g.loadFlows();nh.debug("Flows loaded successfully",{count:e.length}),n(e),C&&(e.some(e=>e.id===C)||(null==F?void 0:F.id)===C||(nh.warn("Previously selected flow no longer exists",{flowId:C}),A(null),M(!1),$("The previously selected flow is no longer available","warning")))}catch(e){nh.error("Error loading flows",e),$("Failed to load flows","error")}finally{k(!1)}})()},[C,F]);let Y=(0,r.useCallback)(e=>{nh.debug("Flow selected",{flowId:e}),A(e),M(!0)},[]);(0,r.useEffect)(()=>{if(!(N&&C))return;let e=e=>{P.current?P.current.requestNavigation(e):e()};return(0,tZ.QO)(e),()=>(0,tZ.bH)(e)},[N,C]);let $=(0,r.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";nh.debug("Showing snackbar",{message:e,severity:t}),J({open:!0,message:e,severity:t})},[]),V=(0,r.useCallback)(()=>{nh.debug("Returning to dashboard");let e=()=>{M(!1),F&&F.id===C&&(E(null),A(null),$("Generated draft discarded","info"))};P.current?P.current.requestNavigation(e):e()},[F,C,$]),X=(0,r.useCallback)(()=>{J(e=>({...e,open:!1}))},[]);(0,r.useEffect)(()=>{if(!U.open||"error"===U.severity)return;let e=setTimeout(()=>{J(e=>({...e,open:!1}))},6e3);return()=>clearTimeout(e)},[U.open,U.message,U.severity]);let Z=(0,r.useCallback)(e=>(nh.debug("Validating flow name",{name:e}),e.trim())?/^[\w-]+$/.test(e)?t.some(t=>t.name.toLowerCase()===e.toLowerCase())?(nh.debug("Flow name validation failed: duplicate name"),"A flow with this name already exists"):(nh.debug("Flow name validation passed"),null):(nh.debug("Flow name validation failed: invalid characters"),"Flow name can only contain letters, numbers, underscores, and dashes"):(nh.debug("Flow name validation failed: empty name"),"Flow name cannot be empty"),[t]),q=async e=>{nh.info("Saving flow",{flowId:e.id,flowName:e.name});try{let o=t.some(t=>t.id===e.id)?await I.g.updateFlow(e):await I.g.addFlow(e);if(!o.success){nh.error("Failed to save flow",{error:o.error}),$(o.error||"Failed to save flow","error");return}nh.debug("Flow saved successfully"),n(t=>{let n=t.findIndex(t=>t.id===e.id);if(!(n>=0))return nh.debug("Adding new flow to state"),[...t,e];{nh.debug("Updating existing flow in state");let o=[...t];return o[n]=e,o}}),(null==F?void 0:F.id)===e.id&&E(null),A(e.id),$("Flow saved successfully","success")}catch(e){nh.error("Error saving flow",e),$("Failed to save flow","error")}},K=async e=>{nh.info("Deleting flow",{flowId:e});try{await I.g.deleteFlow(e),nh.debug("Flow deleted successfully"),n(t=>t.filter(t=>t.id!==e)),C===e&&(nh.debug("Clearing selected flow as it was deleted"),A(null),M(!1)),$("Flow deleted","success")}catch(e){nh.error("Error deleting flow",e),$("Failed to delete flow","error")}},Q=(0,r.useCallback)(async(e,o)=>{nh.info("Setting flow folder",{flowId:e,folder:o});let r=t.find(t=>t.id===e);if(!r)return void nh.warn("Flow to move not found",{flowId:e});let l={...r,folder:o&&o.trim()?o.trim():void 0};try{let t=await I.g.updateFlow(l);if(!t.success)return void $(t.error||"Failed to move flow to folder","error");n(t=>t.map(t=>t.id===e?l:t)),$(l.folder?'Moved to "'.concat(l.folder,'"'):"Removed from folder","success")}catch(e){nh.error("Error setting flow folder",e),$("Failed to move flow to folder","error")}},[t,$]),ee=e=>{nh.info("Copying flow",{flowId:e});let n=t.find(t=>t.id===e);n?(nh.debug("Found flow to copy",{flowName:n.name}),B(n),H("".concat(n.name,"_copy")),W(!0)):(nh.warn("Flow to copy not found",{flowId:e}),$("Flow not found","error"))},et=()=>{nh.debug("Closing copy flow dialog"),W(!1),B(null),H(""),G(null)},en=async()=>{if(nh.info("Confirming flow copy"),!L){nh.warn("No flow to copy"),$("No flow selected to copy","error");return}let e=Z(O);if(e){nh.debug("Flow name validation failed",{error:e}),G(e);return}let t=(0,T.A)();nh.debug("Creating new flow from copy",{newId:t,newName:O});let n={id:t,name:O,description:L.description,nodes:L.nodes,edges:L.edges};await q(n),et(),nh.debug("Selecting newly copied flow"),A(n.id),M(!0),$('Created a copy named "'.concat(O,'"'),"success")},eo=(0,r.useCallback)(e=>{var t,n;nh.info("Opening generated draft flow",{flowId:e.flow.id,attempts:e.attempts,errors:e.errorCount,warnings:e.warningCount}),z(!1),E(e.flow),A(e.flow.id),M(!0);let o=null!=(n=null==(t=e.installedServers)?void 0:t.filter(e=>!e.alreadyExisted))?n:[],r=o.length>0?" Installed MCP server(s): ".concat(o.map(e=>e.name).join(", "),"."):"";e.errorCount>0?$("Draft generated with ".concat(e.errorCount," error(s) and ").concat(e.warningCount," warning(s) — use the Check button, fix, then save.").concat(r),"warning"):e.warningCount>0?$("Draft generated with ".concat(e.warningCount," warning(s) — review, then save to keep it.").concat(r),"info"):$("Flow drafted — review it and save to keep it.".concat(r),"success")},[$]),er=async()=>{nh.info("Creating new flow");let e="NewFlow",n=e,o=1;for(;t.some(e=>e.name===n);)n="".concat(e).concat(o),o++;let r=I.g.createNewFlow(n);await q(r),M(!0),$("New flow created","success")};return(0,o.jsxs)(a.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,o.jsxs)(a.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:1,borderColor:"divider"},children:[(0,o.jsxs)(a.default,{sx:{display:"flex",alignItems:"center"},children:[N&&C&&(0,o.jsx)(c.A,{color:"primary",onClick:V,sx:{mr:1},children:(0,o.jsx)(y.A,{})}),(0,o.jsx)(a.default,{children:(0,o.jsx)(s.default,{variant:"h5",children:N&&C?(null==F?void 0:F.id)===C?"Editing: ".concat(F.name," (unsaved draft)"):"Editing: ".concat((null==(e=t.find(e=>e.id===C))?void 0:e.name)||"Flow"):"Flow Dashboard"})})]}),!N&&(0,o.jsxs)(a.default,{sx:{display:"flex",gap:1},children:[(0,o.jsx)(u.A,{title:"Describe a flow in plain language and let a model draft it",children:(0,o.jsx)(i.A,{variant:"outlined",color:"primary",startIcon:(0,o.jsx)(w.A,{}),onClick:()=>z(!0),"data-tour":"generate-flow",children:"Generate Flow"})}),(0,o.jsx)(u.A,{title:"Create a new flow with a starter template",children:(0,o.jsx)(i.A,{variant:"contained",color:"primary",startIcon:(0,o.jsx)(j.A,{}),onClick:er,"data-tour":"new-flow",children:"New Flow"})})]})]}),(0,o.jsx)(p.A,{in:U.open,unmountOnExit:!0,children:(0,o.jsx)(h.A,{severity:U.severity,onClose:X,sx:{borderRadius:0},children:U.message})}),(0,o.jsx)(a.default,{sx:{flex:1,overflow:"hidden"},children:(()=>{if(N&&C){var e;let n=null!=(e=t.find(e=>e.id===C))?e:(null==F?void 0:F.id)===C?F:void 0;return n?(0,o.jsx)(d.A,{in:!0,timeout:300,children:(0,o.jsx)(a.default,{sx:{height:"100%"},children:(0,o.jsx)(tY,{ref:P,initialFlow:n,onSave:q,onDelete:K,allFlows:t},C)})}):(0,o.jsxs)(a.default,{sx:{p:4,textAlign:"center"},children:[(0,o.jsx)(s.default,{variant:"h6",color:"error",children:"Selected flow not found"}),(0,o.jsx)(i.A,{variant:"contained",onClick:V,sx:{mt:2},children:"Back to Dashboard"})]})}return(0,o.jsx)(d.A,{in:!0,timeout:300,children:(0,o.jsx)(a.default,{sx:{height:"100%"},children:(0,o.jsx)(np,{flows:t,selectedFlow:C,onSelectFlow:Y,onDeleteFlow:K,onCopyFlow:ee,onCreateFlow:er,onSetFolder:Q,isLoading:S})})})})()}),(0,o.jsxs)(f.A,{open:R,onClose:et,children:[(0,o.jsx)(m.A,{children:"Copy Flow"}),(0,o.jsxs)(x.A,{children:[(0,o.jsx)(g.A,{children:"Enter a name for the copied flow:"}),(0,o.jsx)(v.A,{autoFocus:!0,margin:"dense",label:"Flow Name",type:"text",fullWidth:!0,value:O,onChange:e=>{let t=e.target.value;nh.debug("Flow name changed",{name:t}),H(t),G(Z(t))},error:!!_,helperText:_})]}),(0,o.jsxs)(b.A,{children:[(0,o.jsx)(i.A,{onClick:et,children:"Cancel"}),(0,o.jsx)(i.A,{onClick:en,variant:"contained",color:"primary",disabled:!!_,children:"Copy"})]})]}),(0,o.jsx)(tX,{open:D,onClose:()=>z(!1),onGenerated:eo})]})}},32098:()=>{},60530:(e,t,n)=>{"use strict";n.d(t,{L_:()=>a,QO:()=>r,bH:()=>l});let o=null;function r(e){o=e}function l(e){o===e&&(o=null)}function a(e){return!!o&&(o(e),!0)}},61033:(e,t,n)=>{"use strict";n.d(t,{A$:()=>c,X8:()=>s,YP:()=>u,js:()=>d});let o="_-_-_",r=/^(tool|resource):(.+)$/,l=/\$\{((?:tool|resource):[^}]+|_-_-_[^}]+)\}/g;function a(e,t){return"".concat(e,"__").concat(t)}function s(e,t,n){return"${".concat(e,":").concat(a(t,n),"}")}function i(e){let t=r.exec(e);if(t){let e=t[1],n=function(e){let t=e.indexOf("__");if(t<=0)return null;let n=e.slice(t+2);return n?{server:e.slice(0,t),name:n}:null}(t[2]);return n?{kind:e,server:n.server,name:n.name}:null}if(e.startsWith(o)){let t=e.split(o);if(3===t.length&&t[1]&&t[2])return{kind:"tool",server:t[1],name:t[2]}}return null}function d(e){return e.startsWith("${")&&e.endsWith("}")?i(e.slice(2,-1)):null}function c(e){let t,n=[];for(l.lastIndex=0;null!==(t=l.exec(e));){let e=i(t[1]);e&&n.push({...e,fullMatch:t[0],index:t.index})}return n}function u(e){return"tool"===e.kind&&"handoff"===e.server?"handoff:".concat(e.name):"".concat(e.kind,":").concat(a(e.server,e.name))}},71075:(e,t,n)=>{Promise.resolve().then(n.bind(n,18244))},95480:(e,t,n)=>{"use strict";n.d(t,{A:()=>T});var o=n(95155),r=n(12115),l=n(87021),a=n(63941),s=n(29985),i=n(80372),d=n(94049),c=n(25635),u=n(3139),p=n(57883),h=n(2300),f=n(89218),m=n(42063),x=n(17897);n(32098);var g=n(61033);let v=(0,l.h)("frontend/components/shared/PromptBuilder"),b=e=>{v.debug("Deserializing markdown to Slate value");let t=e.split("\n").map(e=>({type:"paragraph",children:(e=>{let t=(0,g.A$)(e);if(0===t.length)return[{text:e}];let n=[],o=0;for(let r of t)r.index>o&&n.push({text:e.slice(o,r.index)}),n.push({type:"binding-reference",kind:r.kind,server:r.server,name:r.name,children:[{text:""}]}),o=r.index+r.fullMatch.length;return o<e.length&&n.push({text:e.slice(o)}),n})(e)}));return t.length>0?t:[{type:"paragraph",children:[{text:""}]}]},y=e=>{v.debug("Serializing Slate value to markdown");let t=0,n=e.map(e=>e.children?e.children.map(e=>a.EY.isText(e)?e.text:"binding-reference"===e.type?(t++,(0,g.X8)(e.kind,e.server,e.name)):"").join(""):"").join("\n");return t>0&&v.debug("Serialized ".concat(t," binding references")),n},j=e=>{let{attributes:t,children:n,element:r}=e;return"binding-reference"===r.type?(0,o.jsxs)("span",{...t,className:"tool-reference-wrapper",children:[(0,o.jsx)(()=>{let e=(0,s.Zi)(),t=(e=>"tool"===e.kind&&"handoff"===e.server)(r),n="resource"===r.kind?"resource":t?"handoff":"",l=()=>{let t=s.rL.findPath(e,r);v.debug("Removing binding reference: ".concat(r.kind,":").concat(r.server,":").concat(r.name)),a.gB.removeNodes(e,{at:t})};return(0,o.jsxs)("span",{contentEditable:!1,className:"tool-reference-container ".concat(n),children:[(0,o.jsx)("span",{className:"tool-reference ".concat(n),children:(0,g.YP)(r)}),(0,o.jsx)("span",{className:"tool-reference-delete ".concat(n),role:"button",tabIndex:0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l()},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),l())},children:"\xd7"})]})},{}),n," "]}):(0,o.jsx)("p",{...t,children:n})},w=e=>{let{attributes:t,children:n,leaf:r}=e,l=n;return r.bold&&(l=(0,o.jsx)("strong",{children:l})),r.italic&&(l=(0,o.jsx)("em",{children:l})),r.code&&(l=(0,o.jsx)("code",{children:l})),(0,o.jsx)("span",{...t,children:l})},C=e=>{let{server:t,name:n}=e,l="handoff"===t,[a,s]=(0,r.useState)(null),[i,d]=(0,r.useState)(!0);return((0,r.useEffect)(()=>{let e=!1;return(async()=>{try{var o;d(!0);let r=null==(o=(await x.S.listServerTools(t)).tools)?void 0:o.find(e=>e.name===n);e||s(r||null)}catch(e){v.error("Failed to fetch tool info for ".concat(t,":").concat(n),e)}finally{e||d(!1)}})(),()=>{e=!0}},[t,n]),i)?(0,o.jsx)("span",{className:"tool-reference-preview loading ".concat(l?"handoff":""),children:"tool:".concat(t,"__").concat(n)}):a?(0,o.jsxs)("span",{className:"tool-reference-preview ".concat(l?"handoff":""),children:["[The user is referencing a ",l?"handoff":"tool"," `tool:",t,"__",n,"` (",a.description||"No description",")]"]}):(0,o.jsx)("span",{className:"tool-reference-preview not-found ".concat(l?"handoff":""),children:"tool:".concat(t,"__").concat(n," (Tool not found)")})},A=e=>{let{server:t,name:n}=e,[l,a]=(0,r.useState)(null),[s,i]=(0,r.useState)(!0);return((0,r.useEffect)(()=>{let e=!1;return(async()=>{try{i(!0);let o=await x.S.listServerResources(t),r=[...o.resources||[],...o.resourceTemplates||[]].find(e=>e.uri===n||e.uriTemplate===n);e||a((null==r?void 0:r.description)||(null==r?void 0:r.name)||null)}catch(e){v.error("Failed to fetch resource info for ".concat(t,":").concat(n),e)}finally{e||i(!1)}})(),()=>{e=!0}},[t,n]),s)?(0,o.jsx)("span",{className:"tool-reference-preview loading resource",children:"resource:".concat(t,"__").concat(n)}):(0,o.jsxs)("span",{className:"tool-reference-preview resource",children:["[The contents of resource `",n,"` from `",t,"`",l?" (".concat(l,")"):""," will be inserted here]"]})},S=e=>{let{binding:t}=e;return"resource"===t.kind?(0,o.jsx)(A,{server:t.server,name:t.name}):(0,o.jsx)(C,{server:t.server,name:t.name})},k=e=>{let{value:t}=e;v.debug("Rendering preview");let n=[],r=0;for(let e of(0,g.A$)(t))e.index>r&&n.push({type:"text",value:t.slice(r,e.index)}),n.push({type:"binding",binding:e,key:e.index}),r=e.index+e.fullMatch.length;r<t.length&&n.push({type:"text",value:t.slice(r)});let l=[],a=[],s=()=>{l.push((0,o.jsx)("p",{children:a},"p-".concat(l.length))),a=[]};for(let e of n)if("text"===e.type){let t=e.value.split("\n");for(let e=0;e<t.length;e++)a.push(t[e]),e<t.length-1&&s()}else a.push((0,o.jsx)(S,{binding:e.binding},"binding-".concat(e.key)));return a.length>0&&s(),(0,o.jsx)("div",{className:"preview-content",children:l})},N=(0,r.forwardRef)((e,t)=>{let{value:n,onChange:l,label:x="Prompt Builder",height:C=300,onModeChange:A,customPreviewRenderer:S}=e;v.info("PromptBuilder initialized");let N=(0,r.useMemo)(()=>{let e=(0,i.$k)((0,s.o$)((0,a.ie)())),{isInline:t,isVoid:n}=e;return e.isInline=e=>"binding-reference"===e.type||t(e),e.isVoid=e=>"binding-reference"===e.type||n(e),e},[]),[T,I]=(0,r.useState)("raw"),[M,P]=(0,r.useState)(()=>b(n||"")),F=(0,r.useRef)(!1),[,E]=(0,r.useState)(0);(0,r.useImperativeHandle)(t,()=>({insertText:e=>{v.info("insertText called with text length: ".concat(e.length));let t=(0,g.js)(e);if(t){v.info("Inserting ".concat(t.kind," reference: ").concat(t.server,":").concat(t.name));let e={type:"binding-reference",kind:t.kind,server:t.server,name:t.name,children:[{text:""}]};N.selection||a.gB.select(N,a.KE.end(N,[])),a.gB.insertNodes(N,e),a.gB.move(N),E(e=>e+1),P([...N.children])}else N.selection||a.gB.select(N,a.KE.end(N,[])),a.gB.insertText(N,e);l(y(N.children)),v.info("insertText completed successfully")},getMode:()=>T})),(0,r.useEffect)(()=>{y(M)!==y(b(n||""))&&(v.debug("External value change detected"),F.current=!0,P(b(n||"")))},[n,M]);let D=(0,r.useCallback)(e=>{if(F.current){F.current=!1;return}P(e),l(y(e))},[l]);return(0,o.jsxs)(d.default,{sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column"},children:[x&&(0,o.jsx)(c.default,{variant:"subtitle1",gutterBottom:!0,sx:{fontWeight:"medium",mb:1},children:x}),(0,o.jsx)(d.default,{sx:{mb:1},children:(0,o.jsxs)(u.A,{value:T,exclusive:!0,onChange:(e,t)=>{null!==t&&(v.info("Mode changed from ".concat(T," to ").concat(t)),I(t),A&&A(t))},size:"small",children:[(0,o.jsxs)(p.A,{value:"raw",children:[(0,o.jsx)(f.A,{fontSize:"small",sx:{mr:.5}}),"Raw"]}),(0,o.jsxs)(p.A,{value:"preview",children:[(0,o.jsx)(m.A,{fontSize:"small",sx:{mr:.5}}),"Preview"]})]})}),(0,o.jsx)(h.A,{elevation:0,sx:{border:"1px solid rgba(0, 0, 0, 0.12)",borderRadius:1,overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column"},children:"raw"===T?(0,o.jsx)(d.default,{className:"slate-editor-container",sx:{height:"number"==typeof C?C:"100%",overflow:"auto",p:2},children:(0,o.jsx)(s.A,{editor:N,initialValue:M,onChange:D,children:(0,o.jsx)(s.Fo,{className:"slate-editor",renderElement:j,renderLeaf:w,placeholder:"Write your prompt here..."})})}):S?(0,o.jsx)(d.default,{className:"custom-preview-container",sx:{height:"number"==typeof C?C:"100%",overflow:"auto"},children:S()}):(0,o.jsx)(d.default,{className:"preview-container",sx:{height:"number"==typeof C?C:"100%",overflow:"auto",p:2},children:(0,o.jsx)(k,{value:n})})})]})});N.displayName="PromptBuilder";let T=N}},e=>{e.O(0,[1137,3862,7926,2678,4754,9244,8548,690,9562,2003,488,3272,6582,2403,3077,1979,539,8867,5961,9414,510,2380,687,8862,8441,1255,7358],()=>e(e.s=71075)),_N_E=e.O()}]);
|