@oxgeneral/orch 1.0.11 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ import {b,a as a$2}from'./chunk-HWEMBO36.js';import {a}from'./chunk-N4OXN2HW.js';import {c,a as a$1}from'./chunk-HXOMNULD.js';import {f,h,g}from'./chunk-64WUDYEM.js';import {m}from'./chunk-IKNBPOQL.js';import ao,{useState,useMemo,useEffect,useRef,useCallback}from'react';import {Box,Text,useInput,useApp,useStdout}from'ink';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var e={amber:"#ffaf00",amberDim:"#af8700",green:"#5faf87",red:"#d75f5f",blue:"#5fafd7",yellow:"#d7af00",cyan:"#5fd7d7",purple:"#af87ff",white:"#eeeeee",silver:"#bcbcbc",gray:"#808080",dim:"#585858",ghost:"#3a3a3a",void:"#262626",errorBg:"#3d1515",warnBg:"#3d2e0a",successBg:"#0f2d1f",infoBg:"#1a1a22",toolBg:"#0f1f2d"},_o="\u2501",Ve="\u2500",fe="\xB7",Zt="\u25C8",Ir="\u2605",gn="\u27F3",Ht="\u25C6",Ao={in_progress:e.green,retrying:e.yellow,review:e.blue,todo:e.dim,done:e.green,failed:e.red,cancelled:e.dim},Ms=new Map,vs=new Map;function He(t){if(t<=0)return "";let n=Ms.get(t);return n||(n=_o.repeat(t),Ms.set(t,n)),n}function Te(t){if(t<=0)return "";let n=vs.get(t);return n||(n=Ve.repeat(t),vs.set(t,n)),n}function rt(t,n){return t.length>n?t.slice(0,n-1)+"\u2026":t}var Ja=1e4;function Mr(t,n=Ja){if(t)return t.length>n?t.slice(0,n)+`
3
+ \u2026[truncated]`:t}var Rs={active:e.green,paused:e.dim,achieved:e.amber,abandoned:e.ghost};var tl=120,vr=0,oo=null,$o=new Set;function nl(){oo||(oo=setInterval(()=>{vr++;for(let t of $o)t(vr);},tl));}function ol(){oo&&$o.size===0&&(clearInterval(oo),oo=null);}function mn(){let[t,n]=useState(vr);return useEffect(()=>{let o=r=>n(r);return $o.add(o),nl(),()=>{$o.delete(o),ol();}},[]),t}var _s=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function En({color:t}){let n=mn();return jsx(Text,{color:t,children:_s[n%_s.length]})}var ro={in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6};var al="\u25CB",$s="\u2713",Bs="\u2715",ll="\u21BB",cl="\u2500",dl="\u25B6",Pt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},ul={in_progress:{icon:dl,label:"RUN",fg:e.green,bg:Pt.green,bold:true,spinner:true},retrying:{icon:ll,label:"RETRY",fg:e.yellow,bg:Pt.yellow,spinner:true},review:{icon:Zt,label:"REVIEW",fg:e.blue,bg:Pt.blue},todo:{icon:al,label:"TODO",fg:e.dim,bg:Pt.neutral},done:{icon:$s,label:"DONE",fg:e.green,bg:Pt.green},failed:{icon:Bs,label:"FAIL",fg:e.red,bg:Pt.red,bold:true},cancelled:{icon:cl,label:"OFF",fg:e.dim,bg:Pt.neutral}},gl={1:{color:e.red,label:"!!!"},2:{color:e.yellow,label:"!!"},3:{color:e.dim,label:"!"},4:{color:e.ghost,label:fe}};var fl=18,pl="#2d1f0a",Bo=ao.memo(function({task:n,selected:o,width:r,agentNameMap:l,goalMap:f$1}){let b=ul[n.status],T=n.status==="in_progress"||n.status==="retrying",x=gl[n.priority]??{color:e.ghost,label:fe},y,C;if(n.status==="done")y=$s,C=e.green;else if(n.status==="failed")y=Bs,C=e.red;else if(T){let E=Date.now()-new Date(n.updated_at).getTime();y=f(E),C=e.cyan;}else y="\u2014",C=void 0;let M=o?"\u25B8":" ",A=n.goalId?f$1?.get(n.goalId):void 0,S=!!A,H=10,V=4,F=14,P=S?fl:0,j=7,O=2+H+V+F+P+j,L=r?Math.max(10,r-O):40,N=n.assignee?l?.get(n.assignee)??n.assignee:void 0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[M," "]}),jsx(Box,{width:H,children:jsx(Text,{backgroundColor:b.bg,color:b.fg,bold:b.bold,children:b.spinner?jsxs(Fragment,{children:[" ",jsx(En,{color:b.fg})," ",b.label," "]}):jsxs(Fragment,{children:[" ",b.icon," ",b.label," "]})})}),jsx(Box,{width:V,children:jsx(Text,{color:x.color,bold:n.priority<=2,children:x.label})}),jsxs(Box,{width:L,children:[jsx(Text,{wrap:"truncate",bold:o||T,color:o?e.white:T?e.silver:void 0,children:n.title.length>L?n.title.slice(0,L-1)+"\u2026":n.title}),(n.attachments?.length??0)>0&&jsxs(Text,{color:e.dim,children:[" ","\u{1F4CE}",n.attachments.length]})]}),S&&jsx(Box,{width:P,children:jsxs(Text,{backgroundColor:pl,color:e.amberDim,wrap:"truncate",children:[" \u2295 ",rt(A.title,13)," "]})}),jsx(Box,{width:F,children:N?jsxs(Text,{backgroundColor:Pt.green,color:e.green,wrap:"truncate",children:[" ",N.length>F-2?N.slice(0,F-3)+"\u2026":N," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:j,justifyContent:"flex-end",children:jsx(Text,{color:C,dimColor:!C,children:y})})]})});var Es="\u2295";function Os({goalTitle:t,taskCount:n,doneCount:o,width:r}){let l=n>0?Math.round(o/n*100):0,f=` ${Es} ${t.toUpperCase()} ${fe} ${n} task${n!==1?"s":""} ${fe} ${l}% done `,b=3,T=Math.max(0,r-b-f.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:Te(b)}),jsx(Text,{backgroundColor:Pt.amber,color:e.amber,bold:true,children:f}),jsx(Text,{color:e.ghost,children:Te(T)})]})}function Ls({taskCount:t,width:n}){let o=` ${Es} UNGROUPED ${fe} ${t} task${t!==1?"s":""} `,r=3,l=Math.max(0,n-r-o.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:Te(r)}),jsx(Text,{backgroundColor:Pt.neutral,color:e.dim,children:o}),jsx(Text,{color:e.ghost,children:Te(l)})]})}var xl="\u2715",Ps="\u25CB",bl="\u25B6",Tl="\u2713",On={green:"#0f2d1f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},yl={running:{icon:bl,label:"ACTIVE",fg:e.green,bg:On.green,bold:true,spinner:true},idle:{icon:Ps,label:"IDLE",fg:e.dim,bg:On.neutral},error:{icon:xl,label:"ERROR",fg:e.red,bg:On.red,bold:true},disabled:{icon:Ps,label:"OFF",fg:e.ghost,bg:On.neutral}},Rr={running:0,idle:1,error:2,disabled:3},Ds=ao.memo(function({agent:n,selected:o,width:r,runningEntry:l,currentTaskTitle:f$1,teamName:b,isLead:T}){let x=yl[n.status],y=n.status==="running",C,M;if(y&&l){let N=Date.now()-new Date(l.started_at).getTime();C=f(N),M=e.cyan;}else n.stats.total_runs>0?(C=`${n.stats.tasks_completed}/${n.stats.total_runs}`,M=n.stats.tasks_completed>0?e.green:e.dim):(C="\u2014",M=void 0);let A=o?"\u25B8":" ",S=11,H=8,V=b?Math.min(b.length+2,12):0,F=10,P=2+S+H+V+F,j=r?Math.max(8,r-P):20,O=n.stats.total_runs>0,L=O?Math.round(n.stats.tasks_completed/n.stats.total_runs*100):0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[A," "]}),jsx(Box,{width:S,children:jsx(Text,{backgroundColor:x.bg,color:x.fg,bold:x.bold,children:x.spinner?jsxs(Fragment,{children:[" ",jsx(En,{color:x.fg})," ",x.label," "]}):jsxs(Fragment,{children:[" ",x.icon," ",x.label," "]})})}),jsx(Box,{width:j,children:jsxs(Text,{wrap:"truncate",bold:o||y,color:o?e.white:y?e.green:e.silver,children:[n.autonomous&&jsxs(Text,{color:e.cyan,children:[gn," "]}),T&&jsxs(Text,{color:e.amber,children:[Ir," "]}),n.name,y&&f$1&&jsxs(Text,{color:e.dim,children:[" ",fe," ",f$1]}),n.status==="error"&&n.last_error&&jsxs(Text,{color:e.red,children:[" ",fe," ",rt(m[n.last_error.kind]?.message??n.last_error.message,30)]})]})}),jsx(Box,{width:H,children:jsx(Text,{color:e.dim,children:n.adapter})}),b&&jsx(Box,{width:V,children:jsx(Text,{color:e.amber,wrap:"truncate",children:b})}),jsx(Box,{width:F,justifyContent:"flex-end",children:O&&!y?jsxs(Text,{color:L>=80?e.green:L>=50?e.yellow:e.red,children:[C," ",Tl]}):jsx(Text,{color:M,dimColor:!M,children:C})})]})});function Fs({teamName:t,memberCount:n,leadName:o,width:r}){let l=`${n} agent${n!==1?"s":""}`,f=o?` ${fe} ${Ir} ${o}`:"",b=` ${Zt} ${t.toUpperCase()} ${fe} ${l}${f} `,T=3,x=Math.max(0,r-T-b.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:Te(T)}),jsx(Text,{backgroundColor:On.amber,color:e.amber,bold:true,children:b}),jsx(Text,{color:e.ghost,children:Te(x)})]})}var wl="\u25C7";function Gs({memberCount:t,width:n}){let o=`${t} agent${t!==1?"s":""}`,r=` ${wl} UNASSIGNED ${fe} ${o} `,l=3,f=Math.max(0,n-l-r.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:Te(l)}),jsx(Text,{backgroundColor:On.neutral,color:e.dim,children:r}),jsx(Text,{color:e.ghost,children:Te(f)})]})}var Ws="\u2713",zs="\u2715",kl="\u2016",Cl="\u25C9",io={green:"#0f2d1f",amber:"#2d1f0a",neutral:"#1a1a22"},Il={active:{icon:Cl,label:"ACTIVE",fg:e.green,bg:io.green,bold:true},paused:{icon:kl,label:"PAUSED",fg:e.dim,bg:io.neutral},achieved:{icon:Ws,label:"DONE",fg:e.amber,bg:io.amber,bold:true},abandoned:{icon:zs,label:"DROP",fg:e.ghost,bg:io.neutral}},Ml="\u2588",vl="\u2591",Rl=14,Vs=ao.memo(function({goal:n,selected:o,width:r,agentNameMap:l,tasksByGoal:f}){let b=Il[n.status],T=o?"\u25B8":" ",x=f?.length??0,y=f?.filter(L=>L.status==="done").length??0,C=x>0,M=11,A=C?Rl:0,S=14,H=7,V=2+M+A+S+H,F=r?Math.max(10,r-V):40,P=n.assignee?l?.get(n.assignee)??n.assignee:void 0,j,O;if(n.status==="achieved")j=Ws,O=e.amber;else if(n.status==="abandoned")j=zs,O=e.ghost;else {let L=Date.now()-new Date(n.created_at).getTime(),N=Math.floor(L/864e5);j=N>0?`${N}d`:"<1d",O=e.dim;}return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[T," "]}),jsx(Box,{width:M,children:jsxs(Text,{backgroundColor:b.bg,color:b.fg,bold:b.bold,children:[" ",b.icon," ",b.label," "]})}),jsx(Box,{width:F,children:jsx(Text,{wrap:"truncate",bold:o||n.status==="active",color:o?e.white:n.status==="active"?e.silver:void 0,children:n.title.length>F?n.title.slice(0,F-1)+"\u2026":n.title})}),C&&(()=>{let N=x>0?Math.round(y/x*6):0,E=6-N;return jsxs(Box,{width:A,children:[jsx(Text,{color:e.green,children:Ml.repeat(N)}),jsx(Text,{color:e.ghost,children:vl.repeat(E)}),jsx(Text,{color:e.dim,children:` ${y}/${x}`})]})})(),jsx(Box,{width:S,children:P?jsxs(Text,{backgroundColor:io.green,color:e.green,wrap:"truncate",children:[" ",P.length>S-2?P.slice(0,S-3)+"\u2026":P," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:H,justifyContent:"flex-end",children:jsx(Text,{color:O,dimColor:!O,children:j})})]})});var _l={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"};function Nn({label:t,width:n,color:o}){let r=n-4,l=` ${t} `,f=3,b=Math.max(0,r-f-l.length);return jsxs(Text,{color:o??e.ghost,children:[" ",Te(f),l,Te(b)]})}function Hs({task:t,height:n,width:o,taskLogs:r,agentNameMap:l,taskTitleMap:f}){let b=Ao[t.status]??e.dim,T=t.priority<=2?t.priority===1?e.red:e.yellow:void 0,x=24,y=!!t.description?.trim(),C=!!t.proof?.agent_summary,M=(t.proof?.files_changed?.length??0)>0,A=(r?.length??0)>0,S=(t.attachments?.length??0)>0,H=y?t.description.split(`
4
+ `):[],V=C?t.proof.agent_summary.split(`
5
+ `):[],F=3;S&&(F+=2+t.attachments.length),y?(F+=1,F+=Math.min(H.length,Math.max(1,Math.ceil((n-10)*.3)))):C||(F+=2),C&&(F+=2),M&&(F+=1),A&&(F+=2);let P=Math.max(0,n-F),j=0,O=0;C&&A?(j=Math.max(1,Math.floor(P*.4)),O=Math.max(1,P-j)):C?j=P:A&&(O=P);let L=y?H.slice(0,Math.max(1,Math.ceil((n-10)*.3))):[],N=V.slice(0,j);return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:b,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" assignee "}),jsx(Text,{color:t.assignee?e.green:e.dim,children:t.assignee?l?.get(t.assignee)??t.assignee:"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" priority "}),jsxs(Text,{color:T,bold:t.priority<=2,children:["P",t.priority]})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" attempts "}),jsxs(Text,{children:[t.attempts,"/",t.max_attempts]})]})]}),jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" labels "}),jsx(Text,{color:e.purple,children:t.labels.length>0?t.labels.join(", "):"\u2014"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" depends "}),jsx(Text,{dimColor:true,children:t.depends_on.length>0?t.depends_on.map(E=>f?.get(E)??E).join(", "):"\u2014"})]})]}),S&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Nn,{label:`attachments (${t.attachments.length})`,width:o,color:e.dim}),t.attachments.map((E,W)=>jsxs(Text,{color:e.cyan,wrap:"truncate",children:[" ",E]},`a${W}`))]}),y&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),L.map((E,W)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",rt(E,o-8)]},`d${W}`))]}),!y&&!C&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:" No description."})]}),C&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Nn,{label:"result",width:o,color:e.dim}),N.map((E,W)=>jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",rt(E,o-8)]},`r${W}`))]}),M&&jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" files "}),jsx(Text,{color:e.cyan,children:t.proof.files_changed.length}),jsx(Text,{color:e.dim,children:" changed"}),t.proof.branch&&jsxs(Fragment,{children:[jsxs(Text,{color:e.dim,children:[" ","\xB7"," "]}),jsx(Text,{color:e.cyan,children:t.proof.branch})]})]}),A&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Nn,{label:"activity",width:o,color:e.dim}),r.slice(-O).map((E,W)=>{let z=E.msgType??"info",X=_l[z]??"\u2502",R=E.color;z==="tool"?R=e.cyan:z==="file"?R=e.purple:z==="error"?R=e.red:z==="lifecycle"?R=e.green:z==="system"&&(R=e.dim);let ae=Math.max(10,o-12),Ee=rt(E.text,ae);return jsxs(Box,{children:[jsxs(Text,{color:e.ghost,children:[" ",E.time," "]}),jsxs(Text,{color:z==="error"?e.red:e.dim,children:[X," "]}),jsx(Text,{color:R,bold:z==="lifecycle",children:Ee})]},W)})]})]})}var Eo=[{key:"G",id:"goals",label:"GOALS"},{key:"T",id:"tasks",label:"TASKS"},{key:"A",id:"agents",label:"AGENTS"},{key:"L",id:"logs",label:"ACTIONS"}];var js="\u25CF",Xs="\u25CB",Al="\u2713",$l="\u2715",Bl="\u2191",El="\u2193",Ol="\u03A3",Ll="\u25B6",Pl="\u21BB",Nl="\u{1F9E0}",Us=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],_r=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],Qe={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"};function qs({color:t}){let n=mn();return jsx(Text,{color:t,children:Us[n%Us.length]})}function Dl(){let t=mn(),n=Math.floor(t/10)%2===0;return jsx(Text,{color:n?e.amber:e.amberDim,bold:true,children:Ht})}function Fl({width:t,active:n}){let o=Math.max(4,Math.floor(t*.08)),r=2,l=mn(),f=Math.ceil((t+o)/r),b=n?l%(f*2):0;if(!n)return jsx(Box,{paddingX:1,children:jsx(Text,{color:e.ghost,children:He(t)})});let T=b<f?b*r:(f*2-b)*r,x=Math.max(0,T-o),y=Math.min(t,T),C=x,M=Math.max(0,y-x),A=Math.max(0,t-y);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:He(C)}),jsx(Text,{color:e.amber,children:He(M)}),jsx(Text,{color:e.ghost,children:He(A)})]})}function Gl({data:t,width:n,color:o}){if(t.length===0)return null;let r=t.slice(-n),l=Math.max(...r,1),f=r.map(b=>{let T=Math.round(b/l*(_r.length-1));return _r[T]??_r[0]}).join("");return jsx(Text,{color:o,children:f})}function Wl({tab:t,flashColor:n,onComplete:o,badge:r}){let l=mn(),f=ao.useRef(l),b=ao.useRef(false),T=l-f.current,x=2,y=6*x;return ao.useEffect(()=>{T>=y&&!b.current&&(b.current=true,o());},[T,o]),Math.floor(T/x)%2===0&&T<y?jsxs(Text,{backgroundColor:n,color:"#0a0a0c",bold:true,children:[" ",t.key," ",t.label,r," "]}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:t.key}),jsxs(Text,{color:e.dim,children:[" ",t.label.toLowerCase(),r]})]})}function zl({projectName:t,activeView:n,mode:o,stats:r,uptime:l,width:f,version:b,latestVersion:T,updateInstalled:x,taskBadge:y,flashTab:C,flashColor:M,onFlashComplete:A}){return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:f,children:[jsxs(Box,{gap:0,children:[jsx(Dl,{}),jsx(Text,{color:e.amber,bold:true,children:" ORCH"}),b&&jsxs(Text,{color:e.ghost,children:[" ",b]}),T&&T!==b&&(x?jsxs(Text,{backgroundColor:Qe.green,color:e.green,bold:true,children:[" v",T," INSTALLED \u2014 RESTART TO APPLY "]}):jsxs(Text,{backgroundColor:Qe.green,color:e.green,bold:true,children:[" UPDATE ",T," "]})),jsxs(Text,{color:e.ghost,children:[" ",fe," "]}),jsx(Text,{color:e.silver,children:t})]}),jsx(Box,{gap:0,children:Eo.map((S,H)=>{let V=n===S.id,F=S.id==="tasks"&&y!=null&&y>0?` (${y})`:"",P=!V&&C===S.id&&M&&A;return jsxs(ao.Fragment,{children:[H>0&&jsx(Text,{children:" "}),V?jsxs(Text,{backgroundColor:e.amber,color:"#0a0a0c",bold:true,children:[" ",S.key," ",S.label,F," "]}):P?jsx(Wl,{tab:S,flashColor:M,onComplete:A,badge:F}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:S.key}),jsxs(Text,{color:e.dim,children:[" ",S.label.toLowerCase(),F]})]})]},S.id)})}),jsxs(Box,{gap:0,children:[o==="watching"?jsxs(Text,{backgroundColor:Qe.green,color:e.green,bold:true,children:[" ",js," WATCHING"," "]}):o==="observing"?jsxs(Text,{backgroundColor:Qe.amber,color:e.amber,bold:true,children:[" ",js," OBSERVING"," "]}):jsxs(Text,{backgroundColor:Qe.neutral,color:e.dim,children:[" ",Xs," IDLE"," "]}),r.running>0&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{backgroundColor:Qe.green,color:e.green,children:[" ",jsx(qs,{color:e.green})," ",r.running," active"," "]})]}),l&&jsxs(Text,{color:e.ghost,children:[" ",l]})]})]})}function Vl({stats:t,tokens:n,width:o,sparklineData:r}){let f=[{icon:Ll,label:"RUN",count:t.running,fg:e.green,bg:Qe.green,bold:true,spinner:true,show:t.running>0},{icon:Pl,label:"RETRY",count:t.retrying,fg:e.yellow,bg:Qe.yellow,show:t.retrying>0},{icon:Zt,label:"REVIEW",count:t.review,fg:e.blue,bg:Qe.blue,show:t.review>0},{icon:Xs,label:"TODO",count:t.todo,fg:e.dim,bg:Qe.neutral,show:t.todo>0},{icon:Al,label:"DONE",count:t.done,fg:e.green,bg:Qe.green,show:t.done>0},{icon:$l,label:"FAIL",count:t.failed,fg:e.red,bg:Qe.red,bold:true,show:t.failed>0},{icon:Ht,label:"TEAMS",count:t.teams,fg:e.amber,bg:Qe.amber,show:t.teams>0}].filter(x=>x.show),b=n.total>0,T=r&&r.length>0?Math.min(16,r.length):0;return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:o,children:[jsxs(Box,{gap:1,children:[f.map(x=>jsx(Text,{backgroundColor:x.bg,color:x.fg,bold:x.bold,children:x.spinner?jsxs(Fragment,{children:[" ",jsx(qs,{color:x.fg})," ",x.count," ",x.label," "]}):jsxs(Fragment,{children:[" ",x.icon," ",x.count," ",x.label," "]})},x.label)),f.length===0&&jsxs(Text,{backgroundColor:Qe.neutral,color:e.dim,children:[" ","NO TASKS"," "]})]}),jsxs(Box,{gap:0,children:[T>0&&r&&jsxs(Fragment,{children:[jsx(Gl,{data:r,width:T,color:e.amberDim}),jsx(Text,{children:" "})]}),b&&jsxs(Text,{backgroundColor:Qe.amber,color:e.cyan,children:[" ",Bl,h(n.input)," ",El,h(n.output),n.reasoning>0?` ${Nl}${h(n.reasoning)}`:""," ",fe," ",Ol,h(n.total)," "]})]})]})}var Ks=ao.memo(function(n){let o=Math.max(10,n.width-2),r=n.stats.running>0;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{height:1}),jsx(zl,{projectName:n.projectName,activeView:n.activeView,mode:n.mode,stats:n.stats,uptime:n.uptime,width:n.width,version:n.version,latestVersion:n.latestVersion,updateInstalled:n.updateInstalled,taskBadge:n.taskBadge,flashTab:n.flashTab,flashColor:n.flashColor,onFlashComplete:n.onFlashComplete}),jsx(Box,{height:1}),jsx(Vl,{stats:n.stats,tokens:n.tokens,width:n.width,sparklineData:n.sparklineData}),jsx(Fl,{width:o,active:r})]})});var lo="\u0423\u041F\u0420\u0410\u0412\u041B\u0415\u041D\u0418\u0415",Dn="\u041C\u041E\u041D\u0418\u0422\u041E\u0420\u0418\u041D\u0413",Lo="\u041D\u0410\u0421\u0422\u0420\u041E\u0419\u041A\u0418",fn={task:{sub:["add","list","show","cancel","retry","assign","approve","reject","delete"],help:"Manage tasks",category:lo},agent:{sub:["add","list","disable","enable","delete","autonomous","shop"],help:"Manage agents",category:lo},team:{sub:["create","list","join","leave","disband","set-lead"],help:"Manage teams",category:lo},goal:{sub:["add","list","show","status","delete"],help:"Manage goals",category:lo},run:{args:"[id]",help:"Run task (or selected)",category:Dn},"run-all":{help:"Run all todo tasks",category:Dn},watch:{help:"Start watch mode (auto-dispatch)",category:Dn},pause:{help:"Pause watch mode",category:Dn},status:{help:"Show orchestrator status",category:Dn},config:{sub:["activity-filter","max-concurrent"],help:"TUI settings",category:Lo},help:{help:"List all commands",category:Lo},quit:{help:"Exit the TUI",category:Lo}};function Ar(t){if(!t.startsWith("/"))return null;let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let T=n;if(!T)return null;let x=Object.keys(fn).find(y=>y.startsWith(T)&&y!==T);return x?x.slice(T.length):null}let r=n.slice(0,o),l=fn[r];if(!l?.sub)return null;let f=n.slice(o+1);if(!f)return null;let b=l.sub.find(T=>T.startsWith(f)&&T!==f);return b?b.slice(f.length):null}function Ys(t){if(!t.startsWith("/"))return [];let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let T=n.toLowerCase(),x=[];if(!T){let y=[lo,Dn,Lo];for(let C of y){x.push({cmd:"",desc:`\u2500\u2500 ${C} \u2500\u2500`});for(let[M,A]of Object.entries(fn))if(A.category===C){let S=A.args?` ${A.args}`:"";x.push({cmd:`/${M}${S}`,desc:A.help,subs:A.sub?.join(" \xB7 ")});}}return x}for(let[y,C]of Object.entries(fn))if(y.startsWith(T)){let M=C.args?` ${C.args}`:"";if(x.push({cmd:`/${y}${M}`,desc:C.help,subs:C.sub?.join(" \xB7 ")}),y===T&&C.sub)for(let A of C.sub)x.push({cmd:`/${y} ${A}`,desc:`${C.help}: ${A}`});}return x}let r=n.slice(0,o),l=fn[r];if(!l?.sub)return [];let f=n.slice(o+1).toLowerCase(),b=[];for(let T of l.sub)(!f||T.startsWith(f))&&b.push({cmd:`/${r} ${T}`,desc:`${l.help}: ${T}`});return b}var Po=class{entries=[];cursor=0;push(n){n&&(this.entries[this.entries.length-1]!==n&&(this.entries.push(n),this.entries.length>100&&this.entries.shift()),this.cursor=this.entries.length);}prev(){return this.entries.length===0?null:(this.cursor>0&&this.cursor--,this.entries[this.cursor]??null)}next(){return this.cursor<this.entries.length-1?(this.cursor++,this.entries[this.cursor]??null):(this.cursor=this.entries.length,null)}reset(){this.cursor=this.entries.length;}};var jl="\u2588",Zs=ao.memo(function({mode:n,value:o,completion:r,activeView:l,canRun:f,canNew:b,canApprove:T,canReject:x,canCancel:y,canDelete:C,canUndo:M,canEdit:A,canForceStop:S,canToggleAuto:H,autoActive:V,canPause:F,isPaused:P,canToggleShowAll:j,showAllActive:O,hasDetail:L,itemCount:N,itemLabel:E,width:W,hasSuggestions:z,onboardingCompleted:X}){if(n==="command"){let R=z?" \u2191\u2193 select Tab fill Esc \u2715":" Enter exec \u2191\u2193 history Tab complete Esc \u2715",ae=Math.max(4,W-6-R.length-(r?.length??0)-1),Ee=o.length>ae?"\u2026"+o.slice(-(ae-1)):o;return jsx(Box,{paddingX:2,justifyContent:"space-between",width:W,children:jsxs(Box,{children:[jsx(Text,{color:e.amber,children:"/ "}),jsx(Text,{color:e.white,children:Ee}),r&&jsx(Text,{color:e.ghost,children:r}),jsx(Text,{color:e.amber,children:jl}),jsx(Text,{color:e.dim,children:R})]})})}return jsxs(Box,{paddingX:2,justifyContent:"space-between",width:W,children:[jsxs(Text,{color:e.dim,children:[jsx(Text,{bold:true,color:e.gray,children:"\u2191\u2193"})," ",jsx(Text,{bold:true,color:e.gray,children:"Tab"}),"/",jsx(Text,{bold:true,color:e.gray,children:"\u2190\u2192"})," ",jsx(Text,{bold:true,color:e.gray,children:"/"})," cmd",b&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"N"})," new"]}),f&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"R"})," run"]}),y&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"C"})," cancel"]}),T&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.green,children:"A"})," approve"]}),x&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"X"})," reject"]}),A&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"E"})," edit"]}),S&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"S"})," stop"]}),F&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"P"}),P?" resume":" pause"]}),H&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"U"}),V?" auto off":" auto on"]}),j&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"S"}),O?" collapse":" show all"]}),C&&!T&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"D"})," delete"]}),M&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.yellow,children:"Z"})," undo"]}),L&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Esc"})," close"]}),!L&&(l==="tasks"||l==="agents"||l==="goals")&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Enter"})," detail"]})," ",jsx(Text,{bold:true,color:e.gray,children:"Q"})," quit"," ",jsx(Text,{bold:true,color:X===false?e.amber:e.gray,children:"?"}),jsx(Text,{color:X===false?e.amber:void 0,children:" help"})]}),N>0&&jsxs(Text,{color:e.dim,children:[N," ",E]})]})});var No="\u2588",Br=process.platform==="darwin"?"\u2318":"Ctrl";function ql(t,n){if(n<=0||t.length<=n)return [t];let o=[];for(let r=0;r<t.length;r+=n)o.push(t.slice(r,r+n));return o}function Do(t,n){if(n<=0)return 0;let o=n-1;for(;o>0&&t[o-1]===" ";)o--;for(;o>0&&t[o-1]!==" ";)o--;return o}function ei(t,n){if(n>=t.length)return t.length;let o=n;for(;o<t.length&&t[o]!==" ";)o++;for(;o<t.length&&t[o]===" ";)o++;return o}function ti({title:t,steps:n,onComplete:o,onCancel:r,width:l,height:f,onPasteImage:b,footerExtra:T,onSuggestionSelected:x}){let [y,C]=useState(0),[M,A]=useState({}),[S,H]=useState(()=>{let $=n.find(I=>!I.skip?.({}));return $?.type==="text"&&$.defaultValue?$.defaultValue:""}),[V,F]=useState(()=>{let $=n.find(I=>!I.skip?.({}));return $?.type==="text"&&$.defaultValue?$.defaultValue.length:0}),[P,j]=useState(()=>{let $=n.find(I=>!I.skip?.({}));return $?.type==="textarea"&&$.defaultValue?$.defaultValue.split(`
6
+ `):[""]}),[O,L]=useState(0),[N,E]=useState(0),[W,z]=useState(()=>{let $=n.find(I=>!I.skip?.({}));if($?.type==="select"&&$.defaultValue){let k=($.getOptions?.({})??$.options??[]).findIndex(B=>B.value===$.defaultValue);return k>=0?k:0}return 0}),X=useMemo(()=>n.filter($=>!$.skip?.(M)),[n,M]),R=X[y],ae=X.length,{taLineNumWidth:Ft,taContentWidth:dt}=useMemo(()=>{let $=String(P.length).length;return {taLineNumWidth:$,taContentWidth:Math.max(1,l-$-4)}},[P.length,l]),_e=useMemo(()=>{if(!R||R.type!=="textarea")return [];let $=[];for(let I=0;I<P.length;I++){let k=ql(P[I]??"",dt);for(let B=0;B<k.length;B++)$.push({logicalRow:I,startCol:B*dt,text:k[B],isFirst:B===0});}return $},[R?.id,R?.type,P,dt]),Ke=useMemo(()=>{for(let $=0;$<_e.length;$++){let I=_e[$];if(I.logicalRow===O&&(N>=I.startCol&&N<I.startCol+dt||N>=I.startCol&&($+1>=_e.length||_e[$+1].logicalRow!==O)))return $}return 0},[_e,O,N,dt]),[ut,pt]=useState(new Set),[De,Ye]=useState(false),[gt,Ze]=useState(0),[nn,Ce]=useState(false),[ht,xt]=useState(null),[Xt,mt]=useState(false),kt=useRef(null),Ue=useRef(null),go=useMemo(()=>R?R.type==="text"?S:R.type==="textarea"?P.join(`
7
+ `):"":"",[R,S,P]),Wn=useCallback(($,I)=>{if(kt.current&&clearTimeout(kt.current),!I){xt(null);return}kt.current=setTimeout(()=>{xt(I($));},300);},[]);useEffect(()=>(R&&R.validate&&(R.type==="text"||R.type==="textarea")&&Wn(go,R.validate),()=>{kt.current&&clearTimeout(kt.current);}),[go,R,Wn]),useEffect(()=>()=>{Ue.current&&clearTimeout(Ue.current);},[]);let _t=useMemo(()=>!R||R.type!=="select"&&R.type!=="multiselect"?[]:R.getOptions?.(M)??R.options??[],[R,M]),Gt=Math.min(W,Math.max(0,_t.length-1)),Wt=useMemo(()=>{if(!R?.suggestions)return [];if(!S.trim())return R.suggestions;let $=S.toLowerCase();return R.suggestions.filter(I=>I.label.toLowerCase().includes($)||(I.hint??"").toLowerCase().includes($))},[R?.suggestions,S]),zt=Math.min(gt,Math.max(0,Wt.length-1)),on=$=>{let I={...M,[R.id]:$};A(I),H(""),F(0),j([""]),L(0),E(0),z(0),pt(new Set),Ye(false),Ze(0),Ce(false),xt(null),mt(false),kt.current&&clearTimeout(kt.current);let k=R.id,q=n.findIndex(te=>te.id===k)+1;for(;q<n.length;){let te=n[q];if(te&&!te.skip?.(I))break;q++;}if(q>=n.length)o(I);else {let te=n[q].id,de=n.filter(Ae=>!Ae.skip?.(I)).findIndex(Ae=>Ae.id===te);C(de>=0?de:0);let K=n[q];if(K.type==="text"){let Ae=K.defaultValue??"";H(Ae),F(Ae.length);}else if(K.type==="textarea"){let Ae=K.defaultValue?K.defaultValue.split(`
8
+ `):[""];j(Ae),L(Ae.length-1),E(Ae[Ae.length-1].length);}else if(K.type==="select"){let Ae=K.getOptions?.(I)??K.options??[];if(K.defaultValue){let we=Ae.findIndex(Vn=>Vn.value===K.defaultValue);z(we>=0?we:0);}else z(0);}else K.type==="multiselect"&&(z(0),K.defaultValue?pt(new Set(K.defaultValue.split(","))):pt(new Set));}},rn=()=>{if(y===0){r();return}let $=R.id,k=n.findIndex(de=>de.id===$)-1;for(;k>=0;){let de=n[k];if(de&&!de.skip?.(M))break;k--;}if(k<0){r();return}let B=n[k].id,q=X.findIndex(de=>de.id===B);C(q>=0?q:0),Ye(false),Ze(0),Ce(false),xt(null),mt(false),kt.current&&clearTimeout(kt.current);let te=n[k];if(M[te.id]&&Ce(true),te.type==="text"){let de=M[te.id]??te.defaultValue??"";H(de),F(de.length);}else if(te.type==="textarea"){let de=M[te.id]??te.defaultValue??"",K=de?de.split(`
9
+ `):[""];j(K),L(K.length-1),E(K[K.length-1].length);}else if(te.type==="multiselect"){z(0);let de=M[te.id];pt(de?new Set(de.split(",")):new Set);}else {let de=te.getOptions?.(M)??te.options??[],K=M[te.id],Ae=de.findIndex(we=>we.value===K);z(Ae>=0?Ae:0);}};if(useInput(($,I)=>{if(R){if(I.escape){y===0?r():rn();return}if((I.ctrl||I.meta)&&($==="v"||$==="i")&&b&&(R.type==="text"||R.type==="textarea")){b();return}if(R.type==="text"){if(De&&Wt.length>0){if(I.upArrow){zt<=0?Ye(false):Ze(k=>k-1);return}if(I.downArrow){Ze(k=>Math.min(Wt.length-1,k+1));return}if(I.return){let k=Wt[zt];k&&x&&x(k.value);return}Ye(false);}if(I.return){let k=S.trim();if(R.required&&!k){Ce(true);return}if(ht!==null){Ce(true),mt(true),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>mt(false),2e3);return}on(k);return}if(I.downArrow&&R.suggestions&&Wt.length>0){Ye(true),Ze(0);return}if(I.ctrl&&$==="a"){F(0);return}if(I.ctrl&&$==="e"){F(S.length);return}if(I.ctrl&&$==="k"){Ce(true),H(k=>k.slice(0,V));return}if(I.ctrl&&$==="u"){Ce(true),H(k=>k.slice(V)),F(0);return}if(I.ctrl&&$==="w"){Ce(true);let k=Do(S,V);H(B=>B.slice(0,k)+B.slice(V)),F(k);return}if(I.meta&&(I.leftArrow||$==="b")){F(Do(S,V));return}if(I.meta&&(I.rightArrow||$==="f")){F(ei(S,V));return}if(I.leftArrow){F(k=>Math.max(0,k-1));return}if(I.rightArrow){F(k=>Math.min(S.length,k+1));return}if(I.backspace||I.delete){if(V===0&&S.length===0&&y>0){rn();return}V>0&&(H(k=>k.slice(0,V-1)+k.slice(V)),F(k=>k-1));return}$&&!I.ctrl&&!I.meta&&!I.escape&&(Ce(true),Ye(false),Ze(0),H(k=>k.slice(0,V)+$+k.slice(V)),F(k=>k+$.length));return}if(R.type==="textarea"){if(I.return&&(I.ctrl||I.meta)){let k=P.join(`
10
+ `).trim();if(R.required&&!k){Ce(true);return}if(ht!==null){Ce(true),mt(true),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>mt(false),2e3);return}on(k);return}if(I.return){Ce(true),j(k=>{let B=k[O]??"",q=B.slice(0,N),te=B.slice(N),le=[...k];return le.splice(O,1,q,te),le}),L(k=>k+1),E(0);return}if(I.ctrl&&$==="a"){E(0);return}if(I.ctrl&&$==="e"){E((P[O]??"").length);return}if(I.ctrl&&$==="k"){Ce(true),j(k=>{let B=[...k];return B[O]=(B[O]??"").slice(0,N),B});return}if(I.ctrl&&$==="u"){Ce(true),j(k=>{let B=[...k];return B[O]=(B[O]??"").slice(N),B}),E(0);return}if(I.ctrl&&$==="w"){Ce(true);let k=O,B=N;j(q=>{let te=q[k]??"",le=Do(te,B),de=[...q];return de[k]=te.slice(0,le)+te.slice(B),E(le),de});return}if(I.meta&&(I.leftArrow||$==="b")){E(Do(P[O]??"",N));return}if(I.meta&&(I.rightArrow||$==="f")){E(ei(P[O]??"",N));return}if(I.upArrow){if(Ke>0){let k=_e[Ke],B=_e[Ke-1],q=N-(k?.startCol??0),te=Math.min(B.startCol+q,B.startCol+B.text.length);L(B.logicalRow),E(te);}return}if(I.downArrow){if(Ke<_e.length-1){let k=_e[Ke],B=_e[Ke+1],q=N-(k?.startCol??0),te=Math.min(B.startCol+q,B.startCol+B.text.length);L(B.logicalRow),E(te);}return}if(I.leftArrow){N>0?E(k=>k-1):O>0&&(L(k=>k-1),E((P[O-1]??"").length));return}if(I.rightArrow){let k=(P[O]??"").length;N<k?E(B=>B+1):O<P.length-1&&(L(B=>B+1),E(0));return}if(I.backspace||I.delete){if(N===0&&O===0)return;if(N>0)j(k=>{let B=[...k],q=B[O]??"";return B[O]=q.slice(0,N-1)+q.slice(N),B}),E(k=>k-1);else {let k=(P[O-1]??"").length;j(B=>{let q=[...B],te=q[O-1]??"",le=q[O]??"";return q.splice(O-1,2,te+le),q}),E(k),L(B=>B-1);}return}if($&&!I.ctrl&&!I.meta&&!I.escape){Ce(true);let k=$.split(/\r?\n/);if(k.length===1)j(B=>{let q=[...B],te=q[O]??"";return q[O]=te.slice(0,N)+$+te.slice(N),q}),E(B=>B+$.length);else {let B=O,q=N;j(te=>{let le=[...te],de=le[B]??"",K=de.slice(0,q),Ae=de.slice(q),we=k[0]??"",Vn=k[k.length-1]??"",Tn=[K+we,...k.slice(1,-1),Vn+Ae];return le.splice(B,1,...Tn),le}),L(B+k.length-1),E((k[k.length-1]??"").length);}}return}if(R.type==="select"||R.type==="multiselect"){if(I.upArrow||$==="k"){z(k=>Math.max(0,k-1));return}if(I.downArrow||$==="j"){z(k=>Math.min(_t.length-1,k+1));return}if(I.backspace||I.delete){rn();return}if(R.type==="select"){if(I.return||I.tab){let k=_t[Gt];if(k){if(R.validate){let B=R.validate(k.value);if(B!==null){Ce(true),xt(B),mt(true),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>mt(false),2e3);return}}on(k.value);}return}if($>="1"&&$<="9"){let k=parseInt($,10)-1;if(k<_t.length){let B=_t[k];B&&on(B.value);}return}}else {if($===" "){let k=_t[Gt];k&&pt(B=>{let q=new Set(B);return q.has(k.value)?q.delete(k.value):q.add(k.value),q});return}if(I.return){let k=Array.from(ut).join(",");on(k);return}}}}}),!R)return null;let nt=nn?ht:null,At=Math.max(20,l-6),xn=`${y+1}/${ae}`,zn=Math.max(2,f-4),qt=0;Gt>=zn&&(qt=Gt-zn+1);let bn=_t.slice(qt,qt+zn);return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsx(Text,{color:e.amber,bold:true,children:t}),jsxs(Text,{color:e.ghost,children:[" ",Ve,Ve," "]}),jsxs(Text,{color:e.dim,children:["step ",xn]})]}),jsxs(Box,{children:[jsx(Text,{children:" "}),X.map(($,I)=>jsxs(Text,{color:I===y?e.amber:I<y?e.green:e.ghost,children:[I===y?"\u25CF":I<y?"\u2713":"\u25CB"," "]},$.id))]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.white,bold:true,children:[" ",R.label]}),R.required&&jsx(Text,{color:e.red,children:" *"}),!R.required&&jsxs(Text,{color:e.dim,children:[" (optional, ",R.type==="textarea"?`${Br}+Enter`:"Enter"," to skip)"]})]}),R.description&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ",R.description]})}),R.type==="text"&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{borderStyle:nt?"round":void 0,borderColor:nt?e.red:void 0,children:[jsxs(Text,{color:e.amber,children:[" ",">"," "]}),S.length>0?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:S.slice(0,V)}),jsx(Text,{color:e.amber,children:No}),jsx(Text,{color:e.white,children:S.slice(V)})]}):R.placeholder?jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:R.placeholder}),jsx(Text,{color:e.amber,children:No})]}):jsx(Text,{color:e.amber,children:No})]}),nt&&jsxs(Text,{color:e.red,dimColor:true,children:[" ",nt]}),Xt&&jsx(Text,{color:e.red,children:" Fix the error above"})]}),R.type==="text"&&R.suggestions&&Wt.length>0&&(()=>{let $=Math.max(2,f-6),I=0;De&&zt>=$&&(I=zt-$+1);let k=Wt.slice(I,I+$);return jsxs(Box,{flexDirection:"column",children:[jsxs(Text,{color:e.ghost,children:[" ",Ve,Ve,Ve," or browse templates ",Ve.repeat(Math.max(0,At-28))]}),k.map((B,q)=>{let te=q+I,le=De&&te===zt;return jsxs(Box,{children:[jsx(Text,{color:le?e.amber:e.ghost,children:le?" \u25B8 ":" "}),jsx(Text,{color:le?e.white:e.silver,bold:le,children:B.label}),B.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",Ve," ",B.hint.replace(/\n/g," ")]})]},B.value)})]})})(),R.type==="textarea"&&(()=>{let $=Math.max(3,f-6),I=0;Ke>=$&&(I=Ke-$+1);let k=_e.slice(I,I+$);return jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{flexDirection:"column",borderStyle:nt?"round":void 0,borderColor:nt?e.red:void 0,children:[k.map((B,q)=>{let te=q+I,le=B.isFirst?String(B.logicalRow+1).padStart(Ft," "):"".padStart(Ft," "),de=te===Ke,K=N-B.startCol;return jsxs(Box,{children:[jsxs(Text,{color:e.dim,children:[" ",le," "]}),jsxs(Text,{color:e.ghost,children:["\u2502"," "]}),de?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:B.text.slice(0,K)}),jsx(Text,{color:e.amber,children:No}),jsx(Text,{color:e.white,children:B.text.slice(K)})]}):jsx(Text,{color:e.silver,children:B.text||(B.isFirst?" ":"")})]},`${B.logicalRow}-${B.startCol}`)}),P.length===1&&P[0]===""&&R.placeholder&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","".padStart(Ft," ")," ",R.placeholder]})})]}),nt&&jsxs(Text,{color:e.red,dimColor:true,children:[" ",nt]}),Xt&&jsx(Text,{color:e.red,children:" Fix the error above"})]})})(),R.type==="select"&&jsxs(Box,{flexDirection:"column",children:[bn.map(($,I)=>{let k=I+qt,B=k===Gt,q=String(k+1).padStart(_t.length>=10?2:1);return jsxs(Box,{children:[jsx(Text,{color:B?e.amber:e.ghost,children:B?" \u25B8 ":` ${q} `}),jsx(Text,{color:B?e.white:e.silver,bold:B,children:$.label}),$.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",Ve," ",$.hint.replace(/\n/g," ")]})]},$.value)}),nt&&jsxs(Text,{color:e.red,dimColor:true,children:[" ",nt]}),Xt&&jsx(Text,{color:e.red,children:" Fix the error above"})]}),R.type==="multiselect"&&jsxs(Box,{flexDirection:"column",children:[bn.map(($,I)=>{let B=I+qt===Gt,q=ut.has($.value);return jsxs(Box,{children:[jsx(Text,{color:B?e.amber:e.ghost,children:B?" \u25B8 ":" "}),jsx(Text,{color:q?e.green:e.dim,children:q?"[\u2713]":"[ ]"}),jsxs(Text,{color:B?e.white:e.silver,bold:B,children:[" ",$.label]}),$.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",Ve," ",$.hint.replace(/\n/g," ")]})]},$.value)}),ut.size>0&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","\u2514"," ",ut.size," selected"]})})]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.ghost,children:[" ",R.type==="select"?"\u2191\u2193 select Enter confirm":R.type==="multiselect"?"\u2191\u2193 move Space toggle Enter confirm":R.type==="textarea"?`Enter newline ${Br}+Enter confirm \u2190\u2191\u2192\u2193 navigate`:De?"\u2191\u2193 browse Enter select \u2191 back to input":R.suggestions?"\u2190\u2192 move Enter confirm \u2193 browse templates":"\u2190\u2192 move Enter confirm",b&&(R.type==="text"||R.type==="textarea")?` ${Br}+V paste image`:""," Esc ",y>0?"back":"cancel"]}),T&&jsxs(Text,{color:e.amber,children:[" ",T]})]})]})}var ri=ao.memo(function({agents:n,selected:o,msgCounts:r,colorMap:l,maxHeight:f,onConfirm:b,onCancel:T}){let [x,y]=useState(0),[C,M]=useState(()=>new Set(o));useMemo(()=>C.size===0||C.size===n.length,[C.size,n.length]);let S=Math.max(3,f-5),H=useMemo(()=>{if(n.length<=S)return 0;let P=Math.floor(S/2),j=n.length-S;return Math.min(j,Math.max(0,x-P))},[x,n.length,S]),V=n.slice(H,H+S);useInput((P,j)=>{if(j.upArrow){y(O=>O>0?O-1:n.length-1);return}if(j.downArrow){y(O=>O<n.length-1?O+1:0);return}if(P===" "){let O=n[x];if(!O)return;M(L=>{let N=new Set(L);return N.has(O.id)?N.delete(O.id):N.add(O.id),N});return}if(P==="a"||P==="A"){M(O=>new Set);return}if(j.return){b(new Set(C));return}if(j.escape){T();return}});let F=C.size===0?n.length:C.size;return jsxs(Box,{flexDirection:"column",borderStyle:"round",borderColor:e.amber,paddingX:1,children:[jsxs(Box,{gap:1,children:[jsx(Text,{color:e.amber,bold:true,children:" \u25C8 Agent Filter"}),jsxs(Text,{color:e.dim,children:[fe," ",F,"/",n.length," selected"]})]}),jsx(Text,{color:e.ghost,children:Ve.repeat(36)}),V.map((P,j)=>{let L=j+H===x,N=C.size===0||C.has(P.id),E=l.get(P.id)??e.silver,W=r.get(P.id)??0;return jsxs(Box,{gap:0,children:[jsx(Text,{color:L?e.amber:e.ghost,children:L?" \u25B8 ":" "}),jsx(Text,{color:N?e.green:e.ghost,children:N?"[\u2713]":"[ ]"}),jsxs(Text,{color:L?E:N?e.silver:e.dim,bold:L,children:[" ",P.name]}),W>0&&jsxs(Text,{color:e.dim,children:[" ",fe,W]})]},P.id)}),n.length>S&&jsxs(Text,{color:e.ghost,children:[" ",H>0?"\u2191":" "," ",H+S<n.length?"\u2193":" "," ",x+1,"/",n.length]}),jsx(Text,{color:e.ghost,children:Ve.repeat(36)}),jsxs(Text,{color:e.dim,children:[" Space toggle"," ",fe," ","a all"," ",fe," ","Enter confirm"," ",fe," ","Esc cancel"]})]})});var Ql={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},ec={system:"System",lifecycle:"Lifecycle",output:"Output",tool:"Tool calls",result:"Results",error:"Errors",file:"Files",info:"Info"},tc={system:e.purple,lifecycle:e.cyan,output:e.white,tool:e.blue,result:e.green,error:e.red,file:e.purple,info:e.silver},wt=["system","lifecycle","output","tool","result","error","file","info"],ai=[{key:"1",label:"all",types:wt},{key:"2",label:"text",types:["output"]},{key:"3",label:"tools",types:["tool","result","file"]},{key:"4",label:"errors",types:["error"]},{key:"5",label:"events",types:["lifecycle","system"]}],li=ao.memo(function({selected:n,typeCounts:o,onConfirm:r,onCancel:l}){let[f,b]=useState(0),[T,x]=useState(()=>new Set(n)),y=useMemo(()=>T.size===wt.length||wt.every(M=>T.has(M)),[T]);useInput((M,A)=>{if(A.upArrow){b(S=>S>0?S-1:wt.length-1);return}if(A.downArrow){b(S=>S<wt.length-1?S+1:0);return}if(M===" "){let S=wt[f];if(!S)return;x(H=>{let V=new Set(H);return V.has(S)?V.delete(S):V.add(S),V});return}if(M==="a"||M==="A"){x(S=>S.size===wt.length?new Set:new Set(wt));return}for(let S of ai)if(M===S.key){x(new Set(S.types));return}if(A.return){let S=T.size===0?new Set(wt):new Set(T);r(S);return}if(A.escape){l();return}});let C=y?wt.length:T.size;return jsxs(Box,{flexDirection:"column",borderStyle:"round",borderColor:e.amber,paddingX:1,children:[jsxs(Box,{gap:1,children:[jsx(Text,{color:e.amber,bold:true,children:" \u25C8 Type Filter"}),jsxs(Text,{color:e.dim,children:[fe," ",C,"/",wt.length," selected"]})]}),jsx(Text,{color:e.ghost,children:Ve.repeat(36)}),wt.map((M,A)=>{let S=A===f,H=T.has(M),V=o[M]??0,F=tc[M];return jsxs(Box,{gap:0,children:[jsx(Text,{color:S?e.amber:e.ghost,children:S?" \u25B8 ":" "}),jsx(Text,{color:H?e.green:e.ghost,children:H?"[\u2713]":"[ ]"}),jsxs(Text,{color:S?F:e.dim,children:[" ",Ql[M]," "]}),jsx(Text,{color:S?F:H?e.silver:e.dim,bold:S,children:ec[M]}),V>0&&jsxs(Text,{color:e.dim,children:[" ",fe,V]})]},M)}),jsx(Text,{color:e.ghost,children:Ve.repeat(36)}),jsxs(Box,{gap:0,children:[jsx(Text,{color:e.dim,children:" "}),ai.map((M,A)=>jsxs(ao.Fragment,{children:[A>0&&jsxs(Text,{color:e.ghost,children:[" ",fe," "]}),jsx(Text,{color:e.amberDim,children:M.key}),jsxs(Text,{color:e.dim,children:["=",M.label]})]},M.key))]}),jsxs(Text,{color:e.dim,children:[" Space toggle"," ",fe," ","a all"," ",fe," ","Enter confirm"," ",fe," ","Esc cancel"]})]})});var Wo="\u256D",zo="\u256E",Vo="\u2570",Ho="\u256F",Ie="\u2502";function tn({children:t,cw:n}){return jsxs(Text,{children:[jsx(Text,{color:e.ghost,children:Ie}),jsxs(Text,{children:[" ",t.padEnd(n)," "]}),jsx(Text,{color:e.ghost,children:Ie})]})}function Go({cw:t}){return jsx(tn,{cw:t,children:""})}function ci({width:t,height:n}){let o=Math.min(t-4,50),r=o-6,l=Te(o-2);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[jsxs(Text,{color:e.ghost,children:[Wo,l,zo]}),jsx(tn,{cw:r,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.amber,children:Ht}),jsx(Text,{color:e.white,bold:true,children:" Welcome to Orch"}),jsx(Text,{children:" ".repeat(Math.max(0,r-15-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(tn,{cw:r,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.silver,children:"Press N to create your first task".padEnd(r)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(tn,{cw:r,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.amber,children:"N"}),jsx(Text,{color:e.gray,children:" new task"}),jsx(Text,{children:" ".repeat(Math.max(0,r-1-1-8))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(tn,{cw:r,children:""}),jsxs(Text,{color:e.ghost,children:[Vo,l,Ho]})]})}function di({step:t,width:n}){let o=Math.min(n-4,50),r=o-6,l=Te(o-2),f,b=null;if(t==="task_created")f="Press R to run task",b={key:"R",label:"run task"};else if(t==="run_started")f="Agent is running your task...";else return null;return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[jsxs(Text,{color:e.ghost,children:[Wo,l,zo]}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.amber,children:Ht}),jsxs(Text,{color:e.silver,children:[" ",f.padEnd(b?r-2-b.key.length-1-b.label.length-2:r-2)]}),b&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",b.key]}),jsxs(Text,{color:e.gray,children:[" ",b.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsxs(Text,{color:e.ghost,children:[Vo,l,Ho]})]})}function ui({width:t}){let n=Math.min(t-4,50),o=n-6,r=Te(n-2);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[jsxs(Text,{color:e.ghost,children:[Wo,r,zo]}),jsx(tn,{cw:o,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.green,bold:true,children:"First task completed!"}),jsx(Text,{children:" ".repeat(Math.max(0,o-21))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(tn,{cw:o,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.silver,children:"Type / to see all commands".padEnd(o)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(tn,{cw:o,children:""}),jsxs(Text,{color:e.ghost,children:[Vo,r,Ho]})]})}function jo({count:t,config:n,width:o}){if(t>=3)return null;let r=Math.min((o??44)-4,50),l=r-6,f=Te(r-2),b=jsxs(Text,{color:e.ghost,children:[Wo,f,zo]}),T=jsxs(Text,{color:e.ghost,children:[Vo,f,Ho]});if(t>0){let y=n.hints[0],C=y?` ${y.key} ${y.label}`:"";return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[b,jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.amber,children:Ht}),jsxs(Text,{color:e.silver,children:[" ",n.nudge.padEnd(l-2-C.length)]}),y&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",y.key]}),jsxs(Text,{color:e.gray,children:[" ",y.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),T]})}let x=n.hints.reduce((y,C,M)=>y+C.key.length+1+C.label.length+(M>0?3:0),0);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[b,jsx(Go,{cw:l}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.amber,children:Ht}),jsxs(Text,{color:e.white,bold:true,children:[" ",n.title]}),jsx(Text,{children:" ".repeat(Math.max(0,l-n.title.length-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(Go,{cw:l}),n.description.map((y,C)=>jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),jsx(Text,{color:e.silver,children:y.padEnd(l)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]},C)),jsx(Go,{cw:l}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[Ie," "]}),n.hints.map((y,C)=>jsxs(ao.Fragment,{children:[C>0&&jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amber,children:y.key}),jsxs(Text,{color:e.gray,children:[" ",y.label]})]},C)),jsx(Text,{children:" ".repeat(Math.max(0,l-x))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:Ie})]}),jsx(Go,{cw:l}),T]})}var oc=2,pi=360,rc={done:4e3,failed:8e3,review:6e3},sc={done:"\u2713",failed:"\u2715",review:Zt},ic={done:e.green,failed:e.red,review:e.blue},ac={done:e.successBg,failed:e.errorBg,review:e.infoBg};function lc(t){let n=t.agentName??"Agent";switch(t.type){case "done":return `Task completed by ${n}`;case "failed":return "Task failed \u2014 press Enter for details";case "review":return "Task ready for review \u2014 press A to approve"}}var cc=ao.memo(function({toast:n,onDismiss:o}){let[r,l]=useState(true),[f,b]=useState(false);useEffect(()=>{let S=setTimeout(()=>l(false),pi);return ()=>clearTimeout(S)},[]),useEffect(()=>{let S=rc[n.type],H=setTimeout(()=>b(true),S),V=setTimeout(()=>o(n.id),S+pi);return ()=>{clearTimeout(H),clearTimeout(V);}},[n.id,n.type,o]);let T=r||f,x=sc[n.type],y=ic[n.type],C=ac[n.type],M=lc(n),A=n.title.length>40?n.title.slice(0,39)+"\u2026":n.title;return jsx(Box,{children:jsxs(Text,{backgroundColor:C,children:[jsxs(Text,{color:T?e.dim:y,children:[" ",x," "]}),jsx(Text,{color:T?e.dim:e.white,bold:!T,children:A}),jsxs(Text,{color:T?e.dim:e.silver,children:[" ",M," "]})]})})}),bi=ao.memo(function({toasts:n,onDismiss:o}){let r=n.slice(0,oc);return r.length===0?null:jsx(Box,{flexDirection:"column",children:r.map(l=>jsx(cc,{toast:l,onDismiss:o},l.id))})});var gc="\u256D",mc="\u256E",fc="\u2570",pc="\u256F",ct="\u2502",Pr=[{key:"\u2191\u2193/j/k",label:"Navigate"},{key:"Tab/\u2190\u2192",label:"Switch tabs"},{key:"Enter",label:"Detail view"},{key:"G",label:"Goals tab"},{key:"T",label:"Tasks tab"},{key:"A",label:"Agents tab"},{key:"L",label:"Logs tab"}],Nr=[{key:"N",label:"New item"},{key:"E",label:"Edit"},{key:"D",label:"Delete"},{key:"R",label:"Run task"},{key:"S",label:"Show / Stop"},{key:"C",label:"Cancel"},{key:"A",label:"Approve"},{key:"X",label:"Reject"},{key:"U",label:"Autonomous"},{key:"Z",label:"Undo delete"}],Dr=[{key:"/",label:"Command mode"},{key:"/task add",label:"Create task"},{key:"/run",label:"Execute"},{key:"/watch",label:"Auto-dispatch"},{key:"/config",label:"Settings"},{key:"/help",label:"Help"},{key:"/quit",label:"Exit"}],Fn=10,Ut=22;function Fr(t){let n=Math.max(0,Math.floor((Ut-t.length-2)/2)),o=Math.max(0,Ut-n-t.length-2);return Te(n)+" "+t+" "+Te(o)}var Ti=ao.memo(function({width:n,height:o}){let r=Ut*3+3+3+2,l=r+2,f=Te(l-2),b="KEYBOARD SHORTCUTS",T=Math.max(0,Math.floor((r-b.length)/2)),x=Math.max(0,r-T-b.length),y="Press any key to dismiss",C=Math.max(0,Math.floor((r-y.length)/2)),M=Math.max(0,r-C-y.length),A=Math.max(Pr.length,Nr.length,Dr.length),S=A+10,H=Math.max(0,Math.floor((o-S)/2)),V=[];for(let L=0;L<A;L++){let N=L<Pr.length?Pr[L]:null,E=L<Nr.length?Nr[L]:null,W=L<Dr.length?Dr[L]:null;V.push(jsxs(Text,{children:[jsx(Text,{color:e.amber,children:ct}),jsx(Text,{children:" "}),N?jsxs(Fragment,{children:[jsx(Text,{color:e.amber,bold:true,children:N.key.padEnd(Fn)}),jsx(Text,{color:e.silver,children:N.label.padEnd(Ut-Fn)})]}):jsx(Text,{children:" ".repeat(Ut)}),jsxs(Text,{color:e.dim,children:[" ",ct," "]}),E?jsxs(Fragment,{children:[jsx(Text,{color:e.amber,bold:true,children:E.key.padEnd(Fn)}),jsx(Text,{color:e.silver,children:E.label.padEnd(Ut-Fn)})]}):jsx(Text,{children:" ".repeat(Ut)}),jsxs(Text,{color:e.dim,children:[" ",ct," "]}),W?jsxs(Fragment,{children:[jsx(Text,{color:e.amber,bold:true,children:W.key.padEnd(Fn)}),jsx(Text,{color:e.silver,children:W.label.padEnd(Ut-Fn)})]}):jsx(Text,{children:" ".repeat(Ut)}),jsx(Text,{children:" "}),jsx(Text,{color:e.amber,children:ct})]},`r${L}`));}let F=L=>jsxs(Text,{children:[jsx(Text,{color:e.amber,children:ct}),jsx(Text,{children:" ".repeat(r)}),jsx(Text,{color:e.amber,children:ct})]},L),P=Fr("NAVIGATION"),j=Fr("ACTIONS"),O=Fr("COMMANDS");return jsxs(Box,{flexDirection:"column",paddingX:Math.max(0,Math.floor((n-l)/2)),marginTop:H,children:[jsxs(Text,{color:e.amber,children:[gc,f,mc]}),F("e1"),jsxs(Text,{children:[jsx(Text,{color:e.amber,children:ct}),jsx(Text,{children:" ".repeat(T)}),jsx(Text,{color:e.amber,bold:true,children:b}),jsx(Text,{children:" ".repeat(x)}),jsx(Text,{color:e.amber,children:ct})]}),F("e2"),jsxs(Text,{children:[jsx(Text,{color:e.amber,children:ct}),jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:P}),jsxs(Text,{color:e.dim,children:[" ",ct," "]}),jsx(Text,{color:e.dim,children:j}),jsxs(Text,{color:e.dim,children:[" ",ct," "]}),jsx(Text,{color:e.dim,children:O}),jsx(Text,{children:" "}),jsx(Text,{color:e.amber,children:ct})]}),F("e3"),V,F("e4"),jsxs(Text,{children:[jsx(Text,{color:e.amber,children:ct}),jsx(Text,{children:" ".repeat(C)}),jsx(Text,{color:e.dim,children:y}),jsx(Text,{children:" ".repeat(M)}),jsx(Text,{color:e.amber,children:ct})]}),F("e5"),jsxs(Text,{color:e.amber,children:[fc,f,pc]})]})});var Si=[{value:"claude-opus-4-6",label:"Claude Opus 4.6",hint:"most capable"},{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",hint:"fast, balanced"},{value:"claude-haiku-4-6",label:"Claude Haiku 4.6",hint:"fastest, cheapest"},{value:"claude-sonnet-4-5-20250929",label:"Claude Sonnet 4.5",hint:"extended thinking"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5",hint:"legacy"}],ki=[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex",hint:"default, balanced"},{value:"gpt-5.4",label:"GPT-5.4",hint:"latest"},{value:"gpt-5",label:"GPT-5",hint:"capable"},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",hint:"fast"},{value:"o3",label:"o3",hint:"reasoning"},{value:"o4-mini",label:"o4-mini",hint:"fast reasoning"},{value:"gpt-5-mini",label:"GPT-5 Mini",hint:"light"},{value:"gpt-5-nano",label:"GPT-5 Nano",hint:"cheapest"},{value:"codex-mini-latest",label:"Codex Mini",hint:"legacy"}],Ci=[{value:"auto",label:"Auto",hint:"let Cursor decide"},{value:"composer-1.5",label:"Composer 1.5",hint:"latest agent"},{value:"composer-1",label:"Composer 1",hint:"stable agent"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex",hint:"OpenAI"},{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",hint:"Anthropic"}],Ii=[{value:"",label:"Default",hint:"use model configured in opencode"},{value:"openrouter/anthropic/claude-sonnet-4.6",label:"Claude Sonnet 4.6",hint:"fast, balanced"},{value:"openrouter/anthropic/claude-opus-4.6",label:"Claude Opus 4.6",hint:"most capable"},{value:"openrouter/google/gemini-2.5-pro",label:"Gemini 2.5 Pro",hint:"Google"},{value:"openrouter/google/gemini-2.5-flash",label:"Gemini 2.5 Flash",hint:"Google, fast"},{value:"openrouter/deepseek/deepseek-v3.2",label:"DeepSeek V3.2",hint:"open-source"},{value:"openrouter/deepseek/deepseek-r1:free",label:"DeepSeek R1",hint:"reasoning, free"},{value:"opencode/big-pickle",label:"Big Pickle",hint:"opencode native"}],Mi=[{value:"",label:"Default",hint:"use shell adapter default"}],vi=[{value:"",label:"Default",hint:"no override \u2014 use model default"},{value:"high",label:"High",hint:"deepest reasoning, best quality, slowest"},{value:"medium",label:"Medium",hint:"balanced speed and quality"},{value:"low",label:"Low",hint:"fastest responses, minimal reasoning"}],Ri=new Set(["claude"]),hc=[{value:"claude",label:"Claude",hint:"Claude Code CLI"},{value:"opencode",label:"OpenCode",hint:"OpenCode \u2014 multi-provider"},{value:"codex",label:"Codex",hint:"OpenAI Codex CLI"},{value:"cursor",label:"Cursor",hint:"Cursor Agent CLI"},{value:"shell",label:"Shell",hint:"custom shell command"}],_i=[{value:"1",label:"P1 Critical",hint:"urgent, do first"},{value:"2",label:"P2 High",hint:"important"},{value:"3",label:"P3 Medium",hint:"default priority"},{value:"4",label:"P4 Low",hint:"nice to have"}],yi=60;function Ai(t){return t.filter(n=>n.status!=="disabled").map(n=>{let o=(n.role??"").split(`
11
+ `)[0].trim(),r=o.length>yi?o.slice(0,yi-1)+"\u2026":o,l=r?`[${n.adapter}] ${r}`:n.adapter;return {value:n.id,label:n.name,hint:l}})}function qo(t,n="Auto-assign",o="orchestrator picks the best agent"){return [{value:"",label:n,hint:o},...Ai(t)]}var Wr=[{value:"",label:"Skip",hint:"no role description"},{value:"Full-stack developer",label:"Full-stack developer",hint:"general purpose"},{value:"Frontend developer",label:"Frontend developer",hint:"React, CSS, UI"},{value:"Backend developer",label:"Backend developer",hint:"APIs, databases, services"},{value:"DevOps engineer",label:"DevOps engineer",hint:"CI/CD, infra, deploys"},{value:"QA / Test engineer",label:"QA / Test engineer",hint:"testing, quality"},{value:"Code reviewer",label:"Code reviewer",hint:"review PRs, find bugs"},{value:"Technical writer",label:"Technical writer",hint:"docs, READMEs"},{value:"__custom__",label:"Custom...",hint:"type your own"}];function $i(t){return [{value:"",label:"None",hint:"no team"},...(t??[]).filter(n=>n.status==="active").map(n=>({value:n.id,label:n.name,hint:`${n.members.length} members`}))]}function Bi(){return [{id:"shop_template",label:"Agent Shop \u2014 choose a template",type:"select",options:a$2.map(t=>({value:t.key,label:t.name,hint:t.description}))}]}function zr(t,n){return t.map(o=>{switch(o.id){case "name":return {...o,defaultValue:n.name};case "adapter":return {...o,defaultValue:n.adapter};case "model":return {...o,defaultValue:n.model};case "role":return {...o,defaultValue:"__custom__"};case "role_custom":return {...o,defaultValue:n.role,skip:void 0};case "skills":return {...o,defaultValue:n.skills.join(", ")};case "approval_policy":return {...o,defaultValue:n.approval_policy};default:return o}})}function Ko(t,n){let o=$i(n);return [{id:"name",label:"Agent name",type:"text",placeholder:"e.g. alpha, frontend-bot, reviewer",required:true,validate:r=>r.trim()?t?.some(l=>l.name===r.trim())?"Agent with this name already exists":null:"Name is required",suggestions:a$2.map(r=>({value:r.key,label:r.name,hint:r.description}))},{id:"adapter",label:"Provider",type:"select",options:hc},{id:"model",label:"Model",type:"select",getOptions:r=>r.adapter==="opencode"?Ii:r.adapter==="codex"?ki:r.adapter==="cursor"?Ci:r.adapter==="shell"?Mi:Si},{id:"effort",label:"Reasoning effort",type:"select",options:vi,skip:r=>!Ri.has(r.adapter??"")},{id:"role",label:"Role / specialization",type:"select",options:Wr},{id:"role_custom",label:"Describe the role",type:"textarea",placeholder:"e.g. Specialist in React and TypeScript",skip:r=>r.role!=="__custom__"},{id:"skills",label:"Skills (comma-separated)",type:"text",placeholder:"e.g. feature-dev:feature-dev, testing-suite:generate-tests"},{id:"approval_policy",label:"Approval policy",type:"text",skip:()=>true},{id:"team",label:"Join team",type:"select",options:o,skip:()=>o.length<=1}]}function Ei(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0,o=t.skills?t.skills.split(",").map(f=>f.trim()).filter(Boolean):void 0,r=t.approval_policy||"auto",l=t.effort||void 0;return {name:t.name,adapter:t.adapter||"claude",role:n,model:t.model||void 0,effort:l,approval_policy:r,skills:o,team_id:t.team||void 0}}function Oi(t,n){let o=Ai(t);return [{id:"name",label:"Team name",type:"text",placeholder:"e.g. frontend, backend, qa",required:true,validate:r=>r.trim()?n?.some(l=>l.name===r.trim())?"Team with this name already exists":null:"Name is required"},{id:"lead",label:"Team lead",type:"select",options:o},{id:"members",label:"Team members",type:"multiselect",getOptions:r=>o.filter(l=>l.value!==r.lead),skip:r=>!o.some(l=>l.value!==r.lead)},{id:"description",label:"Description",type:"textarea",placeholder:"Optional team purpose..."}]}function Li(t){let n=t.members?t.members.split(",").filter(Boolean):[];return {name:t.name,lead_agent_id:t.lead,member_agent_ids:n.length>0?n:void 0,description:t.description||void 0}}function Pi(t){let n=qo(t);return [{id:"title",label:"Task title",type:"text",placeholder:"What needs to be done?",required:true,validate:o=>o.trim()?null:"Title is required"},{id:"priority",label:"Priority",type:"select",options:_i,defaultValue:"3",validate:o=>{let r=Number(o);return !Number.isInteger(r)||r<1||r>4?"Priority must be 1-4":null}},{id:"assignee",label:"Assignee",type:"select",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Optional details, context, acceptance criteria..."}]}function Ni(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description||void 0}}function Di(t,n){let o=qo(n,"None / Auto","remove assignee");return [{id:"title",label:"Task title",type:"text",defaultValue:t.title,required:true,validate:r=>r.trim()?null:"Title is required"},{id:"priority",label:"Priority",type:"select",options:_i,defaultValue:String(t.priority),validate:r=>{let l=Number(r);return !Number.isInteger(l)||l<1||l>4?"Priority must be 1-4":null}},{id:"assignee",label:"Assignee",type:"select",options:o,defaultValue:t.assignee??"",skip:()=>o.length<=1},{id:"description",label:"Description",type:"textarea",defaultValue:t.description||"",placeholder:"Optional details..."}]}function Fi(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description??""}}function Gi(t,n,o){let r=Wr.find(x=>x.value===t.role),l=r?t.role:t.role?"__custom__":"",f=t.adapter==="opencode"?Ii:t.adapter==="codex"?ki:t.adapter==="cursor"?Ci:t.adapter==="shell"?Mi:Si,b=$i(o),T=o?.find(x=>x.members.some(y=>y.agent_id===t.id))?.id;return [{id:"name",label:"Agent name",type:"text",defaultValue:t.name,required:true,validate:x=>x.trim()?n?.some(y=>y.id!==t.id&&y.name===x.trim())?"Agent with this name already exists":null:"Name is required"},{id:"model",label:"Model",type:"select",options:f,defaultValue:t.config.model??""},{id:"effort",label:"Reasoning effort",type:"select",options:vi,defaultValue:t.config.effort??"",skip:()=>!Ri.has(t.adapter)},{id:"role",label:"Role / specialization",type:"select",options:Wr,defaultValue:l},{id:"role_custom",label:"Describe the role",type:"textarea",defaultValue:t.role&&!r?t.role:"",placeholder:"e.g. Specialist in React and TypeScript",skip:x=>x.role!=="__custom__"},{id:"team",label:"Team",type:"select",options:b,defaultValue:T??"",skip:()=>b.length<=1}]}var xc=[{value:"1",label:"1 agent",hint:"~0.5 GB RAM, 1 subprocess"},{value:"2",label:"2 agents",hint:"~1 GB RAM, 2 subprocesses"},{value:"3",label:"3 agents",hint:"~1.5 GB RAM, 3 subprocesses"},{value:"4",label:"4 agents",hint:"~2 GB RAM, 4 subprocesses"},{value:"6",label:"6 agents",hint:"~3 GB RAM, 6 subprocesses"},{value:"8",label:"8 agents",hint:"~4 GB RAM, 8 subprocesses"},{value:"10",label:"10 agents",hint:"~5 GB RAM, 10 subprocesses"}],bc=[{value:"all",label:"All",hint:"show everything"},{value:"text",label:"Text",hint:"agent output only"},{value:"tools",label:"Tools",hint:"tool calls, results, files"},{value:"errors",label:"Errors",hint:"errors only"},{value:"events",label:"Events",hint:"lifecycle, system events"}],wi=[{value:"true",label:"On"},{value:"false",label:"Off"}];function Wi(t,n,o){let r=o??{toast:true,bell:false};return [{id:"activity_filter",label:"Activity filter preset",type:"select",options:bc,defaultValue:t},{id:"max_concurrent",label:"Max concurrent agents",type:"select",options:xc,defaultValue:String(n)},{id:"notifications_toast",label:"Toast notifications",type:"select",options:wi,defaultValue:String(r.toast)},{id:"notifications_bell",label:"Bell on completion",type:"select",options:wi,defaultValue:String(r.bell)}]}function zi(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0,o=t.effort||void 0;return {name:t.name,role:n,model:t.model||void 0,effort:o,team_id:t.team||void 0}}function Yo(t){let n=qo(t,"Any agent","auto-assign to autonomous agents");return [{id:"title",label:"Goal title",type:"text",placeholder:'e.g. "Implement OAuth2 login with Google and GitHub"',description:"Be specific \u2014 agents work better with clear, measurable objectives",required:true,validate:o=>o.trim()?null:"Title is required"},{id:"assignee",label:"Assignee",type:"select",description:"Assigned agent gets autonomous mode \u2014 it will plan and execute without prompts",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Success criteria, constraints, technical context...",description:'Context matters \u2014 include tech stack, constraints, and what "done" looks like'}]}function Vi(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description||void 0}}function Hi(t,n){let o=qo(n,"Any agent","auto-assign");return [{id:"title",label:"Goal title",type:"text",defaultValue:t.title,description:"Be specific \u2014 agents work better with clear, measurable objectives",required:true,validate:r=>r.trim()?null:"Title is required"},{id:"assignee",label:"Assignee",type:"select",description:"Assigned agent gets autonomous mode \u2014 it will plan and execute without prompts",options:o,defaultValue:t.assignee??"",skip:()=>o.length<=1},{id:"description",label:"Description",type:"textarea",defaultValue:t.description||"",placeholder:"Success criteria, constraints, technical context...",description:'Context matters \u2014 include tech stack, constraints, and what "done" looks like'}]}function ji(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description??""}}var Ui=10,Xi=500,tr=2048,hn=500,qi=5,Vr=new Set(["todo","failed","cancelled"]),Sc={title:"Goals",description:["Define what your team should achieve.","The orchestrator breaks goals into tasks","and assigns them to agents automatically."],hints:[{key:"N",label:"new goal"},{key:"/",label:"commands"}],nudge:"Add more goals to keep your team focused."},kc={title:"Tasks",description:["Units of work dispatched to agents.","Create them manually or let goals","generate them automatically."],hints:[{key:"N",label:"new task"},{key:"W",label:"start orchestrator"}],nudge:"Add more tasks to keep agents busy."},Cc={title:"Agents",description:["AI workers that execute your tasks.","Each agent uses an adapter (claude, codex,","cursor, shell) and has its own role."],hints:[{key:"N",label:"new agent"},{key:"W",label:"start orchestrator"}],nudge:"Add more agents to increase parallelism."},Ki=5e3,Zi=0;function og(){Zi=0;}var Ji=/^\[[\w_]+\]$/;function Qi(t){return Ji.test(t)?{msgType:"lifecycle",color:e.dim}:t.startsWith("\u2699")?{msgType:"tool",color:e.dim}:t.startsWith("\u2190")?{msgType:"result",color:e.dim}:t.startsWith("\u2713")?{msgType:"lifecycle",color:e.dim}:t.startsWith("\u23F3")?{msgType:"info",color:e.silver}:{msgType:"output",color:e.silver}}var jr=["#5faf87","#5fafd7","#af87ff","#d7af00","#5fd7d7","#d787af","#afaf5f","#d7875f"],Ic=" ".repeat(9),nr={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},Qo=["system","lifecycle","output","tool","result","error","file","info"],Gn=[{label:"all",types:Qo},{label:"text",types:["output"]},{label:"tools",types:["tool","result","file"]},{label:"errors",types:["error"]},{label:"events",types:["lifecycle","system"]}];function Hr(t){let o=(Gn.findIndex(r=>r.types.length===t.size&&r.types.every(l=>t.has(l)))+1)%Gn.length;return Gn[o]}function rg({projectName:t,tasks:n,agents:o=[],state:r,onRunTask:l,onCreateTask:f,onCancelTask:b$1,onRetryTask:T,onAssignTask:x,onRunAll:y,onDisableAgent:C,onEnableAgent:M,onSubscribeEvents:A,onRefreshTasks:S,onRefreshAgents:H,onRefreshState:V,onLoadHistory:F,onAddAgent:P,onDeleteAgent:j,onApproveTask:O,onRejectTask:L,onDeleteTask:N,onUpdateTask:E,onUpdateAgent:W,onForceStopAgent:z,onCreateTeam:X,onListTeams:R,onJoinTeam:ae,onLeaveTeam:Ee,onDisbandTeam:Ft,onSetTeamLead:dt,onStartWatch:_e,onStopWatch:Ke,onToggleAutonomous:ut,onRefreshGoals:pt,onCreateGoal:De,onUpdateGoal:Ye,onUpdateGoalStatus:gt,onDeleteGoal:Ze,onGetGoalProgress:nn,onCompleteOnboarding:Ce,initialWatchActive:ht,observerMode:xt,watchError:Xt,messageBatchMs:mt=process.env.VITEST?0:80,initialActivityFilter:kt="all",onSaveActivityFilter:Ue,initialMaxConcurrent:go=a.scheduling.max_concurrent_agents,onSaveMaxConcurrent:Wn,initialNotifications:_t,onSaveNotifications:Gt,version:Wt,latestVersion:zt,onCheckUpdate:on,onBackgroundInstall:rn}){let{exit:nt}=useApp(),{stdout:At}=useStdout(),[xn,zn]=useState(zt),qt=useRef(on);useEffect(()=>{if(zt||!qt.current)return;let i=setTimeout(()=>{qt.current?.().then(p=>{p&&zn(p);}).catch(()=>{});},5e3);return ()=>clearTimeout(i)},[zt]);let[bn,$]=useState(false),I=useRef(false);useEffect(()=>{!xn||!rn||I.current||bn||(I.current=true,rn(xn).then(i=>{i&&$(true);}).catch(()=>{}));},[xn,rn,bn]);let[k,B]=useState({w:At?.columns??80,h:At?.rows??24});useEffect(()=>{if(!At)return;let i=()=>B({w:At.columns,h:At.rows});return At.on("resize",i),()=>{At.off("resize",i);}},[At]);let q=k.w,te=k.h,[le,de]=useState(n),[K,Ae]=useState(o),[we,Vn]=useState(r),[Tn,or]=useState(ht??!!r.pid),[Hn,Ur]=useState([]),[sa,Xr]=useState(void 0),[Kt,mo]=useState(()=>r.onboardingCompleted||(r.stats?.total_tasks_completed??0)>0?"dismissed":Object.keys(r.running??{}).length>0?"run_started":n.length>0?"task_created":"welcome");useEffect(()=>{if(Kt!=="completed")return;let i=setTimeout(()=>{mo("dismissed"),Ce?.().catch(()=>{});},5e3);return ()=>clearTimeout(i)},[Kt,Ce]);let[_,yn]=useState("tasks"),[fo,jn]=useState(0),[rr,qr]=useState(0),[sr,Kr]=useState(0),[$e,Un]=useState(false),[ze,Yr]=useState([]),[Fe,Oe]=useState("none"),[sn,Ct]=useState(""),[bt,Je]=useState(null),[an,Xn]=useState([]),[$t,ir]=useState(false),[Zr,ia]=useState(()=>new Set),[wn,ar]=useState(false),[qn,lr]=useState(false),[Jr,Qr]=useState(()=>new Set(Qo)),[Kn,cr]=useState(-1),[aa,Yn]=useState(0),[Sn,dr]=useState(()=>{let i=Gn.find(p=>p.label===kt);return new Set(i?.types??Qo)}),po=useMemo(()=>Gn.find(p=>p.types.length===Sn.size&&p.types.every(s=>Sn.has(s)))?.label??"all",[Sn]),ur=useMemo(()=>Sn.size>=Qo.length?ze:ze.filter(i=>Sn.has(i.msgType??"info")),[ze,Sn]),[es,la]=useState(go),[ho,ca]=useState(_t??{toast:true,bell:false}),[da,ts]=useState([]),ua=useRef(0),[gr,ns]=useState(),os=useRef(_);os.current=_;let rs=useRef(le);rs.current=le;let ss=useRef(K);ss.current=K;let xo=useRef(ho);xo.current=ho;let bo=useCallback((i,p)=>{if(!xo.current.toast)return;let s=rs.current.find(h=>h.id===p),d=s?.title??p,u=s?.assignee?ss.current.find(h=>h.id===s.assignee):void 0;ts(h=>{let g=[...h,{id:`toast_${ua.current++}`,type:i,title:d,agentName:u?.name,ts:Date.now()}];return g.length>qi?g.slice(g.length-qi):g}),xo.current.bell&&(i==="failed"||i==="review")&&process.stdout.write("\x07");},[]),ga=useCallback(i=>{ts(p=>p.filter(s=>s.id!==i));},[]),To=ao.useRef(new Po).current,[ma,kn]=useState(0),[is,as]=useState(false),[Zn,fa]=useState(false),[pa,mr]=useState(0),[ha,fr]=useState(0),[pr,Cn]=useState(0),[yo,hr]=useState(false),[xa,Jn]=useState(0),[wo,Yt]=useState(0),[Vt,ls]=useState([]),[In,xr]=useState([]),Mn=useRef(Vt);Mn.current=Vt;let cs=useRef(0),Z=useCallback(async i=>{cs.current=Date.now();let[p,s,d,u,h]=await Promise.all([S?.()??Promise.resolve(le),H?.()??Promise.resolve(K),V?.()??Promise.resolve(we),i?.includeTeams?R?.()??Promise.resolve(Mn.current):Promise.resolve(null),pt?.()??Promise.resolve(Hn)]);de(p),Ae(s),Vn(d),u!==null&&ls(u),Ur(h),ht&&or(!!d.pid);},[S,H,V,R,pt,ht]),vn=useMemo(()=>{let i=new Map;for(let p of Hn)i.set(p.id,p);return i},[Hn]),Le=useMemo(()=>{let i=[...le].sort((h,g)=>(ro[h.status]??9)-(ro[g.status]??9));if(!Zn)return i;let p=[],s=[],d=[],u=new Map;for(let h of i)h.goalId&&vn.has(h.goalId)?(u.has(h.goalId)||(d.push(h.goalId),u.set(h.goalId,[])),u.get(h.goalId).push(h)):s.push(h);for(let h of d)p.push(...u.get(h));return [...p,...s]},[le,Zn,vn]),Bt=is?Le:Le.slice(0,Ui),Rn=Le.length-Bt.length,U=Le[fo],Qn=useMemo(()=>{let i=new Map;for(let p of le)i.set(p.id,p.title);return i},[le]),ln=useMemo(()=>{let i=new Map;for(let p of K)i.set(p.id,p.name);return i},[K]),ba=useMemo(()=>{let i=new Map;for(let p of le)if(p.goalId){let s=i.get(p.goalId);s||(s=[],i.set(p.goalId,s)),s.push(p);}return i},[le]),So=useMemo(()=>{let i=new Map;for(let p=0;p<K.length;p++)i.set(K[p].id,jr[p%jr.length]);return i},[K]),ds=useMemo(()=>{let i=new Map;for(let p of ze)p.agentId&&i.set(p.agentId,(i.get(p.agentId)??0)+1);return i},[ze]),Ta=useMemo(()=>{let i={};for(let p of ze){let s=p.msgType??"info";i[s]=(i[s]??0)+1;}return i},[ze]),{agentTeamMap:_n,activeTeamCount:eo,teamLeadSet:ya}=useMemo(()=>{let i=new Map,p=new Set,s=0;for(let d of Vt)if(d.status==="active"){s++,p.add(d.lead_agent_id);for(let u of d.members)i.set(u.agent_id,d.name);}return {agentTeamMap:i,activeTeamCount:s,teamLeadSet:p}},[Vt]),Ge=useMemo(()=>{let i=[...K];return i.sort((p,s)=>{let d=_n.get(p.id),u=_n.get(s.id);return d&&!u?-1:!d&&u?1:d&&u&&d!==u?d.localeCompare(u):(Rr[p.status]??9)-(Rr[s.status]??9)}),i},[K,_n]),Q=Ge[rr],ft=useMemo(()=>[...Hn].sort((i,p)=>(c[i.status]??9)-(c[p.status]??9)),[Hn]),oe=ft[sr],wa=useMemo(()=>oe?le.filter(i=>i.goalId===oe.id):[],[oe,le]),br=useRef(nn);br.current=nn,useEffect(()=>{if(!oe||!br.current){Xr(void 0);return}let i=false;return br.current(oe.id).then(p=>{i||Xr(p);}).catch(()=>{}),()=>{i=true;}},[oe?.id]);let cn=useRef(new Map),ko=useRef(new Map);useEffect(()=>{for(let[i,p]of Object.entries(we.running))cn.current.set(p.run_id,p.agent_id),ko.current.set(p.run_id,i);if(cn.current.size>Xi){let i=cn.current.size-Xi,p=0;for(let s of cn.current.keys()){if(p++>=i)break;cn.current.delete(s),ko.current.delete(s);}}},[we.running]);let dn=useRef([]),to=useRef(null),Tr=useCallback(()=>{if(to.current=null,dn.current.length===0)return;let i=dn.current;dn.current=[],Yr(p=>{if(i.length>=hn)return i.slice(-hn);let s=hn-i.length;return (p.length>s?p.slice(-s):p).concat(i)});},[]);useEffect(()=>()=>{to.current&&clearTimeout(to.current);},[]);let a=useCallback((i,p,s)=>{let d=new Date,u=d.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),h=s?.detail&&s.detail.length>tr?s.detail.slice(0,tr)+"\u2026[truncated]":s?.detail;dn.current.push({text:i,color:p,time:u,ts:d.getTime(),...s,detail:h}),dn.current.length>hn&&(dn.current=dn.current.slice(-hn)),mt===0?Tr():to.current||(to.current=setTimeout(Tr,mt));},[Tr]);useEffect(()=>{xt?a("Observer mode: watching external orchestrator via disk polling.",e.amber):Xt&&a(`Watch mode failed: ${Xt}. Tasks will not auto-dispatch.`,e.red);},[]),useEffect(()=>{if(!xt)return;let i=3e3,p=setInterval(()=>{Date.now()-cs.current>=i&&Z().catch(()=>{});},i);return ()=>clearInterval(p)},[xt,Z]);let An=useCallback((i,p,s,d)=>{let u={key:++Zi,entityType:i,entityId:p,entityName:s,expiresAt:Date.now()+Ki,needsForceStop:d?.needsForceStop};xr(h=>[...h,u]),a(`\u2717 "${s}" will be deleted in ${Math.round(Ki/1e3)}s \u2014 press Z to undo`,e.yellow);},[a]),Sa=useCallback(()=>{xr(i=>{if(i.length===0)return i;let p=i[i.length-1];return a(`\u21B6 Undo: "${p.entityName}" restored`,e.green),i.slice(0,-1)});},[a]),us=useCallback(async i=>{try{i.entityType==="task"&&N?await N(i.entityId):i.entityType==="agent"?(i.needsForceStop&&z&&await z(i.entityId),j&&await j(i.entityId)):i.entityType==="goal"&&Ze&&await Ze(i.entityId),a(`\u2713 Deleted "${i.entityName}"`,e.green),Z();}catch(p){a(`Failed to delete "${i.entityName}": ${p instanceof Error?p.message:String(p)}`,e.red);}},[N,j,Ze,z,a,Z]),gs=useRef(us);gs.current=us,useEffect(()=>{if(In.length===0)return;let i=setInterval(()=>{let p=Date.now(),s=[];xr(d=>{let u=d.filter(h=>h.expiresAt<=p?(s.push(h),false):true);return s.length>0?u:d});for(let d of s)gs.current(d);},1e3);return ()=>clearInterval(i)},[In.length>0]),useEffect(()=>{if(!F)return;let i=p=>{let s=new Date(p.timestamp).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),d=typeof p.data=="string"?p.data:JSON.stringify(p.data),u,h=e.silver,g="output";if(p.type==="error")u=typeof p.data=="string"?p.data:JSON.stringify(p.data),u=u.slice(0,200),h=e.red,g="error";else if(p.type==="file_changed")u=String(p.data),h=e.purple,g="file";else if(p.type==="done")u="Completed",h=e.green,g="lifecycle";else if(p.type==="tool_call")u=`\u2699 ${p.data?.name??"tool"}()`,h=e.cyan,g="tool";else {let{summary:w}=ra(d);if(!w)return null;u=w;let J=Qi(u);g=J.msgType,h=J.color;}return {text:u,color:h,time:s,ts:new Date(p.timestamp).getTime(),agentId:p.agentId,taskId:p.taskId,msgType:g}};F(p=>{if(p.length===0)return;let s=p.map(i).filter(d=>d!==null);Yr(d=>{let u=[...s,...d];return u.length>hn?u.slice(-hn):u});}).catch(p=>{process.stderr.write(`[TUI] onLoadHistory error: ${p instanceof Error?p.stack??p.message:String(p)}
12
+ `);});},[]),useEffect(()=>{R?.().then(ls).catch(()=>{}),pt?.().then(Ur).catch(()=>{});},[]);let Co=useCallback(()=>{Je({title:"NEW AGENT",steps:Ko(K,Mn.current),kind:"agent"}),Oe("wizard");},[K]),ms=useCallback(()=>{Je({title:"AGENT SHOP",steps:Bi(),kind:"agent_shop"}),Oe("wizard");},[]),Io=useCallback(()=>{Xn([]),Je({title:"NEW TASK",steps:Pi(K),kind:"task"}),Oe("wizard");},[K]),ka=useCallback(async()=>{try{let{detectClipboardType:i,getClipboardImage:p}=await import('./clipboard-service-WVON5ZN4.js'),s=await i();if(s!=="image")return a(s==="text"?"Clipboard has text, not image":"Clipboard is empty",e.dim),s;let d=await p();if(!d)return a("Failed to read clipboard image",e.red),"empty";let{mkdtemp:u,writeFile:h}=await import('fs/promises'),{tmpdir:g}=await import('os'),{join:w}=await import('path'),J=await u(w(g(),"orch-paste-")),Ot=w(J,`clipboard-${Date.now()}.${d.ext}`);return await h(Ot,d.data),Xn(un=>[...un,Ot]),a(`\u{1F4CE} Image attached (${Math.round(d.data.length/1024)}KB)`,e.green),"image"}catch{return a("Clipboard paste failed",e.red),"empty"}},[a]),Ca=useCallback(i=>{Je({title:"EDIT TASK",steps:Di(i,K),kind:"edit_task",targetId:i.id}),Oe("wizard");},[K]),fs=useCallback(()=>{Je({title:"NEW TEAM",steps:Oi(K,Vt),kind:"team"}),Oe("wizard");},[K]),Ia=useCallback(i=>{Je({title:"EDIT AGENT",steps:Gi(i,K,Vt),kind:"edit_agent",targetId:i.id}),Oe("wizard");},[Vt]),ps=useCallback(()=>{Je({title:"SETTINGS",steps:Wi(po,es,ho),kind:"config"}),Oe("wizard");},[po,es]),Ma=useCallback(i=>{Oe("none");let p=bt?.kind,s=bt?.targetId;if(Je(null),p==="agent_shop"){let d=i.shop_template,u=d?b(d):void 0;if(u){let h=Ko(K,Mn.current),g=zr(h,u);Je({title:`NEW AGENT \u2014 ${u.name}`,steps:g,kind:"agent_from_shop"}),Oe("wizard");}else a("No template selected",e.yellow);return}if((p==="agent"||p==="agent_from_shop")&&P){let d=Ei(i);a(`Creating agent "${d.name}"...`,e.amber),P(d.name,d.adapter,{model:d.model,effort:d.effort,role:d.role,approval_policy:d.approval_policy,skills:d.skills}).then(u=>{a(`\u2713 Created agent "${u.name}" (${u.id}, ${u.adapter})`,e.green),d.team_id&&ae?ae(d.team_id,u.id).then(h=>{a(`\u2713 Joined team "${h.name}"`,e.green),Z({includeTeams:true});},h=>a(`Failed to join team: ${h instanceof Error?h.message:String(h)}`,e.red)):Z();},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(p==="team"&&X){let d=Li(i);a(`Creating team "${d.name}"...`,e.amber),X(d).then(u=>{a(`\u2713 Created team "${u.name}" (${u.id}, ${u.members.length} members)`,e.green),Z({includeTeams:true});},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(p==="task"&&f){let d=Ni(i),u=an.length>0?[...an]:void 0;Xn([]),a(`Creating "${d.title}"...`,e.amber),f(d.title,{priority:d.priority,description:d.description,attachments:u}).then(h=>{a(`\u2713 Created "${h.title}" (${h.id})${u?` \u{1F4CE}${u.length}`:""}`,e.green),d.assignee&&x&&x(h.id,d.assignee).catch(()=>{}),Z();},h=>a(`Failed: ${h instanceof Error?h.message:String(h)}`,e.red));}else if(p==="edit_task"&&s&&E){let d=Fi(i),u=an.length>0?[...an]:void 0;Xn([]),a("Updating task...",e.amber),E(s,{...d,attachments:u}).then(h=>{a(`\u2713 Updated "${h.title}"${u?` \u{1F4CE}${u.length}`:""}`,e.green),d.assignee&&x&&x(s,d.assignee).catch(()=>{}),Z();},h=>a(`Failed: ${h instanceof Error?h.message:String(h)}`,e.red));}else if(p==="edit_agent"&&s&&W){let d=zi(i),u=d.team_id??"",h=Vt.find(g=>g.members.some(w=>w.agent_id===s))?.id??"";a("Updating agent...",e.amber),W(s,{name:d.name,role:d.role,model:d.model,effort:d.effort}).then(g=>{a(`\u2713 Updated agent "${g.name}"`,e.green);let w=[];h&&h!==u&&Ee&&w.push(Ee(h,s).then(J=>a(`\u2713 Left team "${J.name}"`,e.green),J=>a(`Failed to leave team: ${J instanceof Error?J.message:String(J)}`,e.red))),u&&u!==h&&ae&&w.push(ae(u,s).then(J=>a(`\u2713 Joined team "${J.name}"`,e.green),J=>a(`Failed to join team: ${J instanceof Error?J.message:String(J)}`,e.red))),Promise.all(w).then(()=>Z({includeTeams:w.length>0}));},g=>a(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(p==="config"){if(i.activity_filter){let g=Gn.find(w=>w.label===i.activity_filter);g&&(dr(new Set(g.types)),Ue?.(g.label));}if(i.max_concurrent){let g=parseInt(i.max_concurrent,10);g>0&&(la(g),Wn?.(g));}let d=i.notifications_toast==="true",u=i.notifications_bell==="true",h={toast:d,bell:u};ca(h),Gt?.(h),a("Settings saved",e.green);}else if(p==="goal"&&De){let d=Vi(i);a(`Creating goal "${d.title}"...`,e.amber),De(d).then(u=>{a(`\u2713 Created goal "${u.title}" (${u.id})`,e.green),Z();},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(p==="edit_goal"&&s&&Ye){let d=ji(i);a("Updating goal...",e.amber),Ye(s,d).then(u=>{a(`\u2713 Updated goal "${u.title}"`,e.green),Z();},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}},[bt,P,f,X,ae,Ee,x,E,W,ut,De,Ye,a,Z,Ue,Wn,ho,Gt,Vt,an]),va=useCallback(()=>{Oe("none"),Je(null),Xn([]);},[]),Ra=useCallback(i=>{let p=b(i);if(!p)return;let s=Ko(K,Mn.current),d=zr(s,p);Je({title:`NEW AGENT \u2014 ${p.name}`,steps:d,kind:"agent_from_shop"}),Oe("wizard");},[]);useEffect(()=>{if(!A)return;let i=null,p=()=>{i||(i=setTimeout(()=>{i=null,Z().catch(()=>{});},150));},s=A(d=>{if(d.type==="agent:started"&&(cn.current.set(d.runId,d.agentId),ko.current.set(d.runId,d.taskId)),Hc(d,a,cn.current,ko.current),d.type==="task:created"?mo(u=>u==="welcome"?"task_created":u):d.type==="agent:started"?mo(u=>u==="task_created"?"run_started":u):d.type==="task:status_changed"&&d.to==="done"&&mo(u=>u==="run_started"?"completed":u),d.type==="task:status_changed"&&(d.to==="done"?bo("done",d.taskId):d.to==="failed"?bo("failed",d.taskId):d.to==="review"&&bo("review",d.taskId),xo.current.toast&&os.current!=="tasks")){let u=d.to==="done"?e.green:d.to==="failed"?e.red:d.to==="review"?e.blue:void 0;u&&ns({tab:"tasks",color:u});}(d.type==="task:status_changed"||d.type==="task:created"||d.type==="task:assigned"||d.type==="agent:started"||d.type==="agent:completed"||d.type==="run:retry"||d.type==="goal:created"||d.type==="goal:status_changed"||d.type==="goal:updated"||d.type==="goal:deleted")&&p();});return ()=>{s(),i&&clearTimeout(i);}},[A,a,Z,bo]);let yr=xt?"observing":Tn?"watching":"idle",_a=we.started_at?g(we.started_at):void 0,hs=we.stats.total_tokens.total,xs=useMemo(()=>{let i={running:0,retrying:0,review:0,todo:0,done:0,failed:0,cancelled:0};for(let p of le)p.status==="in_progress"?i.running++:p.status==="retrying"?i.retrying++:p.status==="review"?i.review++:p.status==="todo"?i.todo++:p.status==="done"?i.done++:p.status==="failed"?i.failed++:p.status==="cancelled"&&i.cancelled++;return {...i,teams:eo}},[le,eo]);xs.running;let Aa=useMemo(()=>({input:we.stats.total_tokens.input??0,output:we.stats.total_tokens.output??0,reasoning:we.stats.total_tokens.reasoning??0,total:hs,cache_read:we.stats.total_tokens.cache_read??0,cache_write:we.stats.total_tokens.cache_write??0}),[we.stats.total_tokens,hs]),It=Math.max(4,te-9),$a=_n.size,Ba=K.length>$a,Ea=eo>0?eo+(Ba?1:0):0,Oa=useMemo(()=>{if(!Zn||vn.size===0)return 0;let i=0,p=new Set,s=false;for(let d of Bt)d.goalId&&vn.has(d.goalId)?p.has(d.goalId)||(p.add(d.goalId),i++):s=true;return s&&i++,i},[Zn,vn,Bt]),La=_==="goals"?ft.length+1:_==="tasks"?Bt.length+1+(Rn>0?1:0)+Oa:_==="agents"?K.length+1+Ea:0,Pa=Math.min(La+1,Math.ceil(It*.5)),Na=_==="logs"?It:Math.max(2,Math.min(Pa,It-4)),Se,Et;if(_==="logs")Se=It,Et=0;else if(yo)Se=0,Et=Math.max(1,It);else {let i=Math.max(3,Math.min(Na+pr,It-4));Se=i,Et=Math.max(1,It-i);}let ve=Math.max(10,q-2),Mt=useMemo(()=>Fe==="command"?Ys(sn):[],[Fe,sn]),$n=It-4-3;useEffect(()=>{pr>$n&&Cn($n),pr<-$n&&Cn(-$n);},[It]),useEffect(()=>{kn(i=>Math.min(i,Math.max(0,Bt.length-Se)));},[Bt.length,Se]),useEffect(()=>{mr(i=>Math.min(i,Math.max(0,Ge.length-Se)));},[Ge.length,Se]),useEffect(()=>{fr(i=>Math.min(i,Math.max(0,ft.length-Se)));},[ft.length,Se]);let Da=useCallback(i=>{let s=i.trim().replace(/^\//,"").split(/\s+/),d=s[0]?.toLowerCase();if(!d)return;let u=h=>h instanceof Error?h.message:String(h);switch(d){case "cancel":{if(!U){a("No task selected",e.yellow);return}if(!b$1)return;a(`Cancelling "${U.title}"...`,e.amber),b$1(U.id).then(()=>{a(`\u2713 Cancelled "${U.title}"`,e.green),Z();},h=>a(`Failed: ${u(h)}`,e.red));return}case "retry":{if(!U){a("No task selected",e.yellow);return}if(!T)return;a(`Retrying "${U.title}"...`,e.amber),T(U.id).then(()=>{a(`\u2713 Retried "${U.title}"`,e.green),Z();},h=>a(`Failed: ${u(h)}`,e.red));return}case "assign":{if(!U){a("No task selected",e.yellow);return}if(!x||!s[1]){a("Usage: assign <agent>",e.yellow);return}a(`Assigning "${U.title}" to ${s[1]}...`,e.amber),x(U.id,s[1]).then(()=>{a(`\u2713 Assigned "${U.title}" to ${s[1]}`,e.green),Z();},h=>a(`Failed: ${u(h)}`,e.red));return}case "task":{let h=s[1]?.toLowerCase();if(h==="add"){let g=s.slice(2).join(" ");if(!g){Io();return}if(!f){a("Create not available",e.yellow);return}a(`Creating "${g}"...`,e.amber),f(g).then(w=>{a(`\u2713 Created "${w.title}" (${w.id})`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="list"){let g=Le.map(w=>` ${w.id} ${w.status.padEnd(11)} ${w.title}`);if(g.length===0)a("No tasks",e.dim);else for(let w of g)a(w,e.cyan);}else if(h==="show"){let g=s[2]?Le.find(w=>w.id===s[2]):U;if(!g){a("No task selected or id given",e.yellow);return}a(`${g.id} ${g.status} P${g.priority} "${g.title}"`,e.cyan),g.assignee&&a(` agent: ${g.assignee}`,e.dim),g.description&&a(` ${g.description.slice(0,100)}`,e.dim);}else if(h==="cancel"){let g=s[2]?Le.find(w=>w.id===s[2]):U;if(!g){a("No task selected or id given",e.yellow);return}if(!b$1)return;a(`Cancelling "${g.title}"...`,e.amber),b$1(g.id).then(()=>{a(`\u2713 Cancelled "${g.title}"`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="retry"){let g=s[2]?Le.find(w=>w.id===s[2]):U;if(!g){a("No task selected or id given",e.yellow);return}if(!T)return;a(`Retrying "${g.title}"...`,e.amber),T(g.id).then(()=>{a(`\u2713 Retried "${g.title}"`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="assign"){let g=s[2]?Le.find(Ot=>Ot.id===s[2]):void 0,w=g??U,J=g?s[3]:s[2];if(!w){a("No task selected or id given",e.yellow);return}if(!J){a("Usage: /task assign [id] <agent>",e.yellow);return}if(!x)return;a(`Assigning "${w.title}" to ${J}...`,e.amber),x(w.id,J).then(()=>{a(`\u2713 Assigned "${w.title}" to ${J}`,e.green),Z();},Ot=>a(`Failed: ${u(Ot)}`,e.red));}else if(h==="approve"){let g=s[2]?Le.find(w=>w.id===s[2]):U;if(!g){a("No task selected or id given",e.yellow);return}if(g.status!=="review"){a(`Cannot approve \u2014 status is ${g.status}`,e.yellow);return}if(!O)return;a(`Approving "${g.title}"...`,e.amber),O(g.id).then(()=>{a(`\u2713 Approved "${g.title}"`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="reject"){let g=s[2]?Le.find(J=>J.id===s[2]):U;if(!g){a("No task selected or id given",e.yellow);return}if(g.status!=="review"){a(`Cannot reject \u2014 status is ${g.status}`,e.yellow);return}if(!L)return;let w=s.slice(s[2]&&Le.find(J=>J.id===s[2])?3:2).join(" ").trim()||void 0;a(`Rejecting "${g.title}"${w?" with feedback":""}...`,e.amber),L(g.id,w).then(()=>{a(`\u2713 Rejected "${g.title}" \u2192 todo`,e.green),Z();},J=>a(`Failed: ${u(J)}`,e.red));}else if(h==="delete"){let g=s[2]?Le.find(w=>w.id===s[2]):U;if(!g){a("No task selected or id given",e.yellow);return}if(g.status==="in_progress"){a("Cannot delete \u2014 task is running",e.yellow);return}if(!N)return;An("task",g.id,g.title);}else a("Usage: /task add|list|show|cancel|retry|assign|approve|reject|delete",e.yellow);return}case "agent":{let h=s[1]?.toLowerCase();if(h==="add"){let g=s[2];if(!g){Co();return}if(!P){a("Agent creation not available",e.yellow);return}let w=s[3];a(`Creating agent "${g}"...`,e.amber),P(g,w).then(J=>{a(`\u2713 Created agent "${J.name}" (${J.id}, ${J.adapter})`,e.green),Z();},J=>a(`Failed: ${u(J)}`,e.red));}else if(h==="list"){let g=Ge.map(w=>` ${w.id} ${w.status.padEnd(8)} ${w.name} (${w.adapter})`);if(g.length===0)a("No agents",e.dim);else for(let w of g)a(w,e.cyan);}else if(h==="disable"){let g=s[2]?Ge.find(w=>w.id===s[2]||w.name===s[2]):Q;if(!g){a("No agent selected or id given",e.yellow);return}if(!C)return;a(`Disabling ${g.name}...`,e.amber),C(g.id).then(()=>{a(`\u2713 Disabled ${g.name}`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="enable"){let g=s[2]?Ge.find(w=>w.id===s[2]||w.name===s[2]):Q;if(!g){a("No agent selected or id given",e.yellow);return}if(!M)return;a(`Enabling ${g.name}...`,e.amber),M(g.id).then(()=>{a(`\u2713 Enabled ${g.name}`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="delete"||h==="remove"){let g=s[2]?Ge.find(w=>w.id===s[2]||w.name===s[2]):Q;if(!g){a("No agent selected or id given",e.yellow);return}if(g.status==="running"){a("Cannot delete \u2014 agent is running",e.yellow);return}if(!j){a("Agent deletion not available",e.yellow);return}An("agent",g.id,g.name);}else if(h==="autonomous"||h==="auto"){let g=s[2]?Ge.find(w=>w.id===s[2]||w.name===s[2]):Q;if(!g){a("No agent selected or id given",e.yellow);return}if(!ut){a("Autonomous toggle not available",e.yellow);return}g.autonomous?(a(`Disabling autonomous mode for "${g.name}"...`,e.amber),ut(g.id,false).then(()=>{a(`${gn} ${g.name} autonomous OFF`,e.cyan),Z();},w=>a(`Failed: ${u(w)}`,e.red))):(a(`Enabling autonomous mode for "${g.name}"...`,e.amber),ut(g.id,true).then(()=>{a(`${gn} ${g.name} autonomous ON`,e.cyan),Z();},w=>a(`Failed: ${u(w)}`,e.red)));}else h==="shop"?ms():a("Usage: /agent add|list|disable|enable|delete|autonomous|shop",e.yellow);return}case "team":{let h=s[1]?.toLowerCase();if(h==="create"||h==="add")fs();else if(h==="list"){let g=Mn.current;if(g.length===0)a("No teams",e.dim);else for(let w of g)a(` ${w.id} ${w.status.padEnd(8)} ${w.name} (${w.members.length} members)`,e.cyan);}else if(h==="join"){if(!ae){a("Join not available",e.yellow);return}let g=s[2],w=s[3]??Q?.id;if(!g||!w){a("Usage: /team join <teamId> [agentId]",e.yellow);return}a(`Joining team ${g}...`,e.amber),ae(g,w).then(J=>{a(`\u2713 Agent joined team "${J.name}"`,e.green),Z({includeTeams:true});},J=>a(`Failed: ${u(J)}`,e.red));}else if(h==="leave"){if(!Ee){a("Leave not available",e.yellow);return}let g=s[2],w=s[3]??Q?.id;if(!g||!w){a("Usage: /team leave <teamId> [agentId]",e.yellow);return}a(`Leaving team ${g}...`,e.amber),Ee(g,w).then(J=>{a(`\u2713 Agent left team "${J.name}"`,e.green),Z({includeTeams:true});},J=>a(`Failed: ${u(J)}`,e.red));}else if(h==="disband"){if(!Ft){a("Disband not available",e.yellow);return}let g=s[2];if(!g){a("Usage: /team disband <teamId>",e.yellow);return}a(`Disbanding team ${g}...`,e.amber),Ft(g).then(()=>{a("\u2713 Team disbanded",e.green),Z({includeTeams:true});},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="set-lead"){if(!dt){a("Set-lead not available",e.yellow);return}let g=s[2],w=s[3];if(!g||!w){a("Usage: /team set-lead <teamId> <agentId>",e.yellow);return}a(`Setting lead for team ${g}...`,e.amber),dt(g,w).then(J=>{a(`\u2713 New lead for team "${J.name}"`,e.green),Z({includeTeams:true});},J=>a(`Failed: ${u(J)}`,e.red));}else a("Usage: /team create|list|join|leave|disband|set-lead",e.yellow);return}case "goal":{let h=s[1]?.toLowerCase();if(h==="add"||h==="create"){let g=s.slice(2).join(" ").trim();if(!g){let w=Yo(K);Je({title:"New Goal",steps:w,kind:"goal"}),Oe("wizard");return}if(!De){a("Goal creation not available",e.yellow);return}a(`Creating goal "${g}"...`,e.amber),De({title:g}).then(w=>{a(`\u2713 Created goal "${w.title}" (${w.id})`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));}else if(h==="list"){let g=ft.map(w=>` ${w.id} ${w.status.padEnd(8)} ${w.title}`);if(g.length===0)a("No goals",e.dim);else for(let w of g)a(w,e.cyan);}else if(h==="show"){let g=s[2]?ft.find(w=>w.id===s[2]):oe;if(!g){a("No goal selected or id given",e.yellow);return}a(`${g.id} ${g.status} "${g.title}"`,e.cyan),g.description&&a(` ${g.description.slice(0,100)}`,e.dim);}else if(h==="status"){let g=s[2]?ft.find(un=>un.id===s[2]):void 0,w=g??oe;if(!w){a("No goal selected or id given",e.yellow);return}let J=s[g?3:2];if(!J||!a$1.includes(J)){a("Usage: /goal status [id] <active|paused|achieved|abandoned>",e.yellow);return}let Ot=J;if(!gt){a("Status update not available",e.yellow);return}a(`Updating goal status to ${Ot}...`,e.amber),gt(w.id,Ot).then(un=>{a(`\u2713 Goal "${un.title}" \u2192 ${Ot}`,e.green),Z();},un=>a(`Failed: ${u(un)}`,e.red));}else if(h==="delete"){let g=s[2]?ft.find(w=>w.id===s[2]):oe;if(!g){a("No goal selected or id given",e.yellow);return}if(!Ze){a("Goal deletion not available",e.yellow);return}An("goal",g.id,g.title);}else a("Usage: /goal add|list|show|status|delete",e.yellow);return}case "run":{let h=s[1]??U?.id;if(!h){a("No task selected or id given",e.yellow);return}if(!l){a("Run not available",e.yellow);return}let g=Le.find(w=>w.id===h);if(g&&!Vr.has(g.status)){a(`Cannot run \u2014 status is ${g.status}`,e.yellow);return}a(`Running ${h}...`,e.amber),l(h).then(()=>{a(`\u2713 Dispatched ${h}`,e.green),Z();},w=>a(`Failed: ${u(w)}`,e.red));return}case "run-all":{if(!y){a("Run-all not available",e.yellow);return}a("Running all todo tasks...",e.amber),y().then(()=>{a("\u2713 Dispatched all todo tasks",e.green),Z();},h=>a(`Failed: ${u(h)}`,e.red));return}case "watch":{if(Tn){a("Watch mode already active",e.yellow);return}if(!_e){a("Watch not available",e.yellow);return}a("Starting watch mode...",e.amber),_e().then(()=>{or(true),a("\u2713 Watch mode started",e.green);},h=>a(`Failed: ${u(h)}`,e.red));return}case "pause":{if(!Tn){a("Watch mode not active",e.yellow);return}if(!Ke){a("Pause not available",e.yellow);return}a("Pausing watch mode...",e.amber),Ke().then(()=>{or(false),a("\u2713 Watch mode paused",e.green);},h=>a(`Failed: ${u(h)}`,e.red));return}case "config":{s[1]?.toLowerCase()==="activity-filter"?dr(g=>{let w=Hr(g);return Ue?.(w.label),a(`Activity filter: ${w.label}`,e.amber),new Set(w.types)}):ps();return}case "status":{let h=le.filter(g=>g.status==="in_progress").length;a(`${yr} ${h} running ${le.length} tasks ${Ge.length} agents`,e.cyan);return}case "help":{for(let[h,g]of Object.entries(fn)){let w=g.sub?" "+g.sub.join("|"):g.args?" "+g.args:"";a(` /${h}${w} \u2014 ${g.help}`,e.silver);}return}case "quit":{nt();return}case "disable":{if(!Q){a("No agent selected",e.yellow);return}if(!C)return;a(`Disabling ${Q.name}...`,e.amber),C(Q.id).then(()=>{a(`\u2713 Disabled ${Q.name}`,e.green),Z();},h=>a(`Failed: ${u(h)}`,e.red));return}case "enable":{if(!Q){a("No agent selected",e.yellow);return}if(!M)return;a(`Enabling ${Q.name}...`,e.amber),M(Q.id).then(()=>{a(`\u2713 Enabled ${Q.name}`,e.green),Z();},h=>a(`Failed: ${u(h)}`,e.red));return}default:a(`Unknown: ${d}. Type /help for commands`,e.yellow);}},[U,Q,Le,Ge,le,yr,Tn,b$1,T,x,y,l,f,C,M,P,O,L,N,ae,Ee,Ft,dt,_e,Ke,a,nt,Z,Io,Co,fs,ps]);useInput((i,p)=>{if(!($t&&(ir(false),i==="?"||p.escape||i==="\x1BOP"))&&!wn){if((p.ctrl||p.meta)&&i==="s"&&Fe==="wizard"&&bt?.kind==="agent"){ms();return}if(Fe!=="none"){if(p.escape){Oe("none"),Ct(""),To.reset();return}if(p.return){let s=sn.trim();if(!s)return;if(Fe==="new_task"){if(!f)return;Oe("none"),Ct(""),a(`Creating "${s}"...`,e.amber),f(s).then(d=>{a(`\u2713 Created "${d.title}" (${d.id})`,e.green),Z();},d=>a(`Failed to create: ${d instanceof Error?d.message:String(d)}`,e.red));}else if(Fe==="command"){let d=s;if(Mt.length>0&&Mt[wo]){let u=Mt[wo],h=u.cmd.replace(/\s+\[.*\]$/,"");if((h.startsWith(s)||s==="/")&&(d=h),u.subs&&!h.includes(" ")){Ct(h+" "),Yt(0);return}}Oe("none"),Ct(""),Yt(0),To.push(d),Da(d);}return}if(p.tab&&Fe==="command"){if(Mt.length>0){let s=Mt[wo];if(s){let d=s.cmd.replace(/\s+\[.*\]$/,"");Ct(d+(s.subs?" ":"")),Yt(0);}}else {let s=Ar(sn);s&&Ct(d=>d+s);}return}if(p.upArrow&&Fe==="command"){if(Mt.length>0)Yt(s=>Math.max(0,s-1));else {let s=To.prev();s!==null&&Ct(s);}return}if(p.downArrow&&Fe==="command"){if(Mt.length>0)Yt(s=>Math.min(Mt.length-1,s+1));else {let s=To.next();Ct(s??"");}return}if(p.backspace||p.delete){Ct(s=>s.slice(0,-1)),Yt(0);return}i&&!p.ctrl&&!p.meta&&(Ct(s=>s+i),Yt(0));return}if(i.toLowerCase()==="q"){nt();return}if(p.escape){if($e){Un(false),Jn(0);return}if(_==="logs"&&Kn>=0){cr(-1),Yn(0);return}return}if((i==="+"||i==="=")&&_!=="logs"){yo?(hr(false),Cn(-Math.floor(It/2))):Cn(s=>Math.max(-$n,s-3));return}if(i==="-"&&_!=="logs"){yo?(hr(false),Cn(Math.floor(It/2))):Cn(s=>Math.min($n,s+3));return}if(i==="M"&&_!=="logs"){hr(s=>!s);return}if(i==="?"){ir(true);return}if(i==="\x1BOP"){ir(true);return}if(i==="/"&&!$e){Oe("command"),Ct("/"),Yt(0);return}if((i==="a"||i==="A")&&_==="logs"&&!$e&&!wn&&!qn){ar(true);return}if(i==="f"&&_==="logs"&&!$e&&!wn&&!qn){lr(true);return}if(i==="F"&&_==="logs"&&!$e&&!wn&&!qn){Qr(s=>new Set(Hr(s).types));return}if((i==="z"||i==="Z")&&In.length>0){Sa();return}if((i==="f"||i==="F")&&(_==="tasks"||_==="agents"||_==="goals")&&!$e){dr(s=>{let d=Hr(s);return Ue?.(d.label),new Set(d.types)});return}if((i==="n"||i==="N")&&_==="tasks"&&!$e&&f){Io();return}if((i==="n"||i==="N")&&_==="agents"&&!$e&&P){Co();return}if((i==="n"||i==="N")&&_==="goals"&&!$e&&De){let s=Yo(K);Je({title:"New Goal",steps:s,kind:"goal"}),Oe("wizard");return}if((i==="e"||i==="E")&&_==="goals"&&oe&&Ye){let s=Hi(oe,K);Je({title:`Edit Goal: ${oe.title}`,steps:s,kind:"edit_goal",targetId:oe.id}),Oe("wizard");return}if((i==="d"||i==="D")&&_==="goals"&&oe&&Ze){An("goal",oe.id,oe.title);return}if((i==="c"||i==="C")&&_==="goals"&&oe&&gt){(oe.status==="active"||oe.status==="paused")&&(a(`Marking goal "${oe.title}" as achieved...`,e.amber),gt(oe.id,"achieved").then(()=>{a(`\u2713 Goal "${oe.title}" achieved`,e.green),Z();},s=>a(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="x"||i==="X")&&_==="goals"&&oe&&gt){(oe.status==="active"||oe.status==="paused")&&(a(`Abandoning goal "${oe.title}"...`,e.amber),gt(oe.id,"abandoned").then(()=>{a(`\u2713 Goal "${oe.title}" abandoned`,e.dim),Z();},s=>a(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="p"||i==="P")&&_==="goals"&&oe&&gt){let s=oe.status==="paused"?"active":"paused";(oe.status==="active"||oe.status==="paused")&&gt(oe.id,s).then(()=>{a(`Goal "${oe.title}" ${s}`,e.cyan),Z();},d=>a(`Failed: ${d instanceof Error?d.message:String(d)}`,e.red));return}if((i==="a"||i==="A")&&_==="tasks"&&U?.status==="review"&&O){a(`Approving "${U.title}"...`,e.amber),O(U.id).then(()=>{a(`\u2713 Approved "${U.title}"`,e.green),Z();},s=>a(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="x"||i==="X")&&_==="tasks"&&U?.status==="review"&&L){a(`Rejecting "${U.title}"...`,e.amber),L(U.id).then(()=>{a(`\u2713 Rejected "${U.title}" \u2192 todo`,e.green),Z();},s=>a(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="c"||i==="C")&&_==="tasks"&&U&&b$1){if(U.status==="done"||U.status==="failed"||U.status==="cancelled"){a(`Cannot cancel \u2014 status is ${U.status}`,e.yellow);return}a(`Cancelling "${U.title}"...`,e.amber),b$1(U.id).then(()=>{a(`\u2713 Cancelled "${U.title}"`,e.green),Z();},s=>a(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="e"||i==="E")&&_==="tasks"&&U&&E){Ca(U);return}if((i==="e"||i==="E")&&_==="agents"&&Q&&W){Ia(Q);return}if((i==="s"||i==="S")&&_==="tasks"){as(s=>!s),jn(0),kn(0);return}if((i==="g"||i==="G")&&_==="tasks"&&!$e){fa(s=>!s),jn(0),kn(0);return}if((i==="s"||i==="S")&&_==="agents"&&Q&&z){if(!Object.values(we.running).some(d=>d.agent_id===Q.id)&&Q.status!=="running"){a(`Agent "${Q.name}" is not running`,e.yellow);return}a(`Force-stopping agent "${Q.name}"...`,e.amber),z(Q.id).then(()=>{a(`\u2713 Stopped agent "${Q.name}"`,e.green),Z();},d=>a(`Failed: ${d instanceof Error?d.message:String(d)}`,e.red));return}if((i==="d"||i==="D")&&_==="tasks"&&U&&U.status!=="in_progress"&&N){An("task",U.id,U.title);return}if((i==="d"||i==="D")&&_==="agents"&&Q&&j){let s=Object.values(we.running).some(d=>d.agent_id===Q.id);if(s&&!z){a(`Cannot delete \u2014 agent "${Q.name}" is running. Press S to stop first.`,e.yellow);return}An("agent",Q.id,Q.name,{needsForceStop:s});return}if((i==="u"||i==="U")&&_==="agents"&&Q&&ut){let s=!Q.autonomous;a(`${s?"Enabling":"Disabling"} autonomous mode for "${Q.name}"...`,e.amber),ut(Q.id,s).then(()=>{a(`${gn} ${Q.name} autonomous ${s?"ON":"OFF"}`,e.cyan),Z();},d=>a(`Failed: ${d instanceof Error?d.message:String(d)}`,e.red));return}if(!$e){if(i==="g"||i==="G"){yn("goals");return}if(i==="t"||i==="T"){yn("tasks");return}if(i==="a"||i==="A"){yn("agents");return}if(i==="l"||i==="L"){yn("logs");return}}if(!$e){let s=Eo.map(u=>u.id),d=s.indexOf(_);if(p.tab||p.rightArrow){yn(s[(d+1)%s.length]);return}if(p.leftArrow){yn(s[(d+s.length-1)%s.length]);return}}if(p.return){let s=Rn>0?Bt.length:-1;if(_==="tasks"&&fo===s){as(u=>!u),jn(0),kn(0);return}let d=Bt.length+(Rn>0?1:0);if(_==="tasks"&&fo===d&&f){Io();return}if(_==="goals"&&sr===ft.length&&De){let u=Yo(K);Je({title:"New Goal",steps:u,kind:"goal"}),Oe("wizard");return}if(_==="agents"&&rr===Ge.length&&P){Co();return}if(_==="goals"&&oe){Un(u=>!u),Jn(0);return}if(_==="tasks"&&U){Un(u=>!u);return}if(_==="agents"&&Q){Un(u=>!u);return}if(_==="logs"&&Kn>=0){Un(u=>!u);return}}if((i==="r"||i==="R")&&_==="tasks"&&U&&l){if(!Vr.has(U.status)){a(`Cannot run "${U.title}" \u2014 status is ${U.status}`,e.yellow);return}a(`Running "${U.title}"...`,e.green),l(U.id).then(()=>{a(`Dispatched "${U.title}"`,e.green),Z();},s=>a(`Failed to run: ${s instanceof Error?s.message:String(s)}`,e.red));return}if(p.upArrow||i==="k"){if(_==="goals"&&$e){Jn(s=>Math.max(0,s-1));return}_==="goals"?Kr(s=>{let d=Math.max(0,s-1);return fr(u=>d<u?d:u),d}):_==="tasks"?jn(s=>{let d=Math.max(0,s-1);return kn(u=>d<u?d:u),d}):_==="agents"?qr(s=>{let d=Math.max(0,s-1);return mr(u=>d<u?d:u),d}):_==="logs"&&cr(s=>{if(s===-1){let u=ze.length-1;return Yn(Math.max(0,u-Se+2)),Math.max(0,u)}let d=Math.max(0,s-1);return Yn(u=>d<u?d:u),d});}if(p.downArrow||i==="j"){if(_==="goals"&&$e){Jn(s=>s+1);return}if(_==="goals"){let s=ft.length+(De?1:0)-1;Kr(d=>{let u=Math.min(Math.max(0,s),d+1);return fr(h=>u>=h+Se?u-Se+1:h),u});}else if(_==="tasks"){let s=Bt.length+(f?1:0)+(Rn>0?1:0)-1;jn(d=>{let u=Math.min(Math.max(0,s),d+1);return kn(h=>u>=h+Se?u-Se+1:h),u});}else if(_==="agents"){let s=Ge.length+(P?1:0)-1;qr(d=>{let u=Math.min(Math.max(0,s),d+1);return mr(h=>u>=h+Se?u-Se+1:h),u});}else _==="logs"&&cr(s=>{if(s===-1)return -1;let d=ze.length-1;if(s>=d)return Yn(0),-1;let u=s+1;return Yn(h=>u>=h+Se-1?u-Se+2:h),u});}}});let ot=Fe!=="none",bs=Kn>=0?ze[Kn]:void 0,Mo=yo?"+/- exit max":"+/- resize \u2502 M max",Ts=!ot&&$e&&_==="tasks"&&U,ys=!ot&&$e&&_==="agents"&&Q,ws=!ot&&$e&&_==="goals"&&oe,Fa=!ot&&$e&&_==="logs"&&bs,wr=U?.id,Ga=useMemo(()=>wr?ze.filter(i=>i.taskId===wr):[],[ze,wr]),Wa=!ot&&_==="tasks"&&U&&Vr.has(U.status)&&!!l,za=!ot&&!$e&&(_==="goals"&&!!De||_==="tasks"&&!!f||_==="agents"&&!!P),Va=!ot&&_==="tasks"&&U?.status==="review"&&!!O,Ha=!ot&&_==="tasks"&&U?.status==="review"&&!!L,ja=Q?Object.values(we.running).some(i=>i.agent_id===Q.id):false,Ua=!ot&&(_==="goals"&&oe&&!!Ze||_==="tasks"&&U&&U.status!=="in_progress"&&!!N||_==="agents"&&Q&&!!j),Xa=!ot&&!$e&&(_==="goals"&&!!oe&&!!Ye||_==="tasks"&&!!U&&!!E||_==="agents"&&!!Q&&!!W),qa=!ot&&_==="agents"&&Q&&(ja||Q.status==="running")&&!!z,Ka=!ot&&_==="agents"&&!!Q&&!!ut,Ya=!ot&&_==="goals"&&!!oe&&(oe.status==="active"||oe.status==="paused")&&!!gt,Za=!ot&&In.length>0,Ss=Fe==="command"&&Mt.length>0,ks=bt?.kind==="task"||bt?.kind==="edit_task";return jsxs(Box,{flexDirection:"column",width:q,height:te,children:[jsx(Ks,{projectName:t,activeView:_,mode:yr,stats:xs,tokens:Aa,uptime:_a,width:q,version:Wt,latestVersion:xn,updateInstalled:bn,taskBadge:Rn>0?Le.length:void 0,flashTab:gr?.tab,flashColor:gr?.color,onFlashComplete:gr?()=>ns(void 0):void 0}),jsx(Box,{height:1}),$t&&jsx(Ti,{width:q,height:te-7}),!$t&&Kt==="welcome"&&_==="tasks"&&jsx(ci,{width:q,height:te}),!$t&&_==="goals"&&jsx(Rc,{goals:ft,selectedIndex:sr,scrollOffset:ha,height:Se,width:ve,showAddRow:!!De,agentNameMap:ln,tasksByGoalMap:ba}),!$t&&Kt!=="welcome"&&_==="tasks"&&jsx(Ac,{tasks:Bt,selectedIndex:fo,scrollOffset:ma,height:Se,width:ve,showAddRow:!!f,agentNameMap:ln,hiddenCount:Rn,goalMap:vn,groupByGoal:Zn}),!$t&&_==="tasks"&&(Kt==="task_created"||Kt==="run_started")&&jsx(di,{step:Kt,width:q}),!$t&&_==="tasks"&&Kt==="completed"&&jsx(ui,{width:q}),!$t&&_==="agents"&&jsx($c,{agents:Ge,selectedIndex:rr,scrollOffset:pa,height:Se,width:ve,state:we,taskTitleMap:Qn,showAddRow:!!P,agentTeamMap:_n,teamLeadSet:ya,activeTeamCount:eo}),!$t&&_==="logs"&&jsxs(Fragment,{children:[jsx(Ec,{messages:ze,height:wn||qn?Math.max(3,Se-16):Se,agents:Ge,logAgentFilter:Zr,logTypeFilter:Jr,selectedIndex:Kn,scrollOffset:aa,agentNameMap:ln,agentColorMap:So,agentMsgCounts:ds,taskTitleMap:Qn,width:ve}),wn&&jsx(Box,{paddingX:2,children:jsx(ri,{agents:Ge,selected:Zr,msgCounts:ds,colorMap:So,maxHeight:Math.min(Se-4,18),onConfirm:i=>{ia(i),ar(false);},onCancel:()=>ar(false)})}),qn&&jsx(Box,{paddingX:2,children:jsx(li,{selected:Jr,typeCounts:Ta,onConfirm:i=>{Qr(i),lr(false);},onCancel:()=>lr(false)})})]}),jsx(Box,{height:1}),$t?null:Fe==="wizard"&&bt?jsx(ti,{title:bt.title,steps:bt.steps,onComplete:Ma,onCancel:va,width:ve,height:Et,onPasteImage:ks?ka:void 0,onSuggestionSelected:bt.kind==="agent"?Ra:void 0,footerExtra:an.length>0&&ks?`\u{1F4CE}${an.length}`:void 0},`${bt.kind}-${bt.title}`):Ss?jsxs(Fragment,{children:[jsx(Zo,{label:"COMMANDS",width:ve}),jsx(vc,{suggestions:Mt,selectedIndex:wo,height:Math.min(Mt.length,Et),width:ve})]}):Fe==="new_task"?jsxs(Fragment,{children:[jsx(Wc,{mode:Fe,width:ve}),jsx(zc,{mode:Fe,value:sn,width:ve})]}):Ts?jsxs(Fragment,{children:[jsx(Pc,{task:U,width:ve,resizeHint:Mo}),jsx(Hs,{task:U,height:Et,width:ve,taskLogs:Ga,agentNameMap:ln,taskTitleMap:Qn})]}):ws?jsxs(Fragment,{children:[jsx(Zo,{label:`GOAL: ${oe.title}`,width:ve,suffixLen:Mo.length+2,suffix:jsxs(Text,{color:e.dim,children:[" ",Mo," "]})}),jsx(_c,{goal:oe,height:Et,width:ve,agentNameMap:ln,tasks:wa,progressReport:sa,scrollOffset:xa,onClampScroll:Jn})]}):ys?jsxs(Fragment,{children:[jsx(Nc,{agent:Q,width:ve,resizeHint:Mo}),jsx(Dc,{agent:Q,height:Et,state:we,taskTitleMap:Qn,teamName:_n.get(Q.id)})]}):Fa?jsxs(Fragment,{children:[jsx(Zo,{label:"LOG",width:ve}),jsx(Lc,{message:bs,height:Et,width:ve,agents:Ge,agentNameMap:ln,agentColorMap:So,taskTitleMap:Qn})]}):ze.length>0&&_!=="logs"?jsxs(Fragment,{children:[(()=>{let i=` F:${po.toUpperCase()} \u2502 ${ur.length}/${ze.length}`;return jsx(Zo,{label:"ACTIVITY",width:ve,suffixLen:i.length,suffix:jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" F:"}),jsx(Text,{color:e.amber,children:po.toUpperCase()}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," ",ur.length,"/",ze.length]})]})})})(),jsx(Oc,{messages:ur,height:Math.max(1,Et-1),width:ve,agents:Ge,agentNameMap:ln,agentColorMap:So})]}):_==="goals"?jsx(jo,{count:ft.length,config:Sc,width:ve}):_==="tasks"?jsx(jo,{count:Le.length,config:kc,width:ve}):_==="agents"?jsx(jo,{count:Ge.length,config:Cc,width:ve}):null,jsx(Box,{flexGrow:1}),jsx(bi,{toasts:da,onDismiss:ga}),In.length>0&&jsx(Mc,{deletions:In,width:q}),jsx(Zs,{mode:Fe==="command"?"command":"navigate",value:Fe==="command"?sn:"",completion:Fe==="command"?Ar(sn):null,activeView:_,canRun:!!Wa,canNew:!!za,canApprove:!!Va,canReject:!!Ha,canCancel:_==="tasks"&&!!U&&U.status==="in_progress"&&!!b$1,canDelete:!!Ua,canUndo:!!Za,canEdit:!!Xa,canForceStop:!!qa,canToggleAuto:!!Ka,autoActive:Q?.autonomous,canPause:!!Ya,isPaused:oe?.status==="paused",canToggleShowAll:_==="tasks"&&Le.length>Ui,showAllActive:is,hasDetail:!!(Ts||ys||ws),itemCount:_==="goals"?ft.length:_==="tasks"?Le.length:_==="agents"?K.length:ze.length,itemLabel:_==="goals"?"goals":_==="tasks"?"tasks":_==="agents"?"agents":"events",width:q,hasSuggestions:Ss,onboardingCompleted:r.onboardingCompleted})]})}var Mc=ao.memo(function({deletions:n,width:o}){let[,r]=useState(0);useEffect(()=>{let f=setInterval(()=>r(b=>b+1),1e3);return ()=>clearInterval(f)},[]);let l=Date.now();return jsx(Box,{flexDirection:"column",width:o,children:n.map(f=>{let b=Math.max(0,Math.ceil((f.expiresAt-l)/1e3)),T=Math.max(0,o-4),x=f.entityType==="task"?"Task":f.entityType==="agent"?"Agent":"Goal",y=Math.max(10,T-x.length-30),C=f.entityName.length>y?f.entityName.slice(0,y-1)+"\u2026":f.entityName;return jsx(Box,{paddingX:2,children:jsxs(Text,{color:e.yellow,children:["\u2717 ",jsx(Text,{bold:true,children:x}),` "${C}" \u2014 `,jsxs(Text,{color:e.amber,bold:true,children:[b,"s"]}),jsx(Text,{color:e.dim,children:" \u2502 "}),jsx(Text,{color:e.gray,bold:true,children:"Z"}),jsx(Text,{color:e.dim,children:" undo"})]})},f.key)})})});function vc({suggestions:t,selectedIndex:n,height:o,width:r}){let l=o,f=0;n>=l&&(f=n-l+1);let b=t.slice(f,f+l);return jsx(Box,{flexDirection:"column",paddingX:2,children:b.map((T,x)=>{let y=x+f,C=y===n,M=C?"\u25B6":" ",A=Math.min(20,Math.max(14,...t.map(P=>P.cmd.length+1))),S=T.cmd.padEnd(A),H=T.subs?` ${T.subs}`:"",V=Math.max(4,r-A-H.length-8),F=T.desc.length>V?T.desc.slice(0,V-1)+"\u2026":T.desc;return jsxs(Text,{wrap:"truncate",children:[jsx(Text,{color:C?e.amber:e.ghost,children:` ${M} `}),jsx(Text,{color:C?e.white:e.silver,bold:C,children:S}),jsx(Text,{color:e.dim,children:F}),H&&jsx(Text,{color:e.ghost,children:H})]},y)})})}function Rc({goals:t,selectedIndex:n,scrollOffset:o=0,height:r,width:l,showAddRow:f,agentNameMap:b,tasksByGoalMap:T}){let x=t.length,y=t.slice(o,o+r),C=f&&x>=o&&x<o+r;return jsxs(Box,{flexDirection:"column",height:r,children:[y.map((M,A)=>jsx(Box,{paddingX:2,children:jsx(Vs,{goal:M,selected:A+o===n,width:l-2,agentNameMap:b,tasksByGoal:T?.get(M.id)})},M.id)),C&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===x?e.amber:e.ghost,children:[n===x?" \u25B8 ":" ",jsx(Text,{color:n===x?e.amber:e.dim,children:"+ add goal..."})]})},"__add__")]})}function _c({goal:t,height:n,width:o,agentNameMap:r,tasks:l,progressReport:f,scrollOffset:b=0,onClampScroll:T}){let y=ao.useMemo(()=>{let V=l??[],F=t.assignee?r?.get(t.assignee)??t.assignee:"\u2014",P=Math.max(20,o-6),j=(z,X)=>{if(z.length<=X)return [z];let R=[];for(let ae=0;ae<z.length;ae+=X)R.push(z.slice(ae,ae+X));return R},O=Mr(f)?.split(`
13
+ `).flatMap(z=>j(z,P))??[],L=Mr(t.description)?.split(`
14
+ `).flatMap(z=>j(z,P))??[],N=Rs[t.status]??e.dim,E=new Map;for(let z of V)E.set(z.status,(E.get(z.status)??0)+1);let W=[];if(W.push({key:"row-status",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:N,bold:true,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" assignee "}),jsx(Text,{color:t.assignee?e.green:e.dim,children:F})]})]})}),W.push({key:"row-id",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" id "}),jsx(Text,{color:e.dim,children:t.id})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" created "}),jsx(Text,{children:t.created_at.slice(0,10)})]})]})}),t.updated_at&&t.updated_at!==t.created_at&&W.push({key:"row-updated",node:jsxs(Box,{children:[jsx(Box,{width:24,children:jsxs(Text,{color:e.dim,children:[" "," "]})}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" Updated "}),jsx(Text,{children:t.updated_at.slice(0,10)})]})]})}),V.length>0){let z=[];for(let[X,R]of E)z.push(`${R} ${X}`);W.push({key:"row-tasks-summary",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" tasks "}),jsx(Text,{color:e.cyan,children:V.length})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" "}),jsx(Text,{color:e.dim,children:z.join(" \xB7 ")})]})]})});}if(L.length>0){W.push({key:"desc-gap",node:jsx(Text,{children:" "})});for(let z=0;z<L.length;z++)W.push({key:`desc-${z}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",L[z]]})});}else W.push({key:"desc-gap",node:jsx(Text,{children:" "})}),W.push({key:"desc-empty",node:jsx(Text,{color:e.dim,children:" No description."})});if(O.length>0){W.push({key:"prog-gap",node:jsx(Text,{children:" "})}),W.push({key:"prog-div",node:jsx(Nn,{label:"progress",width:o})});for(let z=0;z<O.length;z++)W.push({key:`prog-${z}`,node:jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",O[z]]})});}if(V.length>0){W.push({key:"tasks-gap",node:jsx(Text,{children:" "})}),W.push({key:"tasks-div",node:jsx(Nn,{label:`tasks (${V.length})`,width:o})});for(let z of V){let X=Ao[z.status]??e.dim;W.push({key:`task-${z.id}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",jsx(Text,{color:X,children:z.status.padEnd(12)}),z.title.slice(0,Math.max(10,o-22))]})});}}return W},[t,l,f,o,r]),C=Math.max(0,y.length-n),M=Math.min(b,C);ao.useEffect(()=>{T&&M!==b&&T(M);},[M,b,T]);let A=y.length>n&&M<C,S=A?n-1:n,H=y.slice(M,M+S);return jsxs(Box,{flexDirection:"column",height:n,paddingX:2,children:[H.map(V=>jsx(Box,{children:V.node},V.key)),A&&jsxs(Text,{color:e.ghost,children:[" ","\u2193"," ",y.length-M-S," more ","\u2014"," ","\u2191","\u2193"," to scroll"]})]})}function Ac({tasks:t,selectedIndex:n,scrollOffset:o=0,height:r,width:l,showAddRow:f,agentNameMap:b,hiddenCount:T=0,goalMap:x,groupByGoal:y=false}){let C=T>0,M=C?t.length:-1,A=t.length+(C?1:0),S=t.slice(o,o+r),H=C&&M>=o&&M<o+r,V=f&&A>=o&&A<o+r,F=useMemo(()=>{if(!y||!x||x.size===0)return null;let N=new Map;for(let E of t)if(E.goalId&&x.has(E.goalId)){let W=N.get(E.goalId)??{total:0,done:0};W.total++,E.status==="done"&&W.done++,N.set(E.goalId,W);}return N},[t,y,x]),P=y&&x?t.filter(N=>!N.goalId||!x.has(N.goalId)).length:0,j=y&&x&&x.size>0&&F&&F.size>0,O=[],L=o>0?t[o-1]?.goalId??null:void 0;for(let N=0;N<S.length&&O.length<r;N++){let E=S[N],W=E.goalId&&x?.has(E.goalId)?E.goalId:null;if(j){if(W&&W!==L){let z=x.get(W),X=F.get(W)??{total:0,done:0};if(O.push(jsx(Os,{goalTitle:z.title,taskCount:X.total,doneCount:X.done,width:l},`gh_${W}`)),O.length>=r)break}if(!W&&L!==null&&L!==void 0&&(O.push(jsx(Ls,{taskCount:P,width:l},"__ungrouped__")),O.length>=r))break}L=W,O.push(jsx(Box,{paddingX:2,children:jsx(Bo,{task:E,selected:N+o===n,width:l-2,agentNameMap:b,goalMap:x})},E.id));}return H&&O.length<r&&O.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===M?e.amber:e.ghost,children:[n===M?" \u25B8 ":" ",jsxs(Text,{color:n===M?e.amber:e.dim,children:["\u25BC"," Show all (",T," more) \u2014 press ",jsx(Text,{bold:true,color:e.gray,children:"S"})]})]})},"__show_all__")),V&&O.length<r&&O.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===A?e.amber:e.ghost,children:[n===A?" \u25B8 ":" ",jsx(Text,{color:n===A?e.amber:e.dim,children:"+ add task..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:r,children:O})}function $c({agents:t,selectedIndex:n,scrollOffset:o=0,height:r,width:l,state:f,taskTitleMap:b,showAddRow:T,agentTeamMap:x,teamLeadSet:y,activeTeamCount:C}){let M=new Map;for(let E of Object.values(f.running))M.set(E.agent_id,E);let A=new Map;if(C&&C>0)for(let E of t){let W=x?.get(E.id);W&&A.set(W,(A.get(W)??0)+1);}let S=t.length,H=t.slice(o,o+r),V=T&&S>=o&&S<o+r,F=C!=null&&C>0,P=new Map;if(F&&y&&x){for(let E of t)if(y.has(E.id)){let W=x.get(E.id);W&&P.set(W,E.name);}}let j=0;for(let E of A.values())j+=E;let O=t.length-j,L=[],N=o>0?x?.get(t[o-1]?.id??""):void 0;for(let E=0;E<H.length&&L.length<r;E++){let W=H[E],z=x?.get(W.id);if(F&&z&&z!==N&&(L.push(jsx(Fs,{teamName:z,memberCount:A.get(z)??0,leadName:P.get(z),width:l},`ts-${z}`)),L.length>=r)||F&&!z&&N&&(L.push(jsx(Gs,{memberCount:O,width:l},"ts-unassigned")),L.length>=r))break;N=z,L.push(jsx(Box,{paddingX:2,children:jsx(Ds,{agent:W,selected:E+o===n,width:l-2,runningEntry:M.get(W.id),currentTaskTitle:W.current_task?b.get(W.current_task):void 0,teamName:z,isLead:y?.has(W.id)})},W.id));}return V&&L.length<r&&L.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===S?e.amber:e.ghost,children:[n===S?" \u25B8 ":" ",jsx(Text,{color:n===S?e.amber:e.dim,children:"+ add agent..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:r,children:L})}function ea(t=5e3){let[n,o]=useState(Date.now());return useEffect(()=>{let r=setInterval(()=>o(Date.now()),t);return ()=>clearInterval(r)},[t]),n}function ta(t,n){let o=Math.max(0,n-t);return o<3e3?"now":o<6e4?`${Math.floor(o/1e3)}s`:o<36e5?`${Math.floor(o/6e4)}m`:`${Math.floor(o/36e5)}h`}function Bc(t){if(t==="error")return e.errorBg}function na(t,n){switch(t){case "output":return e.white;case "tool":return e.dim;case "result":return e.dim;case "file":return e.gray;case "error":return e.red;case "lifecycle":return e.dim;case "system":return e.dim;default:return n}}function Ec({messages:t,height:n,agents:o,logAgentFilter:r,logTypeFilter:l,selectedIndex:f,scrollOffset:b,agentNameMap:T,agentColorMap:x,agentMsgCounts:y,taskTitleMap:C,width:M}){let A=ea(),S=useMemo(()=>t.filter(X=>{if(r.size>0&&X.agentId&&!r.has(X.agentId))return false;let R=X.msgType??"info";return l.has(R)}),[t,r,l]);useMemo(()=>{let X={};for(let R of t){let ae=R.msgType??"info";X[ae]=(X[ae]??0)+1;}return X},[t]);let V=l.size>=8?"all":l.size===1&&l.has("output")?"text":l.size===1&&l.has("error")?"errors":l.has("tool")&&!l.has("output")?"tools":l.has("lifecycle")&&!l.has("output")?"events":`${l.size} types`,F=r.size>0,P=n-2,j=f===-1?S.slice(-P):S.slice(b,b+P),O=f===-1?-1:f-b,L=Math.min(10,Math.max(6,...o.map(X=>X.name.length))),N=11+L,E=X=>{if(X===0)return true;let R=j[X],ae=j[X-1];return R.agentId!==ae.agentId?true:R.agentId?R.ts-ae.ts>3e4:false},W=Math.max(4,Math.floor((M-20)/Math.max(1,o.length))-1),z=Math.min(W,10);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsxs(Box,{gap:0,justifyContent:"space-between",width:M,children:[jsxs(Box,{gap:0,children:[f===-1?jsxs(Box,{gap:0,children:[jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" "}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:jsx(En,{color:e.green})}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" LIVE "})]}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,children:[" \u2191\u2193 ",f+1,"/",S.length," "]}),jsxs(Text,{color:e.dim,children:[" ",S.length," events"]}),V!=="all"&&jsxs(Text,{color:e.amber,children:[" f:",V]}),F&&jsxs(Text,{color:e.cyan,children:[" ",r.size,"/",o.length," agents"]})]}),jsxs(Box,{gap:0,children:[jsx(Text,{color:e.amber,bold:true,children:"a"}),jsx(Text,{color:e.dim,children:" filter "}),jsx(Text,{color:e.amber,bold:true,children:"f"}),jsx(Text,{color:e.dim,children:" type "}),jsx(Text,{color:e.amber,bold:true,children:"F"}),jsx(Text,{color:e.dim,children:" cycle"})]})]}),jsx(Box,{gap:0,children:o.map(X=>{let R=x.get(X.id)??jr[0],ae=r.size===0||r.has(X.id),Ee=X.name.length>z?X.name.slice(0,z-1)+"\u2026":X.name;return jsxs(Text,{color:ae?R:e.ghost,bold:ae,children:[" ",Ee]},X.id)})}),j.length===0?jsxs(Box,{flexDirection:"column",paddingX:2,paddingTop:1,children:[jsx(Text,{color:e.dim,children:t.length===0?" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E":"No events for current filter."}),t.length===0&&jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" \u2502 \u2502"}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u25C7"}),jsx(Text,{color:e.gray,children:" Waiting for activity "}),"\u2502"]}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u2502"}),jsx(Text,{color:e.dim,children:" Run tasks or start "}),"\u2502"]}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u2502"}),jsx(Text,{color:e.dim,children:" the orchestrator "}),"\u2502"]}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u25C7"}),jsx(Text,{color:e.dim,children:" "}),"\u2502"]}),jsx(Text,{color:e.dim,children:" \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"})]})]}):j.map((X,R)=>{let ae=R===O,Ee=X.msgType??"info",Ft=nr[Ee]??"\u2502",dt=X.agentId?T.get(X.agentId)??X.agentId.slice(0,8):void 0,_e=X.agentId?x.get(X.agentId):void 0,Ke=E(R),pt=(R>0?j[R-1]:void 0)?.agentId===X.agentId&&!!X.agentId,De=!pt&&!!dt,Ye=pt&&!!dt,gt=na(Ee,X.color),Ze=ae?e.infoBg:Ee==="error"?e.errorBg:void 0,nn=X.taskId?C.get(X.taskId):void 0,Ce=ta(X.ts,A),ht=nn&&M>80?`#${nn.slice(0,20)}`:"",xt=ht?ht.length+3:0,Xt=Math.max(10,M-2-N-xt),mt=rt(X.text,Xt);return jsxs(Box,{backgroundColor:Ze,children:[jsx(Text,{color:_e??e.ghost,children:Ke&&De?"\u250C":Ye?"\u2502":" "}),jsx(Text,{color:ae?e.amber:void 0,children:ae?"\u25B8":" "}),jsx(Box,{width:5,children:jsx(Text,{color:Ce==="now"?e.green:ae?e.silver:e.ghost,children:Ce.padStart(4)})}),jsx(Box,{width:L+1,children:De?jsxs(Text,{color:_e,bold:true,children:[" ",dt.slice(0,L).padEnd(L)]}):Ye?jsxs(Text,{color:_e??e.ghost,children:[" ","\xB7".padEnd(L)]}):jsxs(Text,{color:e.ghost,children:[" "," ".padEnd(L)]})}),jsxs(Text,{color:Ee==="error"?e.red:_e??e.dim,children:[" ",Ft," "]}),jsx(Text,{color:ae?e.white:gt,bold:ae||Ee==="lifecycle",children:mt}),ht&&jsxs(Text,{color:e.ghost,children:[" ",jsx(Text,{color:e.dim,backgroundColor:e.void,children:` ${ht} `})]})]},R)})]})}function Oc({messages:t,height:n,width:o,agents:r,agentNameMap:l,agentColorMap:f}){let b=ea(),T=t.slice(-n),x=Math.max(10,o-2-17),y=Math.max(0,n-T.length),C=0,M=[];for(let A=0;A<T.length;A++)A>0&&T[A].agentId!==T[A-1].agentId&&C++,M.push(C);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[y>0&&jsx(Box,{height:y}),T.map((A,S)=>{let H=A.agentId?l.get(A.agentId)??A.agentId.slice(0,8):void 0,V=A.agentId?f.get(A.agentId):void 0,F=A.msgType??"info",P=nr[F]??"\u2502",j=na(F,A.color),L=(S>0?T[S-1]:void 0)?.agentId===A.agentId&&!!A.agentId,N=(M[S]&1)===1,E=Bc(F)??(N?"#1a1a1a":void 0),W=ta(A.ts,b),z=rt(A.text,x);return jsxs(Box,{backgroundColor:E,children:[jsx(Text,{color:V??e.ghost,children:!L&&H?"\u258D":L?"\u258F":" "}),jsx(Box,{width:5,children:jsx(Text,{color:L?e.ghost:W==="now"?e.green:e.dim,children:L?" ":W.padStart(4)})}),jsx(Box,{width:9,children:H&&!L?jsxs(Text,{color:V,bold:true,children:[" ",H.slice(0,8)]}):jsx(Text,{color:e.ghost,children:Ic})}),jsxs(Text,{color:F==="error"?e.red:L?e.ghost:V??e.dim,children:[P," "]}),jsx(Text,{color:j,children:z})]},S)})]})}function Lc({message:t,height:n,width:o,agents:r,agentNameMap:l,agentColorMap:f,taskTitleMap:b}){let T=t.detail??t.text,x=t.msgType??"info",y=t.agentId?l.get(t.agentId)??t.agentId.slice(0,8):void 0,C=t.agentId?f.get(t.agentId):e.dim,M=t.taskId?b.get(t.taskId):void 0,A,S=false;try{let P=JSON.parse(T);A=JSON.stringify(P,null,2),S=!0;}catch{A=T;}let H=Math.max(4,o-6),V=Math.max(1,n-4),F=A.split(`
15
+ `).slice(0,V);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u256D",Te(H+2),"\u256E"]})}),jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),jsx(Text,{color:e.dim,children:t.time}),jsx(Text,{color:e.ghost,children:" \u2502 "}),y&&jsx(Text,{color:C,bold:true,children:y}),y&&jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:nr[x]?x==="error"?e.red:e.dim:e.dim,children:[nr[x]??"\u2502"," ",x]}),M&&jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:e.dim,children:["#",M.slice(0,30)]})]})]}),jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),jsx(Text,{color:t.color,bold:true,wrap:"truncate",children:t.text.slice(0,H)})]}),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u251C",Te(H+2),"\u2524"]})}),F.map((P,j)=>jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),S&&jsxs(Text,{color:e.ghost,children:[String(j+1).padStart(3)," "]}),jsx(Text,{wrap:"truncate",color:S&&P.includes('"')?e.cyan:S&&/^\s*[}\]]/.test(P)?e.ghost:P.startsWith("error")||P.startsWith("Error")?e.red:e.silver,children:P.slice(0,S?H-4:H)})]},j)),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u2570",Te(H+2),"\u256F"]})})]})}function Zo({label:t,width:n,suffix:o,suffixLen:r=0}){let l=` ${t} `,f=3,b=f+l.length+2;if(!o){let y=Math.max(0,n-b);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:He(f)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:l}),jsx(Text,{color:e.ghost,children:He(y)})]})}let T=2,x=Math.max(0,n-b-T-r);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:He(f)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:l}),jsx(Text,{color:e.ghost,children:He(T)}),o,jsx(Text,{color:e.ghost,children:He(x)})]})}function Pc({task:t,width:n,resizeHint:o}){let r=" DETAIL ",l=o?` ${o} `:"",f=n-r.length-l.length-10,b=t.title.length>f?t.title.slice(0,f-3)+"...":t.title,T=Math.max(0,n-3-r.length-b.length-l.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:He(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:r}),jsxs(Text,{color:e.ghost,children:[_o," "]}),jsx(Text,{color:e.white,bold:true,children:b}),jsxs(Text,{color:e.ghost,children:[" ",He(Math.max(0,T))]}),l?jsx(Text,{color:e.dim,children:l}):null]})}function Nc({agent:t,width:n,resizeHint:o}){let r=" AGENT ",l=o?` ${o} `:"",f=n-r.length-l.length-10,b=t.name.length>f?t.name.slice(0,f-3)+"...":t.name,T=Math.max(0,n-3-r.length-b.length-l.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:He(3)}),jsx(Text,{backgroundColor:"#0f2d1f",color:e.green,bold:true,children:r}),jsxs(Text,{color:e.ghost,children:[_o," "]}),jsx(Text,{color:e.green,bold:true,children:b}),jsxs(Text,{color:e.ghost,children:[" ",He(Math.max(0,T))]}),l?jsx(Text,{color:e.dim,children:l}):null]})}function Dc({agent:t,height:n,state:o,taskTitleMap:r,teamName:l}){let f=Fc[t.status]??e.dim;Object.values(o.running).find(y=>y.agent_id===t.id);let T=t.current_task?r.get(t.current_task):void 0,x=24;return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:f,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" adapter "}),jsx(Text,{color:e.cyan,children:t.adapter})]})]}),jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" model "}),jsx(Text,{children:t.config.model??"\u2014"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" task "}),jsx(Text,{color:T?e.white:e.dim,children:T??"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" runs "}),jsx(Text,{children:t.stats.total_runs}),jsx(Text,{color:e.dim,children:" ("}),jsx(Text,{color:e.green,children:t.stats.tasks_completed}),jsx(Text,{color:e.dim,children:"/"}),jsx(Text,{color:t.stats.tasks_failed>0?e.red:e.dim,children:t.stats.tasks_failed}),jsx(Text,{color:e.dim,children:")"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" team "}),jsx(Text,{color:l?e.amber:e.dim,children:l??"\u2014"})]})]}),t.autonomous&&jsx(Box,{children:jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" auto "}),jsxs(Text,{color:e.cyan,children:[gn," ON"]})]})}),t.config.skills&&t.config.skills.length>0&&jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" skills "}),jsx(Text,{color:e.cyan,wrap:"truncate",children:rt(t.config.skills.join(", "),500)})]}),t.last_error&&(()=>{let y=t.last_error.kind,C=m[y],M=!C||y==="unknown",A=t.last_error.timestamp,S=A?g(A)+" ago":"";return jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Box,{flexDirection:"column",borderStyle:"single",borderColor:e.red,paddingX:1,children:[jsxs(Text,{color:e.red,bold:true,children:["\u26A0"," \u041E\u0448\u0438\u0431\u043A\u0430"]}),C&&jsx(Text,{color:e.white,children:C.message}),C&&jsx(Text,{color:e.cyan,children:C.fix}),C?.doctorHint&&jsx(Text,{color:e.yellow,children:"\u0414\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0430: orch doctor"}),M&&t.last_error.message&&jsx(Text,{color:e.dim,children:rt(t.last_error.message,120)}),S&&jsx(Text,{color:e.dim,children:S})]})]})})(),jsx(Text,{children:" "}),t.role?t.role.split(`
16
+ `).slice(0,Math.max(1,n-(t.last_error?10:4))).map((y,C)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",rt(y,500)]},C)):jsx(Text,{color:e.dim,children:" No role description."})]})}var Fc={idle:e.dim,running:e.green,error:e.red,disabled:e.ghost},Gc="\u2588";function Wc({mode:t,width:n}){let r=` ${t==="command"?"COMMAND":"NEW TASK"} `,l=Math.max(0,n-3-r.length-2);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:He(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:r}),jsx(Text,{color:e.ghost,children:He(l)})]})}function zc({mode:t,value:n,width:o}){let r=t==="command"?"/":"\u25B8",l=Math.max(10,o-8),f=n.length>l?n.slice(-l):n;return jsxs(Box,{paddingX:2,children:[jsxs(Text,{color:e.amber,children:[r," "]}),jsx(Text,{color:e.white,children:f}),jsx(Text,{color:e.amber,children:Gc})]})}function oa(t,n){if(!n||typeof n!="object")return "";let o=n;if(o.file_path&&typeof o.file_path=="string")return o.file_path.split("/").slice(-2).join("/");if(o.command&&typeof o.command=="string")return o.command.slice(0,60);if(o.pattern&&typeof o.pattern=="string")return `"${o.pattern.slice(0,40)}"`;if(o.glob&&typeof o.glob=="string")return o.glob.slice(0,40);let r=JSON.stringify(o);return r.length>80?r.slice(0,77)+"...":r}function Jo(t,n=200){if(typeof t=="string")return t.slice(0,n);if(!Array.isArray(t))return null;let o=[],r=0;for(let l of t){if(r>=n)break;if(l?.type==="text"&&typeof l.text=="string"){let f=l.text.split(`
17
+ `).find(b=>b.trim().length>0)??"";o.push(f.slice(0,n-r)),r+=f.length;}else if(l?.type==="tool_use"){let f=oa(l.name??"tool",l.input),b=`\u2699 ${l.name??"tool"}(${f})`;o.push(b),r+=b.length;}else if(l?.type==="tool_result")o.push("\u2190 (result)"),r+=10;else if(l?.type==="thinking"&&typeof l.thinking=="string"){let f=l.thinking.slice(0,60).split(`
18
+ `)[0]??"";o.push(`\u{1F4AD} ${f}`),r+=f.length+3;}}return o.length>0?o.join(" "):null}function Yi(t){if(typeof t=="string"){let o=t.split(`
19
+ `).length,r=t.split(`
20
+ `).find(l=>l.trim().length>0)??"";return o>3?`${r.slice(0,80)}... (${o} lines)`:r.slice(0,120)}if(!Array.isArray(t))return "(result)";let n=[];for(let o of t)if(o?.type==="tool_result"){o.tool_use_id?o.tool_use_id.slice(0,8):"";let l=o.is_error,f=typeof o.content=="string"?o.content:"",b=f.split(`
21
+ `).length;l?n.push(`\u2715 error: ${f.slice(0,60)}`):b>3?n.push(`\u2713 ${b} lines`):n.push(`\u2713 ${f.slice(0,80)}`);}else o?.type==="text"&&typeof o.text=="string"&&n.push(o.text.split(`
22
+ `)[0]?.slice(0,80)??"");return n.join(" ")||"(result)"}function ra(t){let n=()=>t.length>tr?t.slice(0,tr)+"\u2026":t;if(Ji.test(t.trim()))return {summary:t.trim(),detail:n()};try{let o=JSON.parse(t);if(o.type==="message"&&o.role==="assistant"){let r=Jo(o.content);return r?{summary:r.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="assistant"||o.role==="assistant"){let r=o.message?.content??o.content,l=Jo(r);return l?{summary:l.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="user"||o.role==="user"){let r=o.message?.content??o.content;return {summary:`\u2190 ${Yi(r).slice(0,180)}`,detail:n()}}if(o.type==="tool_use"||typeof o.name=="string"&&"input"in o){let r=o.name??"tool",l=oa(r,o.input);return {summary:`\u2699 ${r}(${l})`,detail:n()}}if(o.type==="tool_result")return {summary:`\u2190 ${Yi(o.content).slice(0,180)}`,detail:n()};if(o.type==="result"){let r=typeof o.result=="string"?o.result:null;return {summary:r?`\u2713 ${r.slice(0,180)}`:"\u2713 Agent finished",detail:n()}}if(o.type==="rate_limit_event")return {summary:`\u23F3 Rate limited (${o.rate_limit_info?.rateLimitType??"unknown"})`,detail:n()};if(o.subtype){if(o.message){let r=o.message.content??o.message,l=Jo(r);if(l)return {summary:l.slice(0,200),detail:n()}}return {summary:`[${o.subtype}]`,detail:n()}}if(o.content){let r=Jo(o.content);if(r)return {summary:r.slice(0,200),detail:n()}}return o.type?{summary:`[${o.type}]`,detail:n()}:{summary:t.slice(0,150),detail:n()}}catch{return {summary:Vc(t),detail:n()}}}function Vc(t){let n=t.match(/"subtype"\s*:\s*"([^"]+)"/);if(n)return `[${n[1]}]`;let o=t.match(/"type"\s*:\s*"([^"]+)"/),r=t.match(/"role"\s*:\s*"([^"]+)"/),l=o?.[1],f=r?.[1];if(!l&&!f)return t.slice(0,200);if(l==="assistant"||l==="message"||f==="assistant"){let b=t.match(/"text"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(b)try{return JSON.parse(`"${b[1]}"`).slice(0,200)}catch{}return "\u{1F4AC} (assistant)"}if(l==="user"||l==="tool_result"||f==="user")return "\u2190 (tool result)";if(l==="tool_use")return `\u2699 ${t.match(/"name"\s*:\s*"([^"]+)"/)?.[1]??"tool"}()`;if(l==="result"){let b=t.match(/"result"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(b)try{return `\u2713 ${JSON.parse(`"${b[1]}"`).slice(0,180)}`}catch{}return "\u2713 Agent finished"}return l==="rate_limit_event"?"\u23F3 Rate limited":`[${l??f}]`}function Hc(t,n,o,r){let l=f=>r?.get(f);switch(t.type){case "agent:started":n("Started task",e.green,{agentId:t.agentId,taskId:t.taskId,msgType:"lifecycle"});break;case "agent:output":{let{summary:f,detail:b}=ra(t.data);if(f){let T=Qi(f);n(f,T.color,{agentId:t.agentId,taskId:l(t.runId),detail:b,msgType:T.msgType});}break}case "agent:file_changed":n(`${t.path}`,e.purple,{agentId:t.agentId,taskId:l(t.runId),msgType:"file"});break;case "agent:completed":n(t.success?"Completed successfully":"Failed",t.success?e.green:e.red,{agentId:t.agentId,taskId:l(t.runId),msgType:"lifecycle"});break;case "agent:error":n(`${t.error.slice(0,150)}`,e.red,{agentId:t.agentId,taskId:l(t.runId),detail:t.error,msgType:"error"});break;case "task:status_changed":n(`${t.from} \u2192 ${t.to}`,e.cyan,{taskId:t.taskId,msgType:"system"});break;case "task:assigned":n(`Assigned \u2192 ${t.agentId}`,e.cyan,{taskId:t.taskId,msgType:"system"});break;case "task:created":n(`Created: ${t.task.title}`,e.amber,{taskId:t.task.id,msgType:"system"});break;case "run:retry":n(`Retry #${t.attempt} (${Math.round(t.delay_ms/1e3)}s delay)`,e.yellow,{agentId:o?.get(t.runId),taskId:l(t.runId),msgType:"lifecycle"});break;case "orchestrator:tick":(t.running>0||t.queued>0)&&n(`${t.running} running \xB7 ${t.queued} queued`,e.ghost,{msgType:"system"});break;case "orchestrator:stall_detected":n("Stall detected",e.yellow,{agentId:o?.get(t.runId),taskId:l(t.runId),msgType:"error"});break;case "task:cascade_failed":n(`Cascade failed (dep: ${t.failedDependencyId})`,e.red,{taskId:t.taskId,detail:t.reason,msgType:"error"});break}}export{rg as App,og as _resetPendingDeletionSeq};
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import {j,o,l,q,d,h,m}from'./chunk-64WUDYEM.js';function T(y,n){let l$1=y.command("agent").description("Manage agents");l$1.command("add <name>").description("Add a new agent").requiredOption("--adapter <adapter>","Adapter type: claude, opencode, codex, cursor, shell").option("--role <role>","Agent role description").option("--command <cmd>","Shell command (for shell adapter)").option("--model <model>","Model name (for AI adapters)").option("--max-turns <n>","Max turns per run").option("--timeout <ms>","Timeout in ms").option("--approval-policy <policy>","suggest|auto|manual").option("--workspace-mode <mode>","shared|worktree|isolated").option("--skills <skills>","Comma-separated list of agent skills").option("-e, --edit","Open $EDITOR to write the role description").action(async(o$1,e)=>{let i=e.role;if(e.edit){let{openInEditor:t,agentToEditorContent:s,agentFromEditorContent:u}=await import('./editor-7IFRWVTL.js'),g=s({name:o$1,model:e.model,role:i}),d=await t(g),c=u(d);c.name&&(o$1=c.name),c.model&&(e.model=c.model),c.role&&(i=c.role);}let a=await n.agentService.create({name:o$1,adapter:e.adapter,role:i,command:e.command,model:e.model,max_turns:e.maxTurns?parseInt(e.maxTurns,10):void 0,timeout_ms:e.timeout?parseInt(e.timeout,10):void 0,approval_policy:e.approvalPolicy,workspace_mode:e.workspaceMode,skills:e.skills?e.skills.split(",").map(t=>t.trim()):void 0});n.context.json?console.log(JSON.stringify(a,null,2)):n.context.quiet?console.log(a.id):j(`Added agent ${o(a.name)} (${a.adapter}) \u2192 ${a.id}`);}),l$1.command("shop").description("Browse and install pre-built agent templates").option("--list","Print all templates (non-interactive)").action(async o$1=>{let{AGENT_SHOP_TEMPLATES:e}=await import('./agent-shop-JHDTCWCD.js');if(o$1.list||!process.stdout.isTTY){l(["Key","Name","Adapter","Model","Skills"],e.map(s=>[s.key,s.name,s.adapter,s.model.replace("claude-",""),s.skills.slice(0,2).join(", ")]));return}let{pickFromShop:i}=await import('./shop-picker-LE3SKFOX.js'),a=await i(e);if(!a){console.log(" Cancelled.");return}let t=await n.agentService.create({name:a.name,adapter:a.adapter,model:a.model,role:a.role,skills:a.skills,approval_policy:a.approval_policy});j(`Added agent ${o(t.name)} (${t.adapter}) \u2192 ${t.id}`);}),l$1.command("list").description("List all agents").action(async()=>{let o$1=await n.agentService.list();if(n.context.json){console.log(JSON.stringify(o$1,null,2));return}if(n.context.quiet){o$1.forEach(t=>console.log(t.id));return}if(o$1.length===0){console.log(`
2
+ import {j,o,l,q,d,h,m}from'./chunk-64WUDYEM.js';function T(y,n){let l$1=y.command("agent").description("Manage agents");l$1.command("add <name>").description("Add a new agent").requiredOption("--adapter <adapter>","Adapter type: claude, opencode, codex, cursor, shell").option("--role <role>","Agent role description").option("--command <cmd>","Shell command (for shell adapter)").option("--model <model>","Model name (for AI adapters)").option("--effort <level>","Reasoning effort: low, medium, high").option("--max-turns <n>","Max turns per run").option("--timeout <ms>","Timeout in ms").option("--approval-policy <policy>","suggest|auto|manual").option("--workspace-mode <mode>","shared|worktree|isolated").option("--skills <skills>","Comma-separated list of agent skills").option("-e, --edit","Open $EDITOR to write the role description").action(async(o$1,e)=>{let i=e.role;if(e.edit){let{openInEditor:t,agentToEditorContent:s,agentFromEditorContent:u}=await import('./editor-7IFRWVTL.js'),g=s({name:o$1,model:e.model,role:i}),d=await t(g),c=u(d);c.name&&(o$1=c.name),c.model&&(e.model=c.model),c.role&&(i=c.role);}let a=await n.agentService.create({name:o$1,adapter:e.adapter,role:i,command:e.command,model:e.model,effort:e.effort,max_turns:e.maxTurns?parseInt(e.maxTurns,10):void 0,timeout_ms:e.timeout?parseInt(e.timeout,10):void 0,approval_policy:e.approvalPolicy,workspace_mode:e.workspaceMode,skills:e.skills?e.skills.split(",").map(t=>t.trim()):void 0});n.context.json?console.log(JSON.stringify(a,null,2)):n.context.quiet?console.log(a.id):j(`Added agent ${o(a.name)} (${a.adapter}) \u2192 ${a.id}`);}),l$1.command("shop").description("Browse and install pre-built agent templates").option("--list","Print all templates (non-interactive)").action(async o$1=>{let{AGENT_SHOP_TEMPLATES:e}=await import('./agent-shop-JHDTCWCD.js');if(o$1.list||!process.stdout.isTTY){l(["Key","Name","Adapter","Model","Skills"],e.map(s=>[s.key,s.name,s.adapter,s.model.replace("claude-",""),s.skills.slice(0,2).join(", ")]));return}let{pickFromShop:i}=await import('./shop-picker-LE3SKFOX.js'),a=await i(e);if(!a){console.log(" Cancelled.");return}let t=await n.agentService.create({name:a.name,adapter:a.adapter,model:a.model,role:a.role,skills:a.skills,approval_policy:a.approval_policy});j(`Added agent ${o(t.name)} (${t.adapter}) \u2192 ${t.id}`);}),l$1.command("list").description("List all agents").action(async()=>{let o$1=await n.agentService.list();if(n.context.json){console.log(JSON.stringify(o$1,null,2));return}if(n.context.quiet){o$1.forEach(t=>console.log(t.id));return}if(o$1.length===0){console.log(`
3
3
  No agents. Add one: ${q("orch agent add <name> --adapter claude")}
4
4
  `);return}let e=["STATUS","AGENT","ADAPTER","TASK","TIME"],i=o$1.map(t=>[`${d(t.status)} ${t.status}`,o(t.name),t.adapter,t.current_task??q("\u2014"),q("\u2014")]);console.log(),l(e,i);let a=o$1.filter(t=>t.status==="running").length;console.log(`
5
5
  ${o$1.length} agents \xB7 ${a} running \xB7 ${h(o$1.reduce((t,s)=>t+(s.stats.tokens_used??0),0))} tokens total
6
6
  `);}),l$1.command("status <id>").description("Show agent details").action(async o=>{let e=await n.agentService.get(o);if(n.context.json){console.log(JSON.stringify(e,null,2));return}console.log(`
7
- ${e.name}`),console.log(` ${"\u2550".repeat(42)}`),console.log();let i=[["Adapter",`${e.adapter}${e.config.model?` (${e.config.model})`:""}`],["Status",`${d(e.status)} ${e.status}`],["Policy",e.config.approval_policy??"auto"]];e.current_task&&i.push(["Task",e.current_task]),e.role&&i.push(["Role",e.role]),e.config.skills?.length&&i.push(["Skills",e.config.skills.join(", ")]),m(i),console.log(`
7
+ ${e.name}`),console.log(` ${"\u2550".repeat(42)}`),console.log();let i=[["Adapter",`${e.adapter}${e.config.model?` (${e.config.model})`:""}`],["Status",`${d(e.status)} ${e.status}`],["Effort",e.config.effort??"default"],["Policy",e.config.approval_policy??"auto"]];e.current_task&&i.push(["Task",e.current_task]),e.role&&i.push(["Role",e.role]),e.config.skills?.length&&i.push(["Skills",e.config.skills.join(", ")]),m(i),console.log(`
8
8
  Stats
9
9
  ${"\u2500".repeat(42)}`),m([["Tasks completed",String(e.stats.tasks_completed)],["Tasks failed",String(e.stats.tasks_failed)],["Total runs",String(e.stats.total_runs)],["Tokens used",h(e.stats.tokens_used??0)]]),console.log();}),l$1.command("edit <id>").description("Edit an agent in $EDITOR").action(async o$1=>{let e=await n.agentService.get(o$1),{openInEditor:i,agentToEditorContent:a,agentFromEditorContent:t}=await import('./editor-7IFRWVTL.js'),s=a({name:e.name,model:e.config.model,role:e.role}),u=await i(s),g=t(u),d=await n.agentService.update(o$1,{name:g.name,role:g.role,model:g.model});n.context.json?console.log(JSON.stringify(d,null,2)):n.context.quiet?console.log(d.id):j(`Updated agent ${o(d.name)} (${d.id})`);}),l$1.command("remove <id>").description("Remove an agent").action(async o=>{await n.agentService.remove(o),j(`Removed agent ${o}`);}),l$1.command("disable <id>").description("Disable an agent").action(async o=>{await n.agentService.disable(o),j(`Disabled agent ${o}`);}),l$1.command("enable <id>").description("Enable an agent").action(async o=>{await n.agentService.enable(o),j(`Enabled agent ${o}`);}),l$1.command("autonomous <id>").description("Toggle autonomous mode for an agent").option("--on","Enable autonomous mode").option("--off","Disable autonomous mode").action(async(o$1,e)=>{let i=await n.agentService.get(o$1),a=e.on?true:e.off?false:!i.autonomous,t=await n.agentService.setAutonomous(o$1,a);n.context.json?console.log(JSON.stringify(t,null,2)):n.context.quiet?console.log(t.id):j(`Autonomous mode ${a?"enabled":"disabled"} for agent ${o(t.name)} (${t.id})`);});}export{T as registerAgentCommand};
@@ -303,22 +303,27 @@ var CRITERION_COMMANDS = {
303
303
  typecheck: { cmd: "npx", args: ["tsc", "--noEmit"] },
304
304
  lint: { cmd: "npm", args: ["run", "lint"] }
305
305
  };
306
+ var CRITERION_ORDER = ["typecheck", "lint", "test_pass"];
306
307
  var ReviewRunner = class {
307
308
  cwd;
308
309
  timeoutMs;
310
+ failFast;
309
311
  constructor(options) {
310
312
  this.cwd = options.cwd;
311
313
  this.timeoutMs = options.timeout_ms ?? 12e4;
314
+ this.failFast = options.fail_fast ?? true;
312
315
  }
313
316
  /**
314
- * Run all criteria and return results.
315
- * Continues running even if one criterion fails.
317
+ * Run criteria in staged order (typecheck → lint → test).
318
+ * In fail-fast mode (default), stops on first failure.
316
319
  */
317
320
  async runAll(criteria) {
321
+ const sorted = sortCriteria(criteria);
318
322
  const results = [];
319
- for (const criterion of criteria) {
323
+ for (const criterion of sorted) {
320
324
  const result = await this.runCriterion(criterion);
321
325
  results.push(result);
326
+ if (this.failFast && !result.passed) break;
322
327
  }
323
328
  return results;
324
329
  }
@@ -334,7 +339,7 @@ var ReviewRunner = class {
334
339
  static formatReport(results) {
335
340
  const lines = results.map((r) => {
336
341
  const icon = r.passed ? "\u2713" : "\u2717";
337
- const truncated = r.output.slice(0, 500);
342
+ const truncated = r.output;
338
343
  return `${icon} ${r.criterion}: ${r.passed ? "PASSED" : "FAILED"}
339
344
  ${truncated}`;
340
345
  });
@@ -359,6 +364,13 @@ var ReviewRunner = class {
359
364
  });
360
365
  }
361
366
  };
367
+ function sortCriteria(criteria) {
368
+ return [...criteria].sort((a, b) => {
369
+ const ai = CRITERION_ORDER.indexOf(a);
370
+ const bi = CRITERION_ORDER.indexOf(b);
371
+ return (ai === -1 ? Infinity : ai) - (bi === -1 ? Infinity : bi);
372
+ });
373
+ }
362
374
 
363
375
  // src/application/orchestrator.ts
364
376
  var MAX_EVENT_DATA_LEN = 8192;
@@ -1715,5 +1727,5 @@ function serializeEventData(data, maxLen) {
1715
1727
  }
1716
1728
 
1717
1729
  export { Orchestrator, canTransition, isBlocked, isDispatchable, isTerminal, resolveFailureStatus };
1718
- //# sourceMappingURL=chunk-OLKQBQ4I.js.map
1719
- //# sourceMappingURL=chunk-OLKQBQ4I.js.map
1730
+ //# sourceMappingURL=chunk-C6II4C6Y.js.map
1731
+ //# sourceMappingURL=chunk-C6II4C6Y.js.map