flujo-ai 3.23.0 → 3.26.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 +205 -186
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +7 -7
- package/.next/react-loadable-manifest.json +25 -20
- package/.next/routes-manifest.json +19 -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 +3 -3
- package/.next/server/app/api/approvals/[id]/route.js +1 -1
- package/.next/server/app/api/approvals/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/approvals/route.js +1 -1
- package/.next/server/app/api/approvals/route.js.nft.json +1 -1
- package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/backup/route.js +1 -1
- package/.next/server/app/api/backup/route.js.nft.json +1 -1
- package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/browse/route.js +1 -1
- package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/bugs/enhance/route.js +2 -2
- package/.next/server/app/api/bugs/enhance/route.js.nft.json +1 -1
- package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/route.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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/compile/route.js +1 -1
- package/.next/server/app/api/flow/compile/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generate/route.js +1 -1
- package/.next/server/app/api/flow/generate/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/improve/route.js +1 -1
- package/.next/server/app/api/flow/improve/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route.js +1 -1
- 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/quick-chat/route.js +1 -1
- package/.next/server/app/api/flow/quick-chat/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/repair/route.js +1 -1
- package/.next/server/app/api/flow/repair/route.js.nft.json +1 -1
- package/.next/server/app/api/flow/repair/route_client-reference-manifest.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 +1 -1
- 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/local-models/capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/cancel/route.js +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 -1
- package/.next/server/app/api/mcp/test-connection/stream/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/route.js +1 -1
- package/.next/server/app/api/mcp-registry/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/[id]/route.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/reset/route.js +1 -1
- package/.next/server/app/api/oauth/reset/route.js.nft.json +1 -1
- package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/reconcile/route.js +1 -1
- package/.next/server/app/api/planned-executions/reconcile/route.js.nft.json +1 -1
- package/.next/server/app/api/planned-executions/reconcile/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 -1
- package/.next/server/app/api/restore/route.js.nft.json +1 -1
- package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/runs/active/route.js +1 -1
- package/.next/server/app/api/runs/active/route.js.nft.json +1 -1
- package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/waves/route.js +1 -1
- package/.next/server/app/api/waves/route.js.nft.json +1 -1
- package/.next/server/app/api/waves/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 +10 -10
- 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 +4 -4
- package/.next/server/app/docs/page.js +11 -8
- package/.next/server/app/docs/page.js.nft.json +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +4 -4
- package/.next/server/app/executions/page.js +3 -3
- 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 +4 -4
- package/.next/server/app/flows/page.js +3 -3
- 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 +4 -4
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +4 -4
- package/.next/server/app/mcp/page.js +5 -5
- 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 +4 -4
- package/.next/server/app/models/page.js +2 -2
- 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 +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +2 -57
- package/.next/server/app/settings/page.js.nft.json +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 +4 -4
- package/.next/server/app/v1/chat/completions/route.js +1 -1
- package/.next/server/app/v1/chat/completions/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js +2 -2
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js +2 -2
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route.js.nft.json +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route.js +2 -2
- 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 +1 -1
- 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]/resources/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/waves/page.js +3 -3
- package/.next/server/app/waves/page.js.nft.json +1 -1
- package/.next/server/app/waves/page_client-reference-manifest.js +1 -1
- package/.next/server/app/waves.html +1 -1
- package/.next/server/app/waves.rsc +4 -4
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/1083.js +1 -1
- package/.next/server/chunks/1114.js +1 -0
- package/.next/server/chunks/1197.js +2 -2
- package/.next/server/chunks/1226.js +1 -1
- package/.next/server/chunks/166.js +5 -0
- package/.next/server/chunks/2373.js +1 -0
- package/.next/server/chunks/2859.js +1 -3
- package/.next/server/chunks/289.js +1 -1
- package/.next/server/chunks/3030.js +1 -1
- package/.next/server/chunks/3298.js +2 -0
- package/.next/server/chunks/3312.js +1 -0
- package/.next/server/chunks/3774.js +1 -1
- package/.next/server/chunks/3823.js +9 -8
- package/.next/server/chunks/3855.js +1 -0
- package/.next/server/chunks/3924.js +52 -0
- package/.next/server/chunks/4545.js +21 -0
- package/.next/server/chunks/4561.js +9 -8
- package/.next/server/chunks/4578.js +1 -0
- package/.next/server/chunks/4671.js +1 -1
- package/.next/server/chunks/4677.js +37 -0
- package/.next/server/chunks/4771.js +2 -2
- package/.next/server/chunks/4793.js +2 -0
- package/.next/server/chunks/4836.js +1 -0
- package/.next/server/chunks/5311.js +1 -1
- package/.next/server/chunks/5463.js +1 -0
- package/.next/server/chunks/5544.js +5 -0
- package/.next/server/chunks/5708.js +11 -8
- package/.next/server/chunks/584.js +1 -0
- package/.next/server/chunks/62.js +1 -1
- package/.next/server/chunks/6240.js +1 -0
- package/.next/server/chunks/6306.js +1 -0
- package/.next/server/chunks/{3928.js → 6745.js} +1 -1
- package/.next/server/chunks/6908.js +2 -2
- package/.next/server/chunks/701.js +1 -1
- package/.next/server/chunks/7214.js +6 -0
- package/.next/server/chunks/7362.js +11 -7
- package/.next/server/chunks/7463.js +6 -0
- package/.next/server/chunks/7506.js +1 -1
- package/.next/server/chunks/7579.js +82 -0
- package/.next/server/chunks/7821.js +1 -1
- package/.next/server/chunks/8216.js +1 -0
- package/.next/server/chunks/8387.js +1 -0
- package/.next/server/chunks/856.js +5 -0
- package/.next/server/chunks/8652.js +1 -1
- package/.next/server/chunks/8739.js +2 -2
- package/.next/server/chunks/9165.js +1 -0
- package/.next/server/chunks/94.js +1 -0
- package/.next/server/chunks/9427.js +1 -0
- package/.next/server/edge-instrumentation.js +2 -0
- package/.next/server/edge-instrumentation.js.map +1 -0
- package/.next/server/edge-runtime-webpack.js +2 -0
- package/.next/server/edge-runtime-webpack.js.map +1 -0
- package/.next/server/instrumentation.js.nft.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-manifest.json +33 -2
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/server/src/middleware.js +14 -0
- package/.next/server/src/middleware.js.map +1 -0
- package/.next/static/chunks/1675-773454288de4309d.js +1 -0
- package/.next/static/chunks/1731-6e45fb529f9044a3.js +1 -0
- package/.next/static/chunks/1871-14c3e63ca865d85e.js +1 -0
- package/.next/static/chunks/2003-7710c23acaef11c9.js +1 -0
- package/.next/static/chunks/2318-76fcb6c769b1a569.js +1 -0
- package/.next/static/chunks/2566-6e2b9d9349814789.js +1 -0
- package/.next/static/chunks/2734-59fbe2f62a59df86.js +1 -0
- package/.next/static/chunks/3089.6b4e21e1faa304e2.js +1 -0
- package/.next/static/chunks/3109-11bdec9bdfd996c3.js +1 -0
- package/.next/static/chunks/3217.f728df99ab5da33c.js +1 -0
- package/.next/static/chunks/333-5f3c5be57c80c48c.js +1 -0
- package/.next/static/chunks/3333-b7b3e5758a568013.js +1 -0
- package/.next/static/chunks/3556-3b6f7c99b015b752.js +1 -0
- package/.next/static/chunks/{6730-c330b55cd0fe4f47.js → 4003-3b3768446ae333df.js} +1 -1
- package/.next/static/chunks/4523-a540747aa2ed34e8.js +1 -0
- package/.next/static/chunks/4635-0fe310d3be64e71e.js +1 -0
- package/.next/static/chunks/4690-ec7d397cfacedac3.js +1 -0
- package/.next/static/chunks/4775-cb9c0be621363a08.js +8 -0
- package/.next/static/chunks/5336-81da1080de29ebfc.js +1 -0
- package/.next/static/chunks/5512.d01d565f73109a1a.js +1 -0
- package/.next/static/chunks/6691-117567b2b40cd9f4.js +1 -0
- package/.next/static/chunks/7274-1184563607f2b5f5.js +1 -0
- package/.next/static/chunks/8166-e75acdc559b34fcd.js +1 -0
- package/.next/static/chunks/8345.fbc0af16acce7256.js +1 -0
- package/.next/static/chunks/8405.e728bc83a7c9fed6.js +1 -0
- package/.next/static/chunks/8470-72cf748472d4d501.js +1 -0
- package/.next/static/chunks/8607-5787e42775fc3acb.js +1 -0
- package/.next/static/chunks/8610-660d5088bc1dd7a7.js +1 -0
- package/.next/static/chunks/8834-faf121e257b517d5.js +1 -0
- package/.next/static/chunks/8989-401559d9f3bc80a0.js +1 -0
- package/.next/static/chunks/{9164-d9f1abba780231e0.js → 9164-829ab5b085ec06d6.js} +1 -1
- package/.next/static/chunks/9240-d0a51f4d504f34b1.js +1 -0
- package/.next/static/chunks/9562-b7922ceb400ec536.js +1 -0
- package/.next/static/chunks/9704-6b7415964d7c042a.js +1 -0
- package/.next/static/chunks/app/chat/page-04ad1fad78048afb.js +1 -0
- package/.next/static/chunks/app/docs/page-5475c616764dbb18.js +1 -0
- package/.next/static/chunks/app/executions/page-c18708ed96d228ec.js +1 -0
- package/.next/static/chunks/app/flows/page-f7e44aa545bcc56e.js +1 -0
- package/.next/static/chunks/app/layout-e6fbae80e0f456a6.js +1 -0
- package/.next/static/chunks/app/mcp/page-3638fbee04a3a6ea.js +1 -0
- package/.next/static/chunks/app/models/error-5732fbb053e182c5.js +1 -0
- package/.next/static/chunks/app/models/page-e690a986047b1e62.js +1 -0
- package/.next/static/chunks/app/{page-a859e4dbd180df98.js → page-0a95c40a65dbd2eb.js} +1 -1
- package/.next/static/chunks/app/settings/page-3ef9b95187e18a5a.js +1 -0
- package/.next/static/chunks/app/waves/page-c9a307e2236423a4.js +1 -0
- package/.next/static/chunks/{main-be8e823624954fab.js → main-9bda5041078d2b6a.js} +1 -1
- package/.next/static/chunks/webpack-a6844e1074885c2f.js +1 -0
- package/.next/static/css/40f9bef305b11bf5.css +1 -0
- package/.next/trace +10 -8
- package/README.md +31 -1
- package/next.config.mjs +139 -119
- package/package.json +1 -1
- package/.next/server/chunks/1119.js +0 -1
- package/.next/server/chunks/1439.js +0 -1
- package/.next/server/chunks/1556.js +0 -52
- package/.next/server/chunks/1910.js +0 -37
- package/.next/server/chunks/1999.js +0 -1
- package/.next/server/chunks/2246.js +0 -1
- package/.next/server/chunks/264.js +0 -17
- package/.next/server/chunks/2823.js +0 -6
- package/.next/server/chunks/3286.js +0 -6
- package/.next/server/chunks/4637.js +0 -81
- package/.next/server/chunks/6644.js +0 -1
- package/.next/server/chunks/7427.js +0 -1
- package/.next/server/chunks/7769.js +0 -6
- package/.next/server/chunks/8357.js +0 -1
- package/.next/server/chunks/8518.js +0 -2
- package/.next/static/chunks/1620-0d8ecd877f123f7b.js +0 -1
- package/.next/static/chunks/1871-dd8c10ed9d37100b.js +0 -1
- package/.next/static/chunks/1983-242862b3dc022a26.js +0 -1
- package/.next/static/chunks/2003-460f30484998c05d.js +0 -1
- package/.next/static/chunks/2619-04bc32f026a0d946.js +0 -1
- package/.next/static/chunks/3217.058098140ec3f563.js +0 -1
- package/.next/static/chunks/3736-5e2b3f6cda1bb923.js +0 -1
- package/.next/static/chunks/4207-41abb9622eb4b4f8.js +0 -1
- package/.next/static/chunks/4812-4a9aceb49632a973.js +0 -1
- package/.next/static/chunks/5501-f5b093c8dfd74196.js +0 -1
- package/.next/static/chunks/5545-2ab6e5d749e103cd.js +0 -1
- package/.next/static/chunks/6016.8201fa15ab6aa90e.js +0 -1
- package/.next/static/chunks/6288-a285bbbd701e0dbf.js +0 -1
- package/.next/static/chunks/6731-c230e88cf0032609.js +0 -1
- package/.next/static/chunks/6920-a83ad5c0d5a54cf3.js +0 -1
- package/.next/static/chunks/7430-6e78aaeac66988a9.js +0 -1
- package/.next/static/chunks/7583.7af90b94e3c263f2.js +0 -1
- package/.next/static/chunks/7687-7edf1a6e1f063b08.js +0 -1
- package/.next/static/chunks/8083.16fda2c7f6d10d0c.js +0 -1
- package/.next/static/chunks/8480-229fd353b68b570f.js +0 -1
- package/.next/static/chunks/8548-8e4a95334064e8b2.js +0 -1
- package/.next/static/chunks/8834-bda798efab40c60a.js +0 -1
- package/.next/static/chunks/9181-8d8ecd3f641b7209.js +0 -8
- package/.next/static/chunks/9356-99ba407b60b9dfe9.js +0 -1
- package/.next/static/chunks/9451-680fa09f81f18806.js +0 -1
- package/.next/static/chunks/9659-a279e3aaba407251.js +0 -1
- package/.next/static/chunks/app/chat/page-ea6752144d35c892.js +0 -1
- package/.next/static/chunks/app/docs/page-935b0386917b91bb.js +0 -1
- package/.next/static/chunks/app/executions/page-d72027b0179e8fa2.js +0 -1
- package/.next/static/chunks/app/flows/page-1844e86dd43fa285.js +0 -1
- package/.next/static/chunks/app/layout-2ebf01d97702a18a.js +0 -1
- package/.next/static/chunks/app/mcp/page-b6866f49f76a6801.js +0 -1
- package/.next/static/chunks/app/models/error-a3183f168e8a9b04.js +0 -1
- package/.next/static/chunks/app/models/page-5a13ea6ff5ac1b9c.js +0 -1
- package/.next/static/chunks/app/settings/page-7a68583660508ffd.js +0 -1
- package/.next/static/chunks/app/waves/page-ec33cf79f6103a9e.js +0 -1
- package/.next/static/chunks/webpack-f4a471ab560eb19e.js +0 -1
- package/.next/static/css/39393a79f7cb0dee.css +0 -1
- /package/.next/static/{WRUzIBdypUJvv0xAct8qc → Il6IDWxf3CN0dv-P6QQrp}/_buildManifest.js +0 -0
- /package/.next/static/{WRUzIBdypUJvv0xAct8qc → Il6IDWxf3CN0dv-P6QQrp}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{45960:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>tJ});var r=n(95155),o=n(12115),a=n(97322),l=n(94049),i=n(78470),s=n(41983),d=n(22003),c=n(9562),u=n(25635),p=n(28548),f=n(91871),h=n(3339),g=n(67895),m=n(2778),x=n(52363),v=n(65036),b=n(50001),y=n(75912),j=n(22719),w=n(11096),A=n(76530),S=n(36741),I=n(60691),C=n(47419),k=n(78410),E=n(14915),T=n(29692),N=n(21067),R=n(41602),z=n(23820),D=n(17681),P=n(73707),F=n(4484),_=n(86946),M=n(19219);let O=e=>{let{conversations:t,currentConversationId:n,onSelectConversation:o,onDeleteConversation:a,onStopConversation:d,onNewConversation:c,onQuickChat:p,onCollapse:h}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.default,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",gap:1},children:[h&&(0,r.jsx)(i.A,{title:"Hide sidebar",children:(0,r.jsx)(s.A,{size:"small",onClick:h,"aria-label":"Hide conversation sidebar",children:(0,r.jsx)(M.A,{})})}),(0,r.jsx)(u.default,{variant:"h6",sx:{flex:1},noWrap:!0,children:"Conversations"}),p&&(0,r.jsx)(i.A,{title:"Quick Chat: a model + optional MCP servers, no saved flow",children:(0,r.jsx)(f.A,{variant:"outlined",color:"primary",startIcon:(0,r.jsx)(w.A,{}),onClick:p,size:"small",children:"Quick"})}),(0,r.jsx)(f.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(_.A,{}),onClick:c,size:"small",children:"New"})]}),(0,r.jsx)(N.A,{}),(0,r.jsx)(R.A,{sx:{overflow:"auto",flex:1},children:0===t.length?(0,r.jsx)(z.Ay,{children:(0,r.jsx)(D.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=>{let t=!!d&&("running"===e.status||"awaiting_tool_approval"===e.status);return(0,r.jsx)(z.Ay,{disablePadding:!0,secondaryAction:(0,r.jsxs)(r.Fragment,{children:[t&&(0,r.jsx)(i.A,{title:"Stop this run",children:(0,r.jsx)(s.A,{edge:"end","aria-label":"stop run",onClick:t=>{t.stopPropagation(),d(e.id)},children:(0,r.jsx)(C.A,{color:"error"})})}),(0,r.jsx)(s.A,{edge:"end","aria-label":"delete",onClick:t=>{t.stopPropagation(),a(e.id)},children:(0,r.jsx)(F.A,{})})]}),sx:{opacity:e.id===n?1:.7},children:(0,r.jsx)(P.A,{selected:e.id===n,onClick:()=>o(e.id),sx:{pr:t?12:7},children:(0,r.jsx)(D.A,{primary:(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.status&&(0,r.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,r.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,r.jsx)(i.A,{title:e.title,enterDelay:500,children:(0,r.jsx)(u.default,{component:"span",fontWeight:e.id===n?"bold":"normal",sx:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},children:e.title})})]}),secondary:new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})})},e.id)})})]})};var W=n(4474),L=n(50430),B=n(99944),H=n(9957),q=n(2300),U=n(52641),J=n(51221),Y=n(55606),G=n(86973),Q=n(98267),K=n(20537),V=n(37960),X=n(36314),$=n(49501),Z=n(6504),ee=n(22133),et=n(11665),en=n(97516),er=n(91861),eo=n(53612),ea=n(3014),el=n(63186),ei=n(70863),es=n(67891),ed=n(12121),ec=n(63992),eu=n(59637),ep=n(30949),ef=n(1877),eh=n(18466);function eg(e){return!!e&&(e.startsWith(eh.n9)||"handoff"===e)}var em=n(26188),ex=n(38952),ev=n(62962),eb=n(17897),ey=n(81029).hp,ej=n(87021);let ew=(0,ej.h)("frontend/components/Chat/McpAppFrame"),eA=e=>{let{serverName:t,uri:n}=e,[a,s]=(0,o.useState)(!1),[c,p]=(0,o.useState)(!1),[h,g]=(0,o.useState)(null),[m,x]=(0,o.useState)(null),v=(0,o.useCallback)(async()=>{p(!0),g(null);try{let e=await eb.S.readResource(t,n);if(!e||!1===e.success)return void g((null==e?void 0:e.error)||"Failed to read the UI resource.");let r=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2097152,r=null==e?void 0:e.contents;if(!Array.isArray(r)||0===r.length)return{error:"Resource has no contents"};let o=r.find(e=>(function(e){if("string"!=typeof e)return!1;let t=e.toLowerCase().replace(/\s+/g,"");return t.startsWith("text/html")&&t.includes("profile=mcp-app")})(e.mimeType)&&"string"==typeof e.text)||r.find(e=>"string"==typeof e.text);if(!o||"string"!=typeof o.text)return{error:"Resource has no HTML text body"};if((void 0!==ey?ey.byteLength(o.text,"utf8"):new TextEncoder().encode(o.text).length)>n)return{error:"Resource exceeds the ".concat(Math.round(n/1024)," KiB size cap")};let a=null==(t=o._meta)?void 0:t.ui;return{html:o.text,meta:a}}(e.data);if("error"in r)return void g(r.error);x(function(e,t){let n='<meta http-equiv="Content-Security-Policy" content="'.concat(function(e){let t=e=>(e||[]).map(e=>"string"==typeof e?e.trim():"").filter(e=>""!==e&&"string"==typeof e&&("'self'"===e||"'none'"===e||!(/[^\x21-\x7e]/.test(e)||/[;,'"`$<>\\()]/.test(e))&&/^(?:https|wss):\/\/(?:\*\.)?(?:[a-z0-9-]+\.)*[a-z0-9-]+(?::\d{1,5})?$/i.test(e))).join(" "),n=t(null==e?void 0:e.connectDomains),r=t(null==e?void 0:e.resourceDomains),o=t(null==e?void 0:e.frameDomains),a=t(null==e?void 0:e.baseUriDomains);return["default-src 'none'","script-src 'unsafe-inline'".concat(r?" ".concat(r):""),"style-src 'unsafe-inline'".concat(r?" ".concat(r):""),"img-src data: blob:".concat(r?" ".concat(r):""),"font-src".concat(r?" ".concat(r):" 'none'"),"media-src data: blob:".concat(r?" ".concat(r):""),"connect-src".concat(n?" ".concat(n):" 'none'"),"frame-src".concat(o?" ".concat(o):" 'none'"),"base-uri".concat(a?" ".concat(a):" 'none'"),"form-action 'none'"].join("; ")}(t),'">');return/<head[\s>]/i.test(e)?e.replace(/<head([^>]*)>/i,(e,t)=>"<head".concat(t,">").concat(n)):'<!DOCTYPE html><html><head><meta charset="utf-8">'.concat(n,"</head><body>").concat(e,"</body></html>")}(r.html,r.meta))}catch(e){ew.warn("Failed to load MCP App resource ".concat(n," from ").concat(t),e),g(e instanceof Error?e.message:"Failed to load the UI resource.")}finally{p(!1)}},[t,n]),b=(0,o.useCallback)(()=>{let e=!a;s(e),e&&null===m&&!c&&v()},[a,m,c,v]);return(0,r.jsxs)(l.default,{sx:{mt:1,border:"1px solid",borderColor:"divider",borderRadius:1,overflow:"hidden"},children:[(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1,px:1,py:.5,bgcolor:"action.hover"},children:[(0,r.jsx)(em.A,{fontSize:"small",color:"primary"}),(0,r.jsxs)(u.default,{variant:"body2",sx:{fontWeight:500},children:["Interactive app from ",t]}),(0,r.jsx)(i.A,{title:"Rendered read-only in a strict sandbox (no same-origin access, no network unless the app declares it). The app cannot call tools in this view.",children:(0,r.jsx)(ex.A,{fontSize:"small",color:"action"})}),(0,r.jsx)(f.A,{size:"small",onClick:b,startIcon:a?(0,r.jsx)(ev.A,{}):(0,r.jsx)(el.A,{}),sx:{ml:"auto"},children:a?"Hide":"Open app"})]}),(0,r.jsx)(L.A,{in:a,unmountOnExit:!0,children:(0,r.jsxs)(l.default,{sx:{p:1},children:[c&&(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1,py:2,justifyContent:"center"},children:[(0,r.jsx)(W.default,{size:16,thickness:6}),(0,r.jsx)(u.default,{variant:"body2",color:"text.secondary",children:"Loading the app…"})]}),h&&(0,r.jsx)(d.A,{severity:"error",sx:{my:1},children:h}),!c&&!h&&null!==m&&(0,r.jsx)(l.default,{component:"iframe",title:"MCP App: ".concat(n),srcDoc:m,sandbox:"allow-scripts",referrerPolicy:"no-referrer",sx:{width:"100%",height:420,border:"none",borderRadius:1,bgcolor:"#fff"}})]})})]})},eS=(0,ej.h)("frontend/components/Chat/ChatMessages");function eI(e){return"assistant"===e.role&&"tool_calls"in e&&Array.isArray(e.tool_calls)}function eC(e){if("tool"!==e.role||"string"!=typeof e.content)return!1;try{var t;return(null==(t=JSON.parse(e.content))?void 0:t.handoff)===!0}catch(e){return!1}}let ek={p:e=>(0,r.jsx)(u.default,{variant:"body1",sx:{mb:.5,whiteSpace:"pre-line"},children:e.children}),h1:e=>(0,r.jsx)(u.default,{variant:"h5",sx:{mt:2,mb:.5},children:e.children}),h2:e=>(0,r.jsx)(u.default,{variant:"h6",sx:{mt:2,mb:.5},children:e.children}),h3:e=>(0,r.jsx)(u.default,{variant:"subtitle1",sx:{mt:1.5,mb:.5},children:e.children}),h4:e=>(0,r.jsx)(u.default,{variant:"subtitle2",sx:{mt:1.5,mb:.5},children:e.children}),h5:e=>(0,r.jsx)(u.default,{variant:"body1",sx:{mt:1,mb:.5,fontWeight:"bold"},children:e.children}),h6:e=>(0,r.jsx)(u.default,{variant:"body2",sx:{mt:1,mb:.5,fontWeight:"bold"},children:e.children}),ul:e=>(0,r.jsx)(l.default,{component:"ul",sx:{pl:2,mb:1},children:e.children}),ol:e=>(0,r.jsx)(l.default,{component:"ol",sx:{pl:2,mb:1},children:e.children}),li:e=>(0,r.jsx)(l.default,{component:"li",sx:{mb:.5,whiteSpace:"pre-line"},children:e.children}),a:e=>(0,r.jsx)(u.default,{component:"a",sx:{color:"primary.main"},href:e.href,children:e.children}),blockquote:e=>(0,r.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:o,...a}=e;return/language-(\w+)/.exec(n||"")||n?(0,r.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:o}):(0,r.jsx)(u.default,{component:"code",sx:{bgcolor:"action.hover",px:.5,py:.25,borderRadius:"4px",fontFamily:"monospace",wordBreak:"break-all"},children:o})}},eE=e=>{let{content:t,showRaw:n}=e;return n?(0,r.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 t?t:"[Invalid tool content]"}):"string"!=typeof t?(0,r.jsx)(u.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",children:"[Invalid tool content]"}):(0,r.jsx)(l.default,{sx:{width:"100%",minWidth:0},children:(()=>{try{let e=JSON.parse(t);if(e&&Array.isArray(e.content))return(0,r.jsx)(l.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.content.map((e,t)=>"text"===e.type?(0,r.jsx)(Z.oz,{remarkPlugins:[ee.A],children:e.text},t):"image"===e.type&&e.data&&e.mimeType?(0,r.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,r.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,r.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,r.jsx)(Z.oz,{remarkPlugins:[ee.A],children:"```json\n".concat(JSON.stringify(e,null,2),"\n```")})}catch(e){return(0,r.jsx)(Z.oz,{remarkPlugins:[ee.A],children:t})}})()})},eT=e=>{let{pairs:t,messageId:n}=e,[a,s]=(0,o.useState)(null),[d,c]=(0,o.useState)({}),f=(e,t)=>e.toolCall.id||"tc-".concat(n,"-").concat(t);return(0,r.jsxs)(l.default,{sx:{mt:1,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",color:"primary.main",mb:1},children:[(0,r.jsx)(ei.A,{fontSize:"small",sx:{mr:1}}),(0,r.jsx)(u.default,{variant:"body2",children:1===t.length?"The assistant used a tool":"The assistant used ".concat(t.length," tools")})]}),(0,r.jsx)(l.default,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:.5},children:t.map((e,t)=>{let n=f(e,t),d=function(e){if(!e)return"pending";if("string"==typeof e.content)try{let t=JSON.parse(e.content);if(t&&(!0===t.isError||null!=t.error))return"error"}catch(e){}return"done"}(e.result),c=a===n;return(0,r.jsxs)(o.Fragment,{children:[t>0&&(0,r.jsx)(l.default,{sx:{width:14,height:"2px",bgcolor:"divider",flexShrink:0}}),(0,r.jsx)(i.A,{title:c?"Hide call & result":"Show call & result",children:(0,r.jsx)(p.A,{icon:function(e){return"pending"===e?(0,r.jsx)(W.default,{size:14,thickness:6}):"error"===e?(0,r.jsx)(I.A,{fontSize:"small"}):(0,r.jsx)(ed.A,{fontSize:"small"})}(d),label:(0,ef.yo)(e.toolCall.function.name),size:"small",clickable:!0,variant:c?"filled":"outlined",color:"error"===d?"error":"pending"===d?"default":"primary",onClick:()=>s(c?null:n),sx:{maxWidth:"100%"}})})]},n)})}),t.map((e,t)=>{var n,o;let i=f(e,t),s=e.toolCall.function.arguments;try{s=JSON.stringify(JSON.parse(e.toolCall.function.arguments),null,2)}catch(e){}let h=!!d[i];return(0,r.jsx)(L.A,{in:a===i,unmountOnExit:!0,children:(0,r.jsxs)(l.default,{sx:{mt:1,p:1,borderRadius:1,bgcolor:"rgba(0, 0, 0, 0.03)"},children:[(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",mb:.5},children:[(0,r.jsx)(ei.A,{fontSize:"small",sx:{mr:.5,color:"primary.main"}}),(0,r.jsx)(u.default,{variant:"caption",sx:{fontWeight:"bold"},children:"Parameters"}),(0,r.jsx)(p.A,{label:"ID: ".concat(e.toolCall.id?e.toolCall.id.substring(0,8):"N/A","..."),size:"small",color:"default",variant:"outlined",sx:{ml:1,height:20,fontSize:"0.7rem"}})]}),(0,r.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:s}),(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",mt:1,mb:.5},children:[(0,r.jsx)(es.A,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),(0,r.jsx)(u.default,{variant:"caption",sx:{fontWeight:"bold"},children:"Result"}),e.result&&(0,r.jsx)(B.A,{control:(0,r.jsx)(H.A,{size:"small",checked:h,onChange:e=>c(t=>({...t,[i]:e.target.checked}))}),label:"Raw",sx:{ml:"auto",mr:0,"& .MuiTypography-root":{fontSize:"0.75rem"}}})]}),e.result?(0,r.jsx)(eE,{content:e.result.content,showRaw:h}):(0,r.jsxs)(u.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(W.default,{size:14,thickness:6})," Waiting for the tool to respond…"]}),(null==(o=e.result)||null==(n=o.ui)?void 0:n.uri)&&e.result.ui.serverName&&(0,r.jsx)(eA,{serverName:e.result.ui.serverName,uri:e.result.ui.uri})]})},i)})]})},eN=o.memo(function(e){var t,n;let o,{message:a,nodeLabel:d,availableNodes:c,showRaw:h,toolCallPairs:g,hoistedHandoffs:m,edit:x,onMenuOpen:v,onToggleRaw:b,onEditContentChange:y,onEditNodeChange:j,onSaveEdit:w,onCancelEdit:A}=e,S=null!=(t=a.depth)?t:0;return(0,r.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",alignItems:"user"===a.role?"flex-end":"flex-start",opacity:a.disabled?.5:1,...S>0&&{pl:3*S,borderLeft:"2px solid",borderColor:"divider",ml:1}},children:[(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",mb:.5},children:[(0,r.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)?(eS.warn("formatTime received invalid timestamp:",n),"Invalid Date"):new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]}),a.processNodeId&&(0,r.jsx)(i.A,{title:"".concat(d?"".concat(d," — "):"","Process Node ID: ").concat(a.processNodeId),children:(0,r.jsx)(p.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}})}),S>0&&(0,r.jsx)(i.A,{title:"Nested subflow step (depth ".concat(S,")"),children:(0,r.jsx)(p.A,{label:"Subflow step",size:"small",color:"secondary",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),a.disabled&&(0,r.jsx)(p.A,{label:"Disabled",size:"small",color:"default",variant:"outlined",sx:{height:20,fontSize:"0.7rem"}}),a.usage&&(0,r.jsx)(i.A,{title:"".concat(a.usage.promptTokens.toLocaleString()," prompt + ").concat(a.usage.completionTokens.toLocaleString()," completion tokens (provider-reported)"),children:(0,r.jsx)(p.A,{label:"".concat((o=a.usage.totalTokens)>=1e3?"".concat((o/1e3).toFixed(o>=1e5?0:1),"k"):"".concat(o)," tok"),size:"small",color:"default",variant:"outlined",sx:{height:20,fontSize:"0.7rem",mr:1}})}),(0,r.jsx)(s.A,{size:"small",onClick:e=>v(e,a.id),sx:{ml:1},children:(0,r.jsx)(et.A,{fontSize:"small"})})]}),(0,r.jsxs)(q.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:[x?(0,r.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",gap:1},children:[(0,r.jsx)("textarea",{value:x.content,onChange:e=>y(e.target.value),style:{width:"100%",minHeight:"100px",padding:"8px",borderRadius:"4px",border:"1px solid #ccc",fontFamily:"inherit",fontSize:"inherit",backgroundColor:"white",color:"black"}}),(0,r.jsxs)(U.A,{fullWidth:!0,size:"small",sx:{mt:1},children:[(0,r.jsx)(J.A,{id:"node-id-select-label",children:"Process Node"}),(0,r.jsx)(Y.A,{labelId:"node-id-select-label",id:"node-id-select",value:x.nodeId||(c.length>0?c[0].id:""),label:"Process Node",onChange:e=>j(e.target.value),children:c.map(e=>(0,r.jsx)(G.A,{value:e.id,children:e.label||e.id.substring(0,8)},e.id))})]}),(0,r.jsxs)(l.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:1},children:[(0,r.jsx)(f.A,{variant:"outlined",size:"small",onClick:A,children:"Cancel"}),(0,r.jsx)(f.A,{variant:"contained",size:"small",onClick:w,children:"Save"})]})]}):(0,r.jsxs)(r.Fragment,{children:["tool"!==a.role&&"string"==typeof a.content&&(0,r.jsx)(Z.oz,{remarkPlugins:[ee.A],components:ek,children:a.content}),"tool"!==a.role&&Array.isArray(a.content)&&(0,r.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,r.jsx)(Z.oz,{remarkPlugins:[ee.A],children:e.text},t):(null==e?void 0:e.type)==="image_url"&&(null==(n=e.image_url)?void 0:n.url)?(0,r.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)&&!eI(a)&&(0,r.jsx)(u.default,{variant:"body2",fontStyle:"italic",color:"text.secondary",children:"[No text content]"})]}),(()=>{let e=[...eI(a)?a.tool_calls.filter(e=>{var t;return!!(t=e.function.name)&&(t.startsWith(eh.n9)||"handoff"===t)}):[],...null!=m?m:[]];return(0,r.jsx)(l.default,{sx:{mt:1,display:"flex",flexWrap:"wrap",gap:.5},children:e.map((e,t)=>(0,r.jsx)(p.A,{size:"small",variant:"outlined",color:"secondary",icon:(0,r.jsx)(ep.A,{fontSize:"small"}),label:"Handoff → ".concat(function(e,t){let n=e.startsWith(eh.n9)?e.slice(eh.n9.length):e,r=n.replace(/_\d+$/,""),o=t.find(e=>{let t=(0,eh.RN)(e.label);return t===n||t===r});return(null==o?void 0:o.label)?o.label:r.split("_").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")||"target node"}(e.function.name,c)),sx:{maxWidth:"100%",fontWeight:500}},e.id||"handoff-".concat(a.id,"-").concat(t)))})})(),g&&g.length>0&&(0,r.jsx)(eT,{pairs:g,messageId:a.id}),"tool"===a.role&&a.tool_call_id&&!eC(a)&&(0,r.jsxs)(l.default,{children:[(0,r.jsxs)(u.default,{variant:"body2",sx:{display:"flex",alignItems:"center",color:"text.secondary",mb:1},children:[(0,r.jsx)(es.A,{fontSize:"small",sx:{mr:1}}),"The tool responded to the assistant"]}),(0,r.jsxs)(Q.A,{defaultExpanded:!1,sx:{mb:.5,"&:before":{display:"none"},boxShadow:"none",bgcolor:"rgba(0, 0, 0, 0.02)"},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),children:(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(es.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),(0,r.jsx)(u.default,{variant:"subtitle2",children:"Tool Result"}),(0,r.jsx)(p.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,r.jsx)(B.A,{control:(0,r.jsx)(H.A,{size:"small",checked:h,onChange:e=>b(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,r.jsx)(V.A,{sx:{pt:0,pb:1,overflow:"hidden"},children:(0,r.jsx)(eE,{content:a.content,showRaw:h})})]})]}),a.attachments&&a.attachments.length>0&&(0,r.jsxs)(l.default,{sx:{mt:1,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,r.jsx)(u.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Attachments:"}),a.attachments.map(e=>"image"===e.type?(0,r.jsx)(l.default,{sx:{mb:.5},children:(0,r.jsx)("img",{src:e.content,alt:e.originalName||"image attachment",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}})},e.id):(0,r.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,r.jsx)(eo.A,{fontSize:"small",sx:{mr:1}}):(0,r.jsx)(ea.A,{fontSize:"small",sx:{mr:1}}),(0,r.jsx)(u.default,{variant:"caption",sx:{wordBreak:"break-all"},children:e.originalName||"".concat(e.type," attachment")})]},e.id))]})]})]})}),eR=e=>{let{messages:t,pendingToolCalls:n,availableNodes:a=[],conversationId:i,onToggleDisabled:s,onSplitConversation:d,onEditMessage:c,onApproveToolCall:h,onRejectToolCall:g}=e,[m,x]=(0,o.useState)(50);(0,o.useEffect)(()=>{x(50)},[i]);let v=Math.max(0,(Array.isArray(t)?t.length:0)-m),b=(0,o.useMemo)(()=>Array.isArray(t)?v>0?t.slice(v):t:[],[t,v]),{pairsByAnchorId:y,handoffsByAnchorId:j,consumedToolCallIds:w,groups:A}=(0,o.useMemo)(()=>(function(e){let t=new Map,n=new Map,r=new Set,o=new Set,a=new Map,l=[];if(!Array.isArray(e))return{pairsByAnchorId:t,handoffsByAnchorId:n,hoistedAssistantIds:r,consumedToolCallIds:o,groups:l};let i=new Map;for(let t of e)"tool"===t.role&&"string"==typeof t.tool_call_id&&t.tool_call_id&&!i.has(t.tool_call_id)&&i.set(t.tool_call_id,t);let s=e=>{let r=a.get(e);return r||(r={anchorId:e,memberIds:[e],hoistedIds:[]},a.set(e,r),l.push(r),t.set(e,[]),n.set(e,[])),r},d=null;for(let a of e){if("user"===a.role||"system"===a.role){d=null;continue}if("assistant"!==a.role)continue;let e=Array.isArray(a.tool_calls)?a.tool_calls:[],l=[],u=[];for(let t of e){var c;if("function"!==t.type)continue;if(eg(null==(c=t.function)?void 0:c.name)){u.push(t);continue}let e=t.id,n=e?i.get(e):void 0;e&&o.add(e),l.push({toolCall:t,result:n})}let p=function(e){let t=e.content;return"string"==typeof t?t.trim().length>0:!!Array.isArray(t)&&t.some(e=>{var t,n;return!!e&&"object"==typeof e&&("text"===e.type?"string"==typeof e.text&&e.text.trim().length>0:"image_url"===e.type?!!(null==(t=e.image_url)?void 0:t.url):"input_audio"===e.type&&!!(null==(n=e.input_audio)?void 0:n.data))})}(a),f=l.length>0||u.length>0;if(p){d=a.id,f&&(s(a.id),t.get(a.id).push(...l),n.get(a.id).push(...u));continue}if(f)if(d){let e=s(d);t.get(d).push(...l),n.get(d).push(...u),e.memberIds.push(a.id),e.hoistedIds.push(a.id),r.add(a.id)}else d=a.id,s(a.id),t.get(a.id).push(...l),n.get(a.id).push(...u)}return{pairsByAnchorId:t,handoffsByAnchorId:n,hoistedAssistantIds:r,consumedToolCallIds:o,groups:l}})(t),[t]),S=(0,o.useMemo)(()=>(function(e){let t=new Set;if(!Array.isArray(e))return t;for(let r of e){if("assistant"!==r.role)continue;let e=r.tool_calls;if(Array.isArray(e))for(let r of e){var n;"function"===r.type&&eg(null==(n=r.function)?void 0:n.name)&&"string"==typeof r.id&&r.id&&t.add(r.id)}}return t})(t),[t]),I=(0,o.useMemo)(()=>new Set(b.map(e=>e.id)),[b]),{renderPairsById:C,renderHandoffsById:k,suppressedIds:T}=(0,o.useMemo)(()=>{let e=new Map,t=new Map,n=new Set;for(let l of A){var r,o,a;let i=null!=(r=y.get(l.anchorId))?r:[],s=null!=(o=j.get(l.anchorId))?o:[],d=null!=(a=l.memberIds.find(e=>I.has(e)))?a:l.anchorId;for(let r of(i.length>0&&e.set(d,i),s.length>0&&t.set(d,s),l.hoistedIds))r!==d&&n.add(r)}return{renderPairsById:e,renderHandoffsById:t,suppressedIds:n}},[A,y,j,I]),[N,R]=o.useState(null),[z,P]=o.useState(null),[F,_]=o.useState(null),[M,O]=o.useState(!1),[W,L]=o.useState(""),[B,H]=o.useState(null),[U,J]=o.useState({}),Y=(0,o.useCallback)((e,t)=>{eS.debug("handleMenuOpen called with messageId: ".concat(t)),R(e.currentTarget),P(t)},[]),Z=(0,o.useCallback)((e,t)=>{J(n=>({...n,[e]:t}))},[]),ee=(0,o.useCallback)(e=>{L(e)},[]),et=(0,o.useCallback)(e=>{H(e)},[]),eo=()=>{R(null),P(null)},ea=()=>{if(z){let e=t.find(e=>e.id===z);e&&"user"===e.role&&"string"==typeof e.content&&(L(e.content),H(e.processNodeId||(a.length>0?a[0].id:"")),_(z),O(!0)),eo()}},es=()=>{F&&c&&(c(F,W,B||""),O(!1),_(null),H(null))},ed=()=>{O(!1),_(null),H(null)},ep=(0,o.useMemo)(()=>{let e=new Map;for(let t of a)e.set(t.id,t.label);return e},[a]),eh=(0,o.useMemo)(()=>z&&t.find(e=>e.id===z)||null,[z,t]);return(0,r.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:[v>0&&(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center"},children:(0,r.jsxs)(f.A,{size:"small",variant:"outlined",onClick:()=>x(e=>e+200),children:["Show earlier messages (",v," more)"]})}),b.map((e,t)=>{if(eC(e)||"tool"===e.role&&"string"==typeof e.tool_call_id&&S.has(e.tool_call_id)||"tool"===e.role&&"string"==typeof e.tool_call_id&&w.has(e.tool_call_id)||T.has(e.id))return null;let n=M&&e.id===F;return(0,r.jsx)(eN,{message:e,nodeLabel:e.processNodeId?ep.get(e.processNodeId):void 0,availableNodes:a,showRaw:!!U[e.id],toolCallPairs:C.get(e.id),hoistedHandoffs:k.get(e.id),edit:n?{content:W,nodeId:B}:null,onMenuOpen:Y,onToggleRaw:Z,onEditContentChange:ee,onEditNodeChange:et,onSaveEdit:n?es:void 0,onCancelEdit:n?ed:void 0},e.id||"msg-".concat(v+t))}),(0,r.jsxs)(X.A,{anchorEl:N,open:!!N,onClose:eo,children:[eh&&(()=>{eS.debug("Entering menu item rendering logic",{activeMessageId:z}),eS.debug("Active message object for menu:",eh),eS.debug("Active message role for menu:",null==eh?void 0:eh.role);try{let e=!!c,t="user"===eh.role&&e;if(eS.debug("Rendering Edit Message menu item check",{activeMessageId:eh.id,messageRole:eh.role,onEditMessagePropType:typeof c,hasOnEditMessageProp:e,shouldShowEdit:t}),t)return(0,r.jsxs)(G.A,{onClick:ea,children:[(0,r.jsx)($.A,{children:(0,r.jsx)(E.A,{fontSize:"small"})}),(0,r.jsx)(D.A,{children:"Edit Message"})]});return null}catch(e){return eS.error("Error rendering Edit Message menu item",{error:e}),null}})(),(0,r.jsxs)(G.A,{onClick:()=>{z&&(s(z),eo())},children:[(0,r.jsx)($.A,{children:(0,r.jsx)(en.A,{fontSize:"small"})}),(0,r.jsx)(D.A,{children:(null==eh?void 0:eh.disabled)?"Enable Message":"Disable Message"})]}),(0,r.jsxs)(G.A,{onClick:()=>{z&&(d(z),eo())},children:[(0,r.jsx)($.A,{children:(0,r.jsx)(er.A,{fontSize:"small"})}),(0,r.jsx)(D.A,{children:"Split Conversation Here"})]})]}),n&&n.length>0&&(0,r.jsxs)(q.A,{elevation:2,sx:{p:2,mt:2,bgcolor:"warning.light",border:"1px solid",borderColor:"warning.main",borderRadius:2},children:[(0,r.jsxs)(u.default,{variant:"h6",sx:{mb:1,display:"flex",alignItems:"center"},children:[(0,r.jsx)(ei.A,{sx:{mr:1}})," Tool Approval Required"]}),(0,r.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,ef.yo)(e.function.name),o=e.function.arguments;try{let t=JSON.parse(e.function.arguments);o=JSON.stringify(t,null,2)}catch(e){}return(0,r.jsxs)(Q.A,{defaultExpanded:!0,sx:{mb:1,"&:before":{display:"none"},boxShadow:1},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),children:(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",width:"100%"},children:[(0,r.jsx)(ei.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),(0,r.jsx)(u.default,{variant:"subtitle2",sx:{fontWeight:"bold",flexGrow:1},children:n}),(0,r.jsx)(p.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,r.jsxs)(V.A,{sx:{pt:0},children:[(0,r.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:o}),(0,r.jsxs)(l.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:1},children:[(0,r.jsx)(f.A,{variant:"outlined",color:"error",size:"small",startIcon:(0,r.jsx)(eu.A,{}),onClick:()=>g&&g(e.id),disabled:!g,children:"Reject"}),(0,r.jsx)(f.A,{variant:"contained",color:"success",size:"small",startIcon:(0,r.jsx)(ec.A,{}),onClick:()=>h&&h(e.id),disabled:!h,children:"Approve"})]})]})]},e.id||"ptc-".concat(t))})]})]})};var ez=n(84869);let eD=(0,ej.h)("frontend/services/transcription");async function eP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onProgress:n,onStatusChange:r,language:o}=t;try{if(eD.debug("Starting transcription service"),r&&r("Initializing transcription..."),!(0,ez.G)().supported)throw Error("Web Speech API is not supported in this browser");r&&r("Using browser speech recognition...");let t=await (0,ez.S)(e,{language:o,onInterimResult:e=>{r&&r("Transcribing: ".concat(e)),n&&n(50)}});return r&&r("Transcription completed"),eD.debug("Web Speech API transcription completed successfully",{textLength:t.length}),{text:t,success:!0,engine:"webspeech"}}catch(e){return eD.error("Transcription failed",{error:e}),r&&r("Transcription failed"),{text:"Transcription failed. Please check if your browser supports speech recognition.",success:!1,error:e instanceof Error?e.message:String(e)}}}var eF=n(9164),e_=n(22822),eM=n(35205),eO=n(77073),eW=n(55930),eL=n(9693),eB=n(4823),eH=n(74879);let eq=(0,ej.h)("frontend/components/Chat/ChatInput"),eU=e=>{var t;let{onSendMessage:n,disabled:a=!1,requireApproval:d=!1,onRequireApprovalChange:h,executeInDebugger:g=!1,onExecuteInDebuggerChange:b,availableNodes:j=[],currentNodeId:w=null,nodeOverrideActive:A=!1,onSelectNode:S}=e,{settings:I}=(0,eF.useStorage)(),[C,k]=(0,o.useState)(""),[E,T]=(0,o.useState)([]),[R,z]=(0,o.useState)(!1),[P,F]=(0,o.useState)(0),[_,M]=(0,o.useState)(null),O=(0,o.useRef)(null),L=(0,o.useRef)(null),H=(0,o.useRef)([]),[U,J]=(0,o.useState)(null),Y=(null==(t=j.find(e=>e.id===w))?void 0:t.label)||(w?"".concat(w.substring(0,6),"..."):"Start"),[Q,K]=(0,o.useState)(!1),[V,Z]=(0,o.useState)(""),[ee,et]=(0,o.useState)(""),[en,er]=(0,o.useState)("document"),[el,ei]=(0,o.useState)(!1),[es,ed]=(0,o.useState)(0),[ec,eu]=(0,o.useState)(""),ep=()=>{(C.trim()||E.length>0)&&(eq.debug("Sending message",{messageLength:C.length,attachmentsCount:E.length}),n(C,E),k(""),T([]))},ef=async e=>{let t=e.target.files;if(!t||0===t.length)return;let n=t[0];eq.debug("File selected",{fileName:n.name,fileSize:n.size,fileType:n.type}),et("Processing ".concat(n.name)),er("document"),Z(""),ei(!0),K(!0);try{let e=await eh(n);eq.debug("File read successfully",{contentLength:e.length}),Z(e),ei(!1)}catch(e){eq.error("Error reading file:",e),Z("Error reading file. Please try again with a text file."),ei(!1)}O.current&&(O.current.value="")},eh=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{var r;(null==(r=e.target)?void 0:r.result)?t(e.target.result):n(Error("Failed to read file"))},r.onerror=()=>{n(Error("Error reading file"))},r.readAsText(e)}),eg=async()=>{eq.debug("Starting audio recording");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});eq.debug("Audio stream obtained successfully"),H.current=[];let t=new MediaRecorder(e);L.current=t,t.ondataavailable=e=>{e.data.size>0&&H.current.push(e.data)},t.onstop=async()=>{let t=new Blob(H.current,{type:"audio/wav"});et("Audio Recording"),er("audio"),Z(""),ei(!0),K(!0);try{if(((null==I?void 0:I.speech)||{enabled:!0,modelSize:"base",autoDownload:!1}).enabled){eu("Initializing transcription..."),ed(0);let e=await eP(t,{onProgress:ed,onStatusChange:eu,language:navigator.language});if(e.success){let t=e.text;Z(t),eq.debug("Transcription successful",{textLength:e.text.length,engine:e.engine})}else Z("Error transcribing audio: ".concat(e.error,".")),eq.error("Transcription failed",{error:e.error})}else Z("Speech recognition is disabled in settings. Enable it to get automatic transcriptions.")}catch(e){eq.error("Error handling audio recording",{error:e}),Z("Failed to process audio: ".concat(e))}finally{ei(!1),e.getTracks().forEach(e=>e.stop())}},t.start(),z(!0);let n=setInterval(()=>{F(e=>e+1)},1e3);M(n)}catch(e){eq.error("Error starting recording:",e),alert("Could not access microphone. Please check permissions.")}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(q.A,{elevation:3,sx:{p:2,display:"flex",flexDirection:"column",borderRadius:2},children:[E.length>0&&(0,r.jsx)(l.default,{sx:{mb:2,display:"flex",flexWrap:"wrap",gap:1},children:E.map(e=>(0,r.jsxs)(q.A,{variant:"outlined",sx:{p:1,display:"flex",alignItems:"center",borderRadius:1,bgcolor:"background.default"},children:["image"===e.type?(0,r.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,r.jsx)(eo.A,{fontSize:"small",sx:{mr:1}}):(0,r.jsx)(ea.A,{fontSize:"small",sx:{mr:1}}),(0,r.jsx)(u.default,{variant:"body2",noWrap:!0,sx:{maxWidth:150},children:e.originalName||"".concat(e.type," attachment")}),(0,r.jsx)(s.A,{size:"small",onClick:()=>(e=>{eq.debug("Removing attachment",{id:e}),T(E.filter(t=>t.id!==e))})(e.id),sx:{ml:1},children:(0,r.jsx)(eO.A,{fontSize:"small"})})]},e.id))}),(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"flex-end"},children:[(0,r.jsx)(c.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||(eq.debug("Enter key pressed, sending message"),e.preventDefault(),ep())},onPaste:e=>{var t;let n=null==(t=e.clipboardData)?void 0:t.items;if(!n)return;let r=[];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&&r.push(e)}}0!==r.length&&(e.preventDefault(),eq.debug("Pasting image attachment(s)",{count:r.length}),r.forEach(e=>{let t=new FileReader;t.onload=t=>{var n;let r=null==(n=t.target)?void 0:n.result;if("string"!=typeof r)return;let o=(e.type.split("/")[1]||"png").split("+")[0];T(t=>[...t,{id:(0,eH.A)(),type:"image",content:r,originalName:e.name&&!/^image\.\w+$/i.test(e.name)?e.name:"Pasted image.".concat(o)}])},t.onerror=()=>eq.error("Failed to read pasted image"),t.readAsDataURL(e)}))},disabled:a,variant:"outlined",sx:{mr:1},InputProps:{sx:{borderRadius:2}}}),(0,r.jsx)(i.A,{title:"Attach document",children:(0,r.jsx)(s.A,{color:"primary",onClick:()=>{var e;eq.debug("File selection triggered"),null==(e=O.current)||e.click()},disabled:a||R,children:(0,r.jsx)(eo.A,{})})}),(0,r.jsx)("input",{type:"file",ref:O,onChange:ef,style:{display:"none"},accept:".txt,.md,.json,.csv,.html,.xml,.js,.ts,.jsx,.tsx,.css,.scss"}),(0,r.jsx)(i.A,{title:R?"Stop recording":"Record audio",children:(0,r.jsxs)(s.A,{color:R?"error":"primary",onClick:R?()=>{eq.debug("Stopping audio recording"),L.current&&"inactive"!==L.current.state&&(L.current.stop(),z(!1),_&&(clearInterval(_),M(null)),F(0))}:eg,disabled:a,children:[(0,r.jsx)(ea.A,{}),R&&(0,r.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,r.jsx)(i.A,{title:"Send message",children:(0,r.jsx)(s.A,{color:"primary",onClick:ep,disabled:a||!C.trim()&&0===E.length,children:(0,r.jsx)(eM.A,{})})})]})," ",(h||S&&j.length>0)&&(0,r.jsxs)(l.default,{sx:{mt:1,display:"flex",justifyContent:"flex-start",alignItems:"center",flexWrap:"wrap",gap:1},children:[S&&j.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{title:A?"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,r.jsx)(p.A,{icon:(0,r.jsx)(eW.A,{}),label:Y,size:"small",color:A?"primary":"default",variant:A?"filled":"outlined",onClick:e=>J(e.currentTarget),disabled:a})}),(0,r.jsxs)(X.A,{anchorEl:U,open:!!U,onClose:()=>J(null),children:[(0,r.jsxs)(G.A,{selected:!A,onClick:()=>{S(null),J(null)},children:[(0,r.jsx)($.A,{children:(0,r.jsx)(eB.A,{fontSize:"small"})}),(0,r.jsx)(D.A,{primary:"Automatic",secondary:"Follow the conversation",secondaryTypographyProps:{variant:"caption"}})]}),(0,r.jsx)(N.A,{}),j.map(e=>(0,r.jsxs)(G.A,{selected:A&&e.id===w,onClick:()=>{S(e.id),J(null)},children:[(0,r.jsx)($.A,{children:e.id===w?(0,r.jsx)(eL.A,{fontSize:"small"}):null}),(0,r.jsx)(D.A,{primary:e.label})]},e.id))]})]}),h&&(0,r.jsx)(B.A,{control:(0,r.jsx)(e_.A,{checked:d,onChange:e=>h(e.target.checked),size:"small",disabled:a}),label:(0,r.jsx)(u.default,{variant:"caption",children:"Require Tool Approvals"}),sx:{mr:"auto"}}),b&&(0,r.jsx)(B.A,{control:(0,r.jsx)(e_.A,{checked:g,onChange:e=>b(e.target.checked),size:"small",disabled:a}),label:(0,r.jsx)(u.default,{variant:"caption",children:"Execute in Debugger"}),sx:{ml:2}})]})," "]})," ",(0,r.jsxs)(m.A,{open:Q,onClose:()=>!el&&K(!1),maxWidth:"md",fullWidth:!0,children:[(0,r.jsxs)(x.A,{children:[ee,!el&&(0,r.jsx)(s.A,{"aria-label":"close",onClick:()=>K(!1),sx:{position:"absolute",right:8,top:8},children:(0,r.jsx)(eO.A,{})})]}),(0,r.jsx)(v.A,{dividers:!0,children:el?(0,r.jsxs)(l.default,{sx:{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",p:4},children:[(0,r.jsx)(W.default,{value:"audio"===en&&es?es:void 0,variant:"audio"===en&&es>0?"determinate":"indeterminate"}),"audio"===en&&(0,r.jsxs)(l.default,{sx:{mt:2,textAlign:"center"},children:[(0,r.jsx)(u.default,{variant:"body2",children:ec||"Processing audio..."}),es>0&&(0,r.jsxs)(u.default,{variant:"body2",color:"text.secondary",sx:{mt:1},children:[Math.round(es),"%"]})]})]}):(0,r.jsx)(c.A,{multiline:!0,fullWidth:!0,minRows:10,maxRows:20,value:V,onChange:e=>Z(e.target.value),variant:"outlined",placeholder:"document"===en?"Document content":"Audio transcription"})}),(0,r.jsxs)(y.A,{children:[(0,r.jsx)(f.A,{onClick:()=>K(!1),disabled:el,children:"Cancel"}),(0,r.jsx)(f.A,{onClick:()=>{eq.debug("Adding attachment",{type:en,titleLength:ee.length}),T([...E,{id:(0,eH.A)(),type:en,content:V,originalName:ee}]),K(!1)},variant:"contained",disabled:el||!V.trim(),children:"Add to Message"})]})]})]})};var eJ=n(25731);let eY=e=>{var t;let{liveStats:n,onStop:a,stopDisabled:i,awaitingApproval:s}=e,[d,c]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{let e=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=n?Math.max(0,Math.round((d-n.startedAt)/1e3)):0,h=n?Math.round((d-n.lastEventAt)/1e3):0,g=!s&&!!n&&h>=60;return(0,r.jsxs)(l.default,{sx:{display:"flex",flexDirection:"column",alignItems:"center",my:2,gap:.5},children:[(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[s?(0,r.jsx)(eJ.A,{fontSize:"small",color:"warning"}):(0,r.jsx)(W.default,{size:20,color:g?"warning":"primary"}),(0,r.jsx)(u.default,{variant:"body2",color:"textSecondary",children:s?"Waiting for tool approval":(null==n?void 0:n.activeNode)?"Running: ".concat(n.activeNode):"Working…"}),(0,r.jsx)(f.A,{variant:"outlined",color:"secondary",size:"small",onClick:a,disabled:i,children:"Stop"})]}),!s&&(0,r.jsxs)(u.default,{variant:"caption",color:g?"warning.main":"textSecondary",children:[(null!=(t=null==n?void 0:n.totalTokens)?t:0).toLocaleString()," tokens \xb7 ",p,"s elapsed",g?" \xb7 no activity for ".concat(h,"s — may be stuck"):""]})]})};var eG=n(88538),eQ=n(16963),eK=n(2456),eV=n(64792),eX=n(71356),e$=n(45202),eZ=n(52005),e0=n(77998);let e1=e=>e>=1e3?"".concat((e/1e3).toFixed(e>=1e5?0:1),"k"):"".concat(e),e2=e=>{var t;let{usage:n,contextInfo:a,availableNodes:s}=e,[d,c]=(0,o.useState)(null);if(!n&&!a)return null;let f=(null==n?void 0:n.byNode)?Object.entries(n.byNode):[],h=null!=(t=null==n?void 0:n.cacheReadTokens)?t:0,g=n?Math.max(0,n.promptTokens-h):0,m=n?Math.max(0,n.totalTokens-h):0,x=(null==a?void 0:a.contextWindow)&&a.contextWindow>0?Math.min(100,Math.round(a.promptTokens/a.contextWindow*100)):void 0;return(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0},children:[n&&m>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{title:"Tokens this conversation — ".concat(g.toLocaleString()," prompt / ").concat(n.completionTokens.toLocaleString()," completion").concat(h>0?" (+".concat(h.toLocaleString()," cached reads, not counted)"):"",". Click for the per-node breakdown."),children:(0,r.jsx)(p.A,{icon:(0,r.jsx)(e0.A,{}),label:"".concat(e1(m)," tokens"),size:"small",variant:"outlined",onClick:e=>c(e.currentTarget),sx:{cursor:"pointer"}})}),(0,r.jsx)(eG.Ay,{open:!!d,anchorEl:d,onClose:()=>c(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,r.jsxs)(l.default,{sx:{p:2,maxWidth:420},children:[(0,r.jsx)(u.default,{variant:"subtitle2",sx:{mb:1},children:"Token usage by node"}),(0,r.jsxs)(eQ.A,{size:"small",children:[(0,r.jsx)(eK.A,{children:(0,r.jsxs)(eV.A,{children:[(0,r.jsx)(eX.A,{children:"Node"}),(0,r.jsx)(eX.A,{align:"right",children:"Prompt"}),(0,r.jsx)(eX.A,{align:"right",children:"Completion"}),(0,r.jsx)(eX.A,{align:"right",children:"Total"})]})}),(0,r.jsxs)(e$.A,{children:[f.map(e=>{let[t,n]=e;return(0,r.jsxs)(eV.A,{children:[(0,r.jsx)(eX.A,{children:(0,r.jsx)(i.A,{title:t,children:(0,r.jsx)("span",{children:(e=>{var t;return(null==(t=s.find(t=>t.id===e))?void 0:t.label)||"".concat(e.substring(0,8),"…")})(t)})})}),(0,r.jsx)(eX.A,{align:"right",children:n.promptTokens.toLocaleString()}),(0,r.jsx)(eX.A,{align:"right",children:n.completionTokens.toLocaleString()}),(0,r.jsx)(eX.A,{align:"right",children:n.totalTokens.toLocaleString()})]},t)}),(0,r.jsxs)(eV.A,{children:[(0,r.jsx)(eX.A,{sx:{fontWeight:"bold"},children:"Total"}),(0,r.jsx)(eX.A,{align:"right",sx:{fontWeight:"bold"},children:n.promptTokens.toLocaleString()}),(0,r.jsx)(eX.A,{align:"right",sx:{fontWeight:"bold"},children:n.completionTokens.toLocaleString()}),(0,r.jsx)(eX.A,{align:"right",sx:{fontWeight:"bold"},children:n.totalTokens.toLocaleString()})]})]})]}),h>0&&(0,r.jsxs)(u.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:["Prompt totals include ",h.toLocaleString()," tokens re-read from the prompt cache. The header chip shows the fresh figure (",m.toLocaleString(),") with those cached reads excluded."]})]})})]}),a&&void 0!==x&&(0,r.jsx)(i.A,{title:"Context of the latest call".concat(a.modelDisplayName?" (".concat(a.modelDisplayName,")"):"",": ").concat(a.promptTokens.toLocaleString()," of ").concat(a.contextWindow.toLocaleString()," tokens"),children:(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:140},children:[(0,r.jsx)(eZ.A,{variant:"determinate",value:x,color:x>=90?"error":x>=70?"warning":"primary",sx:{flex:1,height:6,borderRadius:3}}),(0,r.jsxs)(u.default,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:[e1(a.promptTokens),"/",e1(a.contextWindow)," (",x,"%)"]})]})}),a&&void 0===x&&(0,r.jsx)(i.A,{title:"Prompt size of the latest call".concat(a.modelDisplayName?" (".concat(a.modelDisplayName,")"):"",". Set the model's Context Window in its settings to see a usage meter."),children:(0,r.jsxs)(u.default,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:["ctx ",e1(a.promptTokens)]})})]})};var e5=n(56900),e6=n(90057),e4=n(96362),e8=n(9226),e3=n(68503);let e7=e=>{let{selectedFlowId:t,onSelectFlow:n,disabled:a=!1}=e,[i,s]=(0,o.useState)([]),[d,c]=(0,o.useState)(!0),[p,h]=(0,o.useState)(null),[g,m]=(0,o.useState)(!1);(0,o.useEffect)(()=>{(async()=>{c(!0),h(null);try{let e=await e6.g.loadFlows();s(e)}catch(e){console.error("Error loading flows:",e),h("Failed to load flows")}finally{c(!1)}})()},[]);let x=e=>{n(e),m(!1)},v=async e=>{let t=i.find(t=>t.id===e);if(!t)return;let n=!t.favorite,r={...t,favorite:n||void 0};try{(await e6.g.updateFlow(r)).success&&s(t=>t.map(t=>t.id===e?r:t))}catch(e){console.error("Error toggling flow favorite:",e)}},b=(0,e3.E)("flows",i),y=e=>({key:e.id,content:(e=>(0,r.jsx)(e8.A,{flow:e,selected:e.id===t,onSelect:x,onToggleFavorite:v,pickerMode:!0}))(e)}),j=b.items.map(y),w=b.groups?b.groups.map(e=>({...e,items:e.items.map(y)})):null,A=(()=>{if(!t)return"";let e=i.find(e=>e.id===t);return e?e.name:""})();return(0,r.jsxs)(l.default,{children:[(0,r.jsx)(u.default,{variant:"subtitle1",gutterBottom:!0,children:"Select Flow"}),d?(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(W.default,{size:20}),(0,r.jsx)(u.default,{variant:"body2",color:"text.secondary",children:"Loading flows..."})]}):p?(0,r.jsx)(u.default,{color:"error",variant:"body2",children:p}):0===i.length?(0,r.jsx)(u.default,{variant:"body2",color:"text.secondary",children:"No flows available. Create some flows in the Flow Builder first."}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f.A,{variant:"outlined",startIcon:(0,r.jsx)(e5.A,{}),onClick:()=>m(!0),disabled:a,sx:{textTransform:"none",maxWidth:"100%"},children:(0,r.jsx)(l.default,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t&&A||"Select a flow"})}),(0,r.jsx)(u.default,{variant:"caption",color:"text.secondary",display:"block",sx:{mt:.5},children:t?'Using "'.concat(A,'" flow for this conversation'):"Select a flow to use for this conversation"}),(0,r.jsx)(e4.A,{open:g,onClose:()=>m(!1),title:"Select a flow",description:"Pick the flow this conversation will run.",skeleton:(0,r.jsx)(e8.o,{}),emptyMessage:"No flows available. Create some flows in the Flow Builder first.",searchable:!0,searchPlaceholder:"Search flows…",searchTerm:b.searchTerm,onSearchChange:b.setSearchTerm,items:j,groups:w,collapsedKeys:b.collapsedKeys,onToggleGroup:b.toggleGroup})]})]})};var e9=n(43076);let te=(0,ej.h)("frontend/components/Chat/QuickChatDialog"),tt=e=>{let{open:t,onClose:n,onStart:a}=e,[i,h]=(0,o.useState)([]),[g,b]=(0,o.useState)([]),[j,w]=(0,o.useState)(!1),[A,S]=(0,o.useState)(null),[I,C]=(0,o.useState)(""),[k,E]=(0,o.useState)(""),[T,R]=(0,o.useState)({}),[z,D]=(0,o.useState)(!1),[P,F]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!t)return;let e=!1;return w(!0),S(null),(async()=>{try{let[t,n]=await Promise.all([e9.N.loadModels(),eb.S.loadServerConfigs()]);if(e)return;h(t);let r=Array.isArray(n)?n.filter(e=>!e.disabled).map(e=>e.name):[];b(r),C(e=>{var n;return e||(null==(n=t[0])?void 0:n.id)||""})}catch(t){e||(te.warn("Failed to load models/servers for quick chat",t),S("Could not load models or servers."))}finally{e||w(!1)}})(),()=>{e=!0}},[t]),(0,o.useEffect)(()=>{t||(E(""),R({}),F(null),D(!1))},[t]);let _=(0,o.useCallback)(e=>{R(t=>{let n=t[e];return(null==n?void 0:n.selected)?{...t,[e]:{...n,selected:!1}}:{...t,[e]:{...null!=n?n:{tools:null,expanded:!1},selected:!0}}})},[]),M=(0,o.useCallback)(async e=>{R(t=>{var n;let r=null!=(n=t[e])?n:{selected:!1,tools:null,expanded:!1};return{...t,[e]:{...r,expanded:!r.expanded}}});let t=T[e];if(!(null==t?void 0:t.available)&&!(null==t?void 0:t.loading)){R(t=>{var n;return{...t,[e]:{...null!=(n=t[e])?n:{selected:!1,tools:null,expanded:!0},loading:!0}}});try{let{tools:t}=await eb.S.listServerTools(e),n=Array.isArray(t)?t.map(e=>e.name).filter(Boolean):[];R(t=>{var r;return{...t,[e]:{...null!=(r=t[e])?r:{selected:!1,tools:null,expanded:!0},available:n,loading:!1}}})}catch(t){te.warn("Failed to load tools for ".concat(e),t),R(t=>{var n;return{...t,[e]:{...null!=(n=t[e])?n:{selected:!1,tools:null,expanded:!0},available:[],loading:!1}}})}}},[T]),O=(0,o.useCallback)((e,t,n)=>{R(r=>{var o,a;let l=null!=(o=r[e])?o:{selected:!0,tools:null,expanded:!0},i=new Set(null!=(a=l.tools)?a:new Set(n));return i.has(t)?i.delete(t):i.add(t),{...r,[e]:{...l,selected:!0,tools:i}}})},[]),H=!!I&&!z&&!j,q=async()=>{if(!I)return void F("Pick a model to chat with.");D(!0),F(null);let e=g.filter(e=>{var t;return null==(t=T[e])?void 0:t.selected}).map(e=>{let t=T[e];return!t.tools||t.available&&t.tools.size===t.available.length?{name:e}:{name:e,enabledTools:[...t.tools]}});try{await a({modelId:I,servers:e,systemPrompt:k.trim()||void 0})}catch(e){te.warn("Quick chat failed to start",e),F(e instanceof Error?e.message:"Could not start the quick chat."),D(!1)}};return(0,r.jsxs)(m.A,{open:t,onClose:z?void 0:n,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsx)(x.A,{children:"Quick Chat"}),(0,r.jsxs)(v.A,{children:[(0,r.jsx)(u.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Chat with a model and, optionally, some MCP servers — no need to build and save a flow."}),A&&(0,r.jsx)(d.A,{severity:"error",sx:{mb:2},children:A}),(0,r.jsxs)(U.A,{fullWidth:!0,size:"small",sx:{mb:2},disabled:j,children:[(0,r.jsx)(J.A,{id:"quick-chat-model-label",children:"Model"}),(0,r.jsxs)(Y.A,{labelId:"quick-chat-model-label",label:"Model",value:I,onChange:e=>C(e.target.value),children:[0===i.length&&(0,r.jsx)(G.A,{value:"",disabled:!0,children:j?"Loading…":"No models configured"}),i.map(e=>(0,r.jsx)(G.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),(0,r.jsx)(c.A,{fullWidth:!0,size:"small",multiline:!0,minRows:2,maxRows:6,label:"System prompt (optional)",placeholder:"e.g. You are a concise coding assistant.",value:k,onChange:e=>E(e.target.value),sx:{mb:2}}),(0,r.jsx)(N.A,{sx:{mb:1}}),(0,r.jsx)(u.default,{variant:"subtitle2",gutterBottom:!0,children:"MCP servers (optional)"}),j?(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,r.jsx)(W.default,{size:22})}):0===g.length?(0,r.jsx)(u.default,{variant:"body2",color:"text.secondary",children:"No connected MCP servers. You can still chat with the model alone."}):g.map(e=>{let t=T[e],n=!!(null==t?void 0:t.selected),o=null==t?void 0:t.available,a=null==t?void 0:t.tools;return(0,r.jsxs)(l.default,{sx:{mb:.5},children:[(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(B.A,{sx:{flexGrow:1,mr:0},control:(0,r.jsx)(e_.A,{size:"small",checked:n,onChange:()=>_(e)}),label:(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(u.default,{variant:"body2",children:e}),n&&(0,r.jsx)(p.A,{size:"small",variant:"outlined",label:a?"".concat(a.size," tool").concat(1===a.size?"":"s"):"all tools"})]})}),(0,r.jsx)(s.A,{size:"small",onClick:()=>M(e),"aria-label":"customize ".concat(e," tools"),children:(null==t?void 0:t.expanded)?(0,r.jsx)(ev.A,{fontSize:"small"}):(0,r.jsx)(el.A,{fontSize:"small"})})]}),(0,r.jsx)(L.A,{in:!!(null==t?void 0:t.expanded),unmountOnExit:!0,children:(0,r.jsx)(l.default,{sx:{pl:4,pb:1},children:(null==t?void 0:t.loading)?(0,r.jsx)(W.default,{size:16}):o&&o.length>0?o.map(t=>{let n=!a||a.has(t);return(0,r.jsx)(B.A,{sx:{display:"flex"},control:(0,r.jsx)(e_.A,{size:"small",checked:n,onChange:()=>O(e,t,o)}),label:(0,r.jsx)(u.default,{variant:"caption",children:t})},t)}):(0,r.jsx)(u.default,{variant:"caption",color:"text.secondary",children:o?"No tools reported (server may be offline).":""})})})]},e)}),P&&(0,r.jsx)(d.A,{severity:"error",sx:{mt:2},children:P})]}),(0,r.jsxs)(y.A,{children:[(0,r.jsx)(f.A,{onClick:n,disabled:z,children:"Cancel"}),(0,r.jsx)(f.A,{variant:"contained",onClick:q,disabled:!H,startIcon:z?(0,r.jsx)(W.default,{size:16,color:"inherit"}):void 0,children:z?"Starting…":"Start chat"})]})]})};var tn=n(53940),tr=n(48116),to=n(33567),ta=n(22539),tl=n(33420),ti=n(53911);let ts={byNode:{},byResource:{},byResourceName:{},resourceVersion:0};function td(e,t){return"".concat(e," ").concat(t)}var tc=n(59323),tu=n(72308),tp=n(6422),tf=n(48363);let th=(0,ej.h)("frontend/components/Chat/RunResourcesPanel"),tg=e=>{let{conversationId:t,refreshToken:n}=e,[a,i]=(0,o.useState)(null),[s,d]=(0,o.useState)(null);return((0,o.useEffect)(()=>{if(!t)return;let e=!1;return fetch("/v1/chat/conversations/".concat(encodeURIComponent(t),"/resources")).then(async e=>{if(!e.ok)throw Error("HTTP ".concat(e.status));return e.json()}).then(t=>{e||(i(Array.isArray(t.resources)?t.resources:[]),d(null))}).catch(t=>{e||(th.warn("Failed to load run resources",t),d(t instanceof Error?t.message:String(t)))}),()=>{e=!0}},[t,n]),s)?(0,r.jsxs)(u.default,{variant:"caption",color:"text.secondary",children:["Run data unavailable (",s,")"]}):null===a?(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",p:1},children:(0,r.jsx)(W.default,{size:16})}):0===a.length?(0,r.jsx)(u.default,{variant:"caption",color:"text.secondary",children:"No data artifacts captured in this run yet."}):(0,r.jsx)(R.A,{dense:!0,disablePadding:!0,children:[...a].sort((e,t)=>t.createdAt-e.createdAt).map(e=>{var t;return(0,r.jsxs)(z.Ay,{disableGutters:!0,sx:{alignItems:"flex-start"},children:[(0,r.jsx)($.A,{sx:{minWidth:30,mt:.5},children:function(e){switch(e){case"image":return(0,r.jsx)(tu.A,{fontSize:"small",sx:{color:"#009688"}});case"audio":return(0,r.jsx)(tp.A,{fontSize:"small",sx:{color:"#009688"}});case"link":return(0,r.jsx)(tf.A,{fontSize:"small",sx:{color:"#009688"}});default:return(0,r.jsx)(tc.A,{fontSize:"small",sx:{color:"#009688"}})}}(e.kind)}),(0,r.jsx)(D.A,{primary:(0,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap"},children:[(0,r.jsx)(u.default,{variant:"body2",sx:{fontWeight:500},children:null!=(t=e.name)?t:"".concat(e.kind,"-").concat(e.id.slice(0,8))}),e.mimeType&&(0,r.jsx)(p.A,{label:e.mimeType,size:"small",variant:"outlined",sx:{height:18,fontSize:"0.65rem"}}),(0,r.jsx)(u.default,{variant:"caption",color:"text.secondary",children:function(e){return e<1024?"".concat(e," B"):e<1048576?"".concat(Math.round(e/1024)," KB"):"".concat((e/1048576).toFixed(1)," MB")}(e.size)})]}),secondary:(0,r.jsxs)(u.default,{variant:"caption",color:"text.secondary",component:"span",sx:{wordBreak:"break-all"},children:["by ",function(e){var t,n,r,o,a;let l=e.producedBy;switch(l.source){case"tool-result":return"tool ".concat(null!=(t=l.server)?t:"?","/").concat(null!=(n=l.toolName)?n:"?");case"capture":return"step ".concat(null!=(o=null!=(r=l.nodeName)?r:l.nodeId)?o:"?");case"mcp-link":return"link from ".concat(null!=(a=l.server)?a:"?");default:return"run"}}(e),e.readBy.length>0?" \xb7 read ".concat(e.readBy.length,"\xd7"):""," \xb7 ",e.uri]})})]},e.id)})})},tm=(0,ej.h)("frontend/components/Chat/DebuggerCanvas"),tx={start:tl.vm,process:tl.Uw,finish:tl.IK,mcp:tl.v2,subflow:tl.lA,resource:tl.z9},tv={custom:ti.jY,mcpEdge:ti.oY,resourceEdge:ti.sZ},tb=(0,tr.Ay)(q.A)(e=>{let{theme:t}=e;return{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",padding:t.spacing(1)}}),ty=(0,tr.Ay)(l.default)(e=>{let{theme:t}=e;return{padding:t.spacing(1,2),borderBottom:"1px solid ".concat(t.palette.divider)}}),tj=(0,tr.Ay)(l.default)({flexGrow:1,display:"flex",overflow:"hidden"}),tw=(0,tr.Ay)(l.default)(e=>{let{theme:t}=e;return{width:"200px",borderRight:"1px solid ".concat(t.palette.divider),overflowY:"auto",padding:t.spacing(1)}}),tA=(0,tr.Ay)(l.default)({flexGrow:1,position:"relative",height:"100%"}),tS=(0,tr.Ay)(l.default)(e=>{let{theme:t}=e;return{width:"300px",borderLeft:"1px solid ".concat(t.palette.divider),overflowY:"auto",padding:t.spacing(2)}}),tI=(0,tr.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"}}),tC=e=>{var t,n,a,c;let{debugState:p,conversationId:h,onStep:g,onStepOver:m,onContinue:x,onCancel:v,isLoading:b,breakpoints:y,onToggleBreakpoint:j,onClose:w,liveActivity:A}=e,S=(0,to.A)(),[I,C]=(0,o.useState)(p.executionTrace&&p.executionTrace.length>0?p.executionTrace.length-1:-1),[k,E]=(0,o.useState)(!0),[T,N]=(0,o.useState)(!0),[F,_]=(0,o.useState)(null),[M,O]=(0,o.useState)(!0),[L,B]=(0,o.useState)(null),[H,q,U]=(0,ta.ck)([]),[J,Y,G]=(0,ta.fM)([]);(0,o.useEffect)(()=>{var e;let t=(null==(e=p.executionTrace)?void 0:e.length)||0;t>0?(C(e=>Math.min(e,t-1)),I<t-1&&C(t-1)):C(-1)},[p.executionTrace]),(0,o.useEffect)(()=>{(async()=>{if(!p.flowId){B("Flow ID is missing in debug state."),O(!1);return}O(!0),B(null);try{tm.debug("Loading flow definition for ID: ".concat(p.flowId));let e=await e6.g.getFlow(p.flowId);if(!e)throw Error("Flow with ID ".concat(p.flowId," not found."));_(e),tm.info("Flow definition loaded: ".concat(e.name))}catch(e){tm.error("Error loading flow definition:",e),B(e instanceof Error?e.message:"Failed to load flow definition."),_(null)}finally{O(!1)}})()},[p.flowId]),(0,o.useEffect)(()=>{if(F){tm.debug("Setting nodes and edges from flow definition");let e=F.nodes.map(e=>({...e,draggable:!1,selectable:!1,connectable:!1})),t=F.edges.map(e=>({...e,selectable:!1}));q(e),Y(t)}},[F,q,Y]);let X=(0,o.useCallback)(()=>{if(tm.debug("Previous button clicked. Current index: ".concat(I)),I>0){let e=I-1;tm.debug("Setting current step index to: ".concat(e)),C(e)}else tm.debug("Already at the first step, cannot go previous.")},[I]),$=(0,o.useCallback)(()=>{var e;if(tm.debug("Next button clicked. Current index: ".concat(I,", Trace length: ").concat(null==(e=p.executionTrace)?void 0:e.length)),p.executionTrace&&I<p.executionTrace.length-1){let e=I+1;tm.debug("Navigating to next trace step: ".concat(e)),C(e)}else tm.info("At end of trace, triggering API call for next step."),g()},[I,p.executionTrace,g]),Z=(0,o.useMemo)(()=>{if(p.executionTrace&&I>=0&&I<p.executionTrace.length)return p.executionTrace[I]},[p.executionTrace,I]),[ee,et]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{if(!A)return;let e=()=>{let e=Date.now();return[...Object.values(A.byNode),...Object.values(A.byResource),...Object.values(A.byResourceName)].some(t=>e-t.ts<4e3)};if(!e())return;let t=setInterval(()=>{et(Date.now()),e()||clearInterval(t)},350);return()=>clearInterval(t)},[A]);let en=(0,o.useCallback)(e=>{var t,n;if(!A)return null;let r=A.byNode[e.id];if(r&&ee-r.ts<4e3)return r;let o=e.data;if((null!=(t=null==o?void 0:o.type)?t:e.type)!=="resource")return null;let a=null!=(n=null==o?void 0:o.properties)?n:{},l="run"===a.scope?"string"==typeof a.runName?A.byResourceName[a.runName]:void 0:"string"==typeof a.boundServer&&"string"==typeof a.uri?A.byResource[td(a.boundServer,a.uri)]:void 0;return l&&ee-l.ts<4e3?{kind:"read"===l.kind?"resource-read":"resource-write",ts:l.ts}:null},[A,ee]),er=(0,o.useMemo)(()=>{let e=null==Z?void 0:Z.nodeId;return H.map(t=>{var n;let r=t.id===e,o=null==y?void 0:y.includes(t.id),a=r?null:en(t),l=a?Math.max(.25,1-(ee-a.ts)/4e3):0,i=(null==a?void 0:a.kind)==="active"?S.palette.primary.main:"#009688";return{...t,style:{...t.style,border:r?"2px solid ".concat(S.palette.warning.main):a?"2px solid ".concat(i):o?"2px dashed ".concat(S.palette.error.main):null==(n=t.style)?void 0:n.border,boxShadow:r?"0 0 10px ".concat(S.palette.warning.light):a?"0 0 ".concat("resource-write"===a.kind?14:10,"px ").concat(i).concat(Math.round(255*l).toString(16).padStart(2,"0")):void 0}}})},[H,Z,y,S,en,ee]);return(0,r.jsxs)(tb,{elevation:2,children:[(0,r.jsxs)(ty,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,r.jsxs)(l.default,{children:[(0,r.jsx)(u.default,{variant:"h6",children:"Flow Debugger"}),(0,r.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,r.jsxs)(l.default,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,r.jsx)(i.A,{title:k?"Hide execution trace":"Show execution trace",children:(0,r.jsx)(s.A,{size:"small",onClick:()=>E(e=>!e),color:k?"primary":"default","aria-label":k?"Hide execution trace":"Show execution trace",children:(0,r.jsx)(tn.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})})}),(0,r.jsx)(i.A,{title:T?"Hide step inspector":"Show step inspector",children:(0,r.jsx)(s.A,{size:"small",onClick:()=>N(e=>!e),color:T?"primary":"default","aria-label":T?"Hide step inspector":"Show step inspector",children:(0,r.jsx)(tn.A,{fontSize:"small"})})}),w&&(0,r.jsx)(i.A,{title:"Close debugger",children:(0,r.jsx)(s.A,{size:"small",onClick:w,"aria-label":"Close debugger",children:(0,r.jsx)(eO.A,{fontSize:"small"})})})]})]}),(0,r.jsxs)(tj,{children:[k&&(0,r.jsxs)(tw,{children:[(0,r.jsx)(u.default,{variant:"subtitle2",gutterBottom:!0,children:"Execution Trace"}),(0,r.jsxs)(R.A,{dense:!0,disablePadding:!0,children:[null==(t=p.executionTrace)?void 0:t.map((e,t)=>(0,r.jsx)(z.Ay,{disablePadding:!0,children:(0,r.jsx)(P.A,{selected:t===I,onClick:()=>(e=>{p.executionTrace&&e>=0&&e<p.executionTrace.length?(tm.debug("Trace step selected: ".concat(e)),C(e)):tm.warn("Invalid step index selected: ".concat(e)),C(e),C(e)})(t),children:(0,r.jsx)(D.A,{primary:"".concat(e.stepIndex,": ").concat(e.nodeName||e.nodeId),secondary:e.nodeType})})},e.stepIndex)),b&&(0,r.jsx)(z.Ay,{children:(0,r.jsx)(W.default,{size:20,sx:{margin:"auto"}})})]})]}),(0,r.jsx)(tA,{children:M?(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,r.jsx)(W.default,{})}):L?(0,r.jsx)(d.A,{severity:"error",sx:{margin:2},children:L}):(0,r.jsxs)(ta.Ln,{children:[" ",(0,r.jsx)(ta.Gc,{nodes:er,edges:J,onNodesChange:U,onEdgesChange:G,nodeTypes:tx,edgeTypes:tv,fitView:!0,attributionPosition:"bottom-right",nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!1,onNodeClick:(e,t)=>{e.preventDefault(),j&&j(t.id)},onEdgeClick:e=>e.preventDefault(),onPaneClick:()=>{},children:" "})]})}),T&&(0,r.jsxs)(tS,{children:[(0,r.jsx)(u.default,{variant:"subtitle2",gutterBottom:!0,children:"Step Inspector"}),Z?(0,r.jsxs)(l.default,{children:[(0,r.jsxs)(u.default,{variant:"body2",children:[(0,r.jsx)("b",{children:"Node:"})," ",Z.nodeName," (",Z.nodeId,")"]}),(0,r.jsxs)(u.default,{variant:"body2",children:[(0,r.jsx)("b",{children:"Type:"})," ",Z.nodeType]}),(0,r.jsxs)(u.default,{variant:"body2",children:[(0,r.jsx)("b",{children:"Timestamp:"})," ",new Date(Z.timestamp).toLocaleString()]}),(0,r.jsxs)(u.default,{variant:"body2",children:[(0,r.jsx)("b",{children:"Action Taken:"})," ",Z.actionTaken]}),(0,r.jsxs)(Q.A,{sx:{mt:2,boxShadow:"none","&:before":{display:"none"}},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,r.jsx)(u.default,{variant:"caption",children:"Prep Result"})}),(0,r.jsx)(V.A,{sx:{p:0},children:(0,r.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(Z.prepResultSnapshot,null,2)})})]}),(0,r.jsxs)(Q.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,r.jsxs)(u.default,{variant:"caption",color:(null==(n=Z.execResultSnapshot)?void 0:n.success)===!1?"error":"inherit",children:["Exec Result ",(null==(a=Z.execResultSnapshot)?void 0:a.success)===!1?"(Error)":""]})}),(0,r.jsx)(V.A,{sx:{p:0},children:(null==(c=Z.execResultSnapshot)?void 0:c.success)===!1?(0,r.jsxs)(l.default,{sx:{p:1,background:S.palette.error.light,borderRadius:1},children:[" ",(0,r.jsxs)(u.default,{variant:"body2",color:"error",gutterBottom:!0,children:[(0,r.jsx)("b",{children:"Error:"})," ",Z.execResultSnapshot.error||"Unknown error"]}),Z.execResultSnapshot.errorDetails&&(0,r.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(Z.execResultSnapshot.errorDetails,null,2)})]}):(0,r.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(Z.execResultSnapshot,null,2)})})]}),(0,r.jsxs)(Q.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,r.jsx)(u.default,{variant:"caption",children:"State Before"})}),(0,r.jsx)(V.A,{sx:{p:0},children:(0,r.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(Z.stateBefore,null,2)})})]}),(0,r.jsxs)(Q.A,{sx:{boxShadow:"none","&:before":{display:"none"}},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,r.jsx)(u.default,{variant:"caption",children:"State After"})}),(0,r.jsx)(V.A,{sx:{p:0},children:(0,r.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(Z.stateAfter,null,2)})})]})]}):(0,r.jsx)(u.default,{variant:"body2",color:"textSecondary",children:"Select a step from the trace."}),(0,r.jsxs)(Q.A,{defaultExpanded:!0,sx:{mt:2,boxShadow:"none","&:before":{display:"none"}},children:[(0,r.jsx)(K.A,{expandIcon:(0,r.jsx)(el.A,{}),sx:{minHeight:"36px","& .MuiAccordionSummary-content":{margin:"8px 0"}},children:(0,r.jsx)(u.default,{variant:"caption",children:"Run Data"})}),(0,r.jsx)(V.A,{sx:{p:0},children:(0,r.jsx)(tg,{conversationId:h,refreshToken:null==A?void 0:A.resourceVersion})})]})]})]}),(0,r.jsxs)(tI,{children:[(0,r.jsx)(f.A,{variant:"outlined",size:"small",onClick:X,disabled:b||I<=0,children:"Previous"}),(0,r.jsx)(f.A,{variant:"contained",size:"small",onClick:$,disabled:b||-1===I,children:p.executionTrace&&I<p.executionTrace.length-1?"Next Trace Step":"Step Next"}),m&&(0,r.jsx)(f.A,{variant:"outlined",size:"small",onClick:m,disabled:b,children:"Step Over"}),(0,r.jsx)(f.A,{variant:"contained",color:"secondary",size:"small",onClick:x,disabled:b,children:"Continue"}),(0,r.jsx)(f.A,{variant:"outlined",color:"error",size:"small",onClick:v,disabled:b,children:"Stop"})]})]})};function tk(e){return"string"==typeof e&&e.startsWith("quickchat-")}n(77890);var tE=n(94929),tT=n(29155),tN=n(63650);let tR=(0,ej.h)("frontend/services/chat/index");class tz extends Error{constructor(e,t,n){super(e),this.name="ChatApiError",this.status=t,this.body=n}}let tD="/v1/chat/conversations";async function tP(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 tz(t&&"object"==typeof t&&(t.error||t.message)||"Request failed with status ".concat(e.status),e.status,t);return t}class tF{async listConversations(){return tR.debug("listConversations: Entering method"),tP(await fetch(tD))}async getConversation(e){return tR.debug("getConversation: Entering method",{conversationId:e}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e))))}async createConversation(e){return tR.debug("createConversation: Entering method",{conversationId:e.id}),tP(await fetch(tD,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}))}async updateConversationFlow(e,t){return tR.debug("updateConversationFlow: Entering method",{conversationId:e,flowId:t}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:t})}))}async updateConversationTitle(e,t){return tR.debug("updateConversationTitle: Entering method",{conversationId:e}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t})}))}async updateConversationApproval(e,t){return tR.debug("updateConversationApproval: Entering method",{conversationId:e,requireApproval:t}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApproval:t})}))}async deleteConversation(e){tR.debug("deleteConversation: Entering method",{conversationId:e});let t=await fetch("".concat(tD,"/").concat(encodeURIComponent(e)),{method:"DELETE"});await tP(t)}async respondToToolCall(e,t,n){return tR.debug("respondToToolCall: Entering method",{conversationId:e,action:t,toolCallId:n}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e),"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,toolCallId:n})}))}async debugStep(e){return tR.debug("debugStep: Entering method",{conversationId:e}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e),"/debug/step"),{method:"POST"}))}async debugContinue(e){return tR.debug("debugContinue: Entering method",{conversationId:e}),tP(await fetch("".concat(tD,"/").concat(encodeURIComponent(e),"/debug/continue"),{method:"POST"}))}async setBreakpoints(e,t){tR.debug("setBreakpoints: Entering method",{conversationId:e,count:t.length});let n=await fetch("".concat(tD,"/").concat(encodeURIComponent(e),"/breakpoints"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({breakpoints:t})});await tP(n)}async synthesizeQuickChat(e){return tR.debug("synthesizeQuickChat: Entering method",{conversationId:e.conversationId}),tP(await fetch("/api/flow/quick-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}))}async cancel(e){tR.debug("cancel: Entering method",{conversationId:e});let t=await fetch("".concat(tD,"/").concat(encodeURIComponent(e),"/cancel"),{method:"POST"});await tP(t)}subscribeToEvents(e,t,n){let r=new EventSource(void 0!==n?"".concat(tD,"/").concat(encodeURIComponent(e),"/events?fromSeq=").concat(n):"".concat(tD,"/").concat(encodeURIComponent(e),"/events"));return r.onopen=()=>{var n;tR.debug("Execution event stream open",{conversationId:e}),null==(n=t.onOpen)||n.call(t)},r.onmessage=e=>{try{t.onEvent(JSON.parse(e.data))}catch(e){tR.warn("Failed to parse SSE event",{err:e})}},r.onerror=e=>{var n;tR.debug("SSE stream error (browser will retry if still open)"),null==(n=t.onError)||n.call(t,e)},r}}let t_=new tF,tM=(0,ej.h)("frontend/components/Chat/index");function tO(e){var t;if(Array.isArray(e.content))return e.content;let n="string"==typeof e.content?e.content:"",r=null!=(t=e.attachments)?t:[],o=r.filter(e=>"image"!==e.type),a=r.filter(e=>"image"===e.type);if(o.length>0&&(n+="\n\n"+o.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 tW=/cancelled by user|execution cancelled/i,tL=e=>{var t,n;return(null==e?void 0:e.code)==="cancelled"||(null==e||null==(t=e.error)?void 0:t.code)==="cancelled"||[null==e?void 0:e.message,"string"==typeof(null==e||null==(n=e.body)?void 0:n.error)?e.body.error:void 0].some(e=>"string"==typeof e&&tW.test(e))},tB=()=>{var e;let[t,n]=(0,o.useState)([]),[a,N]=(0,o.useState)(!0),[R,z]=(0,o.useState)(null),[D,P]=(0,o.useState)(null),[F,_]=(0,o.useState)(!1),[M,W]=(0,o.useState)(null),[L,B]=(0,T.Mj)(T.Zg.CURRENT_CONVERSATION_ID,null),[H,q]=(0,T.Mj)(T.Zg.LAST_PICKED_FLOW_ID,null),[U,J]=(0,o.useState)(!1),[Y,G]=(0,o.useState)(new Set),Q=(0,o.useCallback)((e,t)=>{e&&G(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),[K,V]=(0,o.useState)(null),[X,$]=(0,o.useState)([]),[Z,ee]=(0,o.useState)(!1),[et,en]=(0,o.useState)(!1),[er,eo]=(0,o.useState)(""),[ea,el]=(0,o.useState)(!1),[ei,es]=(0,o.useState)(null),[ed,ec]=(0,o.useState)(null),[eu,ep]=(0,o.useState)(null),[ef,eh]=(0,o.useState)(!1),[eg,em]=(0,o.useState)(null),[ex,ev]=(0,o.useState)(!1),[eb,ey]=(0,o.useState)(()=>{let e=Number(window.localStorage.getItem("flujo-debugger-width"));return Number.isFinite(e)&&e>0?e:0}),ej=(0,o.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 r=e=>{ey(Math.min(Math.max(window.innerWidth-e.clientX,360),Math.round(.85*window.innerWidth)))},o=()=>{window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",o),document.body.style.userSelect=t,document.body.style.cursor=n,ey(e=>(e>0&&window.localStorage.setItem("flujo-debugger-width",String(Math.round(e))),e))};window.addEventListener("pointermove",r),window.addEventListener("pointerup",o)},[]),[ew,eA]=(0,o.useState)(()=>{let e=Number(window.localStorage.getItem("flujo-chat-sidebar-width"));return Number.isFinite(e)&&e>0?e:300}),[eS,eI]=(0,o.useState)(()=>"1"===window.localStorage.getItem("flujo-chat-sidebar-collapsed")),eC=(0,o.useCallback)(()=>{eI(e=>{let t=!e;return window.localStorage.setItem("flujo-chat-sidebar-collapsed",t?"1":"0"),t})},[]),ek=(0,o.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 r=e=>{eA(Math.min(Math.max(e.clientX,220),560))},o=()=>{window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",o),document.body.style.userSelect=t,document.body.style.cursor=n,eA(e=>(e>0&&window.localStorage.setItem("flujo-chat-sidebar-width",String(Math.round(e))),e))};window.addEventListener("pointermove",r),window.addEventListener("pointerup",o)},[]),[eE,eT]=(0,o.useState)(null),[eN,ez]=(0,o.useState)(ts),[eD,eP]=(0,o.useState)([]),[eF,e_]=(0,o.useState)(null),eM=(0,o.useRef)(null),eO=(0,o.useRef)(null),eW=(0,o.useRef)(null),eL=(0,o.useRef)(-1),eB=(0,o.useRef)(L);(0,o.useEffect)(()=>{eB.current=L},[L]);let eq=(0,o.useRef)(new Set),eJ=(0,o.useRef)(new Set),eG=(0,o.useRef)(new Set),[eQ,eK]=(0,o.useState)(new Set),eV=(0,o.useCallback)((e,t)=>{e&&(t?eG.current.add(e):eG.current.delete(e),eK(new Set(eG.current)))},[]),eX=(0,o.useRef)(null),e$=(0,o.useRef)(!0),[eZ,e0]=(0,o.useState)(!1),e1=(0,o.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"auto",t=eX.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),e5=(0,o.useCallback)(()=>{let e=eX.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;e$.current=t,e0(!t)},[]),e4=(0,o.useCallback)(()=>{e$.current=!0,e0(!1),e1("smooth")},[e1]);(0,o.useEffect)(()=>{e$.current=!0,e0(!1)},[L]),(0,o.useEffect)(()=>{e$.current&&e1("auto")},[null==D?void 0:D.messages,e1]);let e8=(0,o.useRef)(null);(0,o.useEffect)(()=>{e8.current=eF},[eF]),(0,o.useEffect)(()=>{let e=window.location.origin+"/v1";eM.current=new tT.Ay({baseURL:e,apiKey:"FLUJO",dangerouslyAllowBrowser:!0,maxRetries:0,timeout:18e6})},[]),(0,o.useEffect)(()=>{(async()=>{tM.debug("Loading flows");try{let e=await e6.g.loadFlows();$(e)}catch(e){tM.error("Error loading flows:",e)}})()},[]);let e3=(0,o.useCallback)(async(e,t)=>{var r;let o=null!=(r=null==t?void 0:t.silent)&&r;tM.debug("Fetching conversation list from backend",{silent:o}),o||(N(!0),z(null));let a=[],l=!1;try{for(let e of a=(await t_.listConversations()).filter(e=>!eJ.current.has(e.id)).sort((e,t)=>t.updatedAt-e.updatedAt))eq.current.delete(e.id);n(e=>{let t=e.filter(e=>eq.current.has(e.id)),n=t.length>0?[...t,...a].sort((e,t)=>t.updatedAt-e.updatedAt):a;return((e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.title===r.title&&e.flowId===r.flowId&&e.status===r.status&&e.createdAt===r.createdAt&&e.updatedAt===r.updatedAt}))(e,n)?e:n}),tM.info("Fetched ".concat(a.length," conversations for the list"))}catch(e){l=!0,tM.error("Error fetching conversation list:",e),o||(z("Failed to load conversation history."),n([]))}finally{if(o||N(!1),o||l)return;let t=void 0!==e?e:eB.current,n=eB.current;if(t&&(e=>a.some(t=>t.id===e)||eq.current.has(e))(t))t!==n&&(tM.debug("Setting currentConversationId to ".concat(t," after fetch/operation.")),B(t));else if(a.length>0){let e=a[0].id;e!==n&&(tM.debug("Selecting most recent conversation ".concat(e," after fetch/operation.")),B(e))}else null===n||eq.current.has(n)||(tM.debug("No conversations available after fetch/operation, clearing selection."),B(null))}},[B]);(0,o.useEffect)(()=>{e3()},[]),(0,o.useEffect)(()=>{let e=()=>{("undefined"==typeof document||"visible"===document.visibilityState)&&e3(void 0,{silent:!0})},t=setInterval(e,5e3);return document.addEventListener("visibilitychange",e),()=>{clearInterval(t),document.removeEventListener("visibilitychange",e)}},[e3]);let e9=(0,o.useCallback)(async e=>{if(eq.current.has(e))return void tM.debug("Skipping detail fetch for client-only conversation",{conversationId:e});if(eB.current!==e){tM.debug("Detail fetch requested for non-viewed conversation; refreshing list instead",{conversationId:e}),e3(void 0,{silent:!0});return}tM.debug("Fetching detailed conversation",{conversationId:e}),_(!0),W(null),P(null);try{let t=await t_.getConversation(e);if(eB.current!==e)return void tM.debug("Discarding stale detailed conversation response",{fetchedId:e,currentId:eB.current});P(t),n(n=>n.map(n=>{var r;return n.id===e?{...n,title:t.title,flowId:t.flowId,updatedAt:t.updatedAt,status:null!=(r=t.status)?r:n.status}:n}).sort((e,t)=>t.updatedAt-e.updatedAt)),tM.info("Fetched detailed conversation successfully",{conversationId:e})}catch(t){if(tM.error("Error fetching detailed conversation:",{conversationId:e,err:t}),eB.current!==e)return;t instanceof tz&&404===t.status?(W("Conversation ".concat(e," not found.")),B(null),e3()):W("Failed to load details for conversation ".concat(e,".")),P(null)}finally{eB.current===e&&_(!1)}},[e3,B]);(0,o.useEffect)(()=>{es(null),ep(null),L?e9(L):(P(null),_(!1),W(null))},[L,e9]),(0,o.useEffect)(()=>{if(D){var e;ee(null!=(e=D.requireApproval)&&e)}},[null==D?void 0:D.id]);let te=(0,o.useCallback)(async e=>{if(ee(e),L)try{await t_.updateConversationApproval(L,e)}catch(e){tM.warn("Failed to persist requireApproval setting",{conversationId:L,err:e})}},[L]),tn=t.find(e=>e.id===L)||null,tr=(0,o.useMemo)(()=>{var e,t;return(null==(t=X.find(e=>e.id===(null==D?void 0:D.flowId)))||null==(e=t.nodes)?void 0:e.map(e=>({id:e.id,label:e.data.label||e.id})))||[]},[X,null==D?void 0:D.flowId]),to=(0,o.useMemo)(()=>{var e,t,n;let r=e=>!!e&&tr.some(t=>t.id===e);if(r(eu))return eu;if(r(null==D?void 0:D.currentNodeId))return D.currentNodeId;let o=null!=(t=null==D?void 0:D.messages)?t:[];for(let e=o.length-1;e>=0;e--){let t=o[e];if("assistant"===t.role&&r(t.processNodeId))return t.processNodeId}return null!=(n=null==(e=tr[0])?void 0:e.id)?n:null},[eu,D,tr]),ta=async()=>{var e,t,r;tM.debug("Attempting to create new conversation"),V(null);let o=H&&!tk(H)?X.find(e=>e.id===H):void 0,a=(null==(e=null!=(t=null!=o?o:X.find(e=>e.favorite))?t:X[0])?void 0:e.id)||null;if(!a){tM.error("Cannot create conversation: No flows available or first flow has no ID."),V("Cannot create a new conversation: No flows available.");return}let l=(0,eH.A)(),i=Date.now(),s={id:l,title:"New Conversation",flowId:a,createdAt:i,updatedAt:i};try{tM.info("Sending request to create conversation on backend",{payload:JSON.stringify(s)});let e=await t_.createConversation(s);tM.info("Successfully created conversation on backend",{conversationId:e.id}),n(t=>[e,...t].sort((e,t)=>t.updatedAt-e.updatedAt)),B(e.id),P({id:e.id,title:e.title,flowId:e.flowId,createdAt:e.createdAt,updatedAt:e.updatedAt,messages:[]}),_(!1),W(null)}catch(t){tM.error("Error creating conversation on backend:",t);let e="Failed to create conversation on the server.";t instanceof tz?e+=" Error: ".concat((null==(r=t.body)?void 0:r.error)||t.message):t instanceof Error&&(e+=" Error: ".concat(t.message)),V(e)}},[tl,ti]=(0,o.useState)(!1),tc=async e=>{V(null);let t=(0,eH.A)(),{flow:r}=await t_.synthesizeQuickChat({conversationId:t,modelId:e.modelId,servers:e.servers,systemPrompt:e.systemPrompt}),o=Date.now(),a=await t_.createConversation({id:t,title:"Quick Chat",flowId:r.id,flowSnapshot:r,createdAt:o,updatedAt:o});n(e=>[a,...e].sort((e,t)=>t.updatedAt-e.updatedAt)),B(a.id),P({id:a.id,title:a.title,flowId:a.flowId,createdAt:a.createdAt,updatedAt:a.updatedAt,messages:[]}),_(!1),W(null),ti(!1)},tu=(0,o.useCallback)(e=>{tM.debug("Updating detailed conversation state locally",{conversationId:e.id});let t={...e,updatedAt:Date.now()};P(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))},[]),tp=(0,o.useCallback)(()=>{eW.current&&(tM.debug("Closing execution event stream"),eW.current.close(),eW.current=null)},[]),tf=(0,o.useCallback)((e,t)=>{n(n=>{let r=n.findIndex(t=>t.id===e);if(-1===r||n[r].status===t)return n;let o=[...n];return o[r]={...o[r],status:t},o})},[]),th=(0,o.useCallback)(e=>{if("number"==typeof e.seq){if(e.seq<=eL.current)return;eL.current=e.seq}let t=e=>eT(t=>{var n,r,o,a;return{totalTokens:null!=(r=null!=(n=e.totalTokens)?n:null==t?void 0:t.totalTokens)?r:0,activeNode:void 0!==e.activeNode?e.activeNode:null!=(o=null==t?void 0:t.activeNode)?o:null,startedAt:null!=(a=null==t?void 0:t.startedAt)?a:Date.now(),lastEventAt:Date.now()}}),n=e=>ez(t=>{let n=Date.now(),r={byNode:{...t.byNode},byResource:{...t.byResource},byResourceName:{...t.byResourceName},resourceVersion:t.resourceVersion};return e(r),function(e,t){let n=e=>{let n={};for(let[r,o]of Object.entries(e))t-o.ts<4e3&&(n[r]=o);return n};return{byNode:n(e.byNode),byResource:n(e.byResource),byResourceName:n(e.byResourceName),resourceVersion:e.resourceVersion}}(r,n)});switch(e.type){case"run:start":eT({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),ez(ts),e.conversationId&&(tf(e.conversationId,"running"),eV(e.conversationId,!1));break;case"message":{let n=e.message;t({}),P(t=>{let r;if(!t||t.id!==e.conversationId)return t;let o=t.messages.findIndex(e=>e.id===n.id);return o>=0?(r=[...t.messages])[o]={...r[o],...n}:r=[...t.messages,n],{...t,messages:r}});break}case"usage":eT(t=>{var n,r,o;return{totalTokens:(null!=(n=null==t?void 0:t.totalTokens)?n:0)+(e.totalTokens||0),activeNode:null!=(r=null==t?void 0:t.activeNode)?r:null,startedAt:null!=(o=null==t?void 0:t.startedAt)?o:Date.now(),lastEventAt:Date.now()}});break;case"node:enter":var r,o,a;if(t({activeNode:(null==(r=e.node)?void 0:r.nodeName)||(null==(o=e.node)?void 0:o.nodeId)||null}),null==(a=e.node)?void 0:a.nodeId){let t=e.node.nodeId;n(e=>{e.byNode[t]={kind:"active",ts:Date.now()}})}break;case"resource:read":case"resource:write":{let r="resource:read"===e.type?"read":"write";n(t=>{var n;let o=Date.now();(null==(n=e.node)?void 0:n.nodeId)&&(t.byNode[e.node.nodeId]={kind:"read"===r?"resource-read":"resource-write",ts:o}),e.server&&e.uri&&(t.byResource[td(e.server,e.uri)]={kind:r,ts:o}),e.name&&(t.byResourceName[e.name]={kind:r,ts:o}),"write"===r&&(t.resourceVersion=t.resourceVersion+1)}),t({});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===eB.current&&es(e.pendingToolCalls||[]),e.conversationId&&tf(e.conversationId,"awaiting_tool_approval");break;case"breakpoint:hit":case"run:paused":J(!1),e.conversationId&&(Q(e.conversationId,!1),tf(e.conversationId,"paused_debug")),eh(!0);break;case"run:done":if(e.conversationId&&(Q(e.conversationId,!1),tf(e.conversationId,e.status)),e.conversationId&&e8.current&&e.conversationId!==e8.current)break;eT(null),ez(ts),J(!1),e_(null),tp(),e.conversationId&&e.conversationId===eB.current?e9(e.conversationId):e3(void 0,{silent:!0});break;case"error":V(e.message||"Execution error");break;default:t({})}},[tp,e9,e3,Q,tf,eV]),tg=(0,o.useCallback)((e,t)=>(tp(),eL.current=void 0!==t?t-1:-1,new Promise(n=>{let r=!1,o=()=>{r||(r=!0,n())};try{eW.current=t_.subscribeToEvents(e,{onEvent:th,onOpen:o},t),setTimeout(o,1500)}catch(t){tM.error("Failed to open execution event stream",{conversationId:e,err:t}),o()}})),[th,tp]);(0,o.useEffect)(()=>{if(L&&(null==tn?void 0:tn.status)==="running"&&e8.current!==L){if(eG.current.has(L))return void tM.debug("Skipping re-attach to a conversation the user just stopped",{conversationId:L});tM.info("Re-attaching to in-progress run",{conversationId:L}),e8.current=L,J(!0),e_(L),Q(L,!0),eT(e=>null!=e?e:{totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),tg(L,0)}},[L,null==tn?void 0:tn.status,tg]);let tm=async e=>{tM.debug("Attempting to delete conversation",{conversationId:e}),V(null),eJ.current.add(e);let r=eq.current.delete(e);e8.current===e&&(tp(),J(!1),e_(null),eT(null)),Q(e,!1);let o=t.filter(t=>t.id!==e);n(o);let a=L;L===e&&(o.length>0?(a=o[0].id,tM.debug("Deleted current conversation, selecting next most recent",{nextSelectionId:a})):(a=null,tM.debug("Deleted last conversation, clearing selection")),B(a));try{await t_.deleteConversation(e),tM.info("Successfully deleted conversation on backend",{conversationId:e})}catch(o){tM.error("Error deleting conversation:",{conversationId:e,err:o}),V("Failed to delete conversation ".concat(e,". Please try again.")),eJ.current.delete(e),r&&eq.current.add(e),n(t),B(L)}},tx=async e=>{if(tM.debug("Flow selected, attempting to update",{flowId:e,currentConversationId:L}),V(null),!L){tM.warn("Cannot update flow: No conversation selected."),V("Please select a conversation first.");return}D&&D.id===L&&P({...D,flowId:e,updatedAt:Date.now()}),n(t=>t.map(t=>t.id===L?{...t,flowId:e,updatedAt:Date.now()}:t).sort((e,t)=>t.updatedAt-e.updatedAt));try{let t=await t_.updateConversationFlow(L,e);tM.info("Successfully updated flowId on backend",{conversationId:L,flowId:e}),P(e=>e&&e.id===L?(tM.debug("Confirming detailedConversation update from server response",{conversationId:L,flowId:t.flowId}),{...e,flowId:t.flowId,updatedAt:t.updatedAt}):(tM.debug("Skipping detailedConversation update, ID mismatch or null state",{currentDetailedId:null==e?void 0:e.id,targetId:L}),e)),n(e=>e.map(e=>e.id===L?t:e).sort((e,t)=>t.updatedAt-e.updatedAt))}catch(a){tM.error("Error updating flowId on backend:",{conversationId:L,flowId:e,err:a});let o="Failed to update the selected flow.";if(a instanceof tz){var r;o+=" Error: ".concat((null==(r=a.body)?void 0:r.error)||a.message)}else a instanceof Error&&(o+=" Error: ".concat(a.message));V(o),P(D),n(t)}},tv=()=>{var e,t;eo(null!=(t=null!=(e=null==D?void 0:D.title)?e:null==tn?void 0:tn.title)?t:""),en(!0)},tb=async()=>{var e,t;if(en(!1),!L)return;let r=null!=(t=null!=(e=null==D?void 0:D.title)?e:null==tn?void 0:tn.title)?t:"",o=er.trim().slice(0,200);if(o&&o!==r){P(e=>e&&e.id===L?{...e,title:o}:e),n(e=>e.map(e=>e.id===L?{...e,title:o}:e));try{let e=await t_.updateConversationTitle(L,o);P(t=>t&&t.id===L?{...t,title:e.title}:t),n(t=>t.map(t=>t.id===L?{...t,title:e.title}:t))}catch(e){tM.warn("Failed to rename conversation",{conversationId:L,err:e}),P(e=>e&&e.id===L?{...e,title:r}:e),n(e=>e.map(e=>e.id===L?{...e,title:r}:e)),V("Failed to rename the conversation.")}}},ty=async function(e){var t,n;let r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e.trim()&&0===o.length)return;if(!D){tM.error("Cannot send message, detailed conversation not loaded."),V("Cannot send message: conversation details not loaded.");return}tM.debug("Sending message",{conversationId:D.id,contentLength:e.length,attachmentsCount:o.length});let a=D.messages,l=!a.some(e=>"user"===e.role),i=D.flowId;if(eu)r=eu,ep(null),tM.debug("Assigning manually picked node ID to user message: ".concat(r));else if(l){let e=X.find(e=>e.id===i),n=null==e||null==(t=e.nodes)?void 0:t[0];n?(r=n.id,tM.debug("Assigning start node ID to first user message: ".concat(r))):tM.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){r=t.processNodeId,tM.debug("Assigning last assistant node ID to user message: ".concat(r));break}}if(!r){let e=X.find(e=>e.id===i),t=null==e||null==(n=e.nodes)?void 0:n[0];t?(r=t.id,tM.debug("No prior assistant node ID found, falling back to start node ID: ".concat(r))):tM.warn("Could not find start node for fallback in flow ".concat(i,". User message will not have a processNodeId."))}}let s={id:(0,eH.A)(),role:"user",content:e,timestamp:Date.now(),attachments:o.length>0?o:void 0,processNodeId:r},d={...D,messages:[...D.messages,s]};tu(d),d.flowId?await tA(d):(V("Please select a flow for this conversation before sending messages"),P(D))},tj=(0,o.useCallback)((e,t)=>{tM.verbose("Handling API response data",JSON.stringify(e)),Q(t,"running"===e.status);let r=e8.current===t,o=eB.current===t;if("paused_debug"===e.status&&e.debugState)return(tM.info("API Response: Paused for debugging",{conversationId:t}),o)?(em(e.debugState),eh(!0),ev(!0),J(!1),e_(null),tp(),tw(),P(n=>(null==n?void 0:n.id)===t&&e.debugState.messages&&JSON.stringify(n.messages)!==JSON.stringify(e.debugState.messages)?(tM.debug("Updating detailed conversation messages from debug state"),{...n,messages:e.debugState.messages,updatedAt:e.debugState.updatedAt}):n),n(n=>n.map(n=>{var r,o;return n.id===t?{...n,title:null!=(r=e.debugState.title)?r:n.title,flowId:null!=(o=e.debugState.flowId)?o:n.flowId,status:"paused_debug",updatedAt:e.debugState.updatedAt}:n}).sort((e,t)=>t.updatedAt-e.updatedAt))):(tf(t,"paused_debug"),r&&(J(!1),e_(null),tp(),tw())),!0;if(("completed"===e.status||"error"===e.status)&&o?(tM.info("API Response: Execution completed or errored (Status: ".concat(e.status,"). Hiding debugger panel."),{conversationId:t}),eh(!1),em(null),ev(!1)):tM.debug("API Response: Status is '".concat(e.status,"'. Debugger panel visibility unchanged (currently ").concat(ef?"visible":"hidden",")."),{conversationId:t}),e.messages&&e.conversation_id===t){let n=e.messages.map((e,n)=>"number"!=typeof e.timestamp||isNaN(e.timestamp)?(tM.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);P(r=>{var o,a;let l=r;return(null==r?void 0:r.id)===t&&JSON.stringify(r.messages)!==JSON.stringify(n)&&(tM.info("API Response/Polling: Updating detailed conversation messages",{conversationId:t,newMessageCount:n.length}),l={...r,messages:n,updatedAt:e.updatedAt||r.updatedAt}),tM.debug("Polling: setDetailedConversation callback executed.",{conversationId:t,messagesChanged:l!==r,newMessageCount:null!=(a=null==l||null==(o=l.messages)?void 0:o.length)?a:"N/A"}),l})}if("awaiting_tool_approval"===e.status)tM.info("API Response/Polling: Pausing for tool approval",{conversationId:t}),o&&es(e.pendingToolCalls||[]),r&&(J(!1),e_(null),tp(),tw());else if("completed"===e.status||"error"===e.status){if(tM.info("API Response/Polling: Stopping due to final status",{conversationId:t,status:e.status}),r&&(tw(),J(!1),e_(null),tp()),"error"===e.status){var a,l;let n=(null==(a=e.error)?void 0:a.message)||(null==(l=e.lastResponse)?void 0:l.error)||"Unknown error during execution";tW.test(n)||eG.current.has(t)?(eV(t,!0),(r||o)&&V(null),tM.info("API Response/Polling: Execution cancelled by user",{conversationId:t})):(V(n),tM.error("API Response/Polling: Execution resulted in error",{conversationId:t,error:e.error||e.lastResponse}))}e9(t)}else"running"!==e.status||ef?o&&es(null):(o&&es(null),r&&!eO.current&&J(!0));return e.conversation_id===t&&n(n=>n.map(n=>{var r,o,a;return n.id===t?{...n,title:null!=(r=e.title)?r:n.title,flowId:null!=(o=e.flowId)?o:n.flowId,status:null!=(a=e.status)?a:n.status,updatedAt:e.updatedAt||n.updatedAt}:n}).sort((e,t)=>t.updatedAt-e.updatedAt)),!1},[P,es,J,V,eh,em,n,e9,tp,Q,tf,eV]),tw=()=>{eO.current&&(tM.debug("Stopping polling interval"),clearInterval(eO.current),eO.current=null)};(0,o.useEffect)(()=>()=>{tp()},[tp]);let tA=async e=>{if(!(null==e?void 0:e.id)||!e.flowId||!eM.current)return tM.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}),V("Cannot send message: Missing conversation ID or flow ID."),!1;es(null),V(null),J(!0),e_(e.id),Q(e.id,!0),eV(e.id,!1);let t=eq.current.delete(e.id);eT({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),await tg(e.id);let n=!1;try{let t;if(tk(e.flowId))t="flow-Quick Chat",tM.debug("Sending quick chat to completions",{flowId:e.flowId,conversationId:e.id});else{let n=await e6.g.getFlow(e.flowId);if(!n)throw Error("Flow with ID ".concat(e.flowId," not found"));t="flow-".concat(n.name),tM.debug("Sending to chat completions",{flowId:e.flowId,flowName:n.name,conversationId:e.id})}let r=e.messages.filter(e=>{var t;return!e.disabled&&!((null!=(t=e.depth)?t:0)>0)}).map(e=>{let t=tO(e),n=e.processNodeId,r={id:e.id,timestamp:e.timestamp};return"user"===e.role?{role:"user",content:t,...r,processNodeId:n}:"assistant"===e.role?{role:"assistant",content:t,tool_calls:e.tool_calls,...r,processNodeId:n}:"system"===e.role?{role:"system",content:t,...r,processNodeId:n}:"tool"===e.role?e.tool_call_id?{role:"tool",content:t,tool_call_id:e.tool_call_id,...r,processNodeId:n}:{role:"user",content:"string"==typeof t?"Tool result: ".concat(t):t,...r,processNodeId:n}:{role:"user",content:t,...r,processNodeId:n}}),o=await eM.current.chat.completions.create({model:t,messages:r,stream:!1,metadata:(()=>{let t={flujo:"true",requireApproval:Z?"true":void 0,flujodebug:ea?"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})()});tM.debug("Chat completion initial response received",{completionId:o.id}),n=!0;let a={...o,status:o.status||"completed",conversation_id:e.id,messages:o.messages||e.messages,pendingToolCalls:o.pendingToolCalls,debugState:o.debugState,error:o.error,lastResponse:o.lastResponse,updatedAt:o.updatedAt||Date.now()},l=tj(a,e.id);l||eO.current?l&&tM.debug("Debug state handled, polling remains stopped."):tM.debug("Starting polling after initial non-debug response.")}catch(a){if(tL(a)||eG.current.has(e.id))return tM.info("Chat completion cancelled by user",{conversationId:e.id}),n=!1,Q(e.id,!1),eV(e.id,!0),e8.current===e.id&&(tw(),J(!1),e_(null),tp(),V(null)),n;tM.error("Error calling chat completions API:",a),n=!1;let o="An error occurred while sending the message.";if(a instanceof tN.LG)o="API Error: ".concat(a.message," (Status: ").concat(a.status,")"),a.code&&(o+=" (Code: ".concat(a.code,")")),a.type&&(o+=" [Type: ".concat(a.type,"]")),tM.verbose("APIError details",JSON.stringify(a));else if(a instanceof tN.vc){o="OpenAI Error: ".concat(a.message);let e=a.error;e&&"object"==typeof e&&(e.code&&(o+=" (Code: ".concat(e.code,")")),e.type&&(o+=" [Type: ".concat(e.type,"]"))),tM.verbose("OpenAIError details",JSON.stringify(a))}else if(a instanceof tz){var r;o="Error: ".concat((null==(r=a.body)?void 0:r.error)||a.message),a.status&&(o+=" (Status: ".concat(a.status,")")),tM.verbose("ChatApiError details",JSON.stringify(a.body))}else a instanceof Error&&(o=a.message);V(o),Q(e.id,!1),e8.current===e.id&&(tw(),J(!1),e_(null),tp()),t&&eq.current.add(e.id)}finally{}return n},tS=async(e,t,n)=>{if(!D)return;tM.debug("Editing message",{messageId:e,contentLength:t.length,processNodeId:n});let r=D.messages.findIndex(t=>t.id===e);if(-1===r)return;let o={...D.messages[r],content:t,timestamp:Date.now(),processNodeId:n||void 0},a=[...D.messages.slice(0,r),o],l={...D,messages:a};if(tu(l),l.flowId){let e={flujo:"true",requireApproval:Z?"true":void 0,flujodebug:ea?"true":void 0,conversationId:l.id,processNodeId:n||void 0};if(!eM.current)return;V(null),J(!0),e_(l.id),Q(l.id,!0),eV(l.id,!1),eT({totalTokens:0,activeNode:null,startedAt:Date.now(),lastEventAt:Date.now()}),await tg(l.id);try{let t=await e6.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=tO(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}}),r=await eM.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})()}),o={...r,status:r.status||"completed",conversation_id:l.id,messages:r.messages||l.messages,pendingToolCalls:r.pendingToolCalls,debugState:r.debugState,error:r.error,updatedAt:r.updatedAt||Date.now()};tj(o,l.id)}catch(e){tL(e)||eG.current.has(l.id)?(tM.info("Edited-message run cancelled by user",{conversationId:l.id}),eV(l.id,!0)):(tM.error("Error sending edited message:",e),V(e instanceof Error?e.message:"Failed to send edited message")),Q(l.id,!1),e8.current===l.id&&(J(!1),e_(null),tp())}}},tI=async(e,t)=>{if(L){tM.info("Handling tool response: ".concat(e),{conversationId:L,toolCallId:t}),es(null),J(!0),e_(L),Q(L,!0),V(null),await tg(L);try{let n=await t_.respondToToolCall(L,e,t);tM.debug("Tool response successful",{conversationId:L,action:e,toolCallId:t}),tj(n,L)}catch(o){if(tL(o)||eG.current.has(L)){tM.info("Tool-response resume cancelled by user",{conversationId:L}),eV(L,!0),e8.current===L&&J(!1),Q(L,!1);return}tM.error("Error sending tool response (".concat(e,")"),{conversationId:L,toolCallId:t,err:o});let r="Failed to ".concat(e," tool call.");if(o instanceof tz){var n;r+=" Error: ".concat((null==(n=o.body)?void 0:n.error)||o.message)}else o instanceof Error&&(r+=" Error: ".concat(o.message));V(r),e8.current===L&&J(!1),Q(L,!1)}}},tR=async()=>{if(L&&ef){tM.info("Handling debug step request",{conversationId:L}),J(!0),e_(L),Q(L,!0),V(null),await tg(L);try{let e=await t_.debugStep(L);tj(e,L)}catch(e){tM.error("Error during debug step API call",{conversationId:L,err:e}),V(e instanceof Error?e.message:"Failed to execute debug step."),J(!1),Q(L,!1),eh(!1),em(null)}finally{}}},tD=async()=>{if(L&&ef){tM.info("Handling debug continue request",{conversationId:L}),J(!0),e_(L),Q(L,!0),V(null),eh(!1),await tg(L);try{let e=await t_.debugContinue(L);tj(e,L)}catch(e){tM.error("Error during debug continue API call",{conversationId:L,err:e}),V(e instanceof Error?e.message:"Failed to continue execution."),J(!1),Q(L,!1)}finally{}}};(0,o.useEffect)(()=>{if(eg){var e;eP(null!=(e=eg.breakpoints)?e:[])}},[eg]);let tP=(0,o.useCallback)(async e=>{if(!L)return;let t=eD.includes(e)?eD.filter(t=>t!==e):[...eD,e];eP(t);try{await t_.setBreakpoints(L,t)}catch(e){tM.error("Failed to update breakpoints",{conversationId:L,err:e}),eP(eD)}},[eD,L]),tF=async()=>{if(!L||!ef)return;let e=null==eg?void 0:eg.currentNodeId;J(!0),e_(L),Q(L,!0),V(null),await tg(L);try{for(let o=0;o<50;o++){var t,n,r;let o=await t_.debugStep(L),a=null!=(r=null==o?void 0:o.status)?r:null==o||null==(t=o.debugState)?void 0:t.status,l=null==o||null==(n=o.debugState)?void 0:n.currentNodeId;if("paused_debug"!==a||l&&l!==e)return void tj(o,L)}tM.warn("Step Over hit iteration cap",{conversationId:L}),J(!1),Q(L,!1)}catch(e){tM.error("Error during step over",{conversationId:L,err:e}),V(e instanceof Error?e.message:"Failed to step over."),J(!1),Q(L,!1)}},tB=async()=>{if(L){tM.info("Cancelling request",{conversationId:L}),tw(),J(!1),e_(null),Q(L,!1),eV(L,!0),ev(!1),tp(),es(null),V(null);try{await t_.cancel(L),tM.debug("Cancel request sent successfully",{conversationId:L}),await e9(L)}catch(e){tM.error("Error sending cancel request",{conversationId:L,err:e}),V("Failed to send cancel request to the server.")}}},tH=async e=>{if(e===L)return void await tB();tM.info("Stopping background conversation",{conversationId:e}),eV(e,!0);try{await t_.cancel(e),Q(e,!1),await e3(void 0,{silent:!0})}catch(t){tM.error("Error stopping background conversation",{conversationId:e,err:t}),V("Failed to send cancel request to the server.")}},tq=async()=>{tM.info("Closing debugger panel",{conversationId:L}),eh(!1),em(null),ev(!1),await tB()};tM.debug("Rendering Chat component",{currentConversationId:L,isHandleEditMessageDefined:!0});let tU=(ex||ef)&&!!eg&&!!L,tJ=(null==tn?void 0:tn.status)==="awaiting_tool_approval"||!!ei,tY=!(tJ||(null==tn?void 0:tn.status)==="paused_debug")&&(U&&eF===L||!!L&&Y.has(L)||(null==tn?void 0:tn.status)==="running"),tG=!tY&&!!L&&eQ.has(L);return(0,r.jsxs)(l.default,{sx:{display:"flex",height:"calc(100vh - 64px)"},children:[eS&&(0,r.jsx)(l.default,{sx:{width:40,flexShrink:0,borderRight:1,borderColor:"divider",display:"flex",justifyContent:"center",pt:1},children:(0,r.jsx)(i.A,{title:"Show conversation sidebar",children:(0,r.jsx)(s.A,{size:"small",onClick:eC,"aria-label":"Show conversation sidebar",children:(0,r.jsx)(k.A,{fontSize:"small"})})})}),!eS&&(0,r.jsx)(l.default,{sx:{width:ew,flexShrink:0,borderRight:1,borderColor:"divider",display:"flex",flexDirection:"column"},children:a?(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",p:2},children:(0,r.jsx)(tE.default,{size:"medium",color:"primary"})}):R?(0,r.jsx)(d.A,{severity:"error",sx:{m:2},children:R}):(0,r.jsx)(O,{conversations:t,currentConversationId:L,onSelectConversation:B,onDeleteConversation:tm,onStopConversation:tH,onNewConversation:ta,onQuickChat:()=>ti(!0),onCollapse:eC})}),!eS&&(0,r.jsx)(l.default,{onPointerDown:ek,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,r.jsxs)(l.default,{sx:{flex:1,height:"100%",display:"flex",minWidth:0,minHeight:0},children:[(0,r.jsxs)(l.default,{sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",height:"100%"},children:[L&&(0,r.jsx)(l.default,{sx:{px:2,pt:2,pb:1,display:"flex",alignItems:"center",gap:1,minWidth:0},children:et?(0,r.jsx)(c.A,{value:er,onChange:e=>eo(e.target.value),onBlur:tb,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),tb()):"Escape"===e.key&&en(!1)},size:"small",autoFocus:!0,fullWidth:!0,inputProps:{maxLength:200,"aria-label":"Conversation title"}}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.default,{variant:"h6",noWrap:!0,onClick:tv,title:(null==D?void 0:D.title)||(null==tn?void 0:tn.title)||"",sx:{flex:1,minWidth:0,cursor:"text"},children:(null==D?void 0:D.title)||(null==tn?void 0:tn.title)||"Untitled Conversation"}),(0,r.jsx)(i.A,{title:"Rename conversation",children:(0,r.jsx)(s.A,{size:"small",onClick:tv,"aria-label":"Rename conversation",children:(0,r.jsx)(E.A,{fontSize:"small"})})})]})}),L&&(0,r.jsxs)(l.default,{sx:{p:2,borderBottom:1,borderColor:"divider",display:"flex",alignItems:"center",gap:2},children:[(0,r.jsx)(l.default,{sx:{flex:1,minWidth:0},children:tk((null==tn?void 0:tn.flowId)||(null==D?void 0:D.flowId))?(0,r.jsx)(p.A,{color:"primary",variant:"outlined",icon:(0,r.jsx)(w.A,{}),label:"Quick Chat"}):(0,r.jsx)(e7,{selectedFlowId:(null==tn?void 0:tn.flowId)||(null==D?void 0:D.flowId)||null,onSelectFlow:e=>{var t,n,r,o;if(!L){tM.warn("Cannot update flow: No conversation selected."),V("Please select a conversation first.");return}tk(e)||q(e);let a=null!=(r=null!=(n=null==D?void 0:D.flowId)?n:null==tn?void 0:tn.flowId)?r:null;if((null!=(o=null==D||null==(t=D.messages)?void 0:t.length)?o:0)>0&&a&&e!==a){tM.debug("Flow switch on executed conversation — asking for confirmation",{flowId:e,currentFlowId:a}),ec(e);return}tx(e)},disabled:ef})}),(0,r.jsx)(e2,{usage:null==D?void 0:D.usage,contextInfo:null==D?void 0:D.contextInfo,availableNodes:tr})]}),(0,r.jsxs)(l.default,{sx:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[(0,r.jsx)(l.default,{ref:eX,onScroll:e5,sx:{flex:1,overflow:"auto",p:2},children:F?(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,r.jsx)(tE.default,{size:"medium",color:"primary"})}):M?(0,r.jsx)(d.A,{severity:"error",sx:{m:2},children:M}):D?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR,{messages:D.messages,pendingToolCalls:ei,availableNodes:tr,conversationId:D.id,onToggleDisabled:e=>{if(!D)return;tM.debug("Toggling message disabled state",{messageId:e});let t=D.messages.map(t=>t.id===e?{...t,disabled:!t.disabled}:t);tu({...D,messages:t})},onSplitConversation:e=>{if(!D)return;tM.debug("Splitting conversation at message",{messageId:e});let t=D.messages.findIndex(t=>t.id===e);if(-1===t)return;let r=D.messages.slice(0,t+1),o=(0,eH.A)(),a={id:o,title:"Split from ".concat(D.title),messages:r,flowId:D.flowId,createdAt:Date.now(),updatedAt:Date.now()},l={id:o,title:a.title,flowId:a.flowId,createdAt:a.createdAt,updatedAt:a.updatedAt};eq.current.add(o),n(e=>[l,...e].sort((e,t)=>t.updatedAt-e.updatedAt)),B(o),P(a),_(!1),W(null)},onEditMessage:tS,onApproveToolCall:e=>{tI("approve",e)},onRejectToolCall:e=>{tI("reject",e)}}),!U&&!ef&&D.messages.length>0&&(null==tn?void 0:tn.status)==="completed"&&(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,r.jsx)(d.A,{icon:(0,r.jsx)(S.A,{fontSize:"inherit"}),severity:"success",variant:"filled",sx:{borderRadius:2,py:.5},children:"Conversation completed"})}),!U&&!ef&&tG&&(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,r.jsx)(d.A,{icon:(0,r.jsx)(C.A,{fontSize:"inherit"}),severity:"info",variant:"outlined",sx:{borderRadius:2,py:.5,alignItems:"center"},action:(0,r.jsx)(f.A,{color:"inherit",size:"small",startIcon:(0,r.jsx)(A.A,{}),onClick:()=>tA(D),children:"Resume"}),children:"Conversation stopped"})}),!U&&!ef&&!K&&!tG&&(null==tn?void 0:tn.status)==="error"&&(0,r.jsx)(l.default,{sx:{display:"flex",justifyContent:"center",my:2},children:(0,r.jsx)(d.A,{icon:(0,r.jsx)(I.A,{fontSize:"inherit"}),severity:"error",variant:"filled",sx:{borderRadius:2,py:.5,alignItems:"center"},action:(0,r.jsx)(f.A,{color:"inherit",size:"small",startIcon:(0,r.jsx)(A.A,{}),onClick:()=>{tA(D)},children:"Retry"}),children:"Conversation ended with an error"})}),tY&&!ef&&(0,r.jsx)(eY,{liveStats:eE,onStop:tB,stopDisabled:!L}),!tY&&tJ&&!ef&&(0,r.jsx)(eY,{liveStats:eE,awaitingApproval:!0,onStop:tB,stopDisabled:!L}),K&&(0,r.jsx)(d.A,{severity:"error",sx:{mt:2},action:(0,r.jsx)(f.A,{color:"inherit",size:"small",startIcon:(0,r.jsx)(A.A,{}),onClick:()=>{D&&tA(D)},children:"Retry"}),children:K})]}):(0,r.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,r.jsx)(h.A,{in:eZ,unmountOnExit:!0,children:(0,r.jsx)(g.A,{size:"small",color:"primary","aria-label":"Scroll to latest messages",onClick:e4,sx:{position:"absolute",bottom:16,right:24,zIndex:2},children:(0,r.jsx)(j.A,{})})})]}),(0,r.jsx)(l.default,{sx:{p:2,borderTop:1,borderColor:"divider"},children:(0,r.jsx)(eU,{onSendMessage:ty,disabled:F||!!L&&Y.has(L)||!((null==D?void 0:D.flowId)||(null==tn?void 0:tn.flowId))||!!ei||ef,requireApproval:Z,onRequireApprovalChange:te,executeInDebugger:ea,onExecuteInDebuggerChange:el,availableNodes:tr,currentNodeId:to,nodeOverrideActive:!!eu,onSelectNode:ep})})]})," ",tU&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.default,{onPointerDown:ej,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,r.jsx)(l.default,{sx:{width:eb?"".concat(eb,"px"):"50%",minWidth:360,maxWidth:"85vw",flexShrink:0,display:"flex",flexDirection:"column",height:"100%"},children:(0,r.jsx)(tC,{debugState:eg,conversationId:L,liveActivity:eN,onStep:tR,onStepOver:tF,onContinue:tD,onCancel:tB,isLoading:U,breakpoints:eD,onToggleBreakpoint:tP,onClose:tq})})]})]})," ",(0,r.jsxs)(m.A,{open:!!ed,onClose:()=>ec(null),children:[(0,r.jsx)(x.A,{children:"Switch flow?"}),(0,r.jsx)(v.A,{children:(0,r.jsxs)(b.A,{children:["This conversation has already been processed with its current flow."," ","If you switch to"," ",(0,r.jsx)("strong",{children:(null==(e=X.find(e=>e.id===ed))?void 0:e.name)||"the selected flow"}),","," ","the conversation will continue processing from that flow's Start node again."]})}),(0,r.jsxs)(y.A,{children:[(0,r.jsx)(f.A,{onClick:()=>ec(null),children:"Cancel"}),(0,r.jsx)(f.A,{variant:"contained",onClick:()=>{ec(null),ed&&tx(ed)},children:"Switch Flow"})]})]}),(0,r.jsx)(tt,{open:tl,onClose:()=>ti(!1),onStart:tc})]})},tH=(0,ej.h)("frontend/components/ClientOnly");function tq(e){let{children:t}=e,[n,a]=(0,o.useState)(!1);return((0,o.useEffect)(()=>(tH.debug("ClientOnly component mounted"),a(!0),()=>{tH.debug("ClientOnly component unmounted")}),[]),n)?(tH.debug("ClientOnly component rendering children"),(0,r.jsx)(r.Fragment,{children:t})):(tH.debug("ClientOnly component rendering null (not yet mounted)"),null)}let tU=(0,ej.h)("app/chat/page");function tJ(){return tU.debug("Rendering ChatPage"),(0,r.jsx)(a.A,{maxWidth:!1,disableGutters:!0,children:(0,r.jsx)(tq,{children:(0,r.jsx)(tB,{})})})}},65818:(e,t,n)=>{"use strict";n.d(t,{mO:()=>a,rI:()=>l});var r=n(38459);let o=["stdio","websocket","sse","streamable"];function a(e,t){switch(t){case"name-asc":case"name-desc":return(0,r.po)(e.name);case"status-connected":case"status-disconnected":{let t=e.status;if("connected"===t)return{key:"status:connected",label:"Connected"};if("error"===t)return{key:"status:error",label:"Error"};if("requires_authentication"===t)return{key:"status:auth",label:"Requires authentication"};return{key:"status:disconnected",label:"Disconnected"}}case"transport":{let t=e.transport||"unknown";return{key:"transport:".concat(t),label:({stdio:"Stdio",websocket:"WebSocket",sse:"SSE",streamable:"Streamable HTTP"})[t]||t}}default:return{key:"all",label:"All servers"}}}function l(e,t){return[...e].sort((e,n)=>{switch(t){case"name-asc":return e.name.localeCompare(n.name);case"name-desc":return n.name.localeCompare(e.name);case"status-connected":if("connected"===e.status&&"connected"!==n.status)return -1;if("connected"!==e.status&&"connected"===n.status)return 1;return e.name.localeCompare(n.name);case"status-disconnected":if("disconnected"===e.status&&"disconnected"!==n.status)return -1;if("disconnected"!==e.status&&"disconnected"===n.status)return 1;return e.name.localeCompare(n.name);case"transport":{var r,a;let t=o.indexOf(null!=(r=e.transport)?r:""),l=o.indexOf(null!=(a=n.transport)?a:"");if(t!==l)return t-l;return e.name.localeCompare(n.name)}default:return 0}})}},84869:(e,t,n)=>{"use strict";n.d(t,{G:()=>l,S:()=>a});let r=(0,n(87021).h)("frontend/services/transcription/webSpeech"),o=()=>"webkitSpeechRecognition"in window||"SpeechRecognition"in window;async function a(e,t){if(!o())throw Error("Web Speech API is not supported in this browser");r.debug("Starting Web Speech API transcription");try{let n=URL.createObjectURL(e),o=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 r=e.results[t][0].transcript;e.results[t].isFinal?l+=r+" ":n+=r}(null==t?void 0:t.onInterimResult)&&t.onInterimResult(l+n),r.debug("Recognition interim result",{finalLength:l.length,interimLength:n.length})},a.onend=()=>{r.debug("Recognition ended",{transcriptLength:l.length}),e(l.trim())},a.onerror=e=>{r.error("Recognition error",{error:e.error}),n(Error("Speech recognition error: ".concat(e.error)))},o.onplay=()=>{a.start(),r.debug("Recognition started")},o.onended=()=>{a.stop(),r.debug("Audio playback ended")},o.onerror=e=>{r.error("Audio playback error",{error:e}),a.stop(),n(Error("Error playing audio"))},o.play().catch(e=>{r.error("Error starting audio playback",{error:e}),n(e)})})}catch(e){throw r.error("Error in Web Speech API transcription",{error:e}),e}}function l(){return{supported:o(),message:o()?"Web Speech API is supported":"Web Speech API is not supported in this browser"}}},97206:(e,t,n)=>{Promise.resolve().then(n.bind(n,45960))}},e=>{e.O(0,[3862,2678,4754,9244,8548,1983,1871,2003,5501,488,3272,3077,9659,9451,2403,7687,9554,8480,2005,6730,9181,9164,812,4207,8441,1255,7358],()=>e(e.s=97206)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9040],{32651:(e,t,a)=>{Promise.resolve().then(a.bind(a,71113))},71113:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>E});var o=a(95155),s=a(94049),n=a(12115),r=a(28548),i=a(2300),l=a(25635),d=a(97322),p=a(9562),c=a(56422),u=a(21067),m=a(32683),h=a(51611);let f=[{id:"openai",name:"Chat — OpenAI-compatible",description:'A drop-in OpenAI-compatible surface. In OpenAI-compatible clients (Roo Code, Cline, Cursor, the OpenAI SDK, …) set the Base URL to this instance + "/v1" (e.g. http://localhost:4200/v1) and the model to a flow id (format flow-<NAME>, as listed by /v1/models).',endpoints:[{method:"POST",alsoMethods:["GET","OPTIONS"],path:"/v1/chat/completions",summary:"OpenAI-compatible chat completion. Runs a FLUJO flow as the model. Supports streaming and non-streaming. CORS-enabled; rate-limited (~6000 req/min).",paramsLabel:"Body",params:[{name:"model",type:"string",required:!0,description:"Flow to run, as flow-<NAME>."},{name:"messages",type:"ChatMessage[]",required:!0,description:"Conversation messages (OpenAI shape)."},{name:"stream",type:"boolean",description:"Stream the response as SSE chunks."},{name:"flujo",type:"boolean",description:"Enable FLUJO-specific behavior."},{name:"conversation_id",type:"string",description:"Reuse/continue an existing conversation."},{name:"requireApproval",type:"boolean",description:"Pause for manual tool-call approval."},{name:"flujodebug",type:"boolean",description:"Run in the visual debugger (single-step)."}],response:"OpenAI ChatCompletion object, or an SSE stream of chunks when stream=true."},{method:"GET",path:"/v1/models",summary:"List all flows as OpenAI-style models.",response:'{ object: "list", data: [{ id: "flow-<NAME>", object: "model" }, ...] }'}]},{id:"conversations",name:"Conversations & Execution",description:"Manage conversations and drive flow execution: live event streaming (SSE), tool-call approval, cancellation, and visual-debugger stepping.",endpoints:[{method:"GET",path:"/v1/chat/conversations",summary:"List all conversations (id, title, flowId, createdAt, updatedAt, status), newest first.",response:"Conversation summary array."},{method:"POST",path:"/v1/chat/conversations",summary:"Create a new conversation and initialize its execution state.",paramsLabel:"Body",params:[{name:"id",type:"string",required:!0,description:"Client-generated conversation id."},{name:"title",type:"string",required:!0,description:"Display title."},{name:"flowId",type:"string",required:!0,description:"Flow bound to this conversation."},{name:"createdAt",type:"number",required:!0,description:"Unix ms timestamp."},{name:"updatedAt",type:"number",required:!0,description:"Unix ms timestamp."}]},{method:"GET",alsoMethods:["PATCH","DELETE"],path:"/v1/chat/conversations/{conversationId}",summary:"GET the displayed conversation (messages + metadata); PATCH updates flowId; DELETE removes the conversation and its event log.",paramsLabel:"Body",params:[{name:"flowId",type:"string",description:"New flow id (PATCH only)."}],response:"Conversation with messages, plus usage (token totals, per-node breakdown), status, and contextInfo (latest prompt-token count + the bound model's context window — what the chat token counter and context meter display).",notes:["Messages are a projection of the append-only conversation log when one exists (legacy conversations without a log are served as stored). Node system prompts are never included.","Subflow steps appear inline as depth-tagged, display-only messages (nested in the chat UI); they are never part of the parent's model context."]},{method:"GET",path:"/v1/chat/conversations/{conversationId}/events",summary:"Server-Sent Events stream of execution events (node:enter/exit, message, usage, run:*). Supports Last-Event-ID reconnect.",paramsLabel:"Query",params:[{name:"fromSeq",type:"number",description:"Replay events from this sequence number."}],response:"text/event-stream of ExecutionEvent objects with monotonic seq ids."},{method:"POST",path:"/v1/chat/conversations/{conversationId}/respond",summary:"Approve or reject a pending tool call; resumes execution when all pending calls are handled.",paramsLabel:"Body",params:[{name:"action",type:'"approve" | "reject"',required:!0,description:"Decision for the tool call."},{name:"toolCallId",type:"string",required:!0,description:"Which pending tool call."}]},{method:"POST",path:"/v1/chat/conversations/{conversationId}/cancel",summary:"Request cancellation of an in-progress run (sets the isCancelled flag)."},{method:"PUT",path:"/v1/chat/conversations/{conversationId}/breakpoints",summary:"Set the visual-debugger breakpoint node ids.",paramsLabel:"Body",params:[{name:"breakpoints",type:"string[]",required:!0,description:"Node ids to break on."}]},{method:"POST",path:"/v1/chat/conversations/{conversationId}/debug/step",summary:"Execute exactly one productive step (only when status is paused_debug); pauses after advancing."},{method:"POST",path:"/v1/chat/conversations/{conversationId}/debug/continue",summary:"Resume a debug session — run freely to the next pause, tool approval, or completion."},{method:"PATCH",path:"/v1/chat/conversations/{conversationId}/edit-state",summary:"Edit paused debug state (a message's content, or the next node to run). Only when paused_debug.",paramsLabel:"Body",params:[{name:"messageId",type:"string",description:"Message to edit."},{name:"content",type:"string",description:"New message content."},{name:"currentNodeId",type:"string",description:"Override the next node."}]}]},{id:"model",name:"Models",description:"CRUD for model configurations and provider model discovery. API keys are encrypted at rest and never returned to the browser in clear text.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/model",summary:"GET lists all models; POST creates a model (409 on duplicate name, 201 on success).",paramsLabel:"Body",params:[{name:"model",type:"Model",required:!0,description:"Model config (POST). Secrets are stored encrypted."}],notes:["Stored API keys are masked before reaching the frontend — never expect a clear-text key in a response."]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/model/{id}",summary:"GET / PUT / DELETE a single model. The path id is authoritative on PUT. DELETE returns 204."},{method:"POST",path:"/api/model/provider",summary:"Fetch available models from a provider, using a supplied or stored API key (resolved server-side).",paramsLabel:"Body",params:[{name:"baseUrl",type:"string",required:!0,description:"Provider base URL."},{name:"modelId",type:"string",description:"Existing model whose stored key to reuse."},{name:"searchTerm",type:"string",description:"Filter the returned model list."}],notes:["Accepts an apiKey only inbound to query the provider; keys are never echoed back to the client."]}]},{id:"flow",name:"Flows",description:"CRUD for flow definitions, programmatic flow authoring (FlowSpec), LLM flow generation, and prompt rendering for individual nodes. For creating flows programmatically, prefer POST /api/flow/compile with a FlowSpec — the raw Flow format (ReactFlow JSON) is the internal canvas representation and easy to get subtly wrong.",endpoints:[{method:"POST",path:"/api/flow/compile",summary:"Compile a FlowSpec (the semantic authoring format — see below) into a complete flow, validate it, and optionally save it. Deterministic, no LLM: layout, ids, handles, and MCP wiring are generated for you. THE recommended way for external apps and agents to create flows. Also exposed as MCP tools (create_flow / validate_flow_spec) on /mcp-flows.",paramsLabel:"Body",params:[{name:"spec",type:"FlowSpec",required:!0,description:"The flow specification (format below)."},{name:"save",type:"boolean",description:"Persist the flow — only happens when validation finds ZERO errors."}],response:"{ flow, validation: { issues, errorCount, warningCount, isRunnable }, saved } — 201 when saved, 200 otherwise. Iterate on the issues until clean.",details:'A FlowSpec is a JSON object describing a FLUJO flow semantically — node keys and edges, no coordinates, no ids, no layout:\n{\n "name": "short_flow_name", // letters/digits/_/- only\n "description": "what the flow does",\n "nodes": [ ... ],\n "edges": [ ... ]\n}\n\nNODE TYPES:\n- { "key": "unique_key", "type": "start", "label": "...", "prompt": "system-level instructions for the whole flow" }\n- { "key": "...", "type": "process", "label": "...", "description": "what this step does",\n "model": "<model id or name from the catalog>",\n "prompt": "instructions for this step",\n "servers": [ { "name": "<server name>", "tools": ["tool_a"] } ], // optional; omit "tools" to enable all\n "inputMode": "full-history" | "latest-message" | "isolated", // optional, default full-history\n "isolatedPrompt": "...", // only with inputMode "isolated"\n "outputMode": "full-conversation" | "latest-message", // optional, default full-conversation; latest-message hides this step\'s tool calls/results from later steps (they see only its final response)\n "maxTurns": 20, // optional; per-step cap on agentic tool-loop turns (retry-until-done in ONE node). Unset = model/system default (50)\n "allowedTools": ["tool_a"], // optional; step-level tool allowlist (independent of servers[].tools)\n "captureVariable": "NAME", // optional; save this step\'s output into a run variable other steps inject with ${var:NAME}\n "captureResource": "NAME", // optional; ALSO save this step\'s output as a tracked run resource other steps inject with ${res:NAME} (see rule 9b)\n "captureKv": "NAME", // optional; ALSO save this step\'s output to a PERSISTENT cross-run key other steps inject with ${kv:NAME} (see rule 9d)\n "excludeModelPrompt": true|false, // optional; drop the model\'s base prompt\n "excludeStartNodePrompt": true|false, // optional; drop the start node\'s prompt for this step\n "excludeSystemPrompt": true|false } // optional; drop the workflow/handoff guidance block\n- { "key": "...", "type": "subflow", "label": "...",\n "flow": "<existing flow name or id>", // reference an EXISTING flow, OR:\n "subflowSpec": { ...a nested FlowSpec... }, // define a brand-new child flow INLINE (compiled into its own flow and wired automatically), OR fan out concurrently:\n "parallelFlows": ["flow_a", "flow_b"], // run several EXISTING child flows CONCURRENTLY, same input to each, outputs joined; OR:\n "parallelSubflowSpecs": [ { ...FlowSpec... } ], // run several INLINE child flows concurrently; OR:\n "parallelFlowsVariable": "NAME", // DYNAMIC fan-out (rule 7b): pick the target flows AT RUNTIME from run variable ${var:NAME} (a JSON array of flow ids/names, or newline list); mutually exclusive with mapOverList\n "mapOverList": true | false, // optional; run the SINGLE child ("flow"/"subflowSpec") ONCE PER ITEM parsed from the input; mutually exclusive with parallelFlows/parallelSubflowSpecs\n "itemSplit": "json-array" | "lines", // optional (mapOverList only), how to split the input into items, default json-array\n "sequential": true | false, // optional (mapOverList only), run items one at a time in order instead of concurrently, default false\n "concurrencyLimit": 4, // optional (parallel / mapOverList), default 4\n "joinSeparator": "\\n\\n---\\n\\n", // optional (parallel / mapOverList), string between joined lane outputs, default "\\n\\n"\n "errorStrategy": "collect-all" | "fail-fast", // optional (parallel / mapOverList), default collect-all\n "inputMode": "full-history" | "latest-message" | "isolated",\n "allowCallerPrompt": true | false, // optional, only with inputMode "isolated"; when true a routing step may pass a "prompt" via its handoff tool that overrides the subflow\'s "prompt" (default)\n "allowCallerFanout": true | false, // optional (subflow); when true a routing step may pass a "parallelFlows" array (+ optional "concurrencyLimit") via its handoff tool to CHOOSE the parallel fan-out set at runtime (rule 7c)\n "captureVariable": "NAME", // optional; save the subflow\'s output into a run variable other steps inject with ${var:NAME}\n "captureResource": "NAME", // optional; ALSO save the subflow\'s output as a tracked run resource (${res:NAME}, rule 9b)\n "captureKv": "NAME", // optional; ALSO save the subflow\'s output to a PERSISTENT cross-run key (${kv:NAME}, rule 9d)\n "outputMode": "steps" | "final-only" }\n- { "key": "...", "type": "finish", "label": "..." }\n- { "key": "...", "type": "signal", "label": "...", // fire-and-forget event (rule 11): emits {topic, payload} then passes through unchanged\n "topic": "<event topic other flows\' triggers listen for>", // REQUIRED — a signal with no topic emits nothing\n "payloadTemplate": "event body, may use ${var:NAME}" } // optional; defaults to the node prompt\n- { "key": "...", "type": "resource", "label": "...", // OPTIONAL/advanced (rule 9c): a data artifact shown in the graph\n "server": "<server name>", "uri": "<resource uri>", // EITHER a static MCP resource…\n "runName": "NAME" } // …OR a run artifact steps produce/consume\n\nEDGES: { "from": "<node key>", "to": "<node key>", "bidirectional": true|false,\n "condition": { "kind": "contains"|"regex"|"equals", "value": "...",\n "target": "last-assistant"|"last-message", // optional, default last-assistant\n "ignoreCase": true|false, "negate": true|false } } // condition optional; process-node edges only\n\nRULES:\n1. Exactly ONE start node; at least one finish node reachable from it.\n2. Every process node MUST reference a configured model (by id, display name, or name).\n3. A process step uses MCP tools ONLY via its "servers" list — never emit nodes of type "mcp".\n4. Do not embed ${tool:...} or ${resource:...} references in prompts — tools are wired through "servers".\n5. Branching: give a process node multiple outgoing edges; its model decides where to hand off at runtime. "bidirectional": true lets the target hand back to the source (agent <-> agent).\n5b. Deterministic routing: give a process node\'s outgoing edges a "condition" to route WITHOUT the model — the engine takes the first outgoing edge whose predicate matches the last message (default the step\'s own last assistant message), and a bare (condition-less) edge is the fallback. Use this for reliable data-driven branches (e.g. output contains "FAIL" -> fix step, else -> publish) instead of relying on a small model to emit a handoff. Only process-node edges may carry a condition. Without any condition on a node, that node keeps model-decided handoff (rule 5). If the model still calls a handoff tool, that wins over the condition.\n6. A subflow node may have only ONE outgoing edge. Give it EITHER a "flow" (naming an existing flow) OR a "subflowSpec" (an inline nested FlowSpec that becomes its own child flow) — not both. A "subflowSpec" may itself contain subflow nodes with their own "subflowSpec" (bounded nesting), so you can author whole multi-level flows in one object.\n7. A subflow node may instead fan out to SEVERAL child flows CONCURRENTLY via "parallelFlows" (existing flows) or "parallelSubflowSpecs" (inline). These are STATIC (fixed at author time): the same input is sent to every lane and their outputs are joined. This is about multiple CHILDREN, not successors — the single-outgoing-edge rule (rule 6) still holds. Prefer "parallelFlows" for large fan-outs.\n7b. For DYNAMIC fan-out — when the set of target flows should be decided AT RUNTIME by an earlier step — use "parallelFlowsVariable": "NAME". An upstream process/subflow node captures a JSON array of flow ids/names (or a newline list) into run variable NAME via "captureVariable": "NAME"; this subflow node then fans out over exactly those flows. Unknown ids and a self-reference are dropped, the count is capped, and a non-empty resolution overrides any static "parallelFlows" (empty falls back to it). Mutually exclusive with "mapOverList". Still one outgoing edge (rule 6).\n7c. For AGENTIC fan-out — when the ROUTING MODEL itself should decide the parallel set at the very moment it hands off — set "allowCallerFanout": true on the target subflow node. Its handoff tool then exposes an optional "parallelFlows" (array of flow ids/names) argument plus an optional "concurrencyLimit"; the model passes them at call time to fan out over exactly those flows. A non-empty caller set overrides "parallelFlows"/"parallelFlowsVariable"; unknown ids and a self-reference are dropped and the count is capped. Mutually exclusive with "mapOverList". Still one outgoing edge (rule 6). Prefer 7b\'s "parallelFlowsVariable" when an EARLIER step computes the set; use 7c when the DECIDING (routing) step is the one that chooses it.\n8. A subflow node may instead run its SINGLE child flow ONCE PER ITEM via "mapOverList": true. The input is split into items by "itemSplit" ("json-array" default, or "lines"), each item is sent to its own child run, and the per-item outputs are joined (same pool/tuning as parallel). Use "sequential": true to run items in order. Mutually exclusive with "parallelFlows"/"parallelSubflowSpecs".\n9. Named variables (scratchpad): a step can save its output with "captureVariable": "NAME" (process or subflow) and any LATER step injects it with ${var:NAME} inside its "prompt" / "isolatedPrompt" / subflow prompt. This survives "latest-message"/"isolated" scoping, unlike conversation history — use it to carry a todo list, a file path, a diff, or a captured result across steps that don\'t share history. ${var:NAME} is run-scoped and plaintext; it is DISTINCT from ${global:VAR} (configured secrets/config, resolved only for tool args). Capture a subflow\'s output on the PARENT subflow node — a variable set inside a child flow is not visible to the parent.\n9b. Run resources (tracked data): "captureResource": "NAME" (process or subflow) ALSO saves the step\'s output as a run-scoped RESOURCE — an addressable artifact (flujo://run/... URI) with lineage (which step produced it, which steps read it), readable via the built-in "flujo" MCP server. A later step injects it with ${res:NAME} exactly like ${var:NAME}. Prefer "captureVariable" for short strings; use "captureResource" when the output is a large document/report/dataset worth tracking, or when other tools/agents should be able to read it back. Large or binary MCP tool results (screenshots, files) are auto-captured as run resources without any spec field.\n9c. Resource nodes are OPTIONAL/advanced — most flows should not use them; prefer rule 9b\'s captureResource/${res:NAME}. Emit one only when the data artifact itself should be VISIBLE in the graph: an edge resource→process means the step READS the artifact (its contents are injected into the step\'s context); process→resource means the step\'s output is SAVED to it (run artifacts only, equivalent to captureResource with the node\'s runName). Resource edges are data wiring, not flow control — they never carry conditions and don\'t count as a step\'s successor.\n9d. Persistent state (cross-run): "captureKv": "NAME" (process or subflow) saves the step\'s output to a PERSISTENT key-value store that SURVIVES ACROSS RUNS, injected by any step with ${kv:NAME}. Unlike ${var:} / ${res:} (discarded when the run ends), ${kv:} is what a long-lived SCHEDULED flow uses to carry a loop counter, a pagination cursor, a last-seen id, or a flag to its NEXT run. By default a key lives on the flow\'s FOLDER board (flows in the same folder share it); prefix the name to change scope: "flow/NAME" (this flow only) or "global/NAME" (whole instance). Plaintext, never secrets (distinct from ${global:VAR}). A model can also read/update a key mid-run via the built-in "flujo" server\'s kv_get / kv_set tools.\n10. Keep flows minimal — only the steps the task needs. Write clear, specific prompts and labels; fill "description" on process nodes.\n11. Signals (fire-and-forget events): a "signal" node is a deterministic pass-through that, when the path reaches it, emits an event {topic, payload} onto the flow-run event bus and then continues to its successor unchanged (it never calls a model or touches the conversation). Use it when the flow should notify or kick off ANOTHER flow mid-run — a flow-event trigger configured elsewhere listens for the same "topic" (e.g. "when the review finds blockers, emit a review-blocked signal"). Always give it a "topic" (a signal with no topic emits nothing); "payloadTemplate" is the optional event body and may inject ${var:NAME}. Make emission conditional by putting a conditioned edge (rule 5b) INTO the signal node.'},{method:"POST",path:"/api/flow/generate",summary:"Generate a draft flow from a natural-language description using one of your configured models. The model authors a FlowSpec, FLUJO compiles + validates it and feeds problems back for a bounded number of repair rounds. The generator can always SEARCH the public MCP registry; with allowInstall it can also INSTALL servers it needs. Returns an UNSAVED draft (the UI opens it in the builder for review); persist via the normal save path or /api/flow/compile.",paramsLabel:"Body",params:[{name:"description",type:"string",required:!0,description:"What the flow should do, in plain language."},{name:"modelId",type:"string",required:!0,description:"Configured model that does the generating."},{name:"maxRepairs",type:"number",description:"Repair rounds after the first attempt (default 1, max 2)."},{name:"allowInstall",type:"boolean",description:"Let the generator install MCP servers from the public registry (downloads + RUNS third-party packages on this machine). Off by default."}],response:"{ flow, validation, attempts, installedServers } — the flow is a draft; nothing flow-related is persisted by this endpoint (installed servers ARE persisted).",notes:["allowInstall executes third-party code with this machine's user permissions — opt in deliberately."]},{method:"GET",alsoMethods:["POST"],path:"/api/flow",summary:"GET lists all flow definitions; POST creates a flow (create-only; 409 if the id exists). POST takes the raw internal Flow format — prefer /api/flow/compile for programmatic creation.",paramsLabel:"Body",params:[{name:"flow",type:"Flow",required:!0,description:"Flow object including id (POST)."}]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/flow/{id}",summary:"GET / PUT / DELETE a single flow. On PUT the path id wins over the body id (404 if missing)."},{method:"POST",path:"/api/flow/prompt-renderer",summary:"Render the assembled prompt for a node within a flow.",paramsLabel:"Body",params:[{name:"flowId",type:"string",required:!0,description:"Flow containing the node."},{name:"nodeId",type:"string",required:!0,description:"Node to render."},{name:"options",type:"object",description:"Render options."}]}]},{id:"planned-executions",name:"Planned Executions",description:"Run flows headlessly on triggers: schedules (cron), inbound webhooks, and more. Managed from the Executions page; each run is recorded in a per-execution run history.",endpoints:[{method:"GET",alsoMethods:["POST","PATCH"],path:"/api/planned-executions",summary:"GET lists all planned executions with live trigger status and last run; POST creates one; PATCH toggles the global pause switch ({ paused: boolean }).",response:"GET: { paused, executions: [{ execution, status, lastRun }] }."},{method:"GET",alsoMethods:["PATCH","DELETE"],path:"/api/planned-executions/{id}",summary:"GET / PATCH / DELETE a single planned execution. PATCH takes a partial config and re-arms the trigger."},{method:"POST",path:"/api/planned-executions/{id}/run",summary:"Run now: fire the execution immediately (even while disabled or paused) and wait for the run.",response:"{ record: RunRecord } with status, output preview, and token usage."},{method:"GET",path:"/api/planned-executions/{id}/runs",summary:"The execution’s run history (newest 100 runs, oldest first)."},{method:"POST",path:"/api/planned-executions/preview-schedule",summary:"Validate a cron pattern and preview its next fire times (editor helper).",paramsLabel:"Body",params:[{name:"cron",type:"string",required:!0,description:"Cron pattern (5 or 6 fields)."},{name:"timezone",type:"string",description:"IANA timezone name."}],response:"{ valid, error?, nextRuns: string[] }."},{method:"POST",path:"/api/webhooks/{id}",summary:"Inbound webhook trigger. Fires the planned execution with the request body as trigger context and responds 202 { runId } immediately (the flow runs in the background). For a synchronous answer use /v1/chat/completions instead.",paramsLabel:"Query",params:[{name:"token",type:"string",required:!0,description:"Per-execution secret (alternatively send the X-Flujo-Token header)."}],notes:["Localhost-only by default; external callers must be explicitly allowed per execution.","The webhook body is untrusted input to the flow — prompts should treat it as data."]}]},{id:"mcp",name:"MCP Servers",description:"Manage MCP server configurations, connection state, tool discovery, and tool invocation.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/mcp/servers",summary:"GET lists all MCP server configs; POST registers a new one (409 on duplicate name).",paramsLabel:"Body",params:[{name:"config",type:"MCPServerConfig",required:!0,description:"Server config (POST)."}]},{method:"GET",alsoMethods:["PUT","DELETE"],path:"/api/mcp/servers/{name}",summary:"GET / PUT / DELETE a server config. PUT merges fields; toggling disabled connects/disconnects; a new name triggers a validated rename."},{method:"GET",path:"/api/mcp/servers/{name}/status",summary:"Live connection status. Always 200, even when the server is down.",response:"{ status, ... }"},{method:"GET",path:"/api/mcp/servers/{name}/tools",summary:"List tools exposed by a connected server.",response:"{ tools, error? } (empty tools + error when disconnected)."},{method:"POST",path:"/api/mcp/servers/{name}/tools/{toolName}",summary:"Invoke a tool on a server. Status may reflect the tool itself (408 on timeout).",paramsLabel:"Body",params:[{name:"args",type:"Record<string, unknown>",required:!0,description:"Tool arguments."},{name:"timeout",type:"number",description:"Optional timeout (ms)."}]},{method:"POST",path:"/api/mcp/test-connection",summary:"Run a real MCP handshake against an unsaved config (tests custom CAs and headers) without registering it.",paramsLabel:"Body",params:[{name:"config",type:"MCPServerConfig",required:!0,description:"Config to test."}]},{method:"POST",path:"/api/mcp/cancel",summary:"Cancel an in-progress tool execution; force-reconnects if no token is supplied.",paramsLabel:"Body",params:[{name:"reason",type:"string",required:!0,description:"Cancellation reason."}]}]},{id:"mcp-proxy",name:"FLUJO as an MCP server (proxy)",description:'Re-expose a configured MCP server to EXTERNAL MCP clients (Claude Desktop, Cursor, Cline, mcp-inspector, …) so you configure the server once in FLUJO and reach it everywhere. Enable per server via the "Expose to external apps" toggle on its card. In your MCP client, add a Streamable-HTTP server with the URL below. One downstream server per endpoint, so tool names are unchanged. Localhost-only for now (no auth token in this version — see the security roadmap).',endpoints:[{method:"POST",alsoMethods:["GET","DELETE"],path:"/mcp-proxy/{server}",summary:'A Streamable-HTTP MCP endpoint that forwards tools/list and tools/call to the named downstream MCP server. {server} is the configured server name; it must have "Expose to external apps" enabled (otherwise 404). Rejects non-localhost requests.',response:"MCP JSON-RPC over Streamable HTTP (handled by your MCP client, not called directly)."}]},{id:"mcp-flows",name:"FLUJO as an MCP server (flows + authoring)",description:"A Streamable-HTTP MCP endpoint that exposes FLUJO itself to external MCP clients. Every saved flow is a callable tool (running it ephemerally and returning its output), and three authoring tools let an external agent CREATE flows by sending a semantic FlowSpec — no raw ReactFlow JSON required. Localhost-only (same posture as the proxy).",endpoints:[{method:"POST",alsoMethods:["GET","DELETE"],path:"/mcp-flows",summary:'MCP server with two tool families. Flow tools: one per saved flow (name = slug of the flow name; input = a single "input" string sent as the user turn; runs are ephemeral and never appear in the chat sidebar). Authoring tools: list_flow_building_blocks (models, MCP servers + tools, and existing flows a spec may reference — call first), validate_flow_spec (compile + validate without saving; iterate on the returned issues), create_flow (compile + validate + save; only saves when validation finds zero errors), plus capability acquisition: search_mcp_marketplace (search the public registry) and install_mcp_server (install + connect a registry server — downloads and RUNS third-party packages on the FLUJO host; required keys can be passed via its env argument). The FlowSpec format is documented on POST /api/flow/compile above and inside the tools\' own descriptions.',response:"MCP JSON-RPC over Streamable HTTP (handled by your MCP client, not called directly)."}]},{id:"oauth",name:"OAuth (for MCP)",description:"OAuth authorization flow for MCP servers that require it. Tokens are stored server-side and never sent to the browser.",endpoints:[{method:"POST",path:"/api/oauth/initiate",summary:"Begin the OAuth flow for a server; dynamically registers a client and returns an authorization URL.",paramsLabel:"Body",params:[{name:"serverName",type:"string",required:!0,description:"MCP server to authorize."}]},{method:"GET",alsoMethods:["POST"],path:"/api/oauth/callback",summary:"OAuth redirect target; exchanges the code for tokens, updates the config, and redirects to /mcp.",notes:["Tokens are persisted server-side only."]},{method:"POST",path:"/api/oauth/reset",summary:"Clear a server's OAuth tokens and force re-authentication on the next connection.",paramsLabel:"Body",params:[{name:"serverName",type:"string",required:!0,description:"Server to reset."}]}]},{id:"env",name:"Environment & Secrets",description:"Global environment variables and server-side encryption operations. Secret values are encrypted at rest and masked as ******** in responses.",endpoints:[{method:"GET",alsoMethods:["POST"],path:"/api/env",summary:"GET reads env vars (secrets masked); POST sets/deletes vars (secrets encrypted server-side).",paramsLabel:"Body",params:[{name:"action",type:'"set" | "setAll" | "delete"',required:!0,description:"Operation."},{name:"key",type:"string",description:"Variable name (set/delete)."},{name:"value",type:"string",description:"Value; the placeholder ******** is ignored."},{name:"metadata",type:"{ isSecret: boolean }",description:"Marks a value for encryption."}],notes:["GET masks secret values unless an internal includeSecrets flag is set; the browser never receives clear-text secrets."]},{method:"POST",path:"/api/encryption/secure",summary:"Server-side encryption operations: initialize, authenticate, change_password, encrypt, verify_password, check_initialized, and status queries.",paramsLabel:"Body",params:[{name:"action",type:"string",required:!0,description:"One of the encryption actions."}],notes:["Passwords and tokens are handled here and stay server-side — never log or surface them in the UI."]}]},{id:"storage",name:"Storage & Backup",description:"Generic key-value storage plus zip backup/restore of selected data.",endpoints:[{method:"GET",alsoMethods:["POST","DELETE"],path:"/api/storage",summary:"GET loads an item by StorageKey (with optional default); POST saves; DELETE clears.",paramsLabel:"Query",params:[{name:"key",type:"StorageKey",required:!0,description:"Storage key."},{name:"defaultValue",type:"JSON",description:"Returned when the key is missing (GET)."}]},{method:"POST",path:"/api/backup",summary:"Create a zip backup of selected items and download it.",paramsLabel:"Body",params:[{name:"selections",type:"string[]",required:!0,description:"e.g. models, mcpServers, flows, chatHistory, settings."}],notes:["A backup may include the encryption key and secrets — handle the downloaded file carefully."]},{method:"POST",path:"/api/restore",summary:"Restore data from a backup zip.",paramsLabel:"Form data",params:[{name:"file",type:"File (zip)",required:!0,description:"Backup archive."},{name:"selections",type:"JSON string[]",required:!0,description:"Which items to restore."}]}]},{id:"system",name:"System & Updates",description:"App initialization, working-directory info, repository operations, and self-update.",endpoints:[{method:"GET",path:"/api/init",summary:"Server-side initialization: verify storage and start enabled MCP servers."},{method:"GET",path:"/api/cwd",summary:"Return the current working directory and the mcp-servers directory path."},{method:"GET",path:"/api/browse",summary:"List a directory of the machine running FLUJO, for the folder-picker dialogs (file-watch triggers, MCP server paths). Defaults to the home directory; includes available drives on Windows.",paramsLabel:"Query",params:[{name:"path",type:"string",description:"Absolute directory path to list."}],response:"{ path, parent, home, sep, drives, entries: [{ name, path, isDirectory }] }",notes:["Exposes backend filesystem listings — like the rest of the API it assumes a single trusted user."]},{method:"POST",path:"/api/git",summary:"Repository operations for MCP servers: clone, install, build, run, exists, readFile, listDir, list, checkUpdates, checkUpdatesBatch, pullUpdates.",paramsLabel:"Body",params:[{name:"action",type:"string",required:!0,description:"Operation to perform."}]},{method:"GET",alsoMethods:["POST"],path:"/api/update",summary:'GET checks for a newer version (git fetch + behind count); POST { action: "apply" } pulls, rebuilds, and restarts.',response:"{ success, isGitRepo, updateAvailable, behindBy?, branch?, currentVersion }"}]}],y={GET:"#2e7d32",POST:"#1565c0",PUT:"#ed6c02",PATCH:"#9c27b0",DELETE:"#c62828",OPTIONS:"#616161"};function g(e){let{method:t}=e;return(0,o.jsx)(r.A,{label:t,size:"small",sx:{bgcolor:y[t],color:"#fff",fontWeight:700,fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.7rem",height:22}})}function v(e){var t,a,n,r;let{endpoint:d}=e;return(0,o.jsxs)(i.A,{variant:"outlined",sx:{p:2,mb:1.5},children:[(0,o.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap",mb:1},children:[(0,o.jsx)(g,{method:d.method}),null==(t=d.alsoMethods)?void 0:t.map(e=>(0,o.jsx)(g,{method:e},e)),(0,o.jsx)(l.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.9rem",wordBreak:"break-all"},children:d.path})]}),(0,o.jsx)(l.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5*(null!=(a=d.params)&&!!a.length)},children:d.summary}),d.params&&d.params.length>0&&(0,o.jsxs)(s.default,{sx:{mb:1},children:[(0,o.jsx)(l.default,{variant:"caption",sx:{fontWeight:700,textTransform:"uppercase",color:"text.secondary"},children:null!=(r=d.paramsLabel)?r:"Parameters"}),(0,o.jsx)(s.default,{component:"ul",sx:{m:0,mt:.5,pl:2.5},children:d.params.map(e=>(0,o.jsx)(s.default,{component:"li",sx:{mb:.25},children:(0,o.jsxs)(l.default,{variant:"body2",component:"span",children:[(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontWeight:600},children:e.name}),(0,o.jsxs)(s.default,{component:"span",sx:{color:"text.secondary"},children:[" ",e.type,e.required?" \xb7 required":""," — ",e.description]})]})},e.name))})]}),d.response&&(0,o.jsxs)(l.default,{variant:"body2",sx:{mt:.5},children:[(0,o.jsxs)(s.default,{component:"span",sx:{fontWeight:600},children:["Response:"," "]}),(0,o.jsx)(s.default,{component:"span",sx:{color:"text.secondary"},children:d.response})]}),null==(n=d.notes)?void 0:n.map((e,t)=>(0,o.jsxs)(l.default,{variant:"caption",sx:{display:"block",mt:1,color:"warning.main"},children:["⚠ ",e]},t)),d.details&&(0,o.jsx)(s.default,{component:"pre",sx:{mt:1.5,p:1.5,bgcolor:"action.hover",borderRadius:1,fontSize:"0.75rem",fontFamily:"monospace",whiteSpace:"pre-wrap",overflowX:"auto",m:0,mb:0},children:d.details})]})}function w(){let[e,t]=(0,n.useState)(""),[a,r]=(0,n.useState)("");n.useEffect(()=>{r(window.location.origin)},[]);let y=(0,n.useMemo)(()=>{let t=e.trim().toLowerCase();return t?f.map(e=>{let a=e.endpoints.filter(a=>{var o;return"".concat(a.method," ").concat((null!=(o=a.alsoMethods)?o:[]).join(" ")," ").concat(a.path," ").concat(a.summary).toLowerCase().includes(t)||e.name.toLowerCase().includes(t)});return{...e,endpoints:a}}).filter(e=>e.endpoints.length>0):f},[e]);return(0,o.jsxs)(d.A,{maxWidth:"md",sx:{py:5},children:[(0,o.jsx)(l.default,{variant:"h4",gutterBottom:!0,children:"API Documentation"}),(0,o.jsx)(l.default,{variant:"body1",color:"text.secondary",sx:{mb:2},children:"FLUJO exposes an OpenAI-compatible chat API and a REST surface for managing models, MCP servers, flows, and conversations. All endpoints are served from this instance."}),(0,o.jsxs)(i.A,{variant:"outlined",sx:{p:2,mb:3},children:[(0,o.jsx)(l.default,{variant:"subtitle2",gutterBottom:!0,children:"Base URL"}),(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace",fontSize:"0.9rem"},children:a||"http://localhost:4200"}),(0,o.jsxs)(l.default,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["Point any OpenAI SDK at"," ",(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace"},children:(a||"http://localhost:4200")+"/v1"})," ","and set the model to"," ",(0,o.jsx)(s.default,{component:"code",sx:{fontFamily:"var(--font-geist-mono), monospace"},children:"flow-<NAME>"}),". Any API key value is accepted locally."]})]}),(0,o.jsx)(p.A,{fullWidth:!0,size:"small",placeholder:"Search endpoints (path, method, description)…",value:e,onChange:e=>t(e.target.value),sx:{mb:3},InputProps:{startAdornment:(0,o.jsx)(c.A,{position:"start",children:(0,o.jsx)(h.A,{fontSize:"small"})})}}),0===y.length&&(0,o.jsxs)(l.default,{color:"text.secondary",children:["No endpoints match “",e,"”."]}),y.map(e=>(0,o.jsxs)(s.default,{sx:{mb:4},id:e.id,children:[(0,o.jsx)(l.default,{variant:"h6",gutterBottom:!0,children:e.name}),(0,o.jsx)(l.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:e.description}),e.endpoints.map(e=>(0,o.jsx)(v,{endpoint:e},"".concat(e.method," ").concat(e.path)))]},e.id)),(0,o.jsx)(u.A,{sx:{my:3}}),(0,o.jsxs)(l.default,{variant:"caption",color:"text.secondary",children:["Secrets (API keys, encryption passwords, OAuth tokens) are encrypted at rest and never returned to the browser in clear text. See the project"," ",(0,o.jsx)(m.A,{href:"https://github.com/mario-andreschak/FLUJO",target:"_blank",rel:"noopener",children:"repository"})," ","for source-level details."]})]})}let b=(0,a(87021).h)("app/docs/page");function E(){return b.debug("Rendering DocsPage"),(0,o.jsx)(s.default,{component:"main",sx:{minHeight:"100vh"},children:(0,o.jsx)(w,{})})}},87021:(e,t,a)=>{"use strict";a.d(t,{h:()=>l});let o={LOG_LEVEL:3},s={VERBOSE:-1,DEBUG:0,INFO:1,WARN:2,ERROR:3},n="number"==typeof o.LOG_LEVEL?o.LOG_LEVEL:s.ERROR;function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t>6)return String(e);if(!(e instanceof Error))return e;let a={name:e.name,message:e.message};for(let o of Object.getOwnPropertyNames(e)){if("name"===o||"message"===o)continue;let s=e[o];"function"!=typeof s&&("stack"===o?a.stack=s:"cause"===o?a.cause=r(s,t+1):"errors"===o&&Array.isArray(s)?a.errors=s.map(e=>r(e,t+1)):a[o]=s)}return a}function i(e,t,a,o,i){if(e>=("number"==typeof i?i:n)){if("function"==typeof o)try{o=o()}catch(e){o="[lazy log data threw]"}let n=new Date().toISOString(),i="[".concat(n,"] [").concat(t,"]"),l="".concat(i," ").concat(a);if(void 0!==o)if(o instanceof Error||"object"==typeof o)try{let e=o instanceof Error?r(o):o,t=JSON.stringify(e,(e,t)=>t instanceof Error?r(t):t,2);l+=":\n".concat(t)}catch(e){l+=": [Object cannot be stringified]"}else l+=": ".concat(o);switch(e){case s.VERBOSE:console.debug("[VERBOSE] ".concat(l));break;case s.DEBUG:console.debug(l);break;case s.INFO:console.info(l);break;case s.WARN:console.warn(l);break;case s.ERROR:console.error(l);break;default:console.log(l)}}}function l(e,t){let a,o=((a=e.replace(/^src\//,"")).startsWith("/")&&(a=a.substring(1)),a);return{verbose:(e,a)=>{i(s.VERBOSE,o,e,a,t)},debug:(e,a)=>{i(s.DEBUG,o,e,a,t)},info:(e,a)=>{i(s.INFO,o,e,a,t)},warn:(e,a)=>{i(s.WARN,o,e,a,t)},error:(e,a)=>{i(s.ERROR,o,e,a,t)}}}}},e=>{e.O(0,[2678,4754,9244,8548,5501,488,9356,8441,1255,7358],()=>e(e.s=32651)),_N_E=e.O()}]);
|