@oxgeneral/orch 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App-5EVJSOEL.js +19 -0
- package/dist/cli.js +1 -1
- package/dist/{tui-G4XUFAIP.js → tui-DMGNSGBT.js} +1 -1
- package/package.json +10 -2
- package/readme.md +5 -4
- package/scripts/benchmark.ts +1 -1
- package/dist/App-TW35IULR.js +0 -18
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a}from'./chunk-PJ5DKXGR.js';import {c,a as a$1}from'./chunk-HXOMNULD.js';import {f,g}from'./chunk-L26TK7Y5.js';import Fn,{useState,useEffect,useMemo,useRef,useCallback}from'react';import {Box,Text,useApp,useStdout,useInput}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"},ye="\u2501",bt="\u2500",it="\xB7",Gt="\u25C8",oo="\u2605",Mt="\u27F3",_t="\u25C6",Cn={in_progress:e.green,retrying:e.yellow,review:e.blue,todo:e.dim,done:e.green,failed:e.red,cancelled:e.dim},No={active:e.green,paused:e.dim,achieved:e.amber,abandoned:e.ghost};var Os=120,ro=0,an=null,$n=new Set;function Ps(){an||(an=setInterval(()=>{ro++;for(let t of $n)t(ro);},Os));}function Ds(){an&&$n.size===0&&(clearInterval(an),an=null);}function zt(){let[t,n]=useState(ro);return useEffect(()=>{let o=l=>n(l);return $n.add(o),Ps(),()=>{$n.delete(o),Ds();}},[]),t}var Wo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Vt({color:t}){let n=zt();return jsx(Text,{color:t,children:Wo[n%Wo.length]})}var ln={in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6};var Gs="\u25CB",Go="\u2713",zo="\u2715",zs="\u21BB",Vs="\u2500",js="\u25B6",Tt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22"},Us={in_progress:{icon:js,label:"RUN",fg:e.green,bg:Tt.green,bold:true,spinner:true},retrying:{icon:zs,label:"RETRY",fg:e.yellow,bg:Tt.yellow,spinner:true},review:{icon:Gt,label:"REVIEW",fg:e.blue,bg:Tt.blue},todo:{icon:Gs,label:"TODO",fg:e.dim,bg:Tt.neutral},done:{icon:Go,label:"DONE",fg:e.green,bg:Tt.green},failed:{icon:zo,label:"FAIL",fg:e.red,bg:Tt.red,bold:true},cancelled:{icon:Vs,label:"OFF",fg:e.dim,bg:Tt.neutral}},Hs={1:{color:e.red,label:"!!!"},2:{color:e.yellow,label:"!!"},3:{color:e.dim,label:"!"},4:{color:e.ghost,label:it}};var vn=Fn.memo(function({task:n,selected:o,width:l,agentNameMap:d}){let f$1=Us[n.status],T=n.status==="in_progress"||n.status==="retrying",b=Hs[n.priority]??{color:e.ghost,label:it},y,x;if(n.status==="done")y=Go,x=e.green;else if(n.status==="failed")y=zo,x=e.red;else if(T){let G=Date.now()-new Date(n.updated_at).getTime();y=f(G),x=e.cyan;}else y="\u2014",x=void 0;let I=o?"\u25B8":" ",v=10,P=4,F=14,H=7,O=2+v+P+F+H,N=l?Math.max(10,l-O):40,D=n.assignee?d?.get(n.assignee)??n.assignee:void 0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[I," "]}),jsx(Box,{width:v,children:jsx(Text,{backgroundColor:f$1.bg,color:f$1.fg,bold:f$1.bold,children:f$1.spinner?jsxs(Fragment,{children:[" ",jsx(Vt,{color:f$1.fg})," ",f$1.label," "]}):jsxs(Fragment,{children:[" ",f$1.icon," ",f$1.label," "]})})}),jsx(Box,{width:P,children:jsx(Text,{color:b.color,bold:n.priority<=2,children:b.label})}),jsxs(Box,{width:N,children:[jsx(Text,{wrap:"truncate",bold:o||T,color:o?e.white:T?e.silver:void 0,children:n.title.length>N?n.title.slice(0,N-1)+"\u2026":n.title}),(n.attachments?.length??0)>0&&jsxs(Text,{color:e.dim,children:[" ","\u{1F4CE}",n.attachments.length]})]}),jsx(Box,{width:F,children:D?jsxs(Text,{backgroundColor:Tt.green,color:e.green,wrap:"truncate",children:[" ",D.length>F-2?D.slice(0,F-3)+"\u2026":D," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:H,justifyContent:"flex-end",children:jsx(Text,{color:x,dimColor:!x,children:y})})]})});var Ys="\u2715",Vo="\u25CB",Ks="\u25B6",Zs="\u2713",wt={green:"#0f2d1f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},Js={running:{icon:Ks,label:"ACTIVE",fg:e.green,bg:wt.green,bold:true,spinner:true},idle:{icon:Vo,label:"IDLE",fg:e.dim,bg:wt.neutral},error:{icon:Ys,label:"ERROR",fg:e.red,bg:wt.red,bold:true},disabled:{icon:Vo,label:"OFF",fg:e.ghost,bg:wt.neutral}},so={running:0,idle:1,error:2,disabled:3},Uo=Fn.memo(function({agent:n,selected:o,width:l,runningEntry:d,currentTaskTitle:f$1,teamName:T,isLead:b}){let y=Js[n.status],x=n.status==="running",I,v;if(x&&d){let R=Date.now()-new Date(d.started_at).getTime();I=f(R),v=e.cyan;}else n.stats.total_runs>0?(I=`${n.stats.tasks_completed}/${n.stats.total_runs}`,v=n.stats.tasks_completed>0?e.green:e.dim):(I="\u2014",v=void 0);let P=o?"\u25B8":" ",F=11,H=10,O=T?Math.min(T.length+2,14):0,N=Math.max(6,22-O),D=7,G=2+F+H+O+N+D,Y=l?Math.max(8,l-G):20,V,W,A=false;x&&f$1?(V=f$1,W=e.white,A=true):n.role?(V=n.role,W=e.dim):(V="\u2014",W=e.ghost);let C=n.stats.total_runs>0,M=C?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:[P," "]}),jsx(Box,{width:F,children:jsx(Text,{backgroundColor:y.bg,color:y.fg,bold:y.bold,children:y.spinner?jsxs(Fragment,{children:[" ",jsx(Vt,{color:y.fg})," ",y.label," "]}):jsxs(Fragment,{children:[" ",y.icon," ",y.label," "]})})}),jsx(Box,{width:Y,children:jsxs(Text,{wrap:"truncate",bold:o||x,color:o?e.white:x?e.green:e.silver,children:[n.autonomous&&jsxs(Text,{color:e.cyan,children:[Mt," "]}),b&&jsxs(Text,{color:e.amber,children:[oo," "]}),n.name]})}),jsx(Box,{width:H,children:jsxs(Text,{backgroundColor:wt.neutral,color:e.dim,children:[" ",n.adapter," "]})}),T&&jsx(Box,{width:O,children:jsxs(Text,{backgroundColor:wt.amber,color:e.amber,wrap:"truncate",children:[" ",T," "]})}),jsx(Box,{width:N,children:jsx(Text,{color:W,bold:A,wrap:"truncate",children:V})}),jsx(Box,{width:D,justifyContent:"flex-end",children:C&&!x?jsxs(Text,{color:M>=80?e.green:M>=50?e.yellow:e.red,children:[I," ",Zs]}):jsx(Text,{color:v,dimColor:!v,children:I})})]})});function Ho({teamName:t,memberCount:n,leadName:o,width:l}){let d=`${n} agent${n!==1?"s":""}`,f=o?` ${it} ${oo} ${o}`:"",T=` ${Gt} ${t.toUpperCase()} ${it} ${d}${f} `,b=3,y=Math.max(0,l-b-T.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:"\u2500".repeat(b)}),jsx(Text,{backgroundColor:wt.amber,color:e.amber,bold:true,children:T}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(y)})]})}var Qs="\u25C7";function Xo({memberCount:t,width:n}){let o=`${t} agent${t!==1?"s":""}`,l=` ${Qs} UNASSIGNED ${it} ${o} `,d=3,f=Math.max(0,n-d-l.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:"\u2500".repeat(d)}),jsx(Text,{backgroundColor:wt.neutral,color:e.dim,children:l}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(f)})]})}var qo="\u2713",Yo="\u2715",ti="\u2016",ni="\u25C9",dn={green:"#0f2d1f",amber:"#2d1f0a",neutral:"#1a1a22"},oi={active:{icon:ni,label:"ACTIVE",fg:e.green,bg:dn.green,bold:true},paused:{icon:ti,label:"PAUSED",fg:e.dim,bg:dn.neutral},achieved:{icon:qo,label:"DONE",fg:e.amber,bg:dn.amber,bold:true},abandoned:{icon:Yo,label:"DROP",fg:e.ghost,bg:dn.neutral}},Ko=Fn.memo(function({goal:n,selected:o,width:l,agentNameMap:d}){let f=oi[n.status],T=o?"\u25B8":" ",b=11,y=14,x=7,I=2+b+y+x,v=l?Math.max(10,l-I):40,P=n.assignee?d?.get(n.assignee)??n.assignee:void 0,F,H;if(n.status==="achieved")F=qo,H=e.amber;else if(n.status==="abandoned")F=Yo,H=e.ghost;else {let O=Date.now()-new Date(n.created_at).getTime(),N=Math.floor(O/864e5);F=N>0?`${N}d`:"<1d",H=e.dim;}return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[T," "]}),jsx(Box,{width:b,children:jsxs(Text,{backgroundColor:f.bg,color:f.fg,bold:f.bold,children:[" ",f.icon," ",f.label," "]})}),jsx(Box,{width:v,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>v?n.title.slice(0,v-1)+"\u2026":n.title})}),jsx(Box,{width:y,children:P?jsxs(Text,{backgroundColor:dn.green,color:e.green,wrap:"truncate",children:[" ",P.length>y-2?P.slice(0,y-3)+"\u2026":P," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:x,justifyContent:"flex-end",children:jsx(Text,{color:H,dimColor:!H,children:F})})]})});var ri={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"};function Ht({label:t,width:n,color:o}){let l=n-4,d=` ${t} `,f=3,T=Math.max(0,l-f-d.length);return jsxs(Text,{color:o??e.ghost,children:[" ","\u2500".repeat(f),d,"\u2500".repeat(T)]})}function Zo({task:t,height:n,width:o,taskLogs:l,agentNameMap:d}){let f=Cn[t.status]??e.dim,T=t.priority<=2?t.priority===1?e.red:e.yellow:void 0,b=24,y=!!t.description?.trim(),x=!!t.proof?.agent_summary,I=(t.proof?.files_changed?.length??0)>0,v=(l?.length??0)>0,P=(t.attachments?.length??0)>0,F=y?t.description.split(`
|
|
3
|
+
`):[],H=x?t.proof.agent_summary.split(`
|
|
4
|
+
`):[],O=3;P&&(O+=2+t.attachments.length),y?(O+=1,O+=Math.min(F.length,Math.max(1,Math.ceil((n-10)*.3)))):x||(O+=2),x&&(O+=2),I&&(O+=1),v&&(O+=2);let N=Math.max(0,n-O),D=0,G=0;x&&v?(D=Math.max(1,Math.floor(N*.4)),G=Math.max(1,N-D)):x?D=N:v&&(G=N);let Y=y?F.slice(0,Math.max(1,Math.ceil((n-10)*.3))):[],V=H.slice(0,D);return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:b,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:f,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?d?.get(t.assignee)??t.assignee:"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:b,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:b,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.join(", "):"\u2014"})]})]}),P&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Ht,{label:`attachments (${t.attachments.length})`,width:o,color:e.dim}),t.attachments.map((W,A)=>jsxs(Text,{color:e.cyan,wrap:"truncate",children:[" ",W]},`a${A}`))]}),y&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),Y.map((W,A)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",W]},`d${A}`))]}),!y&&!x&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:" No description."})]}),x&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Ht,{label:"result",width:o,color:e.dim}),V.map((W,A)=>jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",W]},`r${A}`))]}),I&&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})]})]}),v&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Ht,{label:"activity",width:o,color:e.dim}),l.slice(-G).map((W,A)=>{let C=W.msgType??"info",M=ri[C]??"\u2502",R=W.color;C==="tool"?R=e.cyan:C==="file"?R=e.purple:C==="error"?R=e.red:C==="lifecycle"?R=e.green:C==="system"&&(R=e.dim);let ge=Math.max(10,o-12),ie=W.text.length>ge?W.text.slice(0,ge-1)+"\u2026":W.text;return jsxs(Box,{children:[jsxs(Text,{color:e.ghost,children:[" ",W.time," "]}),jsxs(Text,{color:C==="error"?e.red:e.dim,children:[M," "]}),jsx(Text,{color:R,bold:C==="lifecycle",children:ie})]},A)})]})]})}var Mn=[{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 si="\u25CF",er="\u25CB",ii="\u2713",ai="\u2715",li="\u2191",ci="\u2193",di="\u03A3",ui="\u25B6",gi="\u21BB",Jo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],io=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],He={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"};function tr({color:t}){let n=zt();return jsx(Text,{color:t,children:Jo[n%Jo.length]})}function mi(){let t=zt(),n=Math.floor(t/10)%2===0;return jsx(Text,{color:n?e.amber:e.amberDim,bold:true,children:_t})}function fi({width:t,active:n}){let o=Math.max(4,Math.floor(t*.08)),l=2,d=zt(),f=Math.ceil((t+o)/l),T=n?d%(f*2):0;if(!n)return jsx(Box,{paddingX:1,children:jsx(Text,{color:e.ghost,children:ye.repeat(t)})});let b=T<f?T*l:(f*2-T)*l,y=Math.max(0,b-o),x=Math.min(t,b),I=y,v=Math.max(0,x-y),P=Math.max(0,t-x);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(I)}),jsx(Text,{color:e.amber,children:ye.repeat(v)}),jsx(Text,{color:e.ghost,children:ye.repeat(P)})]})}function pi({data:t,width:n,color:o}){if(t.length===0)return null;let l=t.slice(-n),d=Math.max(...l,1),f=l.map(T=>{let b=Math.round(T/d*(io.length-1));return io[b]??io[0]}).join("");return jsx(Text,{color:o,children:f})}function hi({projectName:t,activeView:n,mode:o,stats:l,uptime:d,width:f,version:T,latestVersion:b}){let y=o==="watching";return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:f,children:[jsxs(Box,{gap:0,children:[jsx(mi,{}),jsx(Text,{color:e.amber,bold:true,children:" ORCH"}),T&&jsxs(Text,{color:e.ghost,children:[" ",T]}),b&&b!==T&&jsxs(Text,{backgroundColor:He.green,color:e.green,bold:true,children:[" UPDATE ",b," "]}),jsxs(Text,{color:e.ghost,children:[" ",it," "]}),jsx(Text,{color:e.silver,children:t})]}),jsx(Box,{gap:0,children:Mn.map((x,I)=>{let v=n===x.id;return jsxs(Fn.Fragment,{children:[I>0&&jsx(Text,{children:" "}),v?jsxs(Text,{backgroundColor:e.amber,color:"#0a0a0c",bold:true,children:[" ",x.key," ",x.label," "]}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:x.key}),jsxs(Text,{color:e.dim,children:[" ",x.label.toLowerCase()]})]})]},x.id)})}),jsxs(Box,{gap:0,children:[y?jsxs(Text,{backgroundColor:He.green,color:e.green,bold:true,children:[" ",si," WATCHING"," "]}):jsxs(Text,{backgroundColor:He.neutral,color:e.dim,children:[" ",er," IDLE"," "]}),l.running>0&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{backgroundColor:He.green,color:e.green,children:[" ",jsx(tr,{color:e.green})," ",l.running," active"," "]})]}),d&&jsxs(Text,{color:e.ghost,children:[" ",d]})]})]})}function xi({stats:t,tokens:n,width:o,sparklineData:l}){let f=[{icon:ui,label:"RUN",count:t.running,fg:e.green,bg:He.green,bold:true,spinner:true,show:t.running>0},{icon:gi,label:"RETRY",count:t.retrying,fg:e.yellow,bg:He.yellow,show:t.retrying>0},{icon:Gt,label:"REVIEW",count:t.review,fg:e.blue,bg:He.blue,show:t.review>0},{icon:er,label:"TODO",count:t.todo,fg:e.dim,bg:He.neutral,show:t.todo>0},{icon:ii,label:"DONE",count:t.done,fg:e.green,bg:He.green,show:t.done>0},{icon:ai,label:"FAIL",count:t.failed,fg:e.red,bg:He.red,bold:true,show:t.failed>0},{icon:_t,label:"TEAMS",count:t.teams,fg:e.amber,bg:He.amber,show:t.teams>0}].filter(x=>x.show),T=n.total>0,b=x=>x>=1e3?`${(x/1e3).toFixed(1)}k`:String(x),y=l&&l.length>0?Math.min(16,l.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(tr,{color:x.fg})," ",x.count," ",x.label," "]}):jsxs(Fragment,{children:[" ",x.icon," ",x.count," ",x.label," "]})},x.label)),f.length===0&&jsxs(Text,{backgroundColor:He.neutral,color:e.dim,children:[" ","NO TASKS"," "]})]}),jsxs(Box,{gap:0,children:[y>0&&l&&jsxs(Fragment,{children:[jsx(pi,{data:l,width:y,color:e.amberDim}),jsx(Text,{children:" "})]}),T&&jsxs(Text,{backgroundColor:He.amber,color:e.cyan,children:[" ",li,b(n.input)," ",ci,b(n.output)," ",it," ",di,b(n.total)," "]})]})]})}var nr=Fn.memo(function(n){let o=Math.max(10,n.width-2),l=n.stats.running>0;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{height:1}),jsx(hi,{projectName:n.projectName,activeView:n.activeView,mode:n.mode,stats:n.stats,uptime:n.uptime,width:n.width,version:n.version,latestVersion:n.latestVersion}),jsx(Box,{height:1}),jsx(xi,{stats:n.stats,tokens:n.tokens,width:n.width,sparklineData:n.sparklineData}),jsx(fi,{width:o,active:l})]})});var Xt={goal:{sub:["add","list","show","status","delete"],help:"Manage goals"},task:{sub:["add","list","show","cancel","retry","assign","approve","reject","delete"],help:"Manage tasks"},agent:{sub:["add","list","disable","enable","delete","autonomous"],help:"Manage agents"},team:{sub:["create","list","join","leave","disband","set-lead"],help:"Manage teams"},run:{args:"[id]",help:"Run task (or selected)"},"run-all":{help:"Run all todo tasks"},watch:{help:"Start watch mode (auto-dispatch)"},pause:{help:"Pause watch mode"},config:{sub:["activity-filter","max-concurrent"],help:"TUI settings"},status:{help:"Show orchestrator status"},help:{help:"List all commands"},quit:{help:"Exit the TUI"}};function ao(t){if(!t.startsWith("/"))return null;let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let b=n;if(!b)return null;let y=Object.keys(Xt).find(x=>x.startsWith(b)&&x!==b);return y?y.slice(b.length):null}let l=n.slice(0,o),d=Xt[l];if(!d?.sub)return null;let f=n.slice(o+1);if(!f)return null;let T=d.sub.find(b=>b.startsWith(f)&&b!==f);return T?T.slice(f.length):null}function or(t){if(!t.startsWith("/"))return [];let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let b=n.toLowerCase(),y=[];for(let[x,I]of Object.entries(Xt))if(!b||x.startsWith(b)){let v=I.args?` ${I.args}`:"";if(y.push({cmd:`/${x}${v}`,desc:I.help,subs:I.sub?.join(" \xB7 ")}),b&&x===b&&I.sub)for(let P of I.sub)y.push({cmd:`/${x} ${P}`,desc:`${I.help}: ${P}`});}return y}let l=n.slice(0,o),d=Xt[l];if(!d?.sub)return [];let f=n.slice(o+1).toLowerCase(),T=[];for(let b of d.sub)(!f||b.startsWith(f))&&T.push({cmd:`/${l} ${b}`,desc:`${d.help}: ${b}`});return T}var Rn=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 Ti="\u2588",rr=Fn.memo(function({mode:n,value:o,completion:l,activeView:d,canRun:f,canNew:T,canApprove:b,canReject:y,canCancel:x,canDelete:I,canUndo:v,canEdit:P,canForceStop:F,canToggleAuto:H,autoActive:O,canPause:N,isPaused:D,canToggleShowAll:G,showAllActive:Y,hasDetail:V,itemCount:W,itemLabel:A,width:C,hasSuggestions:M}){if(n==="command"){let R=M?" \u2191\u2193 select Tab fill Esc \u2715":" Enter exec \u2191\u2193 history Tab complete Esc \u2715",ge=Math.max(4,C-6-R.length-(l?.length??0)-1),ie=o.length>ge?"\u2026"+o.slice(-(ge-1)):o;return jsx(Box,{paddingX:2,justifyContent:"space-between",width:C,children:jsxs(Box,{children:[jsx(Text,{color:e.amber,children:"/ "}),jsx(Text,{color:e.white,children:ie}),l&&jsx(Text,{color:e.ghost,children:l}),jsx(Text,{color:e.amber,children:Ti}),jsx(Text,{color:e.dim,children:R})]})})}return jsxs(Box,{paddingX:2,justifyContent:"space-between",width:C,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",T&&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"]}),x&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"C"})," cancel"]}),b&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.green,children:"A"})," approve"]}),y&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"X"})," reject"]}),P&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"E"})," edit"]}),F&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"S"})," stop"]}),N&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"P"}),D?" resume":" pause"]}),H&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"U"}),O?" auto off":" auto on"]}),G&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"S"}),Y?" collapse":" show all"]}),I&&!b&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"D"})," delete"]}),v&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.yellow,children:"Z"})," undo"]}),V&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Esc"})," close"]}),!V&&(d==="tasks"||d==="agents"||d==="goals")&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Enter"})," detail"]})," ",jsx(Text,{bold:true,color:e.gray,children:"Q"})," quit"]}),W>0&&jsxs(Text,{color:e.dim,children:[W," ",A]})]})});var Bn="\u2588";function ir({title:t,steps:n,onComplete:o,onCancel:l,width:d,height:f,onPasteImage:T,footerExtra:b}){let [y,x]=useState(0),[I,v]=useState({}),[P,F]=useState(()=>{let L=n.find(B=>!B.skip?.({}));return L?.type==="text"&&L.defaultValue?L.defaultValue:""}),[H,O]=useState(()=>{let L=n.find(B=>!B.skip?.({}));return L?.type==="text"&&L.defaultValue?L.defaultValue.length:0}),[N,D]=useState(()=>{let L=n.find(B=>!B.skip?.({}));return L?.type==="textarea"&&L.defaultValue?L.defaultValue.split(`
|
|
5
|
+
`):[""]}),[G,Y]=useState(0),[V,W]=useState(0),[A,C]=useState(()=>{let L=n.find(B=>!B.skip?.({}));if(L?.type==="select"&&L.defaultValue){let k=(L.getOptions?.({})??L.options??[]).findIndex(j=>j.value===L.defaultValue);return k>=0?k:0}return 0}),M=useMemo(()=>n.filter(L=>!L.skip?.(I)),[n,I]),R=M[y],ge=M.length,[Me,ot]=useState(new Set),qe=useMemo(()=>!R||R.type!=="select"&&R.type!=="multiselect"?[]:R.getOptions?.(I)??R.options??[],[R,I]),Ve=Math.min(A,Math.max(0,qe.length-1)),Ye=L=>{let B={...I,[R.id]:L};v(B),F(""),O(0),D([""]),Y(0),W(0),C(0),ot(new Set);let k=R.id,K=n.findIndex(Z=>Z.id===k)+1;for(;K<n.length;){let Z=n[K];if(Z&&!Z.skip?.(B))break;K++;}if(K>=n.length)o(B);else {let Z=n[K].id,$e=n.filter(Te=>!Te.skip?.(B)).findIndex(Te=>Te.id===Z);x($e>=0?$e:0);let me=n[K];if(me.type==="text"){let Te=me.defaultValue??"";F(Te),O(Te.length);}else if(me.type==="textarea"){let Te=me.defaultValue?me.defaultValue.split(`
|
|
6
|
+
`):[""];D(Te),Y(Te.length-1),W(Te[Te.length-1].length);}else if(me.type==="select"){let Te=me.getOptions?.(B)??me.options??[];if(me.defaultValue){let mt=Te.findIndex(Ze=>Ze.value===me.defaultValue);C(mt>=0?mt:0);}else C(0);}else me.type==="multiselect"&&(C(0),me.defaultValue?ot(new Set(me.defaultValue.split(","))):ot(new Set));}},Oe=()=>{if(y===0){l();return}let L=R.id,k=n.findIndex(Q=>Q.id===L)-1;for(;k>=0;){let Q=n[k];if(Q&&!Q.skip?.(I))break;k--;}if(k<0){l();return}let j=n[k].id,K=M.findIndex(Q=>Q.id===j);x(K>=0?K:0);let Z=n[k];if(Z.type==="text"){let Q=I[Z.id]??Z.defaultValue??"";F(Q),O(Q.length);}else if(Z.type==="textarea"){let Q=I[Z.id]??Z.defaultValue??"",$e=Q?Q.split(`
|
|
7
|
+
`):[""];D($e),Y($e.length-1),W($e[$e.length-1].length);}else if(Z.type==="multiselect"){C(0);let Q=I[Z.id];ot(Q?new Set(Q.split(",")):new Set);}else {let Q=Z.getOptions?.(I)??Z.options??[],$e=I[Z.id],me=Q.findIndex(Te=>Te.value===$e);C(me>=0?me:0);}};if(useInput((L,B)=>{if(R){if(B.escape){y===0?l():Oe();return}if(B.ctrl&&(L==="v"||L==="i")&&T&&(R.type==="text"||R.type==="textarea")){T();return}if(R.type==="text"){if(B.return){let k=P.trim();if(R.required&&!k)return;Ye(k);return}if(B.leftArrow){O(k=>Math.max(0,k-1));return}if(B.rightArrow){O(k=>Math.min(P.length,k+1));return}if(B.backspace||B.delete){if(H===0&&P.length===0&&y>0){Oe();return}H>0&&(F(k=>k.slice(0,H-1)+k.slice(H)),O(k=>k-1));return}L&&!B.ctrl&&!B.meta&&!B.escape&&(F(k=>k.slice(0,H)+L+k.slice(H)),O(k=>k+L.length));return}if(R.type==="textarea"){if(B.return&&!B.shift){let k=N.join(`
|
|
8
|
+
`).trim();if(R.required&&!k)return;Ye(k);return}if(B.return&&B.shift){D(k=>{let j=k[G]??"",K=j.slice(0,V),Z=j.slice(V),Q=[...k];return Q.splice(G,1,K,Z),Q}),Y(k=>k+1),W(0);return}if(B.upArrow){G>0&&(Y(k=>k-1),W(k=>Math.min(k,(N[G-1]??"").length)));return}if(B.downArrow){G<N.length-1&&(Y(k=>k+1),W(k=>Math.min(k,(N[G+1]??"").length)));return}if(B.leftArrow){V>0?W(k=>k-1):G>0&&(Y(k=>k-1),W((N[G-1]??"").length));return}if(B.rightArrow){let k=(N[G]??"").length;V<k?W(j=>j+1):G<N.length-1&&(Y(j=>j+1),W(0));return}if(B.backspace||B.delete){if(V===0&&G===0)return;if(V>0)D(k=>{let j=[...k],K=j[G]??"";return j[G]=K.slice(0,V-1)+K.slice(V),j}),W(k=>k-1);else {let k=(N[G-1]??"").length;D(j=>{let K=[...j],Z=K[G-1]??"",Q=K[G]??"";return K.splice(G-1,2,Z+Q),K}),W(k),Y(j=>j-1);}return}if(L&&!B.ctrl&&!B.meta&&!B.escape){let k=L.split(/\r?\n/);if(k.length===1)D(j=>{let K=[...j],Z=K[G]??"";return K[G]=Z.slice(0,V)+L+Z.slice(V),K}),W(j=>j+L.length);else {let j=G,K=V;D(Z=>{let Q=[...Z],$e=Q[j]??"",me=$e.slice(0,K),Te=$e.slice(K),mt=k[0]??"",Ze=k[k.length-1]??"",un=[me+mt,...k.slice(1,-1),Ze+Te];return Q.splice(j,1,...un),Q}),Y(j+k.length-1),W((k[k.length-1]??"").length);}}return}if(R.type==="select"||R.type==="multiselect"){if(B.upArrow||L==="k"){C(k=>Math.max(0,k-1));return}if(B.downArrow||L==="j"){C(k=>Math.min(qe.length-1,k+1));return}if(B.backspace||B.delete){Oe();return}if(R.type==="select"){if(B.return||B.tab){let k=qe[Ve];k&&Ye(k.value);return}if(L>="1"&&L<="9"){let k=parseInt(L,10)-1;if(k<qe.length){let j=qe[k];j&&Ye(j.value);}return}}else {if(L===" "){let k=qe[Ve];k&&ot(j=>{let K=new Set(j);return K.has(k.value)?K.delete(k.value):K.add(k.value),K});return}if(B.return){let k=Array.from(Me).join(",");Ye(k);return}}}}}),!R)return null;let Pe=`${y+1}/${ge}`,Ke=Math.max(2,f-4),we=0;Ve>=Ke&&(we=Ve-Ke+1);let De=qe.slice(we,we+Ke);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:[" ",bt,bt," "]}),jsxs(Text,{color:e.dim,children:["step ",Pe]})]}),jsxs(Box,{children:[jsx(Text,{children:" "}),M.map((L,B)=>jsxs(Text,{color:B===y?e.amber:B<y?e.green:e.ghost,children:[B===y?"\u25CF":B<y?"\u2713":"\u25CB"," "]},L.id))]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.white,bold:true,children:[" ",R.label]}),!R.required&&jsx(Text,{color:e.dim,children:" (optional, Enter to skip)"})]}),R.type==="text"&&jsxs(Box,{children:[jsxs(Text,{color:e.amber,children:[" ",">"," "]}),P.length>0?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:P.slice(0,H)}),jsx(Text,{color:e.amber,children:Bn}),jsx(Text,{color:e.white,children:P.slice(H)})]}):R.placeholder?jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:R.placeholder}),jsx(Text,{color:e.amber,children:Bn})]}):jsx(Text,{color:e.amber,children:Bn})]}),R.type==="textarea"&&(()=>{let L=Math.max(3,f-6),B=0;G>=L&&(B=G-L+1);let k=N.slice(B,B+L),j=String(N.length).length;return jsxs(Box,{flexDirection:"column",children:[k.map((K,Z)=>{let Q=Z+B,$e=String(Q+1).padStart(j," "),me=Q===G;return jsxs(Box,{children:[jsxs(Text,{color:e.dim,children:[" ",$e," "]}),jsxs(Text,{color:e.ghost,children:["\u2502"," "]}),me?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:K.slice(0,V)}),jsx(Text,{color:e.amber,children:Bn}),jsx(Text,{color:e.white,children:K.slice(V)})]}):jsx(Text,{color:e.silver,children:K||" "})]},Q)}),N.length===1&&N[0]===""&&R.placeholder&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","".padStart(j," ")," ",R.placeholder]})})]})})(),R.type==="select"&&jsx(Box,{flexDirection:"column",children:De.map((L,B)=>{let k=B+we,j=k===Ve,K=k<9?`${k+1}`:" ";return jsxs(Box,{children:[jsx(Text,{color:j?e.amber:e.ghost,children:j?" \u25B8 ":` ${K} `}),jsx(Text,{color:j?e.white:e.silver,bold:j,children:L.label}),L.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",bt," ",L.hint.replace(/\n/g," ")]})]},L.value)})}),R.type==="multiselect"&&jsxs(Box,{flexDirection:"column",children:[De.map((L,B)=>{let j=B+we===Ve,K=Me.has(L.value);return jsxs(Box,{children:[jsx(Text,{color:j?e.amber:e.ghost,children:j?" \u25B8 ":" "}),jsx(Text,{color:K?e.green:e.dim,children:K?"[\u2713]":"[ ]"}),jsxs(Text,{color:j?e.white:e.silver,bold:j,children:[" ",L.label]}),L.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",bt," ",L.hint.replace(/\n/g," ")]})]},L.value)}),Me.size>0&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","\u2514"," ",Me.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"?"Shift+Enter newline Enter confirm \u2190\u2191\u2192\u2193 navigate":"\u2190\u2192 move Enter confirm",T&&(R.type==="text"||R.type==="textarea")?" Ctrl+V paste image":""," Esc ",y>0?"back":"cancel"]}),b&&jsxs(Text,{color:e.amber,children:[" ",b]})]})]})}var Si="\u256D",ki="\u256E",Ii="\u2570",Ci="\u256F",lt="\u2502";function $i({children:t,cw:n}){return jsxs(Text,{children:[jsx(Text,{color:e.ghost,children:lt}),jsxs(Text,{children:[" ",t.padEnd(n)," "]}),jsx(Text,{color:e.ghost,children:lt})]})}function En({cw:t}){return jsx($i,{cw:t,children:""})}function Ln({count:t,config:n,width:o}){if(t>=3)return null;let l=Math.min((o??44)-4,50),d=l-6,f=bt.repeat(l-2),T=jsxs(Text,{color:e.ghost,children:[Si,f,ki]}),b=jsxs(Text,{color:e.ghost,children:[Ii,f,Ci]});if(t>0){let x=n.hints[0],I=x?` ${x.key} ${x.label}`:"";return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[T,jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),jsx(Text,{color:e.amber,children:_t}),jsxs(Text,{color:e.silver,children:[" ",n.nudge.padEnd(d-2-I.length)]}),x&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",x.key]}),jsxs(Text,{color:e.gray,children:[" ",x.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]}),b]})}let y=n.hints.reduce((x,I,v)=>x+I.key.length+1+I.label.length+(v>0?3:0),0);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[T,jsx(En,{cw:d}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),jsx(Text,{color:e.amber,children:_t}),jsxs(Text,{color:e.white,bold:true,children:[" ",n.title]}),jsx(Text,{children:" ".repeat(Math.max(0,d-n.title.length-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]}),jsx(En,{cw:d}),n.description.map((x,I)=>jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),jsx(Text,{color:e.silver,children:x.padEnd(d)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]},I)),jsx(En,{cw:d}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),n.hints.map((x,I)=>jsxs(Fn.Fragment,{children:[I>0&&jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amber,children:x.key}),jsxs(Text,{color:e.gray,children:[" ",x.label]})]},I)),jsx(Text,{children:" ".repeat(Math.max(0,d-y))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]}),jsx(En,{cw:d}),b]})}var cr=[{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"}],dr=[{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"}],ur=[{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"}],gr=[{value:"",label:"Default",hint:"use shell adapter default"}],Ai=[{value:"claude",label:"Claude",hint:"Claude Code CLI"},{value:"codex",label:"Codex",hint:"OpenAI Codex CLI"},{value:"cursor",label:"Cursor",hint:"Cursor Agent CLI"},{value:"shell",label:"Shell",hint:"custom shell command"}],mr=[{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"}],lr=80;function fr(t){return t.filter(n=>n.status!=="disabled").map(n=>{let o=(n.role??n.adapter).split(`
|
|
9
|
+
`)[0].trim(),l=o.length>lr?o.slice(0,lr-1)+"\u2026":o;return {value:n.id,label:n.name,hint:l}})}function On(t,n="Auto-assign",o="orchestrator picks the best agent"){return [{value:"",label:n,hint:o},...fr(t)]}var uo=[{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 pr(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 hr(t){let n=pr(t);return [{id:"name",label:"Agent name",type:"text",placeholder:"e.g. alpha, frontend-bot, reviewer",required:true},{id:"adapter",label:"Provider",type:"select",options:Ai},{id:"model",label:"Model",type:"select",getOptions:o=>o.adapter==="codex"?dr:o.adapter==="cursor"?ur:o.adapter==="shell"?gr:cr},{id:"role",label:"Role / specialization",type:"select",options:uo},{id:"role_custom",label:"Describe the role",type:"textarea",placeholder:"e.g. Specialist in React and TypeScript",skip:o=>o.role!=="__custom__"},{id:"team",label:"Join team",type:"select",options:n,skip:()=>n.length<=1}]}function xr(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0;return {name:t.name,adapter:t.adapter||"claude",role:n,model:t.model||void 0,approval_policy:"auto",team_id:t.team||void 0}}function br(t){let n=fr(t);return [{id:"name",label:"Team name",type:"text",placeholder:"e.g. frontend, backend, qa",required:true},{id:"lead",label:"Team lead",type:"select",options:n},{id:"members",label:"Team members",type:"multiselect",getOptions:o=>n.filter(l=>l.value!==o.lead),skip:o=>!n.some(l=>l.value!==o.lead)},{id:"description",label:"Description",type:"textarea",placeholder:"Optional team purpose..."}]}function Tr(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 yr(t){let n=On(t);return [{id:"title",label:"Task title",type:"text",placeholder:"What needs to be done?",required:true},{id:"priority",label:"Priority",type:"select",options:mr,defaultValue:"3"},{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 wr(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 Sr(t,n){let o=On(n,"None / Auto","remove assignee");return [{id:"title",label:"Task title",type:"text",defaultValue:t.title,required:true},{id:"priority",label:"Priority",type:"select",options:mr,defaultValue:String(t.priority)},{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 kr(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description??""}}function Ir(t,n){let o=uo.find(b=>b.value===t.role),l=o?t.role:t.role?"__custom__":"",d=t.adapter==="codex"?dr:t.adapter==="cursor"?ur:t.adapter==="shell"?gr:cr,f=pr(n),T=n?.find(b=>b.members.some(y=>y.agent_id===t.id))?.id;return [{id:"name",label:"Agent name",type:"text",defaultValue:t.name,required:true},{id:"model",label:"Model",type:"select",options:d,defaultValue:t.config.model??""},{id:"role",label:"Role / specialization",type:"select",options:uo,defaultValue:l},{id:"role_custom",label:"Describe the role",type:"textarea",defaultValue:t.role&&!o?t.role:"",placeholder:"e.g. Specialist in React and TypeScript",skip:b=>b.role!=="__custom__"},{id:"team",label:"Team",type:"select",options:f,defaultValue:T??"",skip:()=>f.length<=1}]}var Mi=[{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"}],_i=[{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"}];function Cr(t,n){return [{id:"setting",label:"Setting",type:"select",options:[{value:"activity_filter",label:"Activity filter",hint:`current: ${t}`},{value:"max_concurrent",label:"Max concurrent agents",hint:`current: ${n}`}]},{id:"activity_filter",label:"Activity filter preset",type:"select",options:_i,defaultValue:t,skip:o=>o.setting!=="activity_filter"},{id:"max_concurrent",label:"Max concurrent agents",type:"select",options:Mi,defaultValue:String(n),skip:o=>o.setting!=="max_concurrent"}]}function $r(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0;return {name:t.name,role:n,model:t.model||void 0,team_id:t.team||void 0}}function Pn(t){let n=On(t,"Any agent","auto-assign to autonomous agents");return [{id:"title",label:"Goal title",type:"text",placeholder:"What should be achieved?",required:true},{id:"assignee",label:"Assignee",type:"select",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Detailed goal description, success criteria..."}]}function vr(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description||void 0}}function Ar(t,n){let o=On(n,"Any agent","auto-assign");return [{id:"title",label:"Goal title",type:"text",defaultValue:t.title,required:true},{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:"Detailed goal description..."}]}function Mr(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description??""}}var _r=10,Rr=500,Gn=2048,Lt=500,go=new Set(["todo","failed","cancelled"]),Li={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."},Oi={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."},Pi={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."},Br=5e3,Or=0;function Gl(){Or=0;}var Pr=/^\[[\w_]+\]$/;function Dr(t){return Pr.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 Er=["#5faf87","#5fafd7","#af87ff","#d7af00","#5fd7d7","#d787af","#afaf5f","#d7875f"];function zn(t,n){let o=n.findIndex(l=>l.id===t);return Er[o>=0?o%Er.length:0]}var Di=" ".repeat(9),Vn={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},Wn=["system","lifecycle","output","tool","result","error","file","info"],qt=[{label:"all",types:Wn},{label:"text",types:["output"]},{label:"tools",types:["tool","result","file"]},{label:"errors",types:["error"]},{label:"events",types:["lifecycle","system"]}];function mo(t){let o=(qt.findIndex(l=>l.types.length===t.size&&l.types.every(d=>t.has(d)))+1)%qt.length;return qt[o]}function zl({projectName:t,tasks:n,agents:o=[],state:l,onRunTask:d,onCreateTask:f,onCancelTask:T,onRetryTask:b,onAssignTask:y,onRunAll:x,onDisableAgent:I,onEnableAgent:v,onSubscribeEvents:P,onRefreshTasks:F,onRefreshAgents:H,onRefreshState:O,onLoadHistory:N,onAddAgent:D,onDeleteAgent:G,onApproveTask:Y,onRejectTask:V,onDeleteTask:W,onUpdateTask:A,onUpdateAgent:C,onForceStopAgent:M,onCreateTeam:R,onListTeams:ge,onJoinTeam:ie,onLeaveTeam:Me,onDisbandTeam:ot,onSetTeamLead:qe,onStartWatch:Ve,onStopWatch:Ye,onToggleAutonomous:Oe,onRefreshGoals:Ot,onCreateGoal:Pe,onUpdateGoal:Ke,onUpdateGoalStatus:we,onDeleteGoal:De,onGetGoalProgress:L,initialWatchActive:B,watchError:k,messageBatchMs:j=process.env.VITEST?0:80,initialActivityFilter:K="all",onSaveActivityFilter:Z,initialMaxConcurrent:Q=a.scheduling.max_concurrent_agents,onSaveMaxConcurrent:$e,version:me,latestVersion:Te}){let{exit:mt}=useApp(),{stdout:Ze}=useStdout(),[un,Vr]=useState({w:Ze?.columns??80,h:Ze?.rows??24});useEffect(()=>{if(!Ze)return;let i=()=>Vr({w:Ze.columns,h:Ze.rows});return Ze.on("resize",i),()=>{Ze.off("resize",i);}},[Ze]);let Yt=un.w,fo=un.h,[Je,jr]=useState(n),[Se,Ur]=useState(o),[je,Hr]=useState(l),[gn,jn]=useState(B??!!l.pid),[Un,po]=useState([]),[Xr,ho]=useState(void 0),[$,Pt]=useState("tasks"),[mn,fn]=useState(0),[Hn,xo]=useState(0),[Xn,bo]=useState(0),[ke,Kt]=useState(false),[Qe,To]=useState([]),[ve,_e]=useState("none"),[St,rt]=useState(""),[ft,et]=useState(null),[kt,Zt]=useState([]),[qr,Yr]=useState(0),[Kr,Zr]=useState(()=>new Set(Wn)),[Jt,qn]=useState(-1),[Jr,Qt]=useState(0),[Dt,Yn]=useState(()=>{let i=qt.find(w=>w.label===K);return new Set(i?.types??Wn)}),pn=useMemo(()=>qt.find(w=>w.types.length===Dt.size&&w.types.every(s=>Dt.has(s)))?.label??"all",[Dt]),Kn=useMemo(()=>Dt.size>=Wn.length?Qe:Qe.filter(i=>Dt.has(i.msgType??"info")),[Qe,Dt]),[yo,Qr]=useState(Q),hn=Fn.useRef(new Rn).current,[es,en]=useState(0),[wo,So]=useState(false),[ts,Zn]=useState(0),[ns,Jn]=useState(0),[os,tn]=useState(0),[xn,pt]=useState(0),[ht,ko]=useState([]),[Nt,Qn]=useState([]),bn=useRef(ht);bn.current=ht;let U=useCallback(async i=>{let[w,s,c,g,p]=await Promise.all([F?.()??Promise.resolve(Je),H?.()??Promise.resolve(Se),O?.()??Promise.resolve(je),i?.includeTeams?ge?.()??Promise.resolve(bn.current):Promise.resolve(null),Ot?.()??Promise.resolve(Un)]);jr(w),Ur(s),Hr(c),g!==null&&ko(g),po(p),B&&jn(!!c.pid);},[F,H,O,ge,Ot,B]),Ie=useMemo(()=>[...Je].sort((i,w)=>(ln[i.status]??9)-(ln[w.status]??9)),[Je]),xt=wo?Ie:Ie.slice(0,_r),nn=Ie.length-xt.length,E=Ie[mn],Tn=useMemo(()=>{let i=new Map;for(let w of Je)i.set(w.id,w.title);return i},[Je]),It=useMemo(()=>{let i=new Map;for(let w of Se)i.set(w.id,w.name);return i},[Se]),{agentTeamMap:Wt,activeTeamCount:on,teamLeadSet:rs}=useMemo(()=>{let i=new Map,w=new Set,s=0;for(let c of ht)if(c.status==="active"){s++,w.add(c.lead_agent_id);for(let g of c.members)i.set(g.agent_id,c.name);}return {agentTeamMap:i,activeTeamCount:s,teamLeadSet:w}},[ht]),Ae=useMemo(()=>{let i=[...Se];return i.sort((w,s)=>{let c=Wt.get(w.id),g=Wt.get(s.id);return c&&!g?-1:!c&&g?1:c&&g&&c!==g?c.localeCompare(g):(so[w.status]??9)-(so[s.status]??9)}),i},[Se,Wt]),X=Ae[Hn],Ue=useMemo(()=>[...Un].sort((i,w)=>(c[i.status]??9)-(c[w.status]??9)),[Un]),q=Ue[Xn],ss=useMemo(()=>q?Je.filter(i=>i.goalId===q.id):[],[q,Je]),eo=useRef(L);eo.current=L,useEffect(()=>{if(!q||!eo.current){ho(void 0);return}let i=false;return eo.current(q.id).then(w=>{i||ho(w);}).catch(()=>{}),()=>{i=true;}},[q?.id]);let Ct=useRef(new Map),yn=useRef(new Map);useEffect(()=>{for(let[i,w]of Object.entries(je.running))Ct.current.set(w.run_id,w.agent_id),yn.current.set(w.run_id,i);if(Ct.current.size>Rr){let i=Ct.current.size-Rr,w=0;for(let s of Ct.current.keys()){if(w++>=i)break;Ct.current.delete(s),yn.current.delete(s);}}},[je.running]);let $t=useRef([]),rn=useRef(null),to=useCallback(()=>{if(rn.current=null,$t.current.length===0)return;let i=$t.current;$t.current=[],To(w=>{if(i.length>=Lt)return i.slice(-Lt);let s=Lt-i.length;return (w.length>s?w.slice(-s):w).concat(i)});},[]);useEffect(()=>()=>{rn.current&&clearTimeout(rn.current);},[]);let r=useCallback((i,w,s)=>{let c=new Date,g=c.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),p=s?.detail&&s.detail.length>Gn?s.detail.slice(0,Gn)+"\u2026[truncated]":s?.detail;$t.current.push({text:i,color:w,time:g,ts:c.getTime(),...s,detail:p}),$t.current.length>Lt*2&&($t.current=$t.current.slice(-Lt)),j===0?to():rn.current||(rn.current=setTimeout(to,j));},[to]);useEffect(()=>{k&&r(`Watch mode failed: ${k}. Tasks will not auto-dispatch.`,e.red);},[]);let Ft=useCallback((i,w,s,c)=>{let g={key:++Or,entityType:i,entityId:w,entityName:s,expiresAt:Date.now()+Br,needsForceStop:c?.needsForceStop};Qn(p=>[...p,g]),r(`\u2717 "${s}" will be deleted in ${Math.round(Br/1e3)}s \u2014 press Z to undo`,e.yellow);},[r]),is=useCallback(()=>{Qn(i=>{if(i.length===0)return i;let w=i[i.length-1];return r(`\u21B6 Undo: "${w.entityName}" restored`,e.green),i.slice(0,-1)});},[r]),Io=useCallback(async i=>{try{i.entityType==="task"&&W?await W(i.entityId):i.entityType==="agent"?(i.needsForceStop&&M&&await M(i.entityId),G&&await G(i.entityId)):i.entityType==="goal"&&De&&await De(i.entityId),r(`\u2713 Deleted "${i.entityName}"`,e.green),U();}catch(w){r(`Failed to delete "${i.entityName}": ${w instanceof Error?w.message:String(w)}`,e.red);}},[W,G,De,M,r,U]),Co=useRef(Io);Co.current=Io,useEffect(()=>{if(Nt.length===0)return;let i=setInterval(()=>{let w=Date.now(),s=[];Qn(c=>{let g=c.filter(p=>p.expiresAt<=w?(s.push(p),false):true);return s.length>0?g:c});for(let c of s)Co.current(c);},1e3);return ()=>clearInterval(i)},[Nt.length>0]),useEffect(()=>{if(!N)return;let i=w=>{let s=new Date(w.timestamp).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),c=typeof w.data=="string"?w.data:JSON.stringify(w.data),g,p=e.silver,m="output";if(w.type==="error")g=typeof w.data=="string"?w.data:JSON.stringify(w.data),g=g.slice(0,200),p=e.red,m="error";else if(w.type==="file_changed")g=String(w.data),p=e.purple,m="file";else if(w.type==="done")g="Completed",p=e.green,m="lifecycle";else if(w.type==="tool_call")g=`\u2699 ${w.data?.name??"tool"}()`,p=e.cyan,m="tool";else {let{summary:h}=zr(c);if(!h)return null;g=h;let z=Dr(g);m=z.msgType,p=z.color;}return {text:g,color:p,time:s,ts:new Date(w.timestamp).getTime(),agentId:w.agentId,taskId:w.taskId,msgType:m}};N(w=>{if(w.length===0)return;let s=w.map(i).filter(c=>c!==null);To(c=>{let g=[...s,...c];return g.length>Lt?g.slice(-Lt):g});}).catch(()=>{});},[]),useEffect(()=>{ge?.().then(ko).catch(()=>{}),Ot?.().then(po).catch(()=>{});},[]);let wn=useCallback(()=>{et({title:"NEW AGENT",steps:hr(bn.current),kind:"agent"}),_e("wizard");},[]),Sn=useCallback(()=>{Zt([]),et({title:"NEW TASK",steps:yr(Se),kind:"task"}),_e("wizard");},[Se]),as=useCallback(async()=>{try{let{detectClipboardType:i,getClipboardImage:w}=await import('./clipboard-service-PDTSZIR5.js'),s=await i();if(s!=="image")return r(s==="text"?"Clipboard has text, not image":"Clipboard is empty",e.dim),s;let c=await w();if(!c)return r("Failed to read clipboard image",e.red),"empty";let{mkdtemp:g,writeFile:p}=await import('fs/promises'),{tmpdir:m}=await import('os'),{join:h}=await import('path'),z=await g(h(m(),"orch-paste-")),at=h(z,`clipboard-${Date.now()}.${c.ext}`);return await p(at,c.data),Zt(At=>[...At,at]),r(`\u{1F4CE} Image attached (${Math.round(c.data.length/1024)}KB)`,e.green),"image"}catch{return r("Clipboard paste failed",e.red),"empty"}},[r]),ls=useCallback(i=>{et({title:"EDIT TASK",steps:Sr(i,Se),kind:"edit_task",targetId:i.id}),_e("wizard");},[Se]),$o=useCallback(()=>{et({title:"NEW TEAM",steps:br(Se),kind:"team"}),_e("wizard");},[Se]),cs=useCallback(i=>{et({title:"EDIT AGENT",steps:Ir(i,ht),kind:"edit_agent",targetId:i.id}),_e("wizard");},[ht]),vo=useCallback(()=>{et({title:"SETTINGS",steps:Cr(pn,yo),kind:"config"}),_e("wizard");},[pn,yo]),ds=useCallback(i=>{_e("none");let w=ft?.kind,s=ft?.targetId;if(et(null),w==="agent"&&D){let c=xr(i);r(`Creating agent "${c.name}"...`,e.amber),D(c.name,c.adapter,{model:c.model,role:c.role,approval_policy:c.approval_policy}).then(g=>{r(`\u2713 Created agent "${g.name}" (${g.id}, ${g.adapter})`,e.green),c.team_id&&ie?ie(c.team_id,g.id).then(p=>{r(`\u2713 Joined team "${p.name}"`,e.green),U({includeTeams:true});},p=>r(`Failed to join team: ${p instanceof Error?p.message:String(p)}`,e.red)):U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(w==="team"&&R){let c=Tr(i);r(`Creating team "${c.name}"...`,e.amber),R(c).then(g=>{r(`\u2713 Created team "${g.name}" (${g.id}, ${g.members.length} members)`,e.green),U({includeTeams:true});},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(w==="task"&&f){let c=wr(i),g=kt.length>0?[...kt]:void 0;Zt([]),r(`Creating "${c.title}"...`,e.amber),f(c.title,{priority:c.priority,description:c.description,attachments:g}).then(p=>{r(`\u2713 Created "${p.title}" (${p.id})${g?` \u{1F4CE}${g.length}`:""}`,e.green),c.assignee&&y&&y(p.id,c.assignee).catch(()=>{}),U();},p=>r(`Failed: ${p instanceof Error?p.message:String(p)}`,e.red));}else if(w==="edit_task"&&s&&A){let c=kr(i),g=kt.length>0?[...kt]:void 0;Zt([]),r("Updating task...",e.amber),A(s,{...c,attachments:g}).then(p=>{r(`\u2713 Updated "${p.title}"${g?` \u{1F4CE}${g.length}`:""}`,e.green),c.assignee&&y&&y(s,c.assignee).catch(()=>{}),U();},p=>r(`Failed: ${p instanceof Error?p.message:String(p)}`,e.red));}else if(w==="edit_agent"&&s&&C){let c=$r(i),g=c.team_id??"",p=ht.find(m=>m.members.some(h=>h.agent_id===s))?.id??"";r("Updating agent...",e.amber),C(s,{name:c.name,role:c.role,model:c.model}).then(m=>{r(`\u2713 Updated agent "${m.name}"`,e.green);let h=[];p&&p!==g&&Me&&h.push(Me(p,s).then(z=>r(`\u2713 Left team "${z.name}"`,e.green),z=>r(`Failed to leave team: ${z instanceof Error?z.message:String(z)}`,e.red))),g&&g!==p&&ie&&h.push(ie(g,s).then(z=>r(`\u2713 Joined team "${z.name}"`,e.green),z=>r(`Failed to join team: ${z instanceof Error?z.message:String(z)}`,e.red))),Promise.all(h).then(()=>U({includeTeams:h.length>0}));},m=>r(`Failed: ${m instanceof Error?m.message:String(m)}`,e.red));}else if(w==="config"){if(i.setting==="activity_filter"&&i.activity_filter){let c=qt.find(g=>g.label===i.activity_filter);c&&(Yn(new Set(c.types)),Z?.(c.label),r(`Activity filter: ${c.label}`,e.amber));}else if(i.setting==="max_concurrent"&&i.max_concurrent){let c=parseInt(i.max_concurrent,10);c>0&&(Qr(c),$e?.(c),r(`Max concurrent agents: ${c}`,e.amber));}}else if(w==="goal"&&Pe){let c=vr(i);r(`Creating goal "${c.title}"...`,e.amber),Pe(c).then(g=>{r(`\u2713 Created goal "${g.title}" (${g.id})`,e.green),U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(w==="edit_goal"&&s&&Ke){let c=Mr(i);r("Updating goal...",e.amber),Ke(s,c).then(g=>{r(`\u2713 Updated goal "${g.title}"`,e.green),U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}},[ft,D,f,R,ie,Me,y,A,C,Oe,Pe,Ke,r,U,Z,$e,ht,kt]),us=useCallback(()=>{_e("none"),et(null),Zt([]);},[]);useEffect(()=>{if(!P)return;let i=null,w=()=>{i||(i=setTimeout(()=>{i=null,U().catch(()=>{});},150));},s=P(c=>{c.type==="agent:started"&&(Ct.current.set(c.runId,c.agentId),yn.current.set(c.runId,c.taskId)),ra(c,r,Ct.current,yn.current),(c.type==="task:status_changed"||c.type==="task:created"||c.type==="task:assigned"||c.type==="agent:started"||c.type==="agent:completed"||c.type==="run:retry"||c.type==="goal:created"||c.type==="goal:status_changed"||c.type==="goal:updated"||c.type==="goal:deleted")&&w();});return ()=>{s(),i&&clearTimeout(i);}},[P,r,U]);let no=gn?"watching":"idle",gs=je.started_at?g(je.started_at):void 0,ms=je.stats.total_tokens.total,Ao=useMemo(()=>{let i={running:0,retrying:0,review:0,todo:0,done:0,failed:0,cancelled:0};for(let w of Je)w.status==="in_progress"?i.running++:w.status==="retrying"?i.retrying++:w.status==="review"?i.review++:w.status==="todo"?i.todo++:w.status==="done"?i.done++:w.status==="failed"?i.failed++:w.status==="cancelled"&&i.cancelled++;return {...i,teams:on}},[Je,on]);Ao.running;let fs={input:je.stats.total_tokens.input??0,output:je.stats.total_tokens.output??0,total:ms},kn=Math.max(4,fo-9),ps=Wt.size,hs=Se.length>ps,xs=on>0?on+(hs?1:0):0,bs=$==="goals"?Ue.length+1:$==="tasks"?xt.length+1+(nn>0?1:0):$==="agents"?Se.length+1+xs:0,Ts=Math.min(bs+1,Math.ceil(kn*.5)),xe=$==="logs"?kn:Math.max(2,Math.min(Ts,kn-4)),vt=Math.max(1,kn-xe),pe=Math.max(10,Yt-2),st=useMemo(()=>ve==="command"?or(St):[],[ve,St]);useEffect(()=>{en(i=>Math.min(i,Math.max(0,xt.length-xe)));},[xt.length,xe]),useEffect(()=>{Zn(i=>Math.min(i,Math.max(0,Ae.length-xe)));},[Ae.length,xe]),useEffect(()=>{Jn(i=>Math.min(i,Math.max(0,Ue.length-xe)));},[Ue.length,xe]);let ys=useCallback(i=>{let s=i.trim().replace(/^\//,"").split(/\s+/),c=s[0]?.toLowerCase();if(!c)return;let g=p=>p instanceof Error?p.message:String(p);switch(c){case "cancel":{if(!E){r("No task selected",e.yellow);return}if(!T)return;r(`Cancelling "${E.title}"...`,e.amber),T(E.id).then(()=>{r(`\u2713 Cancelled "${E.title}"`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "retry":{if(!E){r("No task selected",e.yellow);return}if(!b)return;r(`Retrying "${E.title}"...`,e.amber),b(E.id).then(()=>{r(`\u2713 Retried "${E.title}"`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "assign":{if(!E){r("No task selected",e.yellow);return}if(!y||!s[1]){r("Usage: assign <agent>",e.yellow);return}r(`Assigning "${E.title}" to ${s[1]}...`,e.amber),y(E.id,s[1]).then(()=>{r(`\u2713 Assigned "${E.title}" to ${s[1]}`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "task":{let p=s[1]?.toLowerCase();if(p==="add"){let m=s.slice(2).join(" ");if(!m){Sn();return}if(!f){r("Create not available",e.yellow);return}r(`Creating "${m}"...`,e.amber),f(m).then(h=>{r(`\u2713 Created "${h.title}" (${h.id})`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="list"){let m=Ie.map(h=>` ${h.id} ${h.status.padEnd(11)} ${h.title}`);if(m.length===0)r("No tasks",e.dim);else for(let h of m)r(h,e.cyan);}else if(p==="show"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}r(`${m.id} ${m.status} P${m.priority} "${m.title}"`,e.cyan),m.assignee&&r(` agent: ${m.assignee}`,e.dim),m.description&&r(` ${m.description.slice(0,100)}`,e.dim);}else if(p==="cancel"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(!T)return;r(`Cancelling "${m.title}"...`,e.amber),T(m.id).then(()=>{r(`\u2713 Cancelled "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="retry"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(!b)return;r(`Retrying "${m.title}"...`,e.amber),b(m.id).then(()=>{r(`\u2713 Retried "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="assign"){let m=s[2]?Ie.find(at=>at.id===s[2]):void 0,h=m??E,z=m?s[3]:s[2];if(!h){r("No task selected or id given",e.yellow);return}if(!z){r("Usage: /task assign [id] <agent>",e.yellow);return}if(!y)return;r(`Assigning "${h.title}" to ${z}...`,e.amber),y(h.id,z).then(()=>{r(`\u2713 Assigned "${h.title}" to ${z}`,e.green),U();},at=>r(`Failed: ${g(at)}`,e.red));}else if(p==="approve"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(m.status!=="review"){r(`Cannot approve \u2014 status is ${m.status}`,e.yellow);return}if(!Y)return;r(`Approving "${m.title}"...`,e.amber),Y(m.id).then(()=>{r(`\u2713 Approved "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="reject"){let m=s[2]?Ie.find(z=>z.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(m.status!=="review"){r(`Cannot reject \u2014 status is ${m.status}`,e.yellow);return}if(!V)return;let h=s.slice(s[2]&&Ie.find(z=>z.id===s[2])?3:2).join(" ").trim()||void 0;r(`Rejecting "${m.title}"${h?" with feedback":""}...`,e.amber),V(m.id,h).then(()=>{r(`\u2713 Rejected "${m.title}" \u2192 todo`,e.green),U();},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="delete"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(m.status==="in_progress"){r("Cannot delete \u2014 task is running",e.yellow);return}if(!W)return;Ft("task",m.id,m.title);}else r("Usage: /task add|list|show|cancel|retry|assign|approve|reject|delete",e.yellow);return}case "agent":{let p=s[1]?.toLowerCase();if(p==="add"){let m=s[2];if(!m){wn();return}if(!D){r("Agent creation not available",e.yellow);return}let h=s[3];r(`Creating agent "${m}"...`,e.amber),D(m,h).then(z=>{r(`\u2713 Created agent "${z.name}" (${z.id}, ${z.adapter})`,e.green),U();},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="list"){let m=Ae.map(h=>` ${h.id} ${h.status.padEnd(8)} ${h.name} (${h.adapter})`);if(m.length===0)r("No agents",e.dim);else for(let h of m)r(h,e.cyan);}else if(p==="disable"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(!I)return;r(`Disabling ${m.name}...`,e.amber),I(m.id).then(()=>{r(`\u2713 Disabled ${m.name}`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="enable"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(!v)return;r(`Enabling ${m.name}...`,e.amber),v(m.id).then(()=>{r(`\u2713 Enabled ${m.name}`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="delete"||p==="remove"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(m.status==="running"){r("Cannot delete \u2014 agent is running",e.yellow);return}if(!G){r("Agent deletion not available",e.yellow);return}Ft("agent",m.id,m.name);}else if(p==="autonomous"||p==="auto"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(!Oe){r("Autonomous toggle not available",e.yellow);return}m.autonomous?(r(`Disabling autonomous mode for "${m.name}"...`,e.amber),Oe(m.id,false).then(()=>{r(`${Mt} ${m.name} autonomous OFF`,e.cyan),U();},h=>r(`Failed: ${g(h)}`,e.red))):(r(`Enabling autonomous mode for "${m.name}"...`,e.amber),Oe(m.id,true).then(()=>{r(`${Mt} ${m.name} autonomous ON`,e.cyan),U();},h=>r(`Failed: ${g(h)}`,e.red)));}else r("Usage: /agent add|list|disable|enable|delete|autonomous",e.yellow);return}case "team":{let p=s[1]?.toLowerCase();if(p==="create"||p==="add")$o();else if(p==="list"){let m=bn.current;if(m.length===0)r("No teams",e.dim);else for(let h of m)r(` ${h.id} ${h.status.padEnd(8)} ${h.name} (${h.members.length} members)`,e.cyan);}else if(p==="join"){if(!ie){r("Join not available",e.yellow);return}let m=s[2],h=s[3]??X?.id;if(!m||!h){r("Usage: /team join <teamId> [agentId]",e.yellow);return}r(`Joining team ${m}...`,e.amber),ie(m,h).then(z=>{r(`\u2713 Agent joined team "${z.name}"`,e.green),U({includeTeams:true});},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="leave"){if(!Me){r("Leave not available",e.yellow);return}let m=s[2],h=s[3]??X?.id;if(!m||!h){r("Usage: /team leave <teamId> [agentId]",e.yellow);return}r(`Leaving team ${m}...`,e.amber),Me(m,h).then(z=>{r(`\u2713 Agent left team "${z.name}"`,e.green),U({includeTeams:true});},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="disband"){if(!ot){r("Disband not available",e.yellow);return}let m=s[2];if(!m){r("Usage: /team disband <teamId>",e.yellow);return}r(`Disbanding team ${m}...`,e.amber),ot(m).then(()=>{r("\u2713 Team disbanded",e.green),U({includeTeams:true});},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="set-lead"){if(!qe){r("Set-lead not available",e.yellow);return}let m=s[2],h=s[3];if(!m||!h){r("Usage: /team set-lead <teamId> <agentId>",e.yellow);return}r(`Setting lead for team ${m}...`,e.amber),qe(m,h).then(z=>{r(`\u2713 New lead for team "${z.name}"`,e.green),U({includeTeams:true});},z=>r(`Failed: ${g(z)}`,e.red));}else r("Usage: /team create|list|join|leave|disband|set-lead",e.yellow);return}case "goal":{let p=s[1]?.toLowerCase();if(p==="add"||p==="create"){let m=s.slice(2).join(" ").trim();if(!m){let h=Pn(Se);et({title:"New Goal",steps:h,kind:"goal"}),_e("wizard");return}if(!Pe){r("Goal creation not available",e.yellow);return}r(`Creating goal "${m}"...`,e.amber),Pe({title:m}).then(h=>{r(`\u2713 Created goal "${h.title}" (${h.id})`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="list"){let m=Ue.map(h=>` ${h.id} ${h.status.padEnd(8)} ${h.title}`);if(m.length===0)r("No goals",e.dim);else for(let h of m)r(h,e.cyan);}else if(p==="show"){let m=s[2]?Ue.find(h=>h.id===s[2]):q;if(!m){r("No goal selected or id given",e.yellow);return}r(`${m.id} ${m.status} "${m.title}"`,e.cyan),m.description&&r(` ${m.description.slice(0,100)}`,e.dim);}else if(p==="status"){let m=s[2]?Ue.find(At=>At.id===s[2]):void 0,h=m??q;if(!h){r("No goal selected or id given",e.yellow);return}let z=s[m?3:2];if(!z||!a$1.includes(z)){r("Usage: /goal status [id] <active|paused|achieved|abandoned>",e.yellow);return}let at=z;if(!we){r("Status update not available",e.yellow);return}r(`Updating goal status to ${at}...`,e.amber),we(h.id,at).then(At=>{r(`\u2713 Goal "${At.title}" \u2192 ${at}`,e.green),U();},At=>r(`Failed: ${g(At)}`,e.red));}else if(p==="delete"){let m=s[2]?Ue.find(h=>h.id===s[2]):q;if(!m){r("No goal selected or id given",e.yellow);return}if(!De){r("Goal deletion not available",e.yellow);return}Ft("goal",m.id,m.title);}else r("Usage: /goal add|list|show|status|delete",e.yellow);return}case "run":{let p=s[1]??E?.id;if(!p){r("No task selected or id given",e.yellow);return}if(!d){r("Run not available",e.yellow);return}let m=Ie.find(h=>h.id===p);if(m&&!go.has(m.status)){r(`Cannot run \u2014 status is ${m.status}`,e.yellow);return}r(`Running ${p}...`,e.amber),d(p).then(()=>{r(`\u2713 Dispatched ${p}`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));return}case "run-all":{if(!x){r("Run-all not available",e.yellow);return}r("Running all todo tasks...",e.amber),x().then(()=>{r("\u2713 Dispatched all todo tasks",e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "watch":{if(gn){r("Watch mode already active",e.yellow);return}if(!Ve){r("Watch not available",e.yellow);return}r("Starting watch mode...",e.amber),Ve().then(()=>{jn(true),r("\u2713 Watch mode started",e.green);},p=>r(`Failed: ${g(p)}`,e.red));return}case "pause":{if(!gn){r("Watch mode not active",e.yellow);return}if(!Ye){r("Pause not available",e.yellow);return}r("Pausing watch mode...",e.amber),Ye().then(()=>{jn(false),r("\u2713 Watch mode paused",e.green);},p=>r(`Failed: ${g(p)}`,e.red));return}case "config":{s[1]?.toLowerCase()==="activity-filter"?Yn(m=>{let h=mo(m);return Z?.(h.label),r(`Activity filter: ${h.label}`,e.amber),new Set(h.types)}):vo();return}case "status":{let p=Je.filter(m=>m.status==="in_progress").length;r(`${no} ${p} running ${Je.length} tasks ${Ae.length} agents`,e.cyan);return}case "help":{for(let[p,m]of Object.entries(Xt)){let h=m.sub?" "+m.sub.join("|"):m.args?" "+m.args:"";r(` /${p}${h} \u2014 ${m.help}`,e.silver);}return}case "quit":{mt();return}case "disable":{if(!X){r("No agent selected",e.yellow);return}if(!I)return;r(`Disabling ${X.name}...`,e.amber),I(X.id).then(()=>{r(`\u2713 Disabled ${X.name}`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "enable":{if(!X){r("No agent selected",e.yellow);return}if(!v)return;r(`Enabling ${X.name}...`,e.amber),v(X.id).then(()=>{r(`\u2713 Enabled ${X.name}`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}default:r(`Unknown: ${c}. Type /help for commands`,e.yellow);}},[E,X,Ie,Ae,Je,no,gn,T,b,y,x,d,f,I,v,D,Y,V,W,ie,Me,ot,qe,Ve,Ye,r,mt,U,Sn,wn,$o,vo]);useInput((i,w)=>{if(ve!=="none"){if(w.escape){_e("none"),rt(""),hn.reset();return}if(w.return){let s=St.trim();if(!s)return;if(ve==="new_task"){if(!f)return;_e("none"),rt(""),r(`Creating "${s}"...`,e.amber),f(s).then(c=>{r(`\u2713 Created "${c.title}" (${c.id})`,e.green),U();},c=>r(`Failed to create: ${c instanceof Error?c.message:String(c)}`,e.red));}else if(ve==="command"){let c=s;if(st.length>0&&st[xn]){let g=st[xn],p=g.cmd.replace(/\s+\[.*\]$/,"");if((p.startsWith(s)||s==="/")&&(c=p),g.subs&&!p.includes(" ")){rt(p+" "),pt(0);return}}_e("none"),rt(""),pt(0),hn.push(c),ys(c);}return}if(w.tab&&ve==="command"){if(st.length>0){let s=st[xn];if(s){let c=s.cmd.replace(/\s+\[.*\]$/,"");rt(c+(s.subs?" ":"")),pt(0);}}else {let s=ao(St);s&&rt(c=>c+s);}return}if(w.upArrow&&ve==="command"){if(st.length>0)pt(s=>Math.max(0,s-1));else {let s=hn.prev();s!==null&&rt(s);}return}if(w.downArrow&&ve==="command"){if(st.length>0)pt(s=>Math.min(st.length-1,s+1));else {let s=hn.next();rt(s??"");}return}if(w.backspace||w.delete){rt(s=>s.slice(0,-1)),pt(0);return}i&&!w.ctrl&&!w.meta&&(rt(s=>s+i),pt(0));return}if(i.toLowerCase()==="q"){mt();return}if(w.escape){if(ke){Kt(false),tn(0);return}if($==="logs"&&Jt>=0){qn(-1),Qt(0);return}return}if(i==="/"&&!ke){_e("command"),rt("/"),pt(0);return}if($==="logs"&&!ke&&i>="0"&&i<="9"){Yr(parseInt(i,10));return}if((i==="f"||i==="F")&&$==="logs"&&!ke){Zr(s=>new Set(mo(s).types));return}if((i==="z"||i==="Z")&&Nt.length>0){is();return}if((i==="f"||i==="F")&&($==="tasks"||$==="agents"||$==="goals")&&!ke){Yn(s=>{let c=mo(s);return Z?.(c.label),new Set(c.types)});return}if((i==="n"||i==="N")&&$==="tasks"&&!ke&&f){Sn();return}if((i==="n"||i==="N")&&$==="agents"&&!ke&&D){wn();return}if((i==="n"||i==="N")&&$==="goals"&&!ke&&Pe){let s=Pn(Se);et({title:"New Goal",steps:s,kind:"goal"}),_e("wizard");return}if((i==="e"||i==="E")&&$==="goals"&&q&&Ke){let s=Ar(q,Se);et({title:`Edit Goal: ${q.title}`,steps:s,kind:"edit_goal",targetId:q.id}),_e("wizard");return}if((i==="d"||i==="D")&&$==="goals"&&q&&De){Ft("goal",q.id,q.title);return}if((i==="c"||i==="C")&&$==="goals"&&q&&we){(q.status==="active"||q.status==="paused")&&(r(`Marking goal "${q.title}" as achieved...`,e.amber),we(q.id,"achieved").then(()=>{r(`\u2713 Goal "${q.title}" achieved`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="x"||i==="X")&&$==="goals"&&q&&we){(q.status==="active"||q.status==="paused")&&(r(`Abandoning goal "${q.title}"...`,e.amber),we(q.id,"abandoned").then(()=>{r(`\u2713 Goal "${q.title}" abandoned`,e.dim),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="p"||i==="P")&&$==="goals"&&q&&we){let s=q.status==="paused"?"active":"paused";(q.status==="active"||q.status==="paused")&&we(q.id,s).then(()=>{r(`Goal "${q.title}" ${s}`,e.cyan),U();},c=>r(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if((i==="a"||i==="A")&&$==="tasks"&&E?.status==="review"&&Y){r(`Approving "${E.title}"...`,e.amber),Y(E.id).then(()=>{r(`\u2713 Approved "${E.title}"`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="x"||i==="X")&&$==="tasks"&&E?.status==="review"&&V){r(`Rejecting "${E.title}"...`,e.amber),V(E.id).then(()=>{r(`\u2713 Rejected "${E.title}" \u2192 todo`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="c"||i==="C")&&$==="tasks"&&E&&T){if(E.status==="done"||E.status==="failed"||E.status==="cancelled"){r(`Cannot cancel \u2014 status is ${E.status}`,e.yellow);return}r(`Cancelling "${E.title}"...`,e.amber),T(E.id).then(()=>{r(`\u2713 Cancelled "${E.title}"`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="e"||i==="E")&&$==="tasks"&&E&&A){ls(E);return}if((i==="e"||i==="E")&&$==="agents"&&X&&C){cs(X);return}if((i==="s"||i==="S")&&$==="tasks"){So(s=>!s),fn(0),en(0);return}if((i==="s"||i==="S")&&$==="agents"&&X&&M){if(!Object.values(je.running).some(c=>c.agent_id===X.id)&&X.status!=="running"){r(`Agent "${X.name}" is not running`,e.yellow);return}r(`Force-stopping agent "${X.name}"...`,e.amber),M(X.id).then(()=>{r(`\u2713 Stopped agent "${X.name}"`,e.green),U();},c=>r(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if((i==="d"||i==="D")&&$==="tasks"&&E&&E.status!=="in_progress"&&W){Ft("task",E.id,E.title);return}if((i==="d"||i==="D")&&$==="agents"&&X&&G){let s=Object.values(je.running).some(c=>c.agent_id===X.id);if(s&&!M){r(`Cannot delete \u2014 agent "${X.name}" is running. Press S to stop first.`,e.yellow);return}Ft("agent",X.id,X.name,{needsForceStop:s});return}if((i==="u"||i==="U")&&$==="agents"&&X&&Oe){let s=!X.autonomous;r(`${s?"Enabling":"Disabling"} autonomous mode for "${X.name}"...`,e.amber),Oe(X.id,s).then(()=>{r(`${Mt} ${X.name} autonomous ${s?"ON":"OFF"}`,e.cyan),U();},c=>r(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if(!ke){if(i==="g"||i==="G"){Pt("goals");return}if(i==="t"||i==="T"){Pt("tasks");return}if(i==="a"||i==="A"){Pt("agents");return}if(i==="l"||i==="L"){Pt("logs");return}}if(!ke){let s=Mn.map(g=>g.id),c=s.indexOf($);if(w.tab||w.rightArrow){Pt(s[(c+1)%s.length]);return}if(w.leftArrow){Pt(s[(c+s.length-1)%s.length]);return}}if(w.return){let s=nn>0?xt.length:-1;if($==="tasks"&&mn===s){So(g=>!g),fn(0),en(0);return}let c=xt.length+(nn>0?1:0);if($==="tasks"&&mn===c&&f){Sn();return}if($==="goals"&&Xn===Ue.length&&Pe){let g=Pn(Se);et({title:"New Goal",steps:g,kind:"goal"}),_e("wizard");return}if($==="agents"&&Hn===Ae.length&&D){wn();return}if($==="goals"&&q){Kt(g=>!g),tn(0);return}if($==="tasks"&&E){Kt(g=>!g);return}if($==="agents"&&X){Kt(g=>!g);return}if($==="logs"&&Jt>=0){Kt(g=>!g);return}}if((i==="r"||i==="R")&&$==="tasks"&&E&&d){if(!go.has(E.status)){r(`Cannot run "${E.title}" \u2014 status is ${E.status}`,e.yellow);return}r(`Running "${E.title}"...`,e.green),d(E.id).then(()=>{r(`Dispatched "${E.title}"`,e.green),U();},s=>r(`Failed to run: ${s instanceof Error?s.message:String(s)}`,e.red));return}if(w.upArrow||i==="k"){if($==="goals"&&ke){tn(s=>Math.max(0,s-1));return}$==="goals"?bo(s=>{let c=Math.max(0,s-1);return Jn(g=>c<g?c:g),c}):$==="tasks"?fn(s=>{let c=Math.max(0,s-1);return en(g=>c<g?c:g),c}):$==="agents"?xo(s=>{let c=Math.max(0,s-1);return Zn(g=>c<g?c:g),c}):$==="logs"&&qn(s=>{if(s===-1){let g=Qe.length-1;return Qt(Math.max(0,g-xe+2)),Math.max(0,g)}let c=Math.max(0,s-1);return Qt(g=>c<g?c:g),c});}if(w.downArrow||i==="j"){if($==="goals"&&ke){tn(s=>s+1);return}if($==="goals"){let s=Ue.length+(Pe?1:0)-1;bo(c=>{let g=Math.min(Math.max(0,s),c+1);return Jn(p=>g>=p+xe?g-xe+1:p),g});}else if($==="tasks"){let s=xt.length+(f?1:0)+(nn>0?1:0)-1;fn(c=>{let g=Math.min(Math.max(0,s),c+1);return en(p=>g>=p+xe?g-xe+1:p),g});}else if($==="agents"){let s=Ae.length+(D?1:0)-1;xo(c=>{let g=Math.min(Math.max(0,s),c+1);return Zn(p=>g>=p+xe?g-xe+1:p),g});}else $==="logs"&&qn(s=>{if(s===-1)return -1;let c=Qe.length-1;if(s>=c)return Qt(0),-1;let g=s+1;return Qt(p=>g>=p+xe-1?g-xe+2:p),g});}});let Ne=ve!=="none",Mo=Jt>=0?Qe[Jt]:void 0,_o=!Ne&&ke&&$==="tasks"&&E,Ro=!Ne&&ke&&$==="agents"&&X,Bo=!Ne&&ke&&$==="goals"&&q,ws=!Ne&&ke&&$==="logs"&&Mo,Ss=!Ne&&$==="tasks"&&E&&go.has(E.status)&&!!d,ks=!Ne&&!ke&&($==="goals"&&!!Pe||$==="tasks"&&!!f||$==="agents"&&!!D),Is=!Ne&&$==="tasks"&&E?.status==="review"&&!!Y,Cs=!Ne&&$==="tasks"&&E?.status==="review"&&!!V,$s=X?Object.values(je.running).some(i=>i.agent_id===X.id):false,vs=!Ne&&($==="goals"&&q&&!!De||$==="tasks"&&E&&E.status!=="in_progress"&&!!W||$==="agents"&&X&&!!G),As=!Ne&&!ke&&($==="goals"&&!!q&&!!Ke||$==="tasks"&&!!E&&!!A||$==="agents"&&!!X&&!!C),Ms=!Ne&&$==="agents"&&X&&($s||X.status==="running")&&!!M,_s=!Ne&&$==="agents"&&!!X&&!!Oe,Rs=!Ne&&$==="goals"&&!!q&&(q.status==="active"||q.status==="paused")&&!!we,Bs=!Ne&&Nt.length>0,Eo=ve==="command"&&st.length>0,Lo=ft?.kind==="task"||ft?.kind==="edit_task";return jsxs(Box,{flexDirection:"column",width:Yt,height:fo,children:[jsx(nr,{projectName:t,activeView:$,mode:no,stats:Ao,tokens:fs,uptime:gs,width:Yt,version:me,latestVersion:Te}),jsx(Box,{height:1}),$==="goals"&&jsx(Fi,{goals:Ue,selectedIndex:Xn,scrollOffset:ns,height:xe,width:pe,showAddRow:!!Pe,agentNameMap:It}),$==="tasks"&&jsx(zi,{tasks:xt,selectedIndex:mn,scrollOffset:es,height:xe,width:pe,showAddRow:!!f,agentNameMap:It,hiddenCount:nn}),$==="agents"&&jsx(Vi,{agents:Ae,selectedIndex:Hn,scrollOffset:ts,height:xe,width:pe,state:je,taskTitleMap:Tn,showAddRow:!!D,agentTeamMap:Wt,teamLeadSet:rs,activeTeamCount:on}),$==="logs"&&jsx(Xi,{messages:Qe,height:xe,agents:Ae,logFilter:qr,logTypeFilter:Kr,selectedIndex:Jt,scrollOffset:Jr,agentNameMap:It,taskTitleMap:Tn,width:pe}),jsx(Box,{height:1}),ve==="wizard"&&ft?jsx(ir,{title:ft.title,steps:ft.steps,onComplete:ds,onCancel:us,width:pe,height:vt,onPasteImage:Lo?as:void 0,footerExtra:kt.length>0&&Lo?`\u{1F4CE}${kt.length}`:void 0}):Eo?jsxs(Fragment,{children:[jsx(Dn,{label:"COMMANDS",width:pe}),jsx(Wi,{suggestions:st,selectedIndex:xn,height:Math.min(st.length,vt),width:pe})]}):ve==="new_task"?jsxs(Fragment,{children:[jsx(ta,{mode:ve,width:pe}),jsx(na,{mode:ve,value:St,width:pe})]}):_o?jsxs(Fragment,{children:[jsx(Ki,{task:E,width:pe}),jsx(Zo,{task:E,height:vt,width:pe,taskLogs:Qe.filter(i=>i.taskId===E.id),agentNameMap:It})]}):Bo?jsxs(Fragment,{children:[jsx(Dn,{label:`GOAL: ${q.title}`,width:pe}),jsx(Gi,{goal:q,height:vt,width:pe,agentNameMap:It,tasks:ss,progressReport:Xr,scrollOffset:os,onClampScroll:tn})]}):Ro?jsxs(Fragment,{children:[jsx(Zi,{agent:X,width:pe}),jsx(Ji,{agent:X,height:vt,state:je,taskTitleMap:Tn,teamName:Wt.get(X.id)})]}):ws?jsxs(Fragment,{children:[jsx(Dn,{label:"LOG",width:pe}),jsx(Yi,{message:Mo,height:vt,width:pe,agents:Ae,agentNameMap:It,taskTitleMap:Tn})]}):Qe.length>0&&$!=="logs"?jsxs(Fragment,{children:[(()=>{let i=` F:${pn.toUpperCase()} \u2502 ${Kn.length}/${Qe.length}`;return jsx(Dn,{label:"ACTIVITY",width:pe,suffixLen:i.length,suffix:jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" F:"}),jsx(Text,{color:e.amber,children:pn.toUpperCase()}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," ",Kn.length,"/",Qe.length]})]})})})(),jsx(qi,{messages:Kn,height:Math.max(1,vt-1),width:pe,agents:Ae,agentNameMap:It})]}):$==="goals"?jsx(Ln,{count:Ue.length,config:Li,width:pe}):$==="tasks"?jsx(Ln,{count:Ie.length,config:Oi,width:pe}):$==="agents"?jsx(Ln,{count:Ae.length,config:Pi,width:pe}):null,jsx(Box,{flexGrow:1}),Nt.length>0&&jsx(Ni,{deletions:Nt,width:Yt}),jsx(rr,{mode:ve==="command"?"command":"navigate",value:ve==="command"?St:"",completion:ve==="command"?ao(St):null,activeView:$,canRun:!!Ss,canNew:!!ks,canApprove:!!Is,canReject:!!Cs,canCancel:$==="tasks"&&!!E&&E.status==="in_progress"&&!!T,canDelete:!!vs,canUndo:!!Bs,canEdit:!!As,canForceStop:!!Ms,canToggleAuto:!!_s,autoActive:X?.autonomous,canPause:!!Rs,isPaused:q?.status==="paused",canToggleShowAll:$==="tasks"&&Ie.length>_r,showAllActive:wo,hasDetail:!!(_o||Ro||Bo),itemCount:$==="goals"?Ue.length:$==="tasks"?Ie.length:$==="agents"?Se.length:Qe.length,itemLabel:$==="goals"?"goals":$==="tasks"?"tasks":$==="agents"?"agents":"events",width:Yt,hasSuggestions:Eo})]})}var Ni=Fn.memo(function({deletions:n,width:o}){let[,l]=useState(0);useEffect(()=>{let f=setInterval(()=>l(T=>T+1),1e3);return ()=>clearInterval(f)},[]);let d=Date.now();return jsx(Box,{flexDirection:"column",width:o,children:n.map(f=>{let T=Math.max(0,Math.ceil((f.expiresAt-d)/1e3)),b=Math.max(0,o-4),y=f.entityType==="task"?"Task":f.entityType==="agent"?"Agent":"Goal",x=Math.max(10,b-y.length-30),I=f.entityName.length>x?f.entityName.slice(0,x-1)+"\u2026":f.entityName;return jsx(Box,{paddingX:2,children:jsxs(Text,{color:e.yellow,children:["\u2717 ",jsx(Text,{bold:true,children:y}),` "${I}" \u2014 `,jsxs(Text,{color:e.amber,bold:true,children:[T,"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 Wi({suggestions:t,selectedIndex:n,height:o,width:l}){let d=o,f=0;n>=d&&(f=n-d+1);let T=t.slice(f,f+d);return jsx(Box,{flexDirection:"column",paddingX:2,children:T.map((b,y)=>{let x=y+f,I=x===n,v=I?"\u25B6":" ",P=Math.min(20,Math.max(14,...t.map(D=>D.cmd.length+1))),F=b.cmd.padEnd(P),H=b.subs?` ${b.subs}`:"",O=Math.max(4,l-P-H.length-8),N=b.desc.length>O?b.desc.slice(0,O-1)+"\u2026":b.desc;return jsxs(Text,{wrap:"truncate",children:[jsx(Text,{color:I?e.amber:e.ghost,children:` ${v} `}),jsx(Text,{color:I?e.white:e.silver,bold:I,children:F}),jsx(Text,{color:e.dim,children:N}),H&&jsx(Text,{color:e.ghost,children:H})]},x)})})}function Fi({goals:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,showAddRow:f,agentNameMap:T}){let b=t.length,y=t.slice(o,o+l),x=f&&b>=o&&b<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[y.map((I,v)=>jsx(Box,{paddingX:2,children:jsx(Ko,{goal:I,selected:v+o===n,width:d-2,agentNameMap:T})},I.id)),x&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===b?e.amber:e.ghost,children:[n===b?" \u25B8 ":" ",jsx(Text,{color:n===b?e.amber:e.dim,children:"+ add goal..."})]})},"__add__")]})}function Gi({goal:t,height:n,width:o,agentNameMap:l,tasks:d,progressReport:f,scrollOffset:T=0,onClampScroll:b}){let x=Fn.useMemo(()=>{let O=d??[],N=t.assignee?l?.get(t.assignee)??t.assignee:"\u2014",D=Math.max(20,o-6),G=(M,R)=>{if(M.length<=R)return [M];let ge=[];for(let ie=0;ie<M.length;ie+=R)ge.push(M.slice(ie,ie+R));return ge},Y=f?f.split(`
|
|
10
|
+
`).flatMap(M=>G(M,D)):[],V=t.description?t.description.split(`
|
|
11
|
+
`).flatMap(M=>G(M,D)):[],W=No[t.status]??e.dim,A=new Map;for(let M of O)A.set(M.status,(A.get(M.status)??0)+1);let C=[];if(C.push({key:"row-status",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:W,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:N})]})]})}),C.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&&C.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)})]})]})}),O.length>0){let M=[];for(let[R,ge]of A)M.push(`${ge} ${R}`);C.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:O.length})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" "}),jsx(Text,{color:e.dim,children:M.join(" \xB7 ")})]})]})});}if(V.length>0){C.push({key:"desc-gap",node:jsx(Text,{children:" "})});for(let M=0;M<V.length;M++)C.push({key:`desc-${M}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",V[M]]})});}else C.push({key:"desc-gap",node:jsx(Text,{children:" "})}),C.push({key:"desc-empty",node:jsx(Text,{color:e.dim,children:" No description."})});if(Y.length>0){C.push({key:"prog-gap",node:jsx(Text,{children:" "})}),C.push({key:"prog-div",node:jsx(Ht,{label:"progress",width:o})});for(let M=0;M<Y.length;M++)C.push({key:`prog-${M}`,node:jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",Y[M]]})});}if(O.length>0){C.push({key:"tasks-gap",node:jsx(Text,{children:" "})}),C.push({key:"tasks-div",node:jsx(Ht,{label:`tasks (${O.length})`,width:o})});for(let M of O){let R=Cn[M.status]??e.dim;C.push({key:`task-${M.id}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",jsx(Text,{color:R,children:M.status.padEnd(12)}),M.title.slice(0,Math.max(10,o-22))]})});}}return C},[t,d,f,o,l]),I=Math.max(0,x.length-n),v=Math.min(T,I);Fn.useEffect(()=>{b&&v!==T&&b(v);},[v,T,b]);let P=x.length>n&&v<I,F=P?n-1:n,H=x.slice(v,v+F);return jsxs(Box,{flexDirection:"column",height:n,paddingX:2,children:[H.map(O=>jsx(Box,{children:O.node},O.key)),P&&jsxs(Text,{color:e.ghost,children:[" ","\u2193"," ",x.length-v-F," more ","\u2014"," ","\u2191","\u2193"," to scroll"]})]})}function zi({tasks:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,showAddRow:f,agentNameMap:T,hiddenCount:b=0}){let y=b>0,x=y?t.length:-1,I=t.length+(y?1:0),v=t.slice(o,o+l),P=y&&x>=o&&x<o+l,F=f&&I>=o&&I<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[v.map((H,O)=>jsx(Box,{paddingX:2,children:jsx(vn,{task:H,selected:O+o===n,width:d-2,agentNameMap:T})},H.id)),P&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===x?e.amber:e.ghost,children:[n===x?" \u25B8 ":" ",jsxs(Text,{color:n===x?e.amber:e.dim,children:["\u25BC"," Show all (",b," more) \u2014 press ",jsx(Text,{bold:true,color:e.gray,children:"S"})]})]})},"__show_all__"),F&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===I?e.amber:e.ghost,children:[n===I?" \u25B8 ":" ",jsx(Text,{color:n===I?e.amber:e.dim,children:"+ add task..."})]})},"__add__")]})}function Vi({agents:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,state:f,taskTitleMap:T,showAddRow:b,agentTeamMap:y,teamLeadSet:x,activeTeamCount:I}){let v=new Map;for(let A of Object.values(f.running))v.set(A.agent_id,A);let P=new Map;if(I&&I>0)for(let A of t){let C=y?.get(A.id);C&&P.set(C,(P.get(C)??0)+1);}let F=t.length,H=t.slice(o,o+l),O=b&&F>=o&&F<o+l,N=I!=null&&I>0,D=new Map;if(N&&x&&y){for(let A of t)if(x.has(A.id)){let C=y.get(A.id);C&&D.set(C,A.name);}}let G=0;for(let A of P.values())G+=A;let Y=t.length-G,V=[],W=o>0?y?.get(t[o-1]?.id??""):void 0;for(let A=0;A<H.length&&V.length<l;A++){let C=H[A],M=y?.get(C.id);if(N&&M&&M!==W&&(V.push(jsx(Ho,{teamName:M,memberCount:P.get(M)??0,leadName:D.get(M),width:d},`ts-${M}`)),V.length>=l)||N&&!M&&W&&(V.push(jsx(Xo,{memberCount:Y,width:d},"ts-unassigned")),V.length>=l))break;W=M,V.push(jsx(Box,{paddingX:2,children:jsx(Uo,{agent:C,selected:A+o===n,width:d-2,runningEntry:v.get(C.id),currentTaskTitle:C.current_task?T.get(C.current_task):void 0,teamName:M,isLead:x?.has(C.id)})},C.id));}return O&&V.length<l&&V.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===F?e.amber:e.ghost,children:[n===F?" \u25B8 ":" ",jsx(Text,{color:n===F?e.amber:e.dim,children:"+ add agent..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:l,children:V})}function Nr(t=5e3){let[n,o]=useState(Date.now());return useEffect(()=>{let l=setInterval(()=>o(Date.now()),t);return ()=>clearInterval(l)},[t]),n}function Wr(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`}var ji=" \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Ui(t,n,o,l){let d=new Array(n).fill(0),f=l-n*o;for(let b of t){if(b.ts<f)continue;let y=Math.min(n-1,Math.floor((b.ts-f)/o));d[y]++;}let T=Math.max(1,...d);return d.map(b=>ji[Math.round(b/T*8)]).join("")}function Hi(t){if(t==="error")return e.errorBg}function Fr(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 Xi({messages:t,height:n,agents:o,logFilter:l,logTypeFilter:d,selectedIndex:f,scrollOffset:T,agentNameMap:b,taskTitleMap:y,width:x}){let I=Nr(),v=useMemo(()=>t.filter(A=>{if(l!==0){let M=o[l-1];if(M&&A.agentId!==M.id)return false}let C=A.msgType??"info";return d.has(C)}),[t,o,l,d]);useMemo(()=>{let A={};for(let C of t){let M=C.msgType??"info";A[M]=(A[M]??0)+1;}return A},[t]);let F=useMemo(()=>{let A=new Map;for(let C of t)C.agentId&&A.set(C.agentId,(A.get(C.agentId)??0)+1);return A},[t]),H=useMemo(()=>Ui(v,30,1e4,I),[v,I]),O=d.size>=8?"all":d.size===1&&d.has("output")?"text":d.size===1&&d.has("error")?"errors":d.has("tool")&&!d.has("output")?"tools":d.has("lifecycle")&&!d.has("output")?"events":`${d.size} types`,N=n-3,D=f===-1?v.slice(-N):v.slice(T,T+N),G=f===-1?-1:f-T,Y=Math.min(10,Math.max(6,...o.map(A=>A.name.length))),V=11+Y,W=A=>{if(A===0)return true;let C=D[A],M=D[A-1];return C.agentId!==M.agentId?true:C.agentId?C.ts-M.ts>3e4:false};return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsxs(Box,{gap:0,children:[l===0?jsx(Text,{backgroundColor:e.infoBg,color:e.silver,bold:true,children:" \u25CF ALL "}):jsx(Text,{color:e.ghost,children:" \u25CB all "}),jsx(Text,{color:e.ghost,children:" "}),o.slice(0,9).map((A,C)=>{let M=zn(A.id,o),R=l===C+1,ge=F.get(A.id)??0,ie=ge>0?`\xB7${ge}`:"";return R?jsxs(Text,{backgroundColor:e.successBg,color:M,bold:true,children:[" ",C+1,":",A.name,ie," "]},A.id):jsxs(Text,{color:ge>0?e.dim:e.ghost,children:[" ",C+1,":",A.name,ie]},A.id)})]}),jsxs(Box,{gap:0,children:[O==="all"?jsx(Text,{color:e.dim,children:" F:all"}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,bold:true,children:[" F:",O.toUpperCase()," "]}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," "]}),jsxs(Text,{color:e.dim,children:[v.length," events"]}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," "]}),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(Vt,{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,"/",v.length," "]}),jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amberDim,children:H}),jsx(Text,{color:e.ghost,children:" 5m"})]}),D.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"})]})]}):D.map((A,C)=>{let M=C===G,R=A.msgType??"info",ge=Vn[R]??"\u2502",ie=A.agentId?b.get(A.agentId)??A.agentId.slice(0,8):void 0,Me=A.agentId?zn(A.agentId,o):void 0,ot=W(C),Ve=(C>0?D[C-1]:void 0)?.agentId===A.agentId&&!!A.agentId,Ye=!Ve&&!!ie,Oe=Ve&&!!ie,Ot=Fr(R,A.color),Pe=M?e.infoBg:R==="error"?e.errorBg:void 0,Ke=A.taskId?y.get(A.taskId):void 0,we=Wr(A.ts,I),De=Ke&&x>80?`#${Ke.slice(0,20)}`:"",L=De?De.length+3:0,B=Math.max(10,x-2-V-L),k=A.text.length>B?A.text.slice(0,B-1)+"\u2026":A.text;return jsxs(Box,{backgroundColor:Pe,children:[jsx(Text,{color:Me??e.ghost,children:ot&&Ye?"\u250C":Oe?"\u2502":" "}),jsx(Text,{color:M?e.amber:void 0,children:M?"\u25B8":" "}),jsx(Box,{width:5,children:jsx(Text,{color:we==="now"?e.green:M?e.silver:e.ghost,children:we.padStart(4)})}),jsx(Box,{width:Y+1,children:Ye?jsxs(Text,{color:Me,bold:true,children:[" ",ie.slice(0,Y).padEnd(Y)]}):Oe?jsxs(Text,{color:Me??e.ghost,children:[" ","\xB7".padEnd(Y)]}):jsxs(Text,{color:e.ghost,children:[" "," ".padEnd(Y)]})}),jsxs(Text,{color:R==="error"?e.red:Me??e.dim,children:[" ",ge," "]}),jsx(Text,{color:M?e.white:Ot,bold:M||R==="lifecycle",children:k}),De&&jsxs(Text,{color:e.ghost,children:[" ",jsx(Text,{color:e.dim,backgroundColor:e.void,children:` ${De} `})]})]},C)})]})}function qi({messages:t,height:n,width:o,agents:l,agentNameMap:d}){let f=Nr(),T=t.slice(-n),b=Math.max(10,o-2-17),y=Math.max(0,n-T.length),x=0,I=[];for(let v=0;v<T.length;v++)v>0&&T[v].agentId!==T[v-1].agentId&&x++,I.push(x);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[y>0&&jsx(Box,{height:y}),T.map((v,P)=>{let F=v.agentId?d.get(v.agentId)??v.agentId.slice(0,8):void 0,H=v.agentId?zn(v.agentId,l):void 0,O=v.msgType??"info",N=Vn[O]??"\u2502",D=Fr(O,v.color),Y=(P>0?T[P-1]:void 0)?.agentId===v.agentId&&!!v.agentId,V=(I[P]&1)===1,W=Hi(O)??(V?"#1a1a1a":void 0),A=Wr(v.ts,f),C=v.text.length>b?v.text.slice(0,b-1)+"\u2026":v.text;return jsxs(Box,{backgroundColor:W,children:[jsx(Text,{color:H??e.ghost,children:!Y&&F?"\u258D":Y?"\u258F":" "}),jsx(Box,{width:5,children:jsx(Text,{color:Y?e.ghost:A==="now"?e.green:e.dim,children:Y?" ":A.padStart(4)})}),jsx(Box,{width:9,children:F&&!Y?jsxs(Text,{color:H,bold:true,children:[" ",F.slice(0,8)]}):jsx(Text,{color:e.ghost,children:Di})}),jsxs(Text,{color:O==="error"?e.red:Y?e.ghost:H??e.dim,children:[N," "]}),jsx(Text,{color:D,children:C})]},P)})]})}function Yi({message:t,height:n,width:o,agents:l,agentNameMap:d,taskTitleMap:f}){let T=t.detail??t.text,b=t.msgType??"info",y=t.agentId?d.get(t.agentId)??t.agentId.slice(0,8):void 0,x=t.agentId?zn(t.agentId,l):e.dim,I=t.taskId?f.get(t.taskId):void 0,v,P=false;try{let N=JSON.parse(T);v=JSON.stringify(N,null,2),P=!0;}catch{v=T;}let F=Math.max(4,o-6),H=Math.max(1,n-4),O=v.split(`
|
|
12
|
+
`).slice(0,H);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u256D","\u2500".repeat(F+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:x,bold:true,children:y}),y&&jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:Vn[b]?b==="error"?e.red:e.dim:e.dim,children:[Vn[b]??"\u2502"," ",b]}),I&&jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:e.dim,children:["#",I.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,F)})]}),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u251C","\u2500".repeat(F+2),"\u2524"]})}),O.map((N,D)=>jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),P&&jsxs(Text,{color:e.ghost,children:[String(D+1).padStart(3)," "]}),jsx(Text,{wrap:"truncate",color:P&&N.includes('"')?e.cyan:P&&/^\s*[}\]]/.test(N)?e.ghost:N.startsWith("error")||N.startsWith("Error")?e.red:e.silver,children:N.slice(0,P?F-4:F)})]},D)),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u2570","\u2500".repeat(F+2),"\u256F"]})})]})}function Dn({label:t,width:n,suffix:o,suffixLen:l=0}){let d=` ${t} `,f=3,T=f+d.length+2;if(!o){let x=Math.max(0,n-T);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(f)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:d}),jsx(Text,{color:e.ghost,children:ye.repeat(x)})]})}let b=2,y=Math.max(0,n-T-b-l);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(f)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:d}),jsx(Text,{color:e.ghost,children:ye.repeat(b)}),o,jsx(Text,{color:e.ghost,children:ye.repeat(y)})]})}function Ki({task:t,width:n}){let o=" DETAIL ",l=n-o.length-10,d=t.title.length>l?t.title.slice(0,l-3)+"...":t.title,f=Math.max(0,n-3-o.length-d.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:o}),jsxs(Text,{color:e.ghost,children:[ye," "]}),jsx(Text,{color:e.white,bold:true,children:d}),jsxs(Text,{color:e.ghost,children:[" ",ye.repeat(Math.max(0,f))]})]})}function Zi({agent:t,width:n}){let o=" AGENT ",l=n-o.length-10,d=t.name.length>l?t.name.slice(0,l-3)+"...":t.name,f=Math.max(0,n-3-o.length-d.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(3)}),jsx(Text,{backgroundColor:"#0f2d1f",color:e.green,bold:true,children:o}),jsxs(Text,{color:e.ghost,children:[ye," "]}),jsx(Text,{color:e.green,bold:true,children:d}),jsxs(Text,{color:e.ghost,children:[" ",ye.repeat(Math.max(0,f))]})]})}function Ji({agent:t,height:n,state:o,taskTitleMap:l,teamName:d}){let f=Qi[t.status]??e.dim;Object.values(o.running).find(x=>x.agent_id===t.id);let b=t.current_task?l.get(t.current_task):void 0,y=24;return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:y,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:y,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:b?e.white:e.dim,children:b??"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:y,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:d?e.amber:e.dim,children:d??"\u2014"})]})]}),t.autonomous&&jsx(Box,{children:jsxs(Box,{width:y,children:[jsx(Text,{color:e.dim,children:" auto "}),jsxs(Text,{color:e.cyan,children:[Mt," 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:t.config.skills.join(", ")})]}),jsx(Text,{children:" "}),t.role?t.role.split(`
|
|
13
|
+
`).slice(0,Math.max(1,n-4)).map((x,I)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",x]},I)):jsx(Text,{color:e.dim,children:" No role description."})]})}var Qi={idle:e.dim,running:e.green,error:e.red,disabled:e.ghost},ea="\u2588";function ta({mode:t,width:n}){let l=` ${t==="command"?"COMMAND":"NEW TASK"} `,d=Math.max(0,n-3-l.length-2);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:l}),jsx(Text,{color:e.ghost,children:ye.repeat(d)})]})}function na({mode:t,value:n,width:o}){let l=t==="command"?"/":"\u25B8",d=Math.max(10,o-8),f=n.length>d?n.slice(-d):n;return jsxs(Box,{paddingX:2,children:[jsxs(Text,{color:e.amber,children:[l," "]}),jsx(Text,{color:e.white,children:f}),jsx(Text,{color:e.amber,children:ea})]})}function Gr(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 l=JSON.stringify(o);return l.length>80?l.slice(0,77)+"...":l}function Nn(t,n=200){if(typeof t=="string")return t.slice(0,n);if(!Array.isArray(t))return null;let o=[],l=0;for(let d of t){if(l>=n)break;if(d?.type==="text"&&typeof d.text=="string"){let f=d.text.split(`
|
|
14
|
+
`).find(T=>T.trim().length>0)??"";o.push(f.slice(0,n-l)),l+=f.length;}else if(d?.type==="tool_use"){let f=Gr(d.name??"tool",d.input),T=`\u2699 ${d.name??"tool"}(${f})`;o.push(T),l+=T.length;}else if(d?.type==="tool_result")o.push("\u2190 (result)"),l+=10;else if(d?.type==="thinking"&&typeof d.thinking=="string"){let f=d.thinking.slice(0,60).split(`
|
|
15
|
+
`)[0]??"";o.push(`\u{1F4AD} ${f}`),l+=f.length+3;}}return o.length>0?o.join(" "):null}function Lr(t){if(typeof t=="string"){let o=t.split(`
|
|
16
|
+
`).length,l=t.split(`
|
|
17
|
+
`).find(d=>d.trim().length>0)??"";return o>3?`${l.slice(0,80)}... (${o} lines)`:l.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 d=o.is_error,f=typeof o.content=="string"?o.content:"",T=f.split(`
|
|
18
|
+
`).length;d?n.push(`\u2715 error: ${f.slice(0,60)}`):T>3?n.push(`\u2713 ${T} lines`):n.push(`\u2713 ${f.slice(0,80)}`);}else o?.type==="text"&&typeof o.text=="string"&&n.push(o.text.split(`
|
|
19
|
+
`)[0]?.slice(0,80)??"");return n.join(" ")||"(result)"}function zr(t){let n=()=>t.length>Gn?t.slice(0,Gn)+"\u2026":t;if(Pr.test(t.trim()))return {summary:t.trim(),detail:n()};try{let o=JSON.parse(t);if(o.type==="message"&&o.role==="assistant"){let l=Nn(o.content);return l?{summary:l.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="assistant"||o.role==="assistant"){let l=o.message?.content??o.content,d=Nn(l);return d?{summary:d.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="user"||o.role==="user"){let l=o.message?.content??o.content;return {summary:`\u2190 ${Lr(l).slice(0,180)}`,detail:n()}}if(o.type==="tool_use"){let l=o.name??"tool",d=Gr(l,o.input);return {summary:`\u2699 ${l}(${d})`,detail:n()}}if(o.type==="tool_result")return {summary:`\u2190 ${Lr(o.content).slice(0,180)}`,detail:n()};if(o.type==="result"){let l=typeof o.result=="string"?o.result:null;return {summary:l?`\u2713 ${l.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 l=o.message.content??o.message,d=Nn(l);if(d)return {summary:d.slice(0,200),detail:n()}}return {summary:`[${o.subtype}]`,detail:n()}}if(o.content){let l=Nn(o.content);if(l)return {summary:l.slice(0,200),detail:n()}}return o.type?{summary:`[${o.type}]`,detail:n()}:{summary:t.slice(0,150),detail:n()}}catch{return {summary:oa(t),detail:n()}}}function oa(t){let n=t.match(/"subtype"\s*:\s*"([^"]+)"/);if(n)return `[${n[1]}]`;let o=t.match(/"type"\s*:\s*"([^"]+)"/),l=t.match(/"role"\s*:\s*"([^"]+)"/),d=o?.[1],f=l?.[1];if(!d&&!f)return t.slice(0,200);if(d==="assistant"||d==="message"||f==="assistant"){let T=t.match(/"text"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(T)try{return JSON.parse(`"${T[1]}"`).slice(0,200)}catch{}return "\u{1F4AC} (assistant)"}if(d==="user"||d==="tool_result"||f==="user")return "\u2190 (tool result)";if(d==="tool_use")return `\u2699 ${t.match(/"name"\s*:\s*"([^"]+)"/)?.[1]??"tool"}()`;if(d==="result"){let T=t.match(/"result"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(T)try{return `\u2713 ${JSON.parse(`"${T[1]}"`).slice(0,180)}`}catch{}return "\u2713 Agent finished"}return d==="rate_limit_event"?"\u23F3 Rate limited":`[${d??f}]`}function ra(t,n,o,l){let d=f=>l?.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:T}=zr(t.data);if(f){let b=Dr(f);n(f,b.color,{agentId:t.agentId,taskId:d(t.runId),detail:T,msgType:b.msgType});}break}case "agent:file_changed":n(`${t.path}`,e.purple,{agentId:t.agentId,taskId:d(t.runId),msgType:"file"});break;case "agent:completed":n(t.success?"Completed successfully":"Failed",t.success?e.green:e.red,{agentId:t.agentId,taskId:d(t.runId),msgType:"lifecycle"});break;case "agent:error":n(`${t.error.slice(0,150)}`,e.red,{agentId:t.agentId,taskId:d(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:d(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:d(t.runId),msgType:"error"});break}}export{zl as App,Gl as _resetPendingDeletionSeq};
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a as a$1,b,i}from'./chunk-L26TK7Y5.js';import {o}from'./chunk-ZA5Z33GO.js';import {a as a$2,b as b$1}from'./chunk-GZ2Q56YZ.js';import {Command}from'commander';function h(o$1){let t=o$1.noColor||"NO_COLOR"in process.env||false,e=o$1.ascii||process.env.TERM==="dumb"||false;return {projectRoot:o(),json:o$1.json??false,quiet:o$1.quiet??false,noColor:t,ascii:e}}var p={task:async(o,t)=>{(await import('./task-J6ZN7ALI.js')).registerTaskCommand(o,t);},agent:async(o,t)=>{(await import('./agent-FRQKL7YI.js')).registerAgentCommand(o,t);},status:async(o,t)=>{(await import('./status-DLBNWSWM.js')).registerStatusCommand(o,t);},logs:async(o,t)=>{(await import('./logs-5QHJWMEG.js')).registerLogsCommand(o,t);},config:async(o,t)=>{(await import('./config-CCSS2P7R.js')).registerConfigCommand(o,t);},context:async(o,t)=>{(await import('./context-GSMQHQES.js')).registerContextCommand(o,t);},msg:async(o,t)=>{(await import('./msg-4SCLBO4K.js')).registerMsgCommand(o,t);},goal:async(o,t)=>{(await import('./goal-RFKFPR7M.js')).registerGoalCommand(o,t);},team:async(o,t)=>{(await import('./team-MSIBKOQC.js')).registerTeamCommand(o,t);}},c={run:async(o,t)=>{(await import('./run-HSHRELOP.js')).registerRunCommand(o,t);},doctor:async(o,t)=>{(await import('./doctor-KBK5JZBZ.js')).registerDoctorCommand(o,t);},tui:async(o,t)=>{(await import('./tui-
|
|
2
|
+
import {a as a$1,b,i}from'./chunk-L26TK7Y5.js';import {o}from'./chunk-ZA5Z33GO.js';import {a as a$2,b as b$1}from'./chunk-GZ2Q56YZ.js';import {Command}from'commander';function h(o$1){let t=o$1.noColor||"NO_COLOR"in process.env||false,e=o$1.ascii||process.env.TERM==="dumb"||false;return {projectRoot:o(),json:o$1.json??false,quiet:o$1.quiet??false,noColor:t,ascii:e}}var p={task:async(o,t)=>{(await import('./task-J6ZN7ALI.js')).registerTaskCommand(o,t);},agent:async(o,t)=>{(await import('./agent-FRQKL7YI.js')).registerAgentCommand(o,t);},status:async(o,t)=>{(await import('./status-DLBNWSWM.js')).registerStatusCommand(o,t);},logs:async(o,t)=>{(await import('./logs-5QHJWMEG.js')).registerLogsCommand(o,t);},config:async(o,t)=>{(await import('./config-CCSS2P7R.js')).registerConfigCommand(o,t);},context:async(o,t)=>{(await import('./context-GSMQHQES.js')).registerContextCommand(o,t);},msg:async(o,t)=>{(await import('./msg-4SCLBO4K.js')).registerMsgCommand(o,t);},goal:async(o,t)=>{(await import('./goal-RFKFPR7M.js')).registerGoalCommand(o,t);},team:async(o,t)=>{(await import('./team-MSIBKOQC.js')).registerTeamCommand(o,t);}},c={run:async(o,t)=>{(await import('./run-HSHRELOP.js')).registerRunCommand(o,t);},doctor:async(o,t)=>{(await import('./doctor-KBK5JZBZ.js')).registerDoctorCommand(o,t);},tui:async(o,t)=>{(await import('./tui-DMGNSGBT.js')).registerTuiCommand(o,t);}},a=new Command;a.name("orchestry").description("Agents Organizations \u2014 CLI orchestrator for AI agents").version("0.3.1").option("--json","Output as JSON").option("--quiet","Minimal output (IDs only)").option("--no-color","Disable colors").option("--ascii","ASCII-only output (no Unicode)").hook("preAction",async o=>{let t=o.opts();t.ascii&&a$1(true),t.color===false&&b(true);});var y=[["task","Manage tasks"],["agent","Manage agents"],["status","Show orchestrator status"],["logs","View run logs"],["config","Manage configuration"],["context","Shared context store for inter-agent data exchange"],["msg","Inter-agent messaging"],["goal","Manage goals"],["team","Manage teams"],["run","Run tasks"],["doctor","Check adapters and dependencies"],["tui","Launch TUI dashboard"],["init","Initialize project"],["update","Check for updates"]],j=new Set(y.map(([o])=>o));async function L(){a.parseOptions(process.argv);let o=a.opts(),t=h({json:o.json,quiet:o.quiet,noColor:o.color===false,ascii:o.ascii}),e=process.argv.slice(2).find(n=>!n.startsWith("-")),v=e!==void 0&&j.has(e);if((process.argv.includes("--help")||process.argv.includes("-h")||process.argv.includes("--version")||process.argv.includes("-V"))&&!v){for(let[n,i]of y)a.command(n).description(i);await a.parseAsync(process.argv);return}if(e==="init"){let{registerInitCommand:n}=await import('./init-WRDFAFS2.js');n(a);}else if(e==="update"){let{registerUpdateCommand:n}=await import('./update-PC2ENCKU.js');n(a);}let O=!e||e in c,{buildFullContainer:d,buildLightContainer:b}=await import('./container-OIXLFSX2.js');try{if(O){let n=await d(t),i=e?c[e]:void 0;i?await i(a,n):await Promise.all(Object.values(c).map(x=>x(a,n)));let s=e?p[e]:void 0;s&&await s(a,n);}else {let n=await b(t),i=p[e];i?await i(a,n):await Promise.all(Object.values(p).map(s=>s(a,n)));}}catch(n){if(n instanceof b$1){if(e==="doctor"){let{registerDoctorCommand:i}=await import('./doctor-KBK5JZBZ.js');i(a);}if(process.argv.length<=2){let{runInit:i}=await import('./init-WRDFAFS2.js');await i();let s=await d(t);await c.tui(a,s),await a.parseAsync([...process.argv,"tui"]);return}if(e==="init"||e==="doctor"||e==="update"){await a.parseAsync(process.argv);return}i(n.message,n.hint),process.exit(n.exitCode);}throw n}process.argv.length<=2&&process.argv.push("tui");let m,g=e==="tui"||e==="update",M=g?Promise.resolve(null):import('./update-check-HGMBDYHL.js').then(n=>(m=n,n.checkForUpdateSWR(a.version()??"0.0.0")));if(await a.parseAsync(process.argv),!g){let n=await M;n&&m&&m.printUpdateNotification(n);}}L().catch(o=>{o instanceof a$2&&(i(o.message,o.hint),process.exit(o.exitCode)),i(o instanceof Error?o.message:String(o)),process.env.ORCHESTRY_DEBUG&&console.error(o),process.exit(1);});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function it(c,e){c.command("tui").description("Launch interactive TUI dashboard").action(async()=>{await e.paths.requireInit();let y=await e.taskService.list(),v=await e.agentService.list(),S=await e.stateStore.read(),{render:w}=await import('ink'),{createElement:h}=await import('react'),{App:f}=await import('./App-
|
|
2
|
+
function it(c,e){c.command("tui").description("Launch interactive TUI dashboard").action(async()=>{await e.paths.requireInit();let y=await e.taskService.list(),v=await e.agentService.list(),S=await e.stateStore.read(),{render:w}=await import('ink'),{createElement:h}=await import('react'),{App:f}=await import('./App-5EVJSOEL.js'),T=async t=>{await e.orchestrator.runTask(t);},A=async(t,s)=>e.taskService.create({title:t,priority:s?.priority,description:s?.description,attachments:s?.attachments}),k=async t=>{await e.orchestrator.cancelTask(t);},R=async t=>{await e.taskService.retry(t);},_=async(t,s)=>{await e.taskService.assign(t,s);},b=async()=>{await e.orchestrator.runAll();},C=async t=>{await e.agentService.disable(t);},E=async t=>{await e.agentService.enable(t);},j=t=>e.eventBus.onAny(t),D=async()=>e.taskService.list(),P=async()=>e.agentService.list(),G=async()=>e.stateStore.read(),U=async(t,s,r)=>e.agentService.create({name:t,adapter:s??"claude",model:r?.model||void 0,role:r?.role||void 0,approval_policy:r?.approval_policy||void 0}),x=async t=>{await e.agentService.remove(t);},I=async t=>{await e.taskService.delete(t);},L=async t=>{await e.taskService.updateStatus(t,"done");},H=async(t,s)=>{await e.taskService.reject(t,s);},W=async(t,s)=>e.taskService.update(t,s),F=async(t,s)=>e.agentService.update(t,{...s,approval_policy:s.approval_policy}),M=async t=>{await e.orchestrator.forceStopAgent(t);},N=async(t,s)=>e.agentService.setAutonomous(t,s),O=async t=>{let s=await e.runService.listAll(),r=3,rt=10,p=s.slice(0,r),d=s.slice(r,rt),u=async a=>(await e.runService.readEventsTail(a.id,30)).map(n=>({timestamp:n.timestamp,agentId:a.agent_id,taskId:a.task_id,type:n.type,data:n.data}));if(p.length>0){let a=(await Promise.all(p.map(u))).flat();a.sort((i,n)=>new Date(i.timestamp).getTime()-new Date(n.timestamp).getTime()),t(a.slice(-200));}if(d.length>0){let a=(await Promise.all(d.map(u))).flat();a.sort((i,n)=>new Date(i.timestamp).getTime()-new Date(n.timestamp).getTime()),t(a.slice(-200));}},V=async t=>e.teamService.create(t),q=async()=>e.teamService.list(),B=async(t,s)=>e.teamService.join(t,s),J=async(t,s)=>e.teamService.leave(t,s),K=async t=>{await e.teamService.disband(t);},z=async(t,s)=>e.teamService.setLead(t,s),Q=async()=>e.goalService.list(),X=async t=>e.goalService.create(t),Y=async(t,s)=>e.goalService.update(t,s),Z=async(t,s)=>e.goalService.updateStatus(t,s),$=async t=>{await e.goalService.delete(t);},tt=async t=>e.goalService.getProgressReport(t),et=async()=>{await e.orchestrator.startWatch();},st=async()=>{await e.orchestrator.stop();},g=c.version()??"0.0.0",at=import('./update-check-HGMBDYHL.js').then(t=>t.checkForUpdateSWR(g)).catch(()=>null),o=false,l;try{await e.orchestrator.startWatch(),o=!0;}catch(t){l=t instanceof Error?t.message:String(t);}let m=await at,{waitUntilExit:nt}=w(h(f,{projectName:e.config.project.name,tasks:y,agents:v,state:S,onRunTask:T,onCreateTask:A,onCancelTask:k,onRetryTask:R,onAssignTask:_,onRunAll:b,onDisableAgent:C,onEnableAgent:E,onSubscribeEvents:j,onRefreshTasks:D,onRefreshAgents:P,onRefreshState:G,onLoadHistory:O,onAddAgent:U,onDeleteAgent:x,onApproveTask:L,onRejectTask:H,onDeleteTask:I,onUpdateTask:W,onUpdateAgent:F,onForceStopAgent:M,onToggleAutonomous:N,onRefreshGoals:Q,onCreateGoal:X,onUpdateGoal:Y,onUpdateGoalStatus:Z,onDeleteGoal:$,onGetGoalProgress:tt,onCreateTeam:V,onListTeams:q,onJoinTeam:B,onLeaveTeam:J,onDisbandTeam:K,onSetTeamLead:z,onStartWatch:et,onStopWatch:st,initialWatchActive:o,watchError:l,version:g,latestVersion:m?.updateAvailable?m.latest:void 0,initialActivityFilter:e.globalConfig.tui.activity_filter,onSaveActivityFilter:async t=>{await e.globalConfigStore.set("activity_filter",t);},initialMaxConcurrent:e.config.scheduling.max_concurrent_agents,onSaveMaxConcurrent:async t=>{await e.configStore.set("scheduling.max_concurrent_agents",t),e.config.scheduling.max_concurrent_agents=t;}}),{kittyKeyboard:{mode:"auto",flags:["disambiguateEscapeCodes"]}});await nt(),o&&await e.orchestrator.stop().catch(()=>{});});}export{it as registerTuiCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxgeneral/orch",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Agents Organizations — CLI orchestrator for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -43,7 +43,15 @@
|
|
|
43
43
|
"agents",
|
|
44
44
|
"claude",
|
|
45
45
|
"codex",
|
|
46
|
-
"terminal"
|
|
46
|
+
"terminal",
|
|
47
|
+
"llm",
|
|
48
|
+
"multi-agent",
|
|
49
|
+
"ai-team",
|
|
50
|
+
"agent-orchestration",
|
|
51
|
+
"claude-code",
|
|
52
|
+
"openai",
|
|
53
|
+
"workflow",
|
|
54
|
+
"devops"
|
|
47
55
|
],
|
|
48
56
|
"author": "Agents Organizations Contributors",
|
|
49
57
|
"license": "MIT",
|
package/readme.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<a href="https://www.npmjs.com/package/@oxgeneral/orch"><img src="https://img.shields.io/npm/v/@oxgeneral/orch?color=cb0000" alt="npm" /></a>
|
|
11
11
|
<a href="#get-started-in-30-seconds"><img src="https://img.shields.io/badge/setup-one%20command-brightgreen" alt="One command setup" /></a>
|
|
12
12
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License" /></a>
|
|
13
|
-
<a href="#development"><img src="https://img.shields.io/badge/tests-
|
|
13
|
+
<a href="#development"><img src="https://img.shields.io/badge/tests-1001%20passing-brightgreen" alt="Tests" /></a>
|
|
14
14
|
<a href="#architecture"><img src="https://img.shields.io/badge/TypeScript-strict-blue" alt="TypeScript strict" /></a>
|
|
15
15
|
</p>
|
|
16
16
|
</p>
|
|
@@ -231,7 +231,7 @@ src/
|
|
|
231
231
|
```bash
|
|
232
232
|
npm run dev # Run via tsx
|
|
233
233
|
npm run build # Build ESM + DTS
|
|
234
|
-
npm test #
|
|
234
|
+
npm test # 1001 tests via Vitest
|
|
235
235
|
npm run typecheck # Strict TypeScript
|
|
236
236
|
```
|
|
237
237
|
|
|
@@ -243,9 +243,10 @@ We just hit **10 stars** — small number, real users. Every star so far came fr
|
|
|
243
243
|
|
|
244
244
|
**Next milestone: 25 stars** — when we get there, we'll add a public "Used by" showcase. If you're already running ORCH in your workflow, [open an issue](https://github.com/oxgeneral/ORCH/issues) and tell us — you'll be first on the list.
|
|
245
245
|
|
|
246
|
-
If ORCH saves you time
|
|
246
|
+
**If ORCH saves you time → [⭐ Star it on GitHub](https://github.com/oxgeneral/ORCH)** — it helps other developers find the project.
|
|
247
|
+
|
|
248
|
+
[](https://star-history.com/#oxgeneral/ORCH&Date)
|
|
247
249
|
|
|
248
|
-
- **⭐ Star the repo** — helps other developers find ORCH: [github.com/oxgeneral/ORCH](https://github.com/oxgeneral/ORCH)
|
|
249
250
|
- **Open an issue** if something breaks or could be better
|
|
250
251
|
- **Submit a PR** — see [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
251
252
|
|
package/scripts/benchmark.ts
CHANGED
package/dist/App-TW35IULR.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a}from'./chunk-PJ5DKXGR.js';import {c}from'./chunk-HXOMNULD.js';import {f,g}from'./chunk-L26TK7Y5.js';import Nn,{useState,useEffect,useMemo,useRef,useCallback}from'react';import {Box,Text,useApp,useStdout,useInput}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"},Te="\u2501",xt="\u2500",st="\xB7",Wt="\u25C8",to="\u2605",$t="\u27F3",At="\u25C6",In={in_progress:e.green,retrying:e.yellow,review:e.blue,todo:e.dim,done:e.green,failed:e.red,cancelled:e.dim},Po={active:e.green,paused:e.dim,achieved:e.amber,abandoned:e.ghost};var Ls=120,no=0,sn=null,Cn=new Set;function Os(){sn||(sn=setInterval(()=>{no++;for(let t of Cn)t(no);},Ls));}function Ps(){sn&&Cn.size===0&&(clearInterval(sn),sn=null);}function Ft(){let[t,n]=useState(no);return useEffect(()=>{let o=l=>n(l);return Cn.add(o),Os(),()=>{Cn.delete(o),Ps();}},[]),t}var Do=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Gt({color:t}){let n=Ft();return jsx(Text,{color:t,children:Do[n%Do.length]})}var an={in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6};var Fs="\u25CB",Wo="\u2713",Fo="\u2715",Gs="\u21BB",zs="\u2500",Vs="\u25B6",bt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22"},js={in_progress:{icon:Vs,label:"RUN",fg:e.green,bg:bt.green,bold:true,spinner:true},retrying:{icon:Gs,label:"RETRY",fg:e.yellow,bg:bt.yellow,spinner:true},review:{icon:Wt,label:"REVIEW",fg:e.blue,bg:bt.blue},todo:{icon:Fs,label:"TODO",fg:e.dim,bg:bt.neutral},done:{icon:Wo,label:"DONE",fg:e.green,bg:bt.green},failed:{icon:Fo,label:"FAIL",fg:e.red,bg:bt.red,bold:true},cancelled:{icon:zs,label:"OFF",fg:e.dim,bg:bt.neutral}},Us={1:{color:e.red,label:"!!!"},2:{color:e.yellow,label:"!!"},3:{color:e.dim,label:"!"},4:{color:e.ghost,label:st}};var vn=Nn.memo(function({task:n,selected:o,width:l,agentNameMap:c}){let m=js[n.status],b=n.status==="in_progress"||n.status==="retrying",x=Us[n.priority]??{color:e.ghost,label:st},T,f$1;if(n.status==="done")T=Wo,f$1=e.green;else if(n.status==="failed")T=Fo,f$1=e.red;else if(b){let F=Date.now()-new Date(n.updated_at).getTime();T=f(F),f$1=e.cyan;}else T="\u2014",f$1=void 0;let C=o?"\u25B8":" ",$=10,P=4,W=14,j=7,O=2+$+P+W+j,N=l?Math.max(10,l-O):40,D=n.assignee?c?.get(n.assignee)??n.assignee:void 0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[C," "]}),jsx(Box,{width:$,children:jsx(Text,{backgroundColor:m.bg,color:m.fg,bold:m.bold,children:m.spinner?jsxs(Fragment,{children:[" ",jsx(Gt,{color:m.fg})," ",m.label," "]}):jsxs(Fragment,{children:[" ",m.icon," ",m.label," "]})})}),jsx(Box,{width:P,children:jsx(Text,{color:x.color,bold:n.priority<=2,children:x.label})}),jsxs(Box,{width:N,children:[jsx(Text,{wrap:"truncate",bold:o||b,color:o?e.white:b?e.silver:void 0,children:n.title.length>N?n.title.slice(0,N-1)+"\u2026":n.title}),(n.attachments?.length??0)>0&&jsxs(Text,{color:e.dim,children:[" ","\u{1F4CE}",n.attachments.length]})]}),jsx(Box,{width:W,children:D?jsxs(Text,{backgroundColor:bt.green,color:e.green,wrap:"truncate",children:[" ",D.length>W-2?D.slice(0,W-3)+"\u2026":D," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:j,justifyContent:"flex-end",children:jsx(Text,{color:f$1,dimColor:!f$1,children:T})})]})});var qs="\u2715",Go="\u25CB",Ys="\u25B6",Ks="\u2713",yt={green:"#0f2d1f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},Zs={running:{icon:Ys,label:"ACTIVE",fg:e.green,bg:yt.green,bold:true,spinner:true},idle:{icon:Go,label:"IDLE",fg:e.dim,bg:yt.neutral},error:{icon:qs,label:"ERROR",fg:e.red,bg:yt.red,bold:true},disabled:{icon:Go,label:"OFF",fg:e.ghost,bg:yt.neutral}},oo={running:0,idle:1,error:2,disabled:3},Vo=Nn.memo(function({agent:n,selected:o,width:l,runningEntry:c,currentTaskTitle:m,teamName:b,isLead:x}){let T=Zs[n.status],f$1=n.status==="running",C,$;if(f$1&&c){let L=Date.now()-new Date(c.started_at).getTime();C=f(L),$=e.cyan;}else n.stats.total_runs>0?(C=`${n.stats.tasks_completed}/${n.stats.total_runs}`,$=n.stats.tasks_completed>0?e.green:e.dim):(C="\u2014",$=void 0);let P=o?"\u25B8":" ",W=11,j=10,O=b?Math.min(b.length+2,14):0,N=Math.max(6,22-O),D=7,F=2+W+j+O+N+D,Y=l?Math.max(8,l-F):20,z,_,S=false;f$1&&m?(z=m,_=e.white,S=true):n.role?(z=n.role,_=e.dim):(z="\u2014",_=e.ghost);let A=n.stats.total_runs>0,G=A?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:[P," "]}),jsx(Box,{width:W,children:jsx(Text,{backgroundColor:T.bg,color:T.fg,bold:T.bold,children:T.spinner?jsxs(Fragment,{children:[" ",jsx(Gt,{color:T.fg})," ",T.label," "]}):jsxs(Fragment,{children:[" ",T.icon," ",T.label," "]})})}),jsx(Box,{width:Y,children:jsxs(Text,{wrap:"truncate",bold:o||f$1,color:o?e.white:f$1?e.green:e.silver,children:[n.autonomous&&jsxs(Text,{color:e.cyan,children:[$t," "]}),x&&jsxs(Text,{color:e.amber,children:[to," "]}),n.name]})}),jsx(Box,{width:j,children:jsxs(Text,{backgroundColor:yt.neutral,color:e.dim,children:[" ",n.adapter," "]})}),b&&jsx(Box,{width:O,children:jsxs(Text,{backgroundColor:yt.amber,color:e.amber,wrap:"truncate",children:[" ",b," "]})}),jsx(Box,{width:N,children:jsx(Text,{color:_,bold:S,wrap:"truncate",children:z})}),jsx(Box,{width:D,justifyContent:"flex-end",children:A&&!f$1?jsxs(Text,{color:G>=80?e.green:G>=50?e.yellow:e.red,children:[C," ",Ks]}):jsx(Text,{color:$,dimColor:!$,children:C})})]})});function jo({teamName:t,memberCount:n,leadName:o,width:l}){let c=`${n} agent${n!==1?"s":""}`,m=o?` ${st} ${to} ${o}`:"",b=` ${Wt} ${t.toUpperCase()} ${st} ${c}${m} `,x=3,T=Math.max(0,l-x-b.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:"\u2500".repeat(x)}),jsx(Text,{backgroundColor:yt.amber,color:e.amber,bold:true,children:b}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(T)})]})}var Js="\u25C7";function Uo({memberCount:t,width:n}){let o=`${t} agent${t!==1?"s":""}`,l=` ${Js} UNASSIGNED ${st} ${o} `,c=3,m=Math.max(0,n-c-l.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:"\u2500".repeat(c)}),jsx(Text,{backgroundColor:yt.neutral,color:e.dim,children:l}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(m)})]})}var Ho="\u2713",Xo="\u2715",ei="\u2016",ti="\u25C9",cn={green:"#0f2d1f",amber:"#2d1f0a",neutral:"#1a1a22"},ni={active:{icon:ti,label:"ACTIVE",fg:e.green,bg:cn.green,bold:true},paused:{icon:ei,label:"PAUSED",fg:e.dim,bg:cn.neutral},achieved:{icon:Ho,label:"DONE",fg:e.amber,bg:cn.amber,bold:true},abandoned:{icon:Xo,label:"DROP",fg:e.ghost,bg:cn.neutral}},qo=Nn.memo(function({goal:n,selected:o,width:l,agentNameMap:c}){let m=ni[n.status],b=o?"\u25B8":" ",x=11,T=14,f=7,C=2+x+T+f,$=l?Math.max(10,l-C):40,P=n.assignee?c?.get(n.assignee)??n.assignee:void 0,W,j;if(n.status==="achieved")W=Ho,j=e.amber;else if(n.status==="abandoned")W=Xo,j=e.ghost;else {let O=Date.now()-new Date(n.created_at).getTime(),N=Math.floor(O/864e5);W=N>0?`${N}d`:"<1d",j=e.dim;}return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[b," "]}),jsx(Box,{width:x,children:jsxs(Text,{backgroundColor:m.bg,color:m.fg,bold:m.bold,children:[" ",m.icon," ",m.label," "]})}),jsx(Box,{width:$,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>$?n.title.slice(0,$-1)+"\u2026":n.title})}),jsx(Box,{width:T,children:P?jsxs(Text,{backgroundColor:cn.green,color:e.green,wrap:"truncate",children:[" ",P.length>T-2?P.slice(0,T-3)+"\u2026":P," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:f,justifyContent:"flex-end",children:jsx(Text,{color:j,dimColor:!j,children:W})})]})});var oi={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"};function jt({label:t,width:n,color:o}){let l=n-4,c=` ${t} `,m=3,b=Math.max(0,l-m-c.length);return jsxs(Text,{color:o??e.ghost,children:[" ","\u2500".repeat(m),c,"\u2500".repeat(b)]})}function Yo({task:t,height:n,width:o,taskLogs:l,agentNameMap:c}){let m=In[t.status]??e.dim,b=t.priority<=2?t.priority===1?e.red:e.yellow:void 0,x=24,T=!!t.description?.trim(),f=!!t.proof?.agent_summary,C=(t.proof?.files_changed?.length??0)>0,$=(l?.length??0)>0,P=(t.attachments?.length??0)>0,W=T?t.description.split(`
|
|
3
|
-
`):[],j=f?t.proof.agent_summary.split(`
|
|
4
|
-
`):[],O=3;P&&(O+=2+t.attachments.length),T?(O+=1,O+=Math.min(W.length,Math.max(1,Math.ceil((n-10)*.3)))):f||(O+=2),f&&(O+=2),C&&(O+=1),$&&(O+=2);let N=Math.max(0,n-O),D=0,F=0;f&&$?(D=Math.max(1,Math.floor(N*.4)),F=Math.max(1,N-D)):f?D=N:$&&(F=N);let Y=T?W.slice(0,Math.max(1,Math.ceil((n-10)*.3))):[],z=j.slice(0,D);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:m,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?c?.get(t.assignee)??t.assignee:"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:x,children:[jsx(Text,{color:e.dim,children:" priority "}),jsxs(Text,{color:b,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.join(", "):"\u2014"})]})]}),P&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(jt,{label:`attachments (${t.attachments.length})`,width:o,color:e.dim}),t.attachments.map((_,S)=>jsxs(Text,{color:e.cyan,wrap:"truncate",children:[" ",_]},`a${S}`))]}),T&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),Y.map((_,S)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",_]},`d${S}`))]}),!T&&!f&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:" No description."})]}),f&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(jt,{label:"result",width:o,color:e.dim}),z.map((_,S)=>jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",_]},`r${S}`))]}),C&&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})]})]}),$&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(jt,{label:"activity",width:o,color:e.dim}),l.slice(-F).map((_,S)=>{let A=_.msgType??"info",G=oi[A]??"\u2502",L=_.color;A==="tool"?L=e.cyan:A==="file"?L=e.purple:A==="error"?L=e.red:A==="lifecycle"?L=e.green:A==="system"&&(L=e.dim);let ye=Math.max(10,o-12),fe=_.text.length>ye?_.text.slice(0,ye-1)+"\u2026":_.text;return jsxs(Box,{children:[jsxs(Text,{color:e.ghost,children:[" ",_.time," "]}),jsxs(Text,{color:A==="error"?e.red:e.dim,children:[G," "]}),jsx(Text,{color:L,bold:A==="lifecycle",children:fe})]},S)})]})]})}var An=[{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 ri="\u25CF",Jo="\u25CB",si="\u2713",ii="\u2715",ai="\u2191",li="\u2193",ci="\u03A3",di="\u25B6",ui="\u21BB",Ko=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],ro=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],je={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"};function Qo({color:t}){let n=Ft();return jsx(Text,{color:t,children:Ko[n%Ko.length]})}function gi(){let t=Ft(),n=Math.floor(t/10)%2===0;return jsx(Text,{color:n?e.amber:e.amberDim,bold:true,children:At})}function mi({width:t,active:n}){let o=Math.max(4,Math.floor(t*.08)),l=2,c=Ft(),m=Math.ceil((t+o)/l),b=n?c%(m*2):0;if(!n)return jsx(Box,{paddingX:1,children:jsx(Text,{color:e.ghost,children:Te.repeat(t)})});let x=b<m?b*l:(m*2-b)*l,T=Math.max(0,x-o),f=Math.min(t,x),C=T,$=Math.max(0,f-T),P=Math.max(0,t-f);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Te.repeat(C)}),jsx(Text,{color:e.amber,children:Te.repeat($)}),jsx(Text,{color:e.ghost,children:Te.repeat(P)})]})}function pi({data:t,width:n,color:o}){if(t.length===0)return null;let l=t.slice(-n),c=Math.max(...l,1),m=l.map(b=>{let x=Math.round(b/c*(ro.length-1));return ro[x]??ro[0]}).join("");return jsx(Text,{color:o,children:m})}function fi({projectName:t,activeView:n,mode:o,stats:l,uptime:c,width:m,version:b,latestVersion:x}){let T=o==="watching";return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:m,children:[jsxs(Box,{gap:0,children:[jsx(gi,{}),jsx(Text,{color:e.amber,bold:true,children:" ORCH"}),b&&jsxs(Text,{color:e.ghost,children:[" ",b]}),x&&x!==b&&jsxs(Text,{backgroundColor:je.green,color:e.green,bold:true,children:[" UPDATE ",x," "]}),jsxs(Text,{color:e.ghost,children:[" ",st," "]}),jsx(Text,{color:e.silver,children:t})]}),jsx(Box,{gap:0,children:An.map((f,C)=>{let $=n===f.id;return jsxs(Nn.Fragment,{children:[C>0&&jsx(Text,{children:" "}),$?jsxs(Text,{backgroundColor:e.amber,color:"#0a0a0c",bold:true,children:[" ",f.key," ",f.label," "]}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:f.key}),jsxs(Text,{color:e.dim,children:[" ",f.label.toLowerCase()]})]})]},f.id)})}),jsxs(Box,{gap:0,children:[T?jsxs(Text,{backgroundColor:je.green,color:e.green,bold:true,children:[" ",ri," WATCHING"," "]}):jsxs(Text,{backgroundColor:je.neutral,color:e.dim,children:[" ",Jo," IDLE"," "]}),l.running>0&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{backgroundColor:je.green,color:e.green,children:[" ",jsx(Qo,{color:e.green})," ",l.running," active"," "]})]}),c&&jsxs(Text,{color:e.ghost,children:[" ",c]})]})]})}function hi({stats:t,tokens:n,width:o,sparklineData:l}){let m=[{icon:di,label:"RUN",count:t.running,fg:e.green,bg:je.green,bold:true,spinner:true,show:t.running>0},{icon:ui,label:"RETRY",count:t.retrying,fg:e.yellow,bg:je.yellow,show:t.retrying>0},{icon:Wt,label:"REVIEW",count:t.review,fg:e.blue,bg:je.blue,show:t.review>0},{icon:Jo,label:"TODO",count:t.todo,fg:e.dim,bg:je.neutral,show:t.todo>0},{icon:si,label:"DONE",count:t.done,fg:e.green,bg:je.green,show:t.done>0},{icon:ii,label:"FAIL",count:t.failed,fg:e.red,bg:je.red,bold:true,show:t.failed>0},{icon:At,label:"TEAMS",count:t.teams,fg:e.amber,bg:je.amber,show:t.teams>0}].filter(f=>f.show),b=n.total>0,x=f=>f>=1e3?`${(f/1e3).toFixed(1)}k`:String(f),T=l&&l.length>0?Math.min(16,l.length):0;return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:o,children:[jsxs(Box,{gap:1,children:[m.map(f=>jsx(Text,{backgroundColor:f.bg,color:f.fg,bold:f.bold,children:f.spinner?jsxs(Fragment,{children:[" ",jsx(Qo,{color:f.fg})," ",f.count," ",f.label," "]}):jsxs(Fragment,{children:[" ",f.icon," ",f.count," ",f.label," "]})},f.label)),m.length===0&&jsxs(Text,{backgroundColor:je.neutral,color:e.dim,children:[" ","NO TASKS"," "]})]}),jsxs(Box,{gap:0,children:[T>0&&l&&jsxs(Fragment,{children:[jsx(pi,{data:l,width:T,color:e.amberDim}),jsx(Text,{children:" "})]}),b&&jsxs(Text,{backgroundColor:je.amber,color:e.cyan,children:[" ",ai,x(n.input)," ",li,x(n.output)," ",st," ",ci,x(n.total)," "]})]})]})}var er=Nn.memo(function(n){let o=Math.max(10,n.width-2),l=n.stats.running>0;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{height:1}),jsx(fi,{projectName:n.projectName,activeView:n.activeView,mode:n.mode,stats:n.stats,uptime:n.uptime,width:n.width,version:n.version,latestVersion:n.latestVersion}),jsx(Box,{height:1}),jsx(hi,{stats:n.stats,tokens:n.tokens,width:n.width,sparklineData:n.sparklineData}),jsx(mi,{width:o,active:l})]})});var Ut={goal:{sub:["add","list","show","status","delete"],help:"Manage goals"},task:{sub:["add","list","show","cancel","retry","assign","approve","reject","delete"],help:"Manage tasks"},agent:{sub:["add","list","disable","enable","delete","autonomous"],help:"Manage agents"},team:{sub:["create","list","join","leave","disband","set-lead"],help:"Manage teams"},run:{args:"[id]",help:"Run task (or selected)"},"run-all":{help:"Run all todo tasks"},watch:{help:"Start watch mode (auto-dispatch)"},pause:{help:"Pause watch mode"},config:{sub:["activity-filter","max-concurrent"],help:"TUI settings"},status:{help:"Show orchestrator status"},help:{help:"List all commands"},quit:{help:"Exit the TUI"}};function so(t){if(!t.startsWith("/"))return null;let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let x=n;if(!x)return null;let T=Object.keys(Ut).find(f=>f.startsWith(x)&&f!==x);return T?T.slice(x.length):null}let l=n.slice(0,o),c=Ut[l];if(!c?.sub)return null;let m=n.slice(o+1);if(!m)return null;let b=c.sub.find(x=>x.startsWith(m)&&x!==m);return b?b.slice(m.length):null}function tr(t){if(!t.startsWith("/"))return [];let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let x=n.toLowerCase(),T=[];for(let[f,C]of Object.entries(Ut))if(!x||f.startsWith(x)){let $=C.args?` ${C.args}`:"";if(T.push({cmd:`/${f}${$}`,desc:C.help,subs:C.sub?.join(" \xB7 ")}),x&&f===x&&C.sub)for(let P of C.sub)T.push({cmd:`/${f} ${P}`,desc:`${C.help}: ${P}`});}return T}let l=n.slice(0,o),c=Ut[l];if(!c?.sub)return [];let m=n.slice(o+1).toLowerCase(),b=[];for(let x of c.sub)(!m||x.startsWith(m))&&b.push({cmd:`/${l} ${x}`,desc:`${c.help}: ${x}`});return b}var _n=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 bi="\u2588",nr=Nn.memo(function({mode:n,value:o,completion:l,activeView:c,canRun:m,canNew:b,canApprove:x,canReject:T,canCancel:f,canDelete:C,canUndo:$,canEdit:P,canForceStop:W,canToggleAuto:j,autoActive:O,canPause:N,isPaused:D,canToggleShowAll:F,showAllActive:Y,hasDetail:z,itemCount:_,itemLabel:S,width:A,hasSuggestions:G}){if(n==="command"){let L=G?" \u2191\u2193 select Tab fill Esc \u2715":" Enter exec \u2191\u2193 history Tab complete Esc \u2715",ye=Math.max(4,A-6-L.length-(l?.length??0)-1),fe=o.length>ye?"\u2026"+o.slice(-(ye-1)):o;return jsx(Box,{paddingX:2,justifyContent:"space-between",width:A,children:jsxs(Box,{children:[jsx(Text,{color:e.amber,children:"/ "}),jsx(Text,{color:e.white,children:fe}),l&&jsx(Text,{color:e.ghost,children:l}),jsx(Text,{color:e.amber,children:bi}),jsx(Text,{color:e.dim,children:L})]})})}return jsxs(Box,{paddingX:2,justifyContent:"space-between",width:A,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"]}),m&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"R"})," run"]}),f&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"C"})," cancel"]}),x&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.green,children:"A"})," approve"]}),T&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"X"})," reject"]}),P&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"E"})," edit"]}),W&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"S"})," stop"]}),N&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"P"}),D?" resume":" pause"]}),j&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"U"}),O?" auto off":" auto on"]}),F&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"S"}),Y?" collapse":" show all"]}),C&&!x&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"D"})," delete"]}),$&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.yellow,children:"Z"})," undo"]}),z&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Esc"})," close"]}),!z&&(c==="tasks"||c==="agents"||c==="goals")&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Enter"})," detail"]})," ",jsx(Text,{bold:true,color:e.gray,children:"Q"})," quit"]}),_>0&&jsxs(Text,{color:e.dim,children:[_," ",S]})]})});var Rn="\u2588";function rr({title:t,steps:n,onComplete:o,onCancel:l,width:c,height:m,onPasteImage:b,footerExtra:x}){let [T,f]=useState(0),[C,$]=useState({}),[P,W]=useState(()=>{let E=n.find(R=>!R.skip?.({}));return E?.type==="text"&&E.defaultValue?E.defaultValue:""}),[j,O]=useState(()=>{let E=n.find(R=>!R.skip?.({}));return E?.type==="text"&&E.defaultValue?E.defaultValue.length:0}),[N,D]=useState(()=>{let E=n.find(R=>!R.skip?.({}));return E?.type==="textarea"&&E.defaultValue?E.defaultValue.split(`
|
|
5
|
-
`):[""]}),[F,Y]=useState(0),[z,_]=useState(0),[S,A]=useState(()=>{let E=n.find(R=>!R.skip?.({}));if(E?.type==="select"&&E.defaultValue){let I=(E.getOptions?.({})??E.options??[]).findIndex(V=>V.value===E.defaultValue);return I>=0?I:0}return 0}),G=useMemo(()=>n.filter(E=>!E.skip?.(C)),[n,C]),L=G[T],ye=G.length,[Ae,tt]=useState(new Set),He=useMemo(()=>!L||L.type!=="select"&&L.type!=="multiselect"?[]:L.getOptions?.(C)??L.options??[],[L,C]),Ge=Math.min(S,Math.max(0,He.length-1)),Xe=E=>{let R={...C,[L.id]:E};$(R),W(""),O(0),D([""]),Y(0),_(0),A(0),tt(new Set);let I=L.id,q=n.findIndex(Z=>Z.id===I)+1;for(;q<n.length;){let Z=n[q];if(Z&&!Z.skip?.(R))break;q++;}if(q>=n.length)o(R);else {let Z=n[q].id,Ie=n.filter(be=>!be.skip?.(R)).findIndex(be=>be.id===Z);f(Ie>=0?Ie:0);let ue=n[q];if(ue.type==="text"){let be=ue.defaultValue??"";W(be),O(be.length);}else if(ue.type==="textarea"){let be=ue.defaultValue?ue.defaultValue.split(`
|
|
6
|
-
`):[""];D(be),Y(be.length-1),_(be[be.length-1].length);}else if(ue.type==="select"){let be=ue.getOptions?.(R)??ue.options??[];if(ue.defaultValue){let gt=be.findIndex(Ke=>Ke.value===ue.defaultValue);A(gt>=0?gt:0);}else A(0);}else ue.type==="multiselect"&&(A(0),ue.defaultValue?tt(new Set(ue.defaultValue.split(","))):tt(new Set));}},Oe=()=>{if(T===0){l();return}let E=L.id,I=n.findIndex(Q=>Q.id===E)-1;for(;I>=0;){let Q=n[I];if(Q&&!Q.skip?.(C))break;I--;}if(I<0){l();return}let V=n[I].id,q=G.findIndex(Q=>Q.id===V);f(q>=0?q:0);let Z=n[I];if(Z.type==="text"){let Q=C[Z.id]??Z.defaultValue??"";W(Q),O(Q.length);}else if(Z.type==="textarea"){let Q=C[Z.id]??Z.defaultValue??"",Ie=Q?Q.split(`
|
|
7
|
-
`):[""];D(Ie),Y(Ie.length-1),_(Ie[Ie.length-1].length);}else if(Z.type==="multiselect"){A(0);let Q=C[Z.id];tt(Q?new Set(Q.split(",")):new Set);}else {let Q=Z.getOptions?.(C)??Z.options??[],Ie=C[Z.id],ue=Q.findIndex(be=>be.value===Ie);A(ue>=0?ue:0);}};if(useInput((E,R)=>{if(L){if(R.escape){T===0?l():Oe();return}if(R.ctrl&&(E==="v"||E==="i")&&b&&(L.type==="text"||L.type==="textarea")){b();return}if(L.type==="text"){if(R.return){let I=P.trim();if(L.required&&!I)return;Xe(I);return}if(R.leftArrow){O(I=>Math.max(0,I-1));return}if(R.rightArrow){O(I=>Math.min(P.length,I+1));return}if(R.backspace||R.delete){if(j===0&&P.length===0&&T>0){Oe();return}j>0&&(W(I=>I.slice(0,j-1)+I.slice(j)),O(I=>I-1));return}E&&!R.ctrl&&!R.meta&&!R.escape&&(W(I=>I.slice(0,j)+E+I.slice(j)),O(I=>I+E.length));return}if(L.type==="textarea"){if(R.return&&!R.shift){let I=N.join(`
|
|
8
|
-
`).trim();if(L.required&&!I)return;Xe(I);return}if(R.return&&R.shift){D(I=>{let V=I[F]??"",q=V.slice(0,z),Z=V.slice(z),Q=[...I];return Q.splice(F,1,q,Z),Q}),Y(I=>I+1),_(0);return}if(R.upArrow){F>0&&(Y(I=>I-1),_(I=>Math.min(I,(N[F-1]??"").length)));return}if(R.downArrow){F<N.length-1&&(Y(I=>I+1),_(I=>Math.min(I,(N[F+1]??"").length)));return}if(R.leftArrow){z>0?_(I=>I-1):F>0&&(Y(I=>I-1),_((N[F-1]??"").length));return}if(R.rightArrow){let I=(N[F]??"").length;z<I?_(V=>V+1):F<N.length-1&&(Y(V=>V+1),_(0));return}if(R.backspace||R.delete){if(z===0&&F===0)return;if(z>0)D(I=>{let V=[...I],q=V[F]??"";return V[F]=q.slice(0,z-1)+q.slice(z),V}),_(I=>I-1);else {let I=(N[F-1]??"").length;D(V=>{let q=[...V],Z=q[F-1]??"",Q=q[F]??"";return q.splice(F-1,2,Z+Q),q}),_(I),Y(V=>V-1);}return}if(E&&!R.ctrl&&!R.meta&&!R.escape){let I=E.split(/\r?\n/);if(I.length===1)D(V=>{let q=[...V],Z=q[F]??"";return q[F]=Z.slice(0,z)+E+Z.slice(z),q}),_(V=>V+E.length);else {let V=F,q=z;D(Z=>{let Q=[...Z],Ie=Q[V]??"",ue=Ie.slice(0,q),be=Ie.slice(q),gt=I[0]??"",Ke=I[I.length-1]??"",dn=[ue+gt,...I.slice(1,-1),Ke+be];return Q.splice(V,1,...dn),Q}),Y(V+I.length-1),_((I[I.length-1]??"").length);}}return}if(L.type==="select"||L.type==="multiselect"){if(R.upArrow||E==="k"){A(I=>Math.max(0,I-1));return}if(R.downArrow||E==="j"){A(I=>Math.min(He.length-1,I+1));return}if(R.backspace||R.delete){Oe();return}if(L.type==="select"){if(R.return||R.tab){let I=He[Ge];I&&Xe(I.value);return}if(E>="1"&&E<="9"){let I=parseInt(E,10)-1;if(I<He.length){let V=He[I];V&&Xe(V.value);}return}}else {if(E===" "){let I=He[Ge];I&&tt(V=>{let q=new Set(V);return q.has(I.value)?q.delete(I.value):q.add(I.value),q});return}if(R.return){let I=Array.from(Ae).join(",");Xe(I);return}}}}}),!L)return null;let qe=`${T+1}/${ye}`,Ye=Math.max(2,m-4),Me=0;Ge>=Ye&&(Me=Ge-Ye+1);let ze=He.slice(Me,Me+Ye);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:[" ",xt,xt," "]}),jsxs(Text,{color:e.dim,children:["step ",qe]})]}),jsxs(Box,{children:[jsx(Text,{children:" "}),G.map((E,R)=>jsxs(Text,{color:R===T?e.amber:R<T?e.green:e.ghost,children:[R===T?"\u25CF":R<T?"\u2713":"\u25CB"," "]},E.id))]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.white,bold:true,children:[" ",L.label]}),!L.required&&jsx(Text,{color:e.dim,children:" (optional, Enter to skip)"})]}),L.type==="text"&&jsxs(Box,{children:[jsxs(Text,{color:e.amber,children:[" ",">"," "]}),P.length>0?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:P.slice(0,j)}),jsx(Text,{color:e.amber,children:Rn}),jsx(Text,{color:e.white,children:P.slice(j)})]}):L.placeholder?jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:L.placeholder}),jsx(Text,{color:e.amber,children:Rn})]}):jsx(Text,{color:e.amber,children:Rn})]}),L.type==="textarea"&&(()=>{let E=Math.max(3,m-6),R=0;F>=E&&(R=F-E+1);let I=N.slice(R,R+E),V=String(N.length).length;return jsxs(Box,{flexDirection:"column",children:[I.map((q,Z)=>{let Q=Z+R,Ie=String(Q+1).padStart(V," "),ue=Q===F;return jsxs(Box,{children:[jsxs(Text,{color:e.dim,children:[" ",Ie," "]}),jsxs(Text,{color:e.ghost,children:["\u2502"," "]}),ue?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:q.slice(0,z)}),jsx(Text,{color:e.amber,children:Rn}),jsx(Text,{color:e.white,children:q.slice(z)})]}):jsx(Text,{color:e.silver,children:q||" "})]},Q)}),N.length===1&&N[0]===""&&L.placeholder&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","".padStart(V," ")," ",L.placeholder]})})]})})(),L.type==="select"&&jsx(Box,{flexDirection:"column",children:ze.map((E,R)=>{let I=R+Me,V=I===Ge,q=I<9?`${I+1}`:" ";return jsxs(Box,{children:[jsx(Text,{color:V?e.amber:e.ghost,children:V?" \u25B8 ":` ${q} `}),jsx(Text,{color:V?e.white:e.silver,bold:V,children:E.label}),E.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",xt," ",E.hint.replace(/\n/g," ")]})]},E.value)})}),L.type==="multiselect"&&jsxs(Box,{flexDirection:"column",children:[ze.map((E,R)=>{let V=R+Me===Ge,q=Ae.has(E.value);return jsxs(Box,{children:[jsx(Text,{color:V?e.amber:e.ghost,children:V?" \u25B8 ":" "}),jsx(Text,{color:q?e.green:e.dim,children:q?"[\u2713]":"[ ]"}),jsxs(Text,{color:V?e.white:e.silver,bold:V,children:[" ",E.label]}),E.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",xt," ",E.hint.replace(/\n/g," ")]})]},E.value)}),Ae.size>0&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","\u2514"," ",Ae.size," selected"]})})]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.ghost,children:[" ",L.type==="select"?"\u2191\u2193 select Enter confirm":L.type==="multiselect"?"\u2191\u2193 move Space toggle Enter confirm":L.type==="textarea"?"Shift+Enter newline Enter confirm \u2190\u2191\u2192\u2193 navigate":"\u2190\u2192 move Enter confirm",b&&(L.type==="text"||L.type==="textarea")?" Ctrl+V paste image":""," Esc ",T>0?"back":"cancel"]}),x&&jsxs(Text,{color:e.amber,children:[" ",x]})]})]})}var wi="\u256D",Si="\u256E",ki="\u2570",Ii="\u256F",it="\u2502";function Ci({children:t,cw:n}){return jsxs(Text,{children:[jsx(Text,{color:e.ghost,children:it}),jsxs(Text,{children:[" ",t.padEnd(n)," "]}),jsx(Text,{color:e.ghost,children:it})]})}function Bn({cw:t}){return jsx(Ci,{cw:t,children:""})}function En({count:t,config:n,width:o}){if(t>=3)return null;let l=Math.min((o??44)-4,50),c=l-6,m=xt.repeat(l-2),b=jsxs(Text,{color:e.ghost,children:[wi,m,Si]}),x=jsxs(Text,{color:e.ghost,children:[ki,m,Ii]});if(t>0){let f=n.hints[0],C=f?` ${f.key} ${f.label}`:"";return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[b,jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[it," "]}),jsx(Text,{color:e.amber,children:At}),jsxs(Text,{color:e.silver,children:[" ",n.nudge.padEnd(c-2-C.length)]}),f&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",f.key]}),jsxs(Text,{color:e.gray,children:[" ",f.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:it})]}),x]})}let T=n.hints.reduce((f,C,$)=>f+C.key.length+1+C.label.length+($>0?3:0),0);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[b,jsx(Bn,{cw:c}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[it," "]}),jsx(Text,{color:e.amber,children:At}),jsxs(Text,{color:e.white,bold:true,children:[" ",n.title]}),jsx(Text,{children:" ".repeat(Math.max(0,c-n.title.length-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:it})]}),jsx(Bn,{cw:c}),n.description.map((f,C)=>jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[it," "]}),jsx(Text,{color:e.silver,children:f.padEnd(c)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:it})]},C)),jsx(Bn,{cw:c}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[it," "]}),n.hints.map((f,C)=>jsxs(Nn.Fragment,{children:[C>0&&jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amber,children:f.key}),jsxs(Text,{color:e.gray,children:[" ",f.label]})]},C)),jsx(Text,{children:" ".repeat(Math.max(0,c-T))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:it})]}),jsx(Bn,{cw:c}),x]})}var ar=[{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"}],lr=[{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"}],cr=[{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"}],dr=[{value:"",label:"Default",hint:"use shell adapter default"}],$i=[{value:"claude",label:"Claude",hint:"Claude Code CLI"},{value:"codex",label:"Codex",hint:"OpenAI Codex CLI"},{value:"cursor",label:"Cursor",hint:"Cursor Agent CLI"},{value:"shell",label:"Shell",hint:"custom shell command"}],ur=[{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"}],ir=80;function gr(t){return t.filter(n=>n.status!=="disabled").map(n=>{let o=n.role??n.adapter,l=o.length>ir?o.slice(0,ir-1)+"\u2026":o;return {value:n.id,label:n.name,hint:l}})}function Ln(t,n="Auto-assign",o="orchestrator picks the best agent"){return [{value:"",label:n,hint:o},...gr(t)]}var lo=[{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 mr(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 pr(t){let n=mr(t);return [{id:"name",label:"Agent name",type:"text",placeholder:"e.g. alpha, frontend-bot, reviewer",required:true},{id:"adapter",label:"Provider",type:"select",options:$i},{id:"model",label:"Model",type:"select",getOptions:o=>o.adapter==="codex"?lr:o.adapter==="cursor"?cr:o.adapter==="shell"?dr:ar},{id:"role",label:"Role / specialization",type:"select",options:lo},{id:"role_custom",label:"Describe the role",type:"textarea",placeholder:"e.g. Specialist in React and TypeScript",skip:o=>o.role!=="__custom__"},{id:"team",label:"Join team",type:"select",options:n,skip:()=>n.length<=1}]}function fr(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0;return {name:t.name,adapter:t.adapter||"claude",role:n,model:t.model||void 0,approval_policy:"auto",team_id:t.team||void 0}}function hr(t){let n=gr(t);return [{id:"name",label:"Team name",type:"text",placeholder:"e.g. frontend, backend, qa",required:true},{id:"lead",label:"Team lead",type:"select",options:n},{id:"members",label:"Team members",type:"multiselect",getOptions:o=>n.filter(l=>l.value!==o.lead),skip:o=>!n.some(l=>l.value!==o.lead)},{id:"description",label:"Description",type:"textarea",placeholder:"Optional team purpose..."}]}function xr(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 br(t){let n=Ln(t);return [{id:"title",label:"Task title",type:"text",placeholder:"What needs to be done?",required:true},{id:"priority",label:"Priority",type:"select",options:ur,defaultValue:"3"},{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 Tr(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 yr(t,n){let o=Ln(n,"None / Auto","remove assignee");return [{id:"title",label:"Task title",type:"text",defaultValue:t.title,required:true},{id:"priority",label:"Priority",type:"select",options:ur,defaultValue:String(t.priority)},{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 wr(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description??""}}function Sr(t,n){let o=lo.find(x=>x.value===t.role),l=o?t.role:t.role?"__custom__":"",c=t.adapter==="codex"?lr:t.adapter==="cursor"?cr:t.adapter==="shell"?dr:ar,m=mr(n),b=n?.find(x=>x.members.some(T=>T.agent_id===t.id))?.id;return [{id:"name",label:"Agent name",type:"text",defaultValue:t.name,required:true},{id:"model",label:"Model",type:"select",options:c,defaultValue:t.config.model??""},{id:"role",label:"Role / specialization",type:"select",options:lo,defaultValue:l},{id:"role_custom",label:"Describe the role",type:"textarea",defaultValue:t.role&&!o?t.role:"",placeholder:"e.g. Specialist in React and TypeScript",skip:x=>x.role!=="__custom__"},{id:"team",label:"Team",type:"select",options:m,defaultValue:b??"",skip:()=>m.length<=1}]}var Ai=[{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"}],Mi=[{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"}];function kr(t,n){return [{id:"setting",label:"Setting",type:"select",options:[{value:"activity_filter",label:"Activity filter",hint:`current: ${t}`},{value:"max_concurrent",label:"Max concurrent agents",hint:`current: ${n}`}]},{id:"activity_filter",label:"Activity filter preset",type:"select",options:Mi,defaultValue:t,skip:o=>o.setting!=="activity_filter"},{id:"max_concurrent",label:"Max concurrent agents",type:"select",options:Ai,defaultValue:String(n),skip:o=>o.setting!=="max_concurrent"}]}function Ir(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0;return {name:t.name,role:n,model:t.model||void 0,team_id:t.team||void 0}}function co(t){let n=Ln(t,"Any agent","auto-assign to autonomous agents");return [{id:"title",label:"Goal title",type:"text",placeholder:"What should be achieved?",required:true},{id:"assignee",label:"Assignee",type:"select",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Detailed goal description, success criteria..."}]}function Cr(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description||void 0}}function vr(t,n){let o=Ln(n,"Any agent","auto-assign");return [{id:"title",label:"Goal title",type:"text",defaultValue:t.title,required:true},{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:"Detailed goal description..."}]}function $r(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description??""}}var Ar=10,Mr=500,Wn=2048,Bt=200,uo=new Set(["todo","failed","cancelled"]),Ei={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."},Li={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."},Oi={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."},_r=5e3,Er=0;function Wl(){Er=0;}var Lr=/^\[[\w_]+\]$/;function Or(t){return Lr.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 Rr=["#5faf87","#5fafd7","#af87ff","#d7af00","#5fd7d7","#d787af","#afaf5f","#d7875f"];function Fn(t,n){let o=n.findIndex(l=>l.id===t);return Rr[o>=0?o%Rr.length:0]}var Pi=" ".repeat(9),Gn={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},Dn=["system","lifecycle","output","tool","result","error","file","info"],Ht=[{label:"all",types:Dn},{label:"text",types:["output"]},{label:"tools",types:["tool","result","file"]},{label:"errors",types:["error"]},{label:"events",types:["lifecycle","system"]}];function go(t){let o=(Ht.findIndex(l=>l.types.length===t.size&&l.types.every(c=>t.has(c)))+1)%Ht.length;return Ht[o]}function Fl({projectName:t,tasks:n,agents:o=[],state:l,onRunTask:c$1,onCreateTask:m,onCancelTask:b,onRetryTask:x,onAssignTask:T,onRunAll:f,onDisableAgent:C,onEnableAgent:$,onSubscribeEvents:P,onRefreshTasks:W,onRefreshAgents:j,onRefreshState:O,onLoadHistory:N,onAddAgent:D,onDeleteAgent:F,onApproveTask:Y,onRejectTask:z,onDeleteTask:_,onUpdateTask:S,onUpdateAgent:A,onForceStopAgent:G,onCreateTeam:L,onListTeams:ye,onJoinTeam:fe,onLeaveTeam:Ae,onDisbandTeam:tt,onSetTeamLead:He,onStartWatch:Ge,onStopWatch:Xe,onToggleAutonomous:Oe,onRefreshGoals:Et,onCreateGoal:qe,onUpdateGoal:Ye,onUpdateGoalStatus:Me,onDeleteGoal:ze,onGetGoalProgress:E,initialWatchActive:R,watchError:I,messageBatchMs:V=process.env.VITEST?0:80,initialActivityFilter:q="all",onSaveActivityFilter:Z,initialMaxConcurrent:Q=a.scheduling.max_concurrent_agents,onSaveMaxConcurrent:Ie,version:ue,latestVersion:be}){let{exit:gt}=useApp(),{stdout:Ke}=useStdout(),[dn,Gr]=useState({w:Ke?.columns??80,h:Ke?.rows??24});useEffect(()=>{if(!Ke)return;let i=()=>Gr({w:Ke.columns,h:Ke.rows});return Ke.on("resize",i),()=>{Ke.off("resize",i);}},[Ke]);let Xt=dn.w,mo=dn.h,[Ze,zr]=useState(n),[Ce,Vr]=useState(o),[Ve,jr]=useState(l),[un,zn]=useState(R??!!l.pid),[Vn,po]=useState([]),[Ur,fo]=useState(void 0),[v,Lt]=useState("tasks"),[gn,mn]=useState(0),[jn,ho]=useState(0),[Un,xo]=useState(0),[we,qt]=useState(false),[Je,bo]=useState([]),[ve,Ee]=useState("none"),[wt,nt]=useState(""),[mt,ot]=useState(null),[St,Yt]=useState([]),[Hr,Xr]=useState(0),[qr,Yr]=useState(()=>new Set(Dn)),[Kt,Hn]=useState(-1),[Kr,Zt]=useState(0),[Ot,Xn]=useState(()=>{let i=Ht.find(y=>y.label===q);return new Set(i?.types??Dn)}),pn=useMemo(()=>Ht.find(y=>y.types.length===Ot.size&&y.types.every(s=>Ot.has(s)))?.label??"all",[Ot]),qn=useMemo(()=>Ot.size>=Dn.length?Je:Je.filter(i=>Ot.has(i.msgType??"info")),[Je,Ot]),[To,Zr]=useState(Q),fn=Nn.useRef(new _n).current,[Jr,Jt]=useState(0),[yo,wo]=useState(false),[Qr,Yn]=useState(0),[es,Kn]=useState(0),[ts,Qt]=useState(0),[hn,pt]=useState(0),[ft,So]=useState([]),[Pt,Zn]=useState([]),xn=useRef(ft);xn.current=ft;let H=useCallback(async i=>{let[y,s,d,g,h]=await Promise.all([W?.()??Promise.resolve(Ze),j?.()??Promise.resolve(Ce),O?.()??Promise.resolve(Ve),i?.includeTeams?ye?.()??Promise.resolve(xn.current):Promise.resolve(null),Et?.()??Promise.resolve(Vn)]);zr(y),Vr(s),jr(d),g!==null&&So(g),po(h),R&&zn(!!d.pid);},[W,j,O,ye,Et,R]),Se=useMemo(()=>[...Ze].sort((i,y)=>(an[i.status]??9)-(an[y.status]??9)),[Ze]),ht=yo?Se:Se.slice(0,Ar),en=Se.length-ht.length,B=Se[gn],bn=useMemo(()=>{let i=new Map;for(let y of Ze)i.set(y.id,y.title);return i},[Ze]),kt=useMemo(()=>{let i=new Map;for(let y of Ce)i.set(y.id,y.name);return i},[Ce]),{agentTeamMap:Dt,activeTeamCount:tn,teamLeadSet:ns}=useMemo(()=>{let i=new Map,y=new Set,s=0;for(let d of ft)if(d.status==="active"){s++,y.add(d.lead_agent_id);for(let g of d.members)i.set(g.agent_id,d.name);}return {agentTeamMap:i,activeTeamCount:s,teamLeadSet:y}},[ft]),$e=useMemo(()=>{let i=[...Ce];return i.sort((y,s)=>{let d=Dt.get(y.id),g=Dt.get(s.id);return d&&!g?-1:!d&&g?1:d&&g&&d!==g?d.localeCompare(g):(oo[y.status]??9)-(oo[s.status]??9)}),i},[Ce,Dt]),U=$e[jn],lt=useMemo(()=>[...Vn].sort((i,y)=>(c[i.status]??9)-(c[y.status]??9)),[Vn]),K=lt[Un],os=useMemo(()=>K?Ze.filter(i=>i.goalId===K.id):[],[K,Ze]),Jn=useRef(E);Jn.current=E,useEffect(()=>{if(!K||!Jn.current){fo(void 0);return}let i=false;return Jn.current(K.id).then(y=>{i||fo(y);}).catch(()=>{}),()=>{i=true;}},[K?.id]);let It=useRef(new Map),Tn=useRef(new Map);useEffect(()=>{for(let[i,y]of Object.entries(Ve.running))It.current.set(y.run_id,y.agent_id),Tn.current.set(y.run_id,i);if(It.current.size>Mr){let i=It.current.size-Mr,y=0;for(let s of It.current.keys()){if(y++>=i)break;It.current.delete(s),Tn.current.delete(s);}}},[Ve.running]);let Ct=useRef([]),nn=useRef(null),Qn=useCallback(()=>{if(nn.current=null,Ct.current.length===0)return;let i=Ct.current;Ct.current=[],bo(y=>{if(i.length>=Bt)return i.slice(-Bt);let s=Bt-i.length;return (y.length>s?y.slice(-s):y).concat(i)});},[]);useEffect(()=>()=>{nn.current&&clearTimeout(nn.current);},[]);let r=useCallback((i,y,s)=>{let d=new Date,g=d.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),h=s?.detail&&s.detail.length>Wn?s.detail.slice(0,Wn)+"\u2026[truncated]":s?.detail;Ct.current.push({text:i,color:y,time:g,ts:d.getTime(),...s,detail:h}),Ct.current.length>Bt*2&&(Ct.current=Ct.current.slice(-Bt)),V===0?Qn():nn.current||(nn.current=setTimeout(Qn,V));},[Qn]);useEffect(()=>{I&&r(`Watch mode failed: ${I}. Tasks will not auto-dispatch.`,e.red);},[]);let on=useCallback((i,y,s,d)=>{let g={key:++Er,entityType:i,entityId:y,entityName:s,expiresAt:Date.now()+_r,needsForceStop:d?.needsForceStop};Zn(h=>[...h,g]),r(`\u2717 "${s}" will be deleted in ${Math.round(_r/1e3)}s \u2014 press Z to undo`,e.yellow);},[r]),rs=useCallback(()=>{Zn(i=>{if(i.length===0)return i;let y=i[i.length-1];return r(`\u21B6 Undo: "${y.entityName}" restored`,e.green),i.slice(0,-1)});},[r]),ko=useCallback(async i=>{try{i.entityType==="task"&&_?await _(i.entityId):i.entityType==="agent"?(i.needsForceStop&&G&&await G(i.entityId),F&&await F(i.entityId)):i.entityType==="goal"&&ze&&await ze(i.entityId),r(`\u2713 Deleted "${i.entityName}"`,e.green),H();}catch(y){r(`Failed to delete "${i.entityName}": ${y instanceof Error?y.message:String(y)}`,e.red);}},[_,F,ze,G,r,H]),Io=useRef(ko);Io.current=ko,useEffect(()=>{if(Pt.length===0)return;let i=setInterval(()=>{let y=Date.now(),s=[];Zn(d=>{let g=d.filter(h=>h.expiresAt<=y?(s.push(h),false):true);return s.length>0?g:d});for(let d of s)Io.current(d);},1e3);return ()=>clearInterval(i)},[Pt.length>0]),useEffect(()=>{if(!N)return;let i=y=>{let s=new Date(y.timestamp).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),d=typeof y.data=="string"?y.data:JSON.stringify(y.data),g,h=e.silver,p="output";if(y.type==="error")g=typeof y.data=="string"?y.data:JSON.stringify(y.data),g=g.slice(0,200),h=e.red,p="error";else if(y.type==="file_changed")g=String(y.data),h=e.purple,p="file";else if(y.type==="done")g="Completed",h=e.green,p="lifecycle";else if(y.type==="tool_call")g=`\u2699 ${y.data?.name??"tool"}()`,h=e.cyan,p="tool";else {let{summary:w}=Fr(d);g=w;let X=Or(g);p=X.msgType,h=X.color;}return {text:g,color:h,time:s,ts:new Date(y.timestamp).getTime(),agentId:y.agentId,taskId:y.taskId,msgType:p}};N(y=>{if(y.length===0)return;let s=y.map(i);bo(d=>{let g=[...s,...d];return g.length>Bt?g.slice(-Bt):g});}).catch(()=>{});},[]),useEffect(()=>{ye?.().then(So).catch(()=>{}),Et?.().then(po).catch(()=>{});},[]);let yn=useCallback(()=>{ot({title:"NEW AGENT",steps:pr(xn.current),kind:"agent"}),Ee("wizard");},[]),wn=useCallback(()=>{Yt([]),ot({title:"NEW TASK",steps:br(Ce),kind:"task"}),Ee("wizard");},[Ce]),ss=useCallback(async()=>{try{let{detectClipboardType:i,getClipboardImage:y}=await import('./clipboard-service-PDTSZIR5.js'),s=await i();if(s!=="image")return r(s==="text"?"Clipboard has text, not image":"Clipboard is empty",e.dim),s;let d=await y();if(!d)return r("Failed to read clipboard image",e.red),"empty";let{mkdtemp:g,writeFile:h}=await import('fs/promises'),{tmpdir:p}=await import('os'),{join:w}=await import('path'),X=await g(w(p(),"orch-paste-")),Nt=w(X,`clipboard-${Date.now()}.${d.ext}`);return await h(Nt,d.data),Yt(Rs=>[...Rs,Nt]),r(`\u{1F4CE} Image attached (${Math.round(d.data.length/1024)}KB)`,e.green),"image"}catch{return r("Clipboard paste failed",e.red),"empty"}},[r]),is=useCallback(i=>{ot({title:"EDIT TASK",steps:yr(i,Ce),kind:"edit_task",targetId:i.id}),Ee("wizard");},[Ce]),Co=useCallback(()=>{ot({title:"NEW TEAM",steps:hr(Ce),kind:"team"}),Ee("wizard");},[Ce]),as=useCallback(i=>{ot({title:"EDIT AGENT",steps:Sr(i,ft),kind:"edit_agent",targetId:i.id}),Ee("wizard");},[ft]),vo=useCallback(()=>{ot({title:"SETTINGS",steps:kr(pn,To),kind:"config"}),Ee("wizard");},[pn,To]),ls=useCallback(i=>{Ee("none");let y=mt?.kind,s=mt?.targetId;if(ot(null),y==="agent"&&D){let d=fr(i);r(`Creating agent "${d.name}"...`,e.amber),D(d.name,d.adapter,{model:d.model,role:d.role,approval_policy:d.approval_policy}).then(g=>{r(`\u2713 Created agent "${g.name}" (${g.id}, ${g.adapter})`,e.green),d.team_id&&fe?fe(d.team_id,g.id).then(h=>{r(`\u2713 Joined team "${h.name}"`,e.green),H({includeTeams:true});},h=>r(`Failed to join team: ${h instanceof Error?h.message:String(h)}`,e.red)):H();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(y==="team"&&L){let d=xr(i);r(`Creating team "${d.name}"...`,e.amber),L(d).then(g=>{r(`\u2713 Created team "${g.name}" (${g.id}, ${g.members.length} members)`,e.green),H({includeTeams:true});},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(y==="task"&&m){let d=Tr(i),g=St.length>0?[...St]:void 0;Yt([]),r(`Creating "${d.title}"...`,e.amber),m(d.title,{priority:d.priority,description:d.description,attachments:g}).then(h=>{r(`\u2713 Created "${h.title}" (${h.id})${g?` \u{1F4CE}${g.length}`:""}`,e.green),d.assignee&&T&&T(h.id,d.assignee).catch(()=>{}),H();},h=>r(`Failed: ${h instanceof Error?h.message:String(h)}`,e.red));}else if(y==="edit_task"&&s&&S){let d=wr(i),g=St.length>0?[...St]:void 0;Yt([]),r("Updating task...",e.amber),S(s,{...d,attachments:g}).then(h=>{r(`\u2713 Updated "${h.title}"${g?` \u{1F4CE}${g.length}`:""}`,e.green),d.assignee&&T&&T(s,d.assignee).catch(()=>{}),H();},h=>r(`Failed: ${h instanceof Error?h.message:String(h)}`,e.red));}else if(y==="edit_agent"&&s&&A){let d=Ir(i),g=d.team_id??"",h=ft.find(p=>p.members.some(w=>w.agent_id===s))?.id??"";r("Updating agent...",e.amber),A(s,{name:d.name,role:d.role,model:d.model}).then(p=>{r(`\u2713 Updated agent "${p.name}"`,e.green);let w=[];h&&h!==g&&Ae&&w.push(Ae(h,s).then(X=>r(`\u2713 Left team "${X.name}"`,e.green),X=>r(`Failed to leave team: ${X instanceof Error?X.message:String(X)}`,e.red))),g&&g!==h&&fe&&w.push(fe(g,s).then(X=>r(`\u2713 Joined team "${X.name}"`,e.green),X=>r(`Failed to join team: ${X instanceof Error?X.message:String(X)}`,e.red))),Promise.all(w).then(()=>H({includeTeams:w.length>0}));},p=>r(`Failed: ${p instanceof Error?p.message:String(p)}`,e.red));}else if(y==="config"){if(i.setting==="activity_filter"&&i.activity_filter){let d=Ht.find(g=>g.label===i.activity_filter);d&&(Xn(new Set(d.types)),Z?.(d.label),r(`Activity filter: ${d.label}`,e.amber));}else if(i.setting==="max_concurrent"&&i.max_concurrent){let d=parseInt(i.max_concurrent,10);d>0&&(Zr(d),Ie?.(d),r(`Max concurrent agents: ${d}`,e.amber));}}else if(y==="goal"&&qe){let d=Cr(i);r(`Creating goal "${d.title}"...`,e.amber),qe(d).then(g=>{r(`\u2713 Created goal "${g.title}" (${g.id})`,e.green),H();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(y==="edit_goal"&&s&&Ye){let d=$r(i);r("Updating goal...",e.amber),Ye(s,d).then(g=>{r(`\u2713 Updated goal "${g.title}"`,e.green),H();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}},[mt,D,m,L,fe,Ae,T,S,A,Oe,qe,Ye,r,H,Z,Ie,ft,St]),cs=useCallback(()=>{Ee("none"),ot(null),Yt([]);},[]);useEffect(()=>{if(!P)return;let i=null,y=()=>{i||(i=setTimeout(()=>{i=null,H().catch(()=>{});},150));},s=P(d=>{d.type==="agent:started"&&(It.current.set(d.runId,d.agentId),Tn.current.set(d.runId,d.taskId)),oa(d,r,It.current,Tn.current),(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")&&y();});return ()=>{s(),i&&clearTimeout(i);}},[P,r,H]);let eo=un?"watching":"idle",ds=Ve.started_at?g(Ve.started_at):void 0,us=Ve.stats.total_tokens.total,$o=useMemo(()=>{let i={running:0,retrying:0,review:0,todo:0,done:0,failed:0,cancelled:0};for(let y of Ze)y.status==="in_progress"?i.running++:y.status==="retrying"?i.retrying++:y.status==="review"?i.review++:y.status==="todo"?i.todo++:y.status==="done"?i.done++:y.status==="failed"?i.failed++:y.status==="cancelled"&&i.cancelled++;return {...i,teams:tn}},[Ze,tn]);$o.running;let gs={input:Ve.stats.total_tokens.input??0,output:Ve.stats.total_tokens.output??0,total:us},Sn=Math.max(4,mo-9),ms=Dt.size,ps=Ce.length>ms,fs=tn>0?tn+(ps?1:0):0,hs=v==="goals"?lt.length+1:v==="tasks"?ht.length+1+(en>0?1:0):v==="agents"?Ce.length+1+fs:0,xs=Math.min(hs+1,Math.ceil(Sn*.5)),he=v==="logs"?Sn:Math.max(2,Math.min(xs,Sn-4)),vt=Math.max(1,Sn-he),me=Math.max(10,Xt-2),rt=useMemo(()=>ve==="command"?tr(wt):[],[ve,wt]);useEffect(()=>{Jt(i=>Math.min(i,Math.max(0,ht.length-he)));},[ht.length,he]),useEffect(()=>{Yn(i=>Math.min(i,Math.max(0,$e.length-he)));},[$e.length,he]),useEffect(()=>{Kn(i=>Math.min(i,Math.max(0,lt.length-he)));},[lt.length,he]);let bs=useCallback(i=>{let s=i.trim().replace(/^\//,"").split(/\s+/),d=s[0]?.toLowerCase();if(!d)return;let g=h=>h instanceof Error?h.message:String(h);switch(d){case "cancel":{if(!B){r("No task selected",e.yellow);return}if(!b)return;r(`Cancelling "${B.title}"...`,e.amber),b(B.id).then(()=>{r(`\u2713 Cancelled "${B.title}"`,e.green),H();},h=>r(`Failed: ${g(h)}`,e.red));return}case "retry":{if(!B){r("No task selected",e.yellow);return}if(!x)return;r(`Retrying "${B.title}"...`,e.amber),x(B.id).then(()=>{r(`\u2713 Retried "${B.title}"`,e.green),H();},h=>r(`Failed: ${g(h)}`,e.red));return}case "assign":{if(!B){r("No task selected",e.yellow);return}if(!T||!s[1]){r("Usage: assign <agent>",e.yellow);return}r(`Assigning "${B.title}" to ${s[1]}...`,e.amber),T(B.id,s[1]).then(()=>{r(`\u2713 Assigned "${B.title}" to ${s[1]}`,e.green),H();},h=>r(`Failed: ${g(h)}`,e.red));return}case "task":{let h=s[1]?.toLowerCase();if(h==="add"){let p=s.slice(2).join(" ");if(!p){wn();return}if(!m){r("Create not available",e.yellow);return}r(`Creating "${p}"...`,e.amber),m(p).then(w=>{r(`\u2713 Created "${w.title}" (${w.id})`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="list"){let p=Se.map(w=>` ${w.id} ${w.status.padEnd(11)} ${w.title}`);if(p.length===0)r("No tasks",e.dim);else for(let w of p)r(w,e.cyan);}else if(h==="show"){let p=s[2]?Se.find(w=>w.id===s[2]):B;if(!p){r("No task selected or id given",e.yellow);return}r(`${p.id} ${p.status} P${p.priority} "${p.title}"`,e.cyan),p.assignee&&r(` agent: ${p.assignee}`,e.dim),p.description&&r(` ${p.description.slice(0,100)}`,e.dim);}else if(h==="cancel"){let p=s[2]?Se.find(w=>w.id===s[2]):B;if(!p){r("No task selected or id given",e.yellow);return}if(!b)return;r(`Cancelling "${p.title}"...`,e.amber),b(p.id).then(()=>{r(`\u2713 Cancelled "${p.title}"`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="retry"){let p=s[2]?Se.find(w=>w.id===s[2]):B;if(!p){r("No task selected or id given",e.yellow);return}if(!x)return;r(`Retrying "${p.title}"...`,e.amber),x(p.id).then(()=>{r(`\u2713 Retried "${p.title}"`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="assign"){let p=s[2]?Se.find(Nt=>Nt.id===s[2]):void 0,w=p??B,X=p?s[3]:s[2];if(!w){r("No task selected or id given",e.yellow);return}if(!X){r("Usage: /task assign [id] <agent>",e.yellow);return}if(!T)return;r(`Assigning "${w.title}" to ${X}...`,e.amber),T(w.id,X).then(()=>{r(`\u2713 Assigned "${w.title}" to ${X}`,e.green),H();},Nt=>r(`Failed: ${g(Nt)}`,e.red));}else if(h==="approve"){let p=s[2]?Se.find(w=>w.id===s[2]):B;if(!p){r("No task selected or id given",e.yellow);return}if(p.status!=="review"){r(`Cannot approve \u2014 status is ${p.status}`,e.yellow);return}if(!Y)return;r(`Approving "${p.title}"...`,e.amber),Y(p.id).then(()=>{r(`\u2713 Approved "${p.title}"`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="reject"){let p=s[2]?Se.find(X=>X.id===s[2]):B;if(!p){r("No task selected or id given",e.yellow);return}if(p.status!=="review"){r(`Cannot reject \u2014 status is ${p.status}`,e.yellow);return}if(!z)return;let w=s.slice(s[2]&&Se.find(X=>X.id===s[2])?3:2).join(" ").trim()||void 0;r(`Rejecting "${p.title}"${w?" with feedback":""}...`,e.amber),z(p.id,w).then(()=>{r(`\u2713 Rejected "${p.title}" \u2192 todo`,e.green),H();},X=>r(`Failed: ${g(X)}`,e.red));}else if(h==="delete"){let p=s[2]?Se.find(w=>w.id===s[2]):B;if(!p){r("No task selected or id given",e.yellow);return}if(p.status==="in_progress"){r("Cannot delete \u2014 task is running",e.yellow);return}if(!_)return;on("task",p.id,p.title);}else r("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 p=s[2];if(!p){yn();return}if(!D){r("Agent creation not available",e.yellow);return}let w=s[3];r(`Creating agent "${p}"...`,e.amber),D(p,w).then(X=>{r(`\u2713 Created agent "${X.name}" (${X.id}, ${X.adapter})`,e.green),H();},X=>r(`Failed: ${g(X)}`,e.red));}else if(h==="list"){let p=$e.map(w=>` ${w.id} ${w.status.padEnd(8)} ${w.name} (${w.adapter})`);if(p.length===0)r("No agents",e.dim);else for(let w of p)r(w,e.cyan);}else if(h==="disable"){let p=s[2]?$e.find(w=>w.id===s[2]||w.name===s[2]):U;if(!p){r("No agent selected or id given",e.yellow);return}if(!C)return;r(`Disabling ${p.name}...`,e.amber),C(p.id).then(()=>{r(`\u2713 Disabled ${p.name}`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="enable"){let p=s[2]?$e.find(w=>w.id===s[2]||w.name===s[2]):U;if(!p){r("No agent selected or id given",e.yellow);return}if(!$)return;r(`Enabling ${p.name}...`,e.amber),$(p.id).then(()=>{r(`\u2713 Enabled ${p.name}`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="delete"||h==="remove"){let p=s[2]?$e.find(w=>w.id===s[2]||w.name===s[2]):U;if(!p){r("No agent selected or id given",e.yellow);return}if(p.status==="running"){r("Cannot delete \u2014 agent is running",e.yellow);return}if(!F){r("Agent deletion not available",e.yellow);return}on("agent",p.id,p.name);}else if(h==="autonomous"||h==="auto"){let p=s[2]?$e.find(w=>w.id===s[2]||w.name===s[2]):U;if(!p){r("No agent selected or id given",e.yellow);return}if(!Oe){r("Autonomous toggle not available",e.yellow);return}p.autonomous?(r(`Disabling autonomous mode for "${p.name}"...`,e.amber),Oe(p.id,false).then(()=>{r(`${$t} ${p.name} autonomous OFF`,e.cyan),H();},w=>r(`Failed: ${g(w)}`,e.red))):(r(`Enabling autonomous mode for "${p.name}"...`,e.amber),Oe(p.id,true).then(()=>{r(`${$t} ${p.name} autonomous ON`,e.cyan),H();},w=>r(`Failed: ${g(w)}`,e.red)));}else r("Usage: /agent add|list|disable|enable|delete|autonomous",e.yellow);return}case "team":{let h=s[1]?.toLowerCase();if(h==="create"||h==="add")Co();else if(h==="list"){let p=xn.current;if(p.length===0)r("No teams",e.dim);else for(let w of p)r(` ${w.id} ${w.status.padEnd(8)} ${w.name} (${w.members.length} members)`,e.cyan);}else if(h==="join"){if(!fe){r("Join not available",e.yellow);return}let p=s[2],w=s[3]??U?.id;if(!p||!w){r("Usage: /team join <teamId> [agentId]",e.yellow);return}r(`Joining team ${p}...`,e.amber),fe(p,w).then(X=>{r(`\u2713 Agent joined team "${X.name}"`,e.green),H({includeTeams:true});},X=>r(`Failed: ${g(X)}`,e.red));}else if(h==="leave"){if(!Ae){r("Leave not available",e.yellow);return}let p=s[2],w=s[3]??U?.id;if(!p||!w){r("Usage: /team leave <teamId> [agentId]",e.yellow);return}r(`Leaving team ${p}...`,e.amber),Ae(p,w).then(X=>{r(`\u2713 Agent left team "${X.name}"`,e.green),H({includeTeams:true});},X=>r(`Failed: ${g(X)}`,e.red));}else if(h==="disband"){if(!tt){r("Disband not available",e.yellow);return}let p=s[2];if(!p){r("Usage: /team disband <teamId>",e.yellow);return}r(`Disbanding team ${p}...`,e.amber),tt(p).then(()=>{r("\u2713 Team disbanded",e.green),H({includeTeams:true});},w=>r(`Failed: ${g(w)}`,e.red));}else if(h==="set-lead"){if(!He){r("Set-lead not available",e.yellow);return}let p=s[2],w=s[3];if(!p||!w){r("Usage: /team set-lead <teamId> <agentId>",e.yellow);return}r(`Setting lead for team ${p}...`,e.amber),He(p,w).then(X=>{r(`\u2713 New lead for team "${X.name}"`,e.green),H({includeTeams:true});},X=>r(`Failed: ${g(X)}`,e.red));}else r("Usage: /team create|list|join|leave|disband|set-lead",e.yellow);return}case "run":{let h=s[1]??B?.id;if(!h){r("No task selected or id given",e.yellow);return}if(!c$1){r("Run not available",e.yellow);return}let p=Se.find(w=>w.id===h);if(p&&!uo.has(p.status)){r(`Cannot run \u2014 status is ${p.status}`,e.yellow);return}r(`Running ${h}...`,e.amber),c$1(h).then(()=>{r(`\u2713 Dispatched ${h}`,e.green),H();},w=>r(`Failed: ${g(w)}`,e.red));return}case "run-all":{if(!f){r("Run-all not available",e.yellow);return}r("Running all todo tasks...",e.amber),f().then(()=>{r("\u2713 Dispatched all todo tasks",e.green),H();},h=>r(`Failed: ${g(h)}`,e.red));return}case "watch":{if(un){r("Watch mode already active",e.yellow);return}if(!Ge){r("Watch not available",e.yellow);return}r("Starting watch mode...",e.amber),Ge().then(()=>{zn(true),r("\u2713 Watch mode started",e.green);},h=>r(`Failed: ${g(h)}`,e.red));return}case "pause":{if(!un){r("Watch mode not active",e.yellow);return}if(!Xe){r("Pause not available",e.yellow);return}r("Pausing watch mode...",e.amber),Xe().then(()=>{zn(false),r("\u2713 Watch mode paused",e.green);},h=>r(`Failed: ${g(h)}`,e.red));return}case "config":{s[1]?.toLowerCase()==="activity-filter"?Xn(p=>{let w=go(p);return Z?.(w.label),r(`Activity filter: ${w.label}`,e.amber),new Set(w.types)}):vo();return}case "status":{let h=Ze.filter(p=>p.status==="in_progress").length;r(`${eo} ${h} running ${Ze.length} tasks ${$e.length} agents`,e.cyan);return}case "help":{for(let[h,p]of Object.entries(Ut)){let w=p.sub?" "+p.sub.join("|"):p.args?" "+p.args:"";r(` /${h}${w} \u2014 ${p.help}`,e.silver);}return}case "quit":{gt();return}case "disable":{if(!U){r("No agent selected",e.yellow);return}if(!C)return;r(`Disabling ${U.name}...`,e.amber),C(U.id).then(()=>{r(`\u2713 Disabled ${U.name}`,e.green),H();},h=>r(`Failed: ${g(h)}`,e.red));return}case "enable":{if(!U){r("No agent selected",e.yellow);return}if(!$)return;r(`Enabling ${U.name}...`,e.amber),$(U.id).then(()=>{r(`\u2713 Enabled ${U.name}`,e.green),H();},h=>r(`Failed: ${g(h)}`,e.red));return}default:r(`Unknown: ${d}. Type /help for commands`,e.yellow);}},[B,U,Se,$e,Ze,eo,un,b,x,T,f,c$1,m,C,$,D,Y,z,_,fe,Ae,tt,He,Ge,Xe,r,gt,H,wn,yn,Co,vo]);useInput((i,y)=>{if(ve!=="none"){if(y.escape){Ee("none"),nt(""),fn.reset();return}if(y.return){let s=wt.trim();if(!s)return;if(ve==="new_task"){if(!m)return;Ee("none"),nt(""),r(`Creating "${s}"...`,e.amber),m(s).then(d=>{r(`\u2713 Created "${d.title}" (${d.id})`,e.green),H();},d=>r(`Failed to create: ${d instanceof Error?d.message:String(d)}`,e.red));}else if(ve==="command"){let d=s;if(rt.length>0&&rt[hn]){let g=rt[hn],h=g.cmd.replace(/\s+\[.*\]$/,"");if((h.startsWith(s)||s==="/")&&(d=h),g.subs&&!h.includes(" ")){nt(h+" "),pt(0);return}}Ee("none"),nt(""),pt(0),fn.push(d),bs(d);}return}if(y.tab&&ve==="command"){if(rt.length>0){let s=rt[hn];if(s){let d=s.cmd.replace(/\s+\[.*\]$/,"");nt(d+(s.subs?" ":"")),pt(0);}}else {let s=so(wt);s&&nt(d=>d+s);}return}if(y.upArrow&&ve==="command"){if(rt.length>0)pt(s=>Math.max(0,s-1));else {let s=fn.prev();s!==null&&nt(s);}return}if(y.downArrow&&ve==="command"){if(rt.length>0)pt(s=>Math.min(rt.length-1,s+1));else {let s=fn.next();nt(s??"");}return}if(y.backspace||y.delete){nt(s=>s.slice(0,-1)),pt(0);return}i&&!y.ctrl&&!y.meta&&(nt(s=>s+i),pt(0));return}if(i.toLowerCase()==="q"){gt();return}if(y.escape){if(we){qt(false),Qt(0);return}if(v==="logs"&&Kt>=0){Hn(-1),Zt(0);return}return}if(i==="/"&&!we){Ee("command"),nt("/"),pt(0);return}if(v==="logs"&&!we&&i>="0"&&i<="9"){Xr(parseInt(i,10));return}if((i==="f"||i==="F")&&v==="logs"&&!we){Yr(s=>new Set(go(s).types));return}if((i==="z"||i==="Z")&&Pt.length>0){rs();return}if((i==="f"||i==="F")&&(v==="tasks"||v==="agents"||v==="goals")&&!we){Xn(s=>{let d=go(s);return Z?.(d.label),new Set(d.types)});return}if((i==="n"||i==="N")&&v==="tasks"&&!we&&m){wn();return}if((i==="n"||i==="N")&&v==="agents"&&!we&&D){yn();return}if((i==="n"||i==="N")&&v==="goals"&&!we&&qe){let s=co(Ce);ot({title:"New Goal",steps:s,kind:"goal"}),Ee("wizard");return}if((i==="e"||i==="E")&&v==="goals"&&K&&Ye){let s=vr(K,Ce);ot({title:`Edit Goal: ${K.title}`,steps:s,kind:"edit_goal",targetId:K.id}),Ee("wizard");return}if((i==="d"||i==="D")&&v==="goals"&&K&&ze){on("goal",K.id,K.title);return}if((i==="c"||i==="C")&&v==="goals"&&K&&Me){(K.status==="active"||K.status==="paused")&&(r(`Marking goal "${K.title}" as achieved...`,e.amber),Me(K.id,"achieved").then(()=>{r(`\u2713 Goal "${K.title}" achieved`,e.green),H();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="x"||i==="X")&&v==="goals"&&K&&Me){(K.status==="active"||K.status==="paused")&&(r(`Abandoning goal "${K.title}"...`,e.amber),Me(K.id,"abandoned").then(()=>{r(`\u2713 Goal "${K.title}" abandoned`,e.dim),H();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="p"||i==="P")&&v==="goals"&&K&&Me){let s=K.status==="paused"?"active":"paused";(K.status==="active"||K.status==="paused")&&Me(K.id,s).then(()=>{r(`Goal "${K.title}" ${s}`,e.cyan),H();},d=>r(`Failed: ${d instanceof Error?d.message:String(d)}`,e.red));return}if((i==="a"||i==="A")&&v==="tasks"&&B?.status==="review"&&Y){r(`Approving "${B.title}"...`,e.amber),Y(B.id).then(()=>{r(`\u2713 Approved "${B.title}"`,e.green),H();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="x"||i==="X")&&v==="tasks"&&B?.status==="review"&&z){r(`Rejecting "${B.title}"...`,e.amber),z(B.id).then(()=>{r(`\u2713 Rejected "${B.title}" \u2192 todo`,e.green),H();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="c"||i==="C")&&v==="tasks"&&B&&b){if(B.status==="done"||B.status==="failed"||B.status==="cancelled"){r(`Cannot cancel \u2014 status is ${B.status}`,e.yellow);return}r(`Cancelling "${B.title}"...`,e.amber),b(B.id).then(()=>{r(`\u2713 Cancelled "${B.title}"`,e.green),H();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="e"||i==="E")&&v==="tasks"&&B&&S){is(B);return}if((i==="e"||i==="E")&&v==="agents"&&U&&A){as(U);return}if((i==="s"||i==="S")&&v==="tasks"){wo(s=>!s),mn(0),Jt(0);return}if((i==="s"||i==="S")&&v==="agents"&&U&&G){if(!Object.values(Ve.running).some(d=>d.agent_id===U.id)&&U.status!=="running"){r(`Agent "${U.name}" is not running`,e.yellow);return}r(`Force-stopping agent "${U.name}"...`,e.amber),G(U.id).then(()=>{r(`\u2713 Stopped agent "${U.name}"`,e.green),H();},d=>r(`Failed: ${d instanceof Error?d.message:String(d)}`,e.red));return}if((i==="d"||i==="D")&&v==="tasks"&&B&&B.status!=="in_progress"&&_){on("task",B.id,B.title);return}if((i==="d"||i==="D")&&v==="agents"&&U&&F){let s=Object.values(Ve.running).some(d=>d.agent_id===U.id);if(s&&!G){r(`Cannot delete \u2014 agent "${U.name}" is running. Press S to stop first.`,e.yellow);return}on("agent",U.id,U.name,{needsForceStop:s});return}if((i==="u"||i==="U")&&v==="agents"&&U&&Oe){let s=!U.autonomous;r(`${s?"Enabling":"Disabling"} autonomous mode for "${U.name}"...`,e.amber),Oe(U.id,s).then(()=>{r(`${$t} ${U.name} autonomous ${s?"ON":"OFF"}`,e.cyan),H();},d=>r(`Failed: ${d instanceof Error?d.message:String(d)}`,e.red));return}if(!we){if(i==="g"||i==="G"){Lt("goals");return}if(i==="t"||i==="T"){Lt("tasks");return}if(i==="a"||i==="A"){Lt("agents");return}if(i==="l"||i==="L"){Lt("logs");return}}if(!we){let s=An.map(g=>g.id),d=s.indexOf(v);if(y.tab||y.rightArrow){Lt(s[(d+1)%s.length]);return}if(y.leftArrow){Lt(s[(d+s.length-1)%s.length]);return}}if(y.return){let s=en>0?ht.length:-1;if(v==="tasks"&&gn===s){wo(g=>!g),mn(0),Jt(0);return}let d=ht.length+(en>0?1:0);if(v==="tasks"&&gn===d&&m){wn();return}if(v==="goals"&&Un===lt.length&&qe){let g=co(Ce);ot({title:"New Goal",steps:g,kind:"goal"}),Ee("wizard");return}if(v==="agents"&&jn===$e.length&&D){yn();return}if(v==="goals"&&K){qt(g=>!g),Qt(0);return}if(v==="tasks"&&B){qt(g=>!g);return}if(v==="agents"&&U){qt(g=>!g);return}if(v==="logs"&&Kt>=0){qt(g=>!g);return}}if((i==="r"||i==="R")&&v==="tasks"&&B&&c$1){if(!uo.has(B.status)){r(`Cannot run "${B.title}" \u2014 status is ${B.status}`,e.yellow);return}r(`Running "${B.title}"...`,e.green),c$1(B.id).then(()=>{r(`Dispatched "${B.title}"`,e.green),H();},s=>r(`Failed to run: ${s instanceof Error?s.message:String(s)}`,e.red));return}if(y.upArrow||i==="k"){if(v==="goals"&&we){Qt(s=>Math.max(0,s-1));return}v==="goals"?xo(s=>{let d=Math.max(0,s-1);return Kn(g=>d<g?d:g),d}):v==="tasks"?mn(s=>{let d=Math.max(0,s-1);return Jt(g=>d<g?d:g),d}):v==="agents"?ho(s=>{let d=Math.max(0,s-1);return Yn(g=>d<g?d:g),d}):v==="logs"&&Hn(s=>{if(s===-1){let g=Je.length-1;return Zt(Math.max(0,g-he+2)),Math.max(0,g)}let d=Math.max(0,s-1);return Zt(g=>d<g?d:g),d});}if(y.downArrow||i==="j"){if(v==="goals"&&we){Qt(s=>s+1);return}if(v==="goals"){let s=lt.length+(qe?1:0)-1;xo(d=>{let g=Math.min(Math.max(0,s),d+1);return Kn(h=>g>=h+he?g-he+1:h),g});}else if(v==="tasks"){let s=ht.length+(m?1:0)+(en>0?1:0)-1;mn(d=>{let g=Math.min(Math.max(0,s),d+1);return Jt(h=>g>=h+he?g-he+1:h),g});}else if(v==="agents"){let s=$e.length+(D?1:0)-1;ho(d=>{let g=Math.min(Math.max(0,s),d+1);return Yn(h=>g>=h+he?g-he+1:h),g});}else v==="logs"&&Hn(s=>{if(s===-1)return -1;let d=Je.length-1;if(s>=d)return Zt(0),-1;let g=s+1;return Zt(h=>g>=h+he-1?g-he+2:h),g});}});let Pe=ve!=="none",Ao=Kt>=0?Je[Kt]:void 0,Mo=!Pe&&we&&v==="tasks"&&B,_o=!Pe&&we&&v==="agents"&&U,Ro=!Pe&&we&&v==="goals"&&K,Ts=!Pe&&we&&v==="logs"&&Ao,ys=!Pe&&v==="tasks"&&B&&uo.has(B.status)&&!!c$1,ws=!Pe&&!we&&(v==="goals"&&!!qe||v==="tasks"&&!!m||v==="agents"&&!!D),Ss=!Pe&&v==="tasks"&&B?.status==="review"&&!!Y,ks=!Pe&&v==="tasks"&&B?.status==="review"&&!!z,Is=U?Object.values(Ve.running).some(i=>i.agent_id===U.id):false,Cs=!Pe&&(v==="goals"&&K&&!!ze||v==="tasks"&&B&&B.status!=="in_progress"&&!!_||v==="agents"&&U&&!!F),vs=!Pe&&!we&&(v==="goals"&&!!K&&!!Ye||v==="tasks"&&!!B&&!!S||v==="agents"&&!!U&&!!A),$s=!Pe&&v==="agents"&&U&&(Is||U.status==="running")&&!!G,As=!Pe&&v==="agents"&&!!U&&!!Oe,Ms=!Pe&&v==="goals"&&!!K&&(K.status==="active"||K.status==="paused")&&!!Me,_s=!Pe&&Pt.length>0,Bo=ve==="command"&&rt.length>0,Eo=mt?.kind==="task"||mt?.kind==="edit_task";return jsxs(Box,{flexDirection:"column",width:Xt,height:mo,children:[jsx(er,{projectName:t,activeView:v,mode:eo,stats:$o,tokens:gs,uptime:ds,width:Xt,version:ue,latestVersion:be}),jsx(Box,{height:1}),v==="goals"&&jsx(Wi,{goals:lt,selectedIndex:Un,scrollOffset:es,height:he,width:me,showAddRow:!!qe,agentNameMap:kt}),v==="tasks"&&jsx(Gi,{tasks:ht,selectedIndex:gn,scrollOffset:Jr,height:he,width:me,showAddRow:!!m,agentNameMap:kt,hiddenCount:en}),v==="agents"&&jsx(zi,{agents:$e,selectedIndex:jn,scrollOffset:Qr,height:he,width:me,state:Ve,taskTitleMap:bn,showAddRow:!!D,agentTeamMap:Dt,teamLeadSet:ns,activeTeamCount:tn}),v==="logs"&&jsx(Hi,{messages:Je,height:he,agents:$e,logFilter:Hr,logTypeFilter:qr,selectedIndex:Kt,scrollOffset:Kr,agentNameMap:kt,taskTitleMap:bn,width:me}),jsx(Box,{height:1}),ve==="wizard"&&mt?jsx(rr,{title:mt.title,steps:mt.steps,onComplete:ls,onCancel:cs,width:me,height:vt,onPasteImage:Eo?ss:void 0,footerExtra:St.length>0&&Eo?`\u{1F4CE}${St.length}`:void 0}):Bo?jsxs(Fragment,{children:[jsx(On,{label:"COMMANDS",width:me}),jsx(Ni,{suggestions:rt,selectedIndex:hn,height:Math.min(rt.length,vt),width:me})]}):ve==="new_task"?jsxs(Fragment,{children:[jsx(ea,{mode:ve,width:me}),jsx(ta,{mode:ve,value:wt,width:me})]}):Mo?jsxs(Fragment,{children:[jsx(Yi,{task:B,width:me}),jsx(Yo,{task:B,height:vt,width:me,taskLogs:Je.filter(i=>i.taskId===B.id),agentNameMap:kt})]}):Ro?jsxs(Fragment,{children:[jsx(On,{label:`GOAL: ${K.title}`,width:me}),jsx(Fi,{goal:K,height:vt,width:me,agentNameMap:kt,tasks:os,progressReport:Ur,scrollOffset:ts,onClampScroll:Qt})]}):_o?jsxs(Fragment,{children:[jsx(Ki,{agent:U,width:me}),jsx(Zi,{agent:U,height:vt,state:Ve,taskTitleMap:bn,teamName:Dt.get(U.id)})]}):Ts?jsxs(Fragment,{children:[jsx(On,{label:"LOG",width:me}),jsx(qi,{message:Ao,height:vt,width:me,agents:$e,agentNameMap:kt,taskTitleMap:bn})]}):Je.length>0&&v!=="logs"?jsxs(Fragment,{children:[(()=>{let i=` F:${pn.toUpperCase()} \u2502 ${qn.length}/${Je.length}`;return jsx(On,{label:"ACTIVITY",width:me,suffixLen:i.length,suffix:jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" F:"}),jsx(Text,{color:e.amber,children:pn.toUpperCase()}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," ",qn.length,"/",Je.length]})]})})})(),jsx(Xi,{messages:qn,height:Math.max(1,vt-1),width:me,agents:$e,agentNameMap:kt})]}):v==="goals"?jsx(En,{count:lt.length,config:Ei,width:me}):v==="tasks"?jsx(En,{count:Se.length,config:Li,width:me}):v==="agents"?jsx(En,{count:$e.length,config:Oi,width:me}):null,jsx(Box,{flexGrow:1}),Pt.length>0&&jsx(Di,{deletions:Pt,width:Xt}),jsx(nr,{mode:ve==="command"?"command":"navigate",value:ve==="command"?wt:"",completion:ve==="command"?so(wt):null,activeView:v,canRun:!!ys,canNew:!!ws,canApprove:!!Ss,canReject:!!ks,canCancel:v==="tasks"&&!!B&&B.status==="in_progress"&&!!b,canDelete:!!Cs,canUndo:!!_s,canEdit:!!vs,canForceStop:!!$s,canToggleAuto:!!As,autoActive:U?.autonomous,canPause:!!Ms,isPaused:K?.status==="paused",canToggleShowAll:v==="tasks"&&Se.length>Ar,showAllActive:yo,hasDetail:!!(Mo||_o||Ro),itemCount:v==="goals"?lt.length:v==="tasks"?Se.length:v==="agents"?Ce.length:Je.length,itemLabel:v==="goals"?"goals":v==="tasks"?"tasks":v==="agents"?"agents":"events",width:Xt,hasSuggestions:Bo})]})}var Di=Nn.memo(function({deletions:n,width:o}){let[,l]=useState(0);useEffect(()=>{let m=setInterval(()=>l(b=>b+1),1e3);return ()=>clearInterval(m)},[]);let c=Date.now();return jsx(Box,{flexDirection:"column",width:o,children:n.map(m=>{let b=Math.max(0,Math.ceil((m.expiresAt-c)/1e3)),x=Math.max(0,o-4),T=m.entityType==="task"?"Task":m.entityType==="agent"?"Agent":"Goal",f=Math.max(10,x-T.length-30),C=m.entityName.length>f?m.entityName.slice(0,f-1)+"\u2026":m.entityName;return jsx(Box,{paddingX:2,children:jsxs(Text,{color:e.yellow,children:["\u2717 ",jsx(Text,{bold:true,children:T}),` "${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"})]})},m.key)})})});function Ni({suggestions:t,selectedIndex:n,height:o,width:l}){let c=o,m=0;n>=c&&(m=n-c+1);let b=t.slice(m,m+c);return jsx(Box,{flexDirection:"column",paddingX:2,children:b.map((x,T)=>{let f=T+m,C=f===n,$=C?"\u25B6":" ",P=Math.min(20,Math.max(14,...t.map(D=>D.cmd.length+1))),W=x.cmd.padEnd(P),j=x.subs?` ${x.subs}`:"",O=Math.max(4,l-P-j.length-8),N=x.desc.length>O?x.desc.slice(0,O-1)+"\u2026":x.desc;return jsxs(Text,{wrap:"truncate",children:[jsx(Text,{color:C?e.amber:e.ghost,children:` ${$} `}),jsx(Text,{color:C?e.white:e.silver,bold:C,children:W}),jsx(Text,{color:e.dim,children:N}),j&&jsx(Text,{color:e.ghost,children:j})]},f)})})}function Wi({goals:t,selectedIndex:n,scrollOffset:o=0,height:l,width:c,showAddRow:m,agentNameMap:b}){let x=t.length,T=t.slice(o,o+l),f=m&&x>=o&&x<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[T.map((C,$)=>jsx(Box,{paddingX:2,children:jsx(qo,{goal:C,selected:$+o===n,width:c-2,agentNameMap:b})},C.id)),f&&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 Fi({goal:t,height:n,width:o,agentNameMap:l,tasks:c,progressReport:m,scrollOffset:b=0,onClampScroll:x}){let f=Nn.useMemo(()=>{let O=c??[],N=t.assignee?l?.get(t.assignee)??t.assignee:"\u2014",D=m?m.split(`
|
|
9
|
-
`):[],F=t.description?t.description.split(`
|
|
10
|
-
`):[],Y=Po[t.status]??e.dim,z=new Map;for(let S of O)z.set(S.status,(z.get(S.status)??0)+1);let _=[];if(_.push({key:"row-status",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:Y,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:N})]})]})}),_.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&&_.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)})]})]})}),O.length>0){let S=[];for(let[A,G]of z)S.push(`${G} ${A}`);_.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:O.length})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" "}),jsx(Text,{color:e.dim,children:S.join(" \xB7 ")})]})]})});}if(F.length>0){_.push({key:"desc-gap",node:jsx(Text,{children:" "})});for(let S=0;S<F.length;S++)_.push({key:`desc-${S}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",F[S]]})});}else _.push({key:"desc-gap",node:jsx(Text,{children:" "})}),_.push({key:"desc-empty",node:jsx(Text,{color:e.dim,children:" No description."})});if(D.length>0){_.push({key:"prog-gap",node:jsx(Text,{children:" "})}),_.push({key:"prog-div",node:jsx(jt,{label:"progress",width:o})});for(let S=0;S<D.length;S++)_.push({key:`prog-${S}`,node:jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",D[S]]})});}if(O.length>0){_.push({key:"tasks-gap",node:jsx(Text,{children:" "})}),_.push({key:"tasks-div",node:jsx(jt,{label:`tasks (${O.length})`,width:o})});for(let S of O){let A=In[S.status]??e.dim;_.push({key:`task-${S.id}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",jsx(Text,{color:A,children:S.status.padEnd(12)}),S.title.slice(0,Math.max(10,o-22))]})});}}return _},[t,c,m,o,l]),C=Math.max(0,f.length-n),$=Math.min(b,C);Nn.useEffect(()=>{x&&$!==b&&x($);},[$,b,x]);let P=f.length>n&&$<C,W=P?n-1:n,j=f.slice($,$+W);return jsxs(Box,{flexDirection:"column",height:n,paddingX:2,children:[j.map(O=>jsx(Box,{children:O.node},O.key)),P&&jsxs(Text,{color:e.ghost,children:[" ","\u2193"," ",f.length-$-W," more ","\u2014"," ","\u2191","\u2193"," to scroll"]})]})}function Gi({tasks:t,selectedIndex:n,scrollOffset:o=0,height:l,width:c,showAddRow:m,agentNameMap:b,hiddenCount:x=0}){let T=x>0,f=T?t.length:-1,C=t.length+(T?1:0),$=t.slice(o,o+l),P=T&&f>=o&&f<o+l,W=m&&C>=o&&C<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[$.map((j,O)=>jsx(Box,{paddingX:2,children:jsx(vn,{task:j,selected:O+o===n,width:c-2,agentNameMap:b})},j.id)),P&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===f?e.amber:e.ghost,children:[n===f?" \u25B8 ":" ",jsxs(Text,{color:n===f?e.amber:e.dim,children:["\u25BC"," Show all (",x," more) \u2014 press ",jsx(Text,{bold:true,color:e.gray,children:"S"})]})]})},"__show_all__"),W&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===C?e.amber:e.ghost,children:[n===C?" \u25B8 ":" ",jsx(Text,{color:n===C?e.amber:e.dim,children:"+ add task..."})]})},"__add__")]})}function zi({agents:t,selectedIndex:n,scrollOffset:o=0,height:l,width:c,state:m,taskTitleMap:b,showAddRow:x,agentTeamMap:T,teamLeadSet:f,activeTeamCount:C}){let $=new Map;for(let S of Object.values(m.running))$.set(S.agent_id,S);let P=new Map;if(C&&C>0)for(let S of t){let A=T?.get(S.id);A&&P.set(A,(P.get(A)??0)+1);}let W=t.length,j=t.slice(o,o+l),O=x&&W>=o&&W<o+l,N=C!=null&&C>0,D=new Map;if(N&&f&&T){for(let S of t)if(f.has(S.id)){let A=T.get(S.id);A&&D.set(A,S.name);}}let F=0;for(let S of P.values())F+=S;let Y=t.length-F,z=[],_=o>0?T?.get(t[o-1]?.id??""):void 0;for(let S=0;S<j.length&&z.length<l;S++){let A=j[S],G=T?.get(A.id);if(N&&G&&G!==_&&(z.push(jsx(jo,{teamName:G,memberCount:P.get(G)??0,leadName:D.get(G),width:c},`ts-${G}`)),z.length>=l)||N&&!G&&_&&(z.push(jsx(Uo,{memberCount:Y,width:c},"ts-unassigned")),z.length>=l))break;_=G,z.push(jsx(Box,{paddingX:2,children:jsx(Vo,{agent:A,selected:S+o===n,width:c-2,runningEntry:$.get(A.id),currentTaskTitle:A.current_task?b.get(A.current_task):void 0,teamName:G,isLead:f?.has(A.id)})},A.id));}return O&&z.length<l&&z.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===W?e.amber:e.ghost,children:[n===W?" \u25B8 ":" ",jsx(Text,{color:n===W?e.amber:e.dim,children:"+ add agent..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:l,children:z})}function Pr(t=5e3){let[n,o]=useState(Date.now());return useEffect(()=>{let l=setInterval(()=>o(Date.now()),t);return ()=>clearInterval(l)},[t]),n}function Dr(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`}var Vi=" \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function ji(t,n,o,l){let c=new Array(n).fill(0),m=l-n*o;for(let x of t){if(x.ts<m)continue;let T=Math.min(n-1,Math.floor((x.ts-m)/o));c[T]++;}let b=Math.max(1,...c);return c.map(x=>Vi[Math.round(x/b*8)]).join("")}function Ui(t){if(t==="error")return e.errorBg}function Nr(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 Hi({messages:t,height:n,agents:o,logFilter:l,logTypeFilter:c,selectedIndex:m,scrollOffset:b,agentNameMap:x,taskTitleMap:T,width:f}){let C=Pr(),$=useMemo(()=>t.filter(S=>{if(l!==0){let G=o[l-1];if(G&&S.agentId!==G.id)return false}let A=S.msgType??"info";return c.has(A)}),[t,o,l,c]);useMemo(()=>{let S={};for(let A of t){let G=A.msgType??"info";S[G]=(S[G]??0)+1;}return S},[t]);let W=useMemo(()=>{let S=new Map;for(let A of t)A.agentId&&S.set(A.agentId,(S.get(A.agentId)??0)+1);return S},[t]),j=useMemo(()=>ji($,30,1e4,C),[$,C]),O=c.size>=8?"all":c.size===1&&c.has("output")?"text":c.size===1&&c.has("error")?"errors":c.has("tool")&&!c.has("output")?"tools":c.has("lifecycle")&&!c.has("output")?"events":`${c.size} types`,N=n-3,D=m===-1?$.slice(-N):$.slice(b,b+N),F=m===-1?-1:m-b,Y=Math.min(10,Math.max(6,...o.map(S=>S.name.length))),z=11+Y,_=S=>{if(S===0)return true;let A=D[S],G=D[S-1];return A.agentId!==G.agentId?true:A.agentId?A.ts-G.ts>3e4:false};return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsxs(Box,{gap:0,children:[l===0?jsx(Text,{backgroundColor:e.infoBg,color:e.silver,bold:true,children:" \u25CF ALL "}):jsx(Text,{color:e.ghost,children:" \u25CB all "}),jsx(Text,{color:e.ghost,children:" "}),o.slice(0,9).map((S,A)=>{let G=Fn(S.id,o),L=l===A+1,ye=W.get(S.id)??0,fe=ye>0?`\xB7${ye}`:"";return L?jsxs(Text,{backgroundColor:e.successBg,color:G,bold:true,children:[" ",A+1,":",S.name,fe," "]},S.id):jsxs(Text,{color:ye>0?e.dim:e.ghost,children:[" ",A+1,":",S.name,fe]},S.id)})]}),jsxs(Box,{gap:0,children:[O==="all"?jsx(Text,{color:e.dim,children:" F:all"}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,bold:true,children:[" F:",O.toUpperCase()," "]}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," "]}),jsxs(Text,{color:e.dim,children:[$.length," events"]}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," "]}),m===-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(Gt,{color:e.green})}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" LIVE "})]}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,children:[" \u2191\u2193 ",m+1,"/",$.length," "]}),jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amberDim,children:j}),jsx(Text,{color:e.ghost,children:" 5m"})]}),D.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"})]})]}):D.map((S,A)=>{let G=A===F,L=S.msgType??"info",ye=Gn[L]??"\u2502",fe=S.agentId?x.get(S.agentId)??S.agentId.slice(0,8):void 0,Ae=S.agentId?Fn(S.agentId,o):void 0,tt=_(A),Ge=(A>0?D[A-1]:void 0)?.agentId===S.agentId&&!!S.agentId,Xe=!Ge&&!!fe,Oe=Ge&&!!fe,Et=Nr(L,S.color),qe=G?e.infoBg:L==="error"?e.errorBg:void 0,Ye=S.taskId?T.get(S.taskId):void 0,Me=Dr(S.ts,C),ze=Ye&&f>80?`#${Ye.slice(0,20)}`:"",E=ze?ze.length+3:0,R=Math.max(10,f-2-z-E),I=S.text.length>R?S.text.slice(0,R-1)+"\u2026":S.text;return jsxs(Box,{backgroundColor:qe,children:[jsx(Text,{color:Ae??e.ghost,children:tt&&Xe?"\u250C":Oe?"\u2502":" "}),jsx(Text,{color:G?e.amber:void 0,children:G?"\u25B8":" "}),jsx(Box,{width:5,children:jsx(Text,{color:Me==="now"?e.green:G?e.silver:e.ghost,children:Me.padStart(4)})}),jsx(Box,{width:Y+1,children:Xe?jsxs(Text,{color:Ae,bold:true,children:[" ",fe.slice(0,Y).padEnd(Y)]}):Oe?jsxs(Text,{color:Ae??e.ghost,children:[" ","\xB7".padEnd(Y)]}):jsxs(Text,{color:e.ghost,children:[" "," ".padEnd(Y)]})}),jsxs(Text,{color:L==="error"?e.red:Ae??e.dim,children:[" ",ye," "]}),jsx(Text,{color:G?e.white:Et,bold:G||L==="lifecycle",children:I}),ze&&jsxs(Text,{color:e.ghost,children:[" ",jsx(Text,{color:e.dim,backgroundColor:e.void,children:` ${ze} `})]})]},A)})]})}function Xi({messages:t,height:n,width:o,agents:l,agentNameMap:c}){let m=Pr(),b=t.slice(-n),x=Math.max(10,o-2-17),T=Math.max(0,n-b.length),f=0,C=[];for(let $=0;$<b.length;$++)$>0&&b[$].agentId!==b[$-1].agentId&&f++,C.push(f);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[T>0&&jsx(Box,{height:T}),b.map(($,P)=>{let W=$.agentId?c.get($.agentId)??$.agentId.slice(0,8):void 0,j=$.agentId?Fn($.agentId,l):void 0,O=$.msgType??"info",N=Gn[O]??"\u2502",D=Nr(O,$.color),Y=(P>0?b[P-1]:void 0)?.agentId===$.agentId&&!!$.agentId,z=(C[P]&1)===1,_=Ui(O)??(z?"#1a1a1a":void 0),S=Dr($.ts,m),A=$.text.length>x?$.text.slice(0,x-1)+"\u2026":$.text;return jsxs(Box,{backgroundColor:_,children:[jsx(Text,{color:j??e.ghost,children:!Y&&W?"\u258D":Y?"\u258F":" "}),jsx(Box,{width:5,children:jsx(Text,{color:Y?e.ghost:S==="now"?e.green:e.dim,children:Y?" ":S.padStart(4)})}),jsx(Box,{width:9,children:W&&!Y?jsxs(Text,{color:j,bold:true,children:[" ",W.slice(0,8)]}):jsx(Text,{color:e.ghost,children:Pi})}),jsxs(Text,{color:O==="error"?e.red:Y?e.ghost:j??e.dim,children:[N," "]}),jsx(Text,{color:D,children:A})]},P)})]})}function qi({message:t,height:n,width:o,agents:l,agentNameMap:c,taskTitleMap:m}){let b=t.detail??t.text,x=t.msgType??"info",T=t.agentId?c.get(t.agentId)??t.agentId.slice(0,8):void 0,f=t.agentId?Fn(t.agentId,l):e.dim,C=t.taskId?m.get(t.taskId):void 0,$,P=false;try{let N=JSON.parse(b);$=JSON.stringify(N,null,2),P=!0;}catch{$=b;}let W=Math.max(4,o-6),j=Math.max(1,n-4),O=$.split(`
|
|
11
|
-
`).slice(0,j);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u256D","\u2500".repeat(W+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 "}),T&&jsx(Text,{color:f,bold:true,children:T}),T&&jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:Gn[x]?x==="error"?e.red:e.dim:e.dim,children:[Gn[x]??"\u2502"," ",x]}),C&&jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:e.dim,children:["#",C.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,W)})]}),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u251C","\u2500".repeat(W+2),"\u2524"]})}),O.map((N,D)=>jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),P&&jsxs(Text,{color:e.ghost,children:[String(D+1).padStart(3)," "]}),jsx(Text,{wrap:"truncate",color:P&&N.includes('"')?e.cyan:P&&/^\s*[}\]]/.test(N)?e.ghost:N.startsWith("error")||N.startsWith("Error")?e.red:e.silver,children:N.slice(0,P?W-4:W)})]},D)),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u2570","\u2500".repeat(W+2),"\u256F"]})})]})}function On({label:t,width:n,suffix:o,suffixLen:l=0}){let c=` ${t} `,m=3,b=m+c.length+2;if(!o){let f=Math.max(0,n-b);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Te.repeat(m)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:c}),jsx(Text,{color:e.ghost,children:Te.repeat(f)})]})}let x=2,T=Math.max(0,n-b-x-l);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Te.repeat(m)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:c}),jsx(Text,{color:e.ghost,children:Te.repeat(x)}),o,jsx(Text,{color:e.ghost,children:Te.repeat(T)})]})}function Yi({task:t,width:n}){let o=" DETAIL ",l=n-o.length-10,c=t.title.length>l?t.title.slice(0,l-3)+"...":t.title,m=Math.max(0,n-3-o.length-c.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Te.repeat(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:o}),jsxs(Text,{color:e.ghost,children:[Te," "]}),jsx(Text,{color:e.white,bold:true,children:c}),jsxs(Text,{color:e.ghost,children:[" ",Te.repeat(Math.max(0,m))]})]})}function Ki({agent:t,width:n}){let o=" AGENT ",l=n-o.length-10,c=t.name.length>l?t.name.slice(0,l-3)+"...":t.name,m=Math.max(0,n-3-o.length-c.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Te.repeat(3)}),jsx(Text,{backgroundColor:"#0f2d1f",color:e.green,bold:true,children:o}),jsxs(Text,{color:e.ghost,children:[Te," "]}),jsx(Text,{color:e.green,bold:true,children:c}),jsxs(Text,{color:e.ghost,children:[" ",Te.repeat(Math.max(0,m))]})]})}function Zi({agent:t,height:n,state:o,taskTitleMap:l,teamName:c}){let m=Ji[t.status]??e.dim;Object.values(o.running).find(f=>f.agent_id===t.id);let x=t.current_task?l.get(t.current_task):void 0,T=24;return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:T,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:m,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:T,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:x?e.white:e.dim,children:x??"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:T,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:c?e.amber:e.dim,children:c??"\u2014"})]})]}),t.autonomous&&jsx(Box,{children:jsxs(Box,{width:T,children:[jsx(Text,{color:e.dim,children:" auto "}),jsxs(Text,{color:e.cyan,children:[$t," 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:t.config.skills.join(", ")})]}),jsx(Text,{children:" "}),t.role?t.role.split(`
|
|
12
|
-
`).slice(0,Math.max(1,n-4)).map((f,C)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",f]},C)):jsx(Text,{color:e.dim,children:" No role description."})]})}var Ji={idle:e.dim,running:e.green,error:e.red,disabled:e.ghost},Qi="\u2588";function ea({mode:t,width:n}){let l=` ${t==="command"?"COMMAND":"NEW TASK"} `,c=Math.max(0,n-3-l.length-2);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Te.repeat(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:l}),jsx(Text,{color:e.ghost,children:Te.repeat(c)})]})}function ta({mode:t,value:n,width:o}){let l=t==="command"?"/":"\u25B8",c=Math.max(10,o-8),m=n.length>c?n.slice(-c):n;return jsxs(Box,{paddingX:2,children:[jsxs(Text,{color:e.amber,children:[l," "]}),jsx(Text,{color:e.white,children:m}),jsx(Text,{color:e.amber,children:Qi})]})}function Wr(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 l=JSON.stringify(o);return l.length>80?l.slice(0,77)+"...":l}function Pn(t,n=200){if(typeof t=="string")return t.slice(0,n);if(!Array.isArray(t))return null;let o=[],l=0;for(let c of t){if(l>=n)break;if(c?.type==="text"&&typeof c.text=="string"){let m=c.text.split(`
|
|
13
|
-
`).find(b=>b.trim().length>0)??"";o.push(m.slice(0,n-l)),l+=m.length;}else if(c?.type==="tool_use"){let m=Wr(c.name??"tool",c.input),b=`\u2699 ${c.name??"tool"}(${m})`;o.push(b),l+=b.length;}else if(c?.type==="tool_result")o.push("\u2190 (result)"),l+=10;else if(c?.type==="thinking"&&typeof c.thinking=="string"){let m=c.thinking.slice(0,60).split(`
|
|
14
|
-
`)[0]??"";o.push(`\u{1F4AD} ${m}`),l+=m.length+3;}}return o.length>0?o.join(" "):null}function Br(t){if(typeof t=="string"){let o=t.split(`
|
|
15
|
-
`).length,l=t.split(`
|
|
16
|
-
`).find(c=>c.trim().length>0)??"";return o>3?`${l.slice(0,80)}... (${o} lines)`:l.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 c=o.is_error,m=typeof o.content=="string"?o.content:"",b=m.split(`
|
|
17
|
-
`).length;c?n.push(`\u2715 error: ${m.slice(0,60)}`):b>3?n.push(`\u2713 ${b} lines`):n.push(`\u2713 ${m.slice(0,80)}`);}else o?.type==="text"&&typeof o.text=="string"&&n.push(o.text.split(`
|
|
18
|
-
`)[0]?.slice(0,80)??"");return n.join(" ")||"(result)"}function Fr(t){let n=t.length>Wn?t.slice(0,Wn)+"\u2026":t;if(Lr.test(t.trim()))return {summary:t.trim(),detail:n};try{let o=JSON.parse(t);if(o.type==="message"&&o.role==="assistant"){let l=Pn(o.content);return l?{summary:l.slice(0,200),detail:n}:{summary:"\u{1F4AC} (assistant message)",detail:n}}if(o.type==="assistant"||o.role==="assistant"){let l=o.message?.content??o.content,c=Pn(l);return c?{summary:c.slice(0,200),detail:n}:{summary:"\u{1F4AC} (assistant)",detail:n}}if(o.type==="user"||o.role==="user"){let l=o.message?.content??o.content;return {summary:`\u2190 ${Br(l).slice(0,180)}`,detail:n}}if(o.type==="tool_use"){let l=o.name??"tool",c=Wr(l,o.input);return {summary:`\u2699 ${l}(${c})`,detail:n}}if(o.type==="tool_result")return {summary:`\u2190 ${Br(o.content).slice(0,180)}`,detail:n};if(o.type==="result"){let l=typeof o.result=="string"?o.result:null;return {summary:l?`\u2713 ${l.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 l=o.message.content??o.message,c=Pn(l);if(c)return {summary:c.slice(0,200),detail:n}}return {summary:`[${o.subtype}]`,detail:n}}if(o.content){let l=Pn(o.content);if(l)return {summary:l.slice(0,200),detail:n}}return o.type?{summary:`[${o.type}]`,detail:n}:{summary:t.slice(0,150),detail:n}}catch{return {summary:na(t),detail:n}}}function na(t){let n=t.match(/"subtype"\s*:\s*"([^"]+)"/);if(n)return `[${n[1]}]`;let o=t.match(/"type"\s*:\s*"([^"]+)"/),l=t.match(/"role"\s*:\s*"([^"]+)"/),c=o?.[1],m=l?.[1];if(!c&&!m)return t.slice(0,200);if(c==="assistant"||c==="message"||m==="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(c==="user"||c==="tool_result"||m==="user")return "\u2190 (tool result)";if(c==="tool_use")return `\u2699 ${t.match(/"name"\s*:\s*"([^"]+)"/)?.[1]??"tool"}()`;if(c==="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 c==="rate_limit_event"?"\u23F3 Rate limited":`[${c??m}]`}function oa(t,n,o,l){let c=m=>l?.get(m);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:m,detail:b}=Fr(t.data),x=Or(m);n(m,x.color,{agentId:t.agentId,taskId:c(t.runId),detail:b,msgType:x.msgType});break}case "agent:file_changed":n(`${t.path}`,e.purple,{agentId:t.agentId,taskId:c(t.runId),msgType:"file"});break;case "agent:completed":n(t.success?"Completed successfully":"Failed",t.success?e.green:e.red,{agentId:t.agentId,taskId:c(t.runId),msgType:"lifecycle"});break;case "agent:error":n(`${t.error.slice(0,150)}`,e.red,{agentId:t.agentId,taskId:c(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:c(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:c(t.runId),msgType:"error"});break}}export{Fl as App,Wl as _resetPendingDeletionSeq};
|