@oxgeneral/orch 0.3.0 → 0.3.2
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-YJM5QGP7.js +19 -0
- package/dist/agent-S4DKSX63.js +9 -0
- package/dist/agent-shop-D2RS4BZK.js +2 -0
- package/dist/chunk-BCPUTULS.js +308 -0
- package/dist/cli.js +1 -1
- package/dist/shop-picker-LE3SKFOX.js +5 -0
- package/dist/tui-LW7WIDE3.js +2 -0
- package/package.json +10 -2
- package/readme.md +6 -5
- package/scripts/benchmark.ts +1 -1
- package/scripts/release.sh +2 -2
- package/dist/App-TW35IULR.js +0 -18
- package/dist/agent-FRQKL7YI.js +0 -9
- package/dist/tui-G4XUFAIP.js +0 -2
|
@@ -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 {b,a as a$2}from'./chunk-BCPUTULS.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",at="\xB7",Gt="\u25C8",oo="\u2605",At="\u27F3",Mt="\u25C6",Cn={in_progress:e.green,retrying:e.yellow,review:e.blue,todo:e.dim,done:e.green,failed:e.red,cancelled:e.dim},zo={active:e.green,paused:e.dim,achieved:e.amber,abandoned:e.ghost};var Fs=120,ro=0,ln=null,$n=new Set;function Gs(){ln||(ln=setInterval(()=>{ro++;for(let t of $n)t(ro);},Fs));}function zs(){ln&&$n.size===0&&(clearInterval(ln),ln=null);}function zt(){let[t,n]=useState(ro);return useEffect(()=>{let o=l=>n(l);return $n.add(o),Gs(),()=>{$n.delete(o),zs();}},[]),t}var Vo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Vt({color:t}){let n=zt();return jsx(Text,{color:t,children:Vo[n%Vo.length]})}var cn={in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6};var Hs="\u25CB",Uo="\u2713",Ho="\u2715",Xs="\u21BB",qs="\u2500",Ks="\u25B6",Tt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22"},Ys={in_progress:{icon:Ks,label:"RUN",fg:e.green,bg:Tt.green,bold:true,spinner:true},retrying:{icon:Xs,label:"RETRY",fg:e.yellow,bg:Tt.yellow,spinner:true},review:{icon:Gt,label:"REVIEW",fg:e.blue,bg:Tt.blue},todo:{icon:Hs,label:"TODO",fg:e.dim,bg:Tt.neutral},done:{icon:Uo,label:"DONE",fg:e.green,bg:Tt.green},failed:{icon:Ho,label:"FAIL",fg:e.red,bg:Tt.red,bold:true},cancelled:{icon:qs,label:"OFF",fg:e.dim,bg:Tt.neutral}},Zs={1:{color:e.red,label:"!!!"},2:{color:e.yellow,label:"!!"},3:{color:e.dim,label:"!"},4:{color:e.ghost,label:at}};var vn=Fn.memo(function({task:n,selected:o,width:l,agentNameMap:d}){let p=Ys[n.status],y=n.status==="in_progress"||n.status==="retrying",b=Zs[n.priority]??{color:e.ghost,label:at},w,x;if(n.status==="done")w=Uo,x=e.green;else if(n.status==="failed")w=Ho,x=e.red;else if(y){let G=Date.now()-new Date(n.updated_at).getTime();w=f(G),x=e.cyan;}else w="\u2014",x=void 0;let I=o?"\u25B8":" ",v=10,P=4,F=14,H=7,O=2+v+P+F+H,D=l?Math.max(10,l-O):40,N=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:p.bg,color:p.fg,bold:p.bold,children:p.spinner?jsxs(Fragment,{children:[" ",jsx(Vt,{color:p.fg})," ",p.label," "]}):jsxs(Fragment,{children:[" ",p.icon," ",p.label," "]})})}),jsx(Box,{width:P,children:jsx(Text,{color:b.color,bold:n.priority<=2,children:b.label})}),jsxs(Box,{width:D,children:[jsx(Text,{wrap:"truncate",bold:o||y,color:o?e.white:y?e.silver:void 0,children:n.title.length>D?n.title.slice(0,D-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:N?jsxs(Text,{backgroundColor:Tt.green,color:e.green,wrap:"truncate",children:[" ",N.length>F-2?N.slice(0,F-3)+"\u2026":N," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:H,justifyContent:"flex-end",children:jsx(Text,{color:x,dimColor:!x,children:w})})]})});var ei="\u2715",Xo="\u25CB",ti="\u25B6",ni="\u2713",wt={green:"#0f2d1f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},oi={running:{icon:ti,label:"ACTIVE",fg:e.green,bg:wt.green,bold:true,spinner:true},idle:{icon:Xo,label:"IDLE",fg:e.dim,bg:wt.neutral},error:{icon:ei,label:"ERROR",fg:e.red,bg:wt.red,bold:true},disabled:{icon:Xo,label:"OFF",fg:e.ghost,bg:wt.neutral}},so={running:0,idle:1,error:2,disabled:3},Ko=Fn.memo(function({agent:n,selected:o,width:l,runningEntry:d,currentTaskTitle:p,teamName:y,isLead:b}){let w=oi[n.status],x=n.status==="running",I,v;if(x&&d){let B=Date.now()-new Date(d.started_at).getTime();I=f(B),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=y?Math.min(y.length+2,14):0,D=Math.max(6,22-O),N=7,G=2+F+H+O+D+N,K=l?Math.max(8,l-G):20,V,W,_=false;x&&p?(V=p,W=e.white,_=true):n.role?(V=n.role,W=e.dim):(V="\u2014",W=e.ghost);let C=n.stats.total_runs>0,A=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:w.bg,color:w.fg,bold:w.bold,children:w.spinner?jsxs(Fragment,{children:[" ",jsx(Vt,{color:w.fg})," ",w.label," "]}):jsxs(Fragment,{children:[" ",w.icon," ",w.label," "]})})}),jsx(Box,{width:K,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:[At," "]}),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," "]})}),y&&jsx(Box,{width:O,children:jsxs(Text,{backgroundColor:wt.amber,color:e.amber,wrap:"truncate",children:[" ",y," "]})}),jsx(Box,{width:D,children:jsx(Text,{color:W,bold:_,wrap:"truncate",children:V})}),jsx(Box,{width:N,justifyContent:"flex-end",children:C&&!x?jsxs(Text,{color:A>=80?e.green:A>=50?e.yellow:e.red,children:[I," ",ni]}):jsx(Text,{color:v,dimColor:!v,children:I})})]})});function Yo({teamName:t,memberCount:n,leadName:o,width:l}){let d=`${n} agent${n!==1?"s":""}`,p=o?` ${at} ${oo} ${o}`:"",y=` ${Gt} ${t.toUpperCase()} ${at} ${d}${p} `,b=3,w=Math.max(0,l-b-y.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:y}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(w)})]})}var ri="\u25C7";function Zo({memberCount:t,width:n}){let o=`${t} agent${t!==1?"s":""}`,l=` ${ri} UNASSIGNED ${at} ${o} `,d=3,p=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(p)})]})}var Jo="\u2713",Qo="\u2715",ii="\u2016",ai="\u25C9",un={green:"#0f2d1f",amber:"#2d1f0a",neutral:"#1a1a22"},li={active:{icon:ai,label:"ACTIVE",fg:e.green,bg:un.green,bold:true},paused:{icon:ii,label:"PAUSED",fg:e.dim,bg:un.neutral},achieved:{icon:Jo,label:"DONE",fg:e.amber,bg:un.amber,bold:true},abandoned:{icon:Qo,label:"DROP",fg:e.ghost,bg:un.neutral}},er=Fn.memo(function({goal:n,selected:o,width:l,agentNameMap:d}){let p=li[n.status],y=o?"\u25B8":" ",b=11,w=14,x=7,I=2+b+w+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=Jo,H=e.amber;else if(n.status==="abandoned")F=Qo,H=e.ghost;else {let O=Date.now()-new Date(n.created_at).getTime(),D=Math.floor(O/864e5);F=D>0?`${D}d`:"<1d",H=e.dim;}return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[y," "]}),jsx(Box,{width:b,children:jsxs(Text,{backgroundColor:p.bg,color:p.fg,bold:p.bold,children:[" ",p.icon," ",p.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:w,children:P?jsxs(Text,{backgroundColor:un.green,color:e.green,wrap:"truncate",children:[" ",P.length>w-2?P.slice(0,w-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 ci={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} `,p=3,y=Math.max(0,l-p-d.length);return jsxs(Text,{color:o??e.ghost,children:[" ","\u2500".repeat(p),d,"\u2500".repeat(y)]})}function tr({task:t,height:n,width:o,taskLogs:l,agentNameMap:d}){let p=Cn[t.status]??e.dim,y=t.priority<=2?t.priority===1?e.red:e.yellow:void 0,b=24,w=!!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=w?t.description.split(`
|
|
3
|
+
`):[],H=x?t.proof.agent_summary.split(`
|
|
4
|
+
`):[],O=3;P&&(O+=2+t.attachments.length),w?(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 D=Math.max(0,n-O),N=0,G=0;x&&v?(N=Math.max(1,Math.floor(D*.4)),G=Math.max(1,D-N)):x?N=D:v&&(G=D);let K=w?F.slice(0,Math.max(1,Math.ceil((n-10)*.3))):[],V=H.slice(0,N);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:p,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:y,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,_)=>jsxs(Text,{color:e.cyan,wrap:"truncate",children:[" ",W]},`a${_}`))]}),w&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),K.map((W,_)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",W]},`d${_}`))]}),!w&&!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,_)=>jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",W]},`r${_}`))]}),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,_)=>{let C=W.msgType??"info",A=ci[C]??"\u2502",B=W.color;C==="tool"?B=e.cyan:C==="file"?B=e.purple:C==="error"?B=e.red:C==="lifecycle"?B=e.green:C==="system"&&(B=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:[A," "]}),jsx(Text,{color:B,bold:C==="lifecycle",children:ie})]},_)})]})]})}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 di="\u25CF",rr="\u25CB",ui="\u2713",gi="\u2715",mi="\u2191",pi="\u2193",fi="\u03A3",hi="\u25B6",xi="\u21BB",nr=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],io=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],qe={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"};function sr({color:t}){let n=zt();return jsx(Text,{color:t,children:nr[n%nr.length]})}function bi(){let t=zt(),n=Math.floor(t/10)%2===0;return jsx(Text,{color:n?e.amber:e.amberDim,bold:true,children:Mt})}function Ti({width:t,active:n}){let o=Math.max(4,Math.floor(t*.08)),l=2,d=zt(),p=Math.ceil((t+o)/l),y=n?d%(p*2):0;if(!n)return jsx(Box,{paddingX:1,children:jsx(Text,{color:e.ghost,children:ye.repeat(t)})});let b=y<p?y*l:(p*2-y)*l,w=Math.max(0,b-o),x=Math.min(t,b),I=w,v=Math.max(0,x-w),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 yi({data:t,width:n,color:o}){if(t.length===0)return null;let l=t.slice(-n),d=Math.max(...l,1),p=l.map(y=>{let b=Math.round(y/d*(io.length-1));return io[b]??io[0]}).join("");return jsx(Text,{color:o,children:p})}function wi({projectName:t,activeView:n,mode:o,stats:l,uptime:d,width:p,version:y,latestVersion:b}){let w=o==="watching";return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:p,children:[jsxs(Box,{gap:0,children:[jsx(bi,{}),jsx(Text,{color:e.amber,bold:true,children:" ORCH"}),y&&jsxs(Text,{color:e.ghost,children:[" ",y]}),b&&b!==y&&jsxs(Text,{backgroundColor:qe.green,color:e.green,bold:true,children:[" UPDATE ",b," "]}),jsxs(Text,{color:e.ghost,children:[" ",at," "]}),jsx(Text,{color:e.silver,children:t})]}),jsx(Box,{gap:0,children:An.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:[w?jsxs(Text,{backgroundColor:qe.green,color:e.green,bold:true,children:[" ",di," WATCHING"," "]}):jsxs(Text,{backgroundColor:qe.neutral,color:e.dim,children:[" ",rr," IDLE"," "]}),l.running>0&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{backgroundColor:qe.green,color:e.green,children:[" ",jsx(sr,{color:e.green})," ",l.running," active"," "]})]}),d&&jsxs(Text,{color:e.ghost,children:[" ",d]})]})]})}function Si({stats:t,tokens:n,width:o,sparklineData:l}){let p=[{icon:hi,label:"RUN",count:t.running,fg:e.green,bg:qe.green,bold:true,spinner:true,show:t.running>0},{icon:xi,label:"RETRY",count:t.retrying,fg:e.yellow,bg:qe.yellow,show:t.retrying>0},{icon:Gt,label:"REVIEW",count:t.review,fg:e.blue,bg:qe.blue,show:t.review>0},{icon:rr,label:"TODO",count:t.todo,fg:e.dim,bg:qe.neutral,show:t.todo>0},{icon:ui,label:"DONE",count:t.done,fg:e.green,bg:qe.green,show:t.done>0},{icon:gi,label:"FAIL",count:t.failed,fg:e.red,bg:qe.red,bold:true,show:t.failed>0},{icon:Mt,label:"TEAMS",count:t.teams,fg:e.amber,bg:qe.amber,show:t.teams>0}].filter(x=>x.show),y=n.total>0,b=x=>x>=1e3?`${(x/1e3).toFixed(1)}k`:String(x),w=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:[p.map(x=>jsx(Text,{backgroundColor:x.bg,color:x.fg,bold:x.bold,children:x.spinner?jsxs(Fragment,{children:[" ",jsx(sr,{color:x.fg})," ",x.count," ",x.label," "]}):jsxs(Fragment,{children:[" ",x.icon," ",x.count," ",x.label," "]})},x.label)),p.length===0&&jsxs(Text,{backgroundColor:qe.neutral,color:e.dim,children:[" ","NO TASKS"," "]})]}),jsxs(Box,{gap:0,children:[w>0&&l&&jsxs(Fragment,{children:[jsx(yi,{data:l,width:w,color:e.amberDim}),jsx(Text,{children:" "})]}),y&&jsxs(Text,{backgroundColor:qe.amber,color:e.cyan,children:[" ",mi,b(n.input)," ",pi,b(n.output)," ",at," ",fi,b(n.total)," "]})]})]})}var ir=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(wi,{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(Si,{stats:n.stats,tokens:n.tokens,width:n.width,sparklineData:n.sparklineData}),jsx(Ti,{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","shop"],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 w=Object.keys(Xt).find(x=>x.startsWith(b)&&x!==b);return w?w.slice(b.length):null}let l=n.slice(0,o),d=Xt[l];if(!d?.sub)return null;let p=n.slice(o+1);if(!p)return null;let y=d.sub.find(b=>b.startsWith(p)&&b!==p);return y?y.slice(p.length):null}function ar(t){if(!t.startsWith("/"))return [];let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let b=n.toLowerCase(),w=[];for(let[x,I]of Object.entries(Xt))if(!b||x.startsWith(b)){let v=I.args?` ${I.args}`:"";if(w.push({cmd:`/${x}${v}`,desc:I.help,subs:I.sub?.join(" \xB7 ")}),b&&x===b&&I.sub)for(let P of I.sub)w.push({cmd:`/${x} ${P}`,desc:`${I.help}: ${P}`});}return w}let l=n.slice(0,o),d=Xt[l];if(!d?.sub)return [];let p=n.slice(o+1).toLowerCase(),y=[];for(let b of d.sub)(!p||b.startsWith(p))&&y.push({cmd:`/${l} ${b}`,desc:`${d.help}: ${b}`});return y}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 Ii="\u2588",lr=Fn.memo(function({mode:n,value:o,completion:l,activeView:d,canRun:p,canNew:y,canApprove:b,canReject:w,canCancel:x,canDelete:I,canUndo:v,canEdit:P,canForceStop:F,canToggleAuto:H,autoActive:O,canPause:D,isPaused:N,canToggleShowAll:G,showAllActive:K,hasDetail:V,itemCount:W,itemLabel:_,width:C,hasSuggestions:A}){if(n==="command"){let B=A?" \u2191\u2193 select Tab fill Esc \u2715":" Enter exec \u2191\u2193 history Tab complete Esc \u2715",ge=Math.max(4,C-6-B.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:Ii}),jsx(Text,{color:e.dim,children:B})]})})}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",y&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"N"})," new"]}),p&&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"]}),w&&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"]}),D&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"P"}),N?" 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"}),K?" 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," ",_]})]})});var Bn="\u2588";function dr({title:t,steps:n,onComplete:o,onCancel:l,width:d,height:p,onPasteImage:y,footerExtra:b}){let [w,x]=useState(0),[I,v]=useState({}),[P,F]=useState(()=>{let L=n.find(R=>!R.skip?.({}));return L?.type==="text"&&L.defaultValue?L.defaultValue:""}),[H,O]=useState(()=>{let L=n.find(R=>!R.skip?.({}));return L?.type==="text"&&L.defaultValue?L.defaultValue.length:0}),[D,N]=useState(()=>{let L=n.find(R=>!R.skip?.({}));return L?.type==="textarea"&&L.defaultValue?L.defaultValue.split(`
|
|
5
|
+
`):[""]}),[G,K]=useState(0),[V,W]=useState(0),[_,C]=useState(()=>{let L=n.find(R=>!R.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}),A=useMemo(()=>n.filter(L=>!L.skip?.(I)),[n,I]),B=A[w],ge=A.length,[Re,rt]=useState(new Set),je=useMemo(()=>!B||B.type!=="select"&&B.type!=="multiselect"?[]:B.getOptions?.(I)??B.options??[],[B,I]),Ue=Math.min(_,Math.max(0,je.length-1)),Ye=L=>{let R={...I,[B.id]:L};v(R),F(""),O(0),N([""]),K(0),W(0),C(0),rt(new Set);let k=B.id,Y=n.findIndex(Z=>Z.id===k)+1;for(;Y<n.length;){let Z=n[Y];if(Z&&!Z.skip?.(R))break;Y++;}if(Y>=n.length)o(R);else {let Z=n[Y].id,_e=n.filter(Te=>!Te.skip?.(R)).findIndex(Te=>Te.id===Z);x(_e>=0?_e:0);let me=n[Y];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
|
+
`):[""];N(Te),K(Te.length-1),W(Te[Te.length-1].length);}else if(me.type==="select"){let Te=me.getOptions?.(R)??me.options??[];if(me.defaultValue){let pt=Te.findIndex(Je=>Je.value===me.defaultValue);C(pt>=0?pt:0);}else C(0);}else me.type==="multiselect"&&(C(0),me.defaultValue?rt(new Set(me.defaultValue.split(","))):rt(new Set));}},Oe=()=>{if(w===0){l();return}let L=B.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,Y=A.findIndex(Q=>Q.id===j);x(Y>=0?Y: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
|
+
`):[""];N(_e),K(_e.length-1),W(_e[_e.length-1].length);}else if(Z.type==="multiselect"){C(0);let Q=I[Z.id];rt(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,R)=>{if(B){if(R.escape){w===0?l():Oe();return}if((R.ctrl||R.meta)&&(L==="v"||L==="i")&&y&&(B.type==="text"||B.type==="textarea")){y();return}if(B.type==="text"){if(R.return){let k=P.trim();if(B.required&&!k)return;Ye(k);return}if(R.leftArrow){O(k=>Math.max(0,k-1));return}if(R.rightArrow){O(k=>Math.min(P.length,k+1));return}if(R.backspace||R.delete){if(H===0&&P.length===0&&w>0){Oe();return}H>0&&(F(k=>k.slice(0,H-1)+k.slice(H)),O(k=>k-1));return}L&&!R.ctrl&&!R.meta&&!R.escape&&(F(k=>k.slice(0,H)+L+k.slice(H)),O(k=>k+L.length));return}if(B.type==="textarea"){if(R.return&&!R.shift){let k=D.join(`
|
|
8
|
+
`).trim();if(B.required&&!k)return;Ye(k);return}if(R.return&&R.shift){N(k=>{let j=k[G]??"",Y=j.slice(0,V),Z=j.slice(V),Q=[...k];return Q.splice(G,1,Y,Z),Q}),K(k=>k+1),W(0);return}if(R.upArrow){G>0&&(K(k=>k-1),W(k=>Math.min(k,(D[G-1]??"").length)));return}if(R.downArrow){G<D.length-1&&(K(k=>k+1),W(k=>Math.min(k,(D[G+1]??"").length)));return}if(R.leftArrow){V>0?W(k=>k-1):G>0&&(K(k=>k-1),W((D[G-1]??"").length));return}if(R.rightArrow){let k=(D[G]??"").length;V<k?W(j=>j+1):G<D.length-1&&(K(j=>j+1),W(0));return}if(R.backspace||R.delete){if(V===0&&G===0)return;if(V>0)N(k=>{let j=[...k],Y=j[G]??"";return j[G]=Y.slice(0,V-1)+Y.slice(V),j}),W(k=>k-1);else {let k=(D[G-1]??"").length;N(j=>{let Y=[...j],Z=Y[G-1]??"",Q=Y[G]??"";return Y.splice(G-1,2,Z+Q),Y}),W(k),K(j=>j-1);}return}if(L&&!R.ctrl&&!R.meta&&!R.escape){let k=L.split(/\r?\n/);if(k.length===1)N(j=>{let Y=[...j],Z=Y[G]??"";return Y[G]=Z.slice(0,V)+L+Z.slice(V),Y}),W(j=>j+L.length);else {let j=G,Y=V;N(Z=>{let Q=[...Z],_e=Q[j]??"",me=_e.slice(0,Y),Te=_e.slice(Y),pt=k[0]??"",Je=k[k.length-1]??"",gn=[me+pt,...k.slice(1,-1),Je+Te];return Q.splice(j,1,...gn),Q}),K(j+k.length-1),W((k[k.length-1]??"").length);}}return}if(B.type==="select"||B.type==="multiselect"){if(R.upArrow||L==="k"){C(k=>Math.max(0,k-1));return}if(R.downArrow||L==="j"){C(k=>Math.min(je.length-1,k+1));return}if(R.backspace||R.delete){Oe();return}if(B.type==="select"){if(R.return||R.tab){let k=je[Ue];k&&Ye(k.value);return}if(L>="1"&&L<="9"){let k=parseInt(L,10)-1;if(k<je.length){let j=je[k];j&&Ye(j.value);}return}}else {if(L===" "){let k=je[Ue];k&&rt(j=>{let Y=new Set(j);return Y.has(k.value)?Y.delete(k.value):Y.add(k.value),Y});return}if(R.return){let k=Array.from(Re).join(",");Ye(k);return}}}}}),!B)return null;let Pe=`${w+1}/${ge}`,Ze=Math.max(2,p-4),we=0;Ue>=Ze&&(we=Ue-Ze+1);let Ne=je.slice(we,we+Ze);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:" "}),A.map((L,R)=>jsxs(Text,{color:R===w?e.amber:R<w?e.green:e.ghost,children:[R===w?"\u25CF":R<w?"\u2713":"\u25CB"," "]},L.id))]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.white,bold:true,children:[" ",B.label]}),!B.required&&jsx(Text,{color:e.dim,children:" (optional, Enter to skip)"})]}),B.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)})]}):B.placeholder?jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:B.placeholder}),jsx(Text,{color:e.amber,children:Bn})]}):jsx(Text,{color:e.amber,children:Bn})]}),B.type==="textarea"&&(()=>{let L=Math.max(3,p-6),R=0;G>=L&&(R=G-L+1);let k=D.slice(R,R+L),j=String(D.length).length;return jsxs(Box,{flexDirection:"column",children:[k.map((Y,Z)=>{let Q=Z+R,_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:Y.slice(0,V)}),jsx(Text,{color:e.amber,children:Bn}),jsx(Text,{color:e.white,children:Y.slice(V)})]}):jsx(Text,{color:e.silver,children:Y||" "})]},Q)}),D.length===1&&D[0]===""&&B.placeholder&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","".padStart(j," ")," ",B.placeholder]})})]})})(),B.type==="select"&&jsx(Box,{flexDirection:"column",children:Ne.map((L,R)=>{let k=R+we,j=k===Ue,Y=String(k+1).padStart(je.length>=10?2:1);return jsxs(Box,{children:[jsx(Text,{color:j?e.amber:e.ghost,children:j?" \u25B8 ":` ${Y} `}),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)})}),B.type==="multiselect"&&jsxs(Box,{flexDirection:"column",children:[Ne.map((L,R)=>{let j=R+we===Ue,Y=Re.has(L.value);return jsxs(Box,{children:[jsx(Text,{color:j?e.amber:e.ghost,children:j?" \u25B8 ":" "}),jsx(Text,{color:Y?e.green:e.dim,children:Y?"[\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)}),Re.size>0&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","\u2514"," ",Re.size," selected"]})})]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.ghost,children:[" ",B.type==="select"?"\u2191\u2193 select Enter confirm":B.type==="multiselect"?"\u2191\u2193 move Space toggle Enter confirm":B.type==="textarea"?"Shift+Enter newline Enter confirm \u2190\u2191\u2192\u2193 navigate":"\u2190\u2192 move Enter confirm",y&&(B.type==="text"||B.type==="textarea")?` ${process.platform==="darwin"?"\u2318":"Ctrl"}+V paste image`:""," Esc ",w>0?"back":"cancel"]}),b&&jsxs(Text,{color:e.amber,children:[" ",b]})]})]})}var vi="\u256D",_i="\u256E",Ai="\u2570",Mi="\u256F",ct="\u2502";function Ri({children:t,cw:n}){return jsxs(Text,{children:[jsx(Text,{color:e.ghost,children:ct}),jsxs(Text,{children:[" ",t.padEnd(n)," "]}),jsx(Text,{color:e.ghost,children:ct})]})}function En({cw:t}){return jsx(Ri,{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,p=bt.repeat(l-2),y=jsxs(Text,{color:e.ghost,children:[vi,p,_i]}),b=jsxs(Text,{color:e.ghost,children:[Ai,p,Mi]});if(t>0){let x=n.hints[0],I=x?` ${x.key} ${x.label}`:"";return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[y,jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ct," "]}),jsx(Text,{color:e.amber,children:Mt}),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:ct})]}),b]})}let w=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:[y,jsx(En,{cw:d}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ct," "]}),jsx(Text,{color:e.amber,children:Mt}),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:ct})]}),jsx(En,{cw:d}),n.description.map((x,I)=>jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ct," "]}),jsx(Text,{color:e.silver,children:x.padEnd(d)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ct})]},I)),jsx(En,{cw:d}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ct," "]}),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-w))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ct})]}),jsx(En,{cw:d}),b]})}var mr=[{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"}],pr=[{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"}],fr=[{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"}],hr=[{value:"",label:"Default",hint:"use shell adapter default"}],Ei=[{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"}],xr=[{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"}],gr=80;function br(t){return t.filter(n=>n.status!=="disabled").map(n=>{let o=(n.role??n.adapter).split(`
|
|
9
|
+
`)[0].trim(),l=o.length>gr?o.slice(0,gr-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},...br(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 Tr(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 yr(){return [{id:"shop_template",label:"Agent Shop \u2014 choose a template",type:"select",options:a$2.map(t=>({value:t.key,label:t.name,hint:t.description}))}]}function wr(t,n){return t.map(o=>{switch(o.id){case "name":return {...o,defaultValue:n.name};case "adapter":return {...o,defaultValue:n.adapter};case "model":return {...o,defaultValue:n.model};case "role":return {...o,defaultValue:"__custom__"};case "role_custom":return {...o,defaultValue:n.role,skip:void 0};case "skills":return {...o,defaultValue:n.skills.join(", ")};case "approval_policy":return {...o,defaultValue:n.approval_policy};default:return o}})}function go(t){let n=Tr(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:Ei},{id:"model",label:"Model",type:"select",getOptions:o=>o.adapter==="codex"?pr:o.adapter==="cursor"?fr:o.adapter==="shell"?hr:mr},{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:"skills",label:"Skills (comma-separated)",type:"text",placeholder:"e.g. feature-dev:feature-dev, testing-suite:generate-tests"},{id:"approval_policy",label:"Approval policy",type:"text",skip:()=>true},{id:"team",label:"Join team",type:"select",options:n,skip:()=>n.length<=1}]}function Sr(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0,o=t.skills?t.skills.split(",").map(d=>d.trim()).filter(Boolean):void 0,l=t.approval_policy||"auto";return {name:t.name,adapter:t.adapter||"claude",role:n,model:t.model||void 0,approval_policy:l,skills:o,team_id:t.team||void 0}}function kr(t){let n=br(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 Ir(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 Cr(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:xr,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 $r(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 vr(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:xr,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 _r(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description??""}}function Ar(t,n){let o=uo.find(b=>b.value===t.role),l=o?t.role:t.role?"__custom__":"",d=t.adapter==="codex"?pr:t.adapter==="cursor"?fr:t.adapter==="shell"?hr:mr,p=Tr(n),y=n?.find(b=>b.members.some(w=>w.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:p,defaultValue:y??"",skip:()=>p.length<=1}]}var Li=[{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"}],Oi=[{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 Mr(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:Oi,defaultValue:t,skip:o=>o.setting!=="activity_filter"},{id:"max_concurrent",label:"Max concurrent agents",type:"select",options:Li,defaultValue:String(n),skip:o=>o.setting!=="max_concurrent"}]}function Rr(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 Br(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description||void 0}}function Er(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 Lr(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description??""}}var Or=10,Pr=500,Gn=2048,Lt=500,mo=new Set(["todo","failed","cancelled"]),Wi={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."},Fi={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."},Gi={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."},Nr=5e3,Fr=0;function Kl(){Fr=0;}var Gr=/^\[[\w_]+\]$/;function zr(t){return Gr.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 Dr=["#5faf87","#5fafd7","#af87ff","#d7af00","#5fd7d7","#d787af","#afaf5f","#d7875f"];function zn(t,n){let o=n.findIndex(l=>l.id===t);return Dr[o>=0?o%Dr.length:0]}var zi=" ".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 po(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 Yl({projectName:t,tasks:n,agents:o=[],state:l,onRunTask:d,onCreateTask:p,onCancelTask:y,onRetryTask:b$1,onAssignTask:w,onRunAll:x,onDisableAgent:I,onEnableAgent:v,onSubscribeEvents:P,onRefreshTasks:F,onRefreshAgents:H,onRefreshState:O,onLoadHistory:D,onAddAgent:N,onDeleteAgent:G,onApproveTask:K,onRejectTask:V,onDeleteTask:W,onUpdateTask:_,onUpdateAgent:C,onForceStopAgent:A,onCreateTeam:B,onListTeams:ge,onJoinTeam:ie,onLeaveTeam:Re,onDisbandTeam:rt,onSetTeamLead:je,onStartWatch:Ue,onStopWatch:Ye,onToggleAutonomous:Oe,onRefreshGoals:Ot,onCreateGoal:Pe,onUpdateGoal:Ze,onUpdateGoalStatus:we,onDeleteGoal:Ne,onGetGoalProgress:L,initialWatchActive:R,watchError:k,messageBatchMs:j=process.env.VITEST?0:80,initialActivityFilter:Y="all",onSaveActivityFilter:Z,initialMaxConcurrent:Q=a.scheduling.max_concurrent_agents,onSaveMaxConcurrent:_e,version:me,latestVersion:Te}){let{exit:pt}=useApp(),{stdout:Je}=useStdout(),[gn,qr]=useState({w:Je?.columns??80,h:Je?.rows??24});useEffect(()=>{if(!Je)return;let i=()=>qr({w:Je.columns,h:Je.rows});return Je.on("resize",i),()=>{Je.off("resize",i);}},[Je]);let Kt=gn.w,fo=gn.h,[Qe,Kr]=useState(n),[Se,Yr]=useState(o),[He,Zr]=useState(l),[mn,jn]=useState(R??!!l.pid),[Un,ho]=useState([]),[Jr,xo]=useState(void 0),[$,Pt]=useState("tasks"),[pn,fn]=useState(0),[Hn,bo]=useState(0),[Xn,To]=useState(0),[ke,Yt]=useState(false),[et,yo]=useState([]),[Ie,Ce]=useState("none"),[St,st]=useState(""),[tt,De]=useState(null),[kt,Zt]=useState([]),[Qr,es]=useState(0),[ts,ns]=useState(()=>new Set(Wn)),[Jt,qn]=useState(-1),[os,Qt]=useState(0),[Nt,Kn]=useState(()=>{let i=qt.find(T=>T.label===Y);return new Set(i?.types??Wn)}),hn=useMemo(()=>qt.find(T=>T.types.length===Nt.size&&T.types.every(s=>Nt.has(s)))?.label??"all",[Nt]),Yn=useMemo(()=>Nt.size>=Wn.length?et:et.filter(i=>Nt.has(i.msgType??"info")),[et,Nt]),[wo,rs]=useState(Q),xn=Fn.useRef(new Rn).current,[ss,en]=useState(0),[So,ko]=useState(false),[is,Zn]=useState(0),[as,Jn]=useState(0),[ls,tn]=useState(0),[bn,ft]=useState(0),[ht,Io]=useState([]),[Dt,Qn]=useState([]),nn=useRef(ht);nn.current=ht;let U=useCallback(async i=>{let[T,s,c,g,f]=await Promise.all([F?.()??Promise.resolve(Qe),H?.()??Promise.resolve(Se),O?.()??Promise.resolve(He),i?.includeTeams?ge?.()??Promise.resolve(nn.current):Promise.resolve(null),Ot?.()??Promise.resolve(Un)]);Kr(T),Yr(s),Zr(c),g!==null&&Io(g),ho(f),R&&jn(!!c.pid);},[F,H,O,ge,Ot,R]),$e=useMemo(()=>[...Qe].sort((i,T)=>(cn[i.status]??9)-(cn[T.status]??9)),[Qe]),xt=So?$e:$e.slice(0,Or),on=$e.length-xt.length,E=$e[pn],Tn=useMemo(()=>{let i=new Map;for(let T of Qe)i.set(T.id,T.title);return i},[Qe]),It=useMemo(()=>{let i=new Map;for(let T of Se)i.set(T.id,T.name);return i},[Se]),{agentTeamMap:Wt,activeTeamCount:rn,teamLeadSet:cs}=useMemo(()=>{let i=new Map,T=new Set,s=0;for(let c of ht)if(c.status==="active"){s++,T.add(c.lead_agent_id);for(let g of c.members)i.set(g.agent_id,c.name);}return {agentTeamMap:i,activeTeamCount:s,teamLeadSet:T}},[ht]),Ae=useMemo(()=>{let i=[...Se];return i.sort((T,s)=>{let c=Wt.get(T.id),g=Wt.get(s.id);return c&&!g?-1:!c&&g?1:c&&g&&c!==g?c.localeCompare(g):(so[T.status]??9)-(so[s.status]??9)}),i},[Se,Wt]),X=Ae[Hn],Xe=useMemo(()=>[...Un].sort((i,T)=>(c[i.status]??9)-(c[T.status]??9)),[Un]),q=Xe[Xn],ds=useMemo(()=>q?Qe.filter(i=>i.goalId===q.id):[],[q,Qe]),eo=useRef(L);eo.current=L,useEffect(()=>{if(!q||!eo.current){xo(void 0);return}let i=false;return eo.current(q.id).then(T=>{i||xo(T);}).catch(()=>{}),()=>{i=true;}},[q?.id]);let Ct=useRef(new Map),yn=useRef(new Map);useEffect(()=>{for(let[i,T]of Object.entries(He.running))Ct.current.set(T.run_id,T.agent_id),yn.current.set(T.run_id,i);if(Ct.current.size>Pr){let i=Ct.current.size-Pr,T=0;for(let s of Ct.current.keys()){if(T++>=i)break;Ct.current.delete(s),yn.current.delete(s);}}},[He.running]);let $t=useRef([]),sn=useRef(null),to=useCallback(()=>{if(sn.current=null,$t.current.length===0)return;let i=$t.current;$t.current=[],yo(T=>{if(i.length>=Lt)return i.slice(-Lt);let s=Lt-i.length;return (T.length>s?T.slice(-s):T).concat(i)});},[]);useEffect(()=>()=>{sn.current&&clearTimeout(sn.current);},[]);let r=useCallback((i,T,s)=>{let c=new Date,g=c.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),f=s?.detail&&s.detail.length>Gn?s.detail.slice(0,Gn)+"\u2026[truncated]":s?.detail;$t.current.push({text:i,color:T,time:g,ts:c.getTime(),...s,detail:f}),$t.current.length>Lt*2&&($t.current=$t.current.slice(-Lt)),j===0?to():sn.current||(sn.current=setTimeout(to,j));},[to]);useEffect(()=>{k&&r(`Watch mode failed: ${k}. Tasks will not auto-dispatch.`,e.red);},[]);let Ft=useCallback((i,T,s,c)=>{let g={key:++Fr,entityType:i,entityId:T,entityName:s,expiresAt:Date.now()+Nr,needsForceStop:c?.needsForceStop};Qn(f=>[...f,g]),r(`\u2717 "${s}" will be deleted in ${Math.round(Nr/1e3)}s \u2014 press Z to undo`,e.yellow);},[r]),us=useCallback(()=>{Qn(i=>{if(i.length===0)return i;let T=i[i.length-1];return r(`\u21B6 Undo: "${T.entityName}" restored`,e.green),i.slice(0,-1)});},[r]),Co=useCallback(async i=>{try{i.entityType==="task"&&W?await W(i.entityId):i.entityType==="agent"?(i.needsForceStop&&A&&await A(i.entityId),G&&await G(i.entityId)):i.entityType==="goal"&&Ne&&await Ne(i.entityId),r(`\u2713 Deleted "${i.entityName}"`,e.green),U();}catch(T){r(`Failed to delete "${i.entityName}": ${T instanceof Error?T.message:String(T)}`,e.red);}},[W,G,Ne,A,r,U]),$o=useRef(Co);$o.current=Co,useEffect(()=>{if(Dt.length===0)return;let i=setInterval(()=>{let T=Date.now(),s=[];Qn(c=>{let g=c.filter(f=>f.expiresAt<=T?(s.push(f),false):true);return s.length>0?g:c});for(let c of s)$o.current(c);},1e3);return ()=>clearInterval(i)},[Dt.length>0]),useEffect(()=>{if(!D)return;let i=T=>{let s=new Date(T.timestamp).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),c=typeof T.data=="string"?T.data:JSON.stringify(T.data),g,f=e.silver,m="output";if(T.type==="error")g=typeof T.data=="string"?T.data:JSON.stringify(T.data),g=g.slice(0,200),f=e.red,m="error";else if(T.type==="file_changed")g=String(T.data),f=e.purple,m="file";else if(T.type==="done")g="Completed",f=e.green,m="lifecycle";else if(T.type==="tool_call")g=`\u2699 ${T.data?.name??"tool"}()`,f=e.cyan,m="tool";else {let{summary:h}=Xr(c);if(!h)return null;g=h;let z=zr(g);m=z.msgType,f=z.color;}return {text:g,color:f,time:s,ts:new Date(T.timestamp).getTime(),agentId:T.agentId,taskId:T.taskId,msgType:m}};D(T=>{if(T.length===0)return;let s=T.map(i).filter(c=>c!==null);yo(c=>{let g=[...s,...c];return g.length>Lt?g.slice(-Lt):g});}).catch(()=>{});},[]),useEffect(()=>{ge?.().then(Io).catch(()=>{}),Ot?.().then(ho).catch(()=>{});},[]);let wn=useCallback(()=>{De({title:"NEW AGENT",steps:go(nn.current),kind:"agent"}),Ce("wizard");},[]),vo=useCallback(()=>{De({title:"AGENT SHOP",steps:yr(),kind:"agent_shop"}),Ce("wizard");},[]),Sn=useCallback(()=>{Zt([]),De({title:"NEW TASK",steps:Cr(Se),kind:"task"}),Ce("wizard");},[Se]),gs=useCallback(async()=>{try{let{detectClipboardType:i,getClipboardImage:T}=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 T();if(!c)return r("Failed to read clipboard image",e.red),"empty";let{mkdtemp:g,writeFile:f}=await import('fs/promises'),{tmpdir:m}=await import('os'),{join:h}=await import('path'),z=await g(h(m(),"orch-paste-")),lt=h(z,`clipboard-${Date.now()}.${c.ext}`);return await f(lt,c.data),Zt(_t=>[..._t,lt]),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]),ms=useCallback(i=>{De({title:"EDIT TASK",steps:vr(i,Se),kind:"edit_task",targetId:i.id}),Ce("wizard");},[Se]),_o=useCallback(()=>{De({title:"NEW TEAM",steps:kr(Se),kind:"team"}),Ce("wizard");},[Se]),ps=useCallback(i=>{De({title:"EDIT AGENT",steps:Ar(i,ht),kind:"edit_agent",targetId:i.id}),Ce("wizard");},[ht]),Ao=useCallback(()=>{De({title:"SETTINGS",steps:Mr(hn,wo),kind:"config"}),Ce("wizard");},[hn,wo]),fs=useCallback(i=>{Ce("none");let T=tt?.kind,s=tt?.targetId;if(De(null),T==="agent_shop"){let c=i.shop_template,g=c?b(c):void 0;if(g){let f=go(nn.current),m=wr(f,g);De({title:`NEW AGENT \u2014 ${g.name}`,steps:m,kind:"agent_from_shop"}),Ce("wizard");}else r("No template selected",e.yellow);return}if((T==="agent"||T==="agent_from_shop")&&N){let c=Sr(i);r(`Creating agent "${c.name}"...`,e.amber),N(c.name,c.adapter,{model:c.model,role:c.role,approval_policy:c.approval_policy,skills:c.skills}).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(f=>{r(`\u2713 Joined team "${f.name}"`,e.green),U({includeTeams:true});},f=>r(`Failed to join team: ${f instanceof Error?f.message:String(f)}`,e.red)):U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(T==="team"&&B){let c=Ir(i);r(`Creating team "${c.name}"...`,e.amber),B(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(T==="task"&&p){let c=$r(i),g=kt.length>0?[...kt]:void 0;Zt([]),r(`Creating "${c.title}"...`,e.amber),p(c.title,{priority:c.priority,description:c.description,attachments:g}).then(f=>{r(`\u2713 Created "${f.title}" (${f.id})${g?` \u{1F4CE}${g.length}`:""}`,e.green),c.assignee&&w&&w(f.id,c.assignee).catch(()=>{}),U();},f=>r(`Failed: ${f instanceof Error?f.message:String(f)}`,e.red));}else if(T==="edit_task"&&s&&_){let c=_r(i),g=kt.length>0?[...kt]:void 0;Zt([]),r("Updating task...",e.amber),_(s,{...c,attachments:g}).then(f=>{r(`\u2713 Updated "${f.title}"${g?` \u{1F4CE}${g.length}`:""}`,e.green),c.assignee&&w&&w(s,c.assignee).catch(()=>{}),U();},f=>r(`Failed: ${f instanceof Error?f.message:String(f)}`,e.red));}else if(T==="edit_agent"&&s&&C){let c=Rr(i),g=c.team_id??"",f=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=[];f&&f!==g&&Re&&h.push(Re(f,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!==f&&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(T==="config"){if(i.setting==="activity_filter"&&i.activity_filter){let c=qt.find(g=>g.label===i.activity_filter);c&&(Kn(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&&(rs(c),_e?.(c),r(`Max concurrent agents: ${c}`,e.amber));}}else if(T==="goal"&&Pe){let c=Br(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(T==="edit_goal"&&s&&Ze){let c=Lr(i);r("Updating goal...",e.amber),Ze(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));}},[tt,N,p,B,ie,Re,w,_,C,Oe,Pe,Ze,r,U,Z,_e,ht,kt]),hs=useCallback(()=>{Ce("none"),De(null),Zt([]);},[]);useEffect(()=>{if(!P)return;let i=null,T=()=>{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)),ca(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")&&T();});return ()=>{s(),i&&clearTimeout(i);}},[P,r,U]);let no=mn?"watching":"idle",xs=He.started_at?g(He.started_at):void 0,bs=He.stats.total_tokens.total,Mo=useMemo(()=>{let i={running:0,retrying:0,review:0,todo:0,done:0,failed:0,cancelled:0};for(let T of Qe)T.status==="in_progress"?i.running++:T.status==="retrying"?i.retrying++:T.status==="review"?i.review++:T.status==="todo"?i.todo++:T.status==="done"?i.done++:T.status==="failed"?i.failed++:T.status==="cancelled"&&i.cancelled++;return {...i,teams:rn}},[Qe,rn]);Mo.running;let Ts={input:He.stats.total_tokens.input??0,output:He.stats.total_tokens.output??0,total:bs},kn=Math.max(4,fo-9),ys=Wt.size,ws=Se.length>ys,Ss=rn>0?rn+(ws?1:0):0,ks=$==="goals"?Xe.length+1:$==="tasks"?xt.length+1+(on>0?1:0):$==="agents"?Se.length+1+Ss:0,Is=Math.min(ks+1,Math.ceil(kn*.5)),xe=$==="logs"?kn:Math.max(2,Math.min(Is,kn-4)),vt=Math.max(1,kn-xe),fe=Math.max(10,Kt-2),it=useMemo(()=>Ie==="command"?ar(St):[],[Ie,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,Xe.length-xe)));},[Xe.length,xe]);let Cs=useCallback(i=>{let s=i.trim().replace(/^\//,"").split(/\s+/),c=s[0]?.toLowerCase();if(!c)return;let g=f=>f instanceof Error?f.message:String(f);switch(c){case "cancel":{if(!E){r("No task selected",e.yellow);return}if(!y)return;r(`Cancelling "${E.title}"...`,e.amber),y(E.id).then(()=>{r(`\u2713 Cancelled "${E.title}"`,e.green),U();},f=>r(`Failed: ${g(f)}`,e.red));return}case "retry":{if(!E){r("No task selected",e.yellow);return}if(!b$1)return;r(`Retrying "${E.title}"...`,e.amber),b$1(E.id).then(()=>{r(`\u2713 Retried "${E.title}"`,e.green),U();},f=>r(`Failed: ${g(f)}`,e.red));return}case "assign":{if(!E){r("No task selected",e.yellow);return}if(!w||!s[1]){r("Usage: assign <agent>",e.yellow);return}r(`Assigning "${E.title}" to ${s[1]}...`,e.amber),w(E.id,s[1]).then(()=>{r(`\u2713 Assigned "${E.title}" to ${s[1]}`,e.green),U();},f=>r(`Failed: ${g(f)}`,e.red));return}case "task":{let f=s[1]?.toLowerCase();if(f==="add"){let m=s.slice(2).join(" ");if(!m){Sn();return}if(!p){r("Create not available",e.yellow);return}r(`Creating "${m}"...`,e.amber),p(m).then(h=>{r(`\u2713 Created "${h.title}" (${h.id})`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(f==="list"){let m=$e.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(f==="show"){let m=s[2]?$e.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(f==="cancel"){let m=s[2]?$e.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(!y)return;r(`Cancelling "${m.title}"...`,e.amber),y(m.id).then(()=>{r(`\u2713 Cancelled "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(f==="retry"){let m=s[2]?$e.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(!b$1)return;r(`Retrying "${m.title}"...`,e.amber),b$1(m.id).then(()=>{r(`\u2713 Retried "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(f==="assign"){let m=s[2]?$e.find(lt=>lt.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(!w)return;r(`Assigning "${h.title}" to ${z}...`,e.amber),w(h.id,z).then(()=>{r(`\u2713 Assigned "${h.title}" to ${z}`,e.green),U();},lt=>r(`Failed: ${g(lt)}`,e.red));}else if(f==="approve"){let m=s[2]?$e.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(!K)return;r(`Approving "${m.title}"...`,e.amber),K(m.id).then(()=>{r(`\u2713 Approved "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(f==="reject"){let m=s[2]?$e.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]&&$e.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(f==="delete"){let m=s[2]?$e.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 f=s[1]?.toLowerCase();if(f==="add"){let m=s[2];if(!m){wn();return}if(!N){r("Agent creation not available",e.yellow);return}let h=s[3];r(`Creating agent "${m}"...`,e.amber),N(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(f==="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(f==="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(f==="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(f==="delete"||f==="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(f==="autonomous"||f==="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(`${At} ${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(`${At} ${m.name} autonomous ON`,e.cyan),U();},h=>r(`Failed: ${g(h)}`,e.red)));}else f==="shop"?vo():r("Usage: /agent add|list|disable|enable|delete|autonomous|shop",e.yellow);return}case "team":{let f=s[1]?.toLowerCase();if(f==="create"||f==="add")_o();else if(f==="list"){let m=nn.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(f==="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(f==="leave"){if(!Re){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),Re(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(f==="disband"){if(!rt){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),rt(m).then(()=>{r("\u2713 Team disbanded",e.green),U({includeTeams:true});},h=>r(`Failed: ${g(h)}`,e.red));}else if(f==="set-lead"){if(!je){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),je(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 f=s[1]?.toLowerCase();if(f==="add"||f==="create"){let m=s.slice(2).join(" ").trim();if(!m){let h=Pn(Se);De({title:"New Goal",steps:h,kind:"goal"}),Ce("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(f==="list"){let m=Xe.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(f==="show"){let m=s[2]?Xe.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(f==="status"){let m=s[2]?Xe.find(_t=>_t.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 lt=z;if(!we){r("Status update not available",e.yellow);return}r(`Updating goal status to ${lt}...`,e.amber),we(h.id,lt).then(_t=>{r(`\u2713 Goal "${_t.title}" \u2192 ${lt}`,e.green),U();},_t=>r(`Failed: ${g(_t)}`,e.red));}else if(f==="delete"){let m=s[2]?Xe.find(h=>h.id===s[2]):q;if(!m){r("No goal selected or id given",e.yellow);return}if(!Ne){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 f=s[1]??E?.id;if(!f){r("No task selected or id given",e.yellow);return}if(!d){r("Run not available",e.yellow);return}let m=$e.find(h=>h.id===f);if(m&&!mo.has(m.status)){r(`Cannot run \u2014 status is ${m.status}`,e.yellow);return}r(`Running ${f}...`,e.amber),d(f).then(()=>{r(`\u2713 Dispatched ${f}`,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();},f=>r(`Failed: ${g(f)}`,e.red));return}case "watch":{if(mn){r("Watch mode already active",e.yellow);return}if(!Ue){r("Watch not available",e.yellow);return}r("Starting watch mode...",e.amber),Ue().then(()=>{jn(true),r("\u2713 Watch mode started",e.green);},f=>r(`Failed: ${g(f)}`,e.red));return}case "pause":{if(!mn){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);},f=>r(`Failed: ${g(f)}`,e.red));return}case "config":{s[1]?.toLowerCase()==="activity-filter"?Kn(m=>{let h=po(m);return Z?.(h.label),r(`Activity filter: ${h.label}`,e.amber),new Set(h.types)}):Ao();return}case "status":{let f=Qe.filter(m=>m.status==="in_progress").length;r(`${no} ${f} running ${Qe.length} tasks ${Ae.length} agents`,e.cyan);return}case "help":{for(let[f,m]of Object.entries(Xt)){let h=m.sub?" "+m.sub.join("|"):m.args?" "+m.args:"";r(` /${f}${h} \u2014 ${m.help}`,e.silver);}return}case "quit":{pt();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();},f=>r(`Failed: ${g(f)}`,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();},f=>r(`Failed: ${g(f)}`,e.red));return}default:r(`Unknown: ${c}. Type /help for commands`,e.yellow);}},[E,X,$e,Ae,Qe,no,mn,y,b$1,w,x,d,p,I,v,N,K,V,W,ie,Re,rt,je,Ue,Ye,r,pt,U,Sn,wn,_o,Ao]);useInput((i,T)=>{if((T.ctrl||T.meta)&&i==="s"&&Ie==="wizard"&&tt?.kind==="agent"){vo();return}if(Ie!=="none"){if(T.escape){Ce("none"),st(""),xn.reset();return}if(T.return){let s=St.trim();if(!s)return;if(Ie==="new_task"){if(!p)return;Ce("none"),st(""),r(`Creating "${s}"...`,e.amber),p(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(Ie==="command"){let c=s;if(it.length>0&&it[bn]){let g=it[bn],f=g.cmd.replace(/\s+\[.*\]$/,"");if((f.startsWith(s)||s==="/")&&(c=f),g.subs&&!f.includes(" ")){st(f+" "),ft(0);return}}Ce("none"),st(""),ft(0),xn.push(c),Cs(c);}return}if(T.tab&&Ie==="command"){if(it.length>0){let s=it[bn];if(s){let c=s.cmd.replace(/\s+\[.*\]$/,"");st(c+(s.subs?" ":"")),ft(0);}}else {let s=ao(St);s&&st(c=>c+s);}return}if(T.upArrow&&Ie==="command"){if(it.length>0)ft(s=>Math.max(0,s-1));else {let s=xn.prev();s!==null&&st(s);}return}if(T.downArrow&&Ie==="command"){if(it.length>0)ft(s=>Math.min(it.length-1,s+1));else {let s=xn.next();st(s??"");}return}if(T.backspace||T.delete){st(s=>s.slice(0,-1)),ft(0);return}i&&!T.ctrl&&!T.meta&&(st(s=>s+i),ft(0));return}if(i.toLowerCase()==="q"){pt();return}if(T.escape){if(ke){Yt(false),tn(0);return}if($==="logs"&&Jt>=0){qn(-1),Qt(0);return}return}if(i==="/"&&!ke){Ce("command"),st("/"),ft(0);return}if($==="logs"&&!ke&&i>="0"&&i<="9"){es(parseInt(i,10));return}if((i==="f"||i==="F")&&$==="logs"&&!ke){ns(s=>new Set(po(s).types));return}if((i==="z"||i==="Z")&&Dt.length>0){us();return}if((i==="f"||i==="F")&&($==="tasks"||$==="agents"||$==="goals")&&!ke){Kn(s=>{let c=po(s);return Z?.(c.label),new Set(c.types)});return}if((i==="n"||i==="N")&&$==="tasks"&&!ke&&p){Sn();return}if((i==="n"||i==="N")&&$==="agents"&&!ke&&N){wn();return}if((i==="n"||i==="N")&&$==="goals"&&!ke&&Pe){let s=Pn(Se);De({title:"New Goal",steps:s,kind:"goal"}),Ce("wizard");return}if((i==="e"||i==="E")&&$==="goals"&&q&&Ze){let s=Er(q,Se);De({title:`Edit Goal: ${q.title}`,steps:s,kind:"edit_goal",targetId:q.id}),Ce("wizard");return}if((i==="d"||i==="D")&&$==="goals"&&q&&Ne){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"&&K){r(`Approving "${E.title}"...`,e.amber),K(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&&y){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),y(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&&_){ms(E);return}if((i==="e"||i==="E")&&$==="agents"&&X&&C){ps(X);return}if((i==="s"||i==="S")&&$==="tasks"){ko(s=>!s),fn(0),en(0);return}if((i==="s"||i==="S")&&$==="agents"&&X&&A){if(!Object.values(He.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),A(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(He.running).some(c=>c.agent_id===X.id);if(s&&!A){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(`${At} ${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=An.map(g=>g.id),c=s.indexOf($);if(T.tab||T.rightArrow){Pt(s[(c+1)%s.length]);return}if(T.leftArrow){Pt(s[(c+s.length-1)%s.length]);return}}if(T.return){let s=on>0?xt.length:-1;if($==="tasks"&&pn===s){ko(g=>!g),fn(0),en(0);return}let c=xt.length+(on>0?1:0);if($==="tasks"&&pn===c&&p){Sn();return}if($==="goals"&&Xn===Xe.length&&Pe){let g=Pn(Se);De({title:"New Goal",steps:g,kind:"goal"}),Ce("wizard");return}if($==="agents"&&Hn===Ae.length&&N){wn();return}if($==="goals"&&q){Yt(g=>!g),tn(0);return}if($==="tasks"&&E){Yt(g=>!g);return}if($==="agents"&&X){Yt(g=>!g);return}if($==="logs"&&Jt>=0){Yt(g=>!g);return}}if((i==="r"||i==="R")&&$==="tasks"&&E&&d){if(!mo.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(T.upArrow||i==="k"){if($==="goals"&&ke){tn(s=>Math.max(0,s-1));return}$==="goals"?To(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"?bo(s=>{let c=Math.max(0,s-1);return Zn(g=>c<g?c:g),c}):$==="logs"&&qn(s=>{if(s===-1){let g=et.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(T.downArrow||i==="j"){if($==="goals"&&ke){tn(s=>s+1);return}if($==="goals"){let s=Xe.length+(Pe?1:0)-1;To(c=>{let g=Math.min(Math.max(0,s),c+1);return Jn(f=>g>=f+xe?g-xe+1:f),g});}else if($==="tasks"){let s=xt.length+(p?1:0)+(on>0?1:0)-1;fn(c=>{let g=Math.min(Math.max(0,s),c+1);return en(f=>g>=f+xe?g-xe+1:f),g});}else if($==="agents"){let s=Ae.length+(N?1:0)-1;bo(c=>{let g=Math.min(Math.max(0,s),c+1);return Zn(f=>g>=f+xe?g-xe+1:f),g});}else $==="logs"&&qn(s=>{if(s===-1)return -1;let c=et.length-1;if(s>=c)return Qt(0),-1;let g=s+1;return Qt(f=>g>=f+xe-1?g-xe+2:f),g});}});let We=Ie!=="none",Ro=Jt>=0?et[Jt]:void 0,Bo=!We&&ke&&$==="tasks"&&E,Eo=!We&&ke&&$==="agents"&&X,Lo=!We&&ke&&$==="goals"&&q,$s=!We&&ke&&$==="logs"&&Ro,vs=!We&&$==="tasks"&&E&&mo.has(E.status)&&!!d,_s=!We&&!ke&&($==="goals"&&!!Pe||$==="tasks"&&!!p||$==="agents"&&!!N),As=!We&&$==="tasks"&&E?.status==="review"&&!!K,Ms=!We&&$==="tasks"&&E?.status==="review"&&!!V,Rs=X?Object.values(He.running).some(i=>i.agent_id===X.id):false,Bs=!We&&($==="goals"&&q&&!!Ne||$==="tasks"&&E&&E.status!=="in_progress"&&!!W||$==="agents"&&X&&!!G),Es=!We&&!ke&&($==="goals"&&!!q&&!!Ze||$==="tasks"&&!!E&&!!_||$==="agents"&&!!X&&!!C),Ls=!We&&$==="agents"&&X&&(Rs||X.status==="running")&&!!A,Os=!We&&$==="agents"&&!!X&&!!Oe,Ps=!We&&$==="goals"&&!!q&&(q.status==="active"||q.status==="paused")&&!!we,Ns=!We&&Dt.length>0,Oo=Ie==="command"&&it.length>0,Po=tt?.kind==="task"||tt?.kind==="edit_task";return jsxs(Box,{flexDirection:"column",width:Kt,height:fo,children:[jsx(ir,{projectName:t,activeView:$,mode:no,stats:Mo,tokens:Ts,uptime:xs,width:Kt,version:me,latestVersion:Te}),jsx(Box,{height:1}),$==="goals"&&jsx(Ui,{goals:Xe,selectedIndex:Xn,scrollOffset:as,height:xe,width:fe,showAddRow:!!Pe,agentNameMap:It}),$==="tasks"&&jsx(Xi,{tasks:xt,selectedIndex:pn,scrollOffset:ss,height:xe,width:fe,showAddRow:!!p,agentNameMap:It,hiddenCount:on}),$==="agents"&&jsx(qi,{agents:Ae,selectedIndex:Hn,scrollOffset:is,height:xe,width:fe,state:He,taskTitleMap:Tn,showAddRow:!!N,agentTeamMap:Wt,teamLeadSet:cs,activeTeamCount:rn}),$==="logs"&&jsx(Ji,{messages:et,height:xe,agents:Ae,logFilter:Qr,logTypeFilter:ts,selectedIndex:Jt,scrollOffset:os,agentNameMap:It,taskTitleMap:Tn,width:fe}),jsx(Box,{height:1}),Ie==="wizard"&&tt?jsx(dr,{title:tt.title,steps:tt.steps,onComplete:fs,onCancel:hs,width:fe,height:vt,onPasteImage:Po?gs:void 0,footerExtra:tt.kind==="agent"?`${process.platform==="darwin"?"\u2318":"Ctrl"}+S browse shop`:kt.length>0&&Po?`\u{1F4CE}${kt.length}`:void 0},`${tt.kind}-${tt.title}`):Oo?jsxs(Fragment,{children:[jsx(Nn,{label:"COMMANDS",width:fe}),jsx(ji,{suggestions:it,selectedIndex:bn,height:Math.min(it.length,vt),width:fe})]}):Ie==="new_task"?jsxs(Fragment,{children:[jsx(ia,{mode:Ie,width:fe}),jsx(aa,{mode:Ie,value:St,width:fe})]}):Bo?jsxs(Fragment,{children:[jsx(ta,{task:E,width:fe}),jsx(tr,{task:E,height:vt,width:fe,taskLogs:et.filter(i=>i.taskId===E.id),agentNameMap:It})]}):Lo?jsxs(Fragment,{children:[jsx(Nn,{label:`GOAL: ${q.title}`,width:fe}),jsx(Hi,{goal:q,height:vt,width:fe,agentNameMap:It,tasks:ds,progressReport:Jr,scrollOffset:ls,onClampScroll:tn})]}):Eo?jsxs(Fragment,{children:[jsx(na,{agent:X,width:fe}),jsx(oa,{agent:X,height:vt,state:He,taskTitleMap:Tn,teamName:Wt.get(X.id)})]}):$s?jsxs(Fragment,{children:[jsx(Nn,{label:"LOG",width:fe}),jsx(ea,{message:Ro,height:vt,width:fe,agents:Ae,agentNameMap:It,taskTitleMap:Tn})]}):et.length>0&&$!=="logs"?jsxs(Fragment,{children:[(()=>{let i=` F:${hn.toUpperCase()} \u2502 ${Yn.length}/${et.length}`;return jsx(Nn,{label:"ACTIVITY",width:fe,suffixLen:i.length,suffix:jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" F:"}),jsx(Text,{color:e.amber,children:hn.toUpperCase()}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," ",Yn.length,"/",et.length]})]})})})(),jsx(Qi,{messages:Yn,height:Math.max(1,vt-1),width:fe,agents:Ae,agentNameMap:It})]}):$==="goals"?jsx(Ln,{count:Xe.length,config:Wi,width:fe}):$==="tasks"?jsx(Ln,{count:$e.length,config:Fi,width:fe}):$==="agents"?jsx(Ln,{count:Ae.length,config:Gi,width:fe}):null,jsx(Box,{flexGrow:1}),Dt.length>0&&jsx(Vi,{deletions:Dt,width:Kt}),jsx(lr,{mode:Ie==="command"?"command":"navigate",value:Ie==="command"?St:"",completion:Ie==="command"?ao(St):null,activeView:$,canRun:!!vs,canNew:!!_s,canApprove:!!As,canReject:!!Ms,canCancel:$==="tasks"&&!!E&&E.status==="in_progress"&&!!y,canDelete:!!Bs,canUndo:!!Ns,canEdit:!!Es,canForceStop:!!Ls,canToggleAuto:!!Os,autoActive:X?.autonomous,canPause:!!Ps,isPaused:q?.status==="paused",canToggleShowAll:$==="tasks"&&$e.length>Or,showAllActive:So,hasDetail:!!(Bo||Eo||Lo),itemCount:$==="goals"?Xe.length:$==="tasks"?$e.length:$==="agents"?Se.length:et.length,itemLabel:$==="goals"?"goals":$==="tasks"?"tasks":$==="agents"?"agents":"events",width:Kt,hasSuggestions:Oo})]})}var Vi=Fn.memo(function({deletions:n,width:o}){let[,l]=useState(0);useEffect(()=>{let p=setInterval(()=>l(y=>y+1),1e3);return ()=>clearInterval(p)},[]);let d=Date.now();return jsx(Box,{flexDirection:"column",width:o,children:n.map(p=>{let y=Math.max(0,Math.ceil((p.expiresAt-d)/1e3)),b=Math.max(0,o-4),w=p.entityType==="task"?"Task":p.entityType==="agent"?"Agent":"Goal",x=Math.max(10,b-w.length-30),I=p.entityName.length>x?p.entityName.slice(0,x-1)+"\u2026":p.entityName;return jsx(Box,{paddingX:2,children:jsxs(Text,{color:e.yellow,children:["\u2717 ",jsx(Text,{bold:true,children:w}),` "${I}" \u2014 `,jsxs(Text,{color:e.amber,bold:true,children:[y,"s"]}),jsx(Text,{color:e.dim,children:" \u2502 "}),jsx(Text,{color:e.gray,bold:true,children:"Z"}),jsx(Text,{color:e.dim,children:" undo"})]})},p.key)})})});function ji({suggestions:t,selectedIndex:n,height:o,width:l}){let d=o,p=0;n>=d&&(p=n-d+1);let y=t.slice(p,p+d);return jsx(Box,{flexDirection:"column",paddingX:2,children:y.map((b,w)=>{let x=w+p,I=x===n,v=I?"\u25B6":" ",P=Math.min(20,Math.max(14,...t.map(N=>N.cmd.length+1))),F=b.cmd.padEnd(P),H=b.subs?` ${b.subs}`:"",O=Math.max(4,l-P-H.length-8),D=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:D}),H&&jsx(Text,{color:e.ghost,children:H})]},x)})})}function Ui({goals:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,showAddRow:p,agentNameMap:y}){let b=t.length,w=t.slice(o,o+l),x=p&&b>=o&&b<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[w.map((I,v)=>jsx(Box,{paddingX:2,children:jsx(er,{goal:I,selected:v+o===n,width:d-2,agentNameMap:y})},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 Hi({goal:t,height:n,width:o,agentNameMap:l,tasks:d,progressReport:p,scrollOffset:y=0,onClampScroll:b}){let x=Fn.useMemo(()=>{let O=d??[],D=t.assignee?l?.get(t.assignee)??t.assignee:"\u2014",N=Math.max(20,o-6),G=(A,B)=>{if(A.length<=B)return [A];let ge=[];for(let ie=0;ie<A.length;ie+=B)ge.push(A.slice(ie,ie+B));return ge},K=p?p.split(`
|
|
10
|
+
`).flatMap(A=>G(A,N)):[],V=t.description?t.description.split(`
|
|
11
|
+
`).flatMap(A=>G(A,N)):[],W=zo[t.status]??e.dim,_=new Map;for(let A of O)_.set(A.status,(_.get(A.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:D})]})]})}),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 A=[];for(let[B,ge]of _)A.push(`${ge} ${B}`);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:A.join(" \xB7 ")})]})]})});}if(V.length>0){C.push({key:"desc-gap",node:jsx(Text,{children:" "})});for(let A=0;A<V.length;A++)C.push({key:`desc-${A}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",V[A]]})});}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(K.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 A=0;A<K.length;A++)C.push({key:`prog-${A}`,node:jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",K[A]]})});}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 A of O){let B=Cn[A.status]??e.dim;C.push({key:`task-${A.id}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",jsx(Text,{color:B,children:A.status.padEnd(12)}),A.title.slice(0,Math.max(10,o-22))]})});}}return C},[t,d,p,o,l]),I=Math.max(0,x.length-n),v=Math.min(y,I);Fn.useEffect(()=>{b&&v!==y&&b(v);},[v,y,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 Xi({tasks:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,showAddRow:p,agentNameMap:y,hiddenCount:b=0}){let w=b>0,x=w?t.length:-1,I=t.length+(w?1:0),v=t.slice(o,o+l),P=w&&x>=o&&x<o+l,F=p&&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:y})},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 qi({agents:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,state:p,taskTitleMap:y,showAddRow:b,agentTeamMap:w,teamLeadSet:x,activeTeamCount:I}){let v=new Map;for(let _ of Object.values(p.running))v.set(_.agent_id,_);let P=new Map;if(I&&I>0)for(let _ of t){let C=w?.get(_.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,D=I!=null&&I>0,N=new Map;if(D&&x&&w){for(let _ of t)if(x.has(_.id)){let C=w.get(_.id);C&&N.set(C,_.name);}}let G=0;for(let _ of P.values())G+=_;let K=t.length-G,V=[],W=o>0?w?.get(t[o-1]?.id??""):void 0;for(let _=0;_<H.length&&V.length<l;_++){let C=H[_],A=w?.get(C.id);if(D&&A&&A!==W&&(V.push(jsx(Yo,{teamName:A,memberCount:P.get(A)??0,leadName:N.get(A),width:d},`ts-${A}`)),V.length>=l)||D&&!A&&W&&(V.push(jsx(Zo,{memberCount:K,width:d},"ts-unassigned")),V.length>=l))break;W=A,V.push(jsx(Box,{paddingX:2,children:jsx(Ko,{agent:C,selected:_+o===n,width:d-2,runningEntry:v.get(C.id),currentTaskTitle:C.current_task?y.get(C.current_task):void 0,teamName:A,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 Vr(t=5e3){let[n,o]=useState(Date.now());return useEffect(()=>{let l=setInterval(()=>o(Date.now()),t);return ()=>clearInterval(l)},[t]),n}function jr(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 Ki=" \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Yi(t,n,o,l){let d=new Array(n).fill(0),p=l-n*o;for(let b of t){if(b.ts<p)continue;let w=Math.min(n-1,Math.floor((b.ts-p)/o));d[w]++;}let y=Math.max(1,...d);return d.map(b=>Ki[Math.round(b/y*8)]).join("")}function Zi(t){if(t==="error")return e.errorBg}function Ur(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 Ji({messages:t,height:n,agents:o,logFilter:l,logTypeFilter:d,selectedIndex:p,scrollOffset:y,agentNameMap:b,taskTitleMap:w,width:x}){let I=Vr(),v=useMemo(()=>t.filter(_=>{if(l!==0){let A=o[l-1];if(A&&_.agentId!==A.id)return false}let C=_.msgType??"info";return d.has(C)}),[t,o,l,d]);useMemo(()=>{let _={};for(let C of t){let A=C.msgType??"info";_[A]=(_[A]??0)+1;}return _},[t]);let F=useMemo(()=>{let _=new Map;for(let C of t)C.agentId&&_.set(C.agentId,(_.get(C.agentId)??0)+1);return _},[t]),H=useMemo(()=>Yi(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`,D=n-3,N=p===-1?v.slice(-D):v.slice(y,y+D),G=p===-1?-1:p-y,K=Math.min(10,Math.max(6,...o.map(_=>_.name.length))),V=11+K,W=_=>{if(_===0)return true;let C=N[_],A=N[_-1];return C.agentId!==A.agentId?true:C.agentId?C.ts-A.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((_,C)=>{let A=zn(_.id,o),B=l===C+1,ge=F.get(_.id)??0,ie=ge>0?`\xB7${ge}`:"";return B?jsxs(Text,{backgroundColor:e.successBg,color:A,bold:true,children:[" ",C+1,":",_.name,ie," "]},_.id):jsxs(Text,{color:ge>0?e.dim:e.ghost,children:[" ",C+1,":",_.name,ie]},_.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"," "]}),p===-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 ",p+1,"/",v.length," "]}),jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amberDim,children:H}),jsx(Text,{color:e.ghost,children:" 5m"})]}),N.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"})]})]}):N.map((_,C)=>{let A=C===G,B=_.msgType??"info",ge=Vn[B]??"\u2502",ie=_.agentId?b.get(_.agentId)??_.agentId.slice(0,8):void 0,Re=_.agentId?zn(_.agentId,o):void 0,rt=W(C),Ue=(C>0?N[C-1]:void 0)?.agentId===_.agentId&&!!_.agentId,Ye=!Ue&&!!ie,Oe=Ue&&!!ie,Ot=Ur(B,_.color),Pe=A?e.infoBg:B==="error"?e.errorBg:void 0,Ze=_.taskId?w.get(_.taskId):void 0,we=jr(_.ts,I),Ne=Ze&&x>80?`#${Ze.slice(0,20)}`:"",L=Ne?Ne.length+3:0,R=Math.max(10,x-2-V-L),k=_.text.length>R?_.text.slice(0,R-1)+"\u2026":_.text;return jsxs(Box,{backgroundColor:Pe,children:[jsx(Text,{color:Re??e.ghost,children:rt&&Ye?"\u250C":Oe?"\u2502":" "}),jsx(Text,{color:A?e.amber:void 0,children:A?"\u25B8":" "}),jsx(Box,{width:5,children:jsx(Text,{color:we==="now"?e.green:A?e.silver:e.ghost,children:we.padStart(4)})}),jsx(Box,{width:K+1,children:Ye?jsxs(Text,{color:Re,bold:true,children:[" ",ie.slice(0,K).padEnd(K)]}):Oe?jsxs(Text,{color:Re??e.ghost,children:[" ","\xB7".padEnd(K)]}):jsxs(Text,{color:e.ghost,children:[" "," ".padEnd(K)]})}),jsxs(Text,{color:B==="error"?e.red:Re??e.dim,children:[" ",ge," "]}),jsx(Text,{color:A?e.white:Ot,bold:A||B==="lifecycle",children:k}),Ne&&jsxs(Text,{color:e.ghost,children:[" ",jsx(Text,{color:e.dim,backgroundColor:e.void,children:` ${Ne} `})]})]},C)})]})}function Qi({messages:t,height:n,width:o,agents:l,agentNameMap:d}){let p=Vr(),y=t.slice(-n),b=Math.max(10,o-2-17),w=Math.max(0,n-y.length),x=0,I=[];for(let v=0;v<y.length;v++)v>0&&y[v].agentId!==y[v-1].agentId&&x++,I.push(x);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[w>0&&jsx(Box,{height:w}),y.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",D=Vn[O]??"\u2502",N=Ur(O,v.color),K=(P>0?y[P-1]:void 0)?.agentId===v.agentId&&!!v.agentId,V=(I[P]&1)===1,W=Zi(O)??(V?"#1a1a1a":void 0),_=jr(v.ts,p),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:!K&&F?"\u258D":K?"\u258F":" "}),jsx(Box,{width:5,children:jsx(Text,{color:K?e.ghost:_==="now"?e.green:e.dim,children:K?" ":_.padStart(4)})}),jsx(Box,{width:9,children:F&&!K?jsxs(Text,{color:H,bold:true,children:[" ",F.slice(0,8)]}):jsx(Text,{color:e.ghost,children:zi})}),jsxs(Text,{color:O==="error"?e.red:K?e.ghost:H??e.dim,children:[D," "]}),jsx(Text,{color:N,children:C})]},P)})]})}function ea({message:t,height:n,width:o,agents:l,agentNameMap:d,taskTitleMap:p}){let y=t.detail??t.text,b=t.msgType??"info",w=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?p.get(t.taskId):void 0,v,P=false;try{let D=JSON.parse(y);v=JSON.stringify(D,null,2),P=!0;}catch{v=y;}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 "}),w&&jsx(Text,{color:x,bold:true,children:w}),w&&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((D,N)=>jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),P&&jsxs(Text,{color:e.ghost,children:[String(N+1).padStart(3)," "]}),jsx(Text,{wrap:"truncate",color:P&&D.includes('"')?e.cyan:P&&/^\s*[}\]]/.test(D)?e.ghost:D.startsWith("error")||D.startsWith("Error")?e.red:e.silver,children:D.slice(0,P?F-4:F)})]},N)),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u2570","\u2500".repeat(F+2),"\u256F"]})})]})}function Nn({label:t,width:n,suffix:o,suffixLen:l=0}){let d=` ${t} `,p=3,y=p+d.length+2;if(!o){let x=Math.max(0,n-y);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(p)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:d}),jsx(Text,{color:e.ghost,children:ye.repeat(x)})]})}let b=2,w=Math.max(0,n-y-b-l);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(p)}),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(w)})]})}function ta({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,p=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,p))]})]})}function na({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,p=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,p))]})]})}function oa({agent:t,height:n,state:o,taskTitleMap:l,teamName:d}){let p=ra[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,w=24;return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:w,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:p,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:w,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:w,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:w,children:[jsx(Text,{color:e.dim,children:" auto "}),jsxs(Text,{color:e.cyan,children:[At," 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 ra={idle:e.dim,running:e.green,error:e.red,disabled:e.ghost},sa="\u2588";function ia({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 aa({mode:t,value:n,width:o}){let l=t==="command"?"/":"\u25B8",d=Math.max(10,o-8),p=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:p}),jsx(Text,{color:e.amber,children:sa})]})}function Hr(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 Dn(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 p=d.text.split(`
|
|
14
|
+
`).find(y=>y.trim().length>0)??"";o.push(p.slice(0,n-l)),l+=p.length;}else if(d?.type==="tool_use"){let p=Hr(d.name??"tool",d.input),y=`\u2699 ${d.name??"tool"}(${p})`;o.push(y),l+=y.length;}else if(d?.type==="tool_result")o.push("\u2190 (result)"),l+=10;else if(d?.type==="thinking"&&typeof d.thinking=="string"){let p=d.thinking.slice(0,60).split(`
|
|
15
|
+
`)[0]??"";o.push(`\u{1F4AD} ${p}`),l+=p.length+3;}}return o.length>0?o.join(" "):null}function Wr(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,p=typeof o.content=="string"?o.content:"",y=p.split(`
|
|
18
|
+
`).length;d?n.push(`\u2715 error: ${p.slice(0,60)}`):y>3?n.push(`\u2713 ${y} lines`):n.push(`\u2713 ${p.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 Xr(t){let n=()=>t.length>Gn?t.slice(0,Gn)+"\u2026":t;if(Gr.test(t.trim()))return {summary:t.trim(),detail:n()};try{let o=JSON.parse(t);if(o.type==="message"&&o.role==="assistant"){let l=Dn(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=Dn(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 ${Wr(l).slice(0,180)}`,detail:n()}}if(o.type==="tool_use"){let l=o.name??"tool",d=Hr(l,o.input);return {summary:`\u2699 ${l}(${d})`,detail:n()}}if(o.type==="tool_result")return {summary:`\u2190 ${Wr(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=Dn(l);if(d)return {summary:d.slice(0,200),detail:n()}}return {summary:`[${o.subtype}]`,detail:n()}}if(o.content){let l=Dn(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:la(t),detail:n()}}}function la(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],p=l?.[1];if(!d&&!p)return t.slice(0,200);if(d==="assistant"||d==="message"||p==="assistant"){let y=t.match(/"text"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(y)try{return JSON.parse(`"${y[1]}"`).slice(0,200)}catch{}return "\u{1F4AC} (assistant)"}if(d==="user"||d==="tool_result"||p==="user")return "\u2190 (tool result)";if(d==="tool_use")return `\u2699 ${t.match(/"name"\s*:\s*"([^"]+)"/)?.[1]??"tool"}()`;if(d==="result"){let y=t.match(/"result"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(y)try{return `\u2713 ${JSON.parse(`"${y[1]}"`).slice(0,180)}`}catch{}return "\u2713 Agent finished"}return d==="rate_limit_event"?"\u23F3 Rate limited":`[${d??p}]`}function ca(t,n,o,l){let d=p=>l?.get(p);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:p,detail:y}=Xr(t.data);if(p){let b=zr(p);n(p,b.color,{agentId:t.agentId,taskId:d(t.runId),detail:y,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{Yl as App,Kl as _resetPendingDeletionSeq};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {d,a,e}from'./chunk-5AJ4LYO5.js';import {j,o,l,q,d as d$1,h,m}from'./chunk-L26TK7Y5.js';function T($,o$1){let l$1=$.command("agent").description("Manage agents");l$1.command("add <name>").description("Add a new agent").requiredOption("--adapter <adapter>","Adapter type: claude, shell, codex, cursor").option("--role <role>","Agent role description").option("--command <cmd>","Shell command (for shell adapter)").option("--model <model>","Model name (for AI adapters)").option("--max-turns <n>","Max turns per run").option("--timeout <ms>","Timeout in ms").option("--approval-policy <policy>","suggest|auto|manual").option("--workspace-mode <mode>","shared|worktree|isolated").option("--skills <skills>","Comma-separated list of agent skills").option("-e, --edit","Open $EDITOR to write the role description").action(async(t,e$1)=>{await o$1.paths.requireInit();let i=e$1.role;if(e$1.edit){let a$1=d({name:t,model:e$1.model,role:i}),s=await a(a$1),d$1=e(s);d$1.name&&(t=d$1.name),d$1.model&&(e$1.model=d$1.model),d$1.role&&(i=d$1.role);}let n=await o$1.agentService.create({name:t,adapter:e$1.adapter,role:i,command:e$1.command,model:e$1.model,max_turns:e$1.maxTurns?parseInt(e$1.maxTurns,10):void 0,timeout_ms:e$1.timeout?parseInt(e$1.timeout,10):void 0,approval_policy:e$1.approvalPolicy,workspace_mode:e$1.workspaceMode,skills:e$1.skills?e$1.skills.split(",").map(a=>a.trim()):void 0});o$1.context.json?console.log(JSON.stringify(n,null,2)):o$1.context.quiet?console.log(n.id):j(`Added agent ${o(n.name)} (${n.adapter}) \u2192 ${n.id}`);}),l$1.command("shop").description("Browse and install pre-built agent templates").option("--list","Print all templates (non-interactive)").action(async t=>{await o$1.paths.requireInit();let{AGENT_SHOP_TEMPLATES:e}=await import('./agent-shop-D2RS4BZK.js');if(t.list||!process.stdout.isTTY){l(["Key","Name","Adapter","Model","Skills"],e.map(s=>[s.key,s.name,s.adapter,s.model.replace("claude-",""),s.skills.slice(0,2).join(", ")]));return}let{pickFromShop:i}=await import('./shop-picker-LE3SKFOX.js'),n=await i(e);if(!n){console.log(" Cancelled.");return}let a=await o$1.agentService.create({name:n.name,adapter:n.adapter,model:n.model,role:n.role,skills:n.skills,approval_policy:n.approval_policy});j(`Added agent ${o(a.name)} (${a.adapter}) \u2192 ${a.id}`);}),l$1.command("list").description("List all agents").action(async()=>{await o$1.paths.requireInit();let t=await o$1.agentService.list();if(o$1.context.json){console.log(JSON.stringify(t,null,2));return}if(o$1.context.quiet){t.forEach(a=>console.log(a.id));return}if(t.length===0){console.log(`
|
|
3
|
+
No agents. Add one: ${q("orch agent add <name> --adapter claude")}
|
|
4
|
+
`);return}let e=["STATUS","AGENT","ADAPTER","TASK","TIME"],i=t.map(a=>[`${d$1(a.status)} ${a.status}`,o(a.name),a.adapter,a.current_task??q("\u2014"),q("\u2014")]);console.log(),l(e,i);let n=t.filter(a=>a.status==="running").length;console.log(`
|
|
5
|
+
${t.length} agents \xB7 ${n} running \xB7 ${h(t.reduce((a,s)=>a+(s.stats.tokens_used??0),0))} tokens total
|
|
6
|
+
`);}),l$1.command("status <id>").description("Show agent details").action(async t=>{await o$1.paths.requireInit();let e=await o$1.agentService.get(t);if(o$1.context.json){console.log(JSON.stringify(e,null,2));return}console.log(`
|
|
7
|
+
${e.name}`),console.log(` ${"\u2550".repeat(42)}`),console.log();let i=[["Adapter",`${e.adapter}${e.config.model?` (${e.config.model})`:""}`],["Status",`${d$1(e.status)} ${e.status}`],["Policy",e.config.approval_policy??"auto"]];e.current_task&&i.push(["Task",e.current_task]),e.role&&i.push(["Role",e.role]),e.config.skills?.length&&i.push(["Skills",e.config.skills.join(", ")]),m(i),console.log(`
|
|
8
|
+
Stats
|
|
9
|
+
${"\u2500".repeat(42)}`),m([["Tasks completed",String(e.stats.tasks_completed)],["Tasks failed",String(e.stats.tasks_failed)],["Total runs",String(e.stats.total_runs)],["Tokens used",h(e.stats.tokens_used??0)]]),console.log();}),l$1.command("edit <id>").description("Edit an agent in $EDITOR").action(async t=>{await o$1.paths.requireInit();let e$1=await o$1.agentService.get(t),i=d({name:e$1.name,model:e$1.config.model,role:e$1.role}),n=await a(i),a$1=e(n),s=await o$1.agentService.update(t,{name:a$1.name,role:a$1.role,model:a$1.model});o$1.context.json?console.log(JSON.stringify(s,null,2)):o$1.context.quiet?console.log(s.id):j(`Updated agent ${o(s.name)} (${s.id})`);}),l$1.command("remove <id>").description("Remove an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.remove(t),j(`Removed agent ${t}`);}),l$1.command("disable <id>").description("Disable an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.disable(t),j(`Disabled agent ${t}`);}),l$1.command("enable <id>").description("Enable an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.enable(t),j(`Enabled agent ${t}`);}),l$1.command("autonomous <id>").description("Toggle autonomous mode for an agent").option("--on","Enable autonomous mode").option("--off","Disable autonomous mode").action(async(t,e)=>{await o$1.paths.requireInit();let i=await o$1.agentService.get(t),n=e.on?true:e.off?false:!i.autonomous,a=await o$1.agentService.setAutonomous(t,n);o$1.context.json?console.log(JSON.stringify(a,null,2)):o$1.context.quiet?console.log(a.id):j(`Autonomous mode ${n?"enabled":"disabled"} for agent ${o(a.name)} (${a.id})`);});}export{T as registerAgentCommand};
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var n=`Backend engineer \u2014 builds APIs, services, database layers, and server-side business logic.
|
|
3
|
+
|
|
4
|
+
## WORKFLOW
|
|
5
|
+
|
|
6
|
+
1) READ the task description and identify the scope: new endpoint, service refactor, DB migration, etc.
|
|
7
|
+
2) EXPLORE the existing codebase with \`/code-explorer\` to understand project structure, conventions, and dependencies.
|
|
8
|
+
3) DESIGN the solution \u2014 define data models, API contracts, and error handling strategy. For non-trivial changes, outline the plan in a context message before coding.
|
|
9
|
+
4) IMPLEMENT using \`/feature-dev\` \u2014 write production code following the project's patterns (naming, folder structure, error classes).
|
|
10
|
+
5) WRITE TESTS \u2014 add unit tests for new logic; ensure edge cases and error paths are covered.
|
|
11
|
+
6) SELF-REVIEW \u2014 re-read the diff, check for hardcoded secrets, missing input validation, and N+1 queries.
|
|
12
|
+
7) MARK DONE \u2014 commit to your worktree branch and transition the task to review.
|
|
13
|
+
|
|
14
|
+
## RULES
|
|
15
|
+
|
|
16
|
+
- Always work inside your assigned git worktree; never modify the main branch directly.
|
|
17
|
+
- Follow existing project conventions for file naming, export style, and error handling.
|
|
18
|
+
- Every public function must have at least one test.
|
|
19
|
+
- Never store secrets or credentials in code \u2014 use environment variables.
|
|
20
|
+
- Keep functions under 40 lines; extract helpers when complexity grows.
|
|
21
|
+
- If the task is ambiguous, set context with your questions before coding.`,a=`Frontend engineer \u2014 builds React UI components, pages, styles, and client-side interactions.
|
|
22
|
+
|
|
23
|
+
## WORKFLOW
|
|
24
|
+
|
|
25
|
+
1) READ the task and identify the deliverable: new component, page, style fix, responsive layout, etc.
|
|
26
|
+
2) EXPLORE the component tree and design system with \`/code-explorer\` to find reusable primitives and naming conventions.
|
|
27
|
+
3) PLAN the component hierarchy \u2014 props interface, state management, and data flow.
|
|
28
|
+
4) IMPLEMENT using \`/feature-dev\` \u2014 write components with proper TypeScript types, accessibility attributes, and responsive styles.
|
|
29
|
+
5) STYLE \u2014 use the project's CSS approach (modules, Tailwind, styled-components) consistently. Check mobile, tablet, desktop breakpoints.
|
|
30
|
+
6) TEST \u2014 add component tests for rendering, user interactions, and edge states (loading, empty, error).
|
|
31
|
+
7) REVIEW your diff visually if possible with \`/frontend-design\`, then transition to review.
|
|
32
|
+
|
|
33
|
+
## RULES
|
|
34
|
+
|
|
35
|
+
- Components must be typed \u2014 no \`any\` props.
|
|
36
|
+
- Always handle loading, error, and empty states explicitly.
|
|
37
|
+
- Use semantic HTML elements (nav, main, section, button) \u2014 not div soup.
|
|
38
|
+
- Keep components under 150 lines; extract sub-components when they grow.
|
|
39
|
+
- Never hardcode colors or spacing \u2014 use design tokens / theme variables.
|
|
40
|
+
- Ensure keyboard navigation and ARIA labels for interactive elements.`,i=`QA engineer \u2014 writes tests, analyzes coverage, and ensures code quality across the project.
|
|
41
|
+
|
|
42
|
+
## WORKFLOW
|
|
43
|
+
|
|
44
|
+
1) READ the task \u2014 determine what needs testing: new feature, regression, coverage gap, flaky test.
|
|
45
|
+
2) ANALYZE existing coverage with \`/test-coverage\` to identify untested paths and weak spots.
|
|
46
|
+
3) PLAN the test matrix \u2014 list scenarios, edge cases, error paths, and boundary values.
|
|
47
|
+
4) WRITE TESTS using \`/generate-tests\` \u2014 unit tests for logic, integration tests for services, e2e for critical flows.
|
|
48
|
+
5) RUN the test suite and verify all new tests pass. Fix flaky tests if discovered.
|
|
49
|
+
6) REPORT \u2014 summarize coverage delta and any risks found during testing. Set context for the team.
|
|
50
|
+
|
|
51
|
+
## RULES
|
|
52
|
+
|
|
53
|
+
- Tests must be deterministic \u2014 no reliance on timing, network, or random data without seeding.
|
|
54
|
+
- Each test must have a clear description that explains WHAT is tested and WHY.
|
|
55
|
+
- Never test implementation details \u2014 test behavior and contracts.
|
|
56
|
+
- Mock external dependencies at the boundary, not deep inside the code.
|
|
57
|
+
- Coverage targets: aim for >80% line coverage on new code, >90% on critical paths.
|
|
58
|
+
- Flag any untestable code as a design smell and suggest refactoring.`,o=`Senior code reviewer \u2014 performs thorough PR reviews focused on correctness, security, maintainability, and adherence to project standards.
|
|
59
|
+
|
|
60
|
+
## WORKFLOW
|
|
61
|
+
|
|
62
|
+
1) READ the task and the diff \u2014 understand the intent of the change, not just the code.
|
|
63
|
+
2) EXPLORE context with \`/code-explorer\` \u2014 check how the changed code integrates with the rest of the system.
|
|
64
|
+
3) REVIEW systematically using \`/code-reviewer\`:
|
|
65
|
+
a) Correctness \u2014 does the logic match the requirements? Are edge cases handled?
|
|
66
|
+
b) Security \u2014 input validation, injection risks, auth checks, secret exposure.
|
|
67
|
+
c) Performance \u2014 unnecessary allocations, missing indexes, O(n^2) where O(n) is possible.
|
|
68
|
+
d) Maintainability \u2014 naming clarity, function length, single responsibility, test coverage.
|
|
69
|
+
e) Conventions \u2014 project style, naming, import order, error handling patterns.
|
|
70
|
+
4) WRITE FEEDBACK \u2014 be specific, cite line numbers, suggest concrete fixes. Distinguish blockers from nits.
|
|
71
|
+
5) DECIDE \u2014 approve, request changes, or flag for architect review if the design needs discussion.
|
|
72
|
+
|
|
73
|
+
## RULES
|
|
74
|
+
|
|
75
|
+
- Always explain WHY something is a problem, not just WHAT to change.
|
|
76
|
+
- Distinguish severity: blocker (must fix), suggestion (should fix), nit (optional).
|
|
77
|
+
- Never approve code with known security issues, even if the task is urgent.
|
|
78
|
+
- Be respectful \u2014 critique code, not the author.
|
|
79
|
+
- If the change is too large to review safely, request it be split.
|
|
80
|
+
- Check that tests exist for new logic; flag untested paths.`,r=`Software architect and technical leader \u2014 makes system-level design decisions, defines architecture, and ensures technical coherence across the project.
|
|
81
|
+
|
|
82
|
+
## WORKFLOW
|
|
83
|
+
|
|
84
|
+
1) READ the task \u2014 understand the architectural question: new system, scaling challenge, tech debt, migration.
|
|
85
|
+
2) EXPLORE the full codebase with \`/code-explorer\` and \`/code-architect\` to map dependencies, layers, and boundaries.
|
|
86
|
+
3) ANALYZE trade-offs \u2014 document at least two alternative approaches with pros/cons for each.
|
|
87
|
+
4) DESIGN the solution \u2014 define component boundaries, data flow, API contracts, and failure modes.
|
|
88
|
+
5) DOCUMENT the decision \u2014 write an ADR (Architecture Decision Record) or design doc explaining the chosen approach and rejected alternatives.
|
|
89
|
+
6) COMMUNICATE \u2014 set context for the team explaining the architectural direction and constraints.
|
|
90
|
+
|
|
91
|
+
## RULES
|
|
92
|
+
|
|
93
|
+
- Every architectural decision must have a documented rationale.
|
|
94
|
+
- Prefer simple solutions over clever ones \u2014 complexity is a liability.
|
|
95
|
+
- Design for failure \u2014 every external call can fail, every queue can back up.
|
|
96
|
+
- Enforce layer boundaries \u2014 domain must not depend on infrastructure.
|
|
97
|
+
- Never introduce a new technology without evaluating operational cost.
|
|
98
|
+
- Think in interfaces first, implementations second.
|
|
99
|
+
- Flag technical debt explicitly; don't let it accumulate silently.`,s=`DevOps engineer \u2014 manages CI/CD pipelines, infrastructure, deployment automation, and cloud configuration.
|
|
100
|
+
|
|
101
|
+
## WORKFLOW
|
|
102
|
+
|
|
103
|
+
1) READ the task \u2014 identify the scope: pipeline fix, infra provisioning, deployment config, monitoring setup.
|
|
104
|
+
2) EXPLORE current infrastructure and CI/CD config with \`/code-explorer\` to understand the existing setup.
|
|
105
|
+
3) DESIGN the change using \`/cloud-architect\` \u2014 plan the infrastructure or pipeline modification with rollback strategy.
|
|
106
|
+
4) IMPLEMENT \u2014 write IaC (Terraform, CloudFormation, Docker, K8s manifests) or pipeline configs (GitHub Actions, GitLab CI).
|
|
107
|
+
5) VALIDATE \u2014 dry-run or plan the change; verify no destructive modifications to production resources.
|
|
108
|
+
6) DOCUMENT \u2014 update runbooks, env variable lists, and deployment docs.
|
|
109
|
+
|
|
110
|
+
## RULES
|
|
111
|
+
|
|
112
|
+
- Never hardcode credentials \u2014 use secret managers or environment injection.
|
|
113
|
+
- Every infrastructure change must be idempotent and reversible.
|
|
114
|
+
- Pipeline changes must be tested in a non-production environment first.
|
|
115
|
+
- Always include health checks and rollback triggers in deployments.
|
|
116
|
+
- Tag all cloud resources with project, environment, and owner.
|
|
117
|
+
- Prefer declarative config over imperative scripts.
|
|
118
|
+
- Monitor cost implications of infrastructure changes.`,c=`Bug hunter \u2014 finds, reproduces, and diagnoses bugs through systematic investigation and proposes minimal fixes.
|
|
119
|
+
|
|
120
|
+
## WORKFLOW
|
|
121
|
+
|
|
122
|
+
1) READ the bug report or task description \u2014 extract symptoms, reproduction steps, and expected behavior.
|
|
123
|
+
2) EXPLORE the relevant code with \`/code-explorer\` \u2014 trace the execution path from input to the faulty output.
|
|
124
|
+
3) REPRODUCE \u2014 write a failing test that captures the bug before attempting any fix.
|
|
125
|
+
4) DIAGNOSE \u2014 identify the root cause, not just the symptom. Check for related occurrences of the same pattern.
|
|
126
|
+
5) FIX with \`/feature-dev\` \u2014 apply the minimal change that resolves the root cause. Avoid collateral refactoring.
|
|
127
|
+
6) VERIFY \u2014 confirm the failing test now passes and no existing tests regress.
|
|
128
|
+
7) REPORT \u2014 set context explaining the root cause, the fix, and any related areas that may have the same issue.
|
|
129
|
+
|
|
130
|
+
## RULES
|
|
131
|
+
|
|
132
|
+
- Always reproduce the bug with a test BEFORE fixing it.
|
|
133
|
+
- Fix the root cause, not the symptom \u2014 band-aids create more bugs.
|
|
134
|
+
- Keep fixes minimal and focused \u2014 one bug per task, no scope creep.
|
|
135
|
+
- Check for the same bug pattern elsewhere in the codebase.
|
|
136
|
+
- Never suppress errors to hide bugs \u2014 surface them properly.
|
|
137
|
+
- If the bug is in a dependency, document the workaround and file upstream.`,d=`Technical writer \u2014 creates and maintains documentation, READMEs, API references, guides, and inline code comments.
|
|
138
|
+
|
|
139
|
+
## WORKFLOW
|
|
140
|
+
|
|
141
|
+
1) READ the task \u2014 determine the documentation need: new feature docs, API reference, migration guide, README update.
|
|
142
|
+
2) EXPLORE the codebase with \`/code-explorer\` to understand the feature, its API surface, configuration options, and edge cases.
|
|
143
|
+
3) OUTLINE the document structure \u2014 headings, sections, and key points to cover.
|
|
144
|
+
4) WRITE using clear, concise language:
|
|
145
|
+
- Lead with the most important information (inverted pyramid).
|
|
146
|
+
- Include working code examples for every API or configuration option.
|
|
147
|
+
- Add diagrams or tables where they clarify complex relationships.
|
|
148
|
+
5) REVIEW \u2014 check for accuracy against the actual code, test that code examples work.
|
|
149
|
+
6) PUBLISH \u2014 commit the documentation and set context for the team.
|
|
150
|
+
|
|
151
|
+
## RULES
|
|
152
|
+
|
|
153
|
+
- Documentation must match the current code \u2014 outdated docs are worse than no docs.
|
|
154
|
+
- Every public API must have: description, parameters, return type, and at least one example.
|
|
155
|
+
- Use active voice and second person ("you can configure\u2026" not "it can be configured\u2026").
|
|
156
|
+
- Keep sentences under 25 words; paragraphs under 5 sentences.
|
|
157
|
+
- Code examples must be complete and runnable \u2014 no pseudo-code in docs.
|
|
158
|
+
- Never document internal implementation details in user-facing docs.`,l=`Marketing strategist \u2014 develops positioning, messaging, copy, and campaign strategies using marketing psychology principles.
|
|
159
|
+
|
|
160
|
+
## WORKFLOW
|
|
161
|
+
|
|
162
|
+
1) READ the task \u2014 identify the marketing objective: positioning, landing page copy, campaign plan, competitor analysis.
|
|
163
|
+
2) RESEARCH the product and market using \`/marketing-psychology\` \u2014 understand the target audience, pain points, and competitive landscape.
|
|
164
|
+
3) STRATEGIZE \u2014 define messaging pillars, value propositions, and differentiation angles.
|
|
165
|
+
4) CREATE the deliverable:
|
|
166
|
+
- Copy: headlines, body text, CTAs \u2014 with A/B variants.
|
|
167
|
+
- Strategy: channel plan, funnel stages, KPIs.
|
|
168
|
+
- Analysis: competitive matrix, SWOT, positioning map.
|
|
169
|
+
5) REVIEW \u2014 check for clarity, consistency, and alignment with brand voice.
|
|
170
|
+
6) DELIVER \u2014 commit artifacts and set context with rationale for the chosen approach.
|
|
171
|
+
|
|
172
|
+
## RULES
|
|
173
|
+
|
|
174
|
+
- Always lead with customer benefits, not product features.
|
|
175
|
+
- Every claim must be substantiated \u2014 no empty superlatives ("best", "revolutionary").
|
|
176
|
+
- Include measurable KPIs for every campaign recommendation.
|
|
177
|
+
- Respect brand voice and tone guidelines if they exist.
|
|
178
|
+
- A/B test assumptions \u2014 never assume you know what converts.
|
|
179
|
+
- Keep copy scannable: short paragraphs, bullet points, clear hierarchy.`,p=`Content creator \u2014 writes blog posts, articles, social media content, and educational materials that drive engagement and authority.
|
|
180
|
+
|
|
181
|
+
## WORKFLOW
|
|
182
|
+
|
|
183
|
+
1) READ the task \u2014 understand the content goal: thought leadership, tutorial, announcement, social post.
|
|
184
|
+
2) RESEARCH the topic using \`/marketing-psychology\` \u2014 gather key points, statistics, and angles that resonate with the target audience.
|
|
185
|
+
3) OUTLINE the content structure \u2014 hook, key sections, CTA. For long-form, plan 3-5 main sections.
|
|
186
|
+
4) WRITE the first draft:
|
|
187
|
+
- Hook the reader in the first two sentences.
|
|
188
|
+
- Use concrete examples and data points.
|
|
189
|
+
- End with a clear call-to-action.
|
|
190
|
+
5) EDIT \u2014 tighten prose, eliminate jargon, ensure logical flow.
|
|
191
|
+
6) DELIVER \u2014 commit the content and set context with publishing recommendations.
|
|
192
|
+
|
|
193
|
+
## RULES
|
|
194
|
+
|
|
195
|
+
- Every piece must have a clear audience and goal defined upfront.
|
|
196
|
+
- Use the inverted pyramid \u2014 most important information first.
|
|
197
|
+
- Paragraphs max 3-4 sentences for readability.
|
|
198
|
+
- Include at least one concrete example or data point per section.
|
|
199
|
+
- Never plagiarize \u2014 all content must be original.
|
|
200
|
+
- Optimize for the target platform (blog post \u2260 tweet \u2260 LinkedIn post).`,u=`Growth hacker \u2014 designs and implements data-driven growth experiments to improve acquisition, activation, retention, and revenue.
|
|
201
|
+
|
|
202
|
+
## WORKFLOW
|
|
203
|
+
|
|
204
|
+
1) READ the task \u2014 identify the growth lever: onboarding funnel, activation rate, retention loop, referral mechanism.
|
|
205
|
+
2) ANALYZE current metrics using \`/product-manager-toolkit\` \u2014 map the funnel, identify drop-off points, and size opportunities.
|
|
206
|
+
3) HYPOTHESIZE \u2014 formulate a testable hypothesis: "If we [change X], then [metric Y] will improve by [Z%] because [reason]."
|
|
207
|
+
4) DESIGN the experiment \u2014 define the test, control group, success metric, sample size, and duration.
|
|
208
|
+
5) IMPLEMENT \u2014 build the experiment (feature flag, A/B test, new flow) using \`/feature-dev\` if code changes are needed.
|
|
209
|
+
6) REPORT \u2014 document the experiment design, expected impact, and measurement plan.
|
|
210
|
+
|
|
211
|
+
## RULES
|
|
212
|
+
|
|
213
|
+
- Every experiment must have a written hypothesis BEFORE implementation.
|
|
214
|
+
- Define success metrics and minimum detectable effect upfront.
|
|
215
|
+
- Run one experiment per funnel stage at a time to avoid confounding.
|
|
216
|
+
- Prioritize experiments by ICE score (Impact \xD7 Confidence \xD7 Ease).
|
|
217
|
+
- Never ship a "growth hack" that degrades user experience long-term.
|
|
218
|
+
- Document results of every experiment, including failures \u2014 they are data.`,h=`Security auditor \u2014 performs security analysis, identifies vulnerabilities, and recommends hardening measures following OWASP and industry best practices.
|
|
219
|
+
|
|
220
|
+
## WORKFLOW
|
|
221
|
+
|
|
222
|
+
1) READ the task \u2014 determine the audit scope: full codebase review, specific feature, dependency check, or incident response.
|
|
223
|
+
2) EXPLORE the attack surface with \`/code-explorer\` \u2014 map entry points (APIs, forms, file uploads), auth boundaries, and data flows.
|
|
224
|
+
3) AUDIT systematically using \`/code-reviewer\`:
|
|
225
|
+
a) OWASP Top 10 \u2014 injection, broken auth, XSS, CSRF, insecure deserialization.
|
|
226
|
+
b) Dependency vulnerabilities \u2014 outdated packages, known CVEs.
|
|
227
|
+
c) Secrets \u2014 hardcoded credentials, API keys in code or config.
|
|
228
|
+
d) Access control \u2014 missing authorization checks, privilege escalation paths.
|
|
229
|
+
e) Data protection \u2014 encryption at rest/transit, PII exposure, logging sensitive data.
|
|
230
|
+
4) CLASSIFY findings by severity: Critical, High, Medium, Low \u2014 with CVSS-like scoring.
|
|
231
|
+
5) RECOMMEND fixes \u2014 provide specific, actionable remediation steps for each finding.
|
|
232
|
+
6) REPORT \u2014 commit the audit report and set context with a prioritized action plan.
|
|
233
|
+
|
|
234
|
+
## RULES
|
|
235
|
+
|
|
236
|
+
- Never ignore a vulnerability because "it's unlikely to be exploited" \u2014 document everything.
|
|
237
|
+
- Always verify findings \u2014 no false positive reports. Reproduce or prove the vulnerability.
|
|
238
|
+
- Classify severity honestly \u2014 don't inflate or downplay.
|
|
239
|
+
- Check both application code AND configuration (CORS, headers, TLS, CSP).
|
|
240
|
+
- Recommend defense-in-depth \u2014 never rely on a single security control.
|
|
241
|
+
- Flag any plaintext secrets immediately as Critical, even in test code.`,m=`Performance engineer \u2014 profiles, benchmarks, and optimizes code for speed, memory efficiency, and scalability.
|
|
242
|
+
|
|
243
|
+
## WORKFLOW
|
|
244
|
+
|
|
245
|
+
1) READ the task \u2014 identify the performance concern: slow endpoint, high memory usage, scaling bottleneck, build time.
|
|
246
|
+
2) MEASURE first with \`/code-explorer\` \u2014 profile the current state, establish baseline metrics (latency, throughput, memory, CPU).
|
|
247
|
+
3) ANALYZE \u2014 identify hotspots, bottlenecks, and inefficient patterns. Look for:
|
|
248
|
+
- O(n^2) or worse algorithms where O(n log n) or O(n) is possible.
|
|
249
|
+
- Unnecessary allocations, memory leaks, missing cleanup.
|
|
250
|
+
- N+1 queries, missing indexes, unoptimized joins.
|
|
251
|
+
- Blocking I/O on the main thread, missing parallelism.
|
|
252
|
+
4) OPTIMIZE using \`/feature-dev\` \u2014 apply targeted fixes. One optimization per commit for clear attribution.
|
|
253
|
+
5) BENCHMARK \u2014 measure the improvement against the baseline. Report absolute numbers and percentage change.
|
|
254
|
+
6) DOCUMENT \u2014 set context with before/after metrics and explain the optimization rationale.
|
|
255
|
+
|
|
256
|
+
## RULES
|
|
257
|
+
|
|
258
|
+
- Always measure BEFORE and AFTER \u2014 no optimization without numbers.
|
|
259
|
+
- Optimize the bottleneck, not the code you like refactoring.
|
|
260
|
+
- Prefer algorithmic improvements over micro-optimizations.
|
|
261
|
+
- Never sacrifice readability for marginal performance gains.
|
|
262
|
+
- Profile in realistic conditions \u2014 not with trivial test data.
|
|
263
|
+
- Watch for regressions \u2014 optimization in one area can degrade another.`,g=`Data engineer \u2014 builds data pipelines, ETL processes, analytics queries, and data infrastructure.
|
|
264
|
+
|
|
265
|
+
## WORKFLOW
|
|
266
|
+
|
|
267
|
+
1) READ the task \u2014 identify the data need: new pipeline, query optimization, schema migration, analytics report.
|
|
268
|
+
2) EXPLORE existing data models and pipelines with \`/code-explorer\` to understand the current data architecture.
|
|
269
|
+
3) DESIGN the data flow \u2014 source, transformation steps, destination, error handling, and idempotency strategy.
|
|
270
|
+
4) IMPLEMENT using \`/feature-dev\`:
|
|
271
|
+
- Schema changes with migrations (never modify in place).
|
|
272
|
+
- ETL logic with proper error handling and retry.
|
|
273
|
+
- Queries optimized for the target database engine.
|
|
274
|
+
5) TEST \u2014 validate with representative data samples; check edge cases (nulls, duplicates, encoding, timezone).
|
|
275
|
+
6) DOCUMENT \u2014 schema diagrams, pipeline dependencies, SLA expectations.
|
|
276
|
+
|
|
277
|
+
## RULES
|
|
278
|
+
|
|
279
|
+
- Every schema change must have a reversible migration.
|
|
280
|
+
- Pipelines must be idempotent \u2014 safe to re-run without duplicating data.
|
|
281
|
+
- Always validate data at ingestion boundaries \u2014 never trust upstream data.
|
|
282
|
+
- Handle NULLs, duplicates, and encoding issues explicitly.
|
|
283
|
+
- Log pipeline metrics: rows processed, duration, error count.
|
|
284
|
+
- Never run DELETE or UPDATE without a WHERE clause and a backup plan.`,f=`Full-stack developer \u2014 works across the entire stack, from database and API to UI components and styling.
|
|
285
|
+
|
|
286
|
+
## WORKFLOW
|
|
287
|
+
|
|
288
|
+
1) READ the task \u2014 identify scope: does it span backend and frontend, or is it a vertical slice of a feature?
|
|
289
|
+
2) EXPLORE both backend and frontend code with \`/code-explorer\` to understand existing patterns and data flow end-to-end.
|
|
290
|
+
3) PLAN the implementation \u2014 define the API contract first (request/response shapes), then plan UI components that consume it.
|
|
291
|
+
4) IMPLEMENT BACKEND using \`/feature-dev\`:
|
|
292
|
+
- Data model, validation, service logic, API endpoint.
|
|
293
|
+
- Error handling with proper HTTP status codes and messages.
|
|
294
|
+
5) IMPLEMENT FRONTEND:
|
|
295
|
+
- Components, state management, API integration.
|
|
296
|
+
- Loading, error, and empty states.
|
|
297
|
+
- Responsive layout and accessibility.
|
|
298
|
+
6) TEST \u2014 backend unit/integration tests + frontend component tests. Verify the full data flow works end-to-end.
|
|
299
|
+
7) REVIEW your own diff holistically \u2014 check that API contracts match between frontend and backend.
|
|
300
|
+
|
|
301
|
+
## RULES
|
|
302
|
+
|
|
303
|
+
- Define the API contract before writing any code \u2014 frontend and backend must agree.
|
|
304
|
+
- Never duplicate validation \u2014 validate on the backend, display errors on the frontend.
|
|
305
|
+
- Keep frontend and backend changes in the same branch for atomic features.
|
|
306
|
+
- Follow each layer's conventions independently \u2014 backend patterns for backend, frontend patterns for frontend.
|
|
307
|
+
- Handle every error state in the UI \u2014 users should never see a blank screen.
|
|
308
|
+
- If a task is too large to deliver end-to-end, split it and communicate the dependency.`,y=[{key:"backend-dev",name:"Backend Developer",description:"APIs, databases, backend services",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:feature-dev","feature-dev:code-explorer"],role:n},{key:"frontend-dev",name:"Frontend Developer",description:"React, UI components, CSS, responsive design",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:feature-dev","feature-dev:code-explorer","frontend-design"],role:a},{key:"qa-engineer",name:"QA Engineer",description:"Test writing, coverage analysis, quality assurance",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["testing-suite:generate-tests","testing-suite:test-coverage","testing-suite:test-quality-analyzer"],role:i},{key:"code-reviewer",name:"Code Reviewer",description:"PR review, bug finding, code quality, security",adapter:"claude",model:"claude-opus-4-6",approval_policy:"suggest",skills:["feature-dev:code-reviewer","feature-dev:code-explorer"],role:o},{key:"architect",name:"Architect",description:"System design, architecture decisions, tech leadership",adapter:"claude",model:"claude-opus-4-6",approval_policy:"suggest",skills:["feature-dev:code-architect","feature-dev:code-explorer"],role:r},{key:"devops-engineer",name:"DevOps Engineer",description:"CI/CD, infrastructure, deployment, cloud",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["devops-automation:cloud-architect","feature-dev:code-explorer"],role:s},{key:"bug-hunter",name:"Bug Hunter",description:"Find bugs, reproduce issues, propose fixes",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:feature-dev","feature-dev:code-explorer"],role:c},{key:"tech-writer",name:"Technical Writer",description:"Documentation, READMEs, API docs, guides",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:code-explorer","docx"],role:d},{key:"marketer",name:"Marketer",description:"Marketing strategy, positioning, copy, campaigns",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["marketing-psychology","product-manager-toolkit"],role:l},{key:"content-creator",name:"Content Creator",description:"Blog posts, articles, social media content",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["marketing-psychology"],role:p},{key:"growth-hacker",name:"Growth Hacker",description:"Growth experiments, analytics, user acquisition",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["product-manager-toolkit","feature-dev:feature-dev"],role:u},{key:"security-auditor",name:"Security Auditor",description:"Security scanning, vulnerability analysis, OWASP",adapter:"claude",model:"claude-opus-4-6",approval_policy:"suggest",skills:["feature-dev:code-reviewer","feature-dev:code-explorer"],role:h},{key:"performance-engineer",name:"Performance Engineer",description:"Optimization, profiling, benchmarks, load testing",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:feature-dev","feature-dev:code-explorer"],role:m},{key:"data-engineer",name:"Data Engineer",description:"Data pipelines, ETL, analytics, SQL",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:feature-dev","feature-dev:code-explorer"],role:g},{key:"fullstack-dev",name:"Full-Stack Developer",description:"End-to-end development, frontend and backend",adapter:"claude",model:"claude-sonnet-4-6",approval_policy:"auto",skills:["feature-dev:feature-dev","feature-dev:code-explorer","frontend-design"],role:f}];function v(e){return y.find(t=>t.key===e)}export{y as a,v as b};
|
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-
|
|
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-S4DKSX63.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-LW7WIDE3.js')).registerTuiCommand(o,t);}},a=new Command;a.name("orchestry").description("Agents Organizations \u2014 CLI orchestrator for AI agents").version("0.3.2").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);});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import*as a from'readline';import r from'chalk';async function w(o){if(!process.stdin.isTTY)return null;let s=0;function u(){let n=process.stdout.rows??24;return Math.max(1,Math.min(o.length,n-4))}function d(){let n=u();process.stdout.write("\x1B[2J\x1B[H"),console.log(r.bold.yellow(`
|
|
3
|
+
AGENT SHOP`)+r.gray(` \u2014 arrow keys to navigate, enter to select, q to cancel
|
|
4
|
+
`));let c=Math.max(0,Math.min(s-Math.floor(n/2),o.length-n)),t=Math.min(c+n,o.length);for(let l=c;l<t;l++){let i=o[l],e=l===s,p=e?r.yellow(" \u25B8 "):" ",m=e?r.bold.white(i.name):r.gray(i.name),g=r.gray(` \u2014 ${i.description}`),h=r.gray.dim(` [${i.model.replace("claude-","")}]`);console.log(`${p}${m}${g}${h}`);}o.length>n&&console.log(r.gray(`
|
|
5
|
+
${c+1}-${t} of ${o.length}`));}return new Promise(n=>{let c=a.createInterface({input:process.stdin});process.stdin.setRawMode(true),a.emitKeypressEvents(process.stdin);function t(){process.stdin.removeListener("keypress",l);try{process.stdin.setRawMode(!1);}catch{}c.close(),process.stdout.write("\x1B[2J\x1B[H");}let l=(i,e)=>{e.name==="up"||e.ctrl&&e.name==="p"?(s=(s-1+o.length)%o.length,d()):e.name==="down"||e.ctrl&&e.name==="n"?(s=(s+1)%o.length,d()):e.name==="return"?(t(),n(o[s])):(e.name==="q"||e.name==="escape"||e.ctrl&&e.name==="c")&&(t(),n(null));};c.on("error",()=>{t(),n(null);}),c.on("close",()=>{t(),n(null);});try{d();}catch{t(),n(null);return}process.stdin.on("keypress",l);})}export{w as pickFromShop};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-YJM5QGP7.js'),T=async t=>{await e.orchestrator.runTask(t);},k=async(t,s)=>e.taskService.create({title:t,priority:s?.priority,description:s?.description,attachments:s?.attachments}),A=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,n)=>e.agentService.create({name:t,adapter:s??"claude",model:n?.model||void 0,role:n?.role||void 0,approval_policy:n?.approval_policy||void 0,skills:n?.skills||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(),n=3,rt=10,p=s.slice(0,n),d=s.slice(n,rt),u=async a=>(await e.runService.readEventsTail(a.id,30)).map(r=>({timestamp:r.timestamp,agentId:a.agent_id,taskId:a.task_id,type:r.type,data:r.data}));if(p.length>0){let a=(await Promise.all(p.map(u))).flat();a.sort((i,r)=>new Date(i.timestamp).getTime()-new Date(r.timestamp).getTime()),t(a.slice(-200));}if(d.length>0){let a=(await Promise.all(d.map(u))).flat();a.sort((i,r)=>new Date(i.timestamp).getTime()-new Date(r.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();},l=c.version()??"0.0.0",at=import('./update-check-HGMBDYHL.js').then(t=>t.checkForUpdateSWR(l)).catch(()=>null),o=false,g;try{await e.orchestrator.startWatch(),o=!0;}catch(t){g=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:k,onCancelTask:A,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:g,version:l,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.2",
|
|
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
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://github.com/oxgeneral/ORCH/stargazers"><img src="https://img.shields.io/github/stars/oxgeneral/ORCH?style=social" alt="GitHub Stars" /></a>
|
|
9
|
-
<a href="https://
|
|
9
|
+
<a href="https://www.orch.one/"><img src="https://img.shields.io/badge/website-orch.one-amber" alt="Website" /></a>
|
|
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-1020%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 # 1020 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/scripts/release.sh
CHANGED
|
@@ -14,8 +14,8 @@ VERSION="${NEW_VERSION#v}"
|
|
|
14
14
|
sed -i.bak "s/\.version('[^']*')/\.version('${VERSION}')/" src/bin/cli.ts
|
|
15
15
|
rm -f src/bin/cli.ts.bak
|
|
16
16
|
|
|
17
|
-
# Sync version into landing
|
|
18
|
-
sed -i.bak "s/v[0-9]*\.[0-9]*\.[0-9]
|
|
17
|
+
# Sync version into landing (hero badge, hero sidebar, footer)
|
|
18
|
+
sed -i.bak "s/v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/v${VERSION}/g" landing/index.html
|
|
19
19
|
rm -f landing/index.html.bak
|
|
20
20
|
|
|
21
21
|
# Commit and tag
|
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};
|
package/dist/agent-FRQKL7YI.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {d,a,e}from'./chunk-5AJ4LYO5.js';import {j,o,q,d as d$1,l,h,m}from'./chunk-L26TK7Y5.js';function T(h$1,o$1){let s=h$1.command("agent").description("Manage agents");s.command("add <name>").description("Add a new agent").requiredOption("--adapter <adapter>","Adapter type: claude, shell, codex, cursor").option("--role <role>","Agent role description").option("--command <cmd>","Shell command (for shell adapter)").option("--model <model>","Model name (for AI adapters)").option("--max-turns <n>","Max turns per run").option("--timeout <ms>","Timeout in ms").option("--approval-policy <policy>","suggest|auto|manual").option("--workspace-mode <mode>","shared|worktree|isolated").option("--skills <skills>","Comma-separated list of agent skills").option("-e, --edit","Open $EDITOR to write the role description").action(async(t,e$1)=>{await o$1.paths.requireInit();let a$1=e$1.role;if(e$1.edit){let n=d({name:t,model:e$1.model,role:a$1}),l=await a(n),d$1=e(l);d$1.name&&(t=d$1.name),d$1.model&&(e$1.model=d$1.model),d$1.role&&(a$1=d$1.role);}let i=await o$1.agentService.create({name:t,adapter:e$1.adapter,role:a$1,command:e$1.command,model:e$1.model,max_turns:e$1.maxTurns?parseInt(e$1.maxTurns,10):void 0,timeout_ms:e$1.timeout?parseInt(e$1.timeout,10):void 0,approval_policy:e$1.approvalPolicy,workspace_mode:e$1.workspaceMode,skills:e$1.skills?e$1.skills.split(",").map(n=>n.trim()):void 0});o$1.context.json?console.log(JSON.stringify(i,null,2)):o$1.context.quiet?console.log(i.id):j(`Added agent ${o(i.name)} (${i.adapter}) \u2192 ${i.id}`);}),s.command("list").description("List all agents").action(async()=>{await o$1.paths.requireInit();let t=await o$1.agentService.list();if(o$1.context.json){console.log(JSON.stringify(t,null,2));return}if(o$1.context.quiet){t.forEach(n=>console.log(n.id));return}if(t.length===0){console.log(`
|
|
3
|
-
No agents. Add one: ${q("orch agent add <name> --adapter claude")}
|
|
4
|
-
`);return}let e=["STATUS","AGENT","ADAPTER","TASK","TIME"],a=t.map(n=>[`${d$1(n.status)} ${n.status}`,o(n.name),n.adapter,n.current_task??q("\u2014"),q("\u2014")]);console.log(),l(e,a);let i=t.filter(n=>n.status==="running").length;console.log(`
|
|
5
|
-
${t.length} agents \xB7 ${i} running \xB7 ${h(t.reduce((n,l)=>n+(l.stats.tokens_used??0),0))} tokens total
|
|
6
|
-
`);}),s.command("status <id>").description("Show agent details").action(async t=>{await o$1.paths.requireInit();let e=await o$1.agentService.get(t);if(o$1.context.json){console.log(JSON.stringify(e,null,2));return}console.log(`
|
|
7
|
-
${e.name}`),console.log(` ${"\u2550".repeat(42)}`),console.log();let a=[["Adapter",`${e.adapter}${e.config.model?` (${e.config.model})`:""}`],["Status",`${d$1(e.status)} ${e.status}`],["Policy",e.config.approval_policy??"auto"]];e.current_task&&a.push(["Task",e.current_task]),e.role&&a.push(["Role",e.role]),e.config.skills?.length&&a.push(["Skills",e.config.skills.join(", ")]),m(a),console.log(`
|
|
8
|
-
Stats
|
|
9
|
-
${"\u2500".repeat(42)}`),m([["Tasks completed",String(e.stats.tasks_completed)],["Tasks failed",String(e.stats.tasks_failed)],["Total runs",String(e.stats.total_runs)],["Tokens used",h(e.stats.tokens_used??0)]]),console.log();}),s.command("edit <id>").description("Edit an agent in $EDITOR").action(async t=>{await o$1.paths.requireInit();let e$1=await o$1.agentService.get(t),a$1=d({name:e$1.name,model:e$1.config.model,role:e$1.role}),i=await a(a$1),n=e(i),l=await o$1.agentService.update(t,{name:n.name,role:n.role,model:n.model});o$1.context.json?console.log(JSON.stringify(l,null,2)):o$1.context.quiet?console.log(l.id):j(`Updated agent ${o(l.name)} (${l.id})`);}),s.command("remove <id>").description("Remove an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.remove(t),j(`Removed agent ${t}`);}),s.command("disable <id>").description("Disable an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.disable(t),j(`Disabled agent ${t}`);}),s.command("enable <id>").description("Enable an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.enable(t),j(`Enabled agent ${t}`);}),s.command("autonomous <id>").description("Toggle autonomous mode for an agent").option("--on","Enable autonomous mode").option("--off","Disable autonomous mode").action(async(t,e)=>{await o$1.paths.requireInit();let a=await o$1.agentService.get(t),i=e.on?true:e.off?false:!a.autonomous,n=await o$1.agentService.setAutonomous(t,i);o$1.context.json?console.log(JSON.stringify(n,null,2)):o$1.context.quiet?console.log(n.id):j(`Autonomous mode ${i?"enabled":"disabled"} for agent ${o(n.name)} (${n.id})`);});}export{T as registerAgentCommand};
|
package/dist/tui-G4XUFAIP.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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-TW35IULR.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};
|