flujo-ai 3.9.1 → 3.10.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 +126 -119
- package/.next/app-path-routes-manifest.json +8 -7
- package/.next/build-manifest.json +2 -2
- 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 -2
- 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 +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.js +1 -1
- package/.next/server/app/api/env/route.js.nft.json +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/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.js +5 -3
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/init/route.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/mcp/cancel/route.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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +1 -0
- package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -0
- package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route.js +1 -2
- package/.next/server/app/api/mcp-registry/spotlight/route.js.nft.json +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 +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 +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 +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 +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.js +1 -1
- package/.next/server/app/api/oauth/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/initiate/route.js +1 -1
- package/.next/server/app/api/oauth/initiate/route.js.nft.json +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 +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 +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 +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 +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 +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 -2
- 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.js +1 -2
- package/.next/server/app/api/storage/route.js.nft.json +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 +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.js +8 -8
- package/.next/server/app/chat/page.js.nft.json +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 +2 -2
- 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 +1 -1
- package/.next/server/app/executions/page.js +2 -2
- package/.next/server/app/executions/page.js.nft.json +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 +2 -2
- package/.next/server/app/flows/page.js +10 -10
- package/.next/server/app/flows/page.js.nft.json +1 -1
- 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.js +13 -13
- package/.next/server/app/mcp/page.js.nft.json +1 -1
- package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-flows/route.js +1 -1
- 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 +2 -2
- package/.next/server/app/models/page.js +3 -3
- 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 +2 -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 +1 -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 +1 -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 +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 +8 -7
- package/.next/server/chunks/117.js +1 -0
- package/.next/server/chunks/1373.js +1 -1
- package/.next/server/chunks/1403.js +1 -1
- package/.next/server/chunks/2181.js +6 -6
- package/.next/server/chunks/2372.js +2 -0
- package/.next/server/chunks/2776.js +1 -1
- package/.next/server/chunks/3426.js +1 -0
- package/.next/server/chunks/3984.js +4 -4
- package/.next/server/chunks/4239.js +1 -1
- package/.next/server/chunks/4323.js +1 -0
- package/.next/server/chunks/4379.js +1 -0
- package/.next/server/chunks/4706.js +1 -1
- package/.next/server/chunks/4729.js +2 -2
- package/.next/server/chunks/5389.js +11 -11
- package/.next/server/chunks/5547.js +2 -2
- package/.next/server/chunks/5734.js +4 -4
- package/.next/server/chunks/6637.js +2 -2
- package/.next/server/chunks/6936.js +13 -13
- package/.next/server/chunks/6996.js +3 -3
- package/.next/server/chunks/724.js +12 -12
- package/.next/server/chunks/8460.js +1 -1
- package/.next/server/chunks/8739.js +1 -2
- package/.next/server/chunks/9188.js +1 -1
- package/.next/server/chunks/9509.js +2 -0
- package/.next/server/chunks/9989.js +1 -1
- package/.next/server/functions-config-manifest.json +3 -2
- 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/1811-8ee01cf37161913c.js +1 -0
- package/.next/static/chunks/2380-5696e0dc0469f6a5.js +1 -0
- package/.next/static/chunks/4205-b9e33afc7e96ecb9.js +1 -0
- package/.next/static/chunks/5781-4328d17aad13f908.js +8 -0
- package/.next/static/chunks/687-98ba5f5043866f48.js +1 -0
- package/.next/static/chunks/7458-4445e76668151564.js +1 -0
- package/.next/static/chunks/{9718-12d33c1a26bb002d.js → 8215-a966f4c36f1ca174.js} +1 -1
- package/.next/static/chunks/8862-8f17ef601bb1fbd0.js +1 -0
- package/.next/static/chunks/8890-a7a8c6f1dc3cd343.js +1 -0
- package/.next/static/chunks/app/api/backup/{route-acd5b6e731d45f1a.js → route-3291f6991ce3f52c.js} +1 -1
- package/.next/static/chunks/app/api/browse/{route-acd5b6e731d45f1a.js → route-3291f6991ce3f52c.js} +1 -1
- package/.next/static/chunks/app/api/cwd/{route-acd5b6e731d45f1a.js → route-3291f6991ce3f52c.js} +1 -1
- package/.next/static/chunks/app/api/encryption/secure/{route-acd5b6e731d45f1a.js → route-3291f6991ce3f52c.js} +1 -1
- package/.next/static/chunks/app/api/env/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/flow/[id]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/flow/prompt-renderer/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/flow/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/git/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/init/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/cancel/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/servers/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/test-connection/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp/test-connection/stream/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp-registry/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/mcp-registry/spotlight/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/model/[id]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/model/provider/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/model/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/model/test/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/oauth/callback/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/oauth/initiate/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/oauth/reset/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/planned-executions/[id]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/planned-executions/[id]/run/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/planned-executions/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/restore/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/storage/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/update/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/api/webhooks/[id]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/chat/page-aea8c8cbfa461e7f.js +1 -0
- package/.next/static/chunks/app/executions/{page-b46744c507a6e810.js → page-95fec57bf97ee809.js} +1 -1
- package/.next/static/chunks/app/flows/page-7fe295069ccdb5fe.js +1 -0
- package/.next/static/chunks/app/mcp/page-0f923960004aa437.js +1 -0
- package/.next/static/chunks/app/mcp-flows/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/mcp-proxy/[server]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/models/page-f43476ea07d5b501.js +1 -0
- package/.next/static/chunks/app/v1/chat/completions/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/chat/conversations/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/chunks/app/v1/models/route-3291f6991ce3f52c.js +1 -0
- package/.next/static/geAgl8xNIf0s1v2mfu4tE/_buildManifest.js +1 -0
- package/.next/trace +7 -7
- package/.next/types/app/api/mcp/test-connection/stream/route.ts +347 -0
- package/.next/types/routes.d.ts +2 -1
- package/.next/types/validator.ts +9 -0
- package/README.md +37 -7
- package/package.json +2 -2
- package/.next/server/chunks/1986.js +0 -1
- package/.next/server/chunks/5486.js +0 -1
- package/.next/server/chunks/62.js +0 -1
- package/.next/server/chunks/6542.js +0 -1
- package/.next/static/6EKGB09pbUp8R7aHuLiP1/_buildManifest.js +0 -1
- package/.next/static/chunks/2380-2a7acfa037ec8e80.js +0 -1
- package/.next/static/chunks/3235-dfcb73b8d483f8cd.js +0 -1
- package/.next/static/chunks/3750-38474d67566af4c3.js +0 -1
- package/.next/static/chunks/3810-cee95063d5535307.js +0 -1
- package/.next/static/chunks/39-1732a0b689c7b641.js +0 -1
- package/.next/static/chunks/6134-758747aabd77289d.js +0 -8
- package/.next/static/chunks/7488-b58bc701d0deda00.js +0 -1
- package/.next/static/chunks/8862-1314a13b011c4817.js +0 -1
- package/.next/static/chunks/app/api/env/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/flow/[id]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/flow/prompt-renderer/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/flow/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/git/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/init/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/cancel/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/get/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/prompts/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/resources/read/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/resources/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/status/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/tools/[toolName]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/[name]/tools/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/servers/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp/test-connection/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp-registry/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/mcp-registry/spotlight/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/model/[id]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/model/provider/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/model/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/model/test/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/oauth/callback/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/oauth/initiate/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/oauth/reset/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/planned-executions/[id]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/planned-executions/[id]/run/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/planned-executions/[id]/runs/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/planned-executions/preview-schedule/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/planned-executions/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/restore/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/storage/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/update/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/api/webhooks/[id]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/chat/page-019d2b836f34f40d.js +0 -1
- package/.next/static/chunks/app/flows/page-7b5c0e06951398ac.js +0 -1
- package/.next/static/chunks/app/mcp/page-1ca55f88a3045b5d.js +0 -1
- package/.next/static/chunks/app/mcp-flows/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/mcp-proxy/[server]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/models/page-a20e6c4e1a5a0c9a.js +0 -1
- package/.next/static/chunks/app/v1/chat/completions/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/breakpoints/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/cancel/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/continue/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/debug/step/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/edit-state/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/events/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/respond/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/[conversationId]/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/chat/conversations/route-acd5b6e731d45f1a.js +0 -1
- package/.next/static/chunks/app/v1/models/route-acd5b6e731d45f1a.js +0 -1
- /package/.next/static/{6EKGB09pbUp8R7aHuLiP1 → geAgl8xNIf0s1v2mfu4tE}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{67421:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>ti});var o=n(95155),r=n(12115),a=n(97322),l=n(94049),i=n(78470),s=n(41983),d=n(22003),c=n(70690),u=n(25635),p=n(2778),g=n(52363),f=n(65036),h=n(50001),m=n(75912),x=n(76530),b=n(36741),v=n(60691),y=n(78410),w=n(29692),j=n(21067),A=n(41602),S=n(23820),I=n(17681),C=n(73707),k=n(4484),E=n(86946),N=n(19219);let T=e=>{let{conversations:t,currentConversationId:n,onSelectConversation:r,onDeleteConversation:a,onNewConversation:d,onCollapse:p}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(l.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",gap:1},children:[p&&(0,o.jsx)(i.A,{title:"Hide sidebar",children:(0,o.jsx)(s.A,{size:"small",onClick:p,"aria-label":"Hide conversation sidebar",children:(0,o.jsx)(N.A,{})})}),(0,o.jsx)(u.default,{variant:"h6",sx:{flex:1},noWrap:!0,children:"Conversations"}),(0,o.jsx)(c.A,{variant:"contained",color:"primary",startIcon:(0,o.jsx)(E.A,{}),onClick:d,size:"small",children:"New"})]}),(0,o.jsx)(j.A,{}),(0,o.jsx)(A.A,{sx:{overflow:"auto",flex:1},children:0===t.length?(0,o.jsx)(S.Ay,{children:(0,o.jsx)(I.A,{primary:"No conversations yet",secondary:"Start a new conversation",primaryTypographyProps:{align:"center"},secondaryTypographyProps:{align:"center"}})}):t.sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>(0,o.jsx)(S.Ay,{disablePadding:!0,secondaryAction:(0,o.jsx)(s.A,{edge:"end","aria-label":"delete",onClick:t=>{t.stopPropagation(),a(e.id)},children:(0,o.jsx)(k.A,{})}),sx:{opacity:e.id===n?1:.7},children:(0,o.jsx)(C.A,{selected:e.id===n,onClick:()=>r(e.id),sx:{pr:7},children:(0,o.jsx)(I.A,{primary:(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.status&&(0,o.jsx)(i.A,{title:(e=>{switch(e){case"running":return"Processing";case"awaiting_tool_approval":return"Waiting for tool approval";case"paused_debug":return"Paused in debug mode";case"completed":return"Completed";case"error":return"Error";default:return""}})(e.status),children:(0,o.jsx)(l.default,{component:"span",sx:{width:8,height:8,borderRadius:"50%",bgcolor:(e=>{switch(e){case"running":return"primary.main";case"awaiting_tool_approval":return"warning.main";case"paused_debug":return"secondary.main";case"completed":return"success.main";case"error":return"error.main";default:return"transparent"}})(e.status),display:"inline-block",flexShrink:0}})}),(0,o.jsx)(u.default,{component:"span",noWrap:!0,fontWeight:e.id===n?"bold":"normal",children:e.title})]}),secondary:new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})})},e.id))})]})};var R=n(28548),D=n(2300),z=n(52641),P=n(51221),O=n(55606),F=n(86973),L=n(98267),W=n(20537),_=n(37960),M=n(99944),B=n(9957),U=n(36314),H=n(49501),J=n(6504),q=n(22133),G=n(11665),Y=n(97516),V=n(91861),X=n(53612),K=n(3014),Z=n(63186),$=n(70863),Q=n(67891),ee=n(14915),et=n(63992),en=n(59637),eo=n(1877),er=n(87021);let ea=(0,er.h)("frontend/components/Chat/ChatMessages");function el(e){return"assistant"===e.role&&"tool_calls"in e&&Array.isArray(e.tool_calls)}let ei={p:e=>(0,o.jsx)(u.default,{variant:"body1",sx:{mb:.5,whiteSpace:"pre-line"},children:e.children}),h1:e=>(0,o.jsx)(u.default,{variant:"h5",sx:{mt:2,mb:.5},children:e.children}),h2:e=>(0,o.jsx)(u.default,{variant:"h6",sx:{mt:2,mb:.5},children:e.children}),h3:e=>(0,o.jsx)(u.default,{variant:"subtitle1",sx:{mt:1.5,mb:.5},children:e.children}),h4:e=>(0,o.jsx)(u.default,{variant:"subtitle2",sx:{mt:1.5,mb:.5},children:e.children}),h5:e=>(0,o.jsx)(u.default,{variant:"body1",sx:{mt:1,mb:.5,fontWeight:"bold"},children:e.children}),h6:e=>(0,o.jsx)(u.default,{variant:"body2",sx:{mt:1,mb:.5,fontWeight:"bold"},children:e.children}),ul:e=>(0,o.jsx)(l.default,{component:"ul",sx:{pl:2,mb:1},children:e.children}),ol:e=>(0,o.jsx)(l.default,{component:"ol",sx:{pl:2,mb:1},children:e.children}),li:e=>(0,o.jsx)(l.default,{component:"li",sx:{mb:.5,whiteSpace:"pre-line"},children:e.children}),a:e=>(0,o.jsx)(u.default,{component:"a",sx:{color:"primary.main"},href:e.href,children:e.children}),blockquote:e=>(0,o.jsx)(l.default,{component:"blockquote",sx:{borderLeft:"4px solid",borderColor:"divider",pl:2,py:.5,my:1,bgcolor:"action.hover",borderRadius:"4px"},children:e.children}),code:e=>{let{node:t,className:n,children:r,...a}=e;return/language-(\w+)/.exec(n||"")||n?(0,o.jsx)(l.default,{component:"pre",sx:{bgcolor:"action.hover",p:1.5,borderRadius:"4px",overflowX:"auto",fontFamily:"monospace",fontSize:"0.875rem",my:1,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:r}):(0,o.jsx)(u.default,{component:"code",sx:{bgcolor:"action.hover",px:.5,py:.25,borderRadius:"4px",fontFamily:"monospace",wordBreak:"break-all"},children:r})}},es=r.memo(function(e){var t,n;let r,{message:a,nodeLabel:d,availableNodes:p,showRaw:g,edit:f,onMenuOpen:h,onToggleRaw:m,onEditContentChange:x,onEditNodeChange:b,onSaveEdit:v,onCancelEdit:y}=e,w=null!=(t=a.depth)?t:0;return(0,o.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",alignItems:"user"===a.role?"flex-end":"flex-start",opacity:a.disabled?.5:1,...w>0&&{pl:3*w,borderLeft:"2px solid",borderColor:"divider",ml:1}},children:[(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",mb:.5},children:[(0,o.jsxs)(u.default,{variant:"caption",color:"text.secondary",sx:{mr:1},children:["user"===a.role?"You":"assistant"===a.role?"Assistant":"tool"===a.role?"Tool":"System"," • ","number"!=typeof(n=a.timestamp)||isNaN(n)?(ea.warn("formatTime received invalid timestamp:",n),"Invalid Date"):new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]}),a.processNodeId&&(0,o.jsx)(i.A,{title:"".concat(d?"".concat(d," — "):"","Process Node ID: ").concat(a.processNodeId),children:(0,o.jsx)(R.A,{label:"Node: ".concat(d||"".concat(a.processNodeId.substring(0,6),"...")),size:"small",color:"primary",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),w>0&&(0,o.jsx)(i.A,{title:"Nested subflow step (depth ".concat(w,")"),children:(0,o.jsx)(R.A,{label:"Subflow step",size:"small",color:"secondary",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),a.disabled&&(0,o.jsx)(R.A,{label:"Disabled",size:"small",color:"default",variant:"outlined",sx:{height:20,fontSize:"0.7rem"}}),a.usage&&(0,o.jsx)(i.A,{title:"".concat(a.usage.promptTokens.toLocaleString()," prompt + ").concat(a.usage.completionTokens.toLocaleString()," completion tokens (provider-reported)"),children:(0,o.jsx)(R.A,{label:"".concat((r=a.usage.totalTokens)>=1e3?"".concat((r/1e3).toFixed(r>=1e5?0:1),"k"):"".concat(r)," tok"),size:"small",color:"default",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),(0,o.jsx)(s.A,{size:"small",onClick:e=>h(e,a.id),sx:{ml:1},children:(0,o.jsx)(G.A,{fontSize:"small"})})]}),(0,o.jsxs)(D.A,{elevation:1,sx:{p:2,maxWidth:"75vw",borderRadius:2,bgcolor:"user"===a.role?"primary.light":"assistant"===a.role||"tool"===a.role?"background.paper":"info.light",color:"user"===a.role?"primary.contrastText":"assistant"===a.role||"tool"===a.role?"text.primary":"info.contrastText",position:"relative",borderLeft:"tool"===a.role?"4px solid":"none",borderColor:"tool"===a.role?"grey.400":"transparent",overflowWrap:"break-word",wordBreak:"break-word",overflow:"hidden"},children:[f?(0,o.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:[(0,o.jsx)("textarea",{value:f.content,onChange:e=>x(e.target.value),style:{width:"100%",minHeight:"100px",padding:"8px",borderRadius:"4px",border:"1px solid #ccc",fontFamily:"inherit",fontSize:"inherit",backgroundColor:"white",color:"black"}}),(0,o.jsxs)(z.A,{fullWidth:!0,size:"small",sx:{mt:1},children:[(0,o.jsx)(P.A,{id:"node-id-select-label",children:"Process Node"}),(0,o.jsx)(O.A,{labelId:"node-id-select-label",id:"node-id-select",value:f.nodeId||(p.length>0?p[0].id:""),label:"Process Node",onChange:e=>b(e.target.value),children:p.map(e=>(0,o.jsx)(F.A,{value:e.id,children:e.label||e.id.substring(0,8)},e.id))})]}),(0,o.jsxs)(l.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:1},children:[(0,o.jsx)(c.A,{variant:"outlined",size:"small",onClick:y,children:"Cancel"}),(0,o.jsx)(c.A,{variant:"contained",size:"small",onClick:v,children:"Save"})]})]}):(0,o.jsxs)(o.Fragment,{children:["tool"!==a.role&&"string"==typeof a.content&&(0,o.jsx)(J.oz,{remarkPlugins:[q.A],components:ei,children:a.content}),"tool"!==a.role&&Array.isArray(a.content)&&(0,o.jsx)(l.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:a.content.map((e,t)=>{var n;return(null==e?void 0:e.type)==="text"?(0,o.jsx)(J.oz,{remarkPlugins:[q.A],children:e.text},t):(null==e?void 0:e.type)==="image_url"&&(null==(n=e.image_url)?void 0:n.url)?(0,o.jsx)("img",{src:e.image_url.url,alt:"Image ".concat(t+1),style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}},t):null})}),"tool"!==a.role&&"string"!=typeof a.content&&!Array.isArray(a.content)&&!el(a)&&(0,o.jsx)(u.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",children:"[No text content]"})]}),el(a)&&a.tool_calls.length>0&&(0,o.jsxs)(l.default,{sx:{mt:1,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,o.jsxs)(u.default,{variant:"body2",sx:{display:"flex",alignItems:"center",color:"primary.main",mb:1},children:[(0,o.jsx)($.A,{fontSize:"small",sx:{mr:1}}),"The assistant is using a tool"]}),a.tool_calls.map((e,t)=>{let n=(0,eo.yo)(e.function.name),r=e.function.arguments;try{let t=JSON.parse(e.function.arguments);r=JSON.stringify(t,null,2)}catch(e){}return(0,o.jsxs)(L.A,{defaultExpanded:!1,sx:{mb:.5,"&:before":{display:"none"},boxShadow:"none",bgcolor:"rgba(0, 0, 0, 0.04)"},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),children:(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)($.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),(0,o.jsx)(u.default,{variant:"subtitle2",sx:{fontWeight:"bold"},children:n}),(0,o.jsx)(R.A,{label:"ID: ".concat(e.id?e.id.substring(0,8):"N/A","..."),size:"small",color:"default",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}})]})}),(0,o.jsx)(_.A,{sx:{p:0,pl:2,pr:2,pb:1},children:(0,o.jsx)(l.default,{component:"pre",sx:{bgcolor:"action.hover",p:1,borderRadius:"4px",overflowX:"auto",fontFamily:"monospace",fontSize:"0.75rem",my:.5,maxHeight:"150px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:r})})]},e.id||"tc-".concat(a.id,"-").concat(t))})]}),"tool"===a.role&&a.tool_call_id&&(0,o.jsxs)(l.default,{children:[(0,o.jsxs)(u.default,{variant:"body2",sx:{display:"flex",alignItems:"center",color:"text.secondary",mb:1},children:[(0,o.jsx)(Q.A,{fontSize:"small",sx:{mr:1}}),"The tool responded to the assistant"]}),(0,o.jsxs)(L.A,{defaultExpanded:!1,sx:{mb:.5,"&:before":{display:"none"},boxShadow:"none",bgcolor:"rgba(0, 0, 0, 0.02)"},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),children:(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center"},children:[(0,o.jsx)(Q.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),(0,o.jsx)(u.default,{variant:"subtitle2",children:"Tool Result"}),(0,o.jsx)(R.A,{label:"ID: ".concat(a.tool_call_id.substring(0,8),"..."),size:"small",color:"default",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}}),(0,o.jsx)(M.A,{control:(0,o.jsx)(B.A,{size:"small",checked:g,onChange:e=>m(a.id,e.target.checked),onClick:e=>e.stopPropagation()}),label:"Raw",sx:{mr:1,ml:"auto","& .MuiTypography-root":{fontSize:"0.75rem"}},onClick:e=>e.stopPropagation()})]})}),(0,o.jsx)(_.A,{sx:{pt:0,pb:1,overflow:"hidden"},children:g?(0,o.jsx)(l.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontSize:"0.8rem",p:1,borderRadius:1,border:1,borderColor:e=>"dark"===e.palette.mode?"#3a3a3a":"#e5e7eb",bgcolor:"action.hover",color:e=>e.palette.text.primary,overflow:"auto",maxHeight:"300px"},children:"string"==typeof a.content?a.content:"[Invalid tool content]"}):(0,o.jsx)(l.default,{sx:{width:"100%",minWidth:0},children:"string"==typeof a.content?(()=>{try{let e=JSON.parse(a.content);if(e&&Array.isArray(e.content))return(0,o.jsx)(l.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.content.map((e,t)=>"text"===e.type?(0,o.jsx)(J.oz,{remarkPlugins:[q.A],children:e.text},t):"image"===e.type&&e.data&&e.mimeType?(0,o.jsx)("img",{src:"data:".concat(e.mimeType,";base64,").concat(e.data),alt:"Tool Result Image ".concat(t+1),style:{maxWidth:"100%",height:"auto",borderRadius:"4px",marginTop:"8px"}},t):"audio"===e.type&&e.data&&e.mimeType?(0,o.jsx)("audio",{controls:!0,src:"data:".concat(e.mimeType,";base64,").concat(e.data),style:{width:"100%",marginTop:"8px"},children:"Your browser does not support the audio element."},t):(0,o.jsx)(l.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontSize:"0.8rem",p:1,borderRadius:1,border:1,borderColor:e=>"dark"===e.palette.mode?"#3a3a3a":"#e5e7eb",bgcolor:"action.hover",color:e=>e.palette.text.primary,overflow:"auto",mt:1},children:"Unsupported content type: ".concat(e.type,"\n").concat(JSON.stringify(e,null,2))},t))});return(0,o.jsx)(J.oz,{remarkPlugins:[q.A],children:"```json\n".concat(JSON.stringify(e,null,2),"\n```")})}catch(e){return(0,o.jsx)(J.oz,{remarkPlugins:[q.A],children:a.content})}})():(0,o.jsx)(u.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",children:"[Invalid tool content]"})})})]})]}),a.attachments&&a.attachments.length>0&&(0,o.jsxs)(l.default,{sx:{mt:1,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,o.jsx)(u.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Attachments:"}),a.attachments.map(e=>"image"===e.type?(0,o.jsx)(l.default,{sx:{mb:.5},children:(0,o.jsx)("img",{src:e.content,alt:e.originalName||"image attachment",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}})},e.id):(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",p:1,borderRadius:1,bgcolor:"rgba(0, 0, 0, 0.04)",mb:.5},children:["document"===e.type?(0,o.jsx)(X.A,{fontSize:"small",sx:{mr:1}}):(0,o.jsx)(K.A,{fontSize:"small",sx:{mr:1}}),(0,o.jsx)(u.default,{variant:"caption",sx:{wordBreak:"break-all"},children:e.originalName||"".concat(e.type," attachment")})]},e.id))]})]})]})}),ed=e=>{let{messages:t,pendingToolCalls:n,availableNodes:a=[],conversationId:i,onToggleDisabled:s,onSplitConversation:d,onEditMessage:p,onApproveToolCall:g,onRejectToolCall:f}=e,h=(0,r.useRef)(null),[m,x]=(0,r.useState)(50);(0,r.useEffect)(()=>{x(50)},[i]);let b=Array.isArray(t)?t.length:0,v=Math.max(0,b-m),y=(0,r.useMemo)(()=>Array.isArray(t)?v>0?t.slice(v):t:[],[t,v]),w=b>0?t[b-1].id:void 0,j=(0,r.useRef)(void 0);(0,r.useEffect)(()=>{var e;w!==j.current&&(j.current=w,null==(e=h.current)||e.scrollIntoView({behavior:"smooth"}))},[w]);let[A,S]=r.useState(null),[C,k]=r.useState(null),[E,N]=r.useState(null),[T,z]=r.useState(!1),[P,O]=r.useState(""),[M,B]=r.useState(null),[J,q]=r.useState({}),G=(0,r.useCallback)((e,t)=>{ea.debug("handleMenuOpen called with messageId: ".concat(t)),S(e.currentTarget),k(t)},[]),X=(0,r.useCallback)((e,t)=>{q(n=>({...n,[e]:t}))},[]),K=(0,r.useCallback)(e=>{O(e)},[]),Q=(0,r.useCallback)(e=>{B(e)},[]),er=()=>{S(null),k(null)},el=()=>{if(C){let e=t.find(e=>e.id===C);e&&"user"===e.role&&"string"==typeof e.content&&(O(e.content),B(e.processNodeId||(a.length>0?a[0].id:"")),N(C),z(!0)),er()}},ei=()=>{E&&p&&(p(E,P,M||""),z(!1),N(null),B(null))},ed=()=>{z(!1),N(null),B(null)},ec=(0,r.useMemo)(()=>{let e=new Map;for(let t of a)e.set(t.id,t.label);return e},[a]),eu=(0,r.useMemo)(()=>C&&t.find(e=>e.id===C)||null,[C,t]);return(0,o.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:[v>0&&(0,o.jsx)(l.default,{sx:{display:"flex",justifyContent:"center"},children:(0,o.jsxs)(c.A,{size:"small",variant:"outlined",onClick:()=>x(e=>e+200),children:["Show earlier messages (",v," more)"]})}),y.map((e,t)=>{let n=T&&e.id===E;return(0,o.jsx)(es,{message:e,nodeLabel:e.processNodeId?ec.get(e.processNodeId):void 0,availableNodes:a,showRaw:!!J[e.id],edit:n?{content:P,nodeId:M}:null,onMenuOpen:G,onToggleRaw:X,onEditContentChange:K,onEditNodeChange:Q,onSaveEdit:n?ei:void 0,onCancelEdit:n?ed:void 0},e.id||"msg-".concat(v+t))}),(0,o.jsxs)(U.A,{anchorEl:A,open:!!A,onClose:er,children:[eu&&(()=>{ea.debug("Entering menu item rendering logic",{activeMessageId:C}),ea.debug("Active message object for menu:",eu),ea.debug("Active message role for menu:",null==eu?void 0:eu.role);try{let e=!!p,t="user"===eu.role&&e;if(ea.debug("Rendering Edit Message menu item check",{activeMessageId:eu.id,messageRole:eu.role,onEditMessagePropType:typeof p,hasOnEditMessageProp:e,shouldShowEdit:t}),t)return(0,o.jsxs)(F.A,{onClick:el,children:[(0,o.jsx)(H.A,{children:(0,o.jsx)(ee.A,{fontSize:"small"})}),(0,o.jsx)(I.A,{children:"Edit Message"})]});return null}catch(e){return ea.error("Error rendering Edit Message menu item",{error:e}),null}})(),(0,o.jsxs)(F.A,{onClick:()=>{C&&(s(C),er())},children:[(0,o.jsx)(H.A,{children:(0,o.jsx)(Y.A,{fontSize:"small"})}),(0,o.jsx)(I.A,{children:(null==eu?void 0:eu.disabled)?"Enable Message":"Disable Message"})]}),(0,o.jsxs)(F.A,{onClick:()=>{C&&(d(C),er())},children:[(0,o.jsx)(H.A,{children:(0,o.jsx)(V.A,{fontSize:"small"})}),(0,o.jsx)(I.A,{children:"Split Conversation Here"})]})]}),(0,o.jsx)("div",{ref:h}),n&&n.length>0&&(0,o.jsxs)(D.A,{elevation:2,sx:{p:2,mt:2,bgcolor:"warning.light",border:"1px solid",borderColor:"warning.main",borderRadius:2},children:[(0,o.jsxs)(u.default,{variant:"h6",sx:{mb:1,display:"flex",alignItems:"center"},children:[(0,o.jsx)($.A,{sx:{mr:1}})," Tool Approval Required"]}),(0,o.jsx)(u.default,{variant:"body2",sx:{mb:2},children:"The assistant wants to use the following tool(s). Please approve or reject each request."}),n.map((e,t)=>{let n=(0,eo.yo)(e.function.name),r=e.function.arguments;try{let t=JSON.parse(e.function.arguments);r=JSON.stringify(t,null,2)}catch(e){}return(0,o.jsxs)(L.A,{defaultExpanded:!0,sx:{mb:1,"&:before":{display:"none"},boxShadow:1},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),children:(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",width:"100%"},children:[(0,o.jsx)($.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),(0,o.jsx)(u.default,{variant:"subtitle2",sx:{fontWeight:"bold",flexGrow:1},children:n}),(0,o.jsx)(R.A,{label:"ID: ".concat(e.id?e.id.substring(0,8):"N/A","..."),size:"small",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}})]})}),(0,o.jsxs)(_.A,{sx:{pt:0},children:[(0,o.jsx)(l.default,{component:"pre",sx:{bgcolor:"action.hover",p:1,borderRadius:"4px",overflowX:"auto",fontFamily:"monospace",fontSize:"0.75rem",my:.5,maxHeight:"150px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:r}),(0,o.jsxs)(l.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:1},children:[(0,o.jsx)(c.A,{variant:"outlined",color:"error",size:"small",startIcon:(0,o.jsx)(en.A,{}),onClick:()=>f&&f(e.id),disabled:!f,children:"Reject"}),(0,o.jsx)(c.A,{variant:"contained",color:"success",size:"small",startIcon:(0,o.jsx)(et.A,{}),onClick:()=>g&&g(e.id),disabled:!g,children:"Approve"})]})]})]},e.id||"ptc-".concat(t))})]})]})};var ec=n(84869);let eu=(0,er.h)("frontend/services/transcription");async function ep(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onProgress:n,onStatusChange:o,language:r}=t;try{if(eu.debug("Starting transcription service"),o&&o("Initializing transcription..."),!(0,ec.G)().supported)throw Error("Web Speech API is not supported in this browser");o&&o("Using browser speech recognition...");let t=await (0,ec.S)(e,{language:r,onInterimResult:e=>{o&&o("Transcribing: ".concat(e)),n&&n(50)}});return o&&o("Transcription completed"),eu.debug("Web Speech API transcription completed successfully",{textLength:t.length}),{text:t,success:!0,engine:"webspeech"}}catch(e){return eu.error("Transcription failed",{error:e}),o&&o("Transcription failed"),{text:"Transcription failed. Please check if your browser supports speech recognition.",success:!1,error:e instanceof Error?e.message:String(e)}}}var eg=n(9164),ef=n(9562),eh=n(22822),em=n(4474),ex=n(35205),eb=n(77073),ev=n(55930),ey=n(9693),ew=n(4823),ej=n(74879);let eA=(0,er.h)("frontend/components/Chat/ChatInput"),eS=e=>{var t;let{onSendMessage:n,disabled:a=!1,requireApproval:d=!1,onRequireApprovalChange:h,executeInDebugger:x=!1,onExecuteInDebuggerChange:b,availableNodes:v=[],currentNodeId:y=null,nodeOverrideActive:w=!1,onSelectNode:A}=e,{settings:S}=(0,eg.useStorage)(),[C,k]=(0,r.useState)(""),[E,N]=(0,r.useState)([]),[T,z]=(0,r.useState)(!1),[P,O]=(0,r.useState)(0),[L,W]=(0,r.useState)(null),_=(0,r.useRef)(null),B=(0,r.useRef)(null),J=(0,r.useRef)([]),[q,G]=(0,r.useState)(null),Y=(null==(t=v.find(e=>e.id===y))?void 0:t.label)||(y?"".concat(y.substring(0,6),"..."):"Start"),[V,Z]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(""),[ee,et]=(0,r.useState)(""),[en,eo]=(0,r.useState)("document"),[er,ea]=(0,r.useState)(!1),[el,ei]=(0,r.useState)(0),[es,ed]=(0,r.useState)(""),ec=()=>{(C.trim()||E.length>0)&&(eA.debug("Sending message",{messageLength:C.length,attachmentsCount:E.length}),n(C,E),k(""),N([]))},eu=async e=>{let t=e.target.files;if(!t||0===t.length)return;let n=t[0];eA.debug("File selected",{fileName:n.name,fileSize:n.size,fileType:n.type}),et("Processing ".concat(n.name)),eo("document"),Q(""),ea(!0),Z(!0);try{let e=await eS(n);eA.debug("File read successfully",{contentLength:e.length}),Q(e),ea(!1)}catch(e){eA.error("Error reading file:",e),Q("Error reading file. Please try again with a text file."),ea(!1)}_.current&&(_.current.value="")},eS=e=>new Promise((t,n)=>{let o=new FileReader;o.onload=e=>{var o;(null==(o=e.target)?void 0:o.result)?t(e.target.result):n(Error("Failed to read file"))},o.onerror=()=>{n(Error("Error reading file"))},o.readAsText(e)}),eI=async()=>{eA.debug("Starting audio recording");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});eA.debug("Audio stream obtained successfully"),J.current=[];let t=new MediaRecorder(e);B.current=t,t.ondataavailable=e=>{e.data.size>0&&J.current.push(e.data)},t.onstop=async()=>{let t=new Blob(J.current,{type:"audio/wav"});et("Audio Recording"),eo("audio"),Q(""),ea(!0),Z(!0);try{if(((null==S?void 0:S.speech)||{enabled:!0,modelSize:"base",autoDownload:!1}).enabled){ed("Initializing transcription..."),ei(0);let e=await ep(t,{onProgress:ei,onStatusChange:ed,language:navigator.language});if(e.success){let t=e.text;Q(t),eA.debug("Transcription successful",{textLength:e.text.length,engine:e.engine})}else Q("Error transcribing audio: ".concat(e.error,".")),eA.error("Transcription failed",{error:e.error})}else Q("Speech recognition is disabled in settings. Enable it to get automatic transcriptions.")}catch(e){eA.error("Error handling audio recording",{error:e}),Q("Failed to process audio: ".concat(e))}finally{ea(!1),e.getTracks().forEach(e=>e.stop())}},t.start(),z(!0);let n=setInterval(()=>{O(e=>e+1)},1e3);W(n)}catch(e){eA.error("Error starting recording:",e),alert("Could not access microphone. Please check permissions.")}};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(D.A,{elevation:3,sx:{p:2,display:"flex",flexDirection:"column",borderRadius:2},children:[E.length>0&&(0,o.jsx)(l.default,{sx:{mb:2,display:"flex",flexWrap:"wrap",gap:1},children:E.map(e=>(0,o.jsxs)(D.A,{variant:"outlined",sx:{p:1,display:"flex",alignItems:"center",borderRadius:1,bgcolor:"background.default"},children:["image"===e.type?(0,o.jsx)(l.default,{component:"img",src:e.content,alt:e.originalName||"pasted image",sx:{width:40,height:40,objectFit:"cover",borderRadius:1,mr:1}}):"document"===e.type?(0,o.jsx)(X.A,{fontSize:"small",sx:{mr:1}}):(0,o.jsx)(K.A,{fontSize:"small",sx:{mr:1}}),(0,o.jsx)(u.default,{variant:"body2",noWrap:!0,sx:{maxWidth:150},children:e.originalName||"".concat(e.type," attachment")}),(0,o.jsx)(s.A,{size:"small",onClick:()=>(e=>{eA.debug("Removing attachment",{id:e}),N(E.filter(t=>t.id!==e))})(e.id),sx:{ml:1},children:(0,o.jsx)(eb.A,{fontSize:"small"})})]},e.id))}),(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"flex-end"},children:[(0,o.jsx)(ef.A,{fullWidth:!0,multiline:!0,maxRows:4,"data-tour":"chat-input",placeholder:"Type a message...",value:C,onChange:e=>{k(e.target.value)},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(eA.debug("Enter key pressed, sending message"),e.preventDefault(),ec())},onPaste:e=>{var t;let n=null==(t=e.clipboardData)?void 0:t.items;if(!n)return;let o=[];for(let e=0;e<n.length;e++){let t=n[e];if("file"===t.kind&&t.type.startsWith("image/")){let e=t.getAsFile();e&&o.push(e)}}0!==o.length&&(e.preventDefault(),eA.debug("Pasting image attachment(s)",{count:o.length}),o.forEach(e=>{let t=new FileReader;t.onload=t=>{var n;let o=null==(n=t.target)?void 0:n.result;if("string"!=typeof o)return;let r=(e.type.split("/")[1]||"png").split("+")[0];N(t=>[...t,{id:(0,ej.A)(),type:"image",content:o,originalName:e.name&&!/^image\.\w+$/i.test(e.name)?e.name:"Pasted image.".concat(r)}])},t.onerror=()=>eA.error("Failed to read pasted image"),t.readAsDataURL(e)}))},disabled:a,variant:"outlined",sx:{mr:1},InputProps:{sx:{borderRadius:2}}}),(0,o.jsx)(i.A,{title:"Attach document",children:(0,o.jsx)(s.A,{color:"primary",onClick:()=>{var e;eA.debug("File selection triggered"),null==(e=_.current)||e.click()},disabled:a||T,children:(0,o.jsx)(X.A,{})})}),(0,o.jsx)("input",{type:"file",ref:_,onChange:eu,style:{display:"none"},accept:".txt,.md,.json,.csv,.html,.xml,.js,.ts,.jsx,.tsx,.css,.scss"}),(0,o.jsx)(i.A,{title:T?"Stop recording":"Record audio",children:(0,o.jsxs)(s.A,{color:T?"error":"primary",onClick:T?()=>{eA.debug("Stopping audio recording"),B.current&&"inactive"!==B.current.state&&(B.current.stop(),z(!1),L&&(clearInterval(L),W(null)),O(0))}:eI,disabled:a,children:[(0,o.jsx)(K.A,{}),T&&(0,o.jsx)(u.default,{variant:"caption",sx:{position:"absolute",bottom:-15,fontSize:"0.7rem",color:"error.main"},children:(e=>{let t=Math.floor(e/60);return"".concat(t.toString().padStart(2,"0"),":").concat((e%60).toString().padStart(2,"0"))})(P)})]})}),(0,o.jsx)(i.A,{title:"Send message",children:(0,o.jsx)(s.A,{color:"primary",onClick:ec,disabled:a||!C.trim()&&0===E.length,children:(0,o.jsx)(ex.A,{})})})]})," ",(h||A&&v.length>0)&&(0,o.jsxs)(l.default,{sx:{mt:1,display:"flex",justifyContent:"flex-start",alignItems:"center",flexWrap:"wrap",gap:1},children:[A&&v.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{title:w?"Next message will run on this manually picked node — click to change":"Node the next message will run on — click to pick a different one",children:(0,o.jsx)(R.A,{icon:(0,o.jsx)(ev.A,{}),label:Y,size:"small",color:w?"primary":"default",variant:w?"filled":"outlined",onClick:e=>G(e.currentTarget),disabled:a})}),(0,o.jsxs)(U.A,{anchorEl:q,open:!!q,onClose:()=>G(null),children:[(0,o.jsxs)(F.A,{selected:!w,onClick:()=>{A(null),G(null)},children:[(0,o.jsx)(H.A,{children:(0,o.jsx)(ew.A,{fontSize:"small"})}),(0,o.jsx)(I.A,{primary:"Automatic",secondary:"Follow the conversation",secondaryTypographyProps:{variant:"caption"}})]}),(0,o.jsx)(j.A,{}),v.map(e=>(0,o.jsxs)(F.A,{selected:w&&e.id===y,onClick:()=>{A(e.id),G(null)},children:[(0,o.jsx)(H.A,{children:e.id===y?(0,o.jsx)(ey.A,{fontSize:"small"}):null}),(0,o.jsx)(I.A,{primary:e.label})]},e.id))]})]}),h&&(0,o.jsx)(M.A,{control:(0,o.jsx)(eh.A,{checked:d,onChange:e=>h(e.target.checked),size:"small",disabled:a}),label:(0,o.jsx)(u.default,{variant:"caption",children:"Require Tool Approvals"}),sx:{mr:"auto"}}),b&&(0,o.jsx)(M.A,{control:(0,o.jsx)(eh.A,{checked:x,onChange:e=>b(e.target.checked),size:"small",disabled:a}),label:(0,o.jsx)(u.default,{variant:"caption",children:"Execute in Debugger"}),sx:{ml:2}})]})," "]})," ",(0,o.jsxs)(p.A,{open:V,onClose:()=>!er&&Z(!1),maxWidth:"md",fullWidth:!0,children:[(0,o.jsxs)(g.A,{children:[ee,!er&&(0,o.jsx)(s.A,{"aria-label":"close",onClick:()=>Z(!1),sx:{position:"absolute",right:8,top:8},children:(0,o.jsx)(eb.A,{})})]}),(0,o.jsx)(f.A,{dividers:!0,children:er?(0,o.jsxs)(l.default,{sx:{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",p:4},children:[(0,o.jsx)(em.default,{value:"audio"===en&&el?el:void 0,variant:"audio"===en&&el>0?"determinate":"indeterminate"}),"audio"===en&&(0,o.jsxs)(l.default,{sx:{mt:2,textAlign:"center"},children:[(0,o.jsx)(u.default,{variant:"body2",children:es||"Processing audio..."}),el>0&&(0,o.jsxs)(u.default,{variant:"body2",color:"text.secondary",sx:{mt:1},children:[Math.round(el),"%"]})]})]}):(0,o.jsx)(ef.A,{multiline:!0,fullWidth:!0,minRows:10,maxRows:20,value:$,onChange:e=>Q(e.target.value),variant:"outlined",placeholder:"document"===en?"Document content":"Audio transcription"})}),(0,o.jsxs)(m.A,{children:[(0,o.jsx)(c.A,{onClick:()=>Z(!1),disabled:er,children:"Cancel"}),(0,o.jsx)(c.A,{onClick:()=>{eA.debug("Adding attachment",{type:en,titleLength:ee.length}),N([...E,{id:(0,ej.A)(),type:en,content:$,originalName:ee}]),Z(!1)},variant:"contained",disabled:er||!$.trim(),children:"Add to Message"})]})]})]})},eI=e=>{var t;let{liveStats:n,onStop:a,stopDisabled:i}=e,[s,d]=(0,r.useState)(()=>Date.now());(0,r.useEffect)(()=>{let e=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=n?Math.max(0,Math.round((s-n.startedAt)/1e3)):0,g=n?Math.round((s-n.lastEventAt)/1e3):0,f=!!n&&g>=60;return(0,o.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",alignItems:"center",my:2,gap:.5},children:[(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,o.jsx)(em.default,{size:20,color:f?"warning":"primary"}),(0,o.jsx)(u.default,{variant:"body2",color:"textSecondary",children:(null==n?void 0:n.activeNode)?"Running: ".concat(n.activeNode):"Working…"}),(0,o.jsx)(c.A,{variant:"outlined",color:"secondary",size:"small",onClick:a,disabled:i,children:"Stop"})]}),(0,o.jsxs)(u.default,{variant:"caption",color:f?"warning.main":"textSecondary",children:[(null!=(t=null==n?void 0:n.totalTokens)?t:0).toLocaleString()," tokens \xb7 ",p,"s elapsed",f?" \xb7 no activity for ".concat(g,"s — may be stuck"):""]})]})};var eC=n(88538),ek=n(16963),eE=n(2456),eN=n(64792),eT=n(71356),eR=n(45202),eD=n(52005),ez=n(77998);let eP=e=>e>=1e3?"".concat((e/1e3).toFixed(e>=1e5?0:1),"k"):"".concat(e),eO=e=>{let{usage:t,contextInfo:n,availableNodes:a}=e,[s,d]=(0,r.useState)(null);if(!t&&!n)return null;let c=(null==t?void 0:t.byNode)?Object.entries(t.byNode):[],p=(null==n?void 0:n.contextWindow)&&n.contextWindow>0?Math.min(100,Math.round(n.promptTokens/n.contextWindow*100)):void 0;return(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0},children:[t&&t.totalTokens>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.A,{title:"Total tokens this conversation — ".concat(t.promptTokens.toLocaleString()," prompt / ").concat(t.completionTokens.toLocaleString()," completion. Click for the per-node breakdown."),children:(0,o.jsx)(R.A,{icon:(0,o.jsx)(ez.A,{}),label:"".concat(eP(t.totalTokens)," tokens"),size:"small",variant:"outlined",onClick:e=>d(e.currentTarget),sx:{cursor:"pointer"}})}),(0,o.jsx)(eC.Ay,{open:!!s,anchorEl:s,onClose:()=>d(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,o.jsxs)(l.default,{sx:{p:2,maxWidth:420},children:[(0,o.jsx)(u.default,{variant:"subtitle2",sx:{mb:1},children:"Token usage by node"}),(0,o.jsxs)(ek.A,{size:"small",children:[(0,o.jsx)(eE.A,{children:(0,o.jsxs)(eN.A,{children:[(0,o.jsx)(eT.A,{children:"Node"}),(0,o.jsx)(eT.A,{align:"right",children:"Prompt"}),(0,o.jsx)(eT.A,{align:"right",children:"Completion"}),(0,o.jsx)(eT.A,{align:"right",children:"Total"})]})}),(0,o.jsxs)(eR.A,{children:[c.map(e=>{let[t,n]=e;return(0,o.jsxs)(eN.A,{children:[(0,o.jsx)(eT.A,{children:(0,o.jsx)(i.A,{title:t,children:(0,o.jsx)("span",{children:(e=>{var t;return(null==(t=a.find(t=>t.id===e))?void 0:t.label)||"".concat(e.substring(0,8),"…")})(t)})})}),(0,o.jsx)(eT.A,{align:"right",children:n.promptTokens.toLocaleString()}),(0,o.jsx)(eT.A,{align:"right",children:n.completionTokens.toLocaleString()}),(0,o.jsx)(eT.A,{align:"right",children:n.totalTokens.toLocaleString()})]},t)}),(0,o.jsxs)(eN.A,{children:[(0,o.jsx)(eT.A,{sx:{fontWeight:"bold"},children:"Total"}),(0,o.jsx)(eT.A,{align:"right",sx:{fontWeight:"bold"},children:t.promptTokens.toLocaleString()}),(0,o.jsx)(eT.A,{align:"right",sx:{fontWeight:"bold"},children:t.completionTokens.toLocaleString()}),(0,o.jsx)(eT.A,{align:"right",sx:{fontWeight:"bold"},children:t.totalTokens.toLocaleString()})]})]})]})]})})]}),n&&void 0!==p&&(0,o.jsx)(i.A,{title:"Context of the latest call".concat(n.modelDisplayName?" (".concat(n.modelDisplayName,")"):"",": ").concat(n.promptTokens.toLocaleString()," of ").concat(n.contextWindow.toLocaleString()," tokens"),children:(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:140},children:[(0,o.jsx)(eD.A,{variant:"determinate",value:p,color:p>=90?"error":p>=70?"warning":"primary",sx:{flex:1,height:6,borderRadius:3}}),(0,o.jsxs)(u.default,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:[eP(n.promptTokens),"/",eP(n.contextWindow)," (",p,"%)"]})]})}),n&&void 0===p&&(0,o.jsx)(i.A,{title:"Prompt size of the latest call".concat(n.modelDisplayName?" (".concat(n.modelDisplayName,")"):"",". Set the model's Context Window in its settings to see a usage meter."),children:(0,o.jsxs)(u.default,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:["ctx ",eP(n.promptTokens)]})})]})};var eF=n(18369),eL=n(90057);let eW=e=>{let{selectedFlowId:t,onSelectFlow:n,disabled:a=!1}=e,[i,s]=(0,r.useState)([]),[d,c]=(0,r.useState)(!0),[p,g]=(0,r.useState)(null);return(0,r.useEffect)(()=>{(async()=>{c(!0),g(null);try{let e=await eL.g.loadFlows();s(e)}catch(e){console.error("Error loading flows:",e),g("Failed to load flows")}finally{c(!1)}})()},[]),(0,o.jsxs)(l.default,{children:[(0,o.jsx)(u.default,{variant:"subtitle1",gutterBottom:!0,children:"Select Flow"}),d?(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,o.jsx)(em.default,{size:20}),(0,o.jsx)(u.default,{variant:"body2",color:"text.secondary",children:"Loading flows..."})]}):p?(0,o.jsx)(u.default,{color:"error",variant:"body2",children:p}):0===i.length?(0,o.jsx)(u.default,{variant:"body2",color:"text.secondary",children:"No flows available. Create some flows in the Flow Builder first."}):(0,o.jsxs)(z.A,{fullWidth:!0,disabled:a,children:[" ",(0,o.jsx)(P.A,{id:"flow-select-label",children:"Flow"}),(0,o.jsx)(O.A,{labelId:"flow-select-label",id:"flow-select",value:t||"",label:"Flow",onChange:e=>{n(e.target.value)},disabled:a,children:i.map(e=>(0,o.jsx)(F.A,{value:e.id,children:e.name},e.id))}),(0,o.jsx)(eF.A,{children:t?'Using "'.concat((()=>{if(!t)return"";let e=i.find(e=>e.id===t);return e?e.name:""})(),'" flow for this conversation'):"Select a flow to use for this conversation"})]})]})};var e_=n(53940),eM=n(48116),eB=n(33567),eU=n(22539),eH=n(33420),eJ=n(80685);let eq=(0,er.h)("frontend/components/Chat/DebuggerCanvas"),eG={start:eH.vm,process:eH.Uw,finish:eH.IK,mcp:eH.v2,subflow:eH.lA},eY={custom:eJ.jY,mcpEdge:eJ.oY},eV=(0,eM.Ay)(D.A)(e=>{let{theme:t}=e;return{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",padding:t.spacing(1)}}),eX=(0,eM.Ay)(l.default)(e=>{let{theme:t}=e;return{padding:t.spacing(1,2),borderBottom:"1px solid ".concat(t.palette.divider)}}),eK=(0,eM.Ay)(l.default)({flexGrow:1,display:"flex",overflow:"hidden"}),eZ=(0,eM.Ay)(l.default)(e=>{let{theme:t}=e;return{width:"200px",borderRight:"1px solid ".concat(t.palette.divider),overflowY:"auto",padding:t.spacing(1)}}),e$=(0,eM.Ay)(l.default)({flexGrow:1,position:"relative",height:"100%"}),eQ=(0,eM.Ay)(l.default)(e=>{let{theme:t}=e;return{width:"300px",borderLeft:"1px solid ".concat(t.palette.divider),overflowY:"auto",padding:t.spacing(2)}}),e0=(0,eM.Ay)(l.default)(e=>{let{theme:t}=e;return{padding:t.spacing(1,2),borderTop:"1px solid ".concat(t.palette.divider),display:"flex",gap:t.spacing(1),justifyContent:"center"}}),e1=e=>{var t,n,a,p;let{debugState:g,conversationId:f,onStep:h,onStepOver:m,onContinue:x,onCancel:b,isLoading:v,breakpoints:y,onToggleBreakpoint:w,onClose:j}=e,k=(0,eB.A)(),[E,N]=(0,r.useState)(g.executionTrace&&g.executionTrace.length>0?g.executionTrace.length-1:-1),[T,R]=(0,r.useState)(!0),[D,z]=(0,r.useState)(!0),[P,O]=(0,r.useState)(null),[F,M]=(0,r.useState)(!0),[B,U]=(0,r.useState)(null),[H,J,q]=(0,eU.ck)([]),[G,Y,V]=(0,eU.fM)([]);(0,r.useEffect)(()=>{var e;let t=(null==(e=g.executionTrace)?void 0:e.length)||0;t>0?(N(e=>Math.min(e,t-1)),E<t-1&&N(t-1)):N(-1)},[g.executionTrace]),(0,r.useEffect)(()=>{(async()=>{if(!g.flowId){U("Flow ID is missing in debug state."),M(!1);return}M(!0),U(null);try{eq.debug("Loading flow definition for ID: ".concat(g.flowId));let e=await eL.g.getFlow(g.flowId);if(!e)throw Error("Flow with ID ".concat(g.flowId," not found."));O(e),eq.info("Flow definition loaded: ".concat(e.name))}catch(e){eq.error("Error loading flow definition:",e),U(e instanceof Error?e.message:"Failed to load flow definition."),O(null)}finally{M(!1)}})()},[g.flowId]),(0,r.useEffect)(()=>{if(P){eq.debug("Setting nodes and edges from flow definition");let e=P.nodes.map(e=>({...e,draggable:!1,selectable:!1,connectable:!1})),t=P.edges.map(e=>({...e,selectable:!1}));J(e),Y(t)}},[P,J,Y]);let X=(0,r.useCallback)(()=>{if(eq.debug("Previous button clicked. Current index: ".concat(E)),E>0){let e=E-1;eq.debug("Setting current step index to: ".concat(e)),N(e)}else eq.debug("Already at the first step, cannot go previous.")},[E]),K=(0,r.useCallback)(()=>{var e;if(eq.debug("Next button clicked. Current index: ".concat(E,", Trace length: ").concat(null==(e=g.executionTrace)?void 0:e.length)),g.executionTrace&&E<g.executionTrace.length-1){let e=E+1;eq.debug("Navigating to next trace step: ".concat(e)),N(e)}else eq.info("At end of trace, triggering API call for next step."),h()},[E,g.executionTrace,h]),$=(0,r.useMemo)(()=>{if(g.executionTrace&&E>=0&&E<g.executionTrace.length)return g.executionTrace[E]},[g.executionTrace,E]),Q=(0,r.useMemo)(()=>{let e=null==$?void 0:$.nodeId;return H.map(t=>{var n;let o=t.id===e,r=null==y?void 0:y.includes(t.id);return{...t,style:{...t.style,border:o?"2px solid ".concat(k.palette.warning.main):r?"2px dashed ".concat(k.palette.error.main):null==(n=t.style)?void 0:n.border,boxShadow:o?"0 0 10px ".concat(k.palette.warning.light):void 0}}})},[H,$,y,k]);return(0,o.jsxs)(eV,{elevation:2,children:[(0,o.jsxs)(eX,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,o.jsxs)(l.default,{children:[(0,o.jsx)(u.default,{variant:"h6",children:"Flow Debugger"}),(0,o.jsxs)(u.default,{variant:"caption",color:"textSecondary",display:"block",children:["Click a node to toggle a breakpoint",y&&y.length>0?" \xb7 ".concat(y.length," active"):""]})]}),(0,o.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,o.jsx)(i.A,{title:T?"Hide execution trace":"Show execution trace",children:(0,o.jsx)(s.A,{size:"small",onClick:()=>R(e=>!e),color:T?"primary":"default","aria-label":T?"Hide execution trace":"Show execution trace",children:(0,o.jsx)(e_.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})})}),(0,o.jsx)(i.A,{title:D?"Hide step inspector":"Show step inspector",children:(0,o.jsx)(s.A,{size:"small",onClick:()=>z(e=>!e),color:D?"primary":"default","aria-label":D?"Hide step inspector":"Show step inspector",children:(0,o.jsx)(e_.A,{fontSize:"small"})})}),j&&(0,o.jsx)(i.A,{title:"Close debugger",children:(0,o.jsx)(s.A,{size:"small",onClick:j,"aria-label":"Close debugger",children:(0,o.jsx)(eb.A,{fontSize:"small"})})})]})]}),(0,o.jsxs)(eK,{children:[T&&(0,o.jsxs)(eZ,{children:[(0,o.jsx)(u.default,{variant:"subtitle2",gutterBottom:!0,children:"Execution Trace"}),(0,o.jsxs)(A.A,{dense:!0,disablePadding:!0,children:[null==(t=g.executionTrace)?void 0:t.map((e,t)=>(0,o.jsx)(S.Ay,{disablePadding:!0,children:(0,o.jsx)(C.A,{selected:t===E,onClick:()=>(e=>{g.executionTrace&&e>=0&&e<g.executionTrace.length?(eq.debug("Trace step selected: ".concat(e)),N(e)):eq.warn("Invalid step index selected: ".concat(e)),N(e),N(e)})(t),children:(0,o.jsx)(I.A,{primary:"".concat(e.stepIndex,": ").concat(e.nodeName||e.nodeId),secondary:e.nodeType})})},e.stepIndex)),v&&(0,o.jsx)(S.Ay,{children:(0,o.jsx)(em.default,{size:20,sx:{margin:"auto"}})})]})]}),(0,o.jsx)(e$,{children:F?(0,o.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(em.default,{})}):B?(0,o.jsx)(d.A,{severity:"error",sx:{margin:2},children:B}):(0,o.jsxs)(eU.Ln,{children:[" ",(0,o.jsx)(eU.Gc,{nodes:Q,edges:G,onNodesChange:q,onEdgesChange:V,nodeTypes:eG,edgeTypes:eY,fitView:!0,attributionPosition:"bottom-right",nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!1,onNodeClick:(e,t)=>{e.preventDefault(),w&&w(t.id)},onEdgeClick:e=>e.preventDefault(),onPaneClick:()=>{},children:" "})]})}),D&&(0,o.jsxs)(eQ,{children:[(0,o.jsx)(u.default,{variant:"subtitle2",gutterBottom:!0,children:"Step Inspector"}),$?(0,o.jsxs)(l.default,{children:[(0,o.jsxs)(u.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Node:"})," ",$.nodeName," (",$.nodeId,")"]}),(0,o.jsxs)(u.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Type:"})," ",$.nodeType]}),(0,o.jsxs)(u.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Timestamp:"})," ",new Date($.timestamp).toLocaleString()]}),(0,o.jsxs)(u.default,{variant:"body2",children:[(0,o.jsx)("b",{children:"Action Taken:"})," ",$.actionTaken]}),(0,o.jsxs)(L.A,{sx:{mt:2,boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsx)(u.default,{variant:"caption",children:"Prep Result"})}),(0,o.jsx)(_.A,{sx:{p:0},children:(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify($.prepResultSnapshot,null,2)})})]}),(0,o.jsxs)(L.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsxs)(u.default,{variant:"caption",color:(null==(n=$.execResultSnapshot)?void 0:n.success)===!1?"error":"inherit",children:["Exec Result ",(null==(a=$.execResultSnapshot)?void 0:a.success)===!1?"(Error)":""]})}),(0,o.jsx)(_.A,{sx:{p:0},children:(null==(p=$.execResultSnapshot)?void 0:p.success)===!1?(0,o.jsxs)(l.default,{sx:{p:1,background:k.palette.error.light,borderRadius:1},children:[" ",(0,o.jsxs)(u.default,{variant:"body2",color:"error",gutterBottom:!0,children:[(0,o.jsx)("b",{children:"Error:"})," ",$.execResultSnapshot.error||"Unknown error"]}),$.execResultSnapshot.errorDetails&&(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"150px",overflowY:"auto",background:"#f5f5f5",padding:"4px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify($.execResultSnapshot.errorDetails,null,2)})]}):(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify($.execResultSnapshot,null,2)})})]}),(0,o.jsxs)(L.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsx)(u.default,{variant:"caption",children:"State Before"})}),(0,o.jsx)(_.A,{sx:{p:0},children:(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify($.stateBefore,null,2)})})]}),(0,o.jsxs)(L.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,o.jsx)(W.A,{expandIcon:(0,o.jsx)(Z.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,o.jsx)(u.default,{variant:"caption",children:"State After"})}),(0,o.jsx)(_.A,{sx:{p:0},children:(0,o.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"200px",overflowY:"auto",background:"#f5f5f5",padding:"8px",borderRadius:"4px",fontSize:"0.75rem",margin:0},children:JSON.stringify($.stateAfter,null,2)})})]})]}):(0,o.jsx)(u.default,{variant:"body2",color:"textSecondary",children:"Select a step from the trace."})]})]}),(0,o.jsxs)(e0,{children:[(0,o.jsx)(c.A,{variant:"outlined",size:"small",onClick:X,disabled:v||E<=0,children:"Previous"}),(0,o.jsx)(c.A,{variant:"contained",size:"small",onClick:K,disabled:v||-1===E,children:g.executionTrace&&E<g.executionTrace.length-1?"Next Trace Step":"Step Next"}),m&&(0,o.jsx)(c.A,{variant:"outlined",size:"small",onClick:m,disabled:v,children:"Step Over"}),(0,o.jsx)(c.A,{variant:"contained",color:"secondary",size:"small",onClick:x,disabled:v,children:"Continue"}),(0,o.jsx)(c.A,{variant:"outlined",color:"error",size:"small",onClick:b,disabled:v,children:"Stop"})]})]})};var e2=n(94929),e5=n(29155),e4=n(63650);let e6=(0,er.h)("frontend/services/chat/index");class e7 extends Error{constructor(e,t,n){super(e),this.name="ChatApiError",this.status=t,this.body=n}}let e3="/v1/chat/conversations";async function e8(e){let t;if(204===e.status)return;let n=await e.text();if(n)try{t=JSON.parse(n)}catch(e){t=n}if(!e.ok)throw new e7(t&&"object"==typeof t&&(t.error||t.message)||"Request failed with status ".concat(e.status),e.status,t);return t}class e9{async listConversations(){return e6.debug("listConversations: Entering method"),e8(await fetch(e3))}async getConversation(e){return e6.debug("getConversation: Entering method",{conversationId:e}),e8(await fetch("".concat(e3,"/").concat(encodeURIComponent(e))))}async createConversation(e){return e6.debug("createConversation: Entering method",{conversationId:e.id}),e8(await fetch(e3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}))}async updateConversationFlow(e,t){return e6.debug("updateConversationFlow: Entering method",{conversationId:e,flowId:t}),e8(await fetch("".concat(e3,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:t})}))}async updateConversationApproval(e,t){return e6.debug("updateConversationApproval: Entering method",{conversationId:e,requireApproval:t}),e8(await fetch("".concat(e3,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApproval:t})}))}async deleteConversation(e){e6.debug("deleteConversation: Entering method",{conversationId:e});let t=await fetch("".concat(e3,"/").concat(encodeURIComponent(e)),{method:"DELETE"});await e8(t)}async respondToToolCall(e,t,n){return e6.debug("respondToToolCall: Entering method",{conversationId:e,action:t,toolCallId:n}),e8(await fetch("".concat(e3,"/").concat(encodeURIComponent(e),"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,toolCallId:n})}))}async debugStep(e){return e6.debug("debugStep: Entering method",{conversationId:e}),e8(await fetch("".concat(e3,"/").concat(encodeURIComponent(e),"/debug/step"),{method:"POST"}))}async debugContinue(e){return e6.debug("debugContinue: Entering method",{conversationId:e}),e8(await fetch("".concat(e3,"/").concat(encodeURIComponent(e),"/debug/continue"),{method:"POST"}))}async setBreakpoints(e,t){e6.debug("setBreakpoints: Entering method",{conversationId:e,count:t.length});let n=await fetch("".concat(e3,"/").concat(encodeURIComponent(e),"/breakpoints"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({breakpoints:t})});await e8(n)}async cancel(e){e6.debug("cancel: Entering method",{conversationId:e});let t=await fetch("".concat(e3,"/").concat(encodeURIComponent(e),"/cancel"),{method:"POST"});await e8(t)}subscribeToEvents(e,t,n){let o=new EventSource(void 0!==n?"".concat(e3,"/").concat(encodeURIComponent(e),"/events?fromSeq=").concat(n):"".concat(e3,"/").concat(encodeURIComponent(e),"/events"));return o.onopen=()=>{var n;e6.debug("Execution event stream open",{conversationId:e}),null==(n=t.onOpen)||n.call(t)},o.onmessage=e=>{try{t.onEvent(JSON.parse(e.data))}catch(e){e6.warn("Failed to parse SSE event",{err:e})}},o.onerror=e=>{var n;e6.debug("SSE stream error (browser will retry if still open)"),null==(n=t.onError)||n.call(t,e)},o}}let te=new e9,tt=(0,er.h)("frontend/components/Chat/index");function tn(e){var t;if(Array.isArray(e.content))return e.content;let n="string"==typeof e.content?e.content:"",o=null!=(t=e.attachments)?t:[],r=o.filter(e=>"image"!==e.type),a=o.filter(e=>"image"===e.type);if(r.length>0&&(n+="\n\n"+r.map(e=>"[".concat(e.type.toUpperCase(),"]: ").concat(e.content)).join("\n\n")),0===a.length)return n;let l=[];for(let e of(n.trim()&&l.push({type:"text",text:n}),a))l.push({type:"image_url",image_url:{url:e.content}});return l}let to=()=>{var e;let[t,n]=(0,r.useState)([]),[a,j]=(0,r.useState)(!0),[A,S]=(0,r.useState)(null),[I,C]=(0,r.useState)(null),[k,E]=(0,r.useState)(!1),[N,R]=(0,r.useState)(null),[D,z]=(0,w.Mj)(w.Zg.CURRENT_CONVERSATION_ID,null),[P,O]=(0,r.useState)(!1),[F,L]=(0,r.useState)(new Set),W=(0,r.useCallback)((e,t)=>{e&&L(n=>{if(t===n.has(e))return n;let o=new Set(n);return t?o.add(e):o.delete(e),o})},[]),[_,M]=(0,r.useState)(null),[B,U]=(0,r.useState)([]),[H,J]=(0,r.useState)(!1),[q,G]=(0,r.useState)(!1),[Y,V]=(0,r.useState)(null),[X,K]=(0,r.useState)(null),[Z,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(!1),[et,en]=(0,r.useState)(null),[eo,er]=(0,r.useState)(!1),[ea,el]=(0,r.useState)(()=>{let e=Number(window.localStorage.getItem("flujo-debugger-width"));return Number.isFinite(e)&&e>0?e:0}),ei=(0,r.useCallback)(e=>{e.preventDefault();let t=document.body.style.userSelect,n=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";let o=e=>{el(Math.min(Math.max(window.innerWidth-e.clientX,360),Math.round(.85*window.innerWidth)))},r=()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",r),document.body.style.userSelect=t,document.body.style.cursor=n,el(e=>(e>0&&window.localStorage.setItem("flujo-debugger-width",String(Math.round(e))),e))};window.addEventListener("pointermove",o),window.addEventListener("pointerup",r)},[]),[es,ec]=(0,r.useState)(()=>{let e=Number(window.localStorage.getItem("flujo-chat-sidebar-width"));return Number.isFinite(e)&&e>0?e:300}),[eu,ep]=(0,r.useState)(()=>"1"===window.localStorage.getItem("flujo-chat-sidebar-collapsed")),eg=(0,r.useCallback)(()=>{ep(e=>{let t=!e;return window.localStorage.setItem("flujo-chat-sidebar-collapsed",t?"1":"0"),t})},[]),ef=(0,r.useCallback)(e=>{e.preventDefault();let t=document.body.style.userSelect,n=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";let o=e=>{ec(Math.min(Math.max(e.clientX,220),560))},r=()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",r),document.body.style.userSelect=t,document.body.style.cursor=n,ec(e=>(e>0&&window.localStorage.setItem("flujo-chat-sidebar-width",String(Math.round(e))),e))};window.addEventListener("pointermove",o),window.addEventListener("pointerup",r)},[]),[eh,em]=(0,r.useState)(null),[ex,eb]=(0,r.useState)([]),[ev,ey]=(0,r.useState)(null),ew=(0,r.useRef)(null),eA=(0,r.useRef)(null),eC=(0,r.useRef)(null),ek=(0,r.useRef)(-1),eE=(0,r.useRef)(D);(0,r.useEffect)(()=>{eE.current=D},[D]);let eN=(0,r.useRef)(null);(0,r.useEffect)(()=>{eN.current=ev},[ev]),(0,r.useEffect)(()=>{let e=window.location.origin+"/v1";ew.current=new e5.Ay({baseURL:e,apiKey:"FLUJO",dangerouslyAllowBrowser:!0,maxRetries:0,timeout:18e6})},[]),(0,r.useEffect)(()=>{(async()=>{tt.debug("Loading flows");try{let e=await eL.g.loadFlows();U(e)}catch(e){tt.error("Error loading flows:",e)}})()},[]);let eT=(0,r.useCallback)(async(e,t)=>{var o;let r=null!=(o=null==t?void 0:t.silent)&&o;tt.debug("Fetching conversation list from backend",{silent:r}),r||(j(!0),S(null));let a=[],l=!1;try{a=(await te.listConversations()).sort((e,t)=>t.updatedAt-e.updatedAt),n(a),tt.info("Fetched ".concat(a.length," conversations for the list"))}catch(e){l=!0,tt.error("Error fetching conversation list:",e),r||(S("Failed to load conversation history."),n([]))}finally{if(r||j(!1),r||l)return;let t=void 0!==e?e:eE.current,n=eE.current;if(t&&a.some(e=>e.id===t))t!==n&&(tt.debug("Setting currentConversationId to ".concat(t," after fetch/operation.")),z(t));else if(a.length>0){let e=a[0].id;e!==n&&(tt.debug("Selecting most recent conversation ".concat(e," after fetch/operation.")),z(e))}else null!==n&&(tt.debug("No conversations available after fetch/operation, clearing selection."),z(null))}},[z]);(0,r.useEffect)(()=>{eT()},[]);let eR=(0,r.useCallback)(async e=>{tt.debug("Fetching detailed conversation",{conversationId:e}),E(!0),R(null),C(null);try{let t=await te.getConversation(e);if(eE.current!==e)return void tt.debug("Discarding stale detailed conversation response",{fetchedId:e,currentId:eE.current});C(t),n(n=>n.map(n=>n.id===e?{...n,title:t.title,flowId:t.flowId,updatedAt:t.updatedAt}:n).sort((e,t)=>t.updatedAt-e.updatedAt)),tt.info("Fetched detailed conversation successfully",{conversationId:e})}catch(t){if(tt.error("Error fetching detailed conversation:",{conversationId:e,err:t}),eE.current!==e)return;t instanceof e7&&404===t.status?(R("Conversation ".concat(e," not found.")),z(null),eT()):R("Failed to load details for conversation ".concat(e,".")),C(null)}finally{eE.current===e&&E(!1)}},[eT,z]);(0,r.useEffect)(()=>{V(null),$(null),D?eR(D):(C(null),E(!1),R(null))},[D,eR]),(0,r.useEffect)(()=>{if(I){var e;J(null!=(e=I.requireApproval)&&e)}},[null==I?void 0:I.id]);let eD=(0,r.useCallback)(async e=>{if(J(e),D)try{await te.updateConversationApproval(D,e)}catch(e){tt.warn("Failed to persist requireApproval setting",{conversationId:D,err:e})}},[D]),ez=t.find(e=>e.id===D)||null,eP=(0,r.useMemo)(()=>{var e,t;return(null==(t=B.find(e=>e.id===(null==I?void 0:I.flowId)))||null==(e=t.nodes)?void 0:e.map(e=>({id:e.id,label:e.data.label||e.id})))||[]},[B,null==I?void 0:I.flowId]),eF=(0,r.useMemo)(()=>{var e,t,n;let o=e=>!!e&&eP.some(t=>t.id===e);if(o(Z))return Z;if(o(null==I?void 0:I.currentNodeId))return I.currentNodeId;let r=null!=(t=null==I?void 0:I.messages)?t:[];for(let e=r.length-1;e>=0;e--){let t=r[e];if("assistant"===t.role&&o(t.processNodeId))return t.processNodeId}return null!=(n=null==(e=eP[0])?void 0:e.id)?n:null},[Z,I,eP]),e_=async()=>{var e,t;tt.debug("Attempting to create new conversation"),M(null);let o=(null==(e=B[0])?void 0:e.id)||null;if(!o){tt.error("Cannot create conversation: No flows available or first flow has no ID."),M("Cannot create a new conversation: No flows available.");return}let r=(0,ej.A)(),a=Date.now(),l={id:r,title:"New Conversation",flowId:o,createdAt:a,updatedAt:a};try{tt.info("Sending request to create conversation on backend",{payload:JSON.stringify(l)});let e=await te.createConversation(l);tt.info("Successfully created conversation on backend",{conversationId:e.id}),n(t=>[e,...t].sort((e,t)=>t.updatedAt-e.updatedAt)),z(e.id),C({id:e.id,title:e.title,flowId:e.flowId,createdAt:e.createdAt,updatedAt:e.updatedAt,messages:[]}),E(!1),R(null)}catch(n){tt.error("Error creating conversation on backend:",n);let e="Failed to create conversation on the server.";n instanceof e7?e+=" Error: ".concat((null==(t=n.body)?void 0:t.error)||n.message):n instanceof Error&&(e+=" Error: ".concat(n.message)),M(e)}},eM=(0,r.useCallback)(e=>{tt.debug("Updating detailed conversation state locally",{conversationId:e.id});let t={...e,updatedAt:Date.now()};C(t),n(e=>e.map(e=>e.id===t.id?{...e,title:t.title,updatedAt:t.updatedAt}:e).sort((e,t)=>t.updatedAt-e.updatedAt))},[]),eB=(0,r.useCallback)(()=>{eC.current&&(tt.debug("Closing execution event stream"),eC.current.close(),eC.current=null)},[]),eU=(0,r.useCallback)(e=>{if("number"==typeof e.seq){if(e.seq<=ek.current)return;ek.current=e.seq}let t=e=>em(t=>{var n,o,r,a;return{totalTokens:null!=(o=null!=(n=e.totalTokens)?n:null==t?void 0:t.totalTokens)?o:0,activeNode:void 0!==e.activeNode?e.activeNode:null!=(r=null==t?void 0:t.activeNode)?r:null,startedAt:null!=(a=null==t?void 0:t.startedAt)?a:Date.now(),lastEventAt:Date.now()}});switch(e.type){case"run:start":em({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()});break;case"message":{let n=e.message;t({}),C(t=>{let o;if(!t||t.id!==e.conversationId)return t;let r=t.messages.findIndex(e=>e.id===n.id);return r>=0?(o=[...t.messages])[r]={...o[r],...n}:o=[...t.messages,n],{...t,messages:o}});break}case"usage":em(t=>{var n,o,r;return{totalTokens:(null!=(n=null==t?void 0:t.totalTokens)?n:0)+(e.totalTokens||0),activeNode:null!=(o=null==t?void 0:t.activeNode)?o:null,startedAt:null!=(r=null==t?void 0:t.startedAt)?r:Date.now(),lastEventAt:Date.now()}});break;case"node:enter":var n,o;t({activeNode:(null==(n=e.node)?void 0:n.nodeName)||(null==(o=e.node)?void 0:o.nodeId)||null});break;case"tool:call":t({activeNode:e.name});break;case"tool:progress":t({activeNode:e.message?"".concat(e.name," — ").concat(e.message):e.name});break;case"subflow:start":t({activeNode:"↳ ".concat(e.subflowName||e.subflowId)});break;case"handoff":t({activeNode:"→ ".concat(e.toNodeId)});break;case"run:awaiting_approval":e.conversationId&&e.conversationId===eE.current&&V(e.pendingToolCalls||[]);break;case"breakpoint:hit":case"run:paused":O(!1),e.conversationId&&W(e.conversationId,!1),ee(!0);break;case"run:done":em(null),O(!1),ey(null),e.conversationId&&W(e.conversationId,!1),eB(),e.conversationId&&e.conversationId===eE.current?eR(e.conversationId):eT(void 0,{silent:!0});break;case"error":M(e.message||"Execution error");break;default:t({})}},[eB,eR,eT,W]),eH=(0,r.useCallback)((e,t)=>(eB(),ek.current=void 0!==t?t-1:-1,new Promise(n=>{let o=!1,r=()=>{o||(o=!0,n())};try{eC.current=te.subscribeToEvents(e,{onEvent:eU,onOpen:r},t),setTimeout(r,1500)}catch(t){tt.error("Failed to open execution event stream",{conversationId:e,err:t}),r()}})),[eU,eB]);(0,r.useEffect)(()=>{D&&(null==ez?void 0:ez.status)==="running"&&eN.current!==D&&(tt.info("Re-attaching to in-progress run",{conversationId:D}),eN.current=D,O(!0),ey(D),W(D,!0),em(e=>null!=e?e:{totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),eH(D,0))},[D,null==ez?void 0:ez.status,eH]);let eJ=async e=>{tt.debug("Attempting to delete conversation",{conversationId:e}),M(null);let o=t.filter(t=>t.id!==e);n(o);let r=D;D===e&&(o.length>0?(r=o[0].id,tt.debug("Deleted current conversation, selecting next most recent",{nextSelectionId:r})):(r=null,tt.debug("Deleted last conversation, clearing selection")),z(r));try{await te.deleteConversation(e),tt.info("Successfully deleted conversation on backend",{conversationId:e})}catch(o){tt.error("Error deleting conversation:",{conversationId:e,err:o}),M("Failed to delete conversation ".concat(e,". Please try again.")),n(t),z(D)}},eq=async e=>{if(tt.debug("Flow selected, attempting to update",{flowId:e,currentConversationId:D}),M(null),!D){tt.warn("Cannot update flow: No conversation selected."),M("Please select a conversation first.");return}I&&I.id===D&&C({...I,flowId:e,updatedAt:Date.now()}),n(t=>t.map(t=>t.id===D?{...t,flowId:e,updatedAt:Date.now()}:t).sort((e,t)=>t.updatedAt-e.updatedAt));try{let t=await te.updateConversationFlow(D,e);tt.info("Successfully updated flowId on backend",{conversationId:D,flowId:e}),C(e=>e&&e.id===D?(tt.debug("Confirming detailedConversation update from server response",{conversationId:D,flowId:t.flowId}),{...e,flowId:t.flowId,updatedAt:t.updatedAt}):(tt.debug("Skipping detailedConversation update, ID mismatch or null state",{currentDetailedId:null==e?void 0:e.id,targetId:D}),e)),n(e=>e.map(e=>e.id===D?t:e).sort((e,t)=>t.updatedAt-e.updatedAt))}catch(a){tt.error("Error updating flowId on backend:",{conversationId:D,flowId:e,err:a});let r="Failed to update the selected flow.";if(a instanceof e7){var o;r+=" Error: ".concat((null==(o=a.body)?void 0:o.error)||a.message)}else a instanceof Error&&(r+=" Error: ".concat(a.message));M(r),C(I),n(t)}},eG=async function(e){var t,n;let o,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e.trim()&&0===r.length)return;if(!I){tt.error("Cannot send message, detailed conversation not loaded."),M("Cannot send message: conversation details not loaded.");return}tt.debug("Sending message",{conversationId:I.id,contentLength:e.length,attachmentsCount:r.length});let a=I.messages,l=!a.some(e=>"user"===e.role),i=I.flowId;if(Z)o=Z,$(null),tt.debug("Assigning manually picked node ID to user message: ".concat(o));else if(l){let e=B.find(e=>e.id===i),n=null==e||null==(t=e.nodes)?void 0:t[0];n?(o=n.id,tt.debug("Assigning start node ID to first user message: ".concat(o))):tt.warn("Could not find start node for flow ".concat(i,". User message will not have a processNodeId."))}else{for(let e=a.length-1;e>=0;e--){let t=a[e];if("assistant"===t.role&&t.processNodeId){o=t.processNodeId,tt.debug("Assigning last assistant node ID to user message: ".concat(o));break}}if(!o){let e=B.find(e=>e.id===i),t=null==e||null==(n=e.nodes)?void 0:n[0];t?(o=t.id,tt.debug("No prior assistant node ID found, falling back to start node ID: ".concat(o))):tt.warn("Could not find start node for fallback in flow ".concat(i,". User message will not have a processNodeId."))}}let s={id:(0,ej.A)(),role:"user",content:e,timestamp:Date.now(),attachments:r.length>0?r:void 0,processNodeId:o},d={...I,messages:[...I.messages,s]};eM(d),d.flowId?await eX(d):(M("Please select a flow for this conversation before sending messages"),C(I))},eY=(0,r.useCallback)((e,t)=>{if(tt.verbose("Handling API response data",JSON.stringify(e)),W(t,"running"===e.status),"paused_debug"===e.status&&e.debugState)return tt.info("API Response: Paused for debugging",{conversationId:t}),en(e.debugState),ee(!0),er(!0),O(!1),ey(null),eB(),eV(),C(n=>(null==n?void 0:n.id)===t&&e.debugState.messages&&JSON.stringify(n.messages)!==JSON.stringify(e.debugState.messages)?(tt.debug("Updating detailed conversation messages from debug state"),{...n,messages:e.debugState.messages,updatedAt:e.debugState.updatedAt}):n),n(n=>n.map(n=>{var o,r;return n.id===t?{...n,title:null!=(o=e.debugState.title)?o:n.title,flowId:null!=(r=e.debugState.flowId)?r:n.flowId,status:"paused_debug",updatedAt:e.debugState.updatedAt}:n}).sort((e,t)=>t.updatedAt-e.updatedAt)),!0;if("completed"===e.status||"error"===e.status?(tt.info("API Response: Execution completed or errored (Status: ".concat(e.status,"). Hiding debugger panel."),{conversationId:t}),ee(!1),en(null),er(!1)):tt.debug("API Response: Status is '".concat(e.status,"'. Debugger panel visibility unchanged (currently ").concat(Q?"visible":"hidden",")."),{conversationId:t}),e.messages&&e.conversation_id===t){let n=e.messages.map((e,n)=>"number"!=typeof e.timestamp||isNaN(e.timestamp)?(tt.warn("Invalid timestamp found in message index ".concat(n," from API response. Defaulting to Date.now()."),{conversationId:t,messageId:e.id,invalidTimestamp:e.timestamp}),{...e,timestamp:Date.now()}):e);C(o=>{var r,a;let l=o;return(null==o?void 0:o.id)===t&&JSON.stringify(o.messages)!==JSON.stringify(n)&&(tt.info("API Response/Polling: Updating detailed conversation messages",{conversationId:t,newMessageCount:n.length}),l={...o,messages:n,updatedAt:e.updatedAt||o.updatedAt}),tt.debug("Polling: setDetailedConversation callback executed.",{conversationId:t,messagesChanged:l!==o,newMessageCount:null!=(a=null==l||null==(r=l.messages)?void 0:r.length)?a:"N/A"}),l})}if("awaiting_tool_approval"===e.status)tt.info("API Response/Polling: Pausing for tool approval",{conversationId:t}),V(e.pendingToolCalls||[]),O(!1),ey(null),eB(),eV();else if("completed"===e.status||"error"===e.status){if(tt.info("API Response/Polling: Stopping due to final status",{conversationId:t,status:e.status}),eV(),O(!1),ey(null),eB(),"error"===e.status){var o,r;M((null==(o=e.error)?void 0:o.message)||(null==(r=e.lastResponse)?void 0:r.error)||"Unknown error during execution"),tt.error("API Response/Polling: Execution resulted in error",{conversationId:t,error:e.error||e.lastResponse})}eR(t)}else"running"!==e.status||Q?V(null):(V(null),eA.current||O(!0));return e.conversation_id===t&&n(n=>n.map(n=>{var o,r,a;return n.id===t?{...n,title:null!=(o=e.title)?o:n.title,flowId:null!=(r=e.flowId)?r:n.flowId,status:null!=(a=e.status)?a:n.status,updatedAt:e.updatedAt||n.updatedAt}:n}).sort((e,t)=>t.updatedAt-e.updatedAt)),!1},[C,V,O,M,ee,en,n,eR,eB,W]),eV=()=>{eA.current&&(tt.debug("Stopping polling interval"),clearInterval(eA.current),eA.current=null)};(0,r.useEffect)(()=>()=>{eB()},[eB]);let eX=async e=>{if(!(null==e?void 0:e.id)||!e.flowId||!ew.current)return tt.error("Cannot send to completions: Missing conversation ID or flow ID.",{id:null==e?void 0:e.id,flowId:null==e?void 0:e.flowId}),M("Cannot send message: Missing conversation ID or flow ID."),!1;V(null),M(null),O(!0),ey(e.id),W(e.id,!0),em({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),await eH(e.id);let t=!1;try{let n=await eL.g.getFlow(e.flowId);if(!n)throw Error("Flow with ID ".concat(e.flowId," not found"));tt.debug("Sending to chat completions",{flowId:e.flowId,flowName:n.name,conversationId:e.id});let o=e.messages.filter(e=>{var t;return!e.disabled&&!((null!=(t=e.depth)?t:0)>0)}).map(e=>{let t=tn(e),n=e.processNodeId,o={id:e.id,timestamp:e.timestamp};return"user"===e.role?{role:"user",content:t,...o,processNodeId:n}:"assistant"===e.role?{role:"assistant",content:t,tool_calls:e.tool_calls,...o,processNodeId:n}:"system"===e.role?{role:"system",content:t,...o,processNodeId:n}:"tool"===e.role?e.tool_call_id?{role:"tool",content:t,tool_call_id:e.tool_call_id,...o,processNodeId:n}:{role:"user",content:"string"==typeof t?"Tool result: ".concat(t):t,...o,processNodeId:n}:{role:"user",content:t,...o,processNodeId:n}}),r=await ew.current.chat.completions.create({model:"flow-".concat(n.name),messages:o,stream:!1,metadata:(()=>{let t={flujo:"true",requireApproval:H?"true":void 0,flujodebug:q?"true":void 0,conversationId:e.id},n={};return t.flujo&&(n.flujo=t.flujo),t.requireApproval&&(n.requireApproval=t.requireApproval),t.flujodebug&&(n.flujodebug=t.flujodebug),t.conversationId&&(n.conversationId=t.conversationId),n})()});tt.debug("Chat completion initial response received",{completionId:r.id}),t=!0;let a={...r,status:r.status||"completed",conversation_id:e.id,messages:r.messages||e.messages,pendingToolCalls:r.pendingToolCalls,debugState:r.debugState,error:r.error,lastResponse:r.lastResponse,updatedAt:r.updatedAt||Date.now()},l=eY(a,e.id);l||eA.current?l&&tt.debug("Debug state handled, polling remains stopped."):tt.debug("Starting polling after initial non-debug response.")}catch(r){tt.error("Error calling chat completions API:",r),t=!1;let o="An error occurred while sending the message.";if(r instanceof e4.LG)o="API Error: ".concat(r.message," (Status: ").concat(r.status,")"),r.code&&(o+=" (Code: ".concat(r.code,")")),r.type&&(o+=" [Type: ".concat(r.type,"]")),tt.verbose("APIError details",JSON.stringify(r));else if(r instanceof e4.vc){o="OpenAI Error: ".concat(r.message);let e=r.error;e&&"object"==typeof e&&(e.code&&(o+=" (Code: ".concat(e.code,")")),e.type&&(o+=" [Type: ".concat(e.type,"]"))),tt.verbose("OpenAIError details",JSON.stringify(r))}else if(r instanceof e7){var n;o="Error: ".concat((null==(n=r.body)?void 0:n.error)||r.message),r.status&&(o+=" (Status: ".concat(r.status,")")),tt.verbose("ChatApiError details",JSON.stringify(r.body))}else r instanceof Error&&(o=r.message);M(o),eV(),O(!1),ey(null),W(e.id,!1),eB()}finally{}return t},eK=async(e,t,n)=>{if(!I)return;tt.debug("Editing message",{messageId:e,contentLength:t.length,processNodeId:n});let o=I.messages.findIndex(t=>t.id===e);if(-1===o)return;let r={...I.messages[o],content:t,timestamp:Date.now(),processNodeId:n||void 0},a=[...I.messages.slice(0,o),r],l={...I,messages:a};if(eM(l),l.flowId){let e={flujo:"true",requireApproval:H?"true":void 0,flujodebug:q?"true":void 0,conversationId:l.id,processNodeId:n||void 0};if(!ew.current)return;M(null),O(!0),ey(l.id),W(l.id,!0),em({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),await eH(l.id);try{let t=await eL.g.getFlow(l.flowId);if(!t)throw Error("Flow with ID ".concat(l.flowId," not found"));let n=l.messages.filter(e=>{var t;return!e.disabled&&!((null!=(t=e.depth)?t:0)>0)}).map(e=>{let t=tn(e),n={id:e.id,timestamp:e.timestamp,processNodeId:e.processNodeId};return"user"===e.role?{role:"user",content:t,...n}:"assistant"===e.role?{role:"assistant",content:t,tool_calls:e.tool_calls,...n}:"system"===e.role?{role:"system",content:t,...n}:"tool"===e.role?e.tool_call_id?{role:"tool",content:t,tool_call_id:e.tool_call_id,...n}:{role:"user",content:"string"==typeof t?"Tool result: ".concat(t):t,...n}:{role:"user",content:t,...n}}),o=await ew.current.chat.completions.create({model:"flow-".concat(t.name),messages:n,stream:!1,metadata:(()=>{let t={};return e.flujo&&(t.flujo=e.flujo),e.requireApproval&&(t.requireApproval=e.requireApproval),e.flujodebug&&(t.flujodebug=e.flujodebug),e.conversationId&&(t.conversationId=e.conversationId),e.processNodeId&&(t.processNodeId=e.processNodeId),t})()}),r={...o,status:o.status||"completed",conversation_id:l.id,messages:o.messages||l.messages,pendingToolCalls:o.pendingToolCalls,debugState:o.debugState,error:o.error,updatedAt:o.updatedAt||Date.now()};eY(r,l.id)}catch(e){tt.error("Error sending edited message:",e),M(e instanceof Error?e.message:"Failed to send edited message"),O(!1),ey(null),W(l.id,!1),eB()}}},eZ=async(e,t)=>{if(D){tt.info("Handling tool response: ".concat(e),{conversationId:D,toolCallId:t}),V(null),O(!0),ey(D),W(D,!0),M(null),await eH(D);try{let n=await te.respondToToolCall(D,e,t);tt.debug("Tool response successful",{conversationId:D,action:e,toolCallId:t}),eY(n,D)}catch(r){tt.error("Error sending tool response (".concat(e,")"),{conversationId:D,toolCallId:t,err:r});let o="Failed to ".concat(e," tool call.");if(r instanceof e7){var n;o+=" Error: ".concat((null==(n=r.body)?void 0:n.error)||r.message)}else r instanceof Error&&(o+=" Error: ".concat(r.message));M(o),O(!1),W(D,!1)}}},e$=async()=>{if(D&&Q){tt.info("Handling debug step request",{conversationId:D}),O(!0),ey(D),W(D,!0),M(null),await eH(D);try{let e=await te.debugStep(D);eY(e,D)}catch(e){tt.error("Error during debug step API call",{conversationId:D,err:e}),M(e instanceof Error?e.message:"Failed to execute debug step."),O(!1),W(D,!1),ee(!1),en(null)}finally{}}},eQ=async()=>{if(D&&Q){tt.info("Handling debug continue request",{conversationId:D}),O(!0),ey(D),W(D,!0),M(null),ee(!1),await eH(D);try{let e=await te.debugContinue(D);eY(e,D)}catch(e){tt.error("Error during debug continue API call",{conversationId:D,err:e}),M(e instanceof Error?e.message:"Failed to continue execution."),O(!1),W(D,!1)}finally{}}};(0,r.useEffect)(()=>{if(et){var e;eb(null!=(e=et.breakpoints)?e:[])}},[et]);let e0=(0,r.useCallback)(async e=>{if(!D)return;let t=ex.includes(e)?ex.filter(t=>t!==e):[...ex,e];eb(t);try{await te.setBreakpoints(D,t)}catch(e){tt.error("Failed to update breakpoints",{conversationId:D,err:e}),eb(ex)}},[ex,D]),e6=async()=>{if(!D||!Q)return;let e=null==et?void 0:et.currentNodeId;O(!0),ey(D),W(D,!0),M(null),await eH(D);try{for(let r=0;r<50;r++){var t,n,o;let r=await te.debugStep(D),a=null!=(o=null==r?void 0:r.status)?o:null==r||null==(t=r.debugState)?void 0:t.status,l=null==r||null==(n=r.debugState)?void 0:n.currentNodeId;if("paused_debug"!==a||l&&l!==e)return void eY(r,D)}tt.warn("Step Over hit iteration cap",{conversationId:D}),O(!1),W(D,!1)}catch(e){tt.error("Error during step over",{conversationId:D,err:e}),M(e instanceof Error?e.message:"Failed to step over."),O(!1),W(D,!1)}},e3=async()=>{if(D){tt.info("Cancelling request",{conversationId:D}),eV(),O(!1),ey(null),W(D,!1),er(!1),eB(),V(null);try{await te.cancel(D),tt.debug("Cancel request sent successfully",{conversationId:D}),await eR(D)}catch(e){tt.error("Error sending cancel request",{conversationId:D,err:e}),M("Failed to send cancel request to the server.")}}},e8=async()=>{tt.info("Closing debugger panel",{conversationId:D}),ee(!1),en(null),er(!1),await e3()};tt.debug("Rendering Chat component",{currentConversationId:D,isHandleEditMessageDefined:!0});let e9=(eo||Q)&&!!et&&!!D;return(0,o.jsxs)(l.default,{sx:{display:"flex",height:"calc(100vh - 64px)"},children:[eu&&(0,o.jsx)(l.default,{sx:{width:40,flexShrink:0,borderRight:1,borderColor:"divider",display:"flex",justifyContent:"center",pt:1},children:(0,o.jsx)(i.A,{title:"Show conversation sidebar",children:(0,o.jsx)(s.A,{size:"small",onClick:eg,"aria-label":"Show conversation sidebar",children:(0,o.jsx)(y.A,{fontSize:"small"})})})}),!eu&&(0,o.jsx)(l.default,{sx:{width:es,flexShrink:0,borderRight:1,borderColor:"divider",display:"flex",flexDirection:"column"},children:a?(0,o.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",p:2},children:(0,o.jsx)(e2.default,{size:"medium",color:"primary"})}):A?(0,o.jsx)(d.A,{severity:"error",sx:{m:2},children:A}):(0,o.jsx)(T,{conversations:t,currentConversationId:D,onSelectConversation:z,onDeleteConversation:eJ,onNewConversation:e_,onCollapse:eg})}),!eu&&(0,o.jsx)(l.default,{onPointerDown:ef,sx:{width:"6px",flexShrink:0,cursor:"col-resize",bgcolor:"divider",transition:"background-color 120ms","&:hover":{bgcolor:"primary.main"},touchAction:"none"},"aria-label":"Resize conversation sidebar"}),(0,o.jsxs)(l.default,{sx:{flex:1,height:"100%",display:"flex",minWidth:0,minHeight:0},children:[(0,o.jsxs)(l.default,{sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",height:"100%"},children:[D&&(0,o.jsxs)(l.default,{sx:{p:2,borderBottom:1,borderColor:"divider",display:"flex",alignItems:"center",gap:2},children:[(0,o.jsx)(l.default,{sx:{flex:1,minWidth:0},children:(0,o.jsx)(eW,{selectedFlowId:(null==ez?void 0:ez.flowId)||(null==I?void 0:I.flowId)||null,onSelectFlow:e=>{var t,n,o,r;if(!D){tt.warn("Cannot update flow: No conversation selected."),M("Please select a conversation first.");return}let a=null!=(o=null!=(n=null==I?void 0:I.flowId)?n:null==ez?void 0:ez.flowId)?o:null;if((null!=(r=null==I||null==(t=I.messages)?void 0:t.length)?r:0)>0&&a&&e!==a){tt.debug("Flow switch on executed conversation — asking for confirmation",{flowId:e,currentFlowId:a}),K(e);return}eq(e)},disabled:Q})}),(0,o.jsx)(eO,{usage:null==I?void 0:I.usage,contextInfo:null==I?void 0:I.contextInfo,availableNodes:eP})]}),(0,o.jsx)(l.default,{sx:{flex:1,overflow:"auto",p:2},children:k?(0,o.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(e2.default,{size:"medium",color:"primary"})}):N?(0,o.jsx)(d.A,{severity:"error",sx:{m:2},children:N}):I?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(ed,{messages:I.messages,pendingToolCalls:Y,availableNodes:eP,conversationId:I.id,onToggleDisabled:e=>{if(!I)return;tt.debug("Toggling message disabled state",{messageId:e});let t=I.messages.map(t=>t.id===e?{...t,disabled:!t.disabled}:t);eM({...I,messages:t})},onSplitConversation:e=>{if(!I)return;tt.debug("Splitting conversation at message",{messageId:e});let t=I.messages.findIndex(t=>t.id===e);if(-1===t)return;let o=I.messages.slice(0,t+1),r=(0,ej.A)(),a={id:r,title:"Split from ".concat(I.title),messages:o,flowId:I.flowId,createdAt:Date.now(),updatedAt:Date.now()},l={id:r,title:a.title,flowId:a.flowId,createdAt:a.createdAt,updatedAt:a.updatedAt};n(e=>[l,...e].sort((e,t)=>t.updatedAt-e.updatedAt)),z(r),C(a),E(!1),R(null)},onEditMessage:eK,onApproveToolCall:e=>{eZ("approve",e)},onRejectToolCall:e=>{eZ("reject",e)}}),!P&&!Q&&I.messages.length>0&&(null==ez?void 0:ez.status)==="completed"&&(0,o.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,o.jsx)(d.A,{icon:(0,o.jsx)(b.A,{fontSize:"inherit"}),severity:"success",variant:"filled",sx:{borderRadius:2,py:.5},children:"Conversation completed"})}),!P&&!Q&&!_&&(null==ez?void 0:ez.status)==="error"&&(0,o.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,o.jsx)(d.A,{icon:(0,o.jsx)(v.A,{fontSize:"inherit"}),severity:"error",variant:"filled",sx:{borderRadius:2,py:.5,alignItems:"center"},action:(0,o.jsx)(c.A,{color:"inherit",size:"small",startIcon:(0,o.jsx)(x.A,{}),onClick:()=>{eX(I)},children:"Retry"}),children:"Conversation ended with an error"})}),P&&ev===D&&(0,o.jsx)(eI,{liveStats:eh,onStop:e3,stopDisabled:!D}),_&&(0,o.jsx)(d.A,{severity:"error",sx:{mt:2},action:(0,o.jsx)(c.A,{color:"inherit",size:"small",startIcon:(0,o.jsx)(x.A,{}),onClick:()=>{I&&eX(I)},children:"Retry"}),children:_})]}):(0,o.jsx)(u.default,{variant:"body1",color:"textSecondary",align:"center",sx:{mt:4},children:t.length>0?"Select a conversation or create a new one.":"Create a new conversation to start chatting."})}),(0,o.jsx)(l.default,{sx:{p:2,borderTop:1,borderColor:"divider"},children:(0,o.jsx)(eS,{onSendMessage:eG,disabled:k||!!D&&F.has(D)||!((null==I?void 0:I.flowId)||(null==ez?void 0:ez.flowId))||!!Y||Q,requireApproval:H,onRequireApprovalChange:eD,executeInDebugger:q,onExecuteInDebuggerChange:G,availableNodes:eP,currentNodeId:eF,nodeOverrideActive:!!Z,onSelectNode:$})})]})," ",e9&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.default,{onPointerDown:ei,sx:{width:"6px",flexShrink:0,cursor:"col-resize",bgcolor:"divider",transition:"background-color 120ms","&:hover":{bgcolor:"primary.main"},touchAction:"none"},"aria-label":"Resize debugger panel"}),(0,o.jsx)(l.default,{sx:{width:ea?"".concat(ea,"px"):"50%",minWidth:360,maxWidth:"85vw",flexShrink:0,display:"flex",flexDirection:"column",height:"100%"},children:(0,o.jsx)(e1,{debugState:et,conversationId:D,onStep:e$,onStepOver:e6,onContinue:eQ,onCancel:e3,isLoading:P,breakpoints:ex,onToggleBreakpoint:e0,onClose:e8})})]})]})," ",(0,o.jsxs)(p.A,{open:!!X,onClose:()=>K(null),children:[(0,o.jsx)(g.A,{children:"Switch flow?"}),(0,o.jsx)(f.A,{children:(0,o.jsxs)(h.A,{children:["This conversation has already been processed with its current flow."," ","If you switch to"," ",(0,o.jsx)("strong",{children:(null==(e=B.find(e=>e.id===X))?void 0:e.name)||"the selected flow"}),","," ","the conversation will continue processing from that flow's Start node again."]})}),(0,o.jsxs)(m.A,{children:[(0,o.jsx)(c.A,{onClick:()=>K(null),children:"Cancel"}),(0,o.jsx)(c.A,{variant:"contained",onClick:()=>{K(null),X&&eq(X)},children:"Switch Flow"})]})]})]})},tr=(0,er.h)("frontend/components/ClientOnly");function ta(e){let{children:t}=e,[n,a]=(0,r.useState)(!1);return((0,r.useEffect)(()=>(tr.debug("ClientOnly component mounted"),a(!0),()=>{tr.debug("ClientOnly component unmounted")}),[]),n)?(tr.debug("ClientOnly component rendering children"),(0,o.jsx)(o.Fragment,{children:t})):(tr.debug("ClientOnly component rendering null (not yet mounted)"),null)}let tl=(0,er.h)("app/chat/page");function ti(){return tl.debug("Rendering ChatPage"),(0,o.jsx)(a.A,{maxWidth:!1,disableGutters:!0,children:(0,o.jsx)(ta,{children:(0,o.jsx)(to,{})})})}},84869:(e,t,n)=>{"use strict";n.d(t,{G:()=>l,S:()=>a});let o=(0,n(87021).h)("frontend/services/transcription/webSpeech"),r=()=>"webkitSpeechRecognition"in window||"SpeechRecognition"in window;async function a(e,t){if(!r())throw Error("Web Speech API is not supported in this browser");o.debug("Starting Web Speech API transcription");try{let n=URL.createObjectURL(e),r=new Audio(n),a=new(window.SpeechRecognition||window.webkitSpeechRecognition);return a.continuous=!0,a.interimResults=!0,(null==t?void 0:t.language)&&(a.lang=t.language),new Promise((e,n)=>{let l="";a.onresult=e=>{let n="";for(let t=e.resultIndex;t<e.results.length;t++){let o=e.results[t][0].transcript;e.results[t].isFinal?l+=o+" ":n+=o}(null==t?void 0:t.onInterimResult)&&t.onInterimResult(l+n),o.debug("Recognition interim result",{finalLength:l.length,interimLength:n.length})},a.onend=()=>{o.debug("Recognition ended",{transcriptLength:l.length}),e(l.trim())},a.onerror=e=>{o.error("Recognition error",{error:e.error}),n(Error("Speech recognition error: ".concat(e.error)))},r.onplay=()=>{a.start(),o.debug("Recognition started")},r.onended=()=>{a.stop(),o.debug("Audio playback ended")},r.onerror=e=>{o.error("Audio playback error",{error:e}),a.stop(),n(Error("Error playing audio"))},r.play().catch(e=>{o.error("Error starting audio playback",{error:e}),n(e)})})}catch(e){throw o.error("Error in Web Speech API transcription",{error:e}),e}}function l(){return{supported:r(),message:r()?"Web Speech API is supported":"Web Speech API is not supported in this browser"}}},87021:(e,t,n)=>{"use strict";n.d(t,{h:()=>s});let o={LOG_LEVEL:3},r={VERBOSE:-1,DEBUG:0,INFO:1,WARN:2,ERROR:3},a="number"==typeof o.LOG_LEVEL?o.LOG_LEVEL:r.ERROR;function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t>6)return String(e);if(!(e instanceof Error))return e;let n={name:e.name,message:e.message};for(let o of Object.getOwnPropertyNames(e)){if("name"===o||"message"===o)continue;let r=e[o];"function"!=typeof r&&("stack"===o?n.stack=r:"cause"===o?n.cause=l(r,t+1):"errors"===o&&Array.isArray(r)?n.errors=r.map(e=>l(e,t+1)):n[o]=r)}return n}function i(e,t,n,o,i){if(e>=("number"==typeof i?i:a)){if("function"==typeof o)try{o=o()}catch(e){o="[lazy log data threw]"}let a=new Date().toISOString(),i="[".concat(a,"] [").concat(t,"]"),s="".concat(i," ").concat(n);if(void 0!==o)if(o instanceof Error||"object"==typeof o)try{let e=o instanceof Error?l(o):o,t=JSON.stringify(e,(e,t)=>t instanceof Error?l(t):t,2);s+=":\n".concat(t)}catch(e){s+=": [Object cannot be stringified]"}else s+=": ".concat(o);switch(e){case r.VERBOSE:console.debug("[VERBOSE] ".concat(s));break;case r.DEBUG:console.debug(s);break;case r.INFO:console.info(s);break;case r.WARN:console.warn(s);break;case r.ERROR:console.error(s);break;default:console.log(s)}}}function s(e,t){let n,o=((n=e.replace(/^src\//,"")).startsWith("/")&&(n=n.substring(1)),n);return{verbose:(e,n)=>{i(r.VERBOSE,o,e,n,t)},debug:(e,n)=>{i(r.DEBUG,o,e,n,t)},info:(e,n)=>{i(r.INFO,o,e,n,t)},warn:(e,n)=>{i(r.WARN,o,e,n,t)},error:(e,n)=>{i(r.ERROR,o,e,n,t)}}}},94929:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var o=n(95155);n(12115);var r=n(94049),a=n(4474);let l=e=>{let{size:t="medium",color:n="primary",className:l="",sx:i={}}=e,s="white"===n?{color:"#fff",...i}:i;return(0,o.jsxs)(r.default,{component:"span",sx:{display:"inline-block",lineHeight:0,...s},className:l,role:"status",children:[(0,o.jsx)(a.default,{size:{small:16,medium:24,large:36}[t],color:"white"===n?"inherit":n,"aria-hidden":"true"}),(0,o.jsx)(r.default,{component:"span",sx:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0},children:"Loading..."})]})}},97206:(e,t,n)=>{Promise.resolve().then(n.bind(n,67421))}},e=>{e.O(0,[3862,2678,4754,9244,8548,690,9562,2003,488,3272,5648,7396,7329,7458,1424,2005,7126,5961,5781,9164,8862,8441,1255,7358],()=>e(e.s=97206)),_N_E=e.O()}]);
|
package/.next/static/chunks/app/executions/{page-b46744c507a6e810.js → page-95fec57bf97ee809.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1488],{17427:(e,t,a)=>{"use strict";a.d(t,{A:()=>p});var l=a(95155),n=a(12115),r=a(25635),o=a(94049),s=a(99944),i=a(9957),d=a(52641),c=a(51221),u=a(55606),h=a(86973),x=a(9562);let p=e=>{var t;let{schema:a,values:p,onChange:f,size:m="small"}=e,[g,y]=(0,n.useState)({}),w=null!=(t=null==a?void 0:a.properties)?t:{},v=Array.isArray(null==a?void 0:a.required)?a.required:[],j=Object.keys(w);if(0===j.length)return(0,l.jsx)(r.default,{variant:"body2",color:"text.secondary",children:"This tool takes no parameters."});let b=(e,t)=>{let a={...p};void 0===t?delete a[e]:a[e]=t,f(a)};return(0,l.jsx)(o.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:j.map(e=>{var t,a;let n=null!=(t=w[e])?t:{},f=v.includes(e)?"".concat(e," *"):e,j="string"==typeof n.description?n.description:"";if("boolean"===n.type)return(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{size:m,checked:!0===p[e],onChange:t=>b(e,t.target.checked)}),label:(0,l.jsxs)(o.default,{children:[(0,l.jsx)(r.default,{variant:"body2",children:f}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",children:j})]})},e);if(Array.isArray(n.enum)&&n.enum.length>0){let t=p[e];return(0,l.jsxs)(d.A,{size:m,fullWidth:!0,children:[(0,l.jsx)(c.A,{id:"schema-param-".concat(e),children:f}),(0,l.jsx)(u.A,{labelId:"schema-param-".concat(e),label:f,value:n.enum.includes(t)?t:"",onChange:t=>b(e,t.target.value),children:n.enum.map(e=>(0,l.jsx)(h.A,{value:e,children:String(e)},String(e)))}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mx:1.75},children:j})]},e)}if("number"===n.type||"integer"===n.type)return(0,l.jsx)(x.A,{fullWidth:!0,size:m,type:"number",label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>{let a=t.target.value;if(""===a)return void b(e,void 0);let l="integer"===n.type?parseInt(a,10):parseFloat(a);b(e,Number.isNaN(l)?void 0:l)},helperText:j},e);if("object"===n.type||"array"===n.type){let t=null!=(a=g[e])?a:void 0!==p[e]?JSON.stringify(p[e],null,2):"",r=null;if(t.trim())try{JSON.parse(t)}catch(e){r="Not valid JSON yet"}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,multiline:!0,minRows:2,label:"".concat(f," (JSON ").concat(n.type,")"),value:t,error:!!r,helperText:null!=r?r:j,onChange:t=>{let a=t.target.value;if(y(t=>({...t,[e]:a})),!a.trim())return void b(e,void 0);try{b(e,JSON.parse(a))}catch(e){}},slotProps:{input:{sx:{fontFamily:"monospace",fontSize:13}}}},e)}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>b(e,""===t.target.value?void 0:t.target.value),helperText:j},e)})})}},60187:(e,t,a)=>{Promise.resolve().then(a.bind(a,95271))},62640:(e,t,a)=>{"use strict";a.d(t,{A:()=>N});var l=a(95155),n=a(12115),r=a(2778),o=a(52363),s=a(65036),i=a(94049),d=a(78470),c=a(41983),u=a(9562),h=a(28548),x=a(22003),p=a(4474),f=a(25635),m=a(41602),g=a(73707),y=a(49501),w=a(17681),v=a(75912),j=a(70690),b=a(80007),A=a(74482),k=a(40171),C=a(36944);let S=(0,a(87021).h)("frontend/components/shared/FolderPickerDialog"),N=e=>{let{open:t,title:a="Choose a folder",selectFiles:N=!1,initialPath:T,onClose:E,onSelect:I}=e,[F,W]=(0,n.useState)(null),[P,R]=(0,n.useState)(""),[O,z]=(0,n.useState)(!1),[M,U]=(0,n.useState)(null),D=(0,n.useCallback)(async e=>{z(!0),U(null);try{let t=e?"?path=".concat(encodeURIComponent(e)):"",a=await fetch("/api/browse".concat(t)),l=await a.json();if(!a.ok||l.error)return void U(l.error||"HTTP ".concat(a.status));W(l),R(l.path)}catch(e){S.warn("Browse failed",e),U("Could not reach the backend to browse folders.")}finally{z(!1)}},[]);(0,n.useEffect)(()=>{t?D(T||void 0):(W(null),U(null))},[t,T,D]);let L=e=>{I(e),E()};return(0,l.jsxs)(r.A,{open:t,onClose:E,maxWidth:"sm",fullWidth:!0,children:[(0,l.jsx)(o.A,{children:a}),(0,l.jsxs)(s.A,{dividers:!0,sx:{display:"flex",flexDirection:"column",gap:1.5},children:[(0,l.jsxs)(i.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(d.A,{title:"Up one folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:!(null==F?void 0:F.parent)||O,onClick:()=>(null==F?void 0:F.parent)&&void D(F.parent),children:(0,l.jsx)(k.A,{fontSize:"small"})})})}),(0,l.jsx)(d.A,{title:"Home folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:O,onClick:()=>void D(),children:(0,l.jsx)(C.A,{fontSize:"small"})})})}),(0,l.jsx)(u.A,{fullWidth:!0,size:"small",value:P,onChange:e=>R(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),D(P))},placeholder:"Type a path and press Enter"})]}),F&&F.drives.length>0&&(0,l.jsx)(i.default,{sx:{display:"flex",gap:.75,flexWrap:"wrap"},children:F.drives.map(e=>(0,l.jsx)(h.A,{label:e,size:"small",variant:F.path.toLowerCase().startsWith(e.toLowerCase())?"filled":"outlined",onClick:()=>void D(e)},e))}),M&&(0,l.jsx)(x.A,{severity:"error",children:M}),(0,l.jsxs)(i.default,{sx:{minHeight:240,maxHeight:"45vh",overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:[O&&(0,l.jsx)(i.default,{sx:{display:"flex",justifyContent:"center",py:4},children:(0,l.jsx)(p.default,{size:24})}),!O&&F&&0===F.entries.length&&(0,l.jsx)(f.default,{variant:"body2",color:"text.secondary",sx:{p:2},children:"This folder is empty."}),!O&&(0,l.jsx)(m.A,{dense:!0,disablePadding:!0,children:null==F?void 0:F.entries.map(e=>(0,l.jsxs)(g.A,{disabled:!e.isDirectory&&!N,onClick:()=>e.isDirectory?void D(e.path):L(e.path),children:[(0,l.jsx)(y.A,{sx:{minWidth:34},children:e.isDirectory?(0,l.jsx)(b.A,{fontSize:"small",color:"primary"}):(0,l.jsx)(A.A,{fontSize:"small"})}),(0,l.jsx)(w.A,{primary:e.name,primaryTypographyProps:{noWrap:!0}})]},e.path))})]})]}),(0,l.jsxs)(v.A,{children:[(0,l.jsx)(j.A,{onClick:E,children:"Cancel"}),(0,l.jsx)(j.A,{variant:"contained",disabled:!F||O,onClick:()=>F&&L(F.path),children:"Select this folder"})]})]})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>o});var l=a(74879);let n=(0,a(87021).h)("frontend/services/flow/index");class r{async loadFlows(){n.debug("loadFlows: Entering method");try{if(this.flowsCache)return n.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return n.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return n.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){n.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return n.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return n.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return n.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return n.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){n.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),n.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async updateFlow(e){n.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return n.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){n.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),n.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return n.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}createNode(e,t){return n.debug("createNode: Entering method",{type:e,position:t}),{id:(0,l.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:{}}}}createStartNode(){return{id:(0,l.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";return n.debug("createNewFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return n.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return n.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let o=new r},95271:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>eF});var l=a(95155),n=a(94049),r=a(12115),o=a(25635),s=a(99944),i=a(9957),d=a(70690),c=a(2778),u=a(52363),h=a(65036),x=a(75912),p=a(86946),f=a(76530),m=a(78470),g=a(41983),y=a(87021);let w=(0,y.h)("frontend/services/plannedExecutions");class v{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return w.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await a.json();if(!a.ok)return{success:!1,error:(null==l?void 0:l.error)||"HTTP ".concat(a.status)};return{success:!0,execution:l.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return w.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let j=new v;var b=a(2300),A=a(28548),k=a(4474),C=a(50430),S=a(55406),N=a(14915),T=a(4484),E=a(63186),I=a(62962),F=a(3713);let W=e=>String(e).padStart(2,"0"),P=e=>{switch(e){case"completed":return"success.main";case"error":return"error.main";case"skipped":return"warning.main";default:return"transparent"}},R=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",O=e=>{if(!e.finishedAt)return"";let t=new Date(e.finishedAt).getTime()-new Date(e.firedAt).getTime();return t<1e3?"<1s":t<6e4?"".concat(Math.round(t/1e3),"s"):"".concat(Math.round(t/6e4),"min")},z=e=>{var t;let{entry:a,onEdit:s,onDelete:p,onToggleEnabled:f,onRanNow:y}=e,{execution:w,status:v,lastRun:z}=a,[M,U]=(0,r.useState)(!1),[D,L]=(0,r.useState)(null),[H,J]=(0,r.useState)(!1),[q,$]=(0,r.useState)(!1),[B,G]=(0,r.useState)(null),_=(0,r.useCallback)(async()=>{J(!0),L([...await j.loadRuns(w.id)].reverse()),J(!1)},[w.id]);(0,r.useEffect)(()=>{M&&_()},[M,_,null==z?void 0:z.runId]);let K=async()=>{$(!0),await j.runNow(w.id),$(!1),M&&_(),y()};return(0,l.jsxs)(b.A,{variant:"outlined",sx:{p:2},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap"},children:[(0,l.jsxs)(n.default,{sx:{flexGrow:1,minWidth:220},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600},children:w.name}),(0,l.jsx)(A.A,{size:"small",label:function(e){switch(e.type){case"schedule":{var t;let a,l=(t=e.cron,(a=/^\*\/(\d+) \* \* \* \* \*$/.exec(t))?"Every ".concat(a[1],"s"):(a=/^\*\/(\d+) \* \* \* \*$/.exec(t))?"Every ".concat(a[1]," min"):(a=/^0 \*\/(\d+) \* \* \*$/.exec(t))?1===Number(a[1])?"Every hour":"Every ".concat(a[1]," hours"):(a=/^(\d+) (\d+) \* \* \*$/.exec(t))?"Daily at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):(a=/^(\d+) (\d+) \* \* 1-5$/.exec(t))?"Weekdays at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):null);return null!=l?l:"Schedule: ".concat(e.cron)}case"webhook":return"Webhook";case"file-watch":return"Watching ".concat(e.path);case"mcp-poll":return"Watching ".concat(e.serverName," › ").concat(e.toolName);case"url-watch":try{return"Watching ".concat(new URL(e.url).hostname)}catch(e){return"Watching a URL"}default:return"Trigger"}}(w.trigger)}),!w.enabled&&(0,l.jsx)(A.A,{size:"small",label:"Off",variant:"outlined"})]}),v.running?(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(k.default,{size:12,thickness:6}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Running…",v.runningSince?" — started ".concat(R(v.runningSince)):""]})]}):(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[v.nextRun&&w.enabled?"Next run: ".concat(R(v.nextRun)):w.enabled&&!v.armed?"Not armed":"",v.lastTriggerError?" — trigger error: ".concat(v.lastTriggerError):""]}),z&&(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(m.A,{title:z.status,children:(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(z.status),flexShrink:0}})}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Last run ",R(z.firedAt),"error"===z.status&&z.error?" — ".concat(z.error):""]})]})]}),(0,l.jsx)(m.A,{title:"Run now",children:(0,l.jsx)("span",{children:(0,l.jsx)(g.A,{onClick:K,disabled:q,color:"primary",children:q?(0,l.jsx)(k.default,{size:20}):(0,l.jsx)(S.A,{})})})}),(0,l.jsx)(m.A,{title:w.enabled?"Turn off":"Turn on",children:(0,l.jsx)(i.A,{checked:w.enabled,onChange:e=>f(e.target.checked)})}),(0,l.jsx)(m.A,{title:"Edit",children:(0,l.jsx)(g.A,{onClick:s,children:(0,l.jsx)(N.A,{})})}),(0,l.jsx)(m.A,{title:"Delete",children:(0,l.jsx)(g.A,{onClick:p,children:(0,l.jsx)(T.A,{})})}),(0,l.jsx)(m.A,{title:M?"Hide run history":"Show run history",children:(0,l.jsx)(g.A,{onClick:()=>U(e=>!e),children:M?(0,l.jsx)(I.A,{}):(0,l.jsx)(E.A,{})})})]}),(0,l.jsx)(C.A,{in:M,timeout:"auto",unmountOnExit:!0,children:(0,l.jsxs)(n.default,{sx:{mt:2,borderTop:1,borderColor:"divider",pt:1.5},children:[H&&!D&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Loading runs…"}),D&&0===D.length&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No runs yet. Use the play button to try it now."}),null==D?void 0:D.map(e=>{var t;return(0,l.jsxs)(n.default,{sx:{display:"flex",gap:1,py:.75,alignItems:"flex-start","&:hover .run-detail-button":{opacity:1}},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(e.status),mt:"5px",flexShrink:0}}),(0,l.jsxs)(n.default,{sx:{minWidth:0,flexGrow:1},children:[(0,l.jsxs)(o.default,{variant:"body2",children:[R(e.firedAt),O(e)?" \xb7 ".concat(O(e)):""," \xb7 ",e.triggerSummary,(null==(t=e.usage)?void 0:t.totalTokens)?" \xb7 ".concat(e.usage.totalTokens.toLocaleString()," tokens"):""]}),e.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",children:e.error}),e.outputText&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.outputText})]}),(0,l.jsx)(m.A,{title:"Show full output",children:(0,l.jsx)(g.A,{className:"run-detail-button",size:"small",onClick:()=>G(e),sx:{opacity:{xs:1,md:.35},transition:"opacity 120ms",flexShrink:0},children:(0,l.jsx)(F.A,{fontSize:"inherit"})})})]},e.runId)})]})}),(0,l.jsxs)(c.A,{open:null!==B,onClose:()=>G(null),maxWidth:"md",fullWidth:!0,children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:B?P(B.status):"transparent",flexShrink:0}}),(0,l.jsxs)(o.default,{variant:"h6",children:[w.name," — ",B?R(B.firedAt):""]})]})}),(0,l.jsx)(h.A,{dividers:!0,children:B&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:[B.status,O(B)?" \xb7 ".concat(O(B)):""," \xb7 ",B.triggerSummary,(null==(t=B.usage)?void 0:t.totalTokens)?" \xb7 ".concat(B.usage.totalTokens.toLocaleString()," tokens (").concat(B.usage.promptTokens.toLocaleString()," in / ").concat(B.usage.completionTokens.toLocaleString()," out)"):""]}),B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",sx:{mb:1.5,whiteSpace:"pre-wrap"},children:B.error}),B.outputText?(0,l.jsx)(n.default,{sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",bgcolor:"action.hover",borderRadius:1,p:2,fontSize:14,maxHeight:"55vh",overflow:"auto"},children:B.outputText}):!B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This run produced no output text."})]})}),(0,l.jsx)(x.A,{children:(0,l.jsx)(d.A,{onClick:()=>G(null),children:"Close"})})]})]})};var M=a(21067),U=a(9562),D=a(52641),L=a(51221),H=a(55606),J=a(86973),q=a(22003),$=a(77073),B=a(26922),G=a(40520),_=a(79299),K=a(22590),Q=a(53657),X=a(90057),Y=a(36741);let V=e=>{let{selected:t,icon:a,title:r,description:s,onClick:i}=e;return(0,l.jsxs)(n.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:i,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},sx:{flex:1,minWidth:200,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,l.jsx)(Y.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[a,(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:r})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:s})]})};var Z=a(22822),ee=a(98267),et=a(20537),ea=a(37960);let el=e=>String(e).padStart(2,"0"),en=e=>{let{cron:t,timezone:a,onChange:i,verb:d="Runs",catchUp:c,onCatchUpChange:u}=e,h=(0,r.useMemo)(()=>(function(e){let t=/^\*\/(\d+) \* \* \* \* \*$/.exec(e);return t?{mode:"seconds",n:Number(t[1]),time:"09:00"}:(t=/^\*\/(\d+) \* \* \* \*$/.exec(e))?{mode:"minutes",n:Number(t[1]),time:"09:00"}:(t=/^0 \*\/(\d+) \* \* \*$/.exec(e))?{mode:"hours",n:Number(t[1]),time:"09:00"}:(t=/^(\d+) (\d+) \* \* \*$/.exec(e))?{mode:"daily",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:(t=/^(\d+) (\d+) \* \* 1-5$/.exec(e))?{mode:"weekdays",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:{mode:"custom",n:15,time:"09:00"}})(t),[]),[x,p]=(0,r.useState)(h.mode),[f,m]=(0,r.useState)(h.n),[g,y]=(0,r.useState)(h.time),[w,v]=(0,r.useState)(t),[b,A]=(0,r.useState)(null),k=function(e,t,a,l){let[n,r]=a.split(":").map(Number);switch(e){case"seconds":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * * *");case"minutes":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * *");case"hours":return"0 */".concat(Math.max(1,Math.min(23,Math.floor(t)||1))," * * *");case"daily":return"".concat(r||0," ").concat(n||0," * * *");case"weekdays":return"".concat(r||0," ").concat(n||0," * * 1-5");default:return l}}(x,f,g,w);return(0,r.useEffect)(()=>{k!==t&&i({cron:k,timezone:a})},[k]),(0,r.useEffect)(()=>{let e=!1,t=setTimeout(()=>{j.previewSchedule(k,a).then(t=>{e||A(t)})},300);return()=>{e=!0,clearTimeout(t)}},[k,a]),(0,l.jsxs)(n.default,{children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1},children:[(0,l.jsxs)(D.A,{sx:{minWidth:180},children:[(0,l.jsx)(L.A,{id:"schedule-preset-label",children:d}),(0,l.jsxs)(H.A,{labelId:"schedule-preset-label",label:d,value:x,onChange:e=>p(e.target.value),children:[(0,l.jsx)(J.A,{value:"seconds",children:"Every N seconds"}),(0,l.jsx)(J.A,{value:"minutes",children:"Every N minutes"}),(0,l.jsx)(J.A,{value:"hours",children:"Every N hours"}),(0,l.jsx)(J.A,{value:"daily",children:"Daily at a time"}),(0,l.jsx)(J.A,{value:"weekdays",children:"Weekdays at a time"}),(0,l.jsx)(J.A,{value:"custom",children:"Custom (cron)"})]})]}),("seconds"===x||"minutes"===x||"hours"===x)&&(0,l.jsx)(U.A,{label:"seconds"===x?"Seconds":"minutes"===x?"Minutes":"Hours",type:"number",value:f,onChange:e=>m(Number(e.target.value)),inputProps:{min:1,max:"hours"===x?23:59},sx:{width:120}}),("daily"===x||"weekdays"===x)&&(0,l.jsx)(U.A,{label:"Time",type:"time",value:g,onChange:e=>y(e.target.value),sx:{width:150},InputLabelProps:{shrink:!0}}),"custom"===x&&(0,l.jsx)(U.A,{label:"Cron pattern",value:w,onChange:e=>v(e.target.value),sx:{minWidth:220},placeholder:"*/15 * * * *"})]}),b&&!b.valid&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:b.error||"This schedule is not valid."}),b&&b.valid&&b.nextRuns.length>0&&(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:2},children:["Next: ",b.nextRuns.map(e=>new Date(e).toLocaleString()).join(" \xb7 ")]}),u&&(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===c,onChange:e=>u(e.target.checked)}),label:"If FLUJO was closed at a scheduled time, run once on startup"}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(U.A,{label:"Timezone (optional)",value:a||"",onChange:e=>i({cron:k,timezone:e.target.value||void 0}),placeholder:"e.g. Europe/Berlin",helperText:"IANA timezone name. Empty = this computer's timezone.",sx:{minWidth:260}}),(0,l.jsx)(U.A,{label:"Generated cron pattern",value:k,InputProps:{readOnly:"custom"!==x},onChange:e=>{p("custom"),v(e.target.value)},helperText:"Editing switches to Custom mode.",sx:{minWidth:220}})]})})]})]})};var er=a(52277),eo=a(9693);let es=e=>{let{config:t,onChange:a,executionId:i,saved:c}=e,[u,h]=(0,r.useState)(null),x=window.location.origin,p="".concat(x,"/api/webhooks/").concat(i),f=async(e,t)=>{try{await navigator.clipboard.writeText(t),h(e),setTimeout(()=>h(null),1500)}catch(e){}};return(0,l.jsxs)(n.default,{sx:{mt:1},children:[!c&&(0,l.jsx)(q.A,{severity:"info",sx:{mb:2},children:"This URL and token are ready to copy now — they become active when you save."}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Webhook URL",value:p,InputProps:{readOnly:!0},size:"small"}),(0,l.jsx)(m.A,{title:"Copy URL",children:(0,l.jsx)(g.A,{onClick:()=>f("url",p),children:"url"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})})]}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mt:2},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Secret token",value:t.token,InputProps:{readOnly:!0},size:"small",type:"password"}),(0,l.jsx)(m.A,{title:"Copy token",children:(0,l.jsx)(g.A,{onClick:()=>f("token",t.token),disabled:!t.token,children:"token"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})}),(0,l.jsx)(d.A,{size:"small",onClick:()=>a({...t,token:crypto.randomUUID()}),sx:{whiteSpace:"nowrap"},children:"New token"})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:c?"A new token takes effect when you save — callers using the old one are cut off.":""}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:1.5},children:["Callers send a POST with the token in the ",(0,l.jsx)("code",{children:"X-Flujo-Token"})," ","header (or ",(0,l.jsx)("code",{children:"?token=…"}),"). The request body becomes part of the flow's input — treat it as untrusted data in your prompt."]}),(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===t.allowExternal,onChange:e=>a({...t,allowExternal:e.target.checked})}),label:"Allow calls from other machines (default: this computer only)"}),t.allowExternal&&(0,l.jsx)(q.A,{severity:"warning",children:"FLUJO assumes a single user on this machine. If you expose it beyond localhost (port forwarding, tunnels), securing that access is your responsibility — anyone with the URL and token can run this flow."})]})};var ei=a(56422),ed=a(17325),ec=a(80007),eu=a(62640);let eh=[{value:"add",label:"A file appears"},{value:"change",label:"A file changes"},{value:"unlink",label:"A file is deleted"}],ex=e=>{var t;let{config:a,onChange:i}=e,[d,c]=(0,r.useState)(!1);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Folder (or file) to watch",value:a.path,onChange:e=>i({...a,path:e.target.value}),placeholder:"e.g. C:\\Users\\me\\Documents\\inbox",margin:"normal",InputProps:{endAdornment:(0,l.jsx)(ei.A,{position:"end",children:(0,l.jsx)(m.A,{title:"Browse folders (on the FLUJO machine)",children:(0,l.jsx)(g.A,{edge:"end",onClick:()=>c(!0),children:(0,l.jsx)(ec.A,{})})})})}}),(0,l.jsx)(eu.A,{open:d,title:"Choose what to watch",selectFiles:!0,initialPath:a.path||void 0,onClose:()=>c(!1),onSelect:e=>i({...a,path:e})}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Only files matching (optional)",value:a.glob||"",onChange:e=>i({...a,glob:e.target.value||void 0}),placeholder:"e.g. *.pdf or reports/**/*.csv",helperText:"Simple patterns: * matches within a folder, ** across folders, ? one character.",margin:"normal"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"Run when…"}),(0,l.jsx)(ed.A,{row:!0,children:eh.map(e=>(0,l.jsx)(s.A,{control:(0,l.jsx)(Z.A,{checked:a.events.includes(e.value),onChange:t=>((e,t)=>{let l=t?[...a.events,e]:a.events.filter(t=>t!==e);i({...a,events:l})})(e.value,t.target.checked)}),label:e.label},e.value))}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"Bursts are batched: many files changing at once produce one run with all changes listed. If this flow writes into the watched folder, it will trigger itself in a loop — point its output somewhere else."}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsx)(U.A,{label:"Quiet window (ms)",type:"number",value:null!=(t=a.debounceMs)?t:2e3,onChange:e=>i({...a,debounceMs:Math.max(0,Number(e.target.value)||0)}),helperText:"How long to wait after the last change before running.",inputProps:{min:0,step:500},sx:{width:220}})})]})]})};var ep=a(41356),ef=a(24610),em=a(17897),eg=a(43076),ey=a(17427);let ew=(0,y.h)("frontend/components/PlannedExecutions/WatchToolPanel"),ev=e=>{var t,a;let{config:s,onChange:i}=e,[c,u]=(0,r.useState)([]),[h,x]=(0,r.useState)([]),[p,f]=(0,r.useState)(!1),[m,g]=(0,r.useState)(Object.keys(s.args||{}).length>0?JSON.stringify(s.args,null,2):""),[y,w]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,S]=(0,r.useState)(null),[N,T]=(0,r.useState)([]),[E,I]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return em.S.loadServerConfigs().then(t=>{e||(Array.isArray(t)?u(t.filter(e=>!e.disabled).map(e=>e.name)):(ew.warn("Failed to load MCP servers for watch-tool panel",t),u([])))}),()=>{e=!0}},[]),(0,r.useEffect)(()=>{if(!s.serverName)return void x([]);let e=!1;return f(!0),em.S.listServerTools(s.serverName).then(t=>{let{tools:a}=t;e||x(a||[])}).finally(()=>{e||f(!1)}),()=>{e=!0}},[s.serverName]),(0,r.useEffect)(()=>{let e=!1;return eg.N.loadModels().then(t=>{e||T(Array.isArray(t)?t:[])}).catch(()=>{e||T([])}),X.g.loadFlows().then(t=>{e||I(t||[])}).catch(()=>{e||I([])}),()=>{e=!0}},[]);let F=async()=>{j(!0),A(null),S(null);try{let a=await em.S.callTool(s.serverName,s.toolName,s.args||{});if(null==a?void 0:a.error)S("string"==typeof a.error?a.error:"Tool call failed");else{var e,t;let l=null!=(e=null==a?void 0:a.data)?e:a,n=null!=(t=JSON.stringify(l,null,2))?t:"";A(n.length>6e3?"".concat(n.slice(0,6e3),"\n… (truncated)"):n)}}catch(e){S(e instanceof Error?e.message:"Tool call failed")}finally{j(!1)}},W=s.evaluate,P=h.find(e=>e.name===s.toolName);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",children:[(0,l.jsx)(L.A,{id:"watch-server-label",children:"Server"}),(0,l.jsxs)(H.A,{labelId:"watch-server-label",label:"Server",value:c.includes(s.serverName)?s.serverName:"",onChange:e=>i({...s,serverName:e.target.value,toolName:""}),children:[0===c.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No MCP servers configured"}),c.map(e=>(0,l.jsx)(J.A,{value:e,children:e},e))]})]}),(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",disabled:!s.serverName,children:[(0,l.jsx)(L.A,{id:"watch-tool-label",children:"Tool"}),(0,l.jsxs)(H.A,{labelId:"watch-tool-label",label:"Tool",value:h.some(e=>e.name===s.toolName)?s.toolName:"",onChange:e=>i({...s,toolName:e.target.value,args:{}}),children:[0===h.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:p?"Loading tools…":"Pick a server first"}),h.map(e=>(0,l.jsx)(J.A,{value:e.name,children:e.name},e.name))]})]})]}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:null!=(t=s.cron)?t:function(e){let t=Math.max(5,Math.round((null!=e?e:6e4)/1e3));if(t<60)return"*/".concat(t," * * * * *");let a=Math.max(1,Math.round(t/60));if(a<60)return"*/".concat(a," * * * *");let l=Math.max(1,Math.min(23,Math.round(a/60)));return"0 */".concat(l," * * *")}(s.intervalMs),timezone:s.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return i({...s,cron:t,timezone:a})}}),P?(0,l.jsxs)(n.default,{sx:{my:1.5},children:[(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mb:1.5},children:"Tool parameters — sent on every check"}),(0,l.jsx)(ey.A,{schema:P.inputSchema,values:s.args||{},onChange:e=>i({...s,args:e})})]}):(0,l.jsx)(U.A,{fullWidth:!0,label:"Tool arguments (JSON, optional)",value:m,onChange:e=>(e=>{if(g(e),!e.trim()){w(null),i({...s,args:{}});return}try{let t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))return void w('Arguments must be a JSON object, e.g. { "query": "…" }');w(null),i({...s,args:t})}catch(e){w("Not valid JSON yet")}})(e.target.value),margin:"normal",multiline:!0,minRows:2,placeholder:'{ "query": "is:unread" }',error:!!y,helperText:null!=y?y:"Sent to the tool on every check.",slotProps:{input:{sx:{fontFamily:"monospace",fontSize:14}}}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[(0,l.jsx)(d.A,{variant:"outlined",size:"small",onClick:F,disabled:!s.serverName||!s.toolName||v||!!y,startIcon:v?(0,l.jsx)(k.default,{size:16}):void 0,children:"Test: call the tool now"}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"See what the result looks like — useful for the settings below."})]}),C&&(0,l.jsx)(q.A,{severity:"error",sx:{mb:1},children:C}),b&&(0,l.jsx)(n.default,{component:"pre",sx:{maxHeight:240,overflow:"auto",bgcolor:"action.hover",borderRadius:1,p:1.5,fontSize:12,m:0,mb:1},children:b}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:2,mb:1},children:"Run the flow when…"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Poll condition",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"on-change"===W.mode,onClick:()=>i({...s,evaluate:{mode:"on-change"}}),icon:(0,l.jsx)(ep.A,{}),title:"The result changes",description:"Any difference from the last check runs the flow. Simplest — no setup."}),(0,l.jsx)(V,{selected:"llm-gate"===W.mode||"flow-gate"===W.mode,onClick:()=>{"llm-gate"!==W.mode&&"flow-gate"!==W.mode&&i({...s,evaluate:{mode:"llm-gate",condition:"",modelId:""}})},icon:(0,l.jsx)(ef.A,{}),title:"AI decides",description:"Describe the condition in plain language; a model — or one of your flows — checks the result whenever it changes."})]}),("llm-gate"===W.mode||"flow-gate"===W.mode)&&(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Run the flow if…",value:W.condition,onChange:e=>i({...s,evaluate:{...W,condition:e.target.value}}),multiline:!0,minRows:2,margin:"normal",placeholder:"e.g. any email mentions an invoice or a payment reminder"}),(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-start"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:170},children:[(0,l.jsx)(L.A,{id:"gate-checker-label",children:"Checked by"}),(0,l.jsxs)(H.A,{labelId:"gate-checker-label",label:"Checked by",value:W.mode,onChange:e=>{let t=e.target.value;if(t===W.mode)return;let a={condition:W.condition,maxCallsPerDay:W.maxCallsPerDay};i({...s,evaluate:"llm-gate"===t?{mode:t,...a,modelId:""}:{mode:t,...a,flowId:""}})},children:[(0,l.jsx)(J.A,{value:"llm-gate",children:"A model"}),(0,l.jsx)(J.A,{value:"flow-gate",children:"One of my flows"})]})]}),"llm-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-model-label",children:"Model that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-model-label",label:"Model that checks",value:N.some(e=>e.id===W.modelId)?W.modelId:"",onChange:e=>i({...s,evaluate:{...W,modelId:e.target.value}}),children:[0===N.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No models configured"}),N.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),"flow-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-flow-label",children:"Flow that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-flow-label",label:"Flow that checks",value:E.some(e=>e.id===W.flowId)?W.flowId:"",onChange:e=>i({...s,evaluate:{...W,flowId:e.target.value}}),children:[0===E.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No flows available"}),E.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),(0,l.jsx)(U.A,{label:"Max checks per day",type:"number",value:null!=(a=W.maxCallsPerDay)?a:500,onChange:e=>i({...s,evaluate:{...W,maxCallsPerDay:Math.max(1,Number(e.target.value)||1)}}),inputProps:{min:1},helperText:"Cost guard per check.",sx:{width:180}})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5},children:"flow-gate"===W.mode?'The checker flow runs invisibly (never in the chat), gets the condition + tool result, and must answer with {"fire": true/false, "reason": "…"} — it can use its own tools to verify before deciding.':"The model is only asked when the result actually changed since the last check — an idle feed costs nothing. Pick a small, cheap model."})]}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:2},children:"The first check only takes a snapshot — the flow runs from the second check onwards, when something actually changed. FLUJO must be running for checks to happen."})]})},ej=e=>{let{config:t,onChange:a}=e;return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"URL to watch",value:t.url,onChange:e=>a({...t,url:e.target.value}),placeholder:"https://example.com/status or an API/feed URL",margin:"normal",type:"url"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:t.cron,timezone:t.timezone,onChange:e=>{let{cron:l,timezone:n}=e;return a({...t,cron:l,timezone:n})}}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"The first check only takes a snapshot; the flow runs when a later check finds different content, and the fetched content is handed to the flow. Pages that embed ever-changing bits (timestamps, session tokens) look “changed” on every check — plain APIs, feeds, and raw files work best."})]})},eb=(0,y.h)("frontend/components/PlannedExecutions/ExecutionModal"),eA={type:"schedule",cron:"0 9 * * *"},ek={type:"file-watch",path:"",events:["add","change"]},eC={type:"mcp-poll",serverName:"",toolName:"",args:{},cron:"*/5 * * * *",evaluate:{mode:"on-change"}},eS={type:"url-watch",url:"",cron:"*/15 * * * *"},eN=e=>{var t;let{open:a,execution:p,onClose:f,onSaved:m}=e,[y,w]=(0,r.useState)(""),[v,b]=(0,r.useState)(""),[A,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!1),[N,T]=(0,r.useState)(eA),[E,I]=(0,r.useState)(""),[F,W]=(0,r.useState)([]),[P,R]=(0,r.useState)(!1),[O,z]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e,t,l,n;a&&(Z(null),w(null!=(e=null==p?void 0:p.name)?e:""),b(null!=(t=null==p?void 0:p.flowId)?t:""),k(null!=(l=null==p?void 0:p.prompt)?l:""),S((null==p?void 0:p.saveConversations)===!0),T(null!=(n=null==p?void 0:p.trigger)?n:eA),I(p?"":crypto.randomUUID()))},[a,p]),(0,r.useEffect)(()=>{if(!a)return;let e=!1;return R(!0),X.g.loadFlows().then(t=>{e||W(t||[])}).catch(t=>{eb.warn("Failed to load flows for execution picker",t),e||W([])}).finally(()=>{e||R(!1)}),()=>{e=!0}},[a]);let ee=!!v&&!P&&F.length>0&&!F.some(e=>e.id===v),et=async()=>{var e;z(!0),Z(null);let t={name:y,flowId:v,prompt:A,saveConversations:C,trigger:N,enabled:null==(e=null==p?void 0:p.enabled)||e,...p?{}:{id:E}},a=p?await j.update(p.id,t):await j.create(t);if(z(!1),!a.success)return void Z(a.error||"Failed to save");m(),f()};return(0,l.jsxs)(c.A,{open:a,onClose:f,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,l.jsx)(o.default,{variant:"h6",children:p?"Edit planned execution":"New planned execution"}),(0,l.jsx)(g.A,{edge:"end",color:"inherit",onClick:f,"aria-label":"close",children:(0,l.jsx)($.A,{})})]})}),(0,l.jsx)(M.A,{}),(0,l.jsxs)(h.A,{sx:{p:3},children:[(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"A planned execution runs one of your flows automatically — on a schedule or when something happens — without anyone sitting in the chat. Results show up in its run history on the Executions page."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Name",value:y,onChange:e=>w(e.target.value),margin:"normal",placeholder:"e.g. Morning news digest"}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:3,mb:1,fontWeight:600},children:"1 \xb7 When should it run?"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Trigger type",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"schedule"===N.type,onClick:()=>{"schedule"!==N.type&&T((null==p?void 0:p.trigger.type)==="schedule"?p.trigger:eA)},icon:(0,l.jsx)(B.A,{}),title:"On a schedule",description:"Run at fixed times — every few minutes, daily, on weekdays, or a custom rhythm."}),(0,l.jsx)(V,{selected:"webhook"===N.type,onClick:()=>{"webhook"!==N.type&&T((null==p?void 0:p.trigger.type)==="webhook"?p.trigger:{type:"webhook",token:crypto.randomUUID()})},icon:(0,l.jsx)(G.A,{}),title:"When called (webhook)",description:"Other apps run this flow by calling a URL — GitHub, Stripe, Slack and most services can send webhooks."}),(0,l.jsx)(V,{selected:"file-watch"===N.type,onClick:()=>{"file-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="file-watch"?p.trigger:ek)},icon:(0,l.jsx)(_.A,{}),title:"When files change",description:"Watch a folder on this computer and run when files appear, change, or disappear."}),(0,l.jsx)(V,{selected:"mcp-poll"===N.type,onClick:()=>{"mcp-poll"!==N.type&&T((null==p?void 0:p.trigger.type)==="mcp-poll"?p.trigger:eC)},icon:(0,l.jsx)(K.A,{}),title:"Watch a tool",description:"Check one of your MCP tools regularly — run when its result changes, or let AI decide."}),(0,l.jsx)(V,{selected:"url-watch"===N.type,onClick:()=>{"url-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="url-watch"?p.trigger:eS)},icon:(0,l.jsx)(Q.A,{}),title:"When a website changes",description:"Check a URL regularly and run when its content is different from the last check."})]}),"schedule"===N.type&&(0,l.jsx)(en,{cron:N.cron,timezone:N.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return T({...N,cron:t,timezone:a})},catchUp:!0===N.catchUp,onCatchUpChange:e=>T({...N,catchUp:e})}),"webhook"===N.type&&(0,l.jsx)(es,{config:N,onChange:T,executionId:null!=(t=null==p?void 0:p.id)?t:E,saved:null!==p}),"file-watch"===N.type&&(0,l.jsx)(ex,{config:N,onChange:T}),"mcp-poll"===N.type&&(0,l.jsx)(ev,{config:N,onChange:T}),"url-watch"===N.type&&(0,l.jsx)(ej,{config:N,onChange:T}),(0,l.jsx)(M.A,{sx:{mt:3}}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:2,mb:0,fontWeight:600},children:"2 \xb7 What should it run?"}),(0,l.jsxs)(D.A,{fullWidth:!0,margin:"normal",children:[(0,l.jsx)(L.A,{id:"execution-flow-label",children:"Flow to run"}),(0,l.jsxs)(H.A,{labelId:"execution-flow-label",label:"Flow to run",value:ee?"":v,onChange:e=>b(e.target.value),displayEmpty:!0,children:[0===F.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:P?"Loading flows…":"No flows available"}),F.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),ee&&(0,l.jsx)(q.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"What should the flow do?",value:A,onChange:e=>k(e.target.value),margin:"normal",multiline:!0,rows:3,helperText:"Sent to the flow as the user message each time this runs. Run details are attached automatically: current time, what triggered it, the previous run, the next planned run, and any trigger data."}),(0,l.jsx)(s.A,{sx:{mt:1},control:(0,l.jsx)(i.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Save full conversations (each run appears in the chat sidebar — useful for debugging)"}),Y&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:Y})]}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:f,children:"Cancel"}),(0,l.jsx)(d.A,{onClick:et,variant:"contained",color:"primary",disabled:O||!y.trim()||!v,children:O?"Saving…":"Save"})]})]})},eT=(0,y.h)("frontend/components/PlannedExecutions"),eE=()=>{let[e,t]=(0,r.useState)([]),[a,y]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),[b,A]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,N]=(0,r.useState)(null),T=(0,r.useCallback)(async()=>{let e=await j.list();t(e.executions),y(e.paused),v(!0)},[]);(0,r.useEffect)(()=>{T()},[T]);let E=e.some(e=>e.status.running);(0,r.useEffect)(()=>{let e=setInterval(()=>{document.hidden||T()},E?3e3:1e4);return()=>clearInterval(e)},[T,E]);let I=async e=>{y(e);let t=await j.setPaused(e);t.success||eT.warn("Failed to toggle pause",t.error),T()},F=async(e,t)=>{await j.update(e.id,{enabled:t}),T()},W=async()=>{S&&(await j.delete(S.id),N(null),T())};return(0,l.jsxs)(n.default,{sx:{p:3,maxWidth:1100,mx:"auto",width:"100%"},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:2,mb:1},children:[(0,l.jsx)(o.default,{variant:"h5",children:"Planned Executions"}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,l.jsx)(m.A,{title:"Refresh",children:(0,l.jsx)(g.A,{onClick:()=>void T(),children:(0,l.jsx)(f.A,{})})}),(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{checked:!a,onChange:e=>I(!e.target.checked)}),label:a?"Paused":"Active"}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},"data-tour":"add-execution",children:"Add"})]})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Run your flows automatically — on a schedule or when something happens — without opening the chat. FLUJO must be running for triggers to fire."}),w&&0===e.length&&(0,l.jsxs)(n.default,{sx:{border:1,borderColor:"divider",borderRadius:2,borderStyle:"dashed",p:6,textAlign:"center"},children:[(0,l.jsx)(o.default,{variant:"h6",sx:{mb:1},children:"Nothing planned yet"}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Create your first planned execution to run a flow on a schedule."}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},children:"New planned execution"})]}),(0,l.jsx)(n.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(e=>(0,l.jsx)(z,{entry:e,onEdit:()=>{C(e.execution),A(!0)},onDelete:()=>N(e.execution),onToggleEnabled:t=>F(e.execution,t),onRanNow:()=>void T()},e.execution.id))}),(0,l.jsx)(eN,{open:b,execution:k,onClose:()=>A(!1),onSaved:()=>void T()}),(0,l.jsxs)(c.A,{open:null!==S,onClose:()=>N(null),children:[(0,l.jsxs)(u.A,{children:["Delete “",null==S?void 0:S.name,"”?"]}),(0,l.jsx)(h.A,{children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This removes the planned execution and its run history. The flow itself is not affected."})}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:()=>N(null),children:"Cancel"}),(0,l.jsx)(d.A,{color:"error",variant:"contained",onClick:W,children:"Delete"})]})]})]})},eI=(0,y.h)("app/executions/page");function eF(){return eI.debug("Rendering ExecutionsPage"),(0,l.jsx)(n.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,l.jsx)(eE,{})})}}},e=>{e.O(0,[2678,4754,9244,8548,690,9562,2003,488,3272,5648,7396,7329,3750,3235,2380,8441,1255,7358],()=>e(e.s=60187)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1488],{17427:(e,t,a)=>{"use strict";a.d(t,{A:()=>p});var l=a(95155),n=a(12115),r=a(25635),o=a(94049),s=a(99944),i=a(9957),d=a(52641),c=a(51221),u=a(55606),h=a(86973),x=a(9562);let p=e=>{var t;let{schema:a,values:p,onChange:f,size:m="small"}=e,[g,y]=(0,n.useState)({}),w=null!=(t=null==a?void 0:a.properties)?t:{},v=Array.isArray(null==a?void 0:a.required)?a.required:[],j=Object.keys(w);if(0===j.length)return(0,l.jsx)(r.default,{variant:"body2",color:"text.secondary",children:"This tool takes no parameters."});let b=(e,t)=>{let a={...p};void 0===t?delete a[e]:a[e]=t,f(a)};return(0,l.jsx)(o.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:j.map(e=>{var t,a;let n=null!=(t=w[e])?t:{},f=v.includes(e)?"".concat(e," *"):e,j="string"==typeof n.description?n.description:"";if("boolean"===n.type)return(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{size:m,checked:!0===p[e],onChange:t=>b(e,t.target.checked)}),label:(0,l.jsxs)(o.default,{children:[(0,l.jsx)(r.default,{variant:"body2",children:f}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",children:j})]})},e);if(Array.isArray(n.enum)&&n.enum.length>0){let t=p[e];return(0,l.jsxs)(d.A,{size:m,fullWidth:!0,children:[(0,l.jsx)(c.A,{id:"schema-param-".concat(e),children:f}),(0,l.jsx)(u.A,{labelId:"schema-param-".concat(e),label:f,value:n.enum.includes(t)?t:"",onChange:t=>b(e,t.target.value),children:n.enum.map(e=>(0,l.jsx)(h.A,{value:e,children:String(e)},String(e)))}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mx:1.75},children:j})]},e)}if("number"===n.type||"integer"===n.type)return(0,l.jsx)(x.A,{fullWidth:!0,size:m,type:"number",label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>{let a=t.target.value;if(""===a)return void b(e,void 0);let l="integer"===n.type?parseInt(a,10):parseFloat(a);b(e,Number.isNaN(l)?void 0:l)},helperText:j},e);if("object"===n.type||"array"===n.type){let t=null!=(a=g[e])?a:void 0!==p[e]?JSON.stringify(p[e],null,2):"",r=null;if(t.trim())try{JSON.parse(t)}catch(e){r="Not valid JSON yet"}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,multiline:!0,minRows:2,label:"".concat(f," (JSON ").concat(n.type,")"),value:t,error:!!r,helperText:null!=r?r:j,onChange:t=>{let a=t.target.value;if(y(t=>({...t,[e]:a})),!a.trim())return void b(e,void 0);try{b(e,JSON.parse(a))}catch(e){}},slotProps:{input:{sx:{fontFamily:"monospace",fontSize:13}}}},e)}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>b(e,""===t.target.value?void 0:t.target.value),helperText:j},e)})})}},60187:(e,t,a)=>{Promise.resolve().then(a.bind(a,95271))},62640:(e,t,a)=>{"use strict";a.d(t,{A:()=>N});var l=a(95155),n=a(12115),r=a(2778),o=a(52363),s=a(65036),i=a(94049),d=a(78470),c=a(41983),u=a(9562),h=a(28548),x=a(22003),p=a(4474),f=a(25635),m=a(41602),g=a(73707),y=a(49501),w=a(17681),v=a(75912),j=a(70690),b=a(80007),A=a(74482),k=a(40171),C=a(36944);let S=(0,a(87021).h)("frontend/components/shared/FolderPickerDialog"),N=e=>{let{open:t,title:a="Choose a folder",selectFiles:N=!1,initialPath:T,onClose:E,onSelect:I}=e,[F,W]=(0,n.useState)(null),[P,R]=(0,n.useState)(""),[O,z]=(0,n.useState)(!1),[M,U]=(0,n.useState)(null),D=(0,n.useCallback)(async e=>{z(!0),U(null);try{let t=e?"?path=".concat(encodeURIComponent(e)):"",a=await fetch("/api/browse".concat(t)),l=await a.json();if(!a.ok||l.error)return void U(l.error||"HTTP ".concat(a.status));W(l),R(l.path)}catch(e){S.warn("Browse failed",e),U("Could not reach the backend to browse folders.")}finally{z(!1)}},[]);(0,n.useEffect)(()=>{t?D(T||void 0):(W(null),U(null))},[t,T,D]);let L=e=>{I(e),E()};return(0,l.jsxs)(r.A,{open:t,onClose:E,maxWidth:"sm",fullWidth:!0,children:[(0,l.jsx)(o.A,{children:a}),(0,l.jsxs)(s.A,{dividers:!0,sx:{display:"flex",flexDirection:"column",gap:1.5},children:[(0,l.jsxs)(i.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(d.A,{title:"Up one folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:!(null==F?void 0:F.parent)||O,onClick:()=>(null==F?void 0:F.parent)&&void D(F.parent),children:(0,l.jsx)(k.A,{fontSize:"small"})})})}),(0,l.jsx)(d.A,{title:"Home folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:O,onClick:()=>void D(),children:(0,l.jsx)(C.A,{fontSize:"small"})})})}),(0,l.jsx)(u.A,{fullWidth:!0,size:"small",value:P,onChange:e=>R(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),D(P))},placeholder:"Type a path and press Enter"})]}),F&&F.drives.length>0&&(0,l.jsx)(i.default,{sx:{display:"flex",gap:.75,flexWrap:"wrap"},children:F.drives.map(e=>(0,l.jsx)(h.A,{label:e,size:"small",variant:F.path.toLowerCase().startsWith(e.toLowerCase())?"filled":"outlined",onClick:()=>void D(e)},e))}),M&&(0,l.jsx)(x.A,{severity:"error",children:M}),(0,l.jsxs)(i.default,{sx:{minHeight:240,maxHeight:"45vh",overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:[O&&(0,l.jsx)(i.default,{sx:{display:"flex",justifyContent:"center",py:4},children:(0,l.jsx)(p.default,{size:24})}),!O&&F&&0===F.entries.length&&(0,l.jsx)(f.default,{variant:"body2",color:"text.secondary",sx:{p:2},children:"This folder is empty."}),!O&&(0,l.jsx)(m.A,{dense:!0,disablePadding:!0,children:null==F?void 0:F.entries.map(e=>(0,l.jsxs)(g.A,{disabled:!e.isDirectory&&!N,onClick:()=>e.isDirectory?void D(e.path):L(e.path),children:[(0,l.jsx)(y.A,{sx:{minWidth:34},children:e.isDirectory?(0,l.jsx)(b.A,{fontSize:"small",color:"primary"}):(0,l.jsx)(A.A,{fontSize:"small"})}),(0,l.jsx)(w.A,{primary:e.name,primaryTypographyProps:{noWrap:!0}})]},e.path))})]})]}),(0,l.jsxs)(v.A,{children:[(0,l.jsx)(j.A,{onClick:E,children:"Cancel"}),(0,l.jsx)(j.A,{variant:"contained",disabled:!F||O,onClick:()=>F&&L(F.path),children:"Select this folder"})]})]})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>o});var l=a(74879);let n=(0,a(87021).h)("frontend/services/flow/index");class r{async loadFlows(){n.debug("loadFlows: Entering method");try{if(this.flowsCache)return n.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return n.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return n.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){n.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return n.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return n.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return n.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return n.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){n.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),n.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async updateFlow(e){n.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return n.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){n.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),n.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return n.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}createNode(e,t){return n.debug("createNode: Entering method",{type:e,position:t}),{id:(0,l.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:{}}}}createStartNode(){return{id:(0,l.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";return n.debug("createNewFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return n.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return n.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let o=new r},95271:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>eF});var l=a(95155),n=a(94049),r=a(12115),o=a(25635),s=a(99944),i=a(9957),d=a(70690),c=a(2778),u=a(52363),h=a(65036),x=a(75912),p=a(86946),f=a(76530),m=a(78470),g=a(41983),y=a(87021);let w=(0,y.h)("frontend/services/plannedExecutions");class v{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return w.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await a.json();if(!a.ok)return{success:!1,error:(null==l?void 0:l.error)||"HTTP ".concat(a.status)};return{success:!0,execution:l.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return w.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let j=new v;var b=a(2300),A=a(28548),k=a(4474),C=a(50430),S=a(55406),N=a(14915),T=a(4484),E=a(63186),I=a(62962),F=a(3713);let W=e=>String(e).padStart(2,"0"),P=e=>{switch(e){case"completed":return"success.main";case"error":return"error.main";case"skipped":return"warning.main";default:return"transparent"}},R=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",O=e=>{if(!e.finishedAt)return"";let t=new Date(e.finishedAt).getTime()-new Date(e.firedAt).getTime();return t<1e3?"<1s":t<6e4?"".concat(Math.round(t/1e3),"s"):"".concat(Math.round(t/6e4),"min")},z=e=>{var t;let{entry:a,onEdit:s,onDelete:p,onToggleEnabled:f,onRanNow:y}=e,{execution:w,status:v,lastRun:z}=a,[M,U]=(0,r.useState)(!1),[D,L]=(0,r.useState)(null),[H,J]=(0,r.useState)(!1),[q,$]=(0,r.useState)(!1),[B,G]=(0,r.useState)(null),_=(0,r.useCallback)(async()=>{J(!0),L([...await j.loadRuns(w.id)].reverse()),J(!1)},[w.id]);(0,r.useEffect)(()=>{M&&_()},[M,_,null==z?void 0:z.runId]);let K=async()=>{$(!0),await j.runNow(w.id),$(!1),M&&_(),y()};return(0,l.jsxs)(b.A,{variant:"outlined",sx:{p:2},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap"},children:[(0,l.jsxs)(n.default,{sx:{flexGrow:1,minWidth:220},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600},children:w.name}),(0,l.jsx)(A.A,{size:"small",label:function(e){switch(e.type){case"schedule":{var t;let a,l=(t=e.cron,(a=/^\*\/(\d+) \* \* \* \* \*$/.exec(t))?"Every ".concat(a[1],"s"):(a=/^\*\/(\d+) \* \* \* \*$/.exec(t))?"Every ".concat(a[1]," min"):(a=/^0 \*\/(\d+) \* \* \*$/.exec(t))?1===Number(a[1])?"Every hour":"Every ".concat(a[1]," hours"):(a=/^(\d+) (\d+) \* \* \*$/.exec(t))?"Daily at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):(a=/^(\d+) (\d+) \* \* 1-5$/.exec(t))?"Weekdays at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):null);return null!=l?l:"Schedule: ".concat(e.cron)}case"webhook":return"Webhook";case"file-watch":return"Watching ".concat(e.path);case"mcp-poll":return"Watching ".concat(e.serverName," › ").concat(e.toolName);case"url-watch":try{return"Watching ".concat(new URL(e.url).hostname)}catch(e){return"Watching a URL"}default:return"Trigger"}}(w.trigger)}),!w.enabled&&(0,l.jsx)(A.A,{size:"small",label:"Off",variant:"outlined"})]}),v.running?(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(k.default,{size:12,thickness:6}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Running…",v.runningSince?" — started ".concat(R(v.runningSince)):""]})]}):(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[v.nextRun&&w.enabled?"Next run: ".concat(R(v.nextRun)):w.enabled&&!v.armed?"Not armed":"",v.lastTriggerError?" — trigger error: ".concat(v.lastTriggerError):""]}),z&&(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(m.A,{title:z.status,children:(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(z.status),flexShrink:0}})}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Last run ",R(z.firedAt),"error"===z.status&&z.error?" — ".concat(z.error):""]})]})]}),(0,l.jsx)(m.A,{title:"Run now",children:(0,l.jsx)("span",{children:(0,l.jsx)(g.A,{onClick:K,disabled:q,color:"primary",children:q?(0,l.jsx)(k.default,{size:20}):(0,l.jsx)(S.A,{})})})}),(0,l.jsx)(m.A,{title:w.enabled?"Turn off":"Turn on",children:(0,l.jsx)(i.A,{checked:w.enabled,onChange:e=>f(e.target.checked)})}),(0,l.jsx)(m.A,{title:"Edit",children:(0,l.jsx)(g.A,{onClick:s,children:(0,l.jsx)(N.A,{})})}),(0,l.jsx)(m.A,{title:"Delete",children:(0,l.jsx)(g.A,{onClick:p,children:(0,l.jsx)(T.A,{})})}),(0,l.jsx)(m.A,{title:M?"Hide run history":"Show run history",children:(0,l.jsx)(g.A,{onClick:()=>U(e=>!e),children:M?(0,l.jsx)(I.A,{}):(0,l.jsx)(E.A,{})})})]}),(0,l.jsx)(C.A,{in:M,timeout:"auto",unmountOnExit:!0,children:(0,l.jsxs)(n.default,{sx:{mt:2,borderTop:1,borderColor:"divider",pt:1.5},children:[H&&!D&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Loading runs…"}),D&&0===D.length&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No runs yet. Use the play button to try it now."}),null==D?void 0:D.map(e=>{var t;return(0,l.jsxs)(n.default,{sx:{display:"flex",gap:1,py:.75,alignItems:"flex-start","&:hover .run-detail-button":{opacity:1}},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(e.status),mt:"5px",flexShrink:0}}),(0,l.jsxs)(n.default,{sx:{minWidth:0,flexGrow:1},children:[(0,l.jsxs)(o.default,{variant:"body2",children:[R(e.firedAt),O(e)?" \xb7 ".concat(O(e)):""," \xb7 ",e.triggerSummary,(null==(t=e.usage)?void 0:t.totalTokens)?" \xb7 ".concat(e.usage.totalTokens.toLocaleString()," tokens"):""]}),e.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",children:e.error}),e.outputText&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.outputText})]}),(0,l.jsx)(m.A,{title:"Show full output",children:(0,l.jsx)(g.A,{className:"run-detail-button",size:"small",onClick:()=>G(e),sx:{opacity:{xs:1,md:.35},transition:"opacity 120ms",flexShrink:0},children:(0,l.jsx)(F.A,{fontSize:"inherit"})})})]},e.runId)})]})}),(0,l.jsxs)(c.A,{open:null!==B,onClose:()=>G(null),maxWidth:"md",fullWidth:!0,children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:B?P(B.status):"transparent",flexShrink:0}}),(0,l.jsxs)(o.default,{variant:"h6",children:[w.name," — ",B?R(B.firedAt):""]})]})}),(0,l.jsx)(h.A,{dividers:!0,children:B&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:[B.status,O(B)?" \xb7 ".concat(O(B)):""," \xb7 ",B.triggerSummary,(null==(t=B.usage)?void 0:t.totalTokens)?" \xb7 ".concat(B.usage.totalTokens.toLocaleString()," tokens (").concat(B.usage.promptTokens.toLocaleString()," in / ").concat(B.usage.completionTokens.toLocaleString()," out)"):""]}),B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",sx:{mb:1.5,whiteSpace:"pre-wrap"},children:B.error}),B.outputText?(0,l.jsx)(n.default,{sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",bgcolor:"action.hover",borderRadius:1,p:2,fontSize:14,maxHeight:"55vh",overflow:"auto"},children:B.outputText}):!B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This run produced no output text."})]})}),(0,l.jsx)(x.A,{children:(0,l.jsx)(d.A,{onClick:()=>G(null),children:"Close"})})]})]})};var M=a(21067),U=a(9562),D=a(52641),L=a(51221),H=a(55606),J=a(86973),q=a(22003),$=a(77073),B=a(26922),G=a(40520),_=a(79299),K=a(22590),Q=a(53657),X=a(90057),Y=a(36741);let V=e=>{let{selected:t,icon:a,title:r,description:s,onClick:i}=e;return(0,l.jsxs)(n.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:i,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},sx:{flex:1,minWidth:200,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,l.jsx)(Y.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[a,(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:r})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:s})]})};var Z=a(22822),ee=a(98267),et=a(20537),ea=a(37960);let el=e=>String(e).padStart(2,"0"),en=e=>{let{cron:t,timezone:a,onChange:i,verb:d="Runs",catchUp:c,onCatchUpChange:u}=e,h=(0,r.useMemo)(()=>(function(e){let t=/^\*\/(\d+) \* \* \* \* \*$/.exec(e);return t?{mode:"seconds",n:Number(t[1]),time:"09:00"}:(t=/^\*\/(\d+) \* \* \* \*$/.exec(e))?{mode:"minutes",n:Number(t[1]),time:"09:00"}:(t=/^0 \*\/(\d+) \* \* \*$/.exec(e))?{mode:"hours",n:Number(t[1]),time:"09:00"}:(t=/^(\d+) (\d+) \* \* \*$/.exec(e))?{mode:"daily",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:(t=/^(\d+) (\d+) \* \* 1-5$/.exec(e))?{mode:"weekdays",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:{mode:"custom",n:15,time:"09:00"}})(t),[]),[x,p]=(0,r.useState)(h.mode),[f,m]=(0,r.useState)(h.n),[g,y]=(0,r.useState)(h.time),[w,v]=(0,r.useState)(t),[b,A]=(0,r.useState)(null),k=function(e,t,a,l){let[n,r]=a.split(":").map(Number);switch(e){case"seconds":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * * *");case"minutes":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * *");case"hours":return"0 */".concat(Math.max(1,Math.min(23,Math.floor(t)||1))," * * *");case"daily":return"".concat(r||0," ").concat(n||0," * * *");case"weekdays":return"".concat(r||0," ").concat(n||0," * * 1-5");default:return l}}(x,f,g,w);return(0,r.useEffect)(()=>{k!==t&&i({cron:k,timezone:a})},[k]),(0,r.useEffect)(()=>{let e=!1,t=setTimeout(()=>{j.previewSchedule(k,a).then(t=>{e||A(t)})},300);return()=>{e=!0,clearTimeout(t)}},[k,a]),(0,l.jsxs)(n.default,{children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1},children:[(0,l.jsxs)(D.A,{sx:{minWidth:180},children:[(0,l.jsx)(L.A,{id:"schedule-preset-label",children:d}),(0,l.jsxs)(H.A,{labelId:"schedule-preset-label",label:d,value:x,onChange:e=>p(e.target.value),children:[(0,l.jsx)(J.A,{value:"seconds",children:"Every N seconds"}),(0,l.jsx)(J.A,{value:"minutes",children:"Every N minutes"}),(0,l.jsx)(J.A,{value:"hours",children:"Every N hours"}),(0,l.jsx)(J.A,{value:"daily",children:"Daily at a time"}),(0,l.jsx)(J.A,{value:"weekdays",children:"Weekdays at a time"}),(0,l.jsx)(J.A,{value:"custom",children:"Custom (cron)"})]})]}),("seconds"===x||"minutes"===x||"hours"===x)&&(0,l.jsx)(U.A,{label:"seconds"===x?"Seconds":"minutes"===x?"Minutes":"Hours",type:"number",value:f,onChange:e=>m(Number(e.target.value)),inputProps:{min:1,max:"hours"===x?23:59},sx:{width:120}}),("daily"===x||"weekdays"===x)&&(0,l.jsx)(U.A,{label:"Time",type:"time",value:g,onChange:e=>y(e.target.value),sx:{width:150},InputLabelProps:{shrink:!0}}),"custom"===x&&(0,l.jsx)(U.A,{label:"Cron pattern",value:w,onChange:e=>v(e.target.value),sx:{minWidth:220},placeholder:"*/15 * * * *"})]}),b&&!b.valid&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:b.error||"This schedule is not valid."}),b&&b.valid&&b.nextRuns.length>0&&(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:2},children:["Next: ",b.nextRuns.map(e=>new Date(e).toLocaleString()).join(" \xb7 ")]}),u&&(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===c,onChange:e=>u(e.target.checked)}),label:"If FLUJO was closed at a scheduled time, run once on startup"}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(U.A,{label:"Timezone (optional)",value:a||"",onChange:e=>i({cron:k,timezone:e.target.value||void 0}),placeholder:"e.g. Europe/Berlin",helperText:"IANA timezone name. Empty = this computer's timezone.",sx:{minWidth:260}}),(0,l.jsx)(U.A,{label:"Generated cron pattern",value:k,InputProps:{readOnly:"custom"!==x},onChange:e=>{p("custom"),v(e.target.value)},helperText:"Editing switches to Custom mode.",sx:{minWidth:220}})]})})]})]})};var er=a(52277),eo=a(9693);let es=e=>{let{config:t,onChange:a,executionId:i,saved:c}=e,[u,h]=(0,r.useState)(null),x=window.location.origin,p="".concat(x,"/api/webhooks/").concat(i),f=async(e,t)=>{try{await navigator.clipboard.writeText(t),h(e),setTimeout(()=>h(null),1500)}catch(e){}};return(0,l.jsxs)(n.default,{sx:{mt:1},children:[!c&&(0,l.jsx)(q.A,{severity:"info",sx:{mb:2},children:"This URL and token are ready to copy now — they become active when you save."}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Webhook URL",value:p,InputProps:{readOnly:!0},size:"small"}),(0,l.jsx)(m.A,{title:"Copy URL",children:(0,l.jsx)(g.A,{onClick:()=>f("url",p),children:"url"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})})]}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mt:2},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Secret token",value:t.token,InputProps:{readOnly:!0},size:"small",type:"password"}),(0,l.jsx)(m.A,{title:"Copy token",children:(0,l.jsx)(g.A,{onClick:()=>f("token",t.token),disabled:!t.token,children:"token"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})}),(0,l.jsx)(d.A,{size:"small",onClick:()=>a({...t,token:crypto.randomUUID()}),sx:{whiteSpace:"nowrap"},children:"New token"})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:c?"A new token takes effect when you save — callers using the old one are cut off.":""}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:1.5},children:["Callers send a POST with the token in the ",(0,l.jsx)("code",{children:"X-Flujo-Token"})," ","header (or ",(0,l.jsx)("code",{children:"?token=…"}),"). The request body becomes part of the flow's input — treat it as untrusted data in your prompt."]}),(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===t.allowExternal,onChange:e=>a({...t,allowExternal:e.target.checked})}),label:"Allow calls from other machines (default: this computer only)"}),t.allowExternal&&(0,l.jsx)(q.A,{severity:"warning",children:"FLUJO assumes a single user on this machine. If you expose it beyond localhost (port forwarding, tunnels), securing that access is your responsibility — anyone with the URL and token can run this flow."})]})};var ei=a(56422),ed=a(17325),ec=a(80007),eu=a(62640);let eh=[{value:"add",label:"A file appears"},{value:"change",label:"A file changes"},{value:"unlink",label:"A file is deleted"}],ex=e=>{var t;let{config:a,onChange:i}=e,[d,c]=(0,r.useState)(!1);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Folder (or file) to watch",value:a.path,onChange:e=>i({...a,path:e.target.value}),placeholder:"e.g. C:\\Users\\me\\Documents\\inbox",margin:"normal",InputProps:{endAdornment:(0,l.jsx)(ei.A,{position:"end",children:(0,l.jsx)(m.A,{title:"Browse folders (on the FLUJO machine)",children:(0,l.jsx)(g.A,{edge:"end",onClick:()=>c(!0),children:(0,l.jsx)(ec.A,{})})})})}}),(0,l.jsx)(eu.A,{open:d,title:"Choose what to watch",selectFiles:!0,initialPath:a.path||void 0,onClose:()=>c(!1),onSelect:e=>i({...a,path:e})}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Only files matching (optional)",value:a.glob||"",onChange:e=>i({...a,glob:e.target.value||void 0}),placeholder:"e.g. *.pdf or reports/**/*.csv",helperText:"Simple patterns: * matches within a folder, ** across folders, ? one character.",margin:"normal"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"Run when…"}),(0,l.jsx)(ed.A,{row:!0,children:eh.map(e=>(0,l.jsx)(s.A,{control:(0,l.jsx)(Z.A,{checked:a.events.includes(e.value),onChange:t=>((e,t)=>{let l=t?[...a.events,e]:a.events.filter(t=>t!==e);i({...a,events:l})})(e.value,t.target.checked)}),label:e.label},e.value))}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"Bursts are batched: many files changing at once produce one run with all changes listed. If this flow writes into the watched folder, it will trigger itself in a loop — point its output somewhere else."}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsx)(U.A,{label:"Quiet window (ms)",type:"number",value:null!=(t=a.debounceMs)?t:2e3,onChange:e=>i({...a,debounceMs:Math.max(0,Number(e.target.value)||0)}),helperText:"How long to wait after the last change before running.",inputProps:{min:0,step:500},sx:{width:220}})})]})]})};var ep=a(41356),ef=a(24610),em=a(17897),eg=a(43076),ey=a(17427);let ew=(0,y.h)("frontend/components/PlannedExecutions/WatchToolPanel"),ev=e=>{var t,a;let{config:s,onChange:i}=e,[c,u]=(0,r.useState)([]),[h,x]=(0,r.useState)([]),[p,f]=(0,r.useState)(!1),[m,g]=(0,r.useState)(Object.keys(s.args||{}).length>0?JSON.stringify(s.args,null,2):""),[y,w]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,S]=(0,r.useState)(null),[N,T]=(0,r.useState)([]),[E,I]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return em.S.loadServerConfigs().then(t=>{e||(Array.isArray(t)?u(t.filter(e=>!e.disabled).map(e=>e.name)):(ew.warn("Failed to load MCP servers for watch-tool panel",t),u([])))}),()=>{e=!0}},[]),(0,r.useEffect)(()=>{if(!s.serverName)return void x([]);let e=!1;return f(!0),em.S.listServerTools(s.serverName).then(t=>{let{tools:a}=t;e||x(a||[])}).finally(()=>{e||f(!1)}),()=>{e=!0}},[s.serverName]),(0,r.useEffect)(()=>{let e=!1;return eg.N.loadModels().then(t=>{e||T(Array.isArray(t)?t:[])}).catch(()=>{e||T([])}),X.g.loadFlows().then(t=>{e||I(t||[])}).catch(()=>{e||I([])}),()=>{e=!0}},[]);let F=async()=>{j(!0),A(null),S(null);try{let a=await em.S.callTool(s.serverName,s.toolName,s.args||{});if(null==a?void 0:a.error)S("string"==typeof a.error?a.error:"Tool call failed");else{var e,t;let l=null!=(e=null==a?void 0:a.data)?e:a,n=null!=(t=JSON.stringify(l,null,2))?t:"";A(n.length>6e3?"".concat(n.slice(0,6e3),"\n… (truncated)"):n)}}catch(e){S(e instanceof Error?e.message:"Tool call failed")}finally{j(!1)}},W=s.evaluate,P=h.find(e=>e.name===s.toolName);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",children:[(0,l.jsx)(L.A,{id:"watch-server-label",children:"Server"}),(0,l.jsxs)(H.A,{labelId:"watch-server-label",label:"Server",value:c.includes(s.serverName)?s.serverName:"",onChange:e=>i({...s,serverName:e.target.value,toolName:""}),children:[0===c.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No MCP servers configured"}),c.map(e=>(0,l.jsx)(J.A,{value:e,children:e},e))]})]}),(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",disabled:!s.serverName,children:[(0,l.jsx)(L.A,{id:"watch-tool-label",children:"Tool"}),(0,l.jsxs)(H.A,{labelId:"watch-tool-label",label:"Tool",value:h.some(e=>e.name===s.toolName)?s.toolName:"",onChange:e=>i({...s,toolName:e.target.value,args:{}}),children:[0===h.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:p?"Loading tools…":"Pick a server first"}),h.map(e=>(0,l.jsx)(J.A,{value:e.name,children:e.name},e.name))]})]})]}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:null!=(t=s.cron)?t:function(e){let t=Math.max(5,Math.round((null!=e?e:6e4)/1e3));if(t<60)return"*/".concat(t," * * * * *");let a=Math.max(1,Math.round(t/60));if(a<60)return"*/".concat(a," * * * *");let l=Math.max(1,Math.min(23,Math.round(a/60)));return"0 */".concat(l," * * *")}(s.intervalMs),timezone:s.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return i({...s,cron:t,timezone:a})}}),P?(0,l.jsxs)(n.default,{sx:{my:1.5},children:[(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mb:1.5},children:"Tool parameters — sent on every check"}),(0,l.jsx)(ey.A,{schema:P.inputSchema,values:s.args||{},onChange:e=>i({...s,args:e})})]}):(0,l.jsx)(U.A,{fullWidth:!0,label:"Tool arguments (JSON, optional)",value:m,onChange:e=>(e=>{if(g(e),!e.trim()){w(null),i({...s,args:{}});return}try{let t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))return void w('Arguments must be a JSON object, e.g. { "query": "…" }');w(null),i({...s,args:t})}catch(e){w("Not valid JSON yet")}})(e.target.value),margin:"normal",multiline:!0,minRows:2,placeholder:'{ "query": "is:unread" }',error:!!y,helperText:null!=y?y:"Sent to the tool on every check.",slotProps:{input:{sx:{fontFamily:"monospace",fontSize:14}}}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[(0,l.jsx)(d.A,{variant:"outlined",size:"small",onClick:F,disabled:!s.serverName||!s.toolName||v||!!y,startIcon:v?(0,l.jsx)(k.default,{size:16}):void 0,children:"Test: call the tool now"}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"See what the result looks like — useful for the settings below."})]}),C&&(0,l.jsx)(q.A,{severity:"error",sx:{mb:1},children:C}),b&&(0,l.jsx)(n.default,{component:"pre",sx:{maxHeight:240,overflow:"auto",bgcolor:"action.hover",borderRadius:1,p:1.5,fontSize:12,m:0,mb:1},children:b}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:2,mb:1},children:"Run the flow when…"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Poll condition",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"on-change"===W.mode,onClick:()=>i({...s,evaluate:{mode:"on-change"}}),icon:(0,l.jsx)(ep.A,{}),title:"The result changes",description:"Any difference from the last check runs the flow. Simplest — no setup."}),(0,l.jsx)(V,{selected:"llm-gate"===W.mode||"flow-gate"===W.mode,onClick:()=>{"llm-gate"!==W.mode&&"flow-gate"!==W.mode&&i({...s,evaluate:{mode:"llm-gate",condition:"",modelId:""}})},icon:(0,l.jsx)(ef.A,{}),title:"AI decides",description:"Describe the condition in plain language; a model — or one of your flows — checks the result whenever it changes."})]}),("llm-gate"===W.mode||"flow-gate"===W.mode)&&(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Run the flow if…",value:W.condition,onChange:e=>i({...s,evaluate:{...W,condition:e.target.value}}),multiline:!0,minRows:2,margin:"normal",placeholder:"e.g. any email mentions an invoice or a payment reminder"}),(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-start"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:170},children:[(0,l.jsx)(L.A,{id:"gate-checker-label",children:"Checked by"}),(0,l.jsxs)(H.A,{labelId:"gate-checker-label",label:"Checked by",value:W.mode,onChange:e=>{let t=e.target.value;if(t===W.mode)return;let a={condition:W.condition,maxCallsPerDay:W.maxCallsPerDay};i({...s,evaluate:"llm-gate"===t?{mode:t,...a,modelId:""}:{mode:t,...a,flowId:""}})},children:[(0,l.jsx)(J.A,{value:"llm-gate",children:"A model"}),(0,l.jsx)(J.A,{value:"flow-gate",children:"One of my flows"})]})]}),"llm-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-model-label",children:"Model that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-model-label",label:"Model that checks",value:N.some(e=>e.id===W.modelId)?W.modelId:"",onChange:e=>i({...s,evaluate:{...W,modelId:e.target.value}}),children:[0===N.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No models configured"}),N.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),"flow-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-flow-label",children:"Flow that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-flow-label",label:"Flow that checks",value:E.some(e=>e.id===W.flowId)?W.flowId:"",onChange:e=>i({...s,evaluate:{...W,flowId:e.target.value}}),children:[0===E.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No flows available"}),E.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),(0,l.jsx)(U.A,{label:"Max checks per day",type:"number",value:null!=(a=W.maxCallsPerDay)?a:500,onChange:e=>i({...s,evaluate:{...W,maxCallsPerDay:Math.max(1,Number(e.target.value)||1)}}),inputProps:{min:1},helperText:"Cost guard per check.",sx:{width:180}})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5},children:"flow-gate"===W.mode?'The checker flow runs invisibly (never in the chat), gets the condition + tool result, and must answer with {"fire": true/false, "reason": "…"} — it can use its own tools to verify before deciding.':"The model is only asked when the result actually changed since the last check — an idle feed costs nothing. Pick a small, cheap model."})]}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:2},children:"The first check only takes a snapshot — the flow runs from the second check onwards, when something actually changed. FLUJO must be running for checks to happen."})]})},ej=e=>{let{config:t,onChange:a}=e;return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"URL to watch",value:t.url,onChange:e=>a({...t,url:e.target.value}),placeholder:"https://example.com/status or an API/feed URL",margin:"normal",type:"url"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:t.cron,timezone:t.timezone,onChange:e=>{let{cron:l,timezone:n}=e;return a({...t,cron:l,timezone:n})}}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"The first check only takes a snapshot; the flow runs when a later check finds different content, and the fetched content is handed to the flow. Pages that embed ever-changing bits (timestamps, session tokens) look “changed” on every check — plain APIs, feeds, and raw files work best."})]})},eb=(0,y.h)("frontend/components/PlannedExecutions/ExecutionModal"),eA={type:"schedule",cron:"0 9 * * *"},ek={type:"file-watch",path:"",events:["add","change"]},eC={type:"mcp-poll",serverName:"",toolName:"",args:{},cron:"*/5 * * * *",evaluate:{mode:"on-change"}},eS={type:"url-watch",url:"",cron:"*/15 * * * *"},eN=e=>{var t;let{open:a,execution:p,onClose:f,onSaved:m}=e,[y,w]=(0,r.useState)(""),[v,b]=(0,r.useState)(""),[A,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!1),[N,T]=(0,r.useState)(eA),[E,I]=(0,r.useState)(""),[F,W]=(0,r.useState)([]),[P,R]=(0,r.useState)(!1),[O,z]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e,t,l,n;a&&(Z(null),w(null!=(e=null==p?void 0:p.name)?e:""),b(null!=(t=null==p?void 0:p.flowId)?t:""),k(null!=(l=null==p?void 0:p.prompt)?l:""),S((null==p?void 0:p.saveConversations)===!0),T(null!=(n=null==p?void 0:p.trigger)?n:eA),I(p?"":crypto.randomUUID()))},[a,p]),(0,r.useEffect)(()=>{if(!a)return;let e=!1;return R(!0),X.g.loadFlows().then(t=>{e||W(t||[])}).catch(t=>{eb.warn("Failed to load flows for execution picker",t),e||W([])}).finally(()=>{e||R(!1)}),()=>{e=!0}},[a]);let ee=!!v&&!P&&F.length>0&&!F.some(e=>e.id===v),et=async()=>{var e;z(!0),Z(null);let t={name:y,flowId:v,prompt:A,saveConversations:C,trigger:N,enabled:null==(e=null==p?void 0:p.enabled)||e,...p?{}:{id:E}},a=p?await j.update(p.id,t):await j.create(t);if(z(!1),!a.success)return void Z(a.error||"Failed to save");m(),f()};return(0,l.jsxs)(c.A,{open:a,onClose:f,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,l.jsx)(o.default,{variant:"h6",children:p?"Edit planned execution":"New planned execution"}),(0,l.jsx)(g.A,{edge:"end",color:"inherit",onClick:f,"aria-label":"close",children:(0,l.jsx)($.A,{})})]})}),(0,l.jsx)(M.A,{}),(0,l.jsxs)(h.A,{sx:{p:3},children:[(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"A planned execution runs one of your flows automatically — on a schedule or when something happens — without anyone sitting in the chat. Results show up in its run history on the Executions page."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Name",value:y,onChange:e=>w(e.target.value),margin:"normal",placeholder:"e.g. Morning news digest"}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:3,mb:1,fontWeight:600},children:"1 \xb7 When should it run?"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Trigger type",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"schedule"===N.type,onClick:()=>{"schedule"!==N.type&&T((null==p?void 0:p.trigger.type)==="schedule"?p.trigger:eA)},icon:(0,l.jsx)(B.A,{}),title:"On a schedule",description:"Run at fixed times — every few minutes, daily, on weekdays, or a custom rhythm."}),(0,l.jsx)(V,{selected:"webhook"===N.type,onClick:()=>{"webhook"!==N.type&&T((null==p?void 0:p.trigger.type)==="webhook"?p.trigger:{type:"webhook",token:crypto.randomUUID()})},icon:(0,l.jsx)(G.A,{}),title:"When called (webhook)",description:"Other apps run this flow by calling a URL — GitHub, Stripe, Slack and most services can send webhooks."}),(0,l.jsx)(V,{selected:"file-watch"===N.type,onClick:()=>{"file-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="file-watch"?p.trigger:ek)},icon:(0,l.jsx)(_.A,{}),title:"When files change",description:"Watch a folder on this computer and run when files appear, change, or disappear."}),(0,l.jsx)(V,{selected:"mcp-poll"===N.type,onClick:()=>{"mcp-poll"!==N.type&&T((null==p?void 0:p.trigger.type)==="mcp-poll"?p.trigger:eC)},icon:(0,l.jsx)(K.A,{}),title:"Watch a tool",description:"Check one of your MCP tools regularly — run when its result changes, or let AI decide."}),(0,l.jsx)(V,{selected:"url-watch"===N.type,onClick:()=>{"url-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="url-watch"?p.trigger:eS)},icon:(0,l.jsx)(Q.A,{}),title:"When a website changes",description:"Check a URL regularly and run when its content is different from the last check."})]}),"schedule"===N.type&&(0,l.jsx)(en,{cron:N.cron,timezone:N.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return T({...N,cron:t,timezone:a})},catchUp:!0===N.catchUp,onCatchUpChange:e=>T({...N,catchUp:e})}),"webhook"===N.type&&(0,l.jsx)(es,{config:N,onChange:T,executionId:null!=(t=null==p?void 0:p.id)?t:E,saved:null!==p}),"file-watch"===N.type&&(0,l.jsx)(ex,{config:N,onChange:T}),"mcp-poll"===N.type&&(0,l.jsx)(ev,{config:N,onChange:T}),"url-watch"===N.type&&(0,l.jsx)(ej,{config:N,onChange:T}),(0,l.jsx)(M.A,{sx:{mt:3}}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:2,mb:0,fontWeight:600},children:"2 \xb7 What should it run?"}),(0,l.jsxs)(D.A,{fullWidth:!0,margin:"normal",children:[(0,l.jsx)(L.A,{id:"execution-flow-label",children:"Flow to run"}),(0,l.jsxs)(H.A,{labelId:"execution-flow-label",label:"Flow to run",value:ee?"":v,onChange:e=>b(e.target.value),displayEmpty:!0,children:[0===F.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:P?"Loading flows…":"No flows available"}),F.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),ee&&(0,l.jsx)(q.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"What should the flow do?",value:A,onChange:e=>k(e.target.value),margin:"normal",multiline:!0,rows:3,helperText:"Sent to the flow as the user message each time this runs. Run details are attached automatically: current time, what triggered it, the previous run, the next planned run, and any trigger data."}),(0,l.jsx)(s.A,{sx:{mt:1},control:(0,l.jsx)(i.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Save full conversations (each run appears in the chat sidebar — useful for debugging)"}),Y&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:Y})]}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:f,children:"Cancel"}),(0,l.jsx)(d.A,{onClick:et,variant:"contained",color:"primary",disabled:O||!y.trim()||!v,children:O?"Saving…":"Save"})]})]})},eT=(0,y.h)("frontend/components/PlannedExecutions"),eE=()=>{let[e,t]=(0,r.useState)([]),[a,y]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),[b,A]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,N]=(0,r.useState)(null),T=(0,r.useCallback)(async()=>{let e=await j.list();t(e.executions),y(e.paused),v(!0)},[]);(0,r.useEffect)(()=>{T()},[T]);let E=e.some(e=>e.status.running);(0,r.useEffect)(()=>{let e=setInterval(()=>{document.hidden||T()},E?3e3:1e4);return()=>clearInterval(e)},[T,E]);let I=async e=>{y(e);let t=await j.setPaused(e);t.success||eT.warn("Failed to toggle pause",t.error),T()},F=async(e,t)=>{await j.update(e.id,{enabled:t}),T()},W=async()=>{S&&(await j.delete(S.id),N(null),T())};return(0,l.jsxs)(n.default,{sx:{p:3,maxWidth:1100,mx:"auto",width:"100%"},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:2,mb:1},children:[(0,l.jsx)(o.default,{variant:"h5",children:"Planned Executions"}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,l.jsx)(m.A,{title:"Refresh",children:(0,l.jsx)(g.A,{onClick:()=>void T(),children:(0,l.jsx)(f.A,{})})}),(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{checked:!a,onChange:e=>I(!e.target.checked)}),label:a?"Paused":"Active"}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},"data-tour":"add-execution",children:"Add"})]})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Run your flows automatically — on a schedule or when something happens — without opening the chat. FLUJO must be running for triggers to fire."}),w&&0===e.length&&(0,l.jsxs)(n.default,{sx:{border:1,borderColor:"divider",borderRadius:2,borderStyle:"dashed",p:6,textAlign:"center"},children:[(0,l.jsx)(o.default,{variant:"h6",sx:{mb:1},children:"Nothing planned yet"}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Create your first planned execution to run a flow on a schedule."}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},children:"New planned execution"})]}),(0,l.jsx)(n.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(e=>(0,l.jsx)(z,{entry:e,onEdit:()=>{C(e.execution),A(!0)},onDelete:()=>N(e.execution),onToggleEnabled:t=>F(e.execution,t),onRanNow:()=>void T()},e.execution.id))}),(0,l.jsx)(eN,{open:b,execution:k,onClose:()=>A(!1),onSaved:()=>void T()}),(0,l.jsxs)(c.A,{open:null!==S,onClose:()=>N(null),children:[(0,l.jsxs)(u.A,{children:["Delete “",null==S?void 0:S.name,"”?"]}),(0,l.jsx)(h.A,{children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This removes the planned execution and its run history. The flow itself is not affected."})}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:()=>N(null),children:"Cancel"}),(0,l.jsx)(d.A,{color:"error",variant:"contained",onClick:W,children:"Delete"})]})]})]})},eI=(0,y.h)("app/executions/page");function eF(){return eI.debug("Rendering ExecutionsPage"),(0,l.jsx)(n.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,l.jsx)(eE,{})})}}},e=>{e.O(0,[2678,4754,9244,8548,690,9562,2003,488,3272,5648,7396,7329,7458,1811,2380,8441,1255,7358],()=>e(e.s=60187)),_N_E=e.O()}]);
|