flujo-ai 3.11.0 → 3.12.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 +154 -154
- package/.next/app-path-routes-manifest.json +12 -12
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +15 -15
- package/.next/react-loadable-manifest.json +4 -4
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env/route.js +2 -2
- package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/init/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page.js +2 -2
- package/.next/server/app/chat/page.js.nft.json +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +2 -2
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +2 -2
- 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 +2 -2
- package/.next/server/app/flows/page.js +1 -1
- package/.next/server/app/flows/page.js.nft.json +1 -1
- package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/flows.html +1 -1
- package/.next/server/app/flows.rsc +2 -2
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/mcp/page.js +10 -10
- 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_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_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp.html +1 -1
- package/.next/server/app/mcp.rsc +2 -2
- package/.next/server/app/models/page.js +3 -3
- package/.next/server/app/models/page.js.nft.json +1 -1
- package/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +2 -2
- 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 +2 -2
- package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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.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_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +12 -12
- package/.next/server/chunks/1050.js +1 -0
- package/.next/server/chunks/1373.js +1 -1
- package/.next/server/chunks/1403.js +1 -1
- package/.next/server/chunks/1746.js +1 -0
- package/.next/server/chunks/1905.js +1 -1
- package/.next/server/chunks/2776.js +1 -1
- package/.next/server/chunks/3984.js +4 -4
- package/.next/server/chunks/5389.js +9 -9
- package/.next/server/chunks/5504.js +2 -2
- package/.next/server/chunks/5558.js +1 -0
- package/.next/server/chunks/5587.js +1 -0
- package/.next/server/chunks/5734.js +4 -4
- package/.next/server/chunks/{9314.js → 5888.js} +3 -3
- package/.next/server/chunks/6936.js +3 -3
- package/.next/server/chunks/6996.js +3 -3
- package/.next/server/chunks/724.js +2 -2
- package/.next/server/chunks/7328.js +1 -0
- package/.next/server/chunks/7485.js +1 -0
- package/.next/server/chunks/8434.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- 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/pages-manifest.json +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/1226-af62e7a89fa9032e.js +1 -0
- package/.next/static/chunks/1979-e2d922370ecef69f.js +1 -0
- package/.next/static/chunks/2158-0d6bb5a428ed0688.js +1 -0
- package/.next/static/chunks/256-7f4847b6726c866c.js +1 -0
- package/.next/static/chunks/2709-29f91a54eef90221.js +1 -0
- package/.next/static/chunks/539-8ddf886986877cfc.js +1 -0
- package/.next/static/chunks/6582-6735fdd6b42b5c35.js +1 -0
- package/.next/static/chunks/6902-cba4e59c4295b4a0.js +1 -0
- package/.next/static/chunks/8867-3f7163974605427b.js +1 -0
- package/.next/static/chunks/8989-401559d9f3bc80a0.js +1 -0
- package/.next/static/chunks/9164-36fedeb944fa71e9.js +1 -0
- package/.next/static/chunks/9414-3cd5c3976cba66b2.js +1 -0
- package/.next/static/chunks/9984-1ed094ea9f5b1f17.js +1 -0
- package/.next/static/chunks/app/chat/{page-aea8c8cbfa461e7f.js → page-5c838e3ce9d7a27d.js} +1 -1
- package/.next/static/chunks/app/docs/page-d4005b311ead55f2.js +1 -0
- package/.next/static/chunks/app/executions/{page-95fec57bf97ee809.js → page-870931839b84c8d5.js} +1 -1
- package/.next/static/chunks/app/flows/{page-7fe295069ccdb5fe.js → page-303dc4d2542567a6.js} +1 -1
- package/.next/static/chunks/app/mcp/page-5012a7e5b6366207.js +1 -0
- package/.next/static/chunks/app/models/page-4fc4d100a8b1d4b4.js +1 -0
- package/.next/static/chunks/app/settings/page-199cff457723ee57.js +1 -0
- package/.next/static/chunks/{webpack-63a4c59e84967e90.js → webpack-4015bd6f241940a1.js} +1 -1
- package/.next/trace +7 -7
- package/README.md +12 -5
- package/package.json +1 -1
- package/scripts/launch-next.mjs +17 -3
- package/.next/server/chunks/1381.js +0 -1
- package/.next/server/chunks/1555.js +0 -1
- package/.next/server/chunks/3426.js +0 -1
- package/.next/server/chunks/4379.js +0 -1
- package/.next/server/chunks/4989.js +0 -1
- package/.next/server/chunks/598.js +0 -1
- package/.next/server/chunks/6064.js +0 -1
- package/.next/static/chunks/1374-e084b3c40554288a.js +0 -1
- package/.next/static/chunks/1424-01898260211a09d0.js +0 -1
- package/.next/static/chunks/1811-8ee01cf37161913c.js +0 -1
- package/.next/static/chunks/2160-4d9f132965bc2a89.js +0 -1
- package/.next/static/chunks/2624-b985ab3eac1139c3.js +0 -1
- package/.next/static/chunks/3403-7c5037145e384171.js +0 -1
- package/.next/static/chunks/4205-b9e33afc7e96ecb9.js +0 -1
- package/.next/static/chunks/5648-2c6caf3d55f95e11.js +0 -1
- package/.next/static/chunks/7396-807a034f58b57712.js +0 -1
- package/.next/static/chunks/7458-4445e76668151564.js +0 -1
- package/.next/static/chunks/8215-a966f4c36f1ca174.js +0 -1
- package/.next/static/chunks/9164-d15e4dab0a1bf282.js +0 -1
- package/.next/static/chunks/app/docs/page-2a4cff7c40706a48.js +0 -1
- package/.next/static/chunks/app/mcp/page-0f923960004aa437.js +0 -1
- package/.next/static/chunks/app/models/page-d81d2b1fe2f1d063.js +0 -1
- package/.next/static/chunks/app/settings/page-d03a168f6efbf7fd.js +0 -1
- /package/.next/static/{9Pzu8N65j3JuRQ7zVUtwD → 07vmuF5x2Bs8Xj1OeV0QV}/_buildManifest.js +0 -0
- /package/.next/static/{9Pzu8N65j3JuRQ7zVUtwD → 07vmuF5x2Bs8Xj1OeV0QV}/_ssgManifest.js +0 -0
package/.next/static/chunks/app/executions/{page-95fec57bf97ee809.js → page-870931839b84c8d5.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1488],{17427:(e,t,a)=>{"use strict";a.d(t,{A:()=>p});var l=a(95155),n=a(12115),r=a(25635),o=a(94049),s=a(99944),i=a(9957),d=a(52641),c=a(51221),u=a(55606),h=a(86973),x=a(9562);let p=e=>{var t;let{schema:a,values:p,onChange:f,size:m="small"}=e,[g,y]=(0,n.useState)({}),w=null!=(t=null==a?void 0:a.properties)?t:{},v=Array.isArray(null==a?void 0:a.required)?a.required:[],j=Object.keys(w);if(0===j.length)return(0,l.jsx)(r.default,{variant:"body2",color:"text.secondary",children:"This tool takes no parameters."});let b=(e,t)=>{let a={...p};void 0===t?delete a[e]:a[e]=t,f(a)};return(0,l.jsx)(o.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:j.map(e=>{var t,a;let n=null!=(t=w[e])?t:{},f=v.includes(e)?"".concat(e," *"):e,j="string"==typeof n.description?n.description:"";if("boolean"===n.type)return(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{size:m,checked:!0===p[e],onChange:t=>b(e,t.target.checked)}),label:(0,l.jsxs)(o.default,{children:[(0,l.jsx)(r.default,{variant:"body2",children:f}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",children:j})]})},e);if(Array.isArray(n.enum)&&n.enum.length>0){let t=p[e];return(0,l.jsxs)(d.A,{size:m,fullWidth:!0,children:[(0,l.jsx)(c.A,{id:"schema-param-".concat(e),children:f}),(0,l.jsx)(u.A,{labelId:"schema-param-".concat(e),label:f,value:n.enum.includes(t)?t:"",onChange:t=>b(e,t.target.value),children:n.enum.map(e=>(0,l.jsx)(h.A,{value:e,children:String(e)},String(e)))}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mx:1.75},children:j})]},e)}if("number"===n.type||"integer"===n.type)return(0,l.jsx)(x.A,{fullWidth:!0,size:m,type:"number",label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>{let a=t.target.value;if(""===a)return void b(e,void 0);let l="integer"===n.type?parseInt(a,10):parseFloat(a);b(e,Number.isNaN(l)?void 0:l)},helperText:j},e);if("object"===n.type||"array"===n.type){let t=null!=(a=g[e])?a:void 0!==p[e]?JSON.stringify(p[e],null,2):"",r=null;if(t.trim())try{JSON.parse(t)}catch(e){r="Not valid JSON yet"}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,multiline:!0,minRows:2,label:"".concat(f," (JSON ").concat(n.type,")"),value:t,error:!!r,helperText:null!=r?r:j,onChange:t=>{let a=t.target.value;if(y(t=>({...t,[e]:a})),!a.trim())return void b(e,void 0);try{b(e,JSON.parse(a))}catch(e){}},slotProps:{input:{sx:{fontFamily:"monospace",fontSize:13}}}},e)}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>b(e,""===t.target.value?void 0:t.target.value),helperText:j},e)})})}},60187:(e,t,a)=>{Promise.resolve().then(a.bind(a,95271))},62640:(e,t,a)=>{"use strict";a.d(t,{A:()=>N});var l=a(95155),n=a(12115),r=a(2778),o=a(52363),s=a(65036),i=a(94049),d=a(78470),c=a(41983),u=a(9562),h=a(28548),x=a(22003),p=a(4474),f=a(25635),m=a(41602),g=a(73707),y=a(49501),w=a(17681),v=a(75912),j=a(70690),b=a(80007),A=a(74482),k=a(40171),C=a(36944);let S=(0,a(87021).h)("frontend/components/shared/FolderPickerDialog"),N=e=>{let{open:t,title:a="Choose a folder",selectFiles:N=!1,initialPath:T,onClose:E,onSelect:I}=e,[F,W]=(0,n.useState)(null),[P,R]=(0,n.useState)(""),[O,z]=(0,n.useState)(!1),[M,U]=(0,n.useState)(null),D=(0,n.useCallback)(async e=>{z(!0),U(null);try{let t=e?"?path=".concat(encodeURIComponent(e)):"",a=await fetch("/api/browse".concat(t)),l=await a.json();if(!a.ok||l.error)return void U(l.error||"HTTP ".concat(a.status));W(l),R(l.path)}catch(e){S.warn("Browse failed",e),U("Could not reach the backend to browse folders.")}finally{z(!1)}},[]);(0,n.useEffect)(()=>{t?D(T||void 0):(W(null),U(null))},[t,T,D]);let L=e=>{I(e),E()};return(0,l.jsxs)(r.A,{open:t,onClose:E,maxWidth:"sm",fullWidth:!0,children:[(0,l.jsx)(o.A,{children:a}),(0,l.jsxs)(s.A,{dividers:!0,sx:{display:"flex",flexDirection:"column",gap:1.5},children:[(0,l.jsxs)(i.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(d.A,{title:"Up one folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:!(null==F?void 0:F.parent)||O,onClick:()=>(null==F?void 0:F.parent)&&void D(F.parent),children:(0,l.jsx)(k.A,{fontSize:"small"})})})}),(0,l.jsx)(d.A,{title:"Home folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:O,onClick:()=>void D(),children:(0,l.jsx)(C.A,{fontSize:"small"})})})}),(0,l.jsx)(u.A,{fullWidth:!0,size:"small",value:P,onChange:e=>R(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),D(P))},placeholder:"Type a path and press Enter"})]}),F&&F.drives.length>0&&(0,l.jsx)(i.default,{sx:{display:"flex",gap:.75,flexWrap:"wrap"},children:F.drives.map(e=>(0,l.jsx)(h.A,{label:e,size:"small",variant:F.path.toLowerCase().startsWith(e.toLowerCase())?"filled":"outlined",onClick:()=>void D(e)},e))}),M&&(0,l.jsx)(x.A,{severity:"error",children:M}),(0,l.jsxs)(i.default,{sx:{minHeight:240,maxHeight:"45vh",overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:[O&&(0,l.jsx)(i.default,{sx:{display:"flex",justifyContent:"center",py:4},children:(0,l.jsx)(p.default,{size:24})}),!O&&F&&0===F.entries.length&&(0,l.jsx)(f.default,{variant:"body2",color:"text.secondary",sx:{p:2},children:"This folder is empty."}),!O&&(0,l.jsx)(m.A,{dense:!0,disablePadding:!0,children:null==F?void 0:F.entries.map(e=>(0,l.jsxs)(g.A,{disabled:!e.isDirectory&&!N,onClick:()=>e.isDirectory?void D(e.path):L(e.path),children:[(0,l.jsx)(y.A,{sx:{minWidth:34},children:e.isDirectory?(0,l.jsx)(b.A,{fontSize:"small",color:"primary"}):(0,l.jsx)(A.A,{fontSize:"small"})}),(0,l.jsx)(w.A,{primary:e.name,primaryTypographyProps:{noWrap:!0}})]},e.path))})]})]}),(0,l.jsxs)(v.A,{children:[(0,l.jsx)(j.A,{onClick:E,children:"Cancel"}),(0,l.jsx)(j.A,{variant:"contained",disabled:!F||O,onClick:()=>F&&L(F.path),children:"Select this folder"})]})]})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>o});var l=a(74879);let n=(0,a(87021).h)("frontend/services/flow/index");class r{async loadFlows(){n.debug("loadFlows: Entering method");try{if(this.flowsCache)return n.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return n.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return n.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){n.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return n.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return n.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return n.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return n.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){n.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),n.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async updateFlow(e){n.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return n.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){n.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),n.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return n.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}createNode(e,t){return n.debug("createNode: Entering method",{type:e,position:t}),{id:(0,l.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:{}}}}createStartNode(){return{id:(0,l.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";return n.debug("createNewFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return n.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return n.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let o=new r},95271:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>eF});var l=a(95155),n=a(94049),r=a(12115),o=a(25635),s=a(99944),i=a(9957),d=a(70690),c=a(2778),u=a(52363),h=a(65036),x=a(75912),p=a(86946),f=a(76530),m=a(78470),g=a(41983),y=a(87021);let w=(0,y.h)("frontend/services/plannedExecutions");class v{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return w.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await a.json();if(!a.ok)return{success:!1,error:(null==l?void 0:l.error)||"HTTP ".concat(a.status)};return{success:!0,execution:l.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return w.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let j=new v;var b=a(2300),A=a(28548),k=a(4474),C=a(50430),S=a(55406),N=a(14915),T=a(4484),E=a(63186),I=a(62962),F=a(3713);let W=e=>String(e).padStart(2,"0"),P=e=>{switch(e){case"completed":return"success.main";case"error":return"error.main";case"skipped":return"warning.main";default:return"transparent"}},R=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",O=e=>{if(!e.finishedAt)return"";let t=new Date(e.finishedAt).getTime()-new Date(e.firedAt).getTime();return t<1e3?"<1s":t<6e4?"".concat(Math.round(t/1e3),"s"):"".concat(Math.round(t/6e4),"min")},z=e=>{var t;let{entry:a,onEdit:s,onDelete:p,onToggleEnabled:f,onRanNow:y}=e,{execution:w,status:v,lastRun:z}=a,[M,U]=(0,r.useState)(!1),[D,L]=(0,r.useState)(null),[H,J]=(0,r.useState)(!1),[q,$]=(0,r.useState)(!1),[B,G]=(0,r.useState)(null),_=(0,r.useCallback)(async()=>{J(!0),L([...await j.loadRuns(w.id)].reverse()),J(!1)},[w.id]);(0,r.useEffect)(()=>{M&&_()},[M,_,null==z?void 0:z.runId]);let K=async()=>{$(!0),await j.runNow(w.id),$(!1),M&&_(),y()};return(0,l.jsxs)(b.A,{variant:"outlined",sx:{p:2},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap"},children:[(0,l.jsxs)(n.default,{sx:{flexGrow:1,minWidth:220},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600},children:w.name}),(0,l.jsx)(A.A,{size:"small",label:function(e){switch(e.type){case"schedule":{var t;let a,l=(t=e.cron,(a=/^\*\/(\d+) \* \* \* \* \*$/.exec(t))?"Every ".concat(a[1],"s"):(a=/^\*\/(\d+) \* \* \* \*$/.exec(t))?"Every ".concat(a[1]," min"):(a=/^0 \*\/(\d+) \* \* \*$/.exec(t))?1===Number(a[1])?"Every hour":"Every ".concat(a[1]," hours"):(a=/^(\d+) (\d+) \* \* \*$/.exec(t))?"Daily at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):(a=/^(\d+) (\d+) \* \* 1-5$/.exec(t))?"Weekdays at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):null);return null!=l?l:"Schedule: ".concat(e.cron)}case"webhook":return"Webhook";case"file-watch":return"Watching ".concat(e.path);case"mcp-poll":return"Watching ".concat(e.serverName," › ").concat(e.toolName);case"url-watch":try{return"Watching ".concat(new URL(e.url).hostname)}catch(e){return"Watching a URL"}default:return"Trigger"}}(w.trigger)}),!w.enabled&&(0,l.jsx)(A.A,{size:"small",label:"Off",variant:"outlined"})]}),v.running?(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(k.default,{size:12,thickness:6}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Running…",v.runningSince?" — started ".concat(R(v.runningSince)):""]})]}):(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[v.nextRun&&w.enabled?"Next run: ".concat(R(v.nextRun)):w.enabled&&!v.armed?"Not armed":"",v.lastTriggerError?" — trigger error: ".concat(v.lastTriggerError):""]}),z&&(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(m.A,{title:z.status,children:(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(z.status),flexShrink:0}})}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Last run ",R(z.firedAt),"error"===z.status&&z.error?" — ".concat(z.error):""]})]})]}),(0,l.jsx)(m.A,{title:"Run now",children:(0,l.jsx)("span",{children:(0,l.jsx)(g.A,{onClick:K,disabled:q,color:"primary",children:q?(0,l.jsx)(k.default,{size:20}):(0,l.jsx)(S.A,{})})})}),(0,l.jsx)(m.A,{title:w.enabled?"Turn off":"Turn on",children:(0,l.jsx)(i.A,{checked:w.enabled,onChange:e=>f(e.target.checked)})}),(0,l.jsx)(m.A,{title:"Edit",children:(0,l.jsx)(g.A,{onClick:s,children:(0,l.jsx)(N.A,{})})}),(0,l.jsx)(m.A,{title:"Delete",children:(0,l.jsx)(g.A,{onClick:p,children:(0,l.jsx)(T.A,{})})}),(0,l.jsx)(m.A,{title:M?"Hide run history":"Show run history",children:(0,l.jsx)(g.A,{onClick:()=>U(e=>!e),children:M?(0,l.jsx)(I.A,{}):(0,l.jsx)(E.A,{})})})]}),(0,l.jsx)(C.A,{in:M,timeout:"auto",unmountOnExit:!0,children:(0,l.jsxs)(n.default,{sx:{mt:2,borderTop:1,borderColor:"divider",pt:1.5},children:[H&&!D&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Loading runs…"}),D&&0===D.length&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No runs yet. Use the play button to try it now."}),null==D?void 0:D.map(e=>{var t;return(0,l.jsxs)(n.default,{sx:{display:"flex",gap:1,py:.75,alignItems:"flex-start","&:hover .run-detail-button":{opacity:1}},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(e.status),mt:"5px",flexShrink:0}}),(0,l.jsxs)(n.default,{sx:{minWidth:0,flexGrow:1},children:[(0,l.jsxs)(o.default,{variant:"body2",children:[R(e.firedAt),O(e)?" \xb7 ".concat(O(e)):""," \xb7 ",e.triggerSummary,(null==(t=e.usage)?void 0:t.totalTokens)?" \xb7 ".concat(e.usage.totalTokens.toLocaleString()," tokens"):""]}),e.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",children:e.error}),e.outputText&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.outputText})]}),(0,l.jsx)(m.A,{title:"Show full output",children:(0,l.jsx)(g.A,{className:"run-detail-button",size:"small",onClick:()=>G(e),sx:{opacity:{xs:1,md:.35},transition:"opacity 120ms",flexShrink:0},children:(0,l.jsx)(F.A,{fontSize:"inherit"})})})]},e.runId)})]})}),(0,l.jsxs)(c.A,{open:null!==B,onClose:()=>G(null),maxWidth:"md",fullWidth:!0,children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:B?P(B.status):"transparent",flexShrink:0}}),(0,l.jsxs)(o.default,{variant:"h6",children:[w.name," — ",B?R(B.firedAt):""]})]})}),(0,l.jsx)(h.A,{dividers:!0,children:B&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:[B.status,O(B)?" \xb7 ".concat(O(B)):""," \xb7 ",B.triggerSummary,(null==(t=B.usage)?void 0:t.totalTokens)?" \xb7 ".concat(B.usage.totalTokens.toLocaleString()," tokens (").concat(B.usage.promptTokens.toLocaleString()," in / ").concat(B.usage.completionTokens.toLocaleString()," out)"):""]}),B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",sx:{mb:1.5,whiteSpace:"pre-wrap"},children:B.error}),B.outputText?(0,l.jsx)(n.default,{sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",bgcolor:"action.hover",borderRadius:1,p:2,fontSize:14,maxHeight:"55vh",overflow:"auto"},children:B.outputText}):!B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This run produced no output text."})]})}),(0,l.jsx)(x.A,{children:(0,l.jsx)(d.A,{onClick:()=>G(null),children:"Close"})})]})]})};var M=a(21067),U=a(9562),D=a(52641),L=a(51221),H=a(55606),J=a(86973),q=a(22003),$=a(77073),B=a(26922),G=a(40520),_=a(79299),K=a(22590),Q=a(53657),X=a(90057),Y=a(36741);let V=e=>{let{selected:t,icon:a,title:r,description:s,onClick:i}=e;return(0,l.jsxs)(n.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:i,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},sx:{flex:1,minWidth:200,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,l.jsx)(Y.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[a,(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:r})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:s})]})};var Z=a(22822),ee=a(98267),et=a(20537),ea=a(37960);let el=e=>String(e).padStart(2,"0"),en=e=>{let{cron:t,timezone:a,onChange:i,verb:d="Runs",catchUp:c,onCatchUpChange:u}=e,h=(0,r.useMemo)(()=>(function(e){let t=/^\*\/(\d+) \* \* \* \* \*$/.exec(e);return t?{mode:"seconds",n:Number(t[1]),time:"09:00"}:(t=/^\*\/(\d+) \* \* \* \*$/.exec(e))?{mode:"minutes",n:Number(t[1]),time:"09:00"}:(t=/^0 \*\/(\d+) \* \* \*$/.exec(e))?{mode:"hours",n:Number(t[1]),time:"09:00"}:(t=/^(\d+) (\d+) \* \* \*$/.exec(e))?{mode:"daily",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:(t=/^(\d+) (\d+) \* \* 1-5$/.exec(e))?{mode:"weekdays",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:{mode:"custom",n:15,time:"09:00"}})(t),[]),[x,p]=(0,r.useState)(h.mode),[f,m]=(0,r.useState)(h.n),[g,y]=(0,r.useState)(h.time),[w,v]=(0,r.useState)(t),[b,A]=(0,r.useState)(null),k=function(e,t,a,l){let[n,r]=a.split(":").map(Number);switch(e){case"seconds":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * * *");case"minutes":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * *");case"hours":return"0 */".concat(Math.max(1,Math.min(23,Math.floor(t)||1))," * * *");case"daily":return"".concat(r||0," ").concat(n||0," * * *");case"weekdays":return"".concat(r||0," ").concat(n||0," * * 1-5");default:return l}}(x,f,g,w);return(0,r.useEffect)(()=>{k!==t&&i({cron:k,timezone:a})},[k]),(0,r.useEffect)(()=>{let e=!1,t=setTimeout(()=>{j.previewSchedule(k,a).then(t=>{e||A(t)})},300);return()=>{e=!0,clearTimeout(t)}},[k,a]),(0,l.jsxs)(n.default,{children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1},children:[(0,l.jsxs)(D.A,{sx:{minWidth:180},children:[(0,l.jsx)(L.A,{id:"schedule-preset-label",children:d}),(0,l.jsxs)(H.A,{labelId:"schedule-preset-label",label:d,value:x,onChange:e=>p(e.target.value),children:[(0,l.jsx)(J.A,{value:"seconds",children:"Every N seconds"}),(0,l.jsx)(J.A,{value:"minutes",children:"Every N minutes"}),(0,l.jsx)(J.A,{value:"hours",children:"Every N hours"}),(0,l.jsx)(J.A,{value:"daily",children:"Daily at a time"}),(0,l.jsx)(J.A,{value:"weekdays",children:"Weekdays at a time"}),(0,l.jsx)(J.A,{value:"custom",children:"Custom (cron)"})]})]}),("seconds"===x||"minutes"===x||"hours"===x)&&(0,l.jsx)(U.A,{label:"seconds"===x?"Seconds":"minutes"===x?"Minutes":"Hours",type:"number",value:f,onChange:e=>m(Number(e.target.value)),inputProps:{min:1,max:"hours"===x?23:59},sx:{width:120}}),("daily"===x||"weekdays"===x)&&(0,l.jsx)(U.A,{label:"Time",type:"time",value:g,onChange:e=>y(e.target.value),sx:{width:150},InputLabelProps:{shrink:!0}}),"custom"===x&&(0,l.jsx)(U.A,{label:"Cron pattern",value:w,onChange:e=>v(e.target.value),sx:{minWidth:220},placeholder:"*/15 * * * *"})]}),b&&!b.valid&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:b.error||"This schedule is not valid."}),b&&b.valid&&b.nextRuns.length>0&&(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:2},children:["Next: ",b.nextRuns.map(e=>new Date(e).toLocaleString()).join(" \xb7 ")]}),u&&(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===c,onChange:e=>u(e.target.checked)}),label:"If FLUJO was closed at a scheduled time, run once on startup"}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(U.A,{label:"Timezone (optional)",value:a||"",onChange:e=>i({cron:k,timezone:e.target.value||void 0}),placeholder:"e.g. Europe/Berlin",helperText:"IANA timezone name. Empty = this computer's timezone.",sx:{minWidth:260}}),(0,l.jsx)(U.A,{label:"Generated cron pattern",value:k,InputProps:{readOnly:"custom"!==x},onChange:e=>{p("custom"),v(e.target.value)},helperText:"Editing switches to Custom mode.",sx:{minWidth:220}})]})})]})]})};var er=a(52277),eo=a(9693);let es=e=>{let{config:t,onChange:a,executionId:i,saved:c}=e,[u,h]=(0,r.useState)(null),x=window.location.origin,p="".concat(x,"/api/webhooks/").concat(i),f=async(e,t)=>{try{await navigator.clipboard.writeText(t),h(e),setTimeout(()=>h(null),1500)}catch(e){}};return(0,l.jsxs)(n.default,{sx:{mt:1},children:[!c&&(0,l.jsx)(q.A,{severity:"info",sx:{mb:2},children:"This URL and token are ready to copy now — they become active when you save."}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Webhook URL",value:p,InputProps:{readOnly:!0},size:"small"}),(0,l.jsx)(m.A,{title:"Copy URL",children:(0,l.jsx)(g.A,{onClick:()=>f("url",p),children:"url"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})})]}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mt:2},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Secret token",value:t.token,InputProps:{readOnly:!0},size:"small",type:"password"}),(0,l.jsx)(m.A,{title:"Copy token",children:(0,l.jsx)(g.A,{onClick:()=>f("token",t.token),disabled:!t.token,children:"token"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})}),(0,l.jsx)(d.A,{size:"small",onClick:()=>a({...t,token:crypto.randomUUID()}),sx:{whiteSpace:"nowrap"},children:"New token"})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:c?"A new token takes effect when you save — callers using the old one are cut off.":""}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:1.5},children:["Callers send a POST with the token in the ",(0,l.jsx)("code",{children:"X-Flujo-Token"})," ","header (or ",(0,l.jsx)("code",{children:"?token=…"}),"). The request body becomes part of the flow's input — treat it as untrusted data in your prompt."]}),(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===t.allowExternal,onChange:e=>a({...t,allowExternal:e.target.checked})}),label:"Allow calls from other machines (default: this computer only)"}),t.allowExternal&&(0,l.jsx)(q.A,{severity:"warning",children:"FLUJO assumes a single user on this machine. If you expose it beyond localhost (port forwarding, tunnels), securing that access is your responsibility — anyone with the URL and token can run this flow."})]})};var ei=a(56422),ed=a(17325),ec=a(80007),eu=a(62640);let eh=[{value:"add",label:"A file appears"},{value:"change",label:"A file changes"},{value:"unlink",label:"A file is deleted"}],ex=e=>{var t;let{config:a,onChange:i}=e,[d,c]=(0,r.useState)(!1);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Folder (or file) to watch",value:a.path,onChange:e=>i({...a,path:e.target.value}),placeholder:"e.g. C:\\Users\\me\\Documents\\inbox",margin:"normal",InputProps:{endAdornment:(0,l.jsx)(ei.A,{position:"end",children:(0,l.jsx)(m.A,{title:"Browse folders (on the FLUJO machine)",children:(0,l.jsx)(g.A,{edge:"end",onClick:()=>c(!0),children:(0,l.jsx)(ec.A,{})})})})}}),(0,l.jsx)(eu.A,{open:d,title:"Choose what to watch",selectFiles:!0,initialPath:a.path||void 0,onClose:()=>c(!1),onSelect:e=>i({...a,path:e})}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Only files matching (optional)",value:a.glob||"",onChange:e=>i({...a,glob:e.target.value||void 0}),placeholder:"e.g. *.pdf or reports/**/*.csv",helperText:"Simple patterns: * matches within a folder, ** across folders, ? one character.",margin:"normal"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"Run when…"}),(0,l.jsx)(ed.A,{row:!0,children:eh.map(e=>(0,l.jsx)(s.A,{control:(0,l.jsx)(Z.A,{checked:a.events.includes(e.value),onChange:t=>((e,t)=>{let l=t?[...a.events,e]:a.events.filter(t=>t!==e);i({...a,events:l})})(e.value,t.target.checked)}),label:e.label},e.value))}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"Bursts are batched: many files changing at once produce one run with all changes listed. If this flow writes into the watched folder, it will trigger itself in a loop — point its output somewhere else."}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsx)(U.A,{label:"Quiet window (ms)",type:"number",value:null!=(t=a.debounceMs)?t:2e3,onChange:e=>i({...a,debounceMs:Math.max(0,Number(e.target.value)||0)}),helperText:"How long to wait after the last change before running.",inputProps:{min:0,step:500},sx:{width:220}})})]})]})};var ep=a(41356),ef=a(24610),em=a(17897),eg=a(43076),ey=a(17427);let ew=(0,y.h)("frontend/components/PlannedExecutions/WatchToolPanel"),ev=e=>{var t,a;let{config:s,onChange:i}=e,[c,u]=(0,r.useState)([]),[h,x]=(0,r.useState)([]),[p,f]=(0,r.useState)(!1),[m,g]=(0,r.useState)(Object.keys(s.args||{}).length>0?JSON.stringify(s.args,null,2):""),[y,w]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,S]=(0,r.useState)(null),[N,T]=(0,r.useState)([]),[E,I]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return em.S.loadServerConfigs().then(t=>{e||(Array.isArray(t)?u(t.filter(e=>!e.disabled).map(e=>e.name)):(ew.warn("Failed to load MCP servers for watch-tool panel",t),u([])))}),()=>{e=!0}},[]),(0,r.useEffect)(()=>{if(!s.serverName)return void x([]);let e=!1;return f(!0),em.S.listServerTools(s.serverName).then(t=>{let{tools:a}=t;e||x(a||[])}).finally(()=>{e||f(!1)}),()=>{e=!0}},[s.serverName]),(0,r.useEffect)(()=>{let e=!1;return eg.N.loadModels().then(t=>{e||T(Array.isArray(t)?t:[])}).catch(()=>{e||T([])}),X.g.loadFlows().then(t=>{e||I(t||[])}).catch(()=>{e||I([])}),()=>{e=!0}},[]);let F=async()=>{j(!0),A(null),S(null);try{let a=await em.S.callTool(s.serverName,s.toolName,s.args||{});if(null==a?void 0:a.error)S("string"==typeof a.error?a.error:"Tool call failed");else{var e,t;let l=null!=(e=null==a?void 0:a.data)?e:a,n=null!=(t=JSON.stringify(l,null,2))?t:"";A(n.length>6e3?"".concat(n.slice(0,6e3),"\n… (truncated)"):n)}}catch(e){S(e instanceof Error?e.message:"Tool call failed")}finally{j(!1)}},W=s.evaluate,P=h.find(e=>e.name===s.toolName);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",children:[(0,l.jsx)(L.A,{id:"watch-server-label",children:"Server"}),(0,l.jsxs)(H.A,{labelId:"watch-server-label",label:"Server",value:c.includes(s.serverName)?s.serverName:"",onChange:e=>i({...s,serverName:e.target.value,toolName:""}),children:[0===c.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No MCP servers configured"}),c.map(e=>(0,l.jsx)(J.A,{value:e,children:e},e))]})]}),(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",disabled:!s.serverName,children:[(0,l.jsx)(L.A,{id:"watch-tool-label",children:"Tool"}),(0,l.jsxs)(H.A,{labelId:"watch-tool-label",label:"Tool",value:h.some(e=>e.name===s.toolName)?s.toolName:"",onChange:e=>i({...s,toolName:e.target.value,args:{}}),children:[0===h.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:p?"Loading tools…":"Pick a server first"}),h.map(e=>(0,l.jsx)(J.A,{value:e.name,children:e.name},e.name))]})]})]}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:null!=(t=s.cron)?t:function(e){let t=Math.max(5,Math.round((null!=e?e:6e4)/1e3));if(t<60)return"*/".concat(t," * * * * *");let a=Math.max(1,Math.round(t/60));if(a<60)return"*/".concat(a," * * * *");let l=Math.max(1,Math.min(23,Math.round(a/60)));return"0 */".concat(l," * * *")}(s.intervalMs),timezone:s.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return i({...s,cron:t,timezone:a})}}),P?(0,l.jsxs)(n.default,{sx:{my:1.5},children:[(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mb:1.5},children:"Tool parameters — sent on every check"}),(0,l.jsx)(ey.A,{schema:P.inputSchema,values:s.args||{},onChange:e=>i({...s,args:e})})]}):(0,l.jsx)(U.A,{fullWidth:!0,label:"Tool arguments (JSON, optional)",value:m,onChange:e=>(e=>{if(g(e),!e.trim()){w(null),i({...s,args:{}});return}try{let t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))return void w('Arguments must be a JSON object, e.g. { "query": "…" }');w(null),i({...s,args:t})}catch(e){w("Not valid JSON yet")}})(e.target.value),margin:"normal",multiline:!0,minRows:2,placeholder:'{ "query": "is:unread" }',error:!!y,helperText:null!=y?y:"Sent to the tool on every check.",slotProps:{input:{sx:{fontFamily:"monospace",fontSize:14}}}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[(0,l.jsx)(d.A,{variant:"outlined",size:"small",onClick:F,disabled:!s.serverName||!s.toolName||v||!!y,startIcon:v?(0,l.jsx)(k.default,{size:16}):void 0,children:"Test: call the tool now"}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"See what the result looks like — useful for the settings below."})]}),C&&(0,l.jsx)(q.A,{severity:"error",sx:{mb:1},children:C}),b&&(0,l.jsx)(n.default,{component:"pre",sx:{maxHeight:240,overflow:"auto",bgcolor:"action.hover",borderRadius:1,p:1.5,fontSize:12,m:0,mb:1},children:b}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:2,mb:1},children:"Run the flow when…"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Poll condition",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"on-change"===W.mode,onClick:()=>i({...s,evaluate:{mode:"on-change"}}),icon:(0,l.jsx)(ep.A,{}),title:"The result changes",description:"Any difference from the last check runs the flow. Simplest — no setup."}),(0,l.jsx)(V,{selected:"llm-gate"===W.mode||"flow-gate"===W.mode,onClick:()=>{"llm-gate"!==W.mode&&"flow-gate"!==W.mode&&i({...s,evaluate:{mode:"llm-gate",condition:"",modelId:""}})},icon:(0,l.jsx)(ef.A,{}),title:"AI decides",description:"Describe the condition in plain language; a model — or one of your flows — checks the result whenever it changes."})]}),("llm-gate"===W.mode||"flow-gate"===W.mode)&&(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Run the flow if…",value:W.condition,onChange:e=>i({...s,evaluate:{...W,condition:e.target.value}}),multiline:!0,minRows:2,margin:"normal",placeholder:"e.g. any email mentions an invoice or a payment reminder"}),(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-start"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:170},children:[(0,l.jsx)(L.A,{id:"gate-checker-label",children:"Checked by"}),(0,l.jsxs)(H.A,{labelId:"gate-checker-label",label:"Checked by",value:W.mode,onChange:e=>{let t=e.target.value;if(t===W.mode)return;let a={condition:W.condition,maxCallsPerDay:W.maxCallsPerDay};i({...s,evaluate:"llm-gate"===t?{mode:t,...a,modelId:""}:{mode:t,...a,flowId:""}})},children:[(0,l.jsx)(J.A,{value:"llm-gate",children:"A model"}),(0,l.jsx)(J.A,{value:"flow-gate",children:"One of my flows"})]})]}),"llm-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-model-label",children:"Model that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-model-label",label:"Model that checks",value:N.some(e=>e.id===W.modelId)?W.modelId:"",onChange:e=>i({...s,evaluate:{...W,modelId:e.target.value}}),children:[0===N.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No models configured"}),N.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),"flow-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-flow-label",children:"Flow that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-flow-label",label:"Flow that checks",value:E.some(e=>e.id===W.flowId)?W.flowId:"",onChange:e=>i({...s,evaluate:{...W,flowId:e.target.value}}),children:[0===E.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No flows available"}),E.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),(0,l.jsx)(U.A,{label:"Max checks per day",type:"number",value:null!=(a=W.maxCallsPerDay)?a:500,onChange:e=>i({...s,evaluate:{...W,maxCallsPerDay:Math.max(1,Number(e.target.value)||1)}}),inputProps:{min:1},helperText:"Cost guard per check.",sx:{width:180}})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5},children:"flow-gate"===W.mode?'The checker flow runs invisibly (never in the chat), gets the condition + tool result, and must answer with {"fire": true/false, "reason": "…"} — it can use its own tools to verify before deciding.':"The model is only asked when the result actually changed since the last check — an idle feed costs nothing. Pick a small, cheap model."})]}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:2},children:"The first check only takes a snapshot — the flow runs from the second check onwards, when something actually changed. FLUJO must be running for checks to happen."})]})},ej=e=>{let{config:t,onChange:a}=e;return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"URL to watch",value:t.url,onChange:e=>a({...t,url:e.target.value}),placeholder:"https://example.com/status or an API/feed URL",margin:"normal",type:"url"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:t.cron,timezone:t.timezone,onChange:e=>{let{cron:l,timezone:n}=e;return a({...t,cron:l,timezone:n})}}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"The first check only takes a snapshot; the flow runs when a later check finds different content, and the fetched content is handed to the flow. Pages that embed ever-changing bits (timestamps, session tokens) look “changed” on every check — plain APIs, feeds, and raw files work best."})]})},eb=(0,y.h)("frontend/components/PlannedExecutions/ExecutionModal"),eA={type:"schedule",cron:"0 9 * * *"},ek={type:"file-watch",path:"",events:["add","change"]},eC={type:"mcp-poll",serverName:"",toolName:"",args:{},cron:"*/5 * * * *",evaluate:{mode:"on-change"}},eS={type:"url-watch",url:"",cron:"*/15 * * * *"},eN=e=>{var t;let{open:a,execution:p,onClose:f,onSaved:m}=e,[y,w]=(0,r.useState)(""),[v,b]=(0,r.useState)(""),[A,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!1),[N,T]=(0,r.useState)(eA),[E,I]=(0,r.useState)(""),[F,W]=(0,r.useState)([]),[P,R]=(0,r.useState)(!1),[O,z]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e,t,l,n;a&&(Z(null),w(null!=(e=null==p?void 0:p.name)?e:""),b(null!=(t=null==p?void 0:p.flowId)?t:""),k(null!=(l=null==p?void 0:p.prompt)?l:""),S((null==p?void 0:p.saveConversations)===!0),T(null!=(n=null==p?void 0:p.trigger)?n:eA),I(p?"":crypto.randomUUID()))},[a,p]),(0,r.useEffect)(()=>{if(!a)return;let e=!1;return R(!0),X.g.loadFlows().then(t=>{e||W(t||[])}).catch(t=>{eb.warn("Failed to load flows for execution picker",t),e||W([])}).finally(()=>{e||R(!1)}),()=>{e=!0}},[a]);let ee=!!v&&!P&&F.length>0&&!F.some(e=>e.id===v),et=async()=>{var e;z(!0),Z(null);let t={name:y,flowId:v,prompt:A,saveConversations:C,trigger:N,enabled:null==(e=null==p?void 0:p.enabled)||e,...p?{}:{id:E}},a=p?await j.update(p.id,t):await j.create(t);if(z(!1),!a.success)return void Z(a.error||"Failed to save");m(),f()};return(0,l.jsxs)(c.A,{open:a,onClose:f,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,l.jsx)(o.default,{variant:"h6",children:p?"Edit planned execution":"New planned execution"}),(0,l.jsx)(g.A,{edge:"end",color:"inherit",onClick:f,"aria-label":"close",children:(0,l.jsx)($.A,{})})]})}),(0,l.jsx)(M.A,{}),(0,l.jsxs)(h.A,{sx:{p:3},children:[(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"A planned execution runs one of your flows automatically — on a schedule or when something happens — without anyone sitting in the chat. Results show up in its run history on the Executions page."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Name",value:y,onChange:e=>w(e.target.value),margin:"normal",placeholder:"e.g. Morning news digest"}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:3,mb:1,fontWeight:600},children:"1 \xb7 When should it run?"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Trigger type",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"schedule"===N.type,onClick:()=>{"schedule"!==N.type&&T((null==p?void 0:p.trigger.type)==="schedule"?p.trigger:eA)},icon:(0,l.jsx)(B.A,{}),title:"On a schedule",description:"Run at fixed times — every few minutes, daily, on weekdays, or a custom rhythm."}),(0,l.jsx)(V,{selected:"webhook"===N.type,onClick:()=>{"webhook"!==N.type&&T((null==p?void 0:p.trigger.type)==="webhook"?p.trigger:{type:"webhook",token:crypto.randomUUID()})},icon:(0,l.jsx)(G.A,{}),title:"When called (webhook)",description:"Other apps run this flow by calling a URL — GitHub, Stripe, Slack and most services can send webhooks."}),(0,l.jsx)(V,{selected:"file-watch"===N.type,onClick:()=>{"file-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="file-watch"?p.trigger:ek)},icon:(0,l.jsx)(_.A,{}),title:"When files change",description:"Watch a folder on this computer and run when files appear, change, or disappear."}),(0,l.jsx)(V,{selected:"mcp-poll"===N.type,onClick:()=>{"mcp-poll"!==N.type&&T((null==p?void 0:p.trigger.type)==="mcp-poll"?p.trigger:eC)},icon:(0,l.jsx)(K.A,{}),title:"Watch a tool",description:"Check one of your MCP tools regularly — run when its result changes, or let AI decide."}),(0,l.jsx)(V,{selected:"url-watch"===N.type,onClick:()=>{"url-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="url-watch"?p.trigger:eS)},icon:(0,l.jsx)(Q.A,{}),title:"When a website changes",description:"Check a URL regularly and run when its content is different from the last check."})]}),"schedule"===N.type&&(0,l.jsx)(en,{cron:N.cron,timezone:N.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return T({...N,cron:t,timezone:a})},catchUp:!0===N.catchUp,onCatchUpChange:e=>T({...N,catchUp:e})}),"webhook"===N.type&&(0,l.jsx)(es,{config:N,onChange:T,executionId:null!=(t=null==p?void 0:p.id)?t:E,saved:null!==p}),"file-watch"===N.type&&(0,l.jsx)(ex,{config:N,onChange:T}),"mcp-poll"===N.type&&(0,l.jsx)(ev,{config:N,onChange:T}),"url-watch"===N.type&&(0,l.jsx)(ej,{config:N,onChange:T}),(0,l.jsx)(M.A,{sx:{mt:3}}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:2,mb:0,fontWeight:600},children:"2 \xb7 What should it run?"}),(0,l.jsxs)(D.A,{fullWidth:!0,margin:"normal",children:[(0,l.jsx)(L.A,{id:"execution-flow-label",children:"Flow to run"}),(0,l.jsxs)(H.A,{labelId:"execution-flow-label",label:"Flow to run",value:ee?"":v,onChange:e=>b(e.target.value),displayEmpty:!0,children:[0===F.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:P?"Loading flows…":"No flows available"}),F.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),ee&&(0,l.jsx)(q.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"What should the flow do?",value:A,onChange:e=>k(e.target.value),margin:"normal",multiline:!0,rows:3,helperText:"Sent to the flow as the user message each time this runs. Run details are attached automatically: current time, what triggered it, the previous run, the next planned run, and any trigger data."}),(0,l.jsx)(s.A,{sx:{mt:1},control:(0,l.jsx)(i.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Save full conversations (each run appears in the chat sidebar — useful for debugging)"}),Y&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:Y})]}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:f,children:"Cancel"}),(0,l.jsx)(d.A,{onClick:et,variant:"contained",color:"primary",disabled:O||!y.trim()||!v,children:O?"Saving…":"Save"})]})]})},eT=(0,y.h)("frontend/components/PlannedExecutions"),eE=()=>{let[e,t]=(0,r.useState)([]),[a,y]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),[b,A]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,N]=(0,r.useState)(null),T=(0,r.useCallback)(async()=>{let e=await j.list();t(e.executions),y(e.paused),v(!0)},[]);(0,r.useEffect)(()=>{T()},[T]);let E=e.some(e=>e.status.running);(0,r.useEffect)(()=>{let e=setInterval(()=>{document.hidden||T()},E?3e3:1e4);return()=>clearInterval(e)},[T,E]);let I=async e=>{y(e);let t=await j.setPaused(e);t.success||eT.warn("Failed to toggle pause",t.error),T()},F=async(e,t)=>{await j.update(e.id,{enabled:t}),T()},W=async()=>{S&&(await j.delete(S.id),N(null),T())};return(0,l.jsxs)(n.default,{sx:{p:3,maxWidth:1100,mx:"auto",width:"100%"},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:2,mb:1},children:[(0,l.jsx)(o.default,{variant:"h5",children:"Planned Executions"}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,l.jsx)(m.A,{title:"Refresh",children:(0,l.jsx)(g.A,{onClick:()=>void T(),children:(0,l.jsx)(f.A,{})})}),(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{checked:!a,onChange:e=>I(!e.target.checked)}),label:a?"Paused":"Active"}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},"data-tour":"add-execution",children:"Add"})]})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Run your flows automatically — on a schedule or when something happens — without opening the chat. FLUJO must be running for triggers to fire."}),w&&0===e.length&&(0,l.jsxs)(n.default,{sx:{border:1,borderColor:"divider",borderRadius:2,borderStyle:"dashed",p:6,textAlign:"center"},children:[(0,l.jsx)(o.default,{variant:"h6",sx:{mb:1},children:"Nothing planned yet"}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Create your first planned execution to run a flow on a schedule."}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},children:"New planned execution"})]}),(0,l.jsx)(n.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(e=>(0,l.jsx)(z,{entry:e,onEdit:()=>{C(e.execution),A(!0)},onDelete:()=>N(e.execution),onToggleEnabled:t=>F(e.execution,t),onRanNow:()=>void T()},e.execution.id))}),(0,l.jsx)(eN,{open:b,execution:k,onClose:()=>A(!1),onSaved:()=>void T()}),(0,l.jsxs)(c.A,{open:null!==S,onClose:()=>N(null),children:[(0,l.jsxs)(u.A,{children:["Delete “",null==S?void 0:S.name,"”?"]}),(0,l.jsx)(h.A,{children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This removes the planned execution and its run history. The flow itself is not affected."})}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:()=>N(null),children:"Cancel"}),(0,l.jsx)(d.A,{color:"error",variant:"contained",onClick:W,children:"Delete"})]})]})]})},eI=(0,y.h)("app/executions/page");function eF(){return eI.debug("Rendering ExecutionsPage"),(0,l.jsx)(n.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,l.jsx)(eE,{})})}}},e=>{e.O(0,[2678,4754,9244,8548,690,9562,2003,488,3272,5648,7396,7329,7458,1811,2380,8441,1255,7358],()=>e(e.s=60187)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1488],{17427:(e,t,a)=>{"use strict";a.d(t,{A:()=>p});var l=a(95155),n=a(12115),r=a(25635),o=a(94049),s=a(99944),i=a(9957),d=a(52641),c=a(51221),u=a(55606),h=a(86973),x=a(9562);let p=e=>{var t;let{schema:a,values:p,onChange:f,size:m="small"}=e,[g,y]=(0,n.useState)({}),w=null!=(t=null==a?void 0:a.properties)?t:{},v=Array.isArray(null==a?void 0:a.required)?a.required:[],j=Object.keys(w);if(0===j.length)return(0,l.jsx)(r.default,{variant:"body2",color:"text.secondary",children:"This tool takes no parameters."});let b=(e,t)=>{let a={...p};void 0===t?delete a[e]:a[e]=t,f(a)};return(0,l.jsx)(o.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:j.map(e=>{var t,a;let n=null!=(t=w[e])?t:{},f=v.includes(e)?"".concat(e," *"):e,j="string"==typeof n.description?n.description:"";if("boolean"===n.type)return(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{size:m,checked:!0===p[e],onChange:t=>b(e,t.target.checked)}),label:(0,l.jsxs)(o.default,{children:[(0,l.jsx)(r.default,{variant:"body2",children:f}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",children:j})]})},e);if(Array.isArray(n.enum)&&n.enum.length>0){let t=p[e];return(0,l.jsxs)(d.A,{size:m,fullWidth:!0,children:[(0,l.jsx)(c.A,{id:"schema-param-".concat(e),children:f}),(0,l.jsx)(u.A,{labelId:"schema-param-".concat(e),label:f,value:n.enum.includes(t)?t:"",onChange:t=>b(e,t.target.value),children:n.enum.map(e=>(0,l.jsx)(h.A,{value:e,children:String(e)},String(e)))}),j&&(0,l.jsx)(r.default,{variant:"caption",color:"text.secondary",sx:{mt:.5,mx:1.75},children:j})]},e)}if("number"===n.type||"integer"===n.type)return(0,l.jsx)(x.A,{fullWidth:!0,size:m,type:"number",label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>{let a=t.target.value;if(""===a)return void b(e,void 0);let l="integer"===n.type?parseInt(a,10):parseFloat(a);b(e,Number.isNaN(l)?void 0:l)},helperText:j},e);if("object"===n.type||"array"===n.type){let t=null!=(a=g[e])?a:void 0!==p[e]?JSON.stringify(p[e],null,2):"",r=null;if(t.trim())try{JSON.parse(t)}catch(e){r="Not valid JSON yet"}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,multiline:!0,minRows:2,label:"".concat(f," (JSON ").concat(n.type,")"),value:t,error:!!r,helperText:null!=r?r:j,onChange:t=>{let a=t.target.value;if(y(t=>({...t,[e]:a})),!a.trim())return void b(e,void 0);try{b(e,JSON.parse(a))}catch(e){}},slotProps:{input:{sx:{fontFamily:"monospace",fontSize:13}}}},e)}return(0,l.jsx)(x.A,{fullWidth:!0,size:m,label:f,value:void 0!==p[e]?String(p[e]):"",onChange:t=>b(e,""===t.target.value?void 0:t.target.value),helperText:j},e)})})}},60187:(e,t,a)=>{Promise.resolve().then(a.bind(a,95271))},62640:(e,t,a)=>{"use strict";a.d(t,{A:()=>N});var l=a(95155),n=a(12115),r=a(2778),o=a(52363),s=a(65036),i=a(94049),d=a(78470),c=a(41983),u=a(9562),h=a(28548),x=a(22003),p=a(4474),f=a(25635),m=a(41602),g=a(73707),y=a(49501),w=a(17681),v=a(75912),j=a(70690),b=a(80007),A=a(74482),k=a(40171),C=a(36944);let S=(0,a(87021).h)("frontend/components/shared/FolderPickerDialog"),N=e=>{let{open:t,title:a="Choose a folder",selectFiles:N=!1,initialPath:T,onClose:E,onSelect:I}=e,[F,W]=(0,n.useState)(null),[P,R]=(0,n.useState)(""),[O,z]=(0,n.useState)(!1),[M,U]=(0,n.useState)(null),D=(0,n.useCallback)(async e=>{z(!0),U(null);try{let t=e?"?path=".concat(encodeURIComponent(e)):"",a=await fetch("/api/browse".concat(t)),l=await a.json();if(!a.ok||l.error)return void U(l.error||"HTTP ".concat(a.status));W(l),R(l.path)}catch(e){S.warn("Browse failed",e),U("Could not reach the backend to browse folders.")}finally{z(!1)}},[]);(0,n.useEffect)(()=>{t?D(T||void 0):(W(null),U(null))},[t,T,D]);let L=e=>{I(e),E()};return(0,l.jsxs)(r.A,{open:t,onClose:E,maxWidth:"sm",fullWidth:!0,children:[(0,l.jsx)(o.A,{children:a}),(0,l.jsxs)(s.A,{dividers:!0,sx:{display:"flex",flexDirection:"column",gap:1.5},children:[(0,l.jsxs)(i.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(d.A,{title:"Up one folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:!(null==F?void 0:F.parent)||O,onClick:()=>(null==F?void 0:F.parent)&&void D(F.parent),children:(0,l.jsx)(k.A,{fontSize:"small"})})})}),(0,l.jsx)(d.A,{title:"Home folder",children:(0,l.jsx)("span",{children:(0,l.jsx)(c.A,{size:"small",disabled:O,onClick:()=>void D(),children:(0,l.jsx)(C.A,{fontSize:"small"})})})}),(0,l.jsx)(u.A,{fullWidth:!0,size:"small",value:P,onChange:e=>R(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),D(P))},placeholder:"Type a path and press Enter"})]}),F&&F.drives.length>0&&(0,l.jsx)(i.default,{sx:{display:"flex",gap:.75,flexWrap:"wrap"},children:F.drives.map(e=>(0,l.jsx)(h.A,{label:e,size:"small",variant:F.path.toLowerCase().startsWith(e.toLowerCase())?"filled":"outlined",onClick:()=>void D(e)},e))}),M&&(0,l.jsx)(x.A,{severity:"error",children:M}),(0,l.jsxs)(i.default,{sx:{minHeight:240,maxHeight:"45vh",overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:[O&&(0,l.jsx)(i.default,{sx:{display:"flex",justifyContent:"center",py:4},children:(0,l.jsx)(p.default,{size:24})}),!O&&F&&0===F.entries.length&&(0,l.jsx)(f.default,{variant:"body2",color:"text.secondary",sx:{p:2},children:"This folder is empty."}),!O&&(0,l.jsx)(m.A,{dense:!0,disablePadding:!0,children:null==F?void 0:F.entries.map(e=>(0,l.jsxs)(g.A,{disabled:!e.isDirectory&&!N,onClick:()=>e.isDirectory?void D(e.path):L(e.path),children:[(0,l.jsx)(y.A,{sx:{minWidth:34},children:e.isDirectory?(0,l.jsx)(b.A,{fontSize:"small",color:"primary"}):(0,l.jsx)(A.A,{fontSize:"small"})}),(0,l.jsx)(w.A,{primary:e.name,primaryTypographyProps:{noWrap:!0}})]},e.path))})]})]}),(0,l.jsxs)(v.A,{children:[(0,l.jsx)(j.A,{onClick:E,children:"Cancel"}),(0,l.jsx)(j.A,{variant:"contained",disabled:!F||O,onClick:()=>F&&L(F.path),children:"Select this folder"})]})]})}},90057:(e,t,a)=>{"use strict";a.d(t,{g:()=>o});var l=a(74879);let n=(0,a(87021).h)("frontend/services/flow/index");class r{async loadFlows(){n.debug("loadFlows: Entering method");try{if(this.flowsCache)return n.debug("loadFlows: Using cached flows",{count:this.flowsCache.length}),this.flowsCache;let e=await fetch("/api/flow");if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load flows")}let t=await e.json();return n.debug("loadFlows: Loaded flows from API",{count:t.length}),this.flowsCache=t,t}catch(e){return n.warn("loadFlows: Failed to load flows:",e),[]}}async getFlow(e){n.debug("getFlow: Entering method",{flowId:e});try{if(this.flowsCache){let t=this.flowsCache.find(t=>t.id===e);if(t)return n.debug("getFlow: Using cached flow",{flowId:e}),t}let t=await fetch("/api/flow/".concat(encodeURIComponent(e)));if(!t.ok){if(404===t.status)return n.debug("getFlow: Flow ".concat(e," not found")),null;let a=await t.json();throw Error(a.error||"Failed to get flow: ".concat(e))}let a=await t.json();return n.debug("getFlow: Retrieved flow from API",{flowId:e}),a}catch(t){return n.warn("getFlow: Failed to get flow ".concat(e,":"),t),null}}async addFlow(e){n.debug("addFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to add flow"}}let a=await t.json();return this.flowsCache&&this.flowsCache.push(a),n.debug("addFlow: Flow added successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("addFlow: Failed to add flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to add flow"}}}async updateFlow(e){n.debug("updateFlow: Entering method",{flowId:e.id,flowName:e.name,nodeCount:e.nodes.length,edgeCount:e.edges.length});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e.id)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to update flow"}}let a=await t.json();if(this.flowsCache){let t=this.flowsCache.findIndex(t=>t.id===e.id);t>=0?this.flowsCache[t]=a:this.flowsCache.push(a)}return n.debug("updateFlow: Flow updated successfully",{flowId:e.id}),{success:!0}}catch(e){return n.warn("updateFlow: Failed to update flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update flow"}}}async deleteFlow(e){n.debug("deleteFlow: Entering method",{flowId:e});try{let t=await fetch("/api/flow/".concat(encodeURIComponent(e)),{method:"DELETE"});if(!t.ok){let e=await t.json();return{success:!1,error:e.error||"Failed to delete flow"}}return this.flowsCache&&(this.flowsCache=this.flowsCache.filter(t=>t.id!==e)),n.debug("deleteFlow: Flow deleted successfully",{flowId:e}),{success:!0}}catch(e){return n.warn("deleteFlow: Failed to delete flow:",e),{success:!1,error:e instanceof Error?e.message:"Failed to delete flow"}}}createNode(e,t){return n.debug("createNode: Entering method",{type:e,position:t}),{id:(0,l.A)(),type:e,position:t,data:{label:"".concat("mcp"===e?"MCP":e.charAt(0).toUpperCase()+e.slice(1)," Node"),type:e,properties:{}}}}createStartNode(){return{id:(0,l.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}}}createNewFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NewFlow";return n.debug("createNewFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[this.createStartNode()],edges:[]}}createHistoryEntry(e,t){return n.debug("createHistoryEntry: Entering method"),{nodes:[...e],edges:[...t]}}generateSampleFlow(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Sample Flow";return n.debug("generateSampleFlow: Entering method",{name:e}),{id:(0,l.A)(),name:e,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]}}constructor(){this.flowsCache=null}}let o=new r},95271:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>eF});var l=a(95155),n=a(94049),r=a(12115),o=a(25635),s=a(99944),i=a(9957),d=a(70690),c=a(2778),u=a(52363),h=a(65036),x=a(75912),p=a(86946),f=a(76530),m=a(78470),g=a(41983),y=a(87021);let w=(0,y.h)("frontend/services/plannedExecutions");class v{async list(){try{let e=await fetch("/api/planned-executions");if(!e.ok)throw Error("HTTP ".concat(e.status));return await e.json()}catch(e){return w.warn("Failed to list planned executions",e),{paused:!1,executions:[]}}}async create(e){try{let t=await fetch("/api/planned-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,execution:a.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async update(e,t){try{let a=await fetch("/api/planned-executions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await a.json();if(!a.ok)return{success:!1,error:(null==l?void 0:l.error)||"HTTP ".concat(a.status)};return{success:!0,execution:l.execution}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async delete(e){try{let t=await fetch("/api/planned-executions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async setPaused(e){try{let t=await fetch("/api/planned-executions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{success:!1,error:(null==e?void 0:e.error)||"HTTP ".concat(t.status)}}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async runNow(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/run"),{method:"POST"}),a=await t.json();if(!t.ok)return{success:!1,error:(null==a?void 0:a.error)||"HTTP ".concat(t.status)};return{success:!0,record:a.record}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Request failed"}}}async loadRuns(e){try{let t=await fetch("/api/planned-executions/".concat(e,"/runs"));if(!t.ok)throw Error("HTTP ".concat(t.status));let a=await t.json();return Array.isArray(null==a?void 0:a.runs)?a.runs:[]}catch(t){return w.warn("Failed to load runs for ".concat(e),t),[]}}async previewSchedule(e,t){try{let a=await fetch("/api/planned-executions/preview-schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cron:e,timezone:t})});if(!a.ok)throw Error("HTTP ".concat(a.status));return await a.json()}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Preview failed",nextRuns:[]}}}}let j=new v;var b=a(2300),A=a(28548),k=a(4474),C=a(50430),S=a(55406),N=a(14915),T=a(4484),E=a(63186),I=a(62962),F=a(3713);let W=e=>String(e).padStart(2,"0"),P=e=>{switch(e){case"completed":return"success.main";case"error":return"error.main";case"skipped":return"warning.main";default:return"transparent"}},R=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",O=e=>{if(!e.finishedAt)return"";let t=new Date(e.finishedAt).getTime()-new Date(e.firedAt).getTime();return t<1e3?"<1s":t<6e4?"".concat(Math.round(t/1e3),"s"):"".concat(Math.round(t/6e4),"min")},z=e=>{var t;let{entry:a,onEdit:s,onDelete:p,onToggleEnabled:f,onRanNow:y}=e,{execution:w,status:v,lastRun:z}=a,[M,U]=(0,r.useState)(!1),[D,L]=(0,r.useState)(null),[H,J]=(0,r.useState)(!1),[q,$]=(0,r.useState)(!1),[B,G]=(0,r.useState)(null),_=(0,r.useCallback)(async()=>{J(!0),L([...await j.loadRuns(w.id)].reverse()),J(!1)},[w.id]);(0,r.useEffect)(()=>{M&&_()},[M,_,null==z?void 0:z.runId]);let K=async()=>{$(!0),await j.runNow(w.id),$(!1),M&&_(),y()};return(0,l.jsxs)(b.A,{variant:"outlined",sx:{p:2},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap"},children:[(0,l.jsxs)(n.default,{sx:{flexGrow:1,minWidth:220},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600},children:w.name}),(0,l.jsx)(A.A,{size:"small",label:function(e){switch(e.type){case"schedule":{var t;let a,l=(t=e.cron,(a=/^\*\/(\d+) \* \* \* \* \*$/.exec(t))?"Every ".concat(a[1],"s"):(a=/^\*\/(\d+) \* \* \* \*$/.exec(t))?"Every ".concat(a[1]," min"):(a=/^0 \*\/(\d+) \* \* \*$/.exec(t))?1===Number(a[1])?"Every hour":"Every ".concat(a[1]," hours"):(a=/^(\d+) (\d+) \* \* \*$/.exec(t))?"Daily at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):(a=/^(\d+) (\d+) \* \* 1-5$/.exec(t))?"Weekdays at ".concat(W(Number(a[2])),":").concat(W(Number(a[1]))):null);return null!=l?l:"Schedule: ".concat(e.cron)}case"webhook":return"Webhook";case"file-watch":return"Watching ".concat(e.path);case"mcp-poll":return"Watching ".concat(e.serverName," › ").concat(e.toolName);case"url-watch":try{return"Watching ".concat(new URL(e.url).hostname)}catch(e){return"Watching a URL"}default:return"Trigger"}}(w.trigger)}),!w.enabled&&(0,l.jsx)(A.A,{size:"small",label:"Off",variant:"outlined"})]}),v.running?(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(k.default,{size:12,thickness:6}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Running…",v.runningSince?" — started ".concat(R(v.runningSince)):""]})]}):(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[v.nextRun&&w.enabled?"Next run: ".concat(R(v.nextRun)):w.enabled&&!v.armed?"Not armed":"",v.lastTriggerError?" — trigger error: ".concat(v.lastTriggerError):""]}),z&&(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.5},children:[(0,l.jsx)(m.A,{title:z.status,children:(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(z.status),flexShrink:0}})}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",children:["Last run ",R(z.firedAt),"error"===z.status&&z.error?" — ".concat(z.error):""]})]})]}),(0,l.jsx)(m.A,{title:"Run now",children:(0,l.jsx)("span",{children:(0,l.jsx)(g.A,{onClick:K,disabled:q,color:"primary",children:q?(0,l.jsx)(k.default,{size:20}):(0,l.jsx)(S.A,{})})})}),(0,l.jsx)(m.A,{title:w.enabled?"Turn off":"Turn on",children:(0,l.jsx)(i.A,{checked:w.enabled,onChange:e=>f(e.target.checked)})}),(0,l.jsx)(m.A,{title:"Edit",children:(0,l.jsx)(g.A,{onClick:s,children:(0,l.jsx)(N.A,{})})}),(0,l.jsx)(m.A,{title:"Delete",children:(0,l.jsx)(g.A,{onClick:p,children:(0,l.jsx)(T.A,{})})}),(0,l.jsx)(m.A,{title:M?"Hide run history":"Show run history",children:(0,l.jsx)(g.A,{onClick:()=>U(e=>!e),children:M?(0,l.jsx)(I.A,{}):(0,l.jsx)(E.A,{})})})]}),(0,l.jsx)(C.A,{in:M,timeout:"auto",unmountOnExit:!0,children:(0,l.jsxs)(n.default,{sx:{mt:2,borderTop:1,borderColor:"divider",pt:1.5},children:[H&&!D&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Loading runs…"}),D&&0===D.length&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"No runs yet. Use the play button to try it now."}),null==D?void 0:D.map(e=>{var t;return(0,l.jsxs)(n.default,{sx:{display:"flex",gap:1,py:.75,alignItems:"flex-start","&:hover .run-detail-button":{opacity:1}},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:P(e.status),mt:"5px",flexShrink:0}}),(0,l.jsxs)(n.default,{sx:{minWidth:0,flexGrow:1},children:[(0,l.jsxs)(o.default,{variant:"body2",children:[R(e.firedAt),O(e)?" \xb7 ".concat(O(e)):""," \xb7 ",e.triggerSummary,(null==(t=e.usage)?void 0:t.totalTokens)?" \xb7 ".concat(e.usage.totalTokens.toLocaleString()," tokens"):""]}),e.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",children:e.error}),e.outputText&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.outputText})]}),(0,l.jsx)(m.A,{title:"Show full output",children:(0,l.jsx)(g.A,{className:"run-detail-button",size:"small",onClick:()=>G(e),sx:{opacity:{xs:1,md:.35},transition:"opacity 120ms",flexShrink:0},children:(0,l.jsx)(F.A,{fontSize:"inherit"})})})]},e.runId)})]})}),(0,l.jsxs)(c.A,{open:null!==B,onClose:()=>G(null),maxWidth:"md",fullWidth:!0,children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(n.default,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:B?P(B.status):"transparent",flexShrink:0}}),(0,l.jsxs)(o.default,{variant:"h6",children:[w.name," — ",B?R(B.firedAt):""]})]})}),(0,l.jsx)(h.A,{dividers:!0,children:B&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:[B.status,O(B)?" \xb7 ".concat(O(B)):""," \xb7 ",B.triggerSummary,(null==(t=B.usage)?void 0:t.totalTokens)?" \xb7 ".concat(B.usage.totalTokens.toLocaleString()," tokens (").concat(B.usage.promptTokens.toLocaleString()," in / ").concat(B.usage.completionTokens.toLocaleString()," out)"):""]}),B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"error",sx:{mb:1.5,whiteSpace:"pre-wrap"},children:B.error}),B.outputText?(0,l.jsx)(n.default,{sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",bgcolor:"action.hover",borderRadius:1,p:2,fontSize:14,maxHeight:"55vh",overflow:"auto"},children:B.outputText}):!B.error&&(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This run produced no output text."})]})}),(0,l.jsx)(x.A,{children:(0,l.jsx)(d.A,{onClick:()=>G(null),children:"Close"})})]})]})};var M=a(21067),U=a(9562),D=a(52641),L=a(51221),H=a(55606),J=a(86973),q=a(22003),$=a(77073),B=a(26922),G=a(40520),_=a(79299),K=a(22590),Q=a(53657),X=a(90057),Y=a(36741);let V=e=>{let{selected:t,icon:a,title:r,description:s,onClick:i}=e;return(0,l.jsxs)(n.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:i,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())},sx:{flex:1,minWidth:200,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,l.jsx)(Y.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[a,(0,l.jsx)(o.default,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:r})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:s})]})};var Z=a(22822),ee=a(98267),et=a(20537),ea=a(37960);let el=e=>String(e).padStart(2,"0"),en=e=>{let{cron:t,timezone:a,onChange:i,verb:d="Runs",catchUp:c,onCatchUpChange:u}=e,h=(0,r.useMemo)(()=>(function(e){let t=/^\*\/(\d+) \* \* \* \* \*$/.exec(e);return t?{mode:"seconds",n:Number(t[1]),time:"09:00"}:(t=/^\*\/(\d+) \* \* \* \*$/.exec(e))?{mode:"minutes",n:Number(t[1]),time:"09:00"}:(t=/^0 \*\/(\d+) \* \* \*$/.exec(e))?{mode:"hours",n:Number(t[1]),time:"09:00"}:(t=/^(\d+) (\d+) \* \* \*$/.exec(e))?{mode:"daily",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:(t=/^(\d+) (\d+) \* \* 1-5$/.exec(e))?{mode:"weekdays",n:1,time:"".concat(el(Number(t[2])),":").concat(el(Number(t[1])))}:{mode:"custom",n:15,time:"09:00"}})(t),[]),[x,p]=(0,r.useState)(h.mode),[f,m]=(0,r.useState)(h.n),[g,y]=(0,r.useState)(h.time),[w,v]=(0,r.useState)(t),[b,A]=(0,r.useState)(null),k=function(e,t,a,l){let[n,r]=a.split(":").map(Number);switch(e){case"seconds":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * * *");case"minutes":return"*/".concat(Math.max(1,Math.min(59,Math.floor(t)||1))," * * * *");case"hours":return"0 */".concat(Math.max(1,Math.min(23,Math.floor(t)||1))," * * *");case"daily":return"".concat(r||0," ").concat(n||0," * * *");case"weekdays":return"".concat(r||0," ").concat(n||0," * * 1-5");default:return l}}(x,f,g,w);return(0,r.useEffect)(()=>{k!==t&&i({cron:k,timezone:a})},[k]),(0,r.useEffect)(()=>{let e=!1,t=setTimeout(()=>{j.previewSchedule(k,a).then(t=>{e||A(t)})},300);return()=>{e=!0,clearTimeout(t)}},[k,a]),(0,l.jsxs)(n.default,{children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1},children:[(0,l.jsxs)(D.A,{sx:{minWidth:180},children:[(0,l.jsx)(L.A,{id:"schedule-preset-label",children:d}),(0,l.jsxs)(H.A,{labelId:"schedule-preset-label",label:d,value:x,onChange:e=>p(e.target.value),children:[(0,l.jsx)(J.A,{value:"seconds",children:"Every N seconds"}),(0,l.jsx)(J.A,{value:"minutes",children:"Every N minutes"}),(0,l.jsx)(J.A,{value:"hours",children:"Every N hours"}),(0,l.jsx)(J.A,{value:"daily",children:"Daily at a time"}),(0,l.jsx)(J.A,{value:"weekdays",children:"Weekdays at a time"}),(0,l.jsx)(J.A,{value:"custom",children:"Custom (cron)"})]})]}),("seconds"===x||"minutes"===x||"hours"===x)&&(0,l.jsx)(U.A,{label:"seconds"===x?"Seconds":"minutes"===x?"Minutes":"Hours",type:"number",value:f,onChange:e=>m(Number(e.target.value)),inputProps:{min:1,max:"hours"===x?23:59},sx:{width:120}}),("daily"===x||"weekdays"===x)&&(0,l.jsx)(U.A,{label:"Time",type:"time",value:g,onChange:e=>y(e.target.value),sx:{width:150},InputLabelProps:{shrink:!0}}),"custom"===x&&(0,l.jsx)(U.A,{label:"Cron pattern",value:w,onChange:e=>v(e.target.value),sx:{minWidth:220},placeholder:"*/15 * * * *"})]}),b&&!b.valid&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:b.error||"This schedule is not valid."}),b&&b.valid&&b.nextRuns.length>0&&(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:2},children:["Next: ",b.nextRuns.map(e=>new Date(e).toLocaleString()).join(" \xb7 ")]}),u&&(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===c,onChange:e=>u(e.target.checked)}),label:"If FLUJO was closed at a scheduled time, run once on startup"}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(U.A,{label:"Timezone (optional)",value:a||"",onChange:e=>i({cron:k,timezone:e.target.value||void 0}),placeholder:"e.g. Europe/Berlin",helperText:"IANA timezone name. Empty = this computer's timezone.",sx:{minWidth:260}}),(0,l.jsx)(U.A,{label:"Generated cron pattern",value:k,InputProps:{readOnly:"custom"!==x},onChange:e=>{p("custom"),v(e.target.value)},helperText:"Editing switches to Custom mode.",sx:{minWidth:220}})]})})]})]})};var er=a(52277),eo=a(9693);let es=e=>{let{config:t,onChange:a,executionId:i,saved:c}=e,[u,h]=(0,r.useState)(null),x=window.location.origin,p="".concat(x,"/api/webhooks/").concat(i),f=async(e,t)=>{try{await navigator.clipboard.writeText(t),h(e),setTimeout(()=>h(null),1500)}catch(e){}};return(0,l.jsxs)(n.default,{sx:{mt:1},children:[!c&&(0,l.jsx)(q.A,{severity:"info",sx:{mb:2},children:"This URL and token are ready to copy now — they become active when you save."}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Webhook URL",value:p,InputProps:{readOnly:!0},size:"small"}),(0,l.jsx)(m.A,{title:"Copy URL",children:(0,l.jsx)(g.A,{onClick:()=>f("url",p),children:"url"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})})]}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:1,mt:2},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Secret token",value:t.token,InputProps:{readOnly:!0},size:"small",type:"password"}),(0,l.jsx)(m.A,{title:"Copy token",children:(0,l.jsx)(g.A,{onClick:()=>f("token",t.token),disabled:!t.token,children:"token"===u?(0,l.jsx)(eo.A,{color:"success"}):(0,l.jsx)(er.A,{})})}),(0,l.jsx)(d.A,{size:"small",onClick:()=>a({...t,token:crypto.randomUUID()}),sx:{whiteSpace:"nowrap"},children:"New token"})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:c?"A new token takes effect when you save — callers using the old one are cut off.":""}),(0,l.jsxs)(o.default,{variant:"body2",color:"text.secondary",sx:{mt:1.5},children:["Callers send a POST with the token in the ",(0,l.jsx)("code",{children:"X-Flujo-Token"})," ","header (or ",(0,l.jsx)("code",{children:"?token=…"}),"). The request body becomes part of the flow's input — treat it as untrusted data in your prompt."]}),(0,l.jsx)(s.A,{sx:{mt:1,display:"flex"},control:(0,l.jsx)(Z.A,{checked:!0===t.allowExternal,onChange:e=>a({...t,allowExternal:e.target.checked})}),label:"Allow calls from other machines (default: this computer only)"}),t.allowExternal&&(0,l.jsx)(q.A,{severity:"warning",children:"FLUJO assumes a single user on this machine. If you expose it beyond localhost (port forwarding, tunnels), securing that access is your responsibility — anyone with the URL and token can run this flow."})]})};var ei=a(56422),ed=a(17325),ec=a(80007),eu=a(62640);let eh=[{value:"add",label:"A file appears"},{value:"change",label:"A file changes"},{value:"unlink",label:"A file is deleted"}],ex=e=>{var t;let{config:a,onChange:i}=e,[d,c]=(0,r.useState)(!1);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Folder (or file) to watch",value:a.path,onChange:e=>i({...a,path:e.target.value}),placeholder:"e.g. C:\\Users\\me\\Documents\\inbox",margin:"normal",InputProps:{endAdornment:(0,l.jsx)(ei.A,{position:"end",children:(0,l.jsx)(m.A,{title:"Browse folders (on the FLUJO machine)",children:(0,l.jsx)(g.A,{edge:"end",onClick:()=>c(!0),children:(0,l.jsx)(ec.A,{})})})})}}),(0,l.jsx)(eu.A,{open:d,title:"Choose what to watch",selectFiles:!0,initialPath:a.path||void 0,onClose:()=>c(!1),onSelect:e=>i({...a,path:e})}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Only files matching (optional)",value:a.glob||"",onChange:e=>i({...a,glob:e.target.value||void 0}),placeholder:"e.g. *.pdf or reports/**/*.csv",helperText:"Simple patterns: * matches within a folder, ** across folders, ? one character.",margin:"normal"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"Run when…"}),(0,l.jsx)(ed.A,{row:!0,children:eh.map(e=>(0,l.jsx)(s.A,{control:(0,l.jsx)(Z.A,{checked:a.events.includes(e.value),onChange:t=>((e,t)=>{let l=t?[...a.events,e]:a.events.filter(t=>t!==e);i({...a,events:l})})(e.value,t.target.checked)}),label:e.label},e.value))}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"Bursts are batched: many files changing at once produce one run with all changes listed. If this flow writes into the watched folder, it will trigger itself in a loop — point its output somewhere else."}),(0,l.jsxs)(ee.A,{disableGutters:!0,elevation:0,sx:{mt:1,"&:before":{display:"none"}},children:[(0,l.jsx)(et.A,{expandIcon:(0,l.jsx)(E.A,{}),sx:{px:0},children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"Advanced"})}),(0,l.jsx)(ea.A,{sx:{px:0},children:(0,l.jsx)(U.A,{label:"Quiet window (ms)",type:"number",value:null!=(t=a.debounceMs)?t:2e3,onChange:e=>i({...a,debounceMs:Math.max(0,Number(e.target.value)||0)}),helperText:"How long to wait after the last change before running.",inputProps:{min:0,step:500},sx:{width:220}})})]})]})};var ep=a(41356),ef=a(24610),em=a(17897),eg=a(43076),ey=a(17427);let ew=(0,y.h)("frontend/components/PlannedExecutions/WatchToolPanel"),ev=e=>{var t,a;let{config:s,onChange:i}=e,[c,u]=(0,r.useState)([]),[h,x]=(0,r.useState)([]),[p,f]=(0,r.useState)(!1),[m,g]=(0,r.useState)(Object.keys(s.args||{}).length>0?JSON.stringify(s.args,null,2):""),[y,w]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[b,A]=(0,r.useState)(null),[C,S]=(0,r.useState)(null),[N,T]=(0,r.useState)([]),[E,I]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return em.S.loadServerConfigs().then(t=>{e||(Array.isArray(t)?u(t.filter(e=>!e.disabled).map(e=>e.name)):(ew.warn("Failed to load MCP servers for watch-tool panel",t),u([])))}),()=>{e=!0}},[]),(0,r.useEffect)(()=>{if(!s.serverName)return void x([]);let e=!1;return f(!0),em.S.listServerTools(s.serverName).then(t=>{let{tools:a}=t;e||x(a||[])}).finally(()=>{e||f(!1)}),()=>{e=!0}},[s.serverName]),(0,r.useEffect)(()=>{let e=!1;return eg.N.loadModels().then(t=>{e||T(Array.isArray(t)?t:[])}).catch(()=>{e||T([])}),X.g.loadFlows().then(t=>{e||I(t||[])}).catch(()=>{e||I([])}),()=>{e=!0}},[]);let F=async()=>{j(!0),A(null),S(null);try{let a=await em.S.callTool(s.serverName,s.toolName,s.args||{});if(null==a?void 0:a.error)S("string"==typeof a.error?a.error:"Tool call failed");else{var e,t;let l=null!=(e=null==a?void 0:a.data)?e:a,n=null!=(t=JSON.stringify(l,null,2))?t:"";A(n.length>6e3?"".concat(n.slice(0,6e3),"\n… (truncated)"):n)}}catch(e){S(e instanceof Error?e.message:"Tool call failed")}finally{j(!1)}},W=s.evaluate,P=h.find(e=>e.name===s.toolName);return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",children:[(0,l.jsx)(L.A,{id:"watch-server-label",children:"Server"}),(0,l.jsxs)(H.A,{labelId:"watch-server-label",label:"Server",value:c.includes(s.serverName)?s.serverName:"",onChange:e=>i({...s,serverName:e.target.value,toolName:""}),children:[0===c.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No MCP servers configured"}),c.map(e=>(0,l.jsx)(J.A,{value:e,children:e},e))]})]}),(0,l.jsxs)(D.A,{sx:{minWidth:220,flex:1},margin:"normal",disabled:!s.serverName,children:[(0,l.jsx)(L.A,{id:"watch-tool-label",children:"Tool"}),(0,l.jsxs)(H.A,{labelId:"watch-tool-label",label:"Tool",value:h.some(e=>e.name===s.toolName)?s.toolName:"",onChange:e=>i({...s,toolName:e.target.value,args:{}}),children:[0===h.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:p?"Loading tools…":"Pick a server first"}),h.map(e=>(0,l.jsx)(J.A,{value:e.name,children:e.name},e.name))]})]})]}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:null!=(t=s.cron)?t:function(e){let t=Math.max(5,Math.round((null!=e?e:6e4)/1e3));if(t<60)return"*/".concat(t," * * * * *");let a=Math.max(1,Math.round(t/60));if(a<60)return"*/".concat(a," * * * *");let l=Math.max(1,Math.min(23,Math.round(a/60)));return"0 */".concat(l," * * *")}(s.intervalMs),timezone:s.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return i({...s,cron:t,timezone:a})}}),P?(0,l.jsxs)(n.default,{sx:{my:1.5},children:[(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mb:1.5},children:"Tool parameters — sent on every check"}),(0,l.jsx)(ey.A,{schema:P.inputSchema,values:s.args||{},onChange:e=>i({...s,args:e})})]}):(0,l.jsx)(U.A,{fullWidth:!0,label:"Tool arguments (JSON, optional)",value:m,onChange:e=>(e=>{if(g(e),!e.trim()){w(null),i({...s,args:{}});return}try{let t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))return void w('Arguments must be a JSON object, e.g. { "query": "…" }');w(null),i({...s,args:t})}catch(e){w("Not valid JSON yet")}})(e.target.value),margin:"normal",multiline:!0,minRows:2,placeholder:'{ "query": "is:unread" }',error:!!y,helperText:null!=y?y:"Sent to the tool on every check.",slotProps:{input:{sx:{fontFamily:"monospace",fontSize:14}}}}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[(0,l.jsx)(d.A,{variant:"outlined",size:"small",onClick:F,disabled:!s.serverName||!s.toolName||v||!!y,startIcon:v?(0,l.jsx)(k.default,{size:16}):void 0,children:"Test: call the tool now"}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"See what the result looks like — useful for the settings below."})]}),C&&(0,l.jsx)(q.A,{severity:"error",sx:{mb:1},children:C}),b&&(0,l.jsx)(n.default,{component:"pre",sx:{maxHeight:240,overflow:"auto",bgcolor:"action.hover",borderRadius:1,p:1.5,fontSize:12,m:0,mb:1},children:b}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:2,mb:1},children:"Run the flow when…"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Poll condition",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"on-change"===W.mode,onClick:()=>i({...s,evaluate:{mode:"on-change"}}),icon:(0,l.jsx)(ep.A,{}),title:"The result changes",description:"Any difference from the last check runs the flow. Simplest — no setup."}),(0,l.jsx)(V,{selected:"llm-gate"===W.mode||"flow-gate"===W.mode,onClick:()=>{"llm-gate"!==W.mode&&"flow-gate"!==W.mode&&i({...s,evaluate:{mode:"llm-gate",condition:"",modelId:""}})},icon:(0,l.jsx)(ef.A,{}),title:"AI decides",description:"Describe the condition in plain language; a model — or one of your flows — checks the result whenever it changes."})]}),("llm-gate"===W.mode||"flow-gate"===W.mode)&&(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"Run the flow if…",value:W.condition,onChange:e=>i({...s,evaluate:{...W,condition:e.target.value}}),multiline:!0,minRows:2,margin:"normal",placeholder:"e.g. any email mentions an invoice or a payment reminder"}),(0,l.jsxs)(n.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-start"},children:[(0,l.jsxs)(D.A,{sx:{minWidth:170},children:[(0,l.jsx)(L.A,{id:"gate-checker-label",children:"Checked by"}),(0,l.jsxs)(H.A,{labelId:"gate-checker-label",label:"Checked by",value:W.mode,onChange:e=>{let t=e.target.value;if(t===W.mode)return;let a={condition:W.condition,maxCallsPerDay:W.maxCallsPerDay};i({...s,evaluate:"llm-gate"===t?{mode:t,...a,modelId:""}:{mode:t,...a,flowId:""}})},children:[(0,l.jsx)(J.A,{value:"llm-gate",children:"A model"}),(0,l.jsx)(J.A,{value:"flow-gate",children:"One of my flows"})]})]}),"llm-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-model-label",children:"Model that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-model-label",label:"Model that checks",value:N.some(e=>e.id===W.modelId)?W.modelId:"",onChange:e=>i({...s,evaluate:{...W,modelId:e.target.value}}),children:[0===N.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No models configured"}),N.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.displayName||e.name},e.id))]})]}),"flow-gate"===W.mode&&(0,l.jsxs)(D.A,{sx:{minWidth:240,flex:1},children:[(0,l.jsx)(L.A,{id:"gate-flow-label",children:"Flow that checks"}),(0,l.jsxs)(H.A,{labelId:"gate-flow-label",label:"Flow that checks",value:E.some(e=>e.id===W.flowId)?W.flowId:"",onChange:e=>i({...s,evaluate:{...W,flowId:e.target.value}}),children:[0===E.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:"No flows available"}),E.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),(0,l.jsx)(U.A,{label:"Max checks per day",type:"number",value:null!=(a=W.maxCallsPerDay)?a:500,onChange:e=>i({...s,evaluate:{...W,maxCallsPerDay:Math.max(1,Number(e.target.value)||1)}}),inputProps:{min:1},helperText:"Cost guard per check.",sx:{width:180}})]}),(0,l.jsx)(o.default,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5},children:"flow-gate"===W.mode?'The checker flow runs invisibly (never in the chat), gets the condition + tool result, and must answer with {"fire": true/false, "reason": "…"} — it can use its own tools to verify before deciding.':"The model is only asked when the result actually changed since the last check — an idle feed costs nothing. Pick a small, cheap model."})]}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:2},children:"The first check only takes a snapshot — the flow runs from the second check onwards, when something actually changed. FLUJO must be running for checks to happen."})]})},ej=e=>{let{config:t,onChange:a}=e;return(0,l.jsxs)(n.default,{sx:{mt:1},children:[(0,l.jsx)(U.A,{fullWidth:!0,label:"URL to watch",value:t.url,onChange:e=>a({...t,url:e.target.value}),placeholder:"https://example.com/status or an API/feed URL",margin:"normal",type:"url"}),(0,l.jsx)(o.default,{variant:"subtitle2",sx:{mt:1},children:"How often to check"}),(0,l.jsx)(en,{verb:"Check",cron:t.cron,timezone:t.timezone,onChange:e=>{let{cron:l,timezone:n}=e;return a({...t,cron:l,timezone:n})}}),(0,l.jsx)(q.A,{severity:"info",sx:{mt:1},children:"The first check only takes a snapshot; the flow runs when a later check finds different content, and the fetched content is handed to the flow. Pages that embed ever-changing bits (timestamps, session tokens) look “changed” on every check — plain APIs, feeds, and raw files work best."})]})},eb=(0,y.h)("frontend/components/PlannedExecutions/ExecutionModal"),eA={type:"schedule",cron:"0 9 * * *"},ek={type:"file-watch",path:"",events:["add","change"]},eC={type:"mcp-poll",serverName:"",toolName:"",args:{},cron:"*/5 * * * *",evaluate:{mode:"on-change"}},eS={type:"url-watch",url:"",cron:"*/15 * * * *"},eN=e=>{var t;let{open:a,execution:p,onClose:f,onSaved:m}=e,[y,w]=(0,r.useState)(""),[v,b]=(0,r.useState)(""),[A,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!1),[N,T]=(0,r.useState)(eA),[E,I]=(0,r.useState)(""),[F,W]=(0,r.useState)([]),[P,R]=(0,r.useState)(!1),[O,z]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e,t,l,n;a&&(Z(null),w(null!=(e=null==p?void 0:p.name)?e:""),b(null!=(t=null==p?void 0:p.flowId)?t:""),k(null!=(l=null==p?void 0:p.prompt)?l:""),S((null==p?void 0:p.saveConversations)===!0),T(null!=(n=null==p?void 0:p.trigger)?n:eA),I(p?"":crypto.randomUUID()))},[a,p]),(0,r.useEffect)(()=>{if(!a)return;let e=!1;return R(!0),X.g.loadFlows().then(t=>{e||W(t||[])}).catch(t=>{eb.warn("Failed to load flows for execution picker",t),e||W([])}).finally(()=>{e||R(!1)}),()=>{e=!0}},[a]);let ee=!!v&&!P&&F.length>0&&!F.some(e=>e.id===v),et=async()=>{var e;z(!0),Z(null);let t={name:y,flowId:v,prompt:A,saveConversations:C,trigger:N,enabled:null==(e=null==p?void 0:p.enabled)||e,...p?{}:{id:E}},a=p?await j.update(p.id,t):await j.create(t);if(z(!1),!a.success)return void Z(a.error||"Failed to save");m(),f()};return(0,l.jsxs)(c.A,{open:a,onClose:f,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,l.jsx)(u.A,{component:"div",children:(0,l.jsxs)(n.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,l.jsx)(o.default,{variant:"h6",children:p?"Edit planned execution":"New planned execution"}),(0,l.jsx)(g.A,{edge:"end",color:"inherit",onClick:f,"aria-label":"close",children:(0,l.jsx)($.A,{})})]})}),(0,l.jsx)(M.A,{}),(0,l.jsxs)(h.A,{sx:{p:3},children:[(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"A planned execution runs one of your flows automatically — on a schedule or when something happens — without anyone sitting in the chat. Results show up in its run history on the Executions page."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"Name",value:y,onChange:e=>w(e.target.value),margin:"normal",placeholder:"e.g. Morning news digest"}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:3,mb:1,fontWeight:600},children:"1 \xb7 When should it run?"}),(0,l.jsxs)(n.default,{role:"radiogroup","aria-label":"Trigger type",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,l.jsx)(V,{selected:"schedule"===N.type,onClick:()=>{"schedule"!==N.type&&T((null==p?void 0:p.trigger.type)==="schedule"?p.trigger:eA)},icon:(0,l.jsx)(B.A,{}),title:"On a schedule",description:"Run at fixed times — every few minutes, daily, on weekdays, or a custom rhythm."}),(0,l.jsx)(V,{selected:"webhook"===N.type,onClick:()=>{"webhook"!==N.type&&T((null==p?void 0:p.trigger.type)==="webhook"?p.trigger:{type:"webhook",token:crypto.randomUUID()})},icon:(0,l.jsx)(G.A,{}),title:"When called (webhook)",description:"Other apps run this flow by calling a URL — GitHub, Stripe, Slack and most services can send webhooks."}),(0,l.jsx)(V,{selected:"file-watch"===N.type,onClick:()=>{"file-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="file-watch"?p.trigger:ek)},icon:(0,l.jsx)(_.A,{}),title:"When files change",description:"Watch a folder on this computer and run when files appear, change, or disappear."}),(0,l.jsx)(V,{selected:"mcp-poll"===N.type,onClick:()=>{"mcp-poll"!==N.type&&T((null==p?void 0:p.trigger.type)==="mcp-poll"?p.trigger:eC)},icon:(0,l.jsx)(K.A,{}),title:"Watch a tool",description:"Check one of your MCP tools regularly — run when its result changes, or let AI decide."}),(0,l.jsx)(V,{selected:"url-watch"===N.type,onClick:()=>{"url-watch"!==N.type&&T((null==p?void 0:p.trigger.type)==="url-watch"?p.trigger:eS)},icon:(0,l.jsx)(Q.A,{}),title:"When a website changes",description:"Check a URL regularly and run when its content is different from the last check."})]}),"schedule"===N.type&&(0,l.jsx)(en,{cron:N.cron,timezone:N.timezone,onChange:e=>{let{cron:t,timezone:a}=e;return T({...N,cron:t,timezone:a})},catchUp:!0===N.catchUp,onCatchUpChange:e=>T({...N,catchUp:e})}),"webhook"===N.type&&(0,l.jsx)(es,{config:N,onChange:T,executionId:null!=(t=null==p?void 0:p.id)?t:E,saved:null!==p}),"file-watch"===N.type&&(0,l.jsx)(ex,{config:N,onChange:T}),"mcp-poll"===N.type&&(0,l.jsx)(ev,{config:N,onChange:T}),"url-watch"===N.type&&(0,l.jsx)(ej,{config:N,onChange:T}),(0,l.jsx)(M.A,{sx:{mt:3}}),(0,l.jsx)(o.default,{variant:"subtitle1",sx:{mt:2,mb:0,fontWeight:600},children:"2 \xb7 What should it run?"}),(0,l.jsxs)(D.A,{fullWidth:!0,margin:"normal",children:[(0,l.jsx)(L.A,{id:"execution-flow-label",children:"Flow to run"}),(0,l.jsxs)(H.A,{labelId:"execution-flow-label",label:"Flow to run",value:ee?"":v,onChange:e=>b(e.target.value),displayEmpty:!0,children:[0===F.length&&(0,l.jsx)(J.A,{value:"",disabled:!0,children:P?"Loading flows…":"No flows available"}),F.map(e=>(0,l.jsx)(J.A,{value:e.id,children:e.name},e.id))]})]}),ee&&(0,l.jsx)(q.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),(0,l.jsx)(U.A,{fullWidth:!0,label:"What should the flow do?",value:A,onChange:e=>k(e.target.value),margin:"normal",multiline:!0,rows:3,helperText:"Sent to the flow as the user message each time this runs. Run details are attached automatically: current time, what triggered it, the previous run, the next planned run, and any trigger data."}),(0,l.jsx)(s.A,{sx:{mt:1},control:(0,l.jsx)(i.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Save full conversations (each run appears in the chat sidebar — useful for debugging)"}),Y&&(0,l.jsx)(q.A,{severity:"error",sx:{mt:2},children:Y})]}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:f,children:"Cancel"}),(0,l.jsx)(d.A,{onClick:et,variant:"contained",color:"primary",disabled:O||!y.trim()||!v,children:O?"Saving…":"Save"})]})]})},eT=(0,y.h)("frontend/components/PlannedExecutions"),eE=()=>{let[e,t]=(0,r.useState)([]),[a,y]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),[b,A]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,N]=(0,r.useState)(null),T=(0,r.useCallback)(async()=>{let e=await j.list();t(e.executions),y(e.paused),v(!0)},[]);(0,r.useEffect)(()=>{T()},[T]);let E=e.some(e=>e.status.running);(0,r.useEffect)(()=>{let e=setInterval(()=>{document.hidden||T()},E?3e3:1e4);return()=>clearInterval(e)},[T,E]);let I=async e=>{y(e);let t=await j.setPaused(e);t.success||eT.warn("Failed to toggle pause",t.error),T()},F=async(e,t)=>{await j.update(e.id,{enabled:t}),T()},W=async()=>{S&&(await j.delete(S.id),N(null),T())};return(0,l.jsxs)(n.default,{sx:{p:3,maxWidth:1100,mx:"auto",width:"100%"},children:[(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:2,mb:1},children:[(0,l.jsx)(o.default,{variant:"h5",children:"Planned Executions"}),(0,l.jsxs)(n.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,l.jsx)(m.A,{title:"Refresh",children:(0,l.jsx)(g.A,{onClick:()=>void T(),children:(0,l.jsx)(f.A,{})})}),(0,l.jsx)(s.A,{control:(0,l.jsx)(i.A,{checked:!a,onChange:e=>I(!e.target.checked)}),label:a?"Paused":"Active"}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},"data-tour":"add-execution",children:"Add"})]})]}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Run your flows automatically — on a schedule or when something happens — without opening the chat. FLUJO must be running for triggers to fire."}),w&&0===e.length&&(0,l.jsxs)(n.default,{sx:{border:1,borderColor:"divider",borderRadius:2,borderStyle:"dashed",p:6,textAlign:"center"},children:[(0,l.jsx)(o.default,{variant:"h6",sx:{mb:1},children:"Nothing planned yet"}),(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Create your first planned execution to run a flow on a schedule."}),(0,l.jsx)(d.A,{variant:"contained",startIcon:(0,l.jsx)(p.A,{}),onClick:()=>{C(null),A(!0)},children:"New planned execution"})]}),(0,l.jsx)(n.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(e=>(0,l.jsx)(z,{entry:e,onEdit:()=>{C(e.execution),A(!0)},onDelete:()=>N(e.execution),onToggleEnabled:t=>F(e.execution,t),onRanNow:()=>void T()},e.execution.id))}),(0,l.jsx)(eN,{open:b,execution:k,onClose:()=>A(!1),onSaved:()=>void T()}),(0,l.jsxs)(c.A,{open:null!==S,onClose:()=>N(null),children:[(0,l.jsxs)(u.A,{children:["Delete “",null==S?void 0:S.name,"”?"]}),(0,l.jsx)(h.A,{children:(0,l.jsx)(o.default,{variant:"body2",color:"text.secondary",children:"This removes the planned execution and its run history. The flow itself is not affected."})}),(0,l.jsxs)(x.A,{children:[(0,l.jsx)(d.A,{onClick:()=>N(null),children:"Cancel"}),(0,l.jsx)(d.A,{color:"error",variant:"contained",onClick:W,children:"Delete"})]})]})]})},eI=(0,y.h)("app/executions/page");function eF(){return eI.debug("Rendering ExecutionsPage"),(0,l.jsx)(n.default,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:(0,l.jsx)(eE,{})})}}},e=>{e.O(0,[2678,4754,9244,8548,690,9562,2003,488,3272,6582,256,7329,9984,2380,8441,1255,7358],()=>e(e.s=60187)),_N_E=e.O()}]);
|