@oxgeneral/orch 0.3.2 → 0.3.3
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-NN7HR7UE.js +20 -0
- package/dist/chunk-3MQNQ7QW.js +2 -0
- package/dist/{chunk-2UC4SVJB.js → chunk-BGHCY7WY.js} +7 -3
- package/dist/chunk-BGHCY7WY.js.map +1 -0
- package/dist/chunk-IS3YBE2B.js +3 -0
- package/dist/chunk-KPCT44WU.js +2 -0
- package/dist/chunk-NLQAJ7TW.js +147 -0
- package/dist/chunk-NLQAJ7TW.js.map +1 -0
- package/dist/{chunk-ZA5Z33GO.js → chunk-OQKREZUF.js} +1 -1
- package/dist/chunk-QFKVCNKL.js +2 -0
- package/dist/{chunk-MGFMVPRD.js → chunk-S3QYSBW4.js} +11 -4
- package/dist/chunk-S3QYSBW4.js.map +1 -0
- package/dist/{chunk-QEEM67OA.js → chunk-UIJYU3J7.js} +3 -3
- package/dist/{chunk-QEEM67OA.js.map → chunk-UIJYU3J7.js.map} +1 -1
- package/dist/claude-GQZNDJ6L.js +2 -0
- package/dist/{claude-RIB3RQS5.js → claude-INM52PTH.js} +13 -7
- package/dist/claude-INM52PTH.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/{clipboard-service-PDTSZIR5.js → clipboard-service-MYLSWM5E.js} +1 -1
- package/dist/{codex-VBUSA2GJ.js → codex-QGH2GRV6.js} +17 -9
- package/dist/codex-QGH2GRV6.js.map +1 -0
- package/dist/codex-SJV7ZZBY.js +2 -0
- package/dist/container-NEKK5W2B.js +6 -0
- package/dist/cursor-4JQOCP5X.js +2 -0
- package/dist/{cursor-4QIOTDBW.js → cursor-KQJTQ73D.js} +11 -6
- package/dist/cursor-KQJTQ73D.js.map +1 -0
- package/dist/{doctor-KBK5JZBZ.js → doctor-UAII4VWN.js} +1 -1
- package/dist/index.d.ts +53 -41
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/dist/{init-WRDFAFS2.js → init-2D4RAN7B.js} +1 -1
- package/dist/{logs-5QHJWMEG.js → logs-UXFXVYCP.js} +1 -1
- package/dist/orchestrator-KF4UY5GD.js +5 -0
- package/dist/{orchestrator-FGGXK3N3.js.map → orchestrator-KF4UY5GD.js.map} +1 -1
- package/dist/{orchestrator-R7IWZUT6.js → orchestrator-MFL3XK5L.js} +4 -4
- package/dist/shell-F42UUF3U.js +2 -0
- package/dist/{shell-IH2MMTVP.js → shell-UXJNTNBC.js} +7 -4
- package/dist/shell-UXJNTNBC.js.map +1 -0
- package/dist/{task-J6ZN7ALI.js → task-AP2TIOOF.js} +1 -1
- package/dist/{tui-LW7WIDE3.js → tui-PIQT4ZZ2.js} +1 -1
- package/dist/{workspace-manager-KOOYTO7E.js → workspace-manager-DYN3XJ7X.js} +1 -1
- package/dist/{workspace-manager-T6AXG7XL.js → workspace-manager-EVD67GCG.js} +4 -4
- package/dist/{workspace-manager-T6AXG7XL.js.map → workspace-manager-EVD67GCG.js.map} +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/dist/App-YJM5QGP7.js +0 -19
- package/dist/chunk-2UC4SVJB.js.map +0 -1
- package/dist/chunk-GZ2Q56YZ.js +0 -2
- package/dist/chunk-IQXRQBUK.js +0 -83
- package/dist/chunk-IQXRQBUK.js.map +0 -1
- package/dist/chunk-L3FYR45M.js +0 -2
- package/dist/chunk-MGFMVPRD.js.map +0 -1
- package/dist/chunk-MNXU3KCD.js +0 -2
- package/dist/chunk-UW6GUUE6.js +0 -3
- package/dist/claude-E36EGXUV.js +0 -2
- package/dist/claude-RIB3RQS5.js.map +0 -1
- package/dist/codex-OTZKVESD.js +0 -2
- package/dist/codex-VBUSA2GJ.js.map +0 -1
- package/dist/container-OIXLFSX2.js +0 -6
- package/dist/cursor-3DJA6LWS.js +0 -2
- package/dist/cursor-4QIOTDBW.js.map +0 -1
- package/dist/orchestrator-FGGXK3N3.js +0 -5
- package/dist/shell-EOJBDWTH.js +0 -2
- package/dist/shell-IH2MMTVP.js.map +0 -1
package/dist/App-YJM5QGP7.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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};
|