PageSourceSearch

https://www.workally.ai/_next/static/chunks/52607-75e6427955f94612.js?dpl=dpl_H2tN3xj5nfNjP6ckuUjFmWMUDSQE

js workally.ai collected 2026-10-05 13:26:48 UTC 93,793 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[52607],{11526:(e,s,t)=>{t.d(s,{U1:()=>l,VL:()=>c,getThreadsPaginated:()=>d,vr:()=>o});var a=t(96648),r=t(53783),i=t(80344),n=t(17343);let l=async e=>{let s=await i.H.get("/projects/".concat(e),{showErrors:!0});if(s.error)throw(0,r.handleApiError)(s.error,{operation:"load project",resource:"project ".concat(e)}),Error(s.error.message||"Project not found: ".concat(e));if(!s.data)throw Error("Project not found: ".concat(e));let t=s.data;return{id:t.project_id,name:t.name||"",description:t.description||"",is_public:t.is_public||!1,created_at:t.created_at,updated_at:t.updated_at||t.created_at,sandbox:t.sandbox||{id:"",pass:"",vnc_preview:"",sandbox_url:""},icon_name:t.icon_name}},o=async(e,s)=>{var t,a,r,n,l,o,c;if(!e||""===e)throw Error("Cannot update project: Invalid project ID");let m=await d(void 0,1,20);if(!(null==m?void 0:m.threads))throw Error("Failed to find thread for project");let u=m.threads.find(s=>s.project_id===e);if(!u)throw Error("No thread found for project ".concat(e));let x={};void 0!==s.name&&(x.title=s.name),void 0!==s.is_public&&(x.is_public=s.is_public);let h=await i.H.patch("/threads/".concat(u.thread_id),x,{showErrors:!0});if(h.error)throw Error(h.error.message||"Failed to update project");return{id:e,name:void 0!==s.name?s.name:(null==(t=u.project)?void 0:t.name)||"",description:(null==(a=u.project)?void 0:a.description)||"",is_public:void 0!==s.is_public?s.is_public:(null==(r=u.project)?void 0:r.is_public)||
1!1,created_at:(null==(n=u.project)?void 0:n.created_at)||"",updated_at:null==(l=u.project)?void 0:l.updated_at,sandbox:(null==(o=u.project)?void 0:o.sandbox)||{id:"",pass:"",vnc_preview:"",sandbox_url:""},icon_name:null==(c=u.project)?void 0:c.icon_name}},d=async function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;try{var a,n;let l=new URLSearchParams({page:s.toString(),limit:t.toString()}),o=await i.H.get("/threads?".concat(l.toString()),{showErrors:!1});if(o.error)return(0,r.handleApiError)(o.error,{operation:"load threads",resource:e?"threads for project ".concat(e):"threads"}),{threads:[],pagination:{page:1,limit:20,total:0,pages:0}};if(!(null==(a=o.data)?void 0:a.threads))return{threads:[],pagination:(null==(n=o.data)?void 0:n.pagination)||{page:1,limit:50,total:0,pages:0}};let d=o.data.threads.map(e=>({thread_id:e.thread_id,project_id:e.project_id,created_at:e.created_at,updated_at:e.updated_at,metadata:e.metadata||{},project:e.project}));return e&&(d=d.filter(s=>s.project_id===e)),{threads:d,pagination:o.data.pagination||{page:s,limit:t,total:d.length,pages:1}}}catch(s){return(0,r.handleApiError)(s,{operation:"load threads",resource:e?"threads for project ".concat(e):"threads"}),{threads:[],pagination:{page:1,limit:50,total:0,pages:0}}}},c=async e=>{try{let s=(0,a.U)(),{data:{session:t}}=await s.auth.getSession(),r=(0,n.w)(),i={"Content-Type":"application/json"};(null==t?void 0:t.access_token)&&(i.Authorization="Bearer ".concat(t.access_token));let l=!new URLSearchParams(window.location.search).has("debug_messages"),o=await fetch("".concat(r,"/threads/").concat(e,"/messages?order=asc&optimized=").concat(l),{headers:i,cache:"no-store"});if(!o.ok){let e=await o.text().catch(()=>"Unknown error"),s=Error("Error getting messages: ".concat(e));throw s.status=o.status,s}return(await o.json()).messages||[]}catch(e){throw e}}},14097:(e,s,t)=>{t.d(s,{e:()=>M});var a=t(95155),r=t(12115),i=(t(52056),t(99708)),n=t(11010),l=t(37135),o=t(55867),d=t(6191),c=t(86651),m=t(68854),u=t(76237),x=t(15239),h=t(95707),g=t(64269);function p(e){let{modelId:s,size:t=24,className:r="",variant:i="default"}=e,n=function(e){if("workally/basic"===e||"workally/power"===e||"workally-basic"===e||"workally-power"===e||e.includes("claude-haiku-4-5")||e.includes("heol2zyy5v48")||e.includes("claude-sonnet-4-5")||e.includes("few7z4l830xh"))return"workally";if(e.includes("anthropic")||e.includes("claude"))return"anthropic";if(e.includes("openai")||e.includes("gpt"))return"openai";if(e.includes("google")||e.includes("gemini"))return"google";if(e.includes("xai")||e.includes("grok"))return"xai";if(e.includes("moonshotai")||e.includes("kimi"))return"moonshotai";if(e.includes("bedrock"))return"bedrock";if(e.includes("openrouter"))return"openrouter";let s=e.split("/");if(s.length>1){let e=s[0].toLowerCase();if(["openai","anthropic","google","xai","moonshotai","bedrock","openrouter"].includes(e))return e}return"openai"}(s),l={workally:"/workally-symbol.svg",anthropic:"/images/models/Anthropic.svg",openai:"/images/models/OAI.svg",google:"/images/models/Gemini.svg",xai:"/images/models/Grok.svg",moonshotai:"/images/models/Moonshot.svg",bedrock:"/images/models/Anthropic.svg",openrouter:"/images/models/OAI.svg"}[n],o={borderRadius:"".concat(Math.min(.25*t,16),"px")};return l?(0,a.jsx)("div",{className:(0,g.cn)("flex items-center justify-center bg-card border flex-shrink-0",r),style:{width:t,height:t,...o},children:(0,a.jsx)(x.default,{src:l,alt:"".concat(n," icon"),width:.6*t,height:.6*t,className:(0,g.cn)("object-contain","workally"===n?"dark:invert":"dark:brightness-0 dark:invert"),style:{width:.6*t,height:.6*t}})}):(0,a.jsx)("div",{className:(0,g.cn)("flex items-center justify-center bg-card border flex-shrink-0",r),style:{width:t,height:t,...o},children:(0,a.jsx)(h.default,{size:.6*t,className:"text-muted-foreground dark:text-zinc-200"})})}var f=t(3998),j=t(6259),v=t(46767),y=t(93184),N=t(34520),b=t(46830),w=t(51834),_=t(65142),k=t(76444);let C=e=>{let{isOpen:s,onClose:t,onSave:i,initialData:n,mode:l}=e,[o,d]=r.useState(n);r.useEffect(()=>{d(n)},[n,s]);let c=()=>{t()};return(0,a.jsx)(w.lG,{open:s,onOpenChange:e=>{e||c()},children:(0,a.jsxs)(w.Cf,{className:"sm:max-w-[430px]",onEscapeKeyDown:c,onPointerDownOutside:c,children:[(0,a.jsxs)(w.c7,{children:[(0,a.jsx)(w.L3,{children:"add"===l?"Add Custom Model":"Edit Custom Model"}),(0,a.jsxs)(w.rr,{children:["WorkAlly uses ",(0,a.jsx)("b",{children:"LiteLLM"})," under the hood, which makes it compatible with over 100 models. You can easily choose any ",(0,a.jsx)("a",{href:"https://openrouter.ai/models",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-600 underline",children:"OpenRouter model"})," by prefixing it with ",(0,a.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",children:"openrouter/"})," and it should work out of the box. If you want to use other models besides OpenRouter, you might have to modify the ",(0,a.jsx)("a",{href:"https://github.com/workally-ai/workally/blob/main/backend/core/services/llm.py",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-600 underline",children:"llm.py"}),", set the correct environment variables, and rebuild your self-hosted Docker container."]}
1)]}),(0,a.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,a.jsxs)("div",{className:"flex flex-col items-start gap-4",children:[(0,a.jsx)(k.J,{htmlFor:"modelId",className:"text-right",children:"Model ID"}),(0,a.jsx)(_.p,{id:"modelId",placeholder:"e.g. openrouter/meta-llama/llama-4-maverick",value:o.id,onChange:e=>{let{id:s,value:t}=e.target;d(e=>({...e,["modelId"===s?"id":"label"]:t}))},className:"col-span-3",onClick:e=>e.stopPropagation()})]})}),(0,a.jsxs)(w.Es,{children:[(0,a.jsx)(f.$,{variant:"outline",onClick:e=>{e.stopPropagation(),c()},children:"Cancel"}),(0,a.jsx)(f.$,{onClick:e=>{e.stopPropagation(),o.id.trim()&&i(o)},disabled:!o.id.trim(),children:"add"===l?"Add Model":"Save Changes"})]})]})})};var S=t(40255),E=t(52619),T=t.n(E);let A=e=>{let{label:s,className:t}=e;return"WorkAlly POWER Mode"===s?(0,a.jsxs)("span",{className:(0,g.cn)("flex items-center gap-2",t),children:[(0,a.jsx)("span",{className:"font-medium",children:"WorkAlly"}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 dark:bg-primary/15 rounded-full",children:[(0,a.jsx)(u.i,{size:12,variant:"symbol"}),(0,a.jsx)("span",{className:"text-[11px] font-semibold tracking-wide uppercase text-primary",children:"Power"})]})]}):"WorkAlly Basic"===s?(0,a.jsxs)("span",{className:(0,g.cn)("flex items-center gap-2",t),children:[(0,a.jsx)("span",{className:"font-medium",children:"WorkAlly"}),(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1.5 py-0.5 bg-muted/50 rounded-md",children:"Basic"})]}):(0,a.jsx)("span",{className:(0,g.cn)("font-medium",t),children:s})};function M(e){let{value:s,onChange:t,disabled:u=!1,variant:x="default",className:h}=e,{allModels:w,canAccessModel:_,subscriptionStatus:k,selectedModel:E,handleModelChange:M,customModels:I,addCustomModel:q,updateCustomModel:F,removeCustomModel:P,modelsData:z}=(0,y.xE)(),[L,V]=(0,r.useState)(!1),[O,U]=(0,r.useState)(""),[J,D]=(0,r.useState)(-1),K=(0,r.useRef)(null),W=(0,S.s)(e=>e.openPricingModal),[$,Q]=(0,r.useState)(!1),[R,B]=(0,r.useState)({id:"",label:""}),[H,G]=(0,r.useState)("add"),[Y,Z]=(0,r.useState)(null),X=s||E,ee=(0,r.useMemo)(()=>{let e=new Map;return(null==z?void 0:z.models)?z.models.forEach(s=>{let t=s.name||s.id;e.set(s.id,{id:s.id,label:t,requiresSubscription:!s.allowed,priority:s.priority||0,recommended:!1,top:(s.priority||0)>=90,capabilities:s.capabilities||[],contextWindow:s.context_window||128e3,isCustom:!1})}):w.forEach(s=>{e.set(s.id,{...s,recommended:!1,isCustom:!1})}),(0,b.Jn)()&&I.forEach(s=>{if(e.has(s.id)){let t=e.get(s.id);e.set(s.id,{...t,isCustom:!0})}else e.set(s.id,{id:s.id,label:s.label||(0,N.I)(s.id),requiresSubscription:!1,top:!1,isCu
1stom:!0})}),Array.from(e.values())},[null==z?void 0:z.models,w,I]),es=(0,r.useMemo)(()=>{let e=ee.find(e=>e.id===X);return(null==e?void 0:e.label)||X},[X,ee]),et=(0,r.useMemo)(()=>ee.filter(e=>e.label.toLowerCase().includes(O.toLowerCase())||e.id.toLowerCase().includes(O.toLowerCase())),[ee,O]),ea=(0,r.useMemo)(()=>[...et].sort((e,s)=>{var t,a;return e.requiresSubscription!==s.requiresSubscription?e.requiresSubscription?1:-1:(null!=(t=s.priority)?t:0)-(null!=(a=e.priority)?a:0)}),[et]),er=ea.filter(e=>!e.requiresSubscription),ei=ea.filter(e=>e.requiresSubscription),en=!(0,b.Jn)()&&ei.length>0;(0,r.useEffect)(()=>{L&&K.current?setTimeout(()=>{var e;null==(e=K.current)||e.focus()},50):(U(""),D(-1))},[L]);let el=e=>{if(I.some(s=>s.id===e)&&(0,b.Jn)()){t(e),V(!1);return}(0,b.Jn)()||_(e)?(t(e),V(!1)):(V(!1),ee.find(s=>s.id===e),W({isAlert:!0,alertTitle:"workally/power"===e?"Upgrade to access WorkAlly Power mode":"Upgrade to access this model"}))},eo=()=>{Q(!1),B({id:"",label:""}),Z(null)},ed=(e,s)=>{let r=!!e.isCustom||(0,b.Jn)()&&I.some(s=>s.id===e.id),o=!!r||(0,b.Jn)()||_(e.id),d=s===J;e.requiresSubscription;let c="workally/power"===e.id,m=e=>null==e?null:"$".concat(e.toFixed(2)),x=m(e.inputCostPerMillionTokens),h=m(e.outputCostPerMillionTokens);return(0,a.jsxs)(v.m_,{children:[(0,a.jsx)(v.k$,{asChild:!0,children:(0,a.jsx)("div",{className:"w-full",children:(0,a.jsxs)(j._2,{className:(0,g.cn)("text-sm px-2 py-2 mx-2 my-0.5 flex items-center gap-0 rounded-lg transition-all duration-200",o?"cursor-pointer":"cursor-not-allowed",d&&o&&"bg-accent",X===e.id&&o&&"bg-muted border border-border",!o&&!u&&"opacity-60 hover:opacity-70"),onClick:()=>!u&&el(e.id),onMouseEnter:()=>D(s),children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,a.jsx)("div",{className:(0,g.cn)("relative",!o&&"opacity-60"),children:(0,a.jsx)(p,{modelId:e.id,size:24})}),(0,a.jsx)("div",{className:(0,g.cn)("flex-1",!o&&"opacity-60"),children:(0,a.jsx)(A,{label:e.label,className:o?"":"opacity-60"})})]}),(0,a.jsx)("div",{className:(0,g.cn)("w-16 text-right text-xs text-muted-foreground",!o&&"opacity-60"),children:x||"—"}),(0,a.jsx)("div",{className:(0,g.cn)("w-16 text-right text-xs text-muted-foreground",!o&&"opacity-60"),children:h||"—"}),(0,a.jsxs)("div",{className:"w-8 flex items-center justify-center",children:[!1,!o&&!(0,b.Jn)()&&(0,a.jsx)(i.default,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,b.Jn)()&&r&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{onClick:s=>{s.stopPropagation(),null==s||s.stopPropagation(),B({id:e.id,label:e.label}),Z(e.id),G("edit"),Q(!0),V(!1)},className:"text-muted-foreground hover:text-foreground",children:(0,a.jsx)(n.default,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:s=>{s.stopPropagation();var a=e.id;if(null==s||s.stopPropagation(),null==s||s.preventDefault(),P(a),X===a){let e=w.find(e=>_(e.id));e&&t(e.id)}},className:"text-muted-foreground hover:text-red-500",children:(0,a.jsx)(l.default,{className:"h-3.5 w-3.5"})})]})]})]})})}),o||(0,b.Jn)()?r?(0,a.jsx)(v.ZI,{side:"left",className:"text-xs max-w-xs",children:(0,a.jsx)("p",{children:"Custom model"})}):null:(0,a.jsx)(v.ZI,{side:"left",className:"text-xs max-w-xs",children:(0,a.jsx)("p",{children:c?"Upgrade to access WorkAlly Power mode":"Upgrade to access this model"})})]},"model-".concat(e.id,"-").concat(s))};return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)(j.rI,{open:L,onOpenChange:V,children:[(0,a.jsxs)(v.m_,{children:[(0,a.jsx)(v.k$,{asChild:!0,children:(0,a.jsx)(j.ty,{asChild:!0,disabled:u,children:"menu-item"===x?(0,a.jsx)("div",{className:(0,g.cn)("flex items-center justify-between cursor-pointer rounded-lg px-3 py-2 mx-0 my-0.5 text-sm hover:bg-accent",u&&"opacity-50 cursor-not-allowed",h),children:(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,a.jsx)(p,{modelId:X,size:24}),(0,a.jsx)("span",{className:"truncate",children:(0,a.jsx)(A,{label:es})})]})}):(0,a.jsxs)(f.$,{variant:"outline",size:"sm",className:(0,g.cn)("h-8 px-4 py-2",u&&"opacity-50 cursor-not-allowed",h),children:[(0,a.jsx)(p,{modelId:X,size:24}),(0,a.jsx)("span",{className:"text-sm",children:(0,a.jsx)(A,{label:es})})]})})}),(0,a.jsx)(v.ZI,{side:"menu-item"===x?"left":"top",className:"text-xs",children:(0,a.jsx)("p",{children:"Choose a model for this agent"})})]}),(0,a.jsx)(j.SQ,{align:"menu-item"===x?"end":"start",className:"w-80 p-0 overflow-hidden",sideOffset:"menu-item"===x?8:4,children:(0,a.jsxs)("div",{className:"max-h-[400px] overflow-y-auto scrollbar-thin scrollbar-thumb-zinc-300 dark:scrollbar-thumb-zinc-700 scrollbar-track-transparent w-full",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground p-2 px-4",children:"All Models"}),(0,b.Jn)()&&(0,a.jsxs)("div",{className:"flex items-center gap-1 p-2",children:[(0,a.jsxs)(v.m_,{children:[(0,a.jsx)(v.k$,{asChild:!0,children:(0,a.jsx)(T(),{href:"/settings/env-manager",className:"h-6 w-6 p-0 flex items-center justify-center",children:(0,a.jsx)(o.default,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(v.ZI,{side:"bottom",className:"text-xs",children:"Local .Env Manager"})]}),(0,a.jsxs)(v.m_,{children:[(0,a.jsx)(v.k$,{asChild:!0,children:(0,a.jsx)(f.$,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:e=>{e.stopPropagation(),null==e||e.stopPropagation(),B({id:"",label:""}),G("add"),Q(!0),V(!1)},children:(0,a.jsx)(d.default,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(v.ZI,{side:"bottom",className:"text-xs",children:"Add a custom model"})]})]})]}),(0,a.jsx)("div",{className:"px-1 py-1",children:(0,a.jsxs)("div",{className:"relative px-1 flex items-center",children:[(0,a.jsx)(c.default,{className:"absolute left-3 h-3.5 w-3.5 text-muted-foreground pointer-events-none"}),(0,a.jsx)("input",{ref:K,type:"text",placeholder:"Search models...",value:O,onChange:e=>U(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),"ArrowDown"===e.key)e.preventDefault(),D(e=>e<et.length-1?e+1:0);else if("ArrowUp"===e.key)e.preventDefault(),D(e=>e>0?e-1:et.length-1);else if("Enter"===e.key&&J>=0){e.preventDefault();let s=et[J];s&&el(s.id)}},className:"w-full h-8 px-8 py-1 rounded-lg text-sm focus:outline-none bg-muted"})]})}),(0,a.jsx)("div",{className:"px-2 py-2",children:(0,a.jsxs)("div",{className:"flex items-center gap-0 text-xs text-muted-foreground",children:[(0,a.jsx)("div",{className:"flex-1 pl-2",children:"Model"}),(0,a.jsx)("div",{className:"w-16 text-right pr-2",children:"Input"}),(0,a.jsx)("div",{className:"w-16 text-right pr-2",children:"Output"}),(0,a.jsx)("div",{className:"w-8"})]})}),en?(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Available Models"}),er.map((e,s)=>ed(e,s)),ei.length>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mt-4 border-t border-border pt-2",children:[(0,a.jsxs)("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground flex items-center",children:[(0,a.jsx)(m.default,{className:"h-3.5 w-3.5 mr-1.5"}),"active"===k?"Premium Models":"Additional Models"]}),(0,a.jsx)("div",{className:"px-2 py-2",children:(0,a.jsxs)("div",{className:"flex items-center gap-0 text-xs text-muted-foreground",children:[(0,a.jsx)("div",{className:"flex-1 pl-2",children:"Model"}),(0,a.jsx)("div",{className:"w-16 text-right pr-2",children:"Input"}),(0,a.jsx)("div",{className:"w-16 text-right pr-2",children:"Output"}),(0,a.jsx)("div",{className:"w-8"})]})}),(0,a.jsxs)("div",{className:"relative overflow-hidden",style:{maxHeight:"active"===k?"none":"160px"},children:[("active"===k?ei:ei.slice(0,3)).map((e,s)=>{let t=(0,b.Jn)()||_(e.id),r=e=>null==e?null:"$".concat(e.toFixed(2)),i=r(e.inputCostPerMillionTokens),n=r(e.outputCostPerMillionTokens);return(0,a.jsxs)(v.m_,{children:[(0,a.jsx)(v.k$,{asChild:!0,children:(0,a.jsx)("div",{className:"w-full",children:(0,a.jsxs)(j._2,{className:(0,g.cn)("text-sm px-2 py-2 mx-2 my-0.5 flex items-center gap-0 cursor-pointer rounded-lg transition-all duration-200",X===e.id&&"bg-muted border border-border",!t&&"opacity-70"),onClick:()=>el(e.id),children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1 pl-2",children:[(0,a.jsx)(p,{modelId:e.id,size:24}),(0,a.jsx)(A,{label:e.label})]}),(0,a.jsx)("div",{className:"w-16 text-right text-xs text-muted-foreground pr-2",children:i||"—"}),(0,a.jsx)("div",{className:"w-16 text-right text-xs text-muted-foreground pr-2",children:n||"—"}),(0,a.jsx)("div",{className:"w-8 flex items-center justify-center",children:!t&&(0,a.jsx)(m.default,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})})}),(0,a.jsx)(v.ZI,{side:"left",className:"text-xs max-w-xs",children:(0,a.jsx)("p",{children:t?"Premium model":"Requires subscription to access premium model"})})]},"premium-".concat(e.id,"-").concat(s))}),"active"!==k&&ei.length>0&&(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-background via-background/95 to-transparent flex items-end justify-center pointer-events-none",children:(0,a.jsx)("div",{className:"w-full p-3 pointer-events-auto",children:(0,a.jsx)("div",{className:"rounded-xl bg-gradient-to-br from-muted/80 to-muted/70 dark:from-muted/40 dark:to-muted/30 shadow-sm border border-border p-3",children:(0,a.jsxs)("div",{className:"flex flex-col space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(m.default,{className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),(0,a.jsx)("div",{children:(0,a.jsx)("p",{className:"text-sm font-medium",children:"Unlock all models + higher limits"})})]}),(0,a.jsx)(f.$,{size:"sm",className:"w-full h-8 font-medium",onClick:()=>{V(!1),W({isAlert:!0,alertTitle:"Upgrade to access premium models"})},children:"Upgrade now"})]})})})})]})]})})]}):(0,a.jsx)("div",{children:ea.length>0?ea.map((e,s)=>ed(e,s)):(0,a.jsx)("div",{className:"text-sm text-center py-4 text-muted-foreground",children:"No models match your search"})})]}),(0,a.jsx)("div",{className:"px-4 py-2 border-t border-border bg-muted/30",children:(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground text-center",children:"* All prices are per 1 million tokens"})})]})})]}),(0,b.Jn)()&&(0,a.jsx)(C,{isOpen:$,onClose:eo,onSave:e=>{let s=e.id.trim(),a=e.label.trim()||(0,N.I)(s);if(!s||I.some(e=>e.id===s&&("add"===H||e.id!==Y)))return;eo();let r={id:s,label:a};"add"===H?(q(r),t(s)):(F(Y,r),X===Y&&t(s)),V(!1)},initialData:R,mode:H})]})}},30886:(e,s,t)=>{t.d(s,{CA:()=>x,Lp:()=>u,ol:()=>m});var a=t(99776),r=t(80549),i=t(96648),n=t(18720);let l="https://izhlxcyecizqgfnamhpf.supabase.co/functions/v1",o=async()=>{let e=(0,i.U)(),{data:{session:s}}=await e.auth.getSession();if(!s)throw Error("You must be logged in to manage integrations");return s.access_token},d=async e=>{let s=await o(),t=await fetch("".concat(l,"/integrations/install"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(s)},body:JSON.stringify(e)});if(!t.ok)throw Error((await t.json().catch(()=>({}))).detail||"Failed to initiate installation");return t.json()},c=async e=>{let s=await o(),t=await fetch("".concat(l,"/integrations/uninstall/").concat(e),{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(s)}});if(!t.ok)throw Error((await t.json().catch(()=>({}))).detail||"Failed to uninstall integration")},m=()=>((0,a.jE)(),(0,r.n)({mutationFn:d,onSuccess:(e,s)=>{sessionStorage.setItem("oauth_agent_id",s.agent_id),sessionStorage.setItem("oauth_provider",s.provider),window.location.href=e.install_url},onError:e=>{n.toast.error(e.message||"Failed to start OAuth installation")}})),u=()=>{let e=(0,a.jE)();return(0,r.n)({mutationFn:c,onSuccess:(s,t)=>{n.toast.success("Integration uninstalled successfully"),e.invali
1dateQueries({queryKey:["oauth-integrations"]}),e.invalidateQueries({queryKey:["agent-triggers"]})},onError:e=>{n.toast.error(e.message||"Failed to uninstall integration")}})},x=()=>{let e=(0,a.jE)();return{handleCallback:()=>{let s=new URLSearchParams(window.location.search),t=sessionStorage.getItem("oauth_agent_id");sessionStorage.getItem("oauth_provider");let a=s.get("slack_success"),r=s.get("discord_success"),i=s.get("teams_success");s.get("trigger_id"),s.get("workspace"),s.get("bot_name");let l=s.get("slack_error"),o=s.get("discord_error"),d=s.get("teams_error");if(a||r||i){n.toast.success("".concat(a?"Slack":r?"Discord":"Teams"," integration installed successfully!")),t&&e.invalidateQueries({queryKey:["oauth-integrations",t]}),sessionStorage.removeItem("oauth_agent_id"),sessionStorage.removeItem("oauth_provider");let s=window.location.pathname;window.history.replaceState({},document.title,s)}else if(l||o||d){let e=l?"Slack":o?"Discord":"Teams";n.toast.error("Failed to install ".concat(e," integration: ").concat(l||o||d)),sessionStorage.removeItem("oauth_agent_id"),sessionStorage.removeItem("oauth_provider");let s=window.location.pathname;window.history.replaceState({},document.title,s)}}}}},31974:(e,s,t)=>{t.d(s,{i:()=>K});var a=t(95155),r=t(12115),i=t(51834),n=t(65142),l=t(3998),o=t(11647),d=t(76444),c=t(31120),m=t(20243),u=t(86259),x=t(11186),h=t(4788),g=t(56154),p=t(95740),f=t(61362),j=t(27937),v=t(23327),y=t(35626),N=t(86651),b=t(35299),w=t(6191),_=t(53455),k=t(99776),C=t(80549),S=t(80344);let E=function(e){let s=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return(0,_.I)({queryKey:["composio","app-triggers",e],queryFn:async()=>{let s=await S.H.get("/composio/triggers/apps/".concat(e));if(!s.success){var t;throw Error((null==(t=s.error)?void 0:t.message)||"Failed to load triggers")}return s.data},enabled:s&&!!e,staleTime:3e5})};var T=t(33089),A=t(82699),M=t(89566),I=t(18720),q=t(64269),F=t(7853),P=t(61380),z=t(14097);let L=e=>{let{currentStep:s}=e,t=[{id:"apps",name:"Select App",icon:(0,a.jsx)(h.default,{className:"h-4 w-4"})},{id:"triggers",name:"Choose Trigger",icon:(0,a.jsx)(g.default,{className:"h-4 w-4"})},{id:"config",name:"Configure",icon:(0,a.jsx)(p.default,{className:"h-4 w-4"})}],i=t.findIndex(e=>e.id===s);return(0,a.jsx)("div",{className:"px-6 py-3 border-b bg-muted/30",children:(0,a.jsx)("div",{className:"flex items-center space-x-1",children:t.map((e,s)=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:(0,q.cn)("flex items-center justify-center w-6 h-6 rounded-full text-xs font-medium",s<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:s<i?(0,a.jsx)(f.default,{className:"h-3 w-3"}):(0,a.jsx)("span",{children:s+1})}),(0,a.jsx)("span",{className:(0,q.cn)("text-sm font-medium",s<=i?"text-foreground":"text-muted-foreground"),children:e.name})]}),s<t.length-1&&(0,a.jsx)(j.default,{className:"h-4 w-4 text-muted-foreground mx-2"})]},e.id))})})},V=e=>{let{app:s,onClick:t,connectionStatus:r}=e;return(0,a.jsxs)("button",{onClick:t,className:"group relative bg-card border border-border rounded-lg p-4 hover:bg-accent text-left w-full",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[s.logo?(0,a.jsx)("div",{className:"border flex-shrink-0 w-10 h-10 rounded-lg bg-muted flex items-center justify-center overflow-hidden",children:(0,a.jsx)("img",{src:s.logo,alt:s.name,className:"w-6 h-6 object-contain"})}):(0,a.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-md bg-muted flex items-center justify-center",children:(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:s.name.charAt(0)})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm mb-1 text-foreground group-hover:text-accent-foreground",children:s.name}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:r.isConnected?"Create automated triggers from ".concat(s.name," events"):r.hasProfiles?"Connect your ".concat(s.name," account to create triggers"):"Set up ".concat(s.name," connection to get started")})]}),(0,a.jsx)(j.default,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})]}),(0,a.jsx)("div",{className:"mt-3 pt-3 border-t border-border",children:(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsx)("div",{className:"flex items-center gap-1",children:r.isConnected?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),(0,a.jsx)("span",{className:"text-xs text-green-600 dark:text-green-400",children:"Connected"})]}):r.hasProfiles?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-yellow-500"}),(0,a.jsx)("span",{className:"text-xs text-yellow-600 dark:text-yellow-400",children:"Not Connected"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),(0,a.jsx)("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Setup Required"})]})})})})]})},O=e=>{let{app:s,trigger:t,onClick:r}=e;return(0,a.jsx)("button",{onClick:r,className:"group relative bg-card border border-border rounded-lg p-4 hover:bg-accent text-left w-full",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[s.logo?(0,a.jsx)("div",{className:"border flex-shrink-0 w-10 h-10 rounded-lg bg-muted flex items-center justify-center overflow-hidden",children:(0,a.jsx)("img",{src:s.logo,alt:s.name,className:"w-6 h-6 object-contain"})}):(0,a.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-md bg-muted flex items-center justify-center",children:(0,a.jsx)(g.default,{className:"h-4 w-4 text-muted-foreground"})}),(0,a.jsx)(o.E,{variant:"secondary",className:"text-xs text-white",children:t.type})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("h3",{className:"font-medium text-sm text-foreground group-hover:text-accent-foreground",children:t.name}),t.description&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:t.description})]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("code",{className:"text-xs bg-muted px-2 py-1 rounded font-mono text-muted-foreground",children:(0,q.W5)(t.slug,25)}),(0,a.jsx)(j.default,{className:"h-3 w-3 text-muted-foreground"})]})})]})})},U=()=>(0,a.jsxs)("div",{className:"bg-card border border-border rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)(m.Skeleton,{className:"w-10 h-10 rounded-md"}),(0,a.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,a.jsx)(m.Skeleton,{className:"w-3/4 h-4"}),(0,a.jsx)(m.Skeleton,{className:"w-full h-3"}),(0,a.jsx)(m.Skeleton,{className:"w-5/6 h-3"})]})]}),(0,a.jsx)("div",{className:"pt-3 border-t border-border",children:(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)(m.Skeleton,{className:"w-16 h-3"}),(0,a.jsx)(m.Skeleton,{className:"w-12 h-5"})]})})]}),J=()=>(0,a.jsx)("div",{className:"bg-card border border-border rounded-lg p-4",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsx)(m.Skeleton,{className:"w-8 h-8 rounded-md"}),(0,a.jsx)(m.Skeleton,{className:"w-12 h-5"})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(m.Skeleton,{className:"w-4/5 h-4"}),(0,a.jsx)(m.Skeleton,{className:"w-full h-3"}),(0,a.jsx)(m.Skeleton,{className:"w-3/4 h-3"})]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)(m.Skeleton,{className:"w-16 h-5"}),(0,a.jsx)(m.Skeleton,{className:"w-4 h-4"})]})})]})}),D=e=>{let{schema:s,value:t,onChange:r}=e;if(!s||!s.properties||0===Object.keys(s.properties).length)return(0,a.jsxs)("div",{className:"text-center py-4 text-muted-foreground",children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-md bg-muted flex items-center justify-center mb-2 mx-auto",children:(0,a.jsx)(v.default,{className:"h-4 w-4"})}),(0,a.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Ready to go!"}),(0,a.jsx)("p",{className:"text-xs",children:"This trigger doesn't require configuration"})]});let i=s.properties||{},l=new Set(s.required||[]);return(0,a.jsx)("div",{className:"space-y-3",children:Object.entries(i).map(e=>{var s,i,o,c,m;
1let[u,x]=e,h=x.title||u,g=x.type||"string",p=l.has(u),f=Array.isArray(x.examples)?x.examples:[],j=x.description||"",v=null!=(i=null!=(s=t[u])?s:x.default)?i:"",y=e=>r({...t,[u]:e});return(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)(d.J,{className:"text-sm",children:[h," ",p&&(0,a.jsx)("span",{className:"text-destructive",children:"*"})]}),"number"===g||"integer"===g?(0,a.jsx)(n.p,{value:v,inputMode:"numeric",onChange:e=>y(""===e.target.value?"":Number(e.target.value)),placeholder:null!=(o=f[0])?o:""}):"array"===g?(0,a.jsx)(n.p,{value:Array.isArray(v)?v.join(","):v,onChange:e=>y(e.target.value.split(",").map(e=>e.trim()).filter(Boolean)),placeholder:null!=(c=f[0])?c:"comma,separated,values"}):"boolean"===g?(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("input",{type:"checkbox",checked:!!v,onChange:e=>y(e.target.checked),className:"rounded border-input"}),(0,a.jsx)("span",{className:"text-sm",children:j||h})]}):(0,a.jsx)(n.p,{value:v,onChange:e=>y(e.target.value),placeholder:null!=(m=f[0])?m:""}),j&&"boolean"!==g&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:j})]},u)})})},K=e=>{let{open:s,onOpenChange:t,agentId:o,onTriggerCreated:m,isEditMode:h=!1,existingTrigger:p,onTriggerUpdated:f}=e,[j,q]=(0,r.useState)(h?"config":"apps"),[K,W]=(0,r.useState)(""),[$,Q]=(0,r.useState)(null),[R,B]=(0,r.useState)(null),[H,G]=(0,r.useState)({}),[Y,Z]=(0,r.useState)(""),[X,ee]=(0,r.useState)(""),[es,et]=(0,r.useState)(""),[ea,er]=(0,r.useState)("workally/basic"),[ei]=(0,r.useState)("agent"),[en,el]=(0,r.useState)(!1),{data:eo,isLoading:ed}=(0,_.I)({queryKey:["composio","apps-with-triggers"],queryFn:async()=>{let e=await S.H.get("/composio/triggers/apps");if(!e.success){var s;throw Error((null==(s=e.error)?void 0:s.message)||"Failed to load apps")}return e.data},staleTime:3e5}),{data:ec,isLoading:em,error:eu}=E(null==$?void 0:$.slug,!!$),{data:ex,isLoading:eh,refetch:eg}=(0,A.lj)((null==$?void 0:$.slug)?{toolkit_slug:$.slug}:void 0),{data:ep}=(0,A.lj)(),{data:ef}=(0,M.RY)((null==$?void 0:$.slug)||"",{enabled:!!$});(0,r.useEffect)(()=>{},[h,$,em,ec,eu]);let ej=(0,r.useMemo)(()=>((null==eo?void 0:eo.items)||[]).filter(e=>e.name.toLowerCase().includes(K.toLowerCase())||e.slug.toLowerCase().includes(K.toLowerCase())),[eo,K]),ev=(0,r.useMemo)(()=>e=>{if(!ep)return{isConnected:!1,hasProfiles:!1};let s=ep.filter(s=>s.toolkit_slug===e);return{isConnected:s.filter(e=>e.is_connected).length>0,hasProfiles:s.length>0}},[ep]),ey=(()=>{let e=(0,k.jE)();return(0,C.n)({mutationFn:async e=>{let s=await S.H.post("/composio/triggers/create",e);if(!s.success)throw s.error||Error("Failed to create trigger");return s.data},onSuccess:s=>{let t=(null==s?void 0:s.agent_id)||void 0;t&&e.invalidateQueries({queryKey:["agent-triggers",t]}),e.invalidateQueries({queryKey:["all-triggers"]})}})})(),eN=(0,T.vg)();(0,r.useEffect)(()=>{s||(q(h?"config":"apps"),Q(null),B(null),G({}),Z(""),ee(""),et(""),er("workally/basic"),el(!1))},[s,h]),(0,r.useEffect)(()=>{R&&Z("".concat((null==$?void 0:$.name)||R.toolkit.name," → Agent"))},[R,$]),(0,r.useEffect)(()=>{et("")},[null==$?void 0:$.slug]),(0,r.useEffect)(()=>{if(ex&&ex.length>0&&!es){let e=ex.filter(e=>e.is_connected);e.length>0&&et(e[0].profile_id)}},[ex,es]),(0,r.useEffect)(()=>{if(h&&p&&s){let e=p.config||{};Z(p.name||""),ee(e.agent_prompt||""),et(e.profile_id||""),er(e.model||"workally/basic");let{agent_prompt:s,profile_id:a,provider_id:r,trigger_slug:i,qualified_name:n,model:l,...o}=e;G(o);let d="composio"===e.provider_id||"composio"===p.provider_id;if(d&&e.trigger_slug){let s="";if(e.qualified_name&&(s=e.qualified_name.replace(/^composio\./,"").toLowerCase()),!s&&e.trigger_slug){let t=e.trigger_slug.toLowerCase().split("_");t.length>0&&(s=t[0])}s?Q({slug:s,name:s,logo:void 0}):(I.toast.error("Could not determine the app for this trigger"),t(!1))}else d&&!e.trigger_slug&&(I.toast.error("Invalid trigger configuration: missing trigger information"),t(!1))}},[h,p,s,t]),(0,r.useEffect)(()=>{if(h&&p&&$){let e=p.config||{};if(void 0!==ec)if((null==ec?void 0:ec.items)&&ec.items.length>0)if(e.trigger_slug){let s=e.trigger_slug.toLowerCase(),a=ec.items.find(e=>e.slug.toLowerCase()===s);a?B(a):(I.toast.error("Could not find the trigger type. It may have been removed or renamed."),setTimeout(()=>t(!1),2e3))}else I.toast.error("Invalid trigger configuration: missing trigger_slug"),setTimeout(()=>t(!1),2e3);else I.toast.error("No triggers available for this app"),setTimeout(()=>t(!1),2e3)}},[h,p,$,ec,t]);let eb=(0,r.useMemo)(()=>null==R||!R.config||Array.from(new Set(R.config.required||[])).every(e=>{let s=H[e];return void 0!==s&&""!==s&&null!==s}),[null==R?void 0:R.config,H]),ew=async()=>
1{if(o&&es&&R)try{if(h&&p){let e={...H,profile_id:es,trigger_slug:R.slug,qualified_name:"composio.".concat(null==$?void 0:$.slug),provider_id:"composio",agent_prompt:X||"Read this",model:ea};await eN.mutateAsync({triggerId:p.trigger_id,name:Y||"".concat(R.toolkit.name," → Agent"),description:p.description||"Event trigger for ".concat(R.toolkit.name),config:e,is_active:!0}),I.toast.success("Task updated"),f&&p.trigger_id&&f(p.trigger_id)}else{let e=null==ex?void 0:ex.find(e=>e.profile_id===es),s={agent_id:o,profile_id:es,slug:R.slug,trigger_config:H,name:Y||"".concat(R.toolkit.name," → Agent"),connected_account_id:null==e?void 0:e.connected_account_id,toolkit_slug:null==$?void 0:$.slug,model:ea},t="agent"===ei?{...s,route:"agent",agent_prompt:X||"Read this"}:{...s,route:"agent"},a=await ey.mutateAsync(t);I.toast.success("Task created"),m&&(null==a?void 0:a.trigger_id)&&m(a.trigger_id)}t(!1)}catch(e){}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.lG,{open:s,onOpenChange:t,children:(0,a.jsx)(i.Cf,{className:"max-w-4xl max-h-[90vh] p-0",children:(0,a.jsxs)("div",{className:"flex flex-col h-full max-h-[90vh]",children:[(0,a.jsx)(i.c7,{className:"shrink-0 px-6 py-4 border-b",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["apps"!==j&&(0,a.jsx)(l.$,{variant:"ghost",size:"icon",onClick:()=>{"triggers"===j?(q("apps"),Q(null)):"config"===j&&(q("triggers"),B(null),G({}))},className:"h-8 w-8",children:(0,a.jsx)(y.default,{className:"h-4 w-4"})}),(0,a.jsx)(i.L3,{className:"text-lg font-semibold",children:h?"Edit Event Trigger":"Create Event Trigger"})]})}),(0,a.jsx)(L,{currentStep:j}),(0,a.jsxs)("div",{className:"flex-1 overflow-hidden",children:["apps"===j&&(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[(0,a.jsxs)("div",{className:"p-6 border-b flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-semibold",children:"Select an Application"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose an app to monitor for events and trigger your agent"})]}),(0,a.jsxs)("div",{className:"relative max-w-md",children:[(0,a.jsx)(N.default,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,a.jsx)(n.p,{placeholder:"Search apps...",value:K,onChange:e=>W(e.target.value),className:"pl-10"})]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",style:{maxHeight:"calc(90vh - 200px)"},children:ed?(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Array.from({length:6}).map((e,s)=>(0,a.jsx)(U,{},s))}):0===ej.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-lg bg-muted flex items-center justify-center mb-3",children:(0,a.jsx)(N.default,{className:"h-6 w-6 text-muted-foreground"})}),(0,a.jsx)("h3",{className:"font-medium mb-1",children:"No apps found"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:K?'No apps match "'.concat(K,'"'):"No apps with triggers available"})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:ej.map(e=>{let s=ev(e.slug);return(0,a.jsx)(V,{app:e,connectionStatus:s,onClick:()=>{Q(e),s.isConnected?q("triggers"):el(!0)}},e.slug)})})})]}),"triggers"===j&&$&&(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[(0,a.jsx)("div",{className:"p-6 border-b",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[$.logo&&(0,a.jsx)("div",{className:"border w-10 h-10 rounded-lg bg-muted flex items-center justify-center overflow-hidden",children:(0,a.jsx)("img",{src:$.logo,alt:$.name,className:"w-5 h-5 object-contain"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("h2",{className:"font-semibold",children:[$.name," Triggers"]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose an event to monitor"})]})]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",style:{maxHeight:"calc(90vh - 200px)"},children:em?(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Array.from({length:4}).map((e,s)=>(0,a.jsx)(J,{},s))}):0===((null==ec?void 0:ec.items)||[]).length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-lg bg-muted flex items-center justify-center mb-3",children:(0,a.jsx)(g.default,{className:"h-6 w-6 text-muted-foreground"})}),(0,a.jsx)("h3",{className:"font-medium mb-1",children:"No triggers available"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"This app doesn't have any triggers yet."})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:((null==ec?void 0:ec.items)||[]).map(e=>(0,a.jsx)(O,{trigger:e,onClick:()=>{B(e),G({}),q("config")},app:$},e.slug))})})]}),"config"===j&&(0,a.jsx)("div",{className:"h-full flex flex-col",children:h&&!R&&(em||!$)?(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,a.jsxs)("div",{className:"text-center space-y-3",children:[(0,a.jsx)(b.default,{className:"h-8 w-8 animate-spin mx-auto text-muted-foreground"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading trigger configuration..."}),eu&&(0,a.jsxs)("p",{className:"text-xs text-destructive",children:["Error: ",String(eu)]})]})}):!h||R||em?R?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",style:{maxHeight:"calc(90vh - 250px)"}
1,children:(0,a.jsxs)("div",{className:"max-w-2xl mx-auto space-y-6",children:[R.instructions&&(0,a.jsx)(P.C,{content:R.instructions,className:"text-sm w-full text-muted-foreground"}),eh||0!==(ex||[]).filter(e=>e.is_connected).length?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:R.name}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure this trigger"})]}),(0,a.jsx)(D,{schema:R.config,value:H,onChange:G})]}),(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Execution Settings"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose how to handle this event"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(d.J,{className:"text-sm",children:"Connection Profile"}),(0,a.jsxs)(x.l6,{value:es,onValueChange:e=>{"__create_new__"===e?el(!0):et(e)},children:[(0,a.jsx)(x.bq,{children:(0,a.jsx)(x.yv,{placeholder:"Select a profile..."})}),(0,a.jsx)(x.gC,{children:eh?(0,a.jsx)(x.eb,{value:"__loading__",disabled:!0,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(b.default,{className:"h-3 w-3 animate-spin"}),(0,a.jsx)("span",{children:"Loading..."})]})}):(0,a.jsxs)(a.Fragment,{children:[(ex||[]).filter(e=>e.is_connected).map(e=>(0,a.jsx)(x.eb,{value:e.profile_id,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),(0,a.jsx)("span",{children:e.profile_name})]})},e.profile_id)),(0,a.jsx)(u.w,{className:"my-1"}),(0,a.jsx)(x.eb,{value:"__create_new__",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 text-primary",children:[(0,a.jsx)(w.default,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:"Create New Connection"})]})})]})})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(d.J,{className:"text-sm",children:"Trigger Name"}),(0,a.jsx)(n.p,{value:Y,onChange:e=>Z(e.target.value),placeholder:"Gmail → Agent"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(d.J,{className:"text-sm",children:"Agent Instructions"}),(0,a.jsx)(c.T,{rows:3,value:X,onChange:e=>ee(e.target.value),placeholder:"What should the agent do when this event occurs?"}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Use ",(0,a.jsx)("code",{className:"text-xs bg-muted px-1 rounded",children:"{{variable_name}}"})," to add variables to the prompt"]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(d.J,{className:"text-sm",children:"Model"}),(0,a.jsx)(z.e,{value:ea,onChange:er}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose which model to use when this event triggers"})]})]})]})]}):(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-lg bg-muted flex items-center justify-center mb-3 mx-auto",children:(0,a.jsx)(v.default,{className:"h-6 w-6 text-muted-foreground"})}),(0,a.jsx)("h3",{className:"font-medium mb-2",children:"No Connected Profile"}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground mb-4",children:["Connect ",null==$?void 0:$.name," first to create triggers."]}),(0,a.jsx)(l.$,{variant:"outline",onClick:()=>q("apps"),children:"Back to Apps"})]})]})}),!eh&&(ex||[]).filter(e=>e.is_connected).length>0&&(0,a.jsx)("div",{className:"shrink-0 border-t p-4 bg-background",children:(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(l.$,{onClick:ew,disabled:(h?eN.isPending:ey.isPending)||!Y.trim()||!es||!eb||!X.trim(),size:"sm",children:(h?eN.isPending:ey.isPending)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b.default,{className:"h-3 w-3 animate-spin mr-2"}),h?"Updating...":"Creating..."]}):h?"Update Trigger":"Create Trigger"})})})]}):null:(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,a.jsxs)("div",{className:"text-center space-y-3",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-lg bg-muted flex items-center justify-center mb-3 mx-auto",children:(0,a.jsx)(v.default,{className:"h-6 w-6 text-muted-foreground"})}),(0,a.jsx)("h3",{className:"font-medium",children:"Unable to load trigger"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:"The trigger configuration could not be loaded. It may have been removed or is no longer available."}),eu&&(0,a.jsxs)("p",{className:"text-xs text-destructive mt-2",children:["Error: ",String(eu)]}),(0,a.jsx)(l.$,{variant:"outline",onClick:()=>t(!1),children:"Close"})]})})})]})]})})}),$&&en&&(0,a.jsx)(F.d,{app:{slug:$.slug,name:$.name,logo:$.logo,description:"Connect your ".concat($.name," account to create event triggers"),tags:[],auth_schemes:(null==ef?void 0:ef.toolkit.auth_schemes)||["oauth"],categories:[]},open:en,onOpenChange:el,mode:"profile-only",onComplete:e=>{et(e),el(!1),eg(),I.toast.success("".concat($.name," profile created successfully")),q("triggers")}})]})}},33089:(e,s,t)=>{t.d(s,{aC:()=>x,A$:()=>h,Dz:()=>p,ct:()=>f,Gj:()=>v,vg:()=>g});var a=t(53455),r=t(99776),i=t(80549),n=t(96648),l=t(12054);let o="https://izhlxcyecizqgfnamhpf.supabase.co/functions/v1",d=async e=>{let s=(0,n.U)(),{data:{session:t}}=await s.auth.getSession();if(!t)throw Error("You must be logged in to create a trigger");let a=await fetch("".concat(o,"/triggers/agents/").concat(e,"/triggers"),{headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t.access_token)}});if(!a.ok)throw Error("Failed to fetch agent triggers");return a.json()},c=async e=>{let s=(0,n.U)(),{data:{session:t}}=await s.auth.getSession();if(!t)throw Error("You must be logged in to create a trigger");let a=await fetch("".concat(o,"/triggers/agents/").concat(e.agentId,"/triggers"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t.access_token)},body:JSON.stringify({provider_id:e.provider_id,name:e.name,description:e.description,config:e.config})});if(!a.ok){let e=await a.json(),s=e.detail||e;if(402===a.status&&"TRIGGER_LIMIT_EXCEEDED"===s.error_code)throw new l.YX(a.status,s);throw Error(s.message||e.detail||"Failed to create trigger")}return a.json()},m=async e=>{let s=(0,n.U)(),{data:{session:t}}=await s.auth.getSession();if(!t)throw Error("You must be logged in to create a trigger");let a=await fetch("".concat(o,"/triggers/").concat(e.triggerId),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t.access_token)},body:JSON.stringify({name:e.name,description:e.description,config:e.config,is_active:e.is_active})});if(!a.ok)throw Error((await a.json()).detail||"Failed to update trigger");return a.json()},u=async e=>{let s=(0,n.U)(),{data:{session:t}}=await s.auth.getSession();if(!t)throw Error("You must be logged in to create a trigger");let a=await fetch("".concat(o,"/triggers/").concat(e.triggerId),{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t.access_token)}});if(!a.ok)throw Error((await a.json()).detail||"Failed to delete trigger")},x=e=>(0,a.I)({queryKey:["agent-triggers",e],queryFn:()=>d(e),enabled:!!e,staleTime:12e4}),h=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:c,onSuccess:s=>
1{e.invalidateQueries({queryKey:["agent-upcoming-runs",s.agent_id]}),e.invalidateQueries({queryKey:["all-triggers"]}),e.invalidateQueries({queryKey:["account-state"]}),e.setQueryData(["agent-triggers",s.agent_id],e=>e?[...e,s]:[s])}})},g=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:m,onSuccess:s=>{e.invalidateQueries({queryKey:["agent-upcoming-runs",s.agent_id]}),e.invalidateQueries({queryKey:["all-triggers"]}),e.setQueryData(["agent-triggers",s.agent_id],e=>e?e.map(e=>e.trigger_id===s.trigger_id?s:e):[s])}})},p=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:u,onSuccess:(s,t)=>{let{triggerId:a,agentId:r}=t;e.invalidateQueries({queryKey:["agent-upcoming-runs",r]}),e.invalidateQueries({queryKey:["agent-triggers"]}),e.invalidateQueries({queryKey:["all-triggers"]})}})},f=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:async e=>m({triggerId:e.triggerId,is_active:e.isActive}),onSuccess:s=>{e.invalidateQueries({queryKey:["agent-upcoming-runs",s.agent_id]}),e.invalidateQueries({queryKey:["all-triggers"]}),e.setQueryData(["agent-triggers",s.agent_id],e=>e?e.map(e=>e.trigger_id===s.trigger_id?s:e):[s])}})},j=async()=>{let e=(0,n.U)(),{data:{session:s}}=await e.auth.getSession();if(!s)throw Error("You must be logged in to create a trigger");let t=await fetch("".concat("https://izhlxcyecizqgfnamhpf.supabase.co/functions/v1","/triggers/providers"),{headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(s.access_token)}});if(!t.ok)throw Error("Failed to fetch trigger providers");return t.json()},v=()=>(0,a.I)({queryKey:["trigger-providers"],queryFn:j,staleTime:3e5,gcTime:6e5});t(30886),t(48264),t(98115)},34520:(e,s,t)=>{t.d(s,{I:()=>n,g:()=>i});var a=t(25959),r=t(89863);let i=(0,a.v)()((0,r.Zr)(e=>({selectedModel:"",setSelectedModel:s=>{e({selectedModel:s})}}),{name:"suna-model-selection-v3",partialize:e=>({selectedModel:e.selectedModel})})),n=e=>e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")},48264:(e,s,t)=>{t.d(s,{W:()=>n});var a=t(53455),r=t(80344);let i=async()=>{var e,s;let t=await r.H.get("/triggers/all");if(!t.success)throw Error((null==(e=t.error)?void 0:e.message)||"Failed to fetch triggers");return null!=(s=t.data)?s:[]},n=()=>(0,a.I)({queryKey:["all-triggers"],queryFn:i,staleTime:6e4,refetchInterval:3e4})},75910:(e,s,t)=>{t.d(s,{u:()=>P});var a=t(95155),r=t(12115),i=t(65142),n=t(76444),l=t(31120),o=t(3998),d=t(26983),c=t(30814),m=t(89652),u=t(16485),x=t(95740),h=t(61362),g=t(27937),p=t(23327),f=t(39068),j=t(13406),v=t(11186),y=t(50276),N=t(26333),b=t(51834),w=t(861),_=t(5282),k=t(64269),C=t(98461),S=t(14097);let E=[{id:"hourly",name:"Every hour",description:"Hourly check-ins",cron:"0 * * * *",icon:(0,a.jsx)(d.default,{className:"h-5 w-5"})},{id:"daily-9am",name:"Daily at 9 AM",description:"Morning routine",cron:"0 9 * * *",icon:(0,a.jsx)(c.default,{className:"h-5 w-5"})},{id:"daily-12pm",name:"Daily at 12 PM",description:"Noon check",cron:"0 12 * * *",icon:(0,a.jsx)(c.default,{className:"h-5 w-5"})},{id:"daily-6pm",name:"Daily at 6 PM",description:"Evening routine",cron:"0 18 * * *",icon:(0,a.jsx)(c.default,{className:"h-5 w-5"})},{id:"twice-daily",name:"Twice daily",description:"9 AM and 5 PM",cron:"0 9,17 * * *",icon:(0,a.jsx)(m.default,{className:"h-5 w-5"})},{id:"weekdays-9am",name:"Weekdays at 9 AM",description:"Monday-Friday mornings",cron:"0 9 * * 1-5",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})},{id:"monday-mornings",name:"Monday mornings",description:"Every Monday at 9 AM",cron:"0 9 * * 1",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})},{id:"friday-evenings",name:"Friday evenings",description:"Every Friday at 5 PM",cron:"0 17 * * 5",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})},{id:"weekend-mornings",name:"Weekend mornings",description:"Saturday & Sunday at 10 AM",cron:"0 10 * * 0,6",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})},{id:"monthly-1st",name:"Monthly on 1st",description:"First day of month at 9 AM",cron:"0 9 1 * *",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})},{id:"monthly-15th",name:"Monthly on 15th",description:"Mid-month at 9 AM",cron:"0 9 15 * *",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})},{id:"end-of-month",name:"End of month",description:"Last few days at 9 AM",cron:"0 9 28-31 * *",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})}],T=[{id:"weekdays-9am",name:"Weekdays at 9 AM",description:"Business hours only",cron:"0 9 * * 1-5",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})}
1,{id:"weekly-monday",name:"Weekly on Monday",description:"Weekly summary",cron:"0 9 * * 1",icon:(0,a.jsx)(m.default,{className:"h-5 w-5"})},{id:"monthly-1st",name:"Monthly on 1st",description:"Monthly reports",cron:"0 9 1 * *",icon:(0,a.jsx)(u.default,{className:"h-5 w-5"})}],A=(()=>{let e=Intl.DateTimeFormat().resolvedOptions().timeZone,s=[{value:"UTC",label:"UTC (Coordinated Universal Time)"},{value:"America/New_York",label:"Eastern Time (ET)"},{value:"America/Chicago",label:"Central Time (CT)"},{value:"America/Denver",label:"Mountain Time (MT)"},{value:"America/Los_Angeles",label:"Pacific Time (PT)"},{value:"Europe/London",label:"Greenwich Mean Time (GMT)"},{value:"Europe/Paris",label:"Central European Time (CET)"},{value:"Asia/Tokyo",label:"Japan Standard Time (JST)"},{value:"Asia/Shanghai",label:"China Standard Time (CST)"},{value:"Australia/Sydney",label:"Australian Eastern Time (AET)"}];return s.some(s=>s.value===e)||s.unshift({value:e,label:"".concat(e," (Your timezone)")}),s})(),M=[{value:"1",label:"Monday",short:"Mon"},{value:"2",label:"Tuesday",short:"Tue"},{value:"3",label:"Wednesday",short:"Wed"},{value:"4",label:"Thursday",short:"Thu"},{value:"5",label:"Friday",short:"Fri"},{value:"6",label:"Saturday",short:"Sat"},{value:"0",label:"Sunday",short:"Sun"}],I=e=>{if(!e)return!1;let s=e.trim().split(/\s+/);if(5!==s.length)return!1;let[t,a]=s;if("*"===a&&("*"===t||t.startsWith("*/")))return!0;if(t.startsWith("*/")){let e=parseInt(t.slice(2),10);if(!isNaN(e)&&e<60)return!0}return!1},q=e=>{let{currentStep:s}=e,t=[{id:"setup",name:"Setup",icon:(0,a.jsx)(c.default,{className:"h-4 w-4"})},{id:"schedule",name:"Schedule",icon:(0,a.jsx)(d.default,{className:"h-4 w-4"})},{id:"execute",name:"Execute",icon:(0,a.jsx)(x.default,{className:"h-4 w-4"})}],i=t.findIndex(e=>e.id===s);return(0,a.jsx)("div",{className:"px-6 py-3 border-b bg-muted/30",children:(0,a.jsx)("div",{className:"flex items-center space-x-1",children:t.map((e,s)=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:(0,k.cn)("flex items-center justify-center w-6 h-6 rounded-full text-xs font-medium",s<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:s<i?(0,a.jsx)(h.default,{className:"h-3 w-3"}):(0,a.jsx)("span",{children:s+1})}),(0,a.jsx)("span",{className:(0,k.cn)("text-sm font-medium",s<=i?"text-foreground":"text-muted-foreground"),children:e.name})]}),s<t.length-1&&(0,a.jsx)(g.default,{className:"h-4 w-4 text-muted-foreground mx-2"})]},e.id))})})},F=Array.from({length:31},(e,s)=>({value:(s+1).toString(),label:(s+1).toString()})),P=e=>{let{config:s,onChange:t,errors:m,agentId:h,name:P,description:z,onNameChange:L,onDescriptionChange:V,isActive:O,onActiveChange:U,selectedAgent:J,onAgentSelect:D,open:K,onOpenChange:W,onSave:$,isEditMode:Q=!1}=e,[R,B]=(0,r.useState)("setup"),[H,G]=(0,r.useState)(""),[Y,Z]=(0,r.useState)(s.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone),[X,ee]=(0,r.useState)("daily"),[es,et]=(0,r.useState)("9"),[ea,er]=(0,r.useState)("0"),[ei,en]=(0,r.useState)(["1","2","3","4","5"]),[el,eo]=(0,r.useState)(["1"]),[ed,ec]=(0,r.useState)(void 0),[em,eu]=(0,r.useState)("9"),[ex,eh]=(0,r.useState)("0");(0,r.useEffect)(()=>{let e=[...E,...T].find(e=>e.cron===s.cron_expression);G((null==e?void 0:e.id)||"")},[s.cron_expression]),(0,r.useEffect)(()=>{!H&&ed&&ev()},[ed,em,ex]),(0,r.useEffect)(()=>{H||s.cron_expression||ef()},[]);let eg=e=>{Z(e),t({...s,timezone:e})},ep=()=>{let e=ea||"0",s=es||"9";switch(X){case"daily":default:return"".concat(e," ").concat(s," * * *");case"weekly":let t=ei.length>0?ei.join(","):"1";return"".concat(e," ").concat(s," * * ").concat(t);case"monthly":let a=el.length>0?el.join(","):"1";return"".concat(e," ").concat(s," ").concat(a," * *")}},ef=()=>{let e=ep();t({...s,cron_expression:e,timezone:Y}),e!==s.cron_expression&&G("")},ej=()=>
1{if(!ed)return"";let e=ed.getDate(),s=ed.getMonth()+1;return"".concat(ex," ").concat(em," ").concat(e," ").concat(s," *")},ev=()=>{let e=ej();t({...s,cron_expression:e,timezone:Y}),G("")};return(0,a.jsx)(b.lG,{open:K,onOpenChange:W,children:(0,a.jsxs)(b.Cf,{className:"max-w-4xl max-h-[90vh] p-0 overflow-hidden",children:[(0,a.jsx)(w.s6,{children:(0,a.jsx)(b.L3,{children:Q?"Edit Scheduled Task":"Create Scheduled Task"})}),(()=>{var e,r;return(0,a.jsxs)("div",{className:"flex flex-col h-full max-h-[90vh]",children:[(0,a.jsx)("div",{className:"shrink-0 px-6 py-4 border-b",children:(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)("h2",{className:"text-lg font-semibold",children:Q?"Edit Scheduled Task":"Create Scheduled Task"})})}),(0,a.jsx)(q,{currentStep:R}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:["setup"===R&&(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[(0,a.jsx)("div",{className:"p-6 border-b flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary/10",children:(0,a.jsx)(c.default,{className:"h-4 w-4 text-primary"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-semibold",children:"Task Setup"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure basic information for your automated task"})]})]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",style:{maxHeight:"calc(90vh - 200px)"},children:(0,a.jsxs)("div",{className:"max-w-2xl mx-auto space-y-6",children:[D&&(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Agent Selection"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose which agent will handle this task"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{children:"Agent"}),(0,a.jsx)(C.b,{selectedAgentId:J,onAgentSelect:D,placeholder:"Choose an agent to handle this task",showCreateOption:!0})]})]}),(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Task Details"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure basic information about your task"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{htmlFor:"task-name",children:"Task Name"}),(0,a.jsx)(i.p,{id:"task-name",value:P,onChange:e=>L(e.target.value),placeholder:"e.g., Daily report generation",className:(0,k.cn)(m.name&&"border-destructive")}
1),m.name&&(0,a.jsx)("p",{className:"text-sm text-destructive",children:m.name})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{htmlFor:"task-description",children:"Description (Optional)"}),(0,a.jsx)(l.T,{id:"task-description",value:z,onChange:e=>V(e.target.value),placeholder:"Brief description of what this task does",rows:2})]})]})]}),(0,a.jsx)("div",{className:"bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-blue-100 dark:bg-blue-900/30 mt-0.5",children:(0,a.jsx)(p.default,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h4",{className:"font-medium text-sm text-blue-900 dark:text-blue-100 mb-1",children:"Pro Tip"}),(0,a.jsx)("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Choose a descriptive name that clearly explains what this task will do. This helps you identify and manage your tasks later."})]})]})})]})}),(0,a.jsx)("div",{className:"shrink-0 border-t p-4 bg-background",children:(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsxs)(o.$,{onClick:()=>B("schedule"),disabled:!P.trim()||D&&!J,size:"sm",children:["Next: Set Schedule & Timing",(0,a.jsx)(g.default,{className:"h-3 w-3 ml-2"})]})})})]}),"schedule"===R&&(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[(0,a.jsx)("div",{className:"p-6 border-b flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary/10",children:(0,a.jsx)(d.default,{className:"h-4 w-4 text-primary"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-semibold",children:"Schedule Configuration"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Set up when and how often this task should run"})]})]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",style:{maxHeight:"calc(90vh - 200px)"},children:(0,a.jsxs)("div",{className:"max-w-2xl mx-auto space-y-6",children:[(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Schedule Frequency"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose how often this task should run"})]}),(0,a.jsxs)(j.tU,{defaultValue:"quick",className:"w-full",children:[(0,a.jsxs)(j.j7,{className:"grid w-full grid-cols-4",children:[(0,a.jsx)(j.Xi,{value:"quick",children:"Quick"}),(0,a.jsx)(j.Xi,{value:"recurring",children:"Recurring"}),(0,a.jsx)(j.Xi,{value:"one-time",children:"One-time"}),(0,a.jsx)(j.Xi,{value:"advanced",children:"Advanced"})]}),(0,a.jsx)(j.av,{value:"quick",className:"space-y-3",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{className:"text-sm font-medium",children:"Choose a common schedule"}),(0,a.jsx)("div",{className:"max-h-64 overflow-y-auto pr-2 space-y-2",children:E.map(e=>(0,a.jsx)(o.$,{variant:H===e.id?"default":"outline",size:"sm",onClick:()=>(e=>{let a=[...E,...T].find(s=>s.id===e);a&&(G(e),t({...s,cron_expression:a.cron,timezone:Y}),P||L(a.name))})(e.id),className:"w-full justify-start h-12 p-3",children:(0,a.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:e.icon}),(0,a.jsxs)("div",{className:"flex-1 text-left min-w-0",children:[(0,a.jsx)("div",{className:"font-medium text-sm",children:e.name}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.description})]})]})},e.id))}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:'Can\'t find what you need? Try the "Recurring" tab for custom schedules.'})]})}),(0,a.jsx)(j.av,{value:"recurring",className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(n.J,{className:"text-sm font-medium",children:"Set up recurring schedule"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{className:"text-sm",children:"How often should this run?"}),(0,a.jsxs)(v.l6,{value:X,onValueChange:e=>{ee(e),"weekly"===e&&5===ei.length?en(["1"]):"monthly"===e&&1!==el.length&&eo(["1"]),setTimeout(()=>ef(),0)},children:[(0,a.jsx)(v.bq,{children:(0,a.jsx)(v.yv,{})}),(0,a.jsxs)(v.gC,{children:[(0,a.jsx)(v.eb,{value:"daily",children:"Every day"}),(0,a.jsx)(v.eb,{value:"weekly",children:"Specific days of the week"}),(0,a.jsx)(v.eb,{value:"monthly",children:"Specific days of the month"})]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{className:"text-sm",children:"What time should it run?"}),(0,a.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,a.jsxs)(v.l6,{value:es,onValueChange:e=>{et(e),setTimeout(()=>ef(),0)},children:[(0,a.jsx)(v.bq,{className:"w-20",children:(0,a.jsx)(v.yv,{})}),(0,a.jsx)(v.gC,{children:Array.from({length:24},(e,s)=>(0,a.jsx)(v.eb,{value:s.toString(),children:s.toString().padStart(2,"0")},s))})]}),(0,a.jsx)("span",{className:"text-muted-foreground",children:":"}),(0,a.jsxs)(v.l6,{value:ea,onValueChange:e=>{er(e),setTimeout(()=>ef(),0)},children:[(0,a.jsx)(v.bq,{className:"w-20",children:(0,a.jsx)(v.yv,{})}),(0,a.jsx)(v.gC,{children:["00","15","30","45"].map(e=>(0,a.jsx)(v.eb,{value:e,children:e},e))})]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground ml-2",children:["(",es.padStart(2,"0"),":",ea," - 24h format)"]})]})]}),"weekly"===X&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(n.J,{className:"text-sm",children:"Which days of the week?"}),(0,a.jsx)("div",{className:"flex gap-1 flex-wrap",children:M.map(e=>(0,a.jsx)(o.$,{variant:ei.includes(e.value)?"default":"outline",size:"sm",onClick:()=>(e=>{let s=ei.includes(e)?ei.filter(s=>s!==e):[...ei,e].sort();s.length>0&&(en(s),setTimeout(()=>ef(),0))})(e.value),className:"h-9 w-14 p-0 text-xs",children:e.short},e.value))}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Click to select/deselect days. Currently selected: ",ei.length," day",1!==ei.length?"s":""]})]}),"monthly"===X&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(n.J,{className:"text-sm",children:"Which days of the month?"}),(0,a.jsx)("div",{className:"grid grid-cols-7 gap-1 max-h-32 overflow-y-auto",children:F.map(e=>(0,a.jsx)(o.$,{variant:el.includes(e.value)?"default":"outline",size:"sm",onClick:()=>(e=>{let s=el.includes(e)?el.filter(s=>s!==e):[...el,e].sort((e,s)=>parseInt(e)-parseInt(s));s.length>0&&(eo(s),setTimeout(()=>ef(),0))})(e.value),className:"h-8 w-8 p-0 text-xs",children:e.label},e.value))}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Click to select/deselect days. Currently selected: ",el.length," day",1!==el.length?"s":""]})]}),(0,a.jsxs)("div",{className:"bg-muted/50 p-4 rounded-lg border",children:[(0,a.jsx)("div",{className:"font-medium text-sm mb-2",children:"Schedule Summary"}),(0,a.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,a.jsxs)("div",{className:"text-foreground",children:["daily"===X&&"Every day at ".concat(es.padStart(2,"0"),":").concat(ea),"weekly"===X&&ei.length>0&&"Every ".concat(M.filter(e=>ei.includes(e.value)).map(e=>e.label).join(", ")," at ").concat(es.padStart(2,"0"),":").concat(ea),"monthly"===X&&el.length>0&&"On day".concat(el.length>
11?"s":""," ").concat(el.join(", ")," of each month at ").concat(es.padStart(2,"0"),":").concat(ea)]}),(0,a.jsxs)("div",{className:"text-muted-foreground",children:[(0,a.jsx)("strong",{children:"Cron:"})," ",(0,a.jsx)("code",{className:"bg-background px-1 rounded font-mono text-xs",children:ep()})]})]})]})]})}),(0,a.jsx)(j.av,{value:"one-time",className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(n.J,{className:"text-sm font-medium",children:"Schedule for specific date and time"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{className:"text-xs",children:"Date"}),(0,a.jsxs)(N.AM,{children:[(0,a.jsx)(N.Wv,{asChild:!0,children:(0,a.jsxs)(o.$,{variant:"outline",className:(0,k.cn)("w-full justify-start text-left font-normal",!ed&&"text-muted-foreground"),children:[(0,a.jsx)(u.default,{className:"mr-2 h-4 w-4"}),ed?(0,_.GP)(ed,"PPP"):(0,a.jsx)("span",{children:"Pick a date"})]})}),(0,a.jsx)(N.hl,{className:"w-auto p-0",align:"start",children:(0,a.jsx)(y.V,{mode:"single",selected:ed,onSelect:ec,disabled:e=>e<new Date,initialFocus:!0})})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{className:"text-xs",children:"Time"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(v.l6,{value:em,onValueChange:eu,children:[(0,a.jsx)(v.bq,{className:"w-20",children:(0,a.jsx)(v.yv,{})}),(0,a.jsx)(v.gC,{children:Array.from({length:24},(e,s)=>(0,a.jsx)(v.eb,{value:s.toString(),children:s.toString().padStart(2,"0")},s))})]}),(0,a.jsx)("span",{className:"flex items-center",children:":"}),(0,a.jsxs)(v.l6,{value:ex,onValueChange:eh,children:[(0,a.jsx)(v.bq,{className:"w-20",children:(0,a.jsx)(v.yv,{})}),(0,a.jsx)(v.gC,{children:["00","15","30","45"].map(e=>(0,a.jsx)(v.eb,{value:e,children:e},e))})]})]})]}),ed&&(0,a.jsxs)("div",{className:"bg-muted/50 p-4 rounded-lg border",children:[(0,a.jsx)("div",{className:"font-medium text-sm mb-2",children:"Schedule Summary"}),(0,a.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,a.jsxs)("div",{className:"text-foreground",children:[(0,a.jsx)("strong",{children:"Scheduled for:"})," ",(0,_.GP)(ed,"PPP")," at ",em.padStart(2,"0"),":",ex]}),(0,a.jsxs)("div",{className:"text-muted-foreground",children:[(0,a.jsx)("strong",{children:"Cron:"})," ",(0,a.jsx)("code",{className:"bg-background px-1 rounded font-mono text-xs",children:ej()})]})]})]}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)("strong",{children:"Note:"})," This task will run once at the specified date and time, then be automatically disabled."]})]})}),(0,a.jsx)(j.av,{value:"advanced",className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(n.J,{className:"text-sm font-medium",children:"Custom Cron Expression"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"For advanced users who need precise control over scheduling"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(n.J,{htmlFor:"cron",children:"Cron Expression"}),(0,a.jsx)(i.p,{id:"cron",value:s.cron_expression||"",onChange:e=>t({...s,cron_expression:e.target.value}),placeholder:"0 9 * * 1-5",className:(0,k.cn)("font-mono",I(s.cron_expression||"")&&"border-destructive")}
1),I(s.cron_expression||"")&&(0,a.jsx)("p",{className:"text-sm text-destructive",children:"Schedules that run more frequently than once per hour are not allowed. Minimum interval is 1 hour."})]}),(0,a.jsxs)("div",{className:"bg-muted/50 p-4 rounded-lg border",children:[(0,a.jsx)("div",{className:"font-medium text-sm mb-2",children:"Cron Format"}),(0,a.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,a.jsx)("div",{className:"font-mono text-xs bg-background p-2 rounded border",children:"Format: minute hour day month weekday"}),(0,a.jsxs)("div",{className:"text-muted-foreground",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Example:"})," ",(0,a.jsx)("code",{className:"bg-background px-1 rounded",children:"0 9 * * 1-5"})," = Weekdays at 9 AM"]}),(0,a.jsxs)("div",{className:"mt-1",children:["Use ",(0,a.jsx)("code",{className:"bg-background px-1 rounded",children:"*"})," for any value,",(0,a.jsx)("code",{className:"bg-background px-1 rounded",children:"*/5"})," for every 5 units"]})]}),(0,a.jsxs)("div",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:["Note: Minimum interval is 1 hour. Schedules like ",(0,a.jsx)("code",{className:"bg-background px-1 rounded",children:"*/5 * * * *"})," are not allowed."]})]})]})]})})]}),m.cron_expression&&(0,a.jsx)("p",{className:"text-sm text-destructive",children:m.cron_expression})]}),(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Timezone"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose the timezone for your schedule"})]}),(0,a.jsxs)(v.l6,{value:Y,onValueChange:eg,children:[(0,a.jsx)(v.bq,{children:(0,a.jsx)(v.yv,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(f.default,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:(null==(e=A.find(e=>e.value===Y))?void 0:e.label)||Y})]})})}),(0,a.jsx)(v.gC,{children:A.map(e=>(0,a.jsx)(v.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,a.jsx)("div",{className:"bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-amber-100 dark:bg-amber-900/30 mt-0.5",children:(0,a.jsx)(d.default,{className:"h-3 w-3 text-amber-600 dark:text-amber-400"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h4",{className:"font-medium text-sm text-amber-900 dark:text-amber-100 mb-1",children:"Timezone Matters"}),(0,a.jsx)("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:"Your schedule will run according to the timezone you select. Make sure it matches your location or preferred time zone."})]})]})})]})}),(0,a.jsx)("div",{className:"shrink-0 border-t p-4 bg-background",children:(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)(o.$,{variant:"outline",onClick:()=>B("setup"),size:"sm",children:[(0,a.jsx)(g.default,{className:"h-3 w-3 mr-2 rotate-180"}),"Back to Setup"]}),(0,a.jsxs)(o.$,{onClick:()=>B("execute"),disabled:!s.cron_expression&&!H||I(s.cron_expression||""),size:"sm",children:["Next: Choose Execution Method",(0,a.jsx)(g.default,{className:"h-3 w-3 ml-2"})]})]})})]}),"execute"===R&&(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[(0,a.jsx)("div",{className:"p-6 border-b",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary/10",children:(0,a.jsx)(x.default,{className:"h-4 w-4 text-primary"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-semibold",children:"Execution Configuration"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure how your task should be executed"})]})]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",style:{maxHeight:"calc(90vh - 200px)"},children:(0,a.jsxs)("div",{className:"max-w-2xl mx-auto space-y-6",children:[(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Execution Method"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose how your task should be executed"})]}),(0,a.jsx)("div",{className:"p-3 border rounded-lg bg-muted/30",children:(0,a.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,a.jsx)("div",{className:"p-1.5 rounded-lg bg-primary/10",children:(0,a.jsx)(x.default,{className:"h-4 w-4 text-primary"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)(n.J,{className:"font-medium",children:"Agent Instructions"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Provide instructions for your agent to execute"})]})]})})]}),(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Agent Instructions"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Provide specific instructions for your agent"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(l.T,{value:s.agent_prompt||"",onChange:e=>{var a;return a=e.target.value,void t({...s,agent_prompt:a})},placeholder:"Enter prompt here. Be specific about what you want your agent to do when this task runs.",rows:4,className:(0,k.cn)(m.agent_prompt&&"border-destructive")}
1),m.agent_prompt&&(0,a.jsx)("p",{className:"text-sm text-destructive",children:m.agent_prompt}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Use ",(0,a.jsx)("code",{className:"text-xs bg-muted px-1 rounded",children:"{{variable_name}}"})," to add variables to the prompt"]})]})]}),(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium mb-1",children:"Model"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose which model to use for this scheduled task"})]}),(0,a.jsx)(S.e,{value:s.model||"workally/basic",onChange:e=>t({...s,model:e})})]})]})}),(0,a.jsx)("div",{className:"shrink-0 border-t p-4 bg-background",children:(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)(o.$,{variant:"outline",onClick:()=>B("schedule"),size:"sm",children:[(0,a.jsx)(g.default,{className:"h-3 w-3 mr-2 rotate-180"}),"Back to Schedule"]}),(0,a.jsxs)(o.$,{onClick:()=>{$&&$({name:P,description:z,config:{...s},is_active:O})},disabled:!(null==(r=s.agent_prompt)?void 0:r.trim()),size:"sm",children:[Q?"Update Scheduled Task":"Create Scheduled Task",(0,a.jsx)(x.default,{className:"h-3 w-3 ml-2"})]})]})})]})]})})]})})()]})})}},78567:(e,s,t)=>{t.d(s,{X:()=>a,g:()=>r});let a={all:["threads"],lists:()=>["threads","list"],details:e=>["thread",e],messages:e=>["thread",e,"messages"],project:e=>["project",e],projects:()=>["projects","list"],publicProjects:()=>["public-projects"],agentRuns:e=>["thread",e,"agent-runs"],byProject:e=>["project",e,"threads"]},r={all:["projects"],lists:()=>["projects","list"],details:e=>["projects","detail",e],public:()=>["projects","public"]}},85551:(e,s,t)=>{t.d(s,{Y:()=>j});var a=t(95155),r=t(12115),i=t(51834),n=t(3998),l=t(26983),o=t(62345),d=t(52987),c=t(31974),m=t(75910),u=t(33089),x=t(18720),h=t(98461),g=t(12054),p=t(40255),f=t(18955);function j(e){let{open:s,onOpenChange:t,type:j,onTriggerCreated:v,isEditMode:y=!1,existingTrigger:N,onTriggerUpdated:b,agentId:w}=e,[_,k]=(0,r.useState)(w||""),[C,S]=(0,r.useState)(w?"config":"agent"),[E,T]=(0,r.useState)(""),[A,M]=(0,r.useState)(""),[I,q]=(0,r.useState)({cron_expression:""}),F=(0,u.A$)(),P=(0,u.vg)(),z=(0,p.s)(),L=(0,f.c)("billing");r.useEffect(()=>{s&&(y&&N?(k(N.agent_id||w||""),T(N.name||""),M(N.description||""),q(N.config||{cron_expression:""}),S("config")):w?(k(w),S("config")):S("agent"))},[y,N,s,w]);let V=async e=>{if(!_)return void x.toast.error("Please select an agent");try{if(y&&N)await P.mutateAsync({triggerId:N.trigger_id,name:e.name||"Scheduled Trigger",description:e.description||"Automatically scheduled trigger",config:e.config,is_active:e.is_active}),x.toast.success("Schedule trigger updated successfully"),b&&N.trigger_id&&b(N.trigger_id);else{let s=await F.mutateAsync({agentId:_,provider_id:"schedule",name:e.name||"Scheduled Trigger",description:e.description||"Automatically scheduled trigger",config:e.config});x.toast.success("Schedule trigger created successfully"),v&&(null==s?void 0:s.trigger_id)&&v(s.trigger_id)}O()}catch(e){if(e instanceof g.YX){z.openPricingModal({isAlert:!0,alertTitle:"".concat(L("reachedLimit")," ").concat(L("triggerLimit",{current:e.detail.current_count,limit:e.detail.limit}))}),O();return}x.toast.error(e.message||"Failed to ".concat(y?"update":"create"," schedule trigger"))}},O=()=>{w?(k(w),S("config")):(k(""),S("agent")),t(!1)};return s?"agent"===C?(0,a.jsx)(i.lG,{open:s,onOpenChange:O,children:(0,a.jsxs)(i.Cf,{className:"sm:max-w-md",children:[(0,a.jsxs)(i.c7,{children:[(0,a.jsx)(i.L3,{className:"flex items-center gap-2",children:"schedule"===j?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.default,{className:"h-5 w-5"}),y?"Edit Scheduled Task":"Create Scheduled Task"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.default,{className:"h-5 w-5"}),y?"Edit App-based Task":"Create App-based Task"]})}),(0,a.jsx)(i.rr,{children:y?"Update the agent for this task":"First, select which agent should handle this task"})]}),(0,a.jsx)("div",{className:"space-y-4 py-4",children:(0,a.jsx)(h.b,{selectedAgentId:_,onAgentSelect:k,placeholder:"Choose an agent"})}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)(n.$,{variant:"outline",onClick:O,children:"Cancel"}),(0,a.jsxs)(n.$,{onClick:()=>{S("config")},disabled:!_,children:["Next",(0,a.jsx)(d.default,{className:"h-4 w-4 ml-2"})]})]})]})}):"schedule"===j?(0,a.jsx)(m.u,{provider:{provider_id:"schedule",name:"Schedule",trigger_type:"schedule",webhook_enabled:!0,config_schema:{}},config:I,onChange:q,errors:{},agentId:_,name:E,description:A,onNameChange:T,onDescriptionChange:M,isActive:!0,onActiveChange:()=>{},selectedAgent:_,onAgentSelect:k,open:s,onOpenChange:t,onSave:V,isEditMode:y}):(0,a.jsx)(c.i,{open:s,onOpenChange:O,agentId:_,onTriggerCreated:v,isEditMode:y,existingTrigger:N,onTriggerUpdated:b}):null}},93184:(e,s,t)=>{t.d(s,{fy:()=>m,xE:()=>f});var a=t(12115),r=t(20063),i=t(4192),n=t(97503),l=t(25959),o=t(89863);let d=(0,l.v)()((0,o.lt)((0,o.Zr)((e,s)=>({currentVersion:null,compareVersion:null,versions:[],isViewingVersion:!1,isComparingVersions:!1,hasUnsavedChanges:!1,isLoading:!1,error:null,setCurrentVersion:s=>e({currentVersion:s,isViewingVersion:null!==s}),setCompareVersion:s=>e({compareVersion:s,isComparingVersions:null!==s}),setVersions:s=>e({versions:s}),setIsViewingVersion:s=>e({isViewingVersion:s}),setIsComparingVersions:t=>e({isComparingVersions:t,compareVersion:t?s().compareVersion:null}),setHasUnsavedChanges:s=>e({hasUnsavedChanges:s}),setIsLoading:s=>e({isLoading:s}),setError:s=>e({error:s}),clearVersionState:()=>e({currentVersion:null,compareVersion:null,versions:[],isViewingVersion:!1,isComparingVersions:!1,hasUnsavedChanges:!1,isLoading:!1,error:null}),isViewingOldVersion:e=>{let t=s();return t.isViewingVersion&&null!==t.currentVersion&&t.currentVersion.version_id!==e}}),{name:"agent-version-store",partialize:e=>({hasUnsavedChanges:e.hasUnsavedChanges})}),{name:"agent-version-store"}));function c(e){return e&&Array.isArray(e)?e.map(e=>e&&"object"==typeof e?{name:e.name||"Unnamed MCP",type:e.type||e.customType||"sse",customType:e.customType||e.type||"sse",config:e.config||{},enabledTools:e.enabledTools||e.enabled_tools||[]}:{name:"Unknown MCP",type:"sse",customType:"sse",config:{},enabledTools:[]}):[]}function m(e){let{agentId:s}=e,t=(0,r.useSearchParams)().get("version"),{data:l,isLoading:o,error:m}=(0,i.fJ)(s),u=t||(null==l?void 0:l.current_version_id),x=t||(null==l?void 0:l.current_version_id)||"",{data:h,isLoading:g,error:p}=(0,n.Jh)(s,u?x:null),{setCurrentVersion:f,clearVersionState:j}=d(),v=(0,a.useMemo)(()=>{var e,s,t,a,r,i,n;return h?"version_id"in h?{version_id:h.version_id,agent_id:h.agent_id,version_number:h.version_number,version_name:h.version_name,system_prompt:h.system_prompt||"",model:h.model,configured_m
1cps:Array.isArray(h.configured_mcps)?h.configured_mcps:[],custom_mcps:c(h.custom_mcps),agentpress_tools:h.agentpress_tools&&"object"==typeof h.agentpress_tools?h.agentpress_tools:{},is_active:null==(e=h.is_active)||e,created_at:h.created_at,updated_at:h.updated_at||h.created_at,created_by:h.created_by,change_description:h.change_description}:{version_id:(null==(s=h.versionId)?void 0:s.value)||h.versionId,agent_id:(null==(t=h.agentId)?void 0:t.value)||h.agentId,version_number:(null==(a=h.versionNumber)?void 0:a.value)||h.versionNumber,version_name:h.versionName,system_prompt:h.systemPrompt||"",model:h.model,configured_mcps:Array.isArray(h.configuredMcps)?h.configuredMcps:[],custom_mcps:c(h.customMcps),agentpress_tools:h.agentpress_tools||(null==(r=h.toolConfiguration)?void 0:r.tools)||{},is_active:null==(n=h.isActive)||n,created_at:h.createdAt instanceof Date?h.createdAt.toISOString():h.createdAt,updated_at:(h.updatedAt instanceof Date?h.updatedAt.toISOString():h.updatedAt)||h.created_at,created_by:(null==(i=h.createdBy)?void 0:i.value)||h.createdBy,change_description:h.changeDescription}:null},[h]),y=(0,a.useMemo)(()=>!!(t&&t!==(null==l?void 0:l.current_version_id)),[t,null==l?void 0:l.current_version_id]);return(0,a.useEffect)(()=>(v?f({version_id:v.version_id,agent_id:v.agent_id,version_number:v.version_number,version_name:v.version_name,system_prompt:v.system_prompt,model:v.model,configured_mcps:v.configured_mcps,custom_mcps:v.custom_mcps,agentpress_tools:v.agentpress_tools,is_active:v.is_active,created_at:v.created_at,updated_at:v.updated_at,created_by:v.created_by,change_description:v.change_description}):t||j(),()=>{j()}),[v,t,f,j]),{agent:l,versionData:v,isViewingOldVersion:y,isLoading:o||!!u&&g,error:m||p}}var u=t(34520),x=t(78807),h=t(19016);let g=e=>!!e&&"free"!==e&&"none"!==e,p=[{id:"workally/basic",label:"Ally 1.5 Lite",requiresSubscription:!1,priority:100,recommended:!0,capabilities:["general","coding","analysis"],contextWindow:128e3},{id:"workally/power",label:"Opus 4.5",requiresSubscription:!0,priority:90,recommended:!1,capabilities:["general","coding","analysis","advanced"],contextWindow:2e5},{id:"openai/gpt-5.2",label:"GPT-5.2",requiresSubscription:!0,priority:80,recommended:!1,capabilities:["general","coding","analysis"],contextWindow:128e3},{id:"google/gemini-3-pro",label:"Gemini 3 Pro",requiresSubscription:!0,priority:70,recommended:!1,capabilities:["general","coding","analysis"],contextWindow:1e6}],f=()=>{let{user:e,isLoading:s}=(0,h.A)(),{data:t,isLoading:r}=(0,x.u4)({enabled:!!e&&!s}),{selectedModel:i,setSelectedModel:n}=(0,u.g)(),l=(0,a.useRef)(null),o=(0,a.useMemo)(()=>g(null==t?void 0:t.subscription.tier_key),[null==t?void 0:t.subscription.tier_key]),d=(0,a.useMemo)(()=>e||s?(null==t?void 0:t.models)?t.models.map(e=>({id:e.id,label:e.name,requiresSubscription:!e.allowed,priority:e.priority||0,recommended:e.recommended||!1,capabilities:e.capabilities||[],contextWindow:e.context_window||128e3})).sort((e,s)=>e.requiresSubscription!==s.requiresSubscription?e.requiresSubscription?1:-1:e.priority!==s.priority?s.priority-e.priority:e.label.localeCompare(s.label)):[]:p,[null==t?void 0:t.models,e,s]),c=(0,a.useMemo)(()=>d.filter(e=>!e.requiresSubscription),[d]);(0,a.useEffect)(()=>{if(!r&&c.length&&(!i||!c.some(e=>e.id===i))){let e=(e=>{let s=e.find(e=>"workally/basic"===e.id||"kortix/basic"===e.id);if(s)return s.id;let t=e.find(e=>"workally/power"===e.id||"kortix/power"===e.id);return t?t.id:e.length>0?e[0].id:""})(c);e&&e!==i&&n(e)}},[i,c,r,n,null==t?void 0:t.subscription.tier_key]),(0,a.useEffect)(()=>{if(r||!d.length)return;let e=null==t?void 0:t.subscription.tier_key,s="free"===l.current||"none"===l.current,a=g(e);if(s&&a&&null!==l.current){let e=d.find(e=>("workally/power"===e.id||"kortix/power"===e.id)&&!e.requiresSubscription);e&&n(e.id)}l.current=e||null},[null==t?void 0:t.subscription.tier_key,d,r,n]);let m=(0,a.useCallback)(e=>{c.find(s=>s.id===e)&&n(e)},[c,n]),f=(0,a.useCallback)(e=>{let s=d.find(s=>s.id===e);return!!s&&!s.requiresSubscription},[d]),j=(0,a.useCallback)(e=>{let s=d.find(s=>s.id===e);return(null==s?void 0:s.requiresSubscription)||!1},[d]),v=(0,a.useCallback)(e=>e,[]),y=(0,a.useCallback)(()=>{},[]),N=(0,a.useCallback)(e=>{},[]),b=(0,a.useCallback)((e,s)=>{},[]),w=(0,a.useCallback)(e=>{},[]);return{selectedModel:i,setSelectedModel:m,availableModels:c,allModels:d,isLoading:r,modelsData:t?{models:t.models,tier:t.subscription.tier_key}:void 0,subscriptionStatus:o?"active":"no_subscription",canAccessModel:f,isSubscriptionRequired:j,handleModelChange:m,customModels:[],addCustomModel:N,updateCustomModel:b,removeCustomModel:w,getActualModelId:v,refreshCustomModels:y}};t(54262)},97503:(e,s,t)=>{t.d(s,{Ic:()=>u,J$:()=>x,Jh:()=>c,aA:()=>d,bW:()=>m});var a=t(53455),r=t(99776),i=t(80549),n=t(18720),l=t(45440),o=t(44561);let d=(e,s)=>(0,a.I)({queryKey:l.R.list(e),queryFn:()=>(0,o.TD)(e).then(e=>e.sort((e,s)=>s.version_number-e.version_number)),enabled:!!e,staleTime:3e4,refetchOnMount:"always",refetchOnWindowFocus:!0,...s}),c=(e,s,t)=>(0,a.I)({queryKey:l.R.detail(e,s),queryFn:()=>(0,o.c9)(e,s),enabled:!!e&&!!s,staleTime:3e4,refetchOnMount:"always",refetchOnWindowFocus:!0,...t}),m=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:async e=>{let{agentId:s,data:t}=e;return(0,o.q5)(s,t)},onSuccess:(s,t)=>{let{agentId:a}=t;
1e.invalidateQueries({queryKey:l.R.list(a)}),e.invalidateQueries({queryKey:["agents","detail",a]}),(null==s?void 0:s.version_id)&&e.invalidateQueries({queryKey:l.R.detail(a,s.version_id)})},onError:e=>{n.toast.error(e.message||"Failed to create version")}})},u=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:async e=>{let{agentId:s,versionId:t}=e;return(0,o.bO)(s,t)},onSuccess:(s,t)=>{let{agentId:a}=t;e.invalidateQueries({queryKey:l.R.list(a)}),e.invalidateQueries({queryKey:["agents","detail",a]}),e.invalidateQueries({queryKey:["agents"]}),n.toast.success("Version activated successfully")},onError:e=>{n.toast.error(e.message||"Failed to activate version")}})},x=()=>{let e=(0,r.jE)();return(0,i.n)({mutationFn:async e=>{let{agentId:s,versionId:t,data:a}=e;return(0,o.$4)(s,t,a)},onSuccess:(s,t)=>{let{agentId:a,versionId:r}=t;e.invalidateQueries({queryKey:l.R.list(a)}),e.invalidateQueries({queryKey:l.R.detail(a,r)}),e.invalidateQueries({queryKey:["agents","detail",a]}),e.invalidateQueries({queryKey:["agents"]}),n.toast.success("Version details updated successfully")},onError:e=>{n.toast.error(e.message||"Failed to update version details")}})}},98115:(e,s,t)=>{t.d(s,{N:()=>i});var a=t(53455),r=t(80344);let i=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;return(0,a.I)({queryKey:["trigger-executions",e,s],queryFn:async()=>(await r.H.get("/triggers/".concat(e,"/executions?limit=").concat(s))).data,enabled:!!e,refetchInterval:3e4,staleTime:15e3})}},98461:(e,s,t)=>{t.d(s,{b:()=>f});var a=t(95155),r=t(12115),i=t(24033),n=t(86651),l=t(5917),o=t(35299),d=t(6191),c=t(3998),m=t(6259),u=t(4192),x=t(72628),h=t(64269),g=t(90597),p=t(20243);let f=e=>{let{selectedAgentId:s,onAgentSelect:t,placeholder:f="Choose a Worker",className:j,disabled:v=!1,showCreateOption:y=!0,variant:N="default"}=e,[b,w]=(0,r.useState)(!1),[_,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(""),[E,T]=(0,r.useState)(1),[A,M]=(0,r.useState)([]),[I,q]=(0,r.useState)(!1),F=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=setTimeout(()=>{S(_),T(1)},300);return()=>clearTimeout(e)},[_]);let P=(0,r.useMemo)(()=>({page:E,limit:50,search:C||void 0}),[E,C]),{data:z,isLoading:L,isFetching:V}=(0,u._F)(P);(0,r.useEffect)(()=>{(null==z?void 0:z.agents)&&(1===E||C?M(z.agents):M(e=>[...e,...z.agents]))},[z,E,C]);let O=(0,r.useMemo)(()=>!!(null==z?void 0:z.pagination)&&z.pagination.current_page<z.pagination.total_pages,[null==z?void 0:z.pagination]),U=(0,r.useCallback)(()=>{O&&!V&&T(e=>e+1)},[O,V]),J=(0,r.useMemo)(()=>{let e=[...A];if(!s)return e;let t=e.findIndex(e=>e.agent_id===s);if(t>0){let[s]=e.splice(t,1);e.unshift(s)}return e},[A,s]);(0,r.useEffect)(()=>{b?setTimeout(()=>{var e;return null==(e=F.current)?void 0:e.focus()},50):(k(""),S(""),T(1))},[b]);let D=A.find(e=>e.agent_id===s);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(m.rI,{open:b,onOpenChange:w,children:[(0,a.jsx)(m.ty,{asChild:!0,children:(0,a.jsx)(c.$,{variant:"outline",className:(0,h.cn)("w-full justify-start h-10 px-3 py-2 border-input bg-background hover:bg-accent hover:text-accent-foreground",!D&&"text-muted-foreground",j),disabled:v,children:D?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,a.jsx)(g.lx,{agentId:D.agent_id,size:24,className:"flex-shrink-0",fallbackName:D.name}),(0,a.jsx)("span",{className:"truncate font-medium",children:D.name})]}),(0,a.jsx)(i.default,{size:12,className:"opacity-60 flex-shrink-0 ml-auto"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground flex-1",children:f}),(0,a.jsx)(i.default,{size:12,className:"opacity-60 flex-shrink-0"})]})})}),(0,a.jsxs)(m.SQ,{className:"w-80 p-0",align:"start",sideOffset:4,children:[(0,a.jsx)("div",{className:"p-3 pb-2",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(n.default,{className:"absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsx)("input",{ref:F,type:"text",placeholder:"Search agents...",value:_,onChange:e=>k(e.target.value),className:"w-full pl-9 pr-3 py-2 text-sm bg-muted/40 border-0 rounded-lg focus:outline-none focus:ring-1 focus:ring-ring focus:bg-muted/60 placeholder:text-muted-foreground
1/60"})]})}),(0,a.jsx)("div",{className:"max-h-64 overflow-y-auto px-1",children:L?(0,a.jsx)("div",{className:"px-3 py-2 space-y-2",children:[1,2,3].map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(p.Skeleton,{className:"h-5 w-5 rounded-full"}),(0,a.jsx)(p.Skeleton,{className:"h-4 flex-1"})]},e))}):0===J.length?(0,a.jsxs)("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:[(0,a.jsx)(n.default,{className:"h-6 w-6 mx-auto mb-2 opacity-40"}),(0,a.jsx)("p",{children:"No agents found"}),_&&(0,a.jsx)("p",{className:"text-xs mt-1 opacity-60",children:"Try adjusting your search"})]}):(0,a.jsx)("div",{className:"space-y-0.5 py-1",children:J.map(e=>(0,a.jsxs)(m._2,{className:"flex items-center gap-3 px-3 py-2.5 mx-1 rounded-lg cursor-pointer",onClick:()=>{t(e.agent_id),w(!1)},children:[(0,a.jsx)(g.lx,{agentId:e.agent_id,size:24,className:"flex-shrink-0",fallbackName:e.name}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"font-medium text-sm truncate",children:e.name}),e.description&&(0,a.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.description})]}),s===e.agent_id&&(0,a.jsx)(l.default,{className:"h-4 w-4 text-blue-500 flex-shrink-0"})]},e.agent_id))})}),O&&(0,a.jsx)("div",{className:"px-1.5 pb-1",children:(0,a.jsx)(c.$,{size:"sm",variant:"ghost",className:"w-full h-8 text-xs text-muted-foreground hover:text-foreground",onClick:U,disabled:V,children:V?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.default,{className:"h-3 w-3 animate-spin mr-1"}),"Loading..."]}):"Load More"})}),y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.mB,{}),(0,a.jsx)("div",{className:"p-1",children:(0,a.jsxs)(m._2,{className:"flex items-center gap-3 px-3 py-2.5 mx-0 rounded-lg cursor-pointer text-muted-foreground hover:text-foreground",onClick:()=>{w(!1),q(!0)},children:[(0,a.jsx)(d.default,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"font-medium",children:"Create new agent"})]})})]})]})]}),(0,a.jsx)(x.G,{open:I,onOpenChange:q,onSuccess:e=>{e&&t(e)}})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.