@oxgeneral/orch 0.2.4 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App-5EVJSOEL.js +19 -0
- package/dist/agent-FRQKL7YI.js +9 -0
- package/dist/{orchestrator-OMU46RCE.js → chunk-2UC4SVJB.js} +190 -53
- package/dist/chunk-2UC4SVJB.js.map +1 -0
- package/dist/chunk-5AJ4LYO5.js +8 -0
- package/dist/{chunk-45K2XID7.js → chunk-6DWHQPTE.js} +2 -1
- package/dist/chunk-6DWHQPTE.js.map +1 -0
- package/dist/{chunk-POUC4CPC.js → chunk-6MJ7V6VY.js} +2 -2
- package/dist/{chunk-HNKJ4IF7.js → chunk-B4JQM4NU.js} +34 -10
- package/dist/chunk-B4JQM4NU.js.map +1 -0
- package/dist/{chunk-6HENRUYZ.js → chunk-CDFA4IIQ.js} +2 -2
- package/dist/chunk-CHRW4CLD.js +2 -0
- package/dist/{chunk-VAAOW526.js → chunk-GZ2Q56YZ.js} +2 -2
- package/dist/{doctor-service-QEJCE5FK.js → chunk-HMMPM7MF.js} +2 -2
- package/dist/{chunk-AELEEEV3.js → chunk-HSBYJ5C5.js} +27 -7
- package/dist/chunk-HXOMNULD.js +2 -0
- package/dist/{chunk-3TGCIXJA.js → chunk-IQXRQBUK.js} +2 -1
- package/dist/chunk-IQXRQBUK.js.map +1 -0
- package/dist/chunk-L26TK7Y5.js +2 -0
- package/dist/chunk-L3FYR45M.js +2 -0
- package/dist/chunk-LXNRCJ22.js +2 -0
- package/dist/{chunk-TX7WOFCW.js → chunk-MGFMVPRD.js} +4 -7
- package/dist/chunk-MGFMVPRD.js.map +1 -0
- package/dist/chunk-MNXU3KCD.js +2 -0
- package/dist/{chunk-CHIP7O6V.js → chunk-O2MSGW3V.js} +3 -1
- package/dist/chunk-O2MSGW3V.js.map +1 -0
- package/dist/chunk-PJ5DKXGR.js +2 -0
- package/dist/{chunk-2KSBOAW3.js → chunk-QEEM67OA.js} +11 -17
- package/dist/chunk-QEEM67OA.js.map +1 -0
- package/dist/chunk-UMZEA3JT.js +5 -0
- package/dist/{shell-OGTSH4RJ.js → chunk-UW6GUUE6.js} +3 -3
- package/dist/chunk-XDVMX2FO.js +8 -0
- package/dist/chunk-XDVMX2FO.js.map +1 -0
- package/dist/chunk-ZA5Z33GO.js +11 -0
- package/dist/claude-E36EGXUV.js +2 -0
- package/dist/{chunk-IRN2U2NE.js → claude-RIB3RQS5.js} +5 -2
- package/dist/claude-RIB3RQS5.js.map +1 -0
- package/dist/cli.js +1 -199
- package/dist/clipboard-service-PDTSZIR5.js +25 -0
- package/dist/codex-OTZKVESD.js +2 -0
- package/dist/{codex-U7LTJTX6.js → codex-VBUSA2GJ.js} +5 -3
- package/dist/codex-VBUSA2GJ.js.map +1 -0
- package/dist/config-CCSS2P7R.js +2 -0
- package/dist/container-OIXLFSX2.js +6 -0
- package/dist/context-GSMQHQES.js +7 -0
- package/dist/cursor-3DJA6LWS.js +2 -0
- package/dist/{cursor-3DI5GKRF.js → cursor-4QIOTDBW.js} +5 -3
- package/dist/cursor-4QIOTDBW.js.map +1 -0
- package/dist/doctor-KBK5JZBZ.js +2 -0
- package/dist/{chunk-K6DMQERQ.js → doctor-service-F2SXDWHS.js} +3 -1
- package/dist/doctor-service-F2SXDWHS.js.map +1 -0
- package/dist/doctor-service-PB7YBH3F.js +2 -0
- package/dist/goal-RFKFPR7M.js +8 -0
- package/dist/index.d.ts +105 -43
- package/dist/index.js +1817 -5
- package/dist/index.js.map +1 -1
- package/dist/init-WRDFAFS2.js +53 -0
- package/dist/logs-5QHJWMEG.js +12 -0
- package/dist/msg-4SCLBO4K.js +9 -0
- package/dist/orchestrator-FGGXK3N3.js +5 -0
- package/dist/{orchestrator-L6QX2LJ7.js.map → orchestrator-FGGXK3N3.js.map} +1 -1
- package/dist/orchestrator-R7IWZUT6.js +13 -0
- package/dist/process-manager-33H27MQF.js +2 -0
- package/dist/process-manager-A36Y7LHP.js +3 -0
- package/dist/{process-manager-TLZOTO4Y.js.map → process-manager-A36Y7LHP.js.map} +1 -1
- package/dist/registry-BO2PPRNG.js +2 -0
- package/dist/registry-JXXRLJ5J.js +3 -0
- package/dist/{registry-UQAHK77P.js.map → registry-JXXRLJ5J.js.map} +1 -1
- package/dist/run-HSHRELOP.js +3 -0
- package/dist/shell-EOJBDWTH.js +2 -0
- package/dist/{chunk-CIIE6LNG.js → shell-IH2MMTVP.js} +3 -2
- package/dist/shell-IH2MMTVP.js.map +1 -0
- package/dist/status-DLBNWSWM.js +2 -0
- package/dist/task-J6ZN7ALI.js +20 -0
- package/dist/team-MSIBKOQC.js +4 -0
- package/dist/template-engine-MFL5B677.js +3 -0
- package/dist/{template-engine-322SCRR6.js.map → template-engine-MFL5B677.js.map} +1 -1
- package/dist/template-engine-ONIDVD4F.js +2 -0
- package/dist/tui-DMGNSGBT.js +2 -0
- package/dist/update-PC2ENCKU.js +2 -0
- package/dist/update-check-HGMBDYHL.js +2 -0
- package/dist/workspace-manager-KOOYTO7E.js +3 -0
- package/dist/{workspace-manager-G5EQRS72.js → workspace-manager-T6AXG7XL.js} +4 -3
- package/dist/workspace-manager-T6AXG7XL.js.map +1 -0
- package/package.json +11 -2
- package/readme.md +8 -6
- package/scripts/benchmark.ts +304 -0
- package/dist/App-KHUT3IV7.js +0 -4962
- package/dist/agent-V5M2C3OC.js +0 -157
- package/dist/chunk-33QNTNR6.js +0 -46
- package/dist/chunk-6HENRUYZ.js.map +0 -1
- package/dist/chunk-AELEEEV3.js.map +0 -1
- package/dist/chunk-ED47GL3F.js +0 -29
- package/dist/chunk-FRTKB575.js +0 -87
- package/dist/chunk-HXYAZGLP.js +0 -15
- package/dist/chunk-I5WEMARW.js +0 -166
- package/dist/chunk-IZYSGYXG.js +0 -2
- package/dist/chunk-IZYSGYXG.js.map +0 -1
- package/dist/chunk-P6ATSXGL.js +0 -107
- package/dist/chunk-PBFE5V3G.js +0 -2
- package/dist/chunk-PBFE5V3G.js.map +0 -1
- package/dist/chunk-PNE6LQRF.js +0 -5
- package/dist/chunk-POUC4CPC.js.map +0 -1
- package/dist/chunk-QTDKQYZI.js +0 -11
- package/dist/chunk-QTDKQYZI.js.map +0 -1
- package/dist/chunk-VAAOW526.js.map +0 -1
- package/dist/chunk-ZTQ3KWXR.js +0 -13
- package/dist/chunk-ZTQ3KWXR.js.map +0 -1
- package/dist/claude-GH6P2DC5.js +0 -4
- package/dist/claude-S47YTIHU.js +0 -2
- package/dist/claude-S47YTIHU.js.map +0 -1
- package/dist/codex-2CH57B7G.js +0 -2
- package/dist/codex-2CH57B7G.js.map +0 -1
- package/dist/config-LJFM55LN.js +0 -75
- package/dist/container-KPH4HVAJ.js +0 -1532
- package/dist/context-EPSDCJTU.js +0 -83
- package/dist/cursor-QFUNKPCQ.js +0 -2
- package/dist/cursor-QFUNKPCQ.js.map +0 -1
- package/dist/doctor-GHRV5I2S.js +0 -67
- package/dist/doctor-service-QEJCE5FK.js.map +0 -1
- package/dist/doctor-service-TPOMFAIG.js +0 -2
- package/dist/goal-I56QP7HS.js +0 -110
- package/dist/init-EQTGQ4G2.js +0 -165
- package/dist/logs-AK255DEJ.js +0 -207
- package/dist/msg-SQWQLJP6.js +0 -95
- package/dist/orchestrator-L6QX2LJ7.js +0 -2
- package/dist/process-manager-HUVNAPQV.js +0 -2
- package/dist/process-manager-TLZOTO4Y.js +0 -2
- package/dist/registry-PQWRVNF2.js +0 -2
- package/dist/registry-UQAHK77P.js +0 -2
- package/dist/run-PSZURVVL.js +0 -95
- package/dist/shell-5ZNXFGXV.js +0 -3
- package/dist/shell-OGTSH4RJ.js.map +0 -1
- package/dist/status-DTF7D3DV.js +0 -56
- package/dist/task-35SDKXFC.js +0 -209
- package/dist/team-AISPLEJB.js +0 -97
- package/dist/template-engine-322SCRR6.js +0 -2
- package/dist/template-engine-3CDRZNMJ.js +0 -3
- package/dist/tui-AR6PVMBQ.js +0 -230
- package/dist/update-DCCWVISK.js +0 -64
- package/dist/update-check-4YKLGBFB.js +0 -2
- package/dist/workspace-manager-AS4TFA7R.js +0 -3
- package/dist/workspace-manager-AS4TFA7R.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a}from'./chunk-PJ5DKXGR.js';import {c,a as a$1}from'./chunk-HXOMNULD.js';import {f,g}from'./chunk-L26TK7Y5.js';import Fn,{useState,useEffect,useMemo,useRef,useCallback}from'react';import {Box,Text,useApp,useStdout,useInput}from'ink';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var e={amber:"#ffaf00",amberDim:"#af8700",green:"#5faf87",red:"#d75f5f",blue:"#5fafd7",yellow:"#d7af00",cyan:"#5fd7d7",purple:"#af87ff",white:"#eeeeee",silver:"#bcbcbc",gray:"#808080",dim:"#585858",ghost:"#3a3a3a",void:"#262626",errorBg:"#3d1515",warnBg:"#3d2e0a",successBg:"#0f2d1f",infoBg:"#1a1a22",toolBg:"#0f1f2d"},ye="\u2501",bt="\u2500",it="\xB7",Gt="\u25C8",oo="\u2605",Mt="\u27F3",_t="\u25C6",Cn={in_progress:e.green,retrying:e.yellow,review:e.blue,todo:e.dim,done:e.green,failed:e.red,cancelled:e.dim},No={active:e.green,paused:e.dim,achieved:e.amber,abandoned:e.ghost};var Os=120,ro=0,an=null,$n=new Set;function Ps(){an||(an=setInterval(()=>{ro++;for(let t of $n)t(ro);},Os));}function Ds(){an&&$n.size===0&&(clearInterval(an),an=null);}function zt(){let[t,n]=useState(ro);return useEffect(()=>{let o=l=>n(l);return $n.add(o),Ps(),()=>{$n.delete(o),Ds();}},[]),t}var Wo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Vt({color:t}){let n=zt();return jsx(Text,{color:t,children:Wo[n%Wo.length]})}var ln={in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6};var Gs="\u25CB",Go="\u2713",zo="\u2715",zs="\u21BB",Vs="\u2500",js="\u25B6",Tt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22"},Us={in_progress:{icon:js,label:"RUN",fg:e.green,bg:Tt.green,bold:true,spinner:true},retrying:{icon:zs,label:"RETRY",fg:e.yellow,bg:Tt.yellow,spinner:true},review:{icon:Gt,label:"REVIEW",fg:e.blue,bg:Tt.blue},todo:{icon:Gs,label:"TODO",fg:e.dim,bg:Tt.neutral},done:{icon:Go,label:"DONE",fg:e.green,bg:Tt.green},failed:{icon:zo,label:"FAIL",fg:e.red,bg:Tt.red,bold:true},cancelled:{icon:Vs,label:"OFF",fg:e.dim,bg:Tt.neutral}},Hs={1:{color:e.red,label:"!!!"},2:{color:e.yellow,label:"!!"},3:{color:e.dim,label:"!"},4:{color:e.ghost,label:it}};var vn=Fn.memo(function({task:n,selected:o,width:l,agentNameMap:d}){let f$1=Us[n.status],T=n.status==="in_progress"||n.status==="retrying",b=Hs[n.priority]??{color:e.ghost,label:it},y,x;if(n.status==="done")y=Go,x=e.green;else if(n.status==="failed")y=zo,x=e.red;else if(T){let G=Date.now()-new Date(n.updated_at).getTime();y=f(G),x=e.cyan;}else y="\u2014",x=void 0;let I=o?"\u25B8":" ",v=10,P=4,F=14,H=7,O=2+v+P+F+H,N=l?Math.max(10,l-O):40,D=n.assignee?d?.get(n.assignee)??n.assignee:void 0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[I," "]}),jsx(Box,{width:v,children:jsx(Text,{backgroundColor:f$1.bg,color:f$1.fg,bold:f$1.bold,children:f$1.spinner?jsxs(Fragment,{children:[" ",jsx(Vt,{color:f$1.fg})," ",f$1.label," "]}):jsxs(Fragment,{children:[" ",f$1.icon," ",f$1.label," "]})})}),jsx(Box,{width:P,children:jsx(Text,{color:b.color,bold:n.priority<=2,children:b.label})}),jsxs(Box,{width:N,children:[jsx(Text,{wrap:"truncate",bold:o||T,color:o?e.white:T?e.silver:void 0,children:n.title.length>N?n.title.slice(0,N-1)+"\u2026":n.title}),(n.attachments?.length??0)>0&&jsxs(Text,{color:e.dim,children:[" ","\u{1F4CE}",n.attachments.length]})]}),jsx(Box,{width:F,children:D?jsxs(Text,{backgroundColor:Tt.green,color:e.green,wrap:"truncate",children:[" ",D.length>F-2?D.slice(0,F-3)+"\u2026":D," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:H,justifyContent:"flex-end",children:jsx(Text,{color:x,dimColor:!x,children:y})})]})});var Ys="\u2715",Vo="\u25CB",Ks="\u25B6",Zs="\u2713",wt={green:"#0f2d1f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},Js={running:{icon:Ks,label:"ACTIVE",fg:e.green,bg:wt.green,bold:true,spinner:true},idle:{icon:Vo,label:"IDLE",fg:e.dim,bg:wt.neutral},error:{icon:Ys,label:"ERROR",fg:e.red,bg:wt.red,bold:true},disabled:{icon:Vo,label:"OFF",fg:e.ghost,bg:wt.neutral}},so={running:0,idle:1,error:2,disabled:3},Uo=Fn.memo(function({agent:n,selected:o,width:l,runningEntry:d,currentTaskTitle:f$1,teamName:T,isLead:b}){let y=Js[n.status],x=n.status==="running",I,v;if(x&&d){let R=Date.now()-new Date(d.started_at).getTime();I=f(R),v=e.cyan;}else n.stats.total_runs>0?(I=`${n.stats.tasks_completed}/${n.stats.total_runs}`,v=n.stats.tasks_completed>0?e.green:e.dim):(I="\u2014",v=void 0);let P=o?"\u25B8":" ",F=11,H=10,O=T?Math.min(T.length+2,14):0,N=Math.max(6,22-O),D=7,G=2+F+H+O+N+D,Y=l?Math.max(8,l-G):20,V,W,A=false;x&&f$1?(V=f$1,W=e.white,A=true):n.role?(V=n.role,W=e.dim):(V="\u2014",W=e.ghost);let C=n.stats.total_runs>0,M=C?Math.round(n.stats.tasks_completed/n.stats.total_runs*100):0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[P," "]}),jsx(Box,{width:F,children:jsx(Text,{backgroundColor:y.bg,color:y.fg,bold:y.bold,children:y.spinner?jsxs(Fragment,{children:[" ",jsx(Vt,{color:y.fg})," ",y.label," "]}):jsxs(Fragment,{children:[" ",y.icon," ",y.label," "]})})}),jsx(Box,{width:Y,children:jsxs(Text,{wrap:"truncate",bold:o||x,color:o?e.white:x?e.green:e.silver,children:[n.autonomous&&jsxs(Text,{color:e.cyan,children:[Mt," "]}),b&&jsxs(Text,{color:e.amber,children:[oo," "]}),n.name]})}),jsx(Box,{width:H,children:jsxs(Text,{backgroundColor:wt.neutral,color:e.dim,children:[" ",n.adapter," "]})}),T&&jsx(Box,{width:O,children:jsxs(Text,{backgroundColor:wt.amber,color:e.amber,wrap:"truncate",children:[" ",T," "]})}),jsx(Box,{width:N,children:jsx(Text,{color:W,bold:A,wrap:"truncate",children:V})}),jsx(Box,{width:D,justifyContent:"flex-end",children:C&&!x?jsxs(Text,{color:M>=80?e.green:M>=50?e.yellow:e.red,children:[I," ",Zs]}):jsx(Text,{color:v,dimColor:!v,children:I})})]})});function Ho({teamName:t,memberCount:n,leadName:o,width:l}){let d=`${n} agent${n!==1?"s":""}`,f=o?` ${it} ${oo} ${o}`:"",T=` ${Gt} ${t.toUpperCase()} ${it} ${d}${f} `,b=3,y=Math.max(0,l-b-T.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:"\u2500".repeat(b)}),jsx(Text,{backgroundColor:wt.amber,color:e.amber,bold:true,children:T}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(y)})]})}var Qs="\u25C7";function Xo({memberCount:t,width:n}){let o=`${t} agent${t!==1?"s":""}`,l=` ${Qs} UNASSIGNED ${it} ${o} `,d=3,f=Math.max(0,n-d-l.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:"\u2500".repeat(d)}),jsx(Text,{backgroundColor:wt.neutral,color:e.dim,children:l}),jsx(Text,{color:e.ghost,children:"\u2500".repeat(f)})]})}var qo="\u2713",Yo="\u2715",ti="\u2016",ni="\u25C9",dn={green:"#0f2d1f",amber:"#2d1f0a",neutral:"#1a1a22"},oi={active:{icon:ni,label:"ACTIVE",fg:e.green,bg:dn.green,bold:true},paused:{icon:ti,label:"PAUSED",fg:e.dim,bg:dn.neutral},achieved:{icon:qo,label:"DONE",fg:e.amber,bg:dn.amber,bold:true},abandoned:{icon:Yo,label:"DROP",fg:e.ghost,bg:dn.neutral}},Ko=Fn.memo(function({goal:n,selected:o,width:l,agentNameMap:d}){let f=oi[n.status],T=o?"\u25B8":" ",b=11,y=14,x=7,I=2+b+y+x,v=l?Math.max(10,l-I):40,P=n.assignee?d?.get(n.assignee)??n.assignee:void 0,F,H;if(n.status==="achieved")F=qo,H=e.amber;else if(n.status==="abandoned")F=Yo,H=e.ghost;else {let O=Date.now()-new Date(n.created_at).getTime(),N=Math.floor(O/864e5);F=N>0?`${N}d`:"<1d",H=e.dim;}return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[T," "]}),jsx(Box,{width:b,children:jsxs(Text,{backgroundColor:f.bg,color:f.fg,bold:f.bold,children:[" ",f.icon," ",f.label," "]})}),jsx(Box,{width:v,children:jsx(Text,{wrap:"truncate",bold:o||n.status==="active",color:o?e.white:n.status==="active"?e.silver:void 0,children:n.title.length>v?n.title.slice(0,v-1)+"\u2026":n.title})}),jsx(Box,{width:y,children:P?jsxs(Text,{backgroundColor:dn.green,color:e.green,wrap:"truncate",children:[" ",P.length>y-2?P.slice(0,y-3)+"\u2026":P," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:x,justifyContent:"flex-end",children:jsx(Text,{color:H,dimColor:!H,children:F})})]})});var ri={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"};function Ht({label:t,width:n,color:o}){let l=n-4,d=` ${t} `,f=3,T=Math.max(0,l-f-d.length);return jsxs(Text,{color:o??e.ghost,children:[" ","\u2500".repeat(f),d,"\u2500".repeat(T)]})}function Zo({task:t,height:n,width:o,taskLogs:l,agentNameMap:d}){let f=Cn[t.status]??e.dim,T=t.priority<=2?t.priority===1?e.red:e.yellow:void 0,b=24,y=!!t.description?.trim(),x=!!t.proof?.agent_summary,I=(t.proof?.files_changed?.length??0)>0,v=(l?.length??0)>0,P=(t.attachments?.length??0)>0,F=y?t.description.split(`
|
|
3
|
+
`):[],H=x?t.proof.agent_summary.split(`
|
|
4
|
+
`):[],O=3;P&&(O+=2+t.attachments.length),y?(O+=1,O+=Math.min(F.length,Math.max(1,Math.ceil((n-10)*.3)))):x||(O+=2),x&&(O+=2),I&&(O+=1),v&&(O+=2);let N=Math.max(0,n-O),D=0,G=0;x&&v?(D=Math.max(1,Math.floor(N*.4)),G=Math.max(1,N-D)):x?D=N:v&&(G=N);let Y=y?F.slice(0,Math.max(1,Math.ceil((n-10)*.3))):[],V=H.slice(0,D);return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:b,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:f,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" assignee "}),jsx(Text,{color:t.assignee?e.green:e.dim,children:t.assignee?d?.get(t.assignee)??t.assignee:"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:b,children:[jsx(Text,{color:e.dim,children:" priority "}),jsxs(Text,{color:T,bold:t.priority<=2,children:["P",t.priority]})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" attempts "}),jsxs(Text,{children:[t.attempts,"/",t.max_attempts]})]})]}),jsxs(Box,{children:[jsxs(Box,{width:b,children:[jsx(Text,{color:e.dim,children:" labels "}),jsx(Text,{color:e.purple,children:t.labels.length>0?t.labels.join(", "):"\u2014"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" depends "}),jsx(Text,{dimColor:true,children:t.depends_on.length>0?t.depends_on.join(", "):"\u2014"})]})]}),P&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Ht,{label:`attachments (${t.attachments.length})`,width:o,color:e.dim}),t.attachments.map((W,A)=>jsxs(Text,{color:e.cyan,wrap:"truncate",children:[" ",W]},`a${A}`))]}),y&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),Y.map((W,A)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",W]},`d${A}`))]}),!y&&!x&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:" No description."})]}),x&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Ht,{label:"result",width:o,color:e.dim}),V.map((W,A)=>jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",W]},`r${A}`))]}),I&&jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" files "}),jsx(Text,{color:e.cyan,children:t.proof.files_changed.length}),jsx(Text,{color:e.dim,children:" changed"}),t.proof.branch&&jsxs(Fragment,{children:[jsxs(Text,{color:e.dim,children:[" ","\xB7"," "]}),jsx(Text,{color:e.cyan,children:t.proof.branch})]})]}),v&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Ht,{label:"activity",width:o,color:e.dim}),l.slice(-G).map((W,A)=>{let C=W.msgType??"info",M=ri[C]??"\u2502",R=W.color;C==="tool"?R=e.cyan:C==="file"?R=e.purple:C==="error"?R=e.red:C==="lifecycle"?R=e.green:C==="system"&&(R=e.dim);let ge=Math.max(10,o-12),ie=W.text.length>ge?W.text.slice(0,ge-1)+"\u2026":W.text;return jsxs(Box,{children:[jsxs(Text,{color:e.ghost,children:[" ",W.time," "]}),jsxs(Text,{color:C==="error"?e.red:e.dim,children:[M," "]}),jsx(Text,{color:R,bold:C==="lifecycle",children:ie})]},A)})]})]})}var Mn=[{key:"G",id:"goals",label:"GOALS"},{key:"T",id:"tasks",label:"TASKS"},{key:"A",id:"agents",label:"AGENTS"},{key:"L",id:"logs",label:"ACTIONS"}];var si="\u25CF",er="\u25CB",ii="\u2713",ai="\u2715",li="\u2191",ci="\u2193",di="\u03A3",ui="\u25B6",gi="\u21BB",Jo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],io=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],He={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"};function tr({color:t}){let n=zt();return jsx(Text,{color:t,children:Jo[n%Jo.length]})}function mi(){let t=zt(),n=Math.floor(t/10)%2===0;return jsx(Text,{color:n?e.amber:e.amberDim,bold:true,children:_t})}function fi({width:t,active:n}){let o=Math.max(4,Math.floor(t*.08)),l=2,d=zt(),f=Math.ceil((t+o)/l),T=n?d%(f*2):0;if(!n)return jsx(Box,{paddingX:1,children:jsx(Text,{color:e.ghost,children:ye.repeat(t)})});let b=T<f?T*l:(f*2-T)*l,y=Math.max(0,b-o),x=Math.min(t,b),I=y,v=Math.max(0,x-y),P=Math.max(0,t-x);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(I)}),jsx(Text,{color:e.amber,children:ye.repeat(v)}),jsx(Text,{color:e.ghost,children:ye.repeat(P)})]})}function pi({data:t,width:n,color:o}){if(t.length===0)return null;let l=t.slice(-n),d=Math.max(...l,1),f=l.map(T=>{let b=Math.round(T/d*(io.length-1));return io[b]??io[0]}).join("");return jsx(Text,{color:o,children:f})}function hi({projectName:t,activeView:n,mode:o,stats:l,uptime:d,width:f,version:T,latestVersion:b}){let y=o==="watching";return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:f,children:[jsxs(Box,{gap:0,children:[jsx(mi,{}),jsx(Text,{color:e.amber,bold:true,children:" ORCH"}),T&&jsxs(Text,{color:e.ghost,children:[" ",T]}),b&&b!==T&&jsxs(Text,{backgroundColor:He.green,color:e.green,bold:true,children:[" UPDATE ",b," "]}),jsxs(Text,{color:e.ghost,children:[" ",it," "]}),jsx(Text,{color:e.silver,children:t})]}),jsx(Box,{gap:0,children:Mn.map((x,I)=>{let v=n===x.id;return jsxs(Fn.Fragment,{children:[I>0&&jsx(Text,{children:" "}),v?jsxs(Text,{backgroundColor:e.amber,color:"#0a0a0c",bold:true,children:[" ",x.key," ",x.label," "]}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:x.key}),jsxs(Text,{color:e.dim,children:[" ",x.label.toLowerCase()]})]})]},x.id)})}),jsxs(Box,{gap:0,children:[y?jsxs(Text,{backgroundColor:He.green,color:e.green,bold:true,children:[" ",si," WATCHING"," "]}):jsxs(Text,{backgroundColor:He.neutral,color:e.dim,children:[" ",er," IDLE"," "]}),l.running>0&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{backgroundColor:He.green,color:e.green,children:[" ",jsx(tr,{color:e.green})," ",l.running," active"," "]})]}),d&&jsxs(Text,{color:e.ghost,children:[" ",d]})]})]})}function xi({stats:t,tokens:n,width:o,sparklineData:l}){let f=[{icon:ui,label:"RUN",count:t.running,fg:e.green,bg:He.green,bold:true,spinner:true,show:t.running>0},{icon:gi,label:"RETRY",count:t.retrying,fg:e.yellow,bg:He.yellow,show:t.retrying>0},{icon:Gt,label:"REVIEW",count:t.review,fg:e.blue,bg:He.blue,show:t.review>0},{icon:er,label:"TODO",count:t.todo,fg:e.dim,bg:He.neutral,show:t.todo>0},{icon:ii,label:"DONE",count:t.done,fg:e.green,bg:He.green,show:t.done>0},{icon:ai,label:"FAIL",count:t.failed,fg:e.red,bg:He.red,bold:true,show:t.failed>0},{icon:_t,label:"TEAMS",count:t.teams,fg:e.amber,bg:He.amber,show:t.teams>0}].filter(x=>x.show),T=n.total>0,b=x=>x>=1e3?`${(x/1e3).toFixed(1)}k`:String(x),y=l&&l.length>0?Math.min(16,l.length):0;return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:o,children:[jsxs(Box,{gap:1,children:[f.map(x=>jsx(Text,{backgroundColor:x.bg,color:x.fg,bold:x.bold,children:x.spinner?jsxs(Fragment,{children:[" ",jsx(tr,{color:x.fg})," ",x.count," ",x.label," "]}):jsxs(Fragment,{children:[" ",x.icon," ",x.count," ",x.label," "]})},x.label)),f.length===0&&jsxs(Text,{backgroundColor:He.neutral,color:e.dim,children:[" ","NO TASKS"," "]})]}),jsxs(Box,{gap:0,children:[y>0&&l&&jsxs(Fragment,{children:[jsx(pi,{data:l,width:y,color:e.amberDim}),jsx(Text,{children:" "})]}),T&&jsxs(Text,{backgroundColor:He.amber,color:e.cyan,children:[" ",li,b(n.input)," ",ci,b(n.output)," ",it," ",di,b(n.total)," "]})]})]})}var nr=Fn.memo(function(n){let o=Math.max(10,n.width-2),l=n.stats.running>0;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{height:1}),jsx(hi,{projectName:n.projectName,activeView:n.activeView,mode:n.mode,stats:n.stats,uptime:n.uptime,width:n.width,version:n.version,latestVersion:n.latestVersion}),jsx(Box,{height:1}),jsx(xi,{stats:n.stats,tokens:n.tokens,width:n.width,sparklineData:n.sparklineData}),jsx(fi,{width:o,active:l})]})});var Xt={goal:{sub:["add","list","show","status","delete"],help:"Manage goals"},task:{sub:["add","list","show","cancel","retry","assign","approve","reject","delete"],help:"Manage tasks"},agent:{sub:["add","list","disable","enable","delete","autonomous"],help:"Manage agents"},team:{sub:["create","list","join","leave","disband","set-lead"],help:"Manage teams"},run:{args:"[id]",help:"Run task (or selected)"},"run-all":{help:"Run all todo tasks"},watch:{help:"Start watch mode (auto-dispatch)"},pause:{help:"Pause watch mode"},config:{sub:["activity-filter","max-concurrent"],help:"TUI settings"},status:{help:"Show orchestrator status"},help:{help:"List all commands"},quit:{help:"Exit the TUI"}};function ao(t){if(!t.startsWith("/"))return null;let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let b=n;if(!b)return null;let y=Object.keys(Xt).find(x=>x.startsWith(b)&&x!==b);return y?y.slice(b.length):null}let l=n.slice(0,o),d=Xt[l];if(!d?.sub)return null;let f=n.slice(o+1);if(!f)return null;let T=d.sub.find(b=>b.startsWith(f)&&b!==f);return T?T.slice(f.length):null}function or(t){if(!t.startsWith("/"))return [];let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let b=n.toLowerCase(),y=[];for(let[x,I]of Object.entries(Xt))if(!b||x.startsWith(b)){let v=I.args?` ${I.args}`:"";if(y.push({cmd:`/${x}${v}`,desc:I.help,subs:I.sub?.join(" \xB7 ")}),b&&x===b&&I.sub)for(let P of I.sub)y.push({cmd:`/${x} ${P}`,desc:`${I.help}: ${P}`});}return y}let l=n.slice(0,o),d=Xt[l];if(!d?.sub)return [];let f=n.slice(o+1).toLowerCase(),T=[];for(let b of d.sub)(!f||b.startsWith(f))&&T.push({cmd:`/${l} ${b}`,desc:`${d.help}: ${b}`});return T}var Rn=class{entries=[];cursor=0;push(n){n&&(this.entries[this.entries.length-1]!==n&&(this.entries.push(n),this.entries.length>100&&this.entries.shift()),this.cursor=this.entries.length);}prev(){return this.entries.length===0?null:(this.cursor>0&&this.cursor--,this.entries[this.cursor]??null)}next(){return this.cursor<this.entries.length-1?(this.cursor++,this.entries[this.cursor]??null):(this.cursor=this.entries.length,null)}reset(){this.cursor=this.entries.length;}};var Ti="\u2588",rr=Fn.memo(function({mode:n,value:o,completion:l,activeView:d,canRun:f,canNew:T,canApprove:b,canReject:y,canCancel:x,canDelete:I,canUndo:v,canEdit:P,canForceStop:F,canToggleAuto:H,autoActive:O,canPause:N,isPaused:D,canToggleShowAll:G,showAllActive:Y,hasDetail:V,itemCount:W,itemLabel:A,width:C,hasSuggestions:M}){if(n==="command"){let R=M?" \u2191\u2193 select Tab fill Esc \u2715":" Enter exec \u2191\u2193 history Tab complete Esc \u2715",ge=Math.max(4,C-6-R.length-(l?.length??0)-1),ie=o.length>ge?"\u2026"+o.slice(-(ge-1)):o;return jsx(Box,{paddingX:2,justifyContent:"space-between",width:C,children:jsxs(Box,{children:[jsx(Text,{color:e.amber,children:"/ "}),jsx(Text,{color:e.white,children:ie}),l&&jsx(Text,{color:e.ghost,children:l}),jsx(Text,{color:e.amber,children:Ti}),jsx(Text,{color:e.dim,children:R})]})})}return jsxs(Box,{paddingX:2,justifyContent:"space-between",width:C,children:[jsxs(Text,{color:e.dim,children:[jsx(Text,{bold:true,color:e.gray,children:"\u2191\u2193"})," ",jsx(Text,{bold:true,color:e.gray,children:"Tab"}),"/",jsx(Text,{bold:true,color:e.gray,children:"\u2190\u2192"})," ",jsx(Text,{bold:true,color:e.gray,children:"/"})," cmd",T&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"N"})," new"]}),f&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"R"})," run"]}),x&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"C"})," cancel"]}),b&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.green,children:"A"})," approve"]}),y&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"X"})," reject"]}),P&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"E"})," edit"]}),F&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"S"})," stop"]}),N&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"P"}),D?" resume":" pause"]}),H&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"U"}),O?" auto off":" auto on"]}),G&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"S"}),Y?" collapse":" show all"]}),I&&!b&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"D"})," delete"]}),v&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.yellow,children:"Z"})," undo"]}),V&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Esc"})," close"]}),!V&&(d==="tasks"||d==="agents"||d==="goals")&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Enter"})," detail"]})," ",jsx(Text,{bold:true,color:e.gray,children:"Q"})," quit"]}),W>0&&jsxs(Text,{color:e.dim,children:[W," ",A]})]})});var Bn="\u2588";function ir({title:t,steps:n,onComplete:o,onCancel:l,width:d,height:f,onPasteImage:T,footerExtra:b}){let [y,x]=useState(0),[I,v]=useState({}),[P,F]=useState(()=>{let L=n.find(B=>!B.skip?.({}));return L?.type==="text"&&L.defaultValue?L.defaultValue:""}),[H,O]=useState(()=>{let L=n.find(B=>!B.skip?.({}));return L?.type==="text"&&L.defaultValue?L.defaultValue.length:0}),[N,D]=useState(()=>{let L=n.find(B=>!B.skip?.({}));return L?.type==="textarea"&&L.defaultValue?L.defaultValue.split(`
|
|
5
|
+
`):[""]}),[G,Y]=useState(0),[V,W]=useState(0),[A,C]=useState(()=>{let L=n.find(B=>!B.skip?.({}));if(L?.type==="select"&&L.defaultValue){let k=(L.getOptions?.({})??L.options??[]).findIndex(j=>j.value===L.defaultValue);return k>=0?k:0}return 0}),M=useMemo(()=>n.filter(L=>!L.skip?.(I)),[n,I]),R=M[y],ge=M.length,[Me,ot]=useState(new Set),qe=useMemo(()=>!R||R.type!=="select"&&R.type!=="multiselect"?[]:R.getOptions?.(I)??R.options??[],[R,I]),Ve=Math.min(A,Math.max(0,qe.length-1)),Ye=L=>{let B={...I,[R.id]:L};v(B),F(""),O(0),D([""]),Y(0),W(0),C(0),ot(new Set);let k=R.id,K=n.findIndex(Z=>Z.id===k)+1;for(;K<n.length;){let Z=n[K];if(Z&&!Z.skip?.(B))break;K++;}if(K>=n.length)o(B);else {let Z=n[K].id,$e=n.filter(Te=>!Te.skip?.(B)).findIndex(Te=>Te.id===Z);x($e>=0?$e:0);let me=n[K];if(me.type==="text"){let Te=me.defaultValue??"";F(Te),O(Te.length);}else if(me.type==="textarea"){let Te=me.defaultValue?me.defaultValue.split(`
|
|
6
|
+
`):[""];D(Te),Y(Te.length-1),W(Te[Te.length-1].length);}else if(me.type==="select"){let Te=me.getOptions?.(B)??me.options??[];if(me.defaultValue){let mt=Te.findIndex(Ze=>Ze.value===me.defaultValue);C(mt>=0?mt:0);}else C(0);}else me.type==="multiselect"&&(C(0),me.defaultValue?ot(new Set(me.defaultValue.split(","))):ot(new Set));}},Oe=()=>{if(y===0){l();return}let L=R.id,k=n.findIndex(Q=>Q.id===L)-1;for(;k>=0;){let Q=n[k];if(Q&&!Q.skip?.(I))break;k--;}if(k<0){l();return}let j=n[k].id,K=M.findIndex(Q=>Q.id===j);x(K>=0?K:0);let Z=n[k];if(Z.type==="text"){let Q=I[Z.id]??Z.defaultValue??"";F(Q),O(Q.length);}else if(Z.type==="textarea"){let Q=I[Z.id]??Z.defaultValue??"",$e=Q?Q.split(`
|
|
7
|
+
`):[""];D($e),Y($e.length-1),W($e[$e.length-1].length);}else if(Z.type==="multiselect"){C(0);let Q=I[Z.id];ot(Q?new Set(Q.split(",")):new Set);}else {let Q=Z.getOptions?.(I)??Z.options??[],$e=I[Z.id],me=Q.findIndex(Te=>Te.value===$e);C(me>=0?me:0);}};if(useInput((L,B)=>{if(R){if(B.escape){y===0?l():Oe();return}if(B.ctrl&&(L==="v"||L==="i")&&T&&(R.type==="text"||R.type==="textarea")){T();return}if(R.type==="text"){if(B.return){let k=P.trim();if(R.required&&!k)return;Ye(k);return}if(B.leftArrow){O(k=>Math.max(0,k-1));return}if(B.rightArrow){O(k=>Math.min(P.length,k+1));return}if(B.backspace||B.delete){if(H===0&&P.length===0&&y>0){Oe();return}H>0&&(F(k=>k.slice(0,H-1)+k.slice(H)),O(k=>k-1));return}L&&!B.ctrl&&!B.meta&&!B.escape&&(F(k=>k.slice(0,H)+L+k.slice(H)),O(k=>k+L.length));return}if(R.type==="textarea"){if(B.return&&!B.shift){let k=N.join(`
|
|
8
|
+
`).trim();if(R.required&&!k)return;Ye(k);return}if(B.return&&B.shift){D(k=>{let j=k[G]??"",K=j.slice(0,V),Z=j.slice(V),Q=[...k];return Q.splice(G,1,K,Z),Q}),Y(k=>k+1),W(0);return}if(B.upArrow){G>0&&(Y(k=>k-1),W(k=>Math.min(k,(N[G-1]??"").length)));return}if(B.downArrow){G<N.length-1&&(Y(k=>k+1),W(k=>Math.min(k,(N[G+1]??"").length)));return}if(B.leftArrow){V>0?W(k=>k-1):G>0&&(Y(k=>k-1),W((N[G-1]??"").length));return}if(B.rightArrow){let k=(N[G]??"").length;V<k?W(j=>j+1):G<N.length-1&&(Y(j=>j+1),W(0));return}if(B.backspace||B.delete){if(V===0&&G===0)return;if(V>0)D(k=>{let j=[...k],K=j[G]??"";return j[G]=K.slice(0,V-1)+K.slice(V),j}),W(k=>k-1);else {let k=(N[G-1]??"").length;D(j=>{let K=[...j],Z=K[G-1]??"",Q=K[G]??"";return K.splice(G-1,2,Z+Q),K}),W(k),Y(j=>j-1);}return}if(L&&!B.ctrl&&!B.meta&&!B.escape){let k=L.split(/\r?\n/);if(k.length===1)D(j=>{let K=[...j],Z=K[G]??"";return K[G]=Z.slice(0,V)+L+Z.slice(V),K}),W(j=>j+L.length);else {let j=G,K=V;D(Z=>{let Q=[...Z],$e=Q[j]??"",me=$e.slice(0,K),Te=$e.slice(K),mt=k[0]??"",Ze=k[k.length-1]??"",un=[me+mt,...k.slice(1,-1),Ze+Te];return Q.splice(j,1,...un),Q}),Y(j+k.length-1),W((k[k.length-1]??"").length);}}return}if(R.type==="select"||R.type==="multiselect"){if(B.upArrow||L==="k"){C(k=>Math.max(0,k-1));return}if(B.downArrow||L==="j"){C(k=>Math.min(qe.length-1,k+1));return}if(B.backspace||B.delete){Oe();return}if(R.type==="select"){if(B.return||B.tab){let k=qe[Ve];k&&Ye(k.value);return}if(L>="1"&&L<="9"){let k=parseInt(L,10)-1;if(k<qe.length){let j=qe[k];j&&Ye(j.value);}return}}else {if(L===" "){let k=qe[Ve];k&&ot(j=>{let K=new Set(j);return K.has(k.value)?K.delete(k.value):K.add(k.value),K});return}if(B.return){let k=Array.from(Me).join(",");Ye(k);return}}}}}),!R)return null;let Pe=`${y+1}/${ge}`,Ke=Math.max(2,f-4),we=0;Ve>=Ke&&(we=Ve-Ke+1);let De=qe.slice(we,we+Ke);return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsx(Text,{color:e.amber,bold:true,children:t}),jsxs(Text,{color:e.ghost,children:[" ",bt,bt," "]}),jsxs(Text,{color:e.dim,children:["step ",Pe]})]}),jsxs(Box,{children:[jsx(Text,{children:" "}),M.map((L,B)=>jsxs(Text,{color:B===y?e.amber:B<y?e.green:e.ghost,children:[B===y?"\u25CF":B<y?"\u2713":"\u25CB"," "]},L.id))]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.white,bold:true,children:[" ",R.label]}),!R.required&&jsx(Text,{color:e.dim,children:" (optional, Enter to skip)"})]}),R.type==="text"&&jsxs(Box,{children:[jsxs(Text,{color:e.amber,children:[" ",">"," "]}),P.length>0?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:P.slice(0,H)}),jsx(Text,{color:e.amber,children:Bn}),jsx(Text,{color:e.white,children:P.slice(H)})]}):R.placeholder?jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:R.placeholder}),jsx(Text,{color:e.amber,children:Bn})]}):jsx(Text,{color:e.amber,children:Bn})]}),R.type==="textarea"&&(()=>{let L=Math.max(3,f-6),B=0;G>=L&&(B=G-L+1);let k=N.slice(B,B+L),j=String(N.length).length;return jsxs(Box,{flexDirection:"column",children:[k.map((K,Z)=>{let Q=Z+B,$e=String(Q+1).padStart(j," "),me=Q===G;return jsxs(Box,{children:[jsxs(Text,{color:e.dim,children:[" ",$e," "]}),jsxs(Text,{color:e.ghost,children:["\u2502"," "]}),me?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:K.slice(0,V)}),jsx(Text,{color:e.amber,children:Bn}),jsx(Text,{color:e.white,children:K.slice(V)})]}):jsx(Text,{color:e.silver,children:K||" "})]},Q)}),N.length===1&&N[0]===""&&R.placeholder&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","".padStart(j," ")," ",R.placeholder]})})]})})(),R.type==="select"&&jsx(Box,{flexDirection:"column",children:De.map((L,B)=>{let k=B+we,j=k===Ve,K=k<9?`${k+1}`:" ";return jsxs(Box,{children:[jsx(Text,{color:j?e.amber:e.ghost,children:j?" \u25B8 ":` ${K} `}),jsx(Text,{color:j?e.white:e.silver,bold:j,children:L.label}),L.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",bt," ",L.hint.replace(/\n/g," ")]})]},L.value)})}),R.type==="multiselect"&&jsxs(Box,{flexDirection:"column",children:[De.map((L,B)=>{let j=B+we===Ve,K=Me.has(L.value);return jsxs(Box,{children:[jsx(Text,{color:j?e.amber:e.ghost,children:j?" \u25B8 ":" "}),jsx(Text,{color:K?e.green:e.dim,children:K?"[\u2713]":"[ ]"}),jsxs(Text,{color:j?e.white:e.silver,bold:j,children:[" ",L.label]}),L.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",bt," ",L.hint.replace(/\n/g," ")]})]},L.value)}),Me.size>0&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","\u2514"," ",Me.size," selected"]})})]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.ghost,children:[" ",R.type==="select"?"\u2191\u2193 select Enter confirm":R.type==="multiselect"?"\u2191\u2193 move Space toggle Enter confirm":R.type==="textarea"?"Shift+Enter newline Enter confirm \u2190\u2191\u2192\u2193 navigate":"\u2190\u2192 move Enter confirm",T&&(R.type==="text"||R.type==="textarea")?" Ctrl+V paste image":""," Esc ",y>0?"back":"cancel"]}),b&&jsxs(Text,{color:e.amber,children:[" ",b]})]})]})}var Si="\u256D",ki="\u256E",Ii="\u2570",Ci="\u256F",lt="\u2502";function $i({children:t,cw:n}){return jsxs(Text,{children:[jsx(Text,{color:e.ghost,children:lt}),jsxs(Text,{children:[" ",t.padEnd(n)," "]}),jsx(Text,{color:e.ghost,children:lt})]})}function En({cw:t}){return jsx($i,{cw:t,children:""})}function Ln({count:t,config:n,width:o}){if(t>=3)return null;let l=Math.min((o??44)-4,50),d=l-6,f=bt.repeat(l-2),T=jsxs(Text,{color:e.ghost,children:[Si,f,ki]}),b=jsxs(Text,{color:e.ghost,children:[Ii,f,Ci]});if(t>0){let x=n.hints[0],I=x?` ${x.key} ${x.label}`:"";return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[T,jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),jsx(Text,{color:e.amber,children:_t}),jsxs(Text,{color:e.silver,children:[" ",n.nudge.padEnd(d-2-I.length)]}),x&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",x.key]}),jsxs(Text,{color:e.gray,children:[" ",x.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]}),b]})}let y=n.hints.reduce((x,I,v)=>x+I.key.length+1+I.label.length+(v>0?3:0),0);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[T,jsx(En,{cw:d}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),jsx(Text,{color:e.amber,children:_t}),jsxs(Text,{color:e.white,bold:true,children:[" ",n.title]}),jsx(Text,{children:" ".repeat(Math.max(0,d-n.title.length-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]}),jsx(En,{cw:d}),n.description.map((x,I)=>jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),jsx(Text,{color:e.silver,children:x.padEnd(d)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]},I)),jsx(En,{cw:d}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[lt," "]}),n.hints.map((x,I)=>jsxs(Fn.Fragment,{children:[I>0&&jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amber,children:x.key}),jsxs(Text,{color:e.gray,children:[" ",x.label]})]},I)),jsx(Text,{children:" ".repeat(Math.max(0,d-y))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:lt})]}),jsx(En,{cw:d}),b]})}var cr=[{value:"claude-opus-4-6",label:"Claude Opus 4.6",hint:"most capable"},{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",hint:"fast, balanced"},{value:"claude-haiku-4-6",label:"Claude Haiku 4.6",hint:"fastest, cheapest"},{value:"claude-sonnet-4-5-20250929",label:"Claude Sonnet 4.5",hint:"extended thinking"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5",hint:"legacy"}],dr=[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex",hint:"default, balanced"},{value:"gpt-5.4",label:"GPT-5.4",hint:"latest"},{value:"gpt-5",label:"GPT-5",hint:"capable"},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",hint:"fast"},{value:"o3",label:"o3",hint:"reasoning"},{value:"o4-mini",label:"o4-mini",hint:"fast reasoning"},{value:"gpt-5-mini",label:"GPT-5 Mini",hint:"light"},{value:"gpt-5-nano",label:"GPT-5 Nano",hint:"cheapest"},{value:"codex-mini-latest",label:"Codex Mini",hint:"legacy"}],ur=[{value:"auto",label:"Auto",hint:"let Cursor decide"},{value:"composer-1.5",label:"Composer 1.5",hint:"latest agent"},{value:"composer-1",label:"Composer 1",hint:"stable agent"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex",hint:"OpenAI"},{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",hint:"Anthropic"}],gr=[{value:"",label:"Default",hint:"use shell adapter default"}],Ai=[{value:"claude",label:"Claude",hint:"Claude Code CLI"},{value:"codex",label:"Codex",hint:"OpenAI Codex CLI"},{value:"cursor",label:"Cursor",hint:"Cursor Agent CLI"},{value:"shell",label:"Shell",hint:"custom shell command"}],mr=[{value:"1",label:"P1 Critical",hint:"urgent, do first"},{value:"2",label:"P2 High",hint:"important"},{value:"3",label:"P3 Medium",hint:"default priority"},{value:"4",label:"P4 Low",hint:"nice to have"}],lr=80;function fr(t){return t.filter(n=>n.status!=="disabled").map(n=>{let o=(n.role??n.adapter).split(`
|
|
9
|
+
`)[0].trim(),l=o.length>lr?o.slice(0,lr-1)+"\u2026":o;return {value:n.id,label:n.name,hint:l}})}function On(t,n="Auto-assign",o="orchestrator picks the best agent"){return [{value:"",label:n,hint:o},...fr(t)]}var uo=[{value:"",label:"Skip",hint:"no role description"},{value:"Full-stack developer",label:"Full-stack developer",hint:"general purpose"},{value:"Frontend developer",label:"Frontend developer",hint:"React, CSS, UI"},{value:"Backend developer",label:"Backend developer",hint:"APIs, databases, services"},{value:"DevOps engineer",label:"DevOps engineer",hint:"CI/CD, infra, deploys"},{value:"QA / Test engineer",label:"QA / Test engineer",hint:"testing, quality"},{value:"Code reviewer",label:"Code reviewer",hint:"review PRs, find bugs"},{value:"Technical writer",label:"Technical writer",hint:"docs, READMEs"},{value:"__custom__",label:"Custom...",hint:"type your own"}];function pr(t){return [{value:"",label:"None",hint:"no team"},...(t??[]).filter(n=>n.status==="active").map(n=>({value:n.id,label:n.name,hint:`${n.members.length} members`}))]}function hr(t){let n=pr(t);return [{id:"name",label:"Agent name",type:"text",placeholder:"e.g. alpha, frontend-bot, reviewer",required:true},{id:"adapter",label:"Provider",type:"select",options:Ai},{id:"model",label:"Model",type:"select",getOptions:o=>o.adapter==="codex"?dr:o.adapter==="cursor"?ur:o.adapter==="shell"?gr:cr},{id:"role",label:"Role / specialization",type:"select",options:uo},{id:"role_custom",label:"Describe the role",type:"textarea",placeholder:"e.g. Specialist in React and TypeScript",skip:o=>o.role!=="__custom__"},{id:"team",label:"Join team",type:"select",options:n,skip:()=>n.length<=1}]}function xr(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0;return {name:t.name,adapter:t.adapter||"claude",role:n,model:t.model||void 0,approval_policy:"auto",team_id:t.team||void 0}}function br(t){let n=fr(t);return [{id:"name",label:"Team name",type:"text",placeholder:"e.g. frontend, backend, qa",required:true},{id:"lead",label:"Team lead",type:"select",options:n},{id:"members",label:"Team members",type:"multiselect",getOptions:o=>n.filter(l=>l.value!==o.lead),skip:o=>!n.some(l=>l.value!==o.lead)},{id:"description",label:"Description",type:"textarea",placeholder:"Optional team purpose..."}]}function Tr(t){let n=t.members?t.members.split(",").filter(Boolean):[];return {name:t.name,lead_agent_id:t.lead,member_agent_ids:n.length>0?n:void 0,description:t.description||void 0}}function yr(t){let n=On(t);return [{id:"title",label:"Task title",type:"text",placeholder:"What needs to be done?",required:true},{id:"priority",label:"Priority",type:"select",options:mr,defaultValue:"3"},{id:"assignee",label:"Assignee",type:"select",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Optional details, context, acceptance criteria..."}]}function wr(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description||void 0}}function Sr(t,n){let o=On(n,"None / Auto","remove assignee");return [{id:"title",label:"Task title",type:"text",defaultValue:t.title,required:true},{id:"priority",label:"Priority",type:"select",options:mr,defaultValue:String(t.priority)},{id:"assignee",label:"Assignee",type:"select",options:o,defaultValue:t.assignee??"",skip:()=>o.length<=1},{id:"description",label:"Description",type:"textarea",defaultValue:t.description||"",placeholder:"Optional details..."}]}function kr(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description??""}}function Ir(t,n){let o=uo.find(b=>b.value===t.role),l=o?t.role:t.role?"__custom__":"",d=t.adapter==="codex"?dr:t.adapter==="cursor"?ur:t.adapter==="shell"?gr:cr,f=pr(n),T=n?.find(b=>b.members.some(y=>y.agent_id===t.id))?.id;return [{id:"name",label:"Agent name",type:"text",defaultValue:t.name,required:true},{id:"model",label:"Model",type:"select",options:d,defaultValue:t.config.model??""},{id:"role",label:"Role / specialization",type:"select",options:uo,defaultValue:l},{id:"role_custom",label:"Describe the role",type:"textarea",defaultValue:t.role&&!o?t.role:"",placeholder:"e.g. Specialist in React and TypeScript",skip:b=>b.role!=="__custom__"},{id:"team",label:"Team",type:"select",options:f,defaultValue:T??"",skip:()=>f.length<=1}]}var Mi=[{value:"1",label:"1 agent",hint:"~0.5 GB RAM, 1 subprocess"},{value:"2",label:"2 agents",hint:"~1 GB RAM, 2 subprocesses"},{value:"3",label:"3 agents",hint:"~1.5 GB RAM, 3 subprocesses"},{value:"4",label:"4 agents",hint:"~2 GB RAM, 4 subprocesses"},{value:"6",label:"6 agents",hint:"~3 GB RAM, 6 subprocesses"},{value:"8",label:"8 agents",hint:"~4 GB RAM, 8 subprocesses"},{value:"10",label:"10 agents",hint:"~5 GB RAM, 10 subprocesses"}],_i=[{value:"all",label:"All",hint:"show everything"},{value:"text",label:"Text",hint:"agent output only"},{value:"tools",label:"Tools",hint:"tool calls, results, files"},{value:"errors",label:"Errors",hint:"errors only"},{value:"events",label:"Events",hint:"lifecycle, system events"}];function Cr(t,n){return [{id:"setting",label:"Setting",type:"select",options:[{value:"activity_filter",label:"Activity filter",hint:`current: ${t}`},{value:"max_concurrent",label:"Max concurrent agents",hint:`current: ${n}`}]},{id:"activity_filter",label:"Activity filter preset",type:"select",options:_i,defaultValue:t,skip:o=>o.setting!=="activity_filter"},{id:"max_concurrent",label:"Max concurrent agents",type:"select",options:Mi,defaultValue:String(n),skip:o=>o.setting!=="max_concurrent"}]}function $r(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0;return {name:t.name,role:n,model:t.model||void 0,team_id:t.team||void 0}}function Pn(t){let n=On(t,"Any agent","auto-assign to autonomous agents");return [{id:"title",label:"Goal title",type:"text",placeholder:"What should be achieved?",required:true},{id:"assignee",label:"Assignee",type:"select",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Detailed goal description, success criteria..."}]}function vr(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description||void 0}}function Ar(t,n){let o=On(n,"Any agent","auto-assign");return [{id:"title",label:"Goal title",type:"text",defaultValue:t.title,required:true},{id:"assignee",label:"Assignee",type:"select",options:o,defaultValue:t.assignee??"",skip:()=>o.length<=1},{id:"description",label:"Description",type:"textarea",defaultValue:t.description||"",placeholder:"Detailed goal description..."}]}function Mr(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description??""}}var _r=10,Rr=500,Gn=2048,Lt=500,go=new Set(["todo","failed","cancelled"]),Li={title:"Goals",description:["Define what your team should achieve.","The orchestrator breaks goals into tasks","and assigns them to agents automatically."],hints:[{key:"N",label:"new goal"},{key:"/",label:"commands"}],nudge:"Add more goals to keep your team focused."},Oi={title:"Tasks",description:["Units of work dispatched to agents.","Create them manually or let goals","generate them automatically."],hints:[{key:"N",label:"new task"},{key:"W",label:"start orchestrator"}],nudge:"Add more tasks to keep agents busy."},Pi={title:"Agents",description:["AI workers that execute your tasks.","Each agent uses an adapter (claude, codex,","cursor, shell) and has its own role."],hints:[{key:"N",label:"new agent"},{key:"W",label:"start orchestrator"}],nudge:"Add more agents to increase parallelism."},Br=5e3,Or=0;function Gl(){Or=0;}var Pr=/^\[[\w_]+\]$/;function Dr(t){return Pr.test(t)?{msgType:"lifecycle",color:e.dim}:t.startsWith("\u2699")?{msgType:"tool",color:e.dim}:t.startsWith("\u2190")?{msgType:"result",color:e.dim}:t.startsWith("\u2713")?{msgType:"lifecycle",color:e.dim}:t.startsWith("\u23F3")?{msgType:"info",color:e.silver}:{msgType:"output",color:e.silver}}var Er=["#5faf87","#5fafd7","#af87ff","#d7af00","#5fd7d7","#d787af","#afaf5f","#d7875f"];function zn(t,n){let o=n.findIndex(l=>l.id===t);return Er[o>=0?o%Er.length:0]}var Di=" ".repeat(9),Vn={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},Wn=["system","lifecycle","output","tool","result","error","file","info"],qt=[{label:"all",types:Wn},{label:"text",types:["output"]},{label:"tools",types:["tool","result","file"]},{label:"errors",types:["error"]},{label:"events",types:["lifecycle","system"]}];function mo(t){let o=(qt.findIndex(l=>l.types.length===t.size&&l.types.every(d=>t.has(d)))+1)%qt.length;return qt[o]}function zl({projectName:t,tasks:n,agents:o=[],state:l,onRunTask:d,onCreateTask:f,onCancelTask:T,onRetryTask:b,onAssignTask:y,onRunAll:x,onDisableAgent:I,onEnableAgent:v,onSubscribeEvents:P,onRefreshTasks:F,onRefreshAgents:H,onRefreshState:O,onLoadHistory:N,onAddAgent:D,onDeleteAgent:G,onApproveTask:Y,onRejectTask:V,onDeleteTask:W,onUpdateTask:A,onUpdateAgent:C,onForceStopAgent:M,onCreateTeam:R,onListTeams:ge,onJoinTeam:ie,onLeaveTeam:Me,onDisbandTeam:ot,onSetTeamLead:qe,onStartWatch:Ve,onStopWatch:Ye,onToggleAutonomous:Oe,onRefreshGoals:Ot,onCreateGoal:Pe,onUpdateGoal:Ke,onUpdateGoalStatus:we,onDeleteGoal:De,onGetGoalProgress:L,initialWatchActive:B,watchError:k,messageBatchMs:j=process.env.VITEST?0:80,initialActivityFilter:K="all",onSaveActivityFilter:Z,initialMaxConcurrent:Q=a.scheduling.max_concurrent_agents,onSaveMaxConcurrent:$e,version:me,latestVersion:Te}){let{exit:mt}=useApp(),{stdout:Ze}=useStdout(),[un,Vr]=useState({w:Ze?.columns??80,h:Ze?.rows??24});useEffect(()=>{if(!Ze)return;let i=()=>Vr({w:Ze.columns,h:Ze.rows});return Ze.on("resize",i),()=>{Ze.off("resize",i);}},[Ze]);let Yt=un.w,fo=un.h,[Je,jr]=useState(n),[Se,Ur]=useState(o),[je,Hr]=useState(l),[gn,jn]=useState(B??!!l.pid),[Un,po]=useState([]),[Xr,ho]=useState(void 0),[$,Pt]=useState("tasks"),[mn,fn]=useState(0),[Hn,xo]=useState(0),[Xn,bo]=useState(0),[ke,Kt]=useState(false),[Qe,To]=useState([]),[ve,_e]=useState("none"),[St,rt]=useState(""),[ft,et]=useState(null),[kt,Zt]=useState([]),[qr,Yr]=useState(0),[Kr,Zr]=useState(()=>new Set(Wn)),[Jt,qn]=useState(-1),[Jr,Qt]=useState(0),[Dt,Yn]=useState(()=>{let i=qt.find(w=>w.label===K);return new Set(i?.types??Wn)}),pn=useMemo(()=>qt.find(w=>w.types.length===Dt.size&&w.types.every(s=>Dt.has(s)))?.label??"all",[Dt]),Kn=useMemo(()=>Dt.size>=Wn.length?Qe:Qe.filter(i=>Dt.has(i.msgType??"info")),[Qe,Dt]),[yo,Qr]=useState(Q),hn=Fn.useRef(new Rn).current,[es,en]=useState(0),[wo,So]=useState(false),[ts,Zn]=useState(0),[ns,Jn]=useState(0),[os,tn]=useState(0),[xn,pt]=useState(0),[ht,ko]=useState([]),[Nt,Qn]=useState([]),bn=useRef(ht);bn.current=ht;let U=useCallback(async i=>{let[w,s,c,g,p]=await Promise.all([F?.()??Promise.resolve(Je),H?.()??Promise.resolve(Se),O?.()??Promise.resolve(je),i?.includeTeams?ge?.()??Promise.resolve(bn.current):Promise.resolve(null),Ot?.()??Promise.resolve(Un)]);jr(w),Ur(s),Hr(c),g!==null&&ko(g),po(p),B&&jn(!!c.pid);},[F,H,O,ge,Ot,B]),Ie=useMemo(()=>[...Je].sort((i,w)=>(ln[i.status]??9)-(ln[w.status]??9)),[Je]),xt=wo?Ie:Ie.slice(0,_r),nn=Ie.length-xt.length,E=Ie[mn],Tn=useMemo(()=>{let i=new Map;for(let w of Je)i.set(w.id,w.title);return i},[Je]),It=useMemo(()=>{let i=new Map;for(let w of Se)i.set(w.id,w.name);return i},[Se]),{agentTeamMap:Wt,activeTeamCount:on,teamLeadSet:rs}=useMemo(()=>{let i=new Map,w=new Set,s=0;for(let c of ht)if(c.status==="active"){s++,w.add(c.lead_agent_id);for(let g of c.members)i.set(g.agent_id,c.name);}return {agentTeamMap:i,activeTeamCount:s,teamLeadSet:w}},[ht]),Ae=useMemo(()=>{let i=[...Se];return i.sort((w,s)=>{let c=Wt.get(w.id),g=Wt.get(s.id);return c&&!g?-1:!c&&g?1:c&&g&&c!==g?c.localeCompare(g):(so[w.status]??9)-(so[s.status]??9)}),i},[Se,Wt]),X=Ae[Hn],Ue=useMemo(()=>[...Un].sort((i,w)=>(c[i.status]??9)-(c[w.status]??9)),[Un]),q=Ue[Xn],ss=useMemo(()=>q?Je.filter(i=>i.goalId===q.id):[],[q,Je]),eo=useRef(L);eo.current=L,useEffect(()=>{if(!q||!eo.current){ho(void 0);return}let i=false;return eo.current(q.id).then(w=>{i||ho(w);}).catch(()=>{}),()=>{i=true;}},[q?.id]);let Ct=useRef(new Map),yn=useRef(new Map);useEffect(()=>{for(let[i,w]of Object.entries(je.running))Ct.current.set(w.run_id,w.agent_id),yn.current.set(w.run_id,i);if(Ct.current.size>Rr){let i=Ct.current.size-Rr,w=0;for(let s of Ct.current.keys()){if(w++>=i)break;Ct.current.delete(s),yn.current.delete(s);}}},[je.running]);let $t=useRef([]),rn=useRef(null),to=useCallback(()=>{if(rn.current=null,$t.current.length===0)return;let i=$t.current;$t.current=[],To(w=>{if(i.length>=Lt)return i.slice(-Lt);let s=Lt-i.length;return (w.length>s?w.slice(-s):w).concat(i)});},[]);useEffect(()=>()=>{rn.current&&clearTimeout(rn.current);},[]);let r=useCallback((i,w,s)=>{let c=new Date,g=c.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),p=s?.detail&&s.detail.length>Gn?s.detail.slice(0,Gn)+"\u2026[truncated]":s?.detail;$t.current.push({text:i,color:w,time:g,ts:c.getTime(),...s,detail:p}),$t.current.length>Lt*2&&($t.current=$t.current.slice(-Lt)),j===0?to():rn.current||(rn.current=setTimeout(to,j));},[to]);useEffect(()=>{k&&r(`Watch mode failed: ${k}. Tasks will not auto-dispatch.`,e.red);},[]);let Ft=useCallback((i,w,s,c)=>{let g={key:++Or,entityType:i,entityId:w,entityName:s,expiresAt:Date.now()+Br,needsForceStop:c?.needsForceStop};Qn(p=>[...p,g]),r(`\u2717 "${s}" will be deleted in ${Math.round(Br/1e3)}s \u2014 press Z to undo`,e.yellow);},[r]),is=useCallback(()=>{Qn(i=>{if(i.length===0)return i;let w=i[i.length-1];return r(`\u21B6 Undo: "${w.entityName}" restored`,e.green),i.slice(0,-1)});},[r]),Io=useCallback(async i=>{try{i.entityType==="task"&&W?await W(i.entityId):i.entityType==="agent"?(i.needsForceStop&&M&&await M(i.entityId),G&&await G(i.entityId)):i.entityType==="goal"&&De&&await De(i.entityId),r(`\u2713 Deleted "${i.entityName}"`,e.green),U();}catch(w){r(`Failed to delete "${i.entityName}": ${w instanceof Error?w.message:String(w)}`,e.red);}},[W,G,De,M,r,U]),Co=useRef(Io);Co.current=Io,useEffect(()=>{if(Nt.length===0)return;let i=setInterval(()=>{let w=Date.now(),s=[];Qn(c=>{let g=c.filter(p=>p.expiresAt<=w?(s.push(p),false):true);return s.length>0?g:c});for(let c of s)Co.current(c);},1e3);return ()=>clearInterval(i)},[Nt.length>0]),useEffect(()=>{if(!N)return;let i=w=>{let s=new Date(w.timestamp).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),c=typeof w.data=="string"?w.data:JSON.stringify(w.data),g,p=e.silver,m="output";if(w.type==="error")g=typeof w.data=="string"?w.data:JSON.stringify(w.data),g=g.slice(0,200),p=e.red,m="error";else if(w.type==="file_changed")g=String(w.data),p=e.purple,m="file";else if(w.type==="done")g="Completed",p=e.green,m="lifecycle";else if(w.type==="tool_call")g=`\u2699 ${w.data?.name??"tool"}()`,p=e.cyan,m="tool";else {let{summary:h}=zr(c);if(!h)return null;g=h;let z=Dr(g);m=z.msgType,p=z.color;}return {text:g,color:p,time:s,ts:new Date(w.timestamp).getTime(),agentId:w.agentId,taskId:w.taskId,msgType:m}};N(w=>{if(w.length===0)return;let s=w.map(i).filter(c=>c!==null);To(c=>{let g=[...s,...c];return g.length>Lt?g.slice(-Lt):g});}).catch(()=>{});},[]),useEffect(()=>{ge?.().then(ko).catch(()=>{}),Ot?.().then(po).catch(()=>{});},[]);let wn=useCallback(()=>{et({title:"NEW AGENT",steps:hr(bn.current),kind:"agent"}),_e("wizard");},[]),Sn=useCallback(()=>{Zt([]),et({title:"NEW TASK",steps:yr(Se),kind:"task"}),_e("wizard");},[Se]),as=useCallback(async()=>{try{let{detectClipboardType:i,getClipboardImage:w}=await import('./clipboard-service-PDTSZIR5.js'),s=await i();if(s!=="image")return r(s==="text"?"Clipboard has text, not image":"Clipboard is empty",e.dim),s;let c=await w();if(!c)return r("Failed to read clipboard image",e.red),"empty";let{mkdtemp:g,writeFile:p}=await import('fs/promises'),{tmpdir:m}=await import('os'),{join:h}=await import('path'),z=await g(h(m(),"orch-paste-")),at=h(z,`clipboard-${Date.now()}.${c.ext}`);return await p(at,c.data),Zt(At=>[...At,at]),r(`\u{1F4CE} Image attached (${Math.round(c.data.length/1024)}KB)`,e.green),"image"}catch{return r("Clipboard paste failed",e.red),"empty"}},[r]),ls=useCallback(i=>{et({title:"EDIT TASK",steps:Sr(i,Se),kind:"edit_task",targetId:i.id}),_e("wizard");},[Se]),$o=useCallback(()=>{et({title:"NEW TEAM",steps:br(Se),kind:"team"}),_e("wizard");},[Se]),cs=useCallback(i=>{et({title:"EDIT AGENT",steps:Ir(i,ht),kind:"edit_agent",targetId:i.id}),_e("wizard");},[ht]),vo=useCallback(()=>{et({title:"SETTINGS",steps:Cr(pn,yo),kind:"config"}),_e("wizard");},[pn,yo]),ds=useCallback(i=>{_e("none");let w=ft?.kind,s=ft?.targetId;if(et(null),w==="agent"&&D){let c=xr(i);r(`Creating agent "${c.name}"...`,e.amber),D(c.name,c.adapter,{model:c.model,role:c.role,approval_policy:c.approval_policy}).then(g=>{r(`\u2713 Created agent "${g.name}" (${g.id}, ${g.adapter})`,e.green),c.team_id&&ie?ie(c.team_id,g.id).then(p=>{r(`\u2713 Joined team "${p.name}"`,e.green),U({includeTeams:true});},p=>r(`Failed to join team: ${p instanceof Error?p.message:String(p)}`,e.red)):U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(w==="team"&&R){let c=Tr(i);r(`Creating team "${c.name}"...`,e.amber),R(c).then(g=>{r(`\u2713 Created team "${g.name}" (${g.id}, ${g.members.length} members)`,e.green),U({includeTeams:true});},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(w==="task"&&f){let c=wr(i),g=kt.length>0?[...kt]:void 0;Zt([]),r(`Creating "${c.title}"...`,e.amber),f(c.title,{priority:c.priority,description:c.description,attachments:g}).then(p=>{r(`\u2713 Created "${p.title}" (${p.id})${g?` \u{1F4CE}${g.length}`:""}`,e.green),c.assignee&&y&&y(p.id,c.assignee).catch(()=>{}),U();},p=>r(`Failed: ${p instanceof Error?p.message:String(p)}`,e.red));}else if(w==="edit_task"&&s&&A){let c=kr(i),g=kt.length>0?[...kt]:void 0;Zt([]),r("Updating task...",e.amber),A(s,{...c,attachments:g}).then(p=>{r(`\u2713 Updated "${p.title}"${g?` \u{1F4CE}${g.length}`:""}`,e.green),c.assignee&&y&&y(s,c.assignee).catch(()=>{}),U();},p=>r(`Failed: ${p instanceof Error?p.message:String(p)}`,e.red));}else if(w==="edit_agent"&&s&&C){let c=$r(i),g=c.team_id??"",p=ht.find(m=>m.members.some(h=>h.agent_id===s))?.id??"";r("Updating agent...",e.amber),C(s,{name:c.name,role:c.role,model:c.model}).then(m=>{r(`\u2713 Updated agent "${m.name}"`,e.green);let h=[];p&&p!==g&&Me&&h.push(Me(p,s).then(z=>r(`\u2713 Left team "${z.name}"`,e.green),z=>r(`Failed to leave team: ${z instanceof Error?z.message:String(z)}`,e.red))),g&&g!==p&&ie&&h.push(ie(g,s).then(z=>r(`\u2713 Joined team "${z.name}"`,e.green),z=>r(`Failed to join team: ${z instanceof Error?z.message:String(z)}`,e.red))),Promise.all(h).then(()=>U({includeTeams:h.length>0}));},m=>r(`Failed: ${m instanceof Error?m.message:String(m)}`,e.red));}else if(w==="config"){if(i.setting==="activity_filter"&&i.activity_filter){let c=qt.find(g=>g.label===i.activity_filter);c&&(Yn(new Set(c.types)),Z?.(c.label),r(`Activity filter: ${c.label}`,e.amber));}else if(i.setting==="max_concurrent"&&i.max_concurrent){let c=parseInt(i.max_concurrent,10);c>0&&(Qr(c),$e?.(c),r(`Max concurrent agents: ${c}`,e.amber));}}else if(w==="goal"&&Pe){let c=vr(i);r(`Creating goal "${c.title}"...`,e.amber),Pe(c).then(g=>{r(`\u2713 Created goal "${g.title}" (${g.id})`,e.green),U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(w==="edit_goal"&&s&&Ke){let c=Mr(i);r("Updating goal...",e.amber),Ke(s,c).then(g=>{r(`\u2713 Updated goal "${g.title}"`,e.green),U();},g=>r(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}},[ft,D,f,R,ie,Me,y,A,C,Oe,Pe,Ke,r,U,Z,$e,ht,kt]),us=useCallback(()=>{_e("none"),et(null),Zt([]);},[]);useEffect(()=>{if(!P)return;let i=null,w=()=>{i||(i=setTimeout(()=>{i=null,U().catch(()=>{});},150));},s=P(c=>{c.type==="agent:started"&&(Ct.current.set(c.runId,c.agentId),yn.current.set(c.runId,c.taskId)),ra(c,r,Ct.current,yn.current),(c.type==="task:status_changed"||c.type==="task:created"||c.type==="task:assigned"||c.type==="agent:started"||c.type==="agent:completed"||c.type==="run:retry"||c.type==="goal:created"||c.type==="goal:status_changed"||c.type==="goal:updated"||c.type==="goal:deleted")&&w();});return ()=>{s(),i&&clearTimeout(i);}},[P,r,U]);let no=gn?"watching":"idle",gs=je.started_at?g(je.started_at):void 0,ms=je.stats.total_tokens.total,Ao=useMemo(()=>{let i={running:0,retrying:0,review:0,todo:0,done:0,failed:0,cancelled:0};for(let w of Je)w.status==="in_progress"?i.running++:w.status==="retrying"?i.retrying++:w.status==="review"?i.review++:w.status==="todo"?i.todo++:w.status==="done"?i.done++:w.status==="failed"?i.failed++:w.status==="cancelled"&&i.cancelled++;return {...i,teams:on}},[Je,on]);Ao.running;let fs={input:je.stats.total_tokens.input??0,output:je.stats.total_tokens.output??0,total:ms},kn=Math.max(4,fo-9),ps=Wt.size,hs=Se.length>ps,xs=on>0?on+(hs?1:0):0,bs=$==="goals"?Ue.length+1:$==="tasks"?xt.length+1+(nn>0?1:0):$==="agents"?Se.length+1+xs:0,Ts=Math.min(bs+1,Math.ceil(kn*.5)),xe=$==="logs"?kn:Math.max(2,Math.min(Ts,kn-4)),vt=Math.max(1,kn-xe),pe=Math.max(10,Yt-2),st=useMemo(()=>ve==="command"?or(St):[],[ve,St]);useEffect(()=>{en(i=>Math.min(i,Math.max(0,xt.length-xe)));},[xt.length,xe]),useEffect(()=>{Zn(i=>Math.min(i,Math.max(0,Ae.length-xe)));},[Ae.length,xe]),useEffect(()=>{Jn(i=>Math.min(i,Math.max(0,Ue.length-xe)));},[Ue.length,xe]);let ys=useCallback(i=>{let s=i.trim().replace(/^\//,"").split(/\s+/),c=s[0]?.toLowerCase();if(!c)return;let g=p=>p instanceof Error?p.message:String(p);switch(c){case "cancel":{if(!E){r("No task selected",e.yellow);return}if(!T)return;r(`Cancelling "${E.title}"...`,e.amber),T(E.id).then(()=>{r(`\u2713 Cancelled "${E.title}"`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "retry":{if(!E){r("No task selected",e.yellow);return}if(!b)return;r(`Retrying "${E.title}"...`,e.amber),b(E.id).then(()=>{r(`\u2713 Retried "${E.title}"`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "assign":{if(!E){r("No task selected",e.yellow);return}if(!y||!s[1]){r("Usage: assign <agent>",e.yellow);return}r(`Assigning "${E.title}" to ${s[1]}...`,e.amber),y(E.id,s[1]).then(()=>{r(`\u2713 Assigned "${E.title}" to ${s[1]}`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "task":{let p=s[1]?.toLowerCase();if(p==="add"){let m=s.slice(2).join(" ");if(!m){Sn();return}if(!f){r("Create not available",e.yellow);return}r(`Creating "${m}"...`,e.amber),f(m).then(h=>{r(`\u2713 Created "${h.title}" (${h.id})`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="list"){let m=Ie.map(h=>` ${h.id} ${h.status.padEnd(11)} ${h.title}`);if(m.length===0)r("No tasks",e.dim);else for(let h of m)r(h,e.cyan);}else if(p==="show"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}r(`${m.id} ${m.status} P${m.priority} "${m.title}"`,e.cyan),m.assignee&&r(` agent: ${m.assignee}`,e.dim),m.description&&r(` ${m.description.slice(0,100)}`,e.dim);}else if(p==="cancel"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(!T)return;r(`Cancelling "${m.title}"...`,e.amber),T(m.id).then(()=>{r(`\u2713 Cancelled "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="retry"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(!b)return;r(`Retrying "${m.title}"...`,e.amber),b(m.id).then(()=>{r(`\u2713 Retried "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="assign"){let m=s[2]?Ie.find(at=>at.id===s[2]):void 0,h=m??E,z=m?s[3]:s[2];if(!h){r("No task selected or id given",e.yellow);return}if(!z){r("Usage: /task assign [id] <agent>",e.yellow);return}if(!y)return;r(`Assigning "${h.title}" to ${z}...`,e.amber),y(h.id,z).then(()=>{r(`\u2713 Assigned "${h.title}" to ${z}`,e.green),U();},at=>r(`Failed: ${g(at)}`,e.red));}else if(p==="approve"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(m.status!=="review"){r(`Cannot approve \u2014 status is ${m.status}`,e.yellow);return}if(!Y)return;r(`Approving "${m.title}"...`,e.amber),Y(m.id).then(()=>{r(`\u2713 Approved "${m.title}"`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="reject"){let m=s[2]?Ie.find(z=>z.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(m.status!=="review"){r(`Cannot reject \u2014 status is ${m.status}`,e.yellow);return}if(!V)return;let h=s.slice(s[2]&&Ie.find(z=>z.id===s[2])?3:2).join(" ").trim()||void 0;r(`Rejecting "${m.title}"${h?" with feedback":""}...`,e.amber),V(m.id,h).then(()=>{r(`\u2713 Rejected "${m.title}" \u2192 todo`,e.green),U();},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="delete"){let m=s[2]?Ie.find(h=>h.id===s[2]):E;if(!m){r("No task selected or id given",e.yellow);return}if(m.status==="in_progress"){r("Cannot delete \u2014 task is running",e.yellow);return}if(!W)return;Ft("task",m.id,m.title);}else r("Usage: /task add|list|show|cancel|retry|assign|approve|reject|delete",e.yellow);return}case "agent":{let p=s[1]?.toLowerCase();if(p==="add"){let m=s[2];if(!m){wn();return}if(!D){r("Agent creation not available",e.yellow);return}let h=s[3];r(`Creating agent "${m}"...`,e.amber),D(m,h).then(z=>{r(`\u2713 Created agent "${z.name}" (${z.id}, ${z.adapter})`,e.green),U();},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="list"){let m=Ae.map(h=>` ${h.id} ${h.status.padEnd(8)} ${h.name} (${h.adapter})`);if(m.length===0)r("No agents",e.dim);else for(let h of m)r(h,e.cyan);}else if(p==="disable"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(!I)return;r(`Disabling ${m.name}...`,e.amber),I(m.id).then(()=>{r(`\u2713 Disabled ${m.name}`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="enable"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(!v)return;r(`Enabling ${m.name}...`,e.amber),v(m.id).then(()=>{r(`\u2713 Enabled ${m.name}`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="delete"||p==="remove"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(m.status==="running"){r("Cannot delete \u2014 agent is running",e.yellow);return}if(!G){r("Agent deletion not available",e.yellow);return}Ft("agent",m.id,m.name);}else if(p==="autonomous"||p==="auto"){let m=s[2]?Ae.find(h=>h.id===s[2]||h.name===s[2]):X;if(!m){r("No agent selected or id given",e.yellow);return}if(!Oe){r("Autonomous toggle not available",e.yellow);return}m.autonomous?(r(`Disabling autonomous mode for "${m.name}"...`,e.amber),Oe(m.id,false).then(()=>{r(`${Mt} ${m.name} autonomous OFF`,e.cyan),U();},h=>r(`Failed: ${g(h)}`,e.red))):(r(`Enabling autonomous mode for "${m.name}"...`,e.amber),Oe(m.id,true).then(()=>{r(`${Mt} ${m.name} autonomous ON`,e.cyan),U();},h=>r(`Failed: ${g(h)}`,e.red)));}else r("Usage: /agent add|list|disable|enable|delete|autonomous",e.yellow);return}case "team":{let p=s[1]?.toLowerCase();if(p==="create"||p==="add")$o();else if(p==="list"){let m=bn.current;if(m.length===0)r("No teams",e.dim);else for(let h of m)r(` ${h.id} ${h.status.padEnd(8)} ${h.name} (${h.members.length} members)`,e.cyan);}else if(p==="join"){if(!ie){r("Join not available",e.yellow);return}let m=s[2],h=s[3]??X?.id;if(!m||!h){r("Usage: /team join <teamId> [agentId]",e.yellow);return}r(`Joining team ${m}...`,e.amber),ie(m,h).then(z=>{r(`\u2713 Agent joined team "${z.name}"`,e.green),U({includeTeams:true});},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="leave"){if(!Me){r("Leave not available",e.yellow);return}let m=s[2],h=s[3]??X?.id;if(!m||!h){r("Usage: /team leave <teamId> [agentId]",e.yellow);return}r(`Leaving team ${m}...`,e.amber),Me(m,h).then(z=>{r(`\u2713 Agent left team "${z.name}"`,e.green),U({includeTeams:true});},z=>r(`Failed: ${g(z)}`,e.red));}else if(p==="disband"){if(!ot){r("Disband not available",e.yellow);return}let m=s[2];if(!m){r("Usage: /team disband <teamId>",e.yellow);return}r(`Disbanding team ${m}...`,e.amber),ot(m).then(()=>{r("\u2713 Team disbanded",e.green),U({includeTeams:true});},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="set-lead"){if(!qe){r("Set-lead not available",e.yellow);return}let m=s[2],h=s[3];if(!m||!h){r("Usage: /team set-lead <teamId> <agentId>",e.yellow);return}r(`Setting lead for team ${m}...`,e.amber),qe(m,h).then(z=>{r(`\u2713 New lead for team "${z.name}"`,e.green),U({includeTeams:true});},z=>r(`Failed: ${g(z)}`,e.red));}else r("Usage: /team create|list|join|leave|disband|set-lead",e.yellow);return}case "goal":{let p=s[1]?.toLowerCase();if(p==="add"||p==="create"){let m=s.slice(2).join(" ").trim();if(!m){let h=Pn(Se);et({title:"New Goal",steps:h,kind:"goal"}),_e("wizard");return}if(!Pe){r("Goal creation not available",e.yellow);return}r(`Creating goal "${m}"...`,e.amber),Pe({title:m}).then(h=>{r(`\u2713 Created goal "${h.title}" (${h.id})`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));}else if(p==="list"){let m=Ue.map(h=>` ${h.id} ${h.status.padEnd(8)} ${h.title}`);if(m.length===0)r("No goals",e.dim);else for(let h of m)r(h,e.cyan);}else if(p==="show"){let m=s[2]?Ue.find(h=>h.id===s[2]):q;if(!m){r("No goal selected or id given",e.yellow);return}r(`${m.id} ${m.status} "${m.title}"`,e.cyan),m.description&&r(` ${m.description.slice(0,100)}`,e.dim);}else if(p==="status"){let m=s[2]?Ue.find(At=>At.id===s[2]):void 0,h=m??q;if(!h){r("No goal selected or id given",e.yellow);return}let z=s[m?3:2];if(!z||!a$1.includes(z)){r("Usage: /goal status [id] <active|paused|achieved|abandoned>",e.yellow);return}let at=z;if(!we){r("Status update not available",e.yellow);return}r(`Updating goal status to ${at}...`,e.amber),we(h.id,at).then(At=>{r(`\u2713 Goal "${At.title}" \u2192 ${at}`,e.green),U();},At=>r(`Failed: ${g(At)}`,e.red));}else if(p==="delete"){let m=s[2]?Ue.find(h=>h.id===s[2]):q;if(!m){r("No goal selected or id given",e.yellow);return}if(!De){r("Goal deletion not available",e.yellow);return}Ft("goal",m.id,m.title);}else r("Usage: /goal add|list|show|status|delete",e.yellow);return}case "run":{let p=s[1]??E?.id;if(!p){r("No task selected or id given",e.yellow);return}if(!d){r("Run not available",e.yellow);return}let m=Ie.find(h=>h.id===p);if(m&&!go.has(m.status)){r(`Cannot run \u2014 status is ${m.status}`,e.yellow);return}r(`Running ${p}...`,e.amber),d(p).then(()=>{r(`\u2713 Dispatched ${p}`,e.green),U();},h=>r(`Failed: ${g(h)}`,e.red));return}case "run-all":{if(!x){r("Run-all not available",e.yellow);return}r("Running all todo tasks...",e.amber),x().then(()=>{r("\u2713 Dispatched all todo tasks",e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "watch":{if(gn){r("Watch mode already active",e.yellow);return}if(!Ve){r("Watch not available",e.yellow);return}r("Starting watch mode...",e.amber),Ve().then(()=>{jn(true),r("\u2713 Watch mode started",e.green);},p=>r(`Failed: ${g(p)}`,e.red));return}case "pause":{if(!gn){r("Watch mode not active",e.yellow);return}if(!Ye){r("Pause not available",e.yellow);return}r("Pausing watch mode...",e.amber),Ye().then(()=>{jn(false),r("\u2713 Watch mode paused",e.green);},p=>r(`Failed: ${g(p)}`,e.red));return}case "config":{s[1]?.toLowerCase()==="activity-filter"?Yn(m=>{let h=mo(m);return Z?.(h.label),r(`Activity filter: ${h.label}`,e.amber),new Set(h.types)}):vo();return}case "status":{let p=Je.filter(m=>m.status==="in_progress").length;r(`${no} ${p} running ${Je.length} tasks ${Ae.length} agents`,e.cyan);return}case "help":{for(let[p,m]of Object.entries(Xt)){let h=m.sub?" "+m.sub.join("|"):m.args?" "+m.args:"";r(` /${p}${h} \u2014 ${m.help}`,e.silver);}return}case "quit":{mt();return}case "disable":{if(!X){r("No agent selected",e.yellow);return}if(!I)return;r(`Disabling ${X.name}...`,e.amber),I(X.id).then(()=>{r(`\u2713 Disabled ${X.name}`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}case "enable":{if(!X){r("No agent selected",e.yellow);return}if(!v)return;r(`Enabling ${X.name}...`,e.amber),v(X.id).then(()=>{r(`\u2713 Enabled ${X.name}`,e.green),U();},p=>r(`Failed: ${g(p)}`,e.red));return}default:r(`Unknown: ${c}. Type /help for commands`,e.yellow);}},[E,X,Ie,Ae,Je,no,gn,T,b,y,x,d,f,I,v,D,Y,V,W,ie,Me,ot,qe,Ve,Ye,r,mt,U,Sn,wn,$o,vo]);useInput((i,w)=>{if(ve!=="none"){if(w.escape){_e("none"),rt(""),hn.reset();return}if(w.return){let s=St.trim();if(!s)return;if(ve==="new_task"){if(!f)return;_e("none"),rt(""),r(`Creating "${s}"...`,e.amber),f(s).then(c=>{r(`\u2713 Created "${c.title}" (${c.id})`,e.green),U();},c=>r(`Failed to create: ${c instanceof Error?c.message:String(c)}`,e.red));}else if(ve==="command"){let c=s;if(st.length>0&&st[xn]){let g=st[xn],p=g.cmd.replace(/\s+\[.*\]$/,"");if((p.startsWith(s)||s==="/")&&(c=p),g.subs&&!p.includes(" ")){rt(p+" "),pt(0);return}}_e("none"),rt(""),pt(0),hn.push(c),ys(c);}return}if(w.tab&&ve==="command"){if(st.length>0){let s=st[xn];if(s){let c=s.cmd.replace(/\s+\[.*\]$/,"");rt(c+(s.subs?" ":"")),pt(0);}}else {let s=ao(St);s&&rt(c=>c+s);}return}if(w.upArrow&&ve==="command"){if(st.length>0)pt(s=>Math.max(0,s-1));else {let s=hn.prev();s!==null&&rt(s);}return}if(w.downArrow&&ve==="command"){if(st.length>0)pt(s=>Math.min(st.length-1,s+1));else {let s=hn.next();rt(s??"");}return}if(w.backspace||w.delete){rt(s=>s.slice(0,-1)),pt(0);return}i&&!w.ctrl&&!w.meta&&(rt(s=>s+i),pt(0));return}if(i.toLowerCase()==="q"){mt();return}if(w.escape){if(ke){Kt(false),tn(0);return}if($==="logs"&&Jt>=0){qn(-1),Qt(0);return}return}if(i==="/"&&!ke){_e("command"),rt("/"),pt(0);return}if($==="logs"&&!ke&&i>="0"&&i<="9"){Yr(parseInt(i,10));return}if((i==="f"||i==="F")&&$==="logs"&&!ke){Zr(s=>new Set(mo(s).types));return}if((i==="z"||i==="Z")&&Nt.length>0){is();return}if((i==="f"||i==="F")&&($==="tasks"||$==="agents"||$==="goals")&&!ke){Yn(s=>{let c=mo(s);return Z?.(c.label),new Set(c.types)});return}if((i==="n"||i==="N")&&$==="tasks"&&!ke&&f){Sn();return}if((i==="n"||i==="N")&&$==="agents"&&!ke&&D){wn();return}if((i==="n"||i==="N")&&$==="goals"&&!ke&&Pe){let s=Pn(Se);et({title:"New Goal",steps:s,kind:"goal"}),_e("wizard");return}if((i==="e"||i==="E")&&$==="goals"&&q&&Ke){let s=Ar(q,Se);et({title:`Edit Goal: ${q.title}`,steps:s,kind:"edit_goal",targetId:q.id}),_e("wizard");return}if((i==="d"||i==="D")&&$==="goals"&&q&&De){Ft("goal",q.id,q.title);return}if((i==="c"||i==="C")&&$==="goals"&&q&&we){(q.status==="active"||q.status==="paused")&&(r(`Marking goal "${q.title}" as achieved...`,e.amber),we(q.id,"achieved").then(()=>{r(`\u2713 Goal "${q.title}" achieved`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="x"||i==="X")&&$==="goals"&&q&&we){(q.status==="active"||q.status==="paused")&&(r(`Abandoning goal "${q.title}"...`,e.amber),we(q.id,"abandoned").then(()=>{r(`\u2713 Goal "${q.title}" abandoned`,e.dim),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red)));return}if((i==="p"||i==="P")&&$==="goals"&&q&&we){let s=q.status==="paused"?"active":"paused";(q.status==="active"||q.status==="paused")&&we(q.id,s).then(()=>{r(`Goal "${q.title}" ${s}`,e.cyan),U();},c=>r(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if((i==="a"||i==="A")&&$==="tasks"&&E?.status==="review"&&Y){r(`Approving "${E.title}"...`,e.amber),Y(E.id).then(()=>{r(`\u2713 Approved "${E.title}"`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="x"||i==="X")&&$==="tasks"&&E?.status==="review"&&V){r(`Rejecting "${E.title}"...`,e.amber),V(E.id).then(()=>{r(`\u2713 Rejected "${E.title}" \u2192 todo`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="c"||i==="C")&&$==="tasks"&&E&&T){if(E.status==="done"||E.status==="failed"||E.status==="cancelled"){r(`Cannot cancel \u2014 status is ${E.status}`,e.yellow);return}r(`Cancelling "${E.title}"...`,e.amber),T(E.id).then(()=>{r(`\u2713 Cancelled "${E.title}"`,e.green),U();},s=>r(`Failed: ${s instanceof Error?s.message:String(s)}`,e.red));return}if((i==="e"||i==="E")&&$==="tasks"&&E&&A){ls(E);return}if((i==="e"||i==="E")&&$==="agents"&&X&&C){cs(X);return}if((i==="s"||i==="S")&&$==="tasks"){So(s=>!s),fn(0),en(0);return}if((i==="s"||i==="S")&&$==="agents"&&X&&M){if(!Object.values(je.running).some(c=>c.agent_id===X.id)&&X.status!=="running"){r(`Agent "${X.name}" is not running`,e.yellow);return}r(`Force-stopping agent "${X.name}"...`,e.amber),M(X.id).then(()=>{r(`\u2713 Stopped agent "${X.name}"`,e.green),U();},c=>r(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if((i==="d"||i==="D")&&$==="tasks"&&E&&E.status!=="in_progress"&&W){Ft("task",E.id,E.title);return}if((i==="d"||i==="D")&&$==="agents"&&X&&G){let s=Object.values(je.running).some(c=>c.agent_id===X.id);if(s&&!M){r(`Cannot delete \u2014 agent "${X.name}" is running. Press S to stop first.`,e.yellow);return}Ft("agent",X.id,X.name,{needsForceStop:s});return}if((i==="u"||i==="U")&&$==="agents"&&X&&Oe){let s=!X.autonomous;r(`${s?"Enabling":"Disabling"} autonomous mode for "${X.name}"...`,e.amber),Oe(X.id,s).then(()=>{r(`${Mt} ${X.name} autonomous ${s?"ON":"OFF"}`,e.cyan),U();},c=>r(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if(!ke){if(i==="g"||i==="G"){Pt("goals");return}if(i==="t"||i==="T"){Pt("tasks");return}if(i==="a"||i==="A"){Pt("agents");return}if(i==="l"||i==="L"){Pt("logs");return}}if(!ke){let s=Mn.map(g=>g.id),c=s.indexOf($);if(w.tab||w.rightArrow){Pt(s[(c+1)%s.length]);return}if(w.leftArrow){Pt(s[(c+s.length-1)%s.length]);return}}if(w.return){let s=nn>0?xt.length:-1;if($==="tasks"&&mn===s){So(g=>!g),fn(0),en(0);return}let c=xt.length+(nn>0?1:0);if($==="tasks"&&mn===c&&f){Sn();return}if($==="goals"&&Xn===Ue.length&&Pe){let g=Pn(Se);et({title:"New Goal",steps:g,kind:"goal"}),_e("wizard");return}if($==="agents"&&Hn===Ae.length&&D){wn();return}if($==="goals"&&q){Kt(g=>!g),tn(0);return}if($==="tasks"&&E){Kt(g=>!g);return}if($==="agents"&&X){Kt(g=>!g);return}if($==="logs"&&Jt>=0){Kt(g=>!g);return}}if((i==="r"||i==="R")&&$==="tasks"&&E&&d){if(!go.has(E.status)){r(`Cannot run "${E.title}" \u2014 status is ${E.status}`,e.yellow);return}r(`Running "${E.title}"...`,e.green),d(E.id).then(()=>{r(`Dispatched "${E.title}"`,e.green),U();},s=>r(`Failed to run: ${s instanceof Error?s.message:String(s)}`,e.red));return}if(w.upArrow||i==="k"){if($==="goals"&&ke){tn(s=>Math.max(0,s-1));return}$==="goals"?bo(s=>{let c=Math.max(0,s-1);return Jn(g=>c<g?c:g),c}):$==="tasks"?fn(s=>{let c=Math.max(0,s-1);return en(g=>c<g?c:g),c}):$==="agents"?xo(s=>{let c=Math.max(0,s-1);return Zn(g=>c<g?c:g),c}):$==="logs"&&qn(s=>{if(s===-1){let g=Qe.length-1;return Qt(Math.max(0,g-xe+2)),Math.max(0,g)}let c=Math.max(0,s-1);return Qt(g=>c<g?c:g),c});}if(w.downArrow||i==="j"){if($==="goals"&&ke){tn(s=>s+1);return}if($==="goals"){let s=Ue.length+(Pe?1:0)-1;bo(c=>{let g=Math.min(Math.max(0,s),c+1);return Jn(p=>g>=p+xe?g-xe+1:p),g});}else if($==="tasks"){let s=xt.length+(f?1:0)+(nn>0?1:0)-1;fn(c=>{let g=Math.min(Math.max(0,s),c+1);return en(p=>g>=p+xe?g-xe+1:p),g});}else if($==="agents"){let s=Ae.length+(D?1:0)-1;xo(c=>{let g=Math.min(Math.max(0,s),c+1);return Zn(p=>g>=p+xe?g-xe+1:p),g});}else $==="logs"&&qn(s=>{if(s===-1)return -1;let c=Qe.length-1;if(s>=c)return Qt(0),-1;let g=s+1;return Qt(p=>g>=p+xe-1?g-xe+2:p),g});}});let Ne=ve!=="none",Mo=Jt>=0?Qe[Jt]:void 0,_o=!Ne&&ke&&$==="tasks"&&E,Ro=!Ne&&ke&&$==="agents"&&X,Bo=!Ne&&ke&&$==="goals"&&q,ws=!Ne&&ke&&$==="logs"&&Mo,Ss=!Ne&&$==="tasks"&&E&&go.has(E.status)&&!!d,ks=!Ne&&!ke&&($==="goals"&&!!Pe||$==="tasks"&&!!f||$==="agents"&&!!D),Is=!Ne&&$==="tasks"&&E?.status==="review"&&!!Y,Cs=!Ne&&$==="tasks"&&E?.status==="review"&&!!V,$s=X?Object.values(je.running).some(i=>i.agent_id===X.id):false,vs=!Ne&&($==="goals"&&q&&!!De||$==="tasks"&&E&&E.status!=="in_progress"&&!!W||$==="agents"&&X&&!!G),As=!Ne&&!ke&&($==="goals"&&!!q&&!!Ke||$==="tasks"&&!!E&&!!A||$==="agents"&&!!X&&!!C),Ms=!Ne&&$==="agents"&&X&&($s||X.status==="running")&&!!M,_s=!Ne&&$==="agents"&&!!X&&!!Oe,Rs=!Ne&&$==="goals"&&!!q&&(q.status==="active"||q.status==="paused")&&!!we,Bs=!Ne&&Nt.length>0,Eo=ve==="command"&&st.length>0,Lo=ft?.kind==="task"||ft?.kind==="edit_task";return jsxs(Box,{flexDirection:"column",width:Yt,height:fo,children:[jsx(nr,{projectName:t,activeView:$,mode:no,stats:Ao,tokens:fs,uptime:gs,width:Yt,version:me,latestVersion:Te}),jsx(Box,{height:1}),$==="goals"&&jsx(Fi,{goals:Ue,selectedIndex:Xn,scrollOffset:ns,height:xe,width:pe,showAddRow:!!Pe,agentNameMap:It}),$==="tasks"&&jsx(zi,{tasks:xt,selectedIndex:mn,scrollOffset:es,height:xe,width:pe,showAddRow:!!f,agentNameMap:It,hiddenCount:nn}),$==="agents"&&jsx(Vi,{agents:Ae,selectedIndex:Hn,scrollOffset:ts,height:xe,width:pe,state:je,taskTitleMap:Tn,showAddRow:!!D,agentTeamMap:Wt,teamLeadSet:rs,activeTeamCount:on}),$==="logs"&&jsx(Xi,{messages:Qe,height:xe,agents:Ae,logFilter:qr,logTypeFilter:Kr,selectedIndex:Jt,scrollOffset:Jr,agentNameMap:It,taskTitleMap:Tn,width:pe}),jsx(Box,{height:1}),ve==="wizard"&&ft?jsx(ir,{title:ft.title,steps:ft.steps,onComplete:ds,onCancel:us,width:pe,height:vt,onPasteImage:Lo?as:void 0,footerExtra:kt.length>0&&Lo?`\u{1F4CE}${kt.length}`:void 0}):Eo?jsxs(Fragment,{children:[jsx(Dn,{label:"COMMANDS",width:pe}),jsx(Wi,{suggestions:st,selectedIndex:xn,height:Math.min(st.length,vt),width:pe})]}):ve==="new_task"?jsxs(Fragment,{children:[jsx(ta,{mode:ve,width:pe}),jsx(na,{mode:ve,value:St,width:pe})]}):_o?jsxs(Fragment,{children:[jsx(Ki,{task:E,width:pe}),jsx(Zo,{task:E,height:vt,width:pe,taskLogs:Qe.filter(i=>i.taskId===E.id),agentNameMap:It})]}):Bo?jsxs(Fragment,{children:[jsx(Dn,{label:`GOAL: ${q.title}`,width:pe}),jsx(Gi,{goal:q,height:vt,width:pe,agentNameMap:It,tasks:ss,progressReport:Xr,scrollOffset:os,onClampScroll:tn})]}):Ro?jsxs(Fragment,{children:[jsx(Zi,{agent:X,width:pe}),jsx(Ji,{agent:X,height:vt,state:je,taskTitleMap:Tn,teamName:Wt.get(X.id)})]}):ws?jsxs(Fragment,{children:[jsx(Dn,{label:"LOG",width:pe}),jsx(Yi,{message:Mo,height:vt,width:pe,agents:Ae,agentNameMap:It,taskTitleMap:Tn})]}):Qe.length>0&&$!=="logs"?jsxs(Fragment,{children:[(()=>{let i=` F:${pn.toUpperCase()} \u2502 ${Kn.length}/${Qe.length}`;return jsx(Dn,{label:"ACTIVITY",width:pe,suffixLen:i.length,suffix:jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" F:"}),jsx(Text,{color:e.amber,children:pn.toUpperCase()}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," ",Kn.length,"/",Qe.length]})]})})})(),jsx(qi,{messages:Kn,height:Math.max(1,vt-1),width:pe,agents:Ae,agentNameMap:It})]}):$==="goals"?jsx(Ln,{count:Ue.length,config:Li,width:pe}):$==="tasks"?jsx(Ln,{count:Ie.length,config:Oi,width:pe}):$==="agents"?jsx(Ln,{count:Ae.length,config:Pi,width:pe}):null,jsx(Box,{flexGrow:1}),Nt.length>0&&jsx(Ni,{deletions:Nt,width:Yt}),jsx(rr,{mode:ve==="command"?"command":"navigate",value:ve==="command"?St:"",completion:ve==="command"?ao(St):null,activeView:$,canRun:!!Ss,canNew:!!ks,canApprove:!!Is,canReject:!!Cs,canCancel:$==="tasks"&&!!E&&E.status==="in_progress"&&!!T,canDelete:!!vs,canUndo:!!Bs,canEdit:!!As,canForceStop:!!Ms,canToggleAuto:!!_s,autoActive:X?.autonomous,canPause:!!Rs,isPaused:q?.status==="paused",canToggleShowAll:$==="tasks"&&Ie.length>_r,showAllActive:wo,hasDetail:!!(_o||Ro||Bo),itemCount:$==="goals"?Ue.length:$==="tasks"?Ie.length:$==="agents"?Se.length:Qe.length,itemLabel:$==="goals"?"goals":$==="tasks"?"tasks":$==="agents"?"agents":"events",width:Yt,hasSuggestions:Eo})]})}var Ni=Fn.memo(function({deletions:n,width:o}){let[,l]=useState(0);useEffect(()=>{let f=setInterval(()=>l(T=>T+1),1e3);return ()=>clearInterval(f)},[]);let d=Date.now();return jsx(Box,{flexDirection:"column",width:o,children:n.map(f=>{let T=Math.max(0,Math.ceil((f.expiresAt-d)/1e3)),b=Math.max(0,o-4),y=f.entityType==="task"?"Task":f.entityType==="agent"?"Agent":"Goal",x=Math.max(10,b-y.length-30),I=f.entityName.length>x?f.entityName.slice(0,x-1)+"\u2026":f.entityName;return jsx(Box,{paddingX:2,children:jsxs(Text,{color:e.yellow,children:["\u2717 ",jsx(Text,{bold:true,children:y}),` "${I}" \u2014 `,jsxs(Text,{color:e.amber,bold:true,children:[T,"s"]}),jsx(Text,{color:e.dim,children:" \u2502 "}),jsx(Text,{color:e.gray,bold:true,children:"Z"}),jsx(Text,{color:e.dim,children:" undo"})]})},f.key)})})});function Wi({suggestions:t,selectedIndex:n,height:o,width:l}){let d=o,f=0;n>=d&&(f=n-d+1);let T=t.slice(f,f+d);return jsx(Box,{flexDirection:"column",paddingX:2,children:T.map((b,y)=>{let x=y+f,I=x===n,v=I?"\u25B6":" ",P=Math.min(20,Math.max(14,...t.map(D=>D.cmd.length+1))),F=b.cmd.padEnd(P),H=b.subs?` ${b.subs}`:"",O=Math.max(4,l-P-H.length-8),N=b.desc.length>O?b.desc.slice(0,O-1)+"\u2026":b.desc;return jsxs(Text,{wrap:"truncate",children:[jsx(Text,{color:I?e.amber:e.ghost,children:` ${v} `}),jsx(Text,{color:I?e.white:e.silver,bold:I,children:F}),jsx(Text,{color:e.dim,children:N}),H&&jsx(Text,{color:e.ghost,children:H})]},x)})})}function Fi({goals:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,showAddRow:f,agentNameMap:T}){let b=t.length,y=t.slice(o,o+l),x=f&&b>=o&&b<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[y.map((I,v)=>jsx(Box,{paddingX:2,children:jsx(Ko,{goal:I,selected:v+o===n,width:d-2,agentNameMap:T})},I.id)),x&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===b?e.amber:e.ghost,children:[n===b?" \u25B8 ":" ",jsx(Text,{color:n===b?e.amber:e.dim,children:"+ add goal..."})]})},"__add__")]})}function Gi({goal:t,height:n,width:o,agentNameMap:l,tasks:d,progressReport:f,scrollOffset:T=0,onClampScroll:b}){let x=Fn.useMemo(()=>{let O=d??[],N=t.assignee?l?.get(t.assignee)??t.assignee:"\u2014",D=Math.max(20,o-6),G=(M,R)=>{if(M.length<=R)return [M];let ge=[];for(let ie=0;ie<M.length;ie+=R)ge.push(M.slice(ie,ie+R));return ge},Y=f?f.split(`
|
|
10
|
+
`).flatMap(M=>G(M,D)):[],V=t.description?t.description.split(`
|
|
11
|
+
`).flatMap(M=>G(M,D)):[],W=No[t.status]??e.dim,A=new Map;for(let M of O)A.set(M.status,(A.get(M.status)??0)+1);let C=[];if(C.push({key:"row-status",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:W,bold:true,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" assignee "}),jsx(Text,{color:t.assignee?e.green:e.dim,children:N})]})]})}),C.push({key:"row-id",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" id "}),jsx(Text,{color:e.dim,children:t.id})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" created "}),jsx(Text,{children:t.created_at.slice(0,10)})]})]})}),t.updated_at&&t.updated_at!==t.created_at&&C.push({key:"row-updated",node:jsxs(Box,{children:[jsx(Box,{width:24,children:jsxs(Text,{color:e.dim,children:[" "," "]})}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" Updated "}),jsx(Text,{children:t.updated_at.slice(0,10)})]})]})}),O.length>0){let M=[];for(let[R,ge]of A)M.push(`${ge} ${R}`);C.push({key:"row-tasks-summary",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" tasks "}),jsx(Text,{color:e.cyan,children:O.length})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" "}),jsx(Text,{color:e.dim,children:M.join(" \xB7 ")})]})]})});}if(V.length>0){C.push({key:"desc-gap",node:jsx(Text,{children:" "})});for(let M=0;M<V.length;M++)C.push({key:`desc-${M}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",V[M]]})});}else C.push({key:"desc-gap",node:jsx(Text,{children:" "})}),C.push({key:"desc-empty",node:jsx(Text,{color:e.dim,children:" No description."})});if(Y.length>0){C.push({key:"prog-gap",node:jsx(Text,{children:" "})}),C.push({key:"prog-div",node:jsx(Ht,{label:"progress",width:o})});for(let M=0;M<Y.length;M++)C.push({key:`prog-${M}`,node:jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",Y[M]]})});}if(O.length>0){C.push({key:"tasks-gap",node:jsx(Text,{children:" "})}),C.push({key:"tasks-div",node:jsx(Ht,{label:`tasks (${O.length})`,width:o})});for(let M of O){let R=Cn[M.status]??e.dim;C.push({key:`task-${M.id}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",jsx(Text,{color:R,children:M.status.padEnd(12)}),M.title.slice(0,Math.max(10,o-22))]})});}}return C},[t,d,f,o,l]),I=Math.max(0,x.length-n),v=Math.min(T,I);Fn.useEffect(()=>{b&&v!==T&&b(v);},[v,T,b]);let P=x.length>n&&v<I,F=P?n-1:n,H=x.slice(v,v+F);return jsxs(Box,{flexDirection:"column",height:n,paddingX:2,children:[H.map(O=>jsx(Box,{children:O.node},O.key)),P&&jsxs(Text,{color:e.ghost,children:[" ","\u2193"," ",x.length-v-F," more ","\u2014"," ","\u2191","\u2193"," to scroll"]})]})}function zi({tasks:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,showAddRow:f,agentNameMap:T,hiddenCount:b=0}){let y=b>0,x=y?t.length:-1,I=t.length+(y?1:0),v=t.slice(o,o+l),P=y&&x>=o&&x<o+l,F=f&&I>=o&&I<o+l;return jsxs(Box,{flexDirection:"column",height:l,children:[v.map((H,O)=>jsx(Box,{paddingX:2,children:jsx(vn,{task:H,selected:O+o===n,width:d-2,agentNameMap:T})},H.id)),P&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===x?e.amber:e.ghost,children:[n===x?" \u25B8 ":" ",jsxs(Text,{color:n===x?e.amber:e.dim,children:["\u25BC"," Show all (",b," more) \u2014 press ",jsx(Text,{bold:true,color:e.gray,children:"S"})]})]})},"__show_all__"),F&&jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===I?e.amber:e.ghost,children:[n===I?" \u25B8 ":" ",jsx(Text,{color:n===I?e.amber:e.dim,children:"+ add task..."})]})},"__add__")]})}function Vi({agents:t,selectedIndex:n,scrollOffset:o=0,height:l,width:d,state:f,taskTitleMap:T,showAddRow:b,agentTeamMap:y,teamLeadSet:x,activeTeamCount:I}){let v=new Map;for(let A of Object.values(f.running))v.set(A.agent_id,A);let P=new Map;if(I&&I>0)for(let A of t){let C=y?.get(A.id);C&&P.set(C,(P.get(C)??0)+1);}let F=t.length,H=t.slice(o,o+l),O=b&&F>=o&&F<o+l,N=I!=null&&I>0,D=new Map;if(N&&x&&y){for(let A of t)if(x.has(A.id)){let C=y.get(A.id);C&&D.set(C,A.name);}}let G=0;for(let A of P.values())G+=A;let Y=t.length-G,V=[],W=o>0?y?.get(t[o-1]?.id??""):void 0;for(let A=0;A<H.length&&V.length<l;A++){let C=H[A],M=y?.get(C.id);if(N&&M&&M!==W&&(V.push(jsx(Ho,{teamName:M,memberCount:P.get(M)??0,leadName:D.get(M),width:d},`ts-${M}`)),V.length>=l)||N&&!M&&W&&(V.push(jsx(Xo,{memberCount:Y,width:d},"ts-unassigned")),V.length>=l))break;W=M,V.push(jsx(Box,{paddingX:2,children:jsx(Uo,{agent:C,selected:A+o===n,width:d-2,runningEntry:v.get(C.id),currentTaskTitle:C.current_task?T.get(C.current_task):void 0,teamName:M,isLead:x?.has(C.id)})},C.id));}return O&&V.length<l&&V.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===F?e.amber:e.ghost,children:[n===F?" \u25B8 ":" ",jsx(Text,{color:n===F?e.amber:e.dim,children:"+ add agent..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:l,children:V})}function Nr(t=5e3){let[n,o]=useState(Date.now());return useEffect(()=>{let l=setInterval(()=>o(Date.now()),t);return ()=>clearInterval(l)},[t]),n}function Wr(t,n){let o=Math.max(0,n-t);return o<3e3?"now":o<6e4?`${Math.floor(o/1e3)}s`:o<36e5?`${Math.floor(o/6e4)}m`:`${Math.floor(o/36e5)}h`}var ji=" \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Ui(t,n,o,l){let d=new Array(n).fill(0),f=l-n*o;for(let b of t){if(b.ts<f)continue;let y=Math.min(n-1,Math.floor((b.ts-f)/o));d[y]++;}let T=Math.max(1,...d);return d.map(b=>ji[Math.round(b/T*8)]).join("")}function Hi(t){if(t==="error")return e.errorBg}function Fr(t,n){switch(t){case "output":return e.white;case "tool":return e.dim;case "result":return e.dim;case "file":return e.gray;case "error":return e.red;case "lifecycle":return e.dim;case "system":return e.dim;default:return n}}function Xi({messages:t,height:n,agents:o,logFilter:l,logTypeFilter:d,selectedIndex:f,scrollOffset:T,agentNameMap:b,taskTitleMap:y,width:x}){let I=Nr(),v=useMemo(()=>t.filter(A=>{if(l!==0){let M=o[l-1];if(M&&A.agentId!==M.id)return false}let C=A.msgType??"info";return d.has(C)}),[t,o,l,d]);useMemo(()=>{let A={};for(let C of t){let M=C.msgType??"info";A[M]=(A[M]??0)+1;}return A},[t]);let F=useMemo(()=>{let A=new Map;for(let C of t)C.agentId&&A.set(C.agentId,(A.get(C.agentId)??0)+1);return A},[t]),H=useMemo(()=>Ui(v,30,1e4,I),[v,I]),O=d.size>=8?"all":d.size===1&&d.has("output")?"text":d.size===1&&d.has("error")?"errors":d.has("tool")&&!d.has("output")?"tools":d.has("lifecycle")&&!d.has("output")?"events":`${d.size} types`,N=n-3,D=f===-1?v.slice(-N):v.slice(T,T+N),G=f===-1?-1:f-T,Y=Math.min(10,Math.max(6,...o.map(A=>A.name.length))),V=11+Y,W=A=>{if(A===0)return true;let C=D[A],M=D[A-1];return C.agentId!==M.agentId?true:C.agentId?C.ts-M.ts>3e4:false};return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsxs(Box,{gap:0,children:[l===0?jsx(Text,{backgroundColor:e.infoBg,color:e.silver,bold:true,children:" \u25CF ALL "}):jsx(Text,{color:e.ghost,children:" \u25CB all "}),jsx(Text,{color:e.ghost,children:" "}),o.slice(0,9).map((A,C)=>{let M=zn(A.id,o),R=l===C+1,ge=F.get(A.id)??0,ie=ge>0?`\xB7${ge}`:"";return R?jsxs(Text,{backgroundColor:e.successBg,color:M,bold:true,children:[" ",C+1,":",A.name,ie," "]},A.id):jsxs(Text,{color:ge>0?e.dim:e.ghost,children:[" ",C+1,":",A.name,ie]},A.id)})]}),jsxs(Box,{gap:0,children:[O==="all"?jsx(Text,{color:e.dim,children:" F:all"}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,bold:true,children:[" F:",O.toUpperCase()," "]}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," "]}),jsxs(Text,{color:e.dim,children:[v.length," events"]}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," "]}),f===-1?jsxs(Box,{gap:0,children:[jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" "}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:jsx(Vt,{color:e.green})}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" LIVE "})]}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,children:[" \u2191\u2193 ",f+1,"/",v.length," "]}),jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amberDim,children:H}),jsx(Text,{color:e.ghost,children:" 5m"})]}),D.length===0?jsxs(Box,{flexDirection:"column",paddingX:2,paddingTop:1,children:[jsx(Text,{color:e.dim,children:t.length===0?" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E":"No events for current filter."}),t.length===0&&jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" \u2502 \u2502"}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u25C7"}),jsx(Text,{color:e.gray,children:" Waiting for activity "}),"\u2502"]}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u2502"}),jsx(Text,{color:e.dim,children:" Run tasks or start "}),"\u2502"]}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u2502"}),jsx(Text,{color:e.dim,children:" the orchestrator "}),"\u2502"]}),jsxs(Text,{color:e.dim,children:[" \u2502 ",jsx(Text,{color:e.ghost,children:"\u25C7"}),jsx(Text,{color:e.dim,children:" "}),"\u2502"]}),jsx(Text,{color:e.dim,children:" \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"})]})]}):D.map((A,C)=>{let M=C===G,R=A.msgType??"info",ge=Vn[R]??"\u2502",ie=A.agentId?b.get(A.agentId)??A.agentId.slice(0,8):void 0,Me=A.agentId?zn(A.agentId,o):void 0,ot=W(C),Ve=(C>0?D[C-1]:void 0)?.agentId===A.agentId&&!!A.agentId,Ye=!Ve&&!!ie,Oe=Ve&&!!ie,Ot=Fr(R,A.color),Pe=M?e.infoBg:R==="error"?e.errorBg:void 0,Ke=A.taskId?y.get(A.taskId):void 0,we=Wr(A.ts,I),De=Ke&&x>80?`#${Ke.slice(0,20)}`:"",L=De?De.length+3:0,B=Math.max(10,x-2-V-L),k=A.text.length>B?A.text.slice(0,B-1)+"\u2026":A.text;return jsxs(Box,{backgroundColor:Pe,children:[jsx(Text,{color:Me??e.ghost,children:ot&&Ye?"\u250C":Oe?"\u2502":" "}),jsx(Text,{color:M?e.amber:void 0,children:M?"\u25B8":" "}),jsx(Box,{width:5,children:jsx(Text,{color:we==="now"?e.green:M?e.silver:e.ghost,children:we.padStart(4)})}),jsx(Box,{width:Y+1,children:Ye?jsxs(Text,{color:Me,bold:true,children:[" ",ie.slice(0,Y).padEnd(Y)]}):Oe?jsxs(Text,{color:Me??e.ghost,children:[" ","\xB7".padEnd(Y)]}):jsxs(Text,{color:e.ghost,children:[" "," ".padEnd(Y)]})}),jsxs(Text,{color:R==="error"?e.red:Me??e.dim,children:[" ",ge," "]}),jsx(Text,{color:M?e.white:Ot,bold:M||R==="lifecycle",children:k}),De&&jsxs(Text,{color:e.ghost,children:[" ",jsx(Text,{color:e.dim,backgroundColor:e.void,children:` ${De} `})]})]},C)})]})}function qi({messages:t,height:n,width:o,agents:l,agentNameMap:d}){let f=Nr(),T=t.slice(-n),b=Math.max(10,o-2-17),y=Math.max(0,n-T.length),x=0,I=[];for(let v=0;v<T.length;v++)v>0&&T[v].agentId!==T[v-1].agentId&&x++,I.push(x);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[y>0&&jsx(Box,{height:y}),T.map((v,P)=>{let F=v.agentId?d.get(v.agentId)??v.agentId.slice(0,8):void 0,H=v.agentId?zn(v.agentId,l):void 0,O=v.msgType??"info",N=Vn[O]??"\u2502",D=Fr(O,v.color),Y=(P>0?T[P-1]:void 0)?.agentId===v.agentId&&!!v.agentId,V=(I[P]&1)===1,W=Hi(O)??(V?"#1a1a1a":void 0),A=Wr(v.ts,f),C=v.text.length>b?v.text.slice(0,b-1)+"\u2026":v.text;return jsxs(Box,{backgroundColor:W,children:[jsx(Text,{color:H??e.ghost,children:!Y&&F?"\u258D":Y?"\u258F":" "}),jsx(Box,{width:5,children:jsx(Text,{color:Y?e.ghost:A==="now"?e.green:e.dim,children:Y?" ":A.padStart(4)})}),jsx(Box,{width:9,children:F&&!Y?jsxs(Text,{color:H,bold:true,children:[" ",F.slice(0,8)]}):jsx(Text,{color:e.ghost,children:Di})}),jsxs(Text,{color:O==="error"?e.red:Y?e.ghost:H??e.dim,children:[N," "]}),jsx(Text,{color:D,children:C})]},P)})]})}function Yi({message:t,height:n,width:o,agents:l,agentNameMap:d,taskTitleMap:f}){let T=t.detail??t.text,b=t.msgType??"info",y=t.agentId?d.get(t.agentId)??t.agentId.slice(0,8):void 0,x=t.agentId?zn(t.agentId,l):e.dim,I=t.taskId?f.get(t.taskId):void 0,v,P=false;try{let N=JSON.parse(T);v=JSON.stringify(N,null,2),P=!0;}catch{v=T;}let F=Math.max(4,o-6),H=Math.max(1,n-4),O=v.split(`
|
|
12
|
+
`).slice(0,H);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u256D","\u2500".repeat(F+2),"\u256E"]})}),jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),jsx(Text,{color:e.dim,children:t.time}),jsx(Text,{color:e.ghost,children:" \u2502 "}),y&&jsx(Text,{color:x,bold:true,children:y}),y&&jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:Vn[b]?b==="error"?e.red:e.dim:e.dim,children:[Vn[b]??"\u2502"," ",b]}),I&&jsxs(Fragment,{children:[jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:e.dim,children:["#",I.slice(0,30)]})]})]}),jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),jsx(Text,{color:t.color,bold:true,wrap:"truncate",children:t.text.slice(0,F)})]}),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u251C","\u2500".repeat(F+2),"\u2524"]})}),O.map((N,D)=>jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),P&&jsxs(Text,{color:e.ghost,children:[String(D+1).padStart(3)," "]}),jsx(Text,{wrap:"truncate",color:P&&N.includes('"')?e.cyan:P&&/^\s*[}\]]/.test(N)?e.ghost:N.startsWith("error")||N.startsWith("Error")?e.red:e.silver,children:N.slice(0,P?F-4:F)})]},D)),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u2570","\u2500".repeat(F+2),"\u256F"]})})]})}function Dn({label:t,width:n,suffix:o,suffixLen:l=0}){let d=` ${t} `,f=3,T=f+d.length+2;if(!o){let x=Math.max(0,n-T);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(f)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:d}),jsx(Text,{color:e.ghost,children:ye.repeat(x)})]})}let b=2,y=Math.max(0,n-T-b-l);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(f)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:d}),jsx(Text,{color:e.ghost,children:ye.repeat(b)}),o,jsx(Text,{color:e.ghost,children:ye.repeat(y)})]})}function Ki({task:t,width:n}){let o=" DETAIL ",l=n-o.length-10,d=t.title.length>l?t.title.slice(0,l-3)+"...":t.title,f=Math.max(0,n-3-o.length-d.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:o}),jsxs(Text,{color:e.ghost,children:[ye," "]}),jsx(Text,{color:e.white,bold:true,children:d}),jsxs(Text,{color:e.ghost,children:[" ",ye.repeat(Math.max(0,f))]})]})}function Zi({agent:t,width:n}){let o=" AGENT ",l=n-o.length-10,d=t.name.length>l?t.name.slice(0,l-3)+"...":t.name,f=Math.max(0,n-3-o.length-d.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(3)}),jsx(Text,{backgroundColor:"#0f2d1f",color:e.green,bold:true,children:o}),jsxs(Text,{color:e.ghost,children:[ye," "]}),jsx(Text,{color:e.green,bold:true,children:d}),jsxs(Text,{color:e.ghost,children:[" ",ye.repeat(Math.max(0,f))]})]})}function Ji({agent:t,height:n,state:o,taskTitleMap:l,teamName:d}){let f=Qi[t.status]??e.dim;Object.values(o.running).find(x=>x.agent_id===t.id);let b=t.current_task?l.get(t.current_task):void 0,y=24;return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:y,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:f,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" adapter "}),jsx(Text,{color:e.cyan,children:t.adapter})]})]}),jsxs(Box,{children:[jsxs(Box,{width:y,children:[jsx(Text,{color:e.dim,children:" model "}),jsx(Text,{children:t.config.model??"\u2014"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" task "}),jsx(Text,{color:b?e.white:e.dim,children:b??"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:y,children:[jsx(Text,{color:e.dim,children:" runs "}),jsx(Text,{children:t.stats.total_runs}),jsx(Text,{color:e.dim,children:" ("}),jsx(Text,{color:e.green,children:t.stats.tasks_completed}),jsx(Text,{color:e.dim,children:"/"}),jsx(Text,{color:t.stats.tasks_failed>0?e.red:e.dim,children:t.stats.tasks_failed}),jsx(Text,{color:e.dim,children:")"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" team "}),jsx(Text,{color:d?e.amber:e.dim,children:d??"\u2014"})]})]}),t.autonomous&&jsx(Box,{children:jsxs(Box,{width:y,children:[jsx(Text,{color:e.dim,children:" auto "}),jsxs(Text,{color:e.cyan,children:[Mt," ON"]})]})}),t.config.skills&&t.config.skills.length>0&&jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" skills "}),jsx(Text,{color:e.cyan,wrap:"truncate",children:t.config.skills.join(", ")})]}),jsx(Text,{children:" "}),t.role?t.role.split(`
|
|
13
|
+
`).slice(0,Math.max(1,n-4)).map((x,I)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",x]},I)):jsx(Text,{color:e.dim,children:" No role description."})]})}var Qi={idle:e.dim,running:e.green,error:e.red,disabled:e.ghost},ea="\u2588";function ta({mode:t,width:n}){let l=` ${t==="command"?"COMMAND":"NEW TASK"} `,d=Math.max(0,n-3-l.length-2);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:ye.repeat(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:l}),jsx(Text,{color:e.ghost,children:ye.repeat(d)})]})}function na({mode:t,value:n,width:o}){let l=t==="command"?"/":"\u25B8",d=Math.max(10,o-8),f=n.length>d?n.slice(-d):n;return jsxs(Box,{paddingX:2,children:[jsxs(Text,{color:e.amber,children:[l," "]}),jsx(Text,{color:e.white,children:f}),jsx(Text,{color:e.amber,children:ea})]})}function Gr(t,n){if(!n||typeof n!="object")return "";let o=n;if(o.file_path&&typeof o.file_path=="string")return o.file_path.split("/").slice(-2).join("/");if(o.command&&typeof o.command=="string")return o.command.slice(0,60);if(o.pattern&&typeof o.pattern=="string")return `"${o.pattern.slice(0,40)}"`;if(o.glob&&typeof o.glob=="string")return o.glob.slice(0,40);let l=JSON.stringify(o);return l.length>80?l.slice(0,77)+"...":l}function Nn(t,n=200){if(typeof t=="string")return t.slice(0,n);if(!Array.isArray(t))return null;let o=[],l=0;for(let d of t){if(l>=n)break;if(d?.type==="text"&&typeof d.text=="string"){let f=d.text.split(`
|
|
14
|
+
`).find(T=>T.trim().length>0)??"";o.push(f.slice(0,n-l)),l+=f.length;}else if(d?.type==="tool_use"){let f=Gr(d.name??"tool",d.input),T=`\u2699 ${d.name??"tool"}(${f})`;o.push(T),l+=T.length;}else if(d?.type==="tool_result")o.push("\u2190 (result)"),l+=10;else if(d?.type==="thinking"&&typeof d.thinking=="string"){let f=d.thinking.slice(0,60).split(`
|
|
15
|
+
`)[0]??"";o.push(`\u{1F4AD} ${f}`),l+=f.length+3;}}return o.length>0?o.join(" "):null}function Lr(t){if(typeof t=="string"){let o=t.split(`
|
|
16
|
+
`).length,l=t.split(`
|
|
17
|
+
`).find(d=>d.trim().length>0)??"";return o>3?`${l.slice(0,80)}... (${o} lines)`:l.slice(0,120)}if(!Array.isArray(t))return "(result)";let n=[];for(let o of t)if(o?.type==="tool_result"){o.tool_use_id?o.tool_use_id.slice(0,8):"";let d=o.is_error,f=typeof o.content=="string"?o.content:"",T=f.split(`
|
|
18
|
+
`).length;d?n.push(`\u2715 error: ${f.slice(0,60)}`):T>3?n.push(`\u2713 ${T} lines`):n.push(`\u2713 ${f.slice(0,80)}`);}else o?.type==="text"&&typeof o.text=="string"&&n.push(o.text.split(`
|
|
19
|
+
`)[0]?.slice(0,80)??"");return n.join(" ")||"(result)"}function zr(t){let n=()=>t.length>Gn?t.slice(0,Gn)+"\u2026":t;if(Pr.test(t.trim()))return {summary:t.trim(),detail:n()};try{let o=JSON.parse(t);if(o.type==="message"&&o.role==="assistant"){let l=Nn(o.content);return l?{summary:l.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="assistant"||o.role==="assistant"){let l=o.message?.content??o.content,d=Nn(l);return d?{summary:d.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="user"||o.role==="user"){let l=o.message?.content??o.content;return {summary:`\u2190 ${Lr(l).slice(0,180)}`,detail:n()}}if(o.type==="tool_use"){let l=o.name??"tool",d=Gr(l,o.input);return {summary:`\u2699 ${l}(${d})`,detail:n()}}if(o.type==="tool_result")return {summary:`\u2190 ${Lr(o.content).slice(0,180)}`,detail:n()};if(o.type==="result"){let l=typeof o.result=="string"?o.result:null;return {summary:l?`\u2713 ${l.slice(0,180)}`:"\u2713 Agent finished",detail:n()}}if(o.type==="rate_limit_event")return {summary:`\u23F3 Rate limited (${o.rate_limit_info?.rateLimitType??"unknown"})`,detail:n()};if(o.subtype){if(o.message){let l=o.message.content??o.message,d=Nn(l);if(d)return {summary:d.slice(0,200),detail:n()}}return {summary:`[${o.subtype}]`,detail:n()}}if(o.content){let l=Nn(o.content);if(l)return {summary:l.slice(0,200),detail:n()}}return o.type?{summary:`[${o.type}]`,detail:n()}:{summary:t.slice(0,150),detail:n()}}catch{return {summary:oa(t),detail:n()}}}function oa(t){let n=t.match(/"subtype"\s*:\s*"([^"]+)"/);if(n)return `[${n[1]}]`;let o=t.match(/"type"\s*:\s*"([^"]+)"/),l=t.match(/"role"\s*:\s*"([^"]+)"/),d=o?.[1],f=l?.[1];if(!d&&!f)return t.slice(0,200);if(d==="assistant"||d==="message"||f==="assistant"){let T=t.match(/"text"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(T)try{return JSON.parse(`"${T[1]}"`).slice(0,200)}catch{}return "\u{1F4AC} (assistant)"}if(d==="user"||d==="tool_result"||f==="user")return "\u2190 (tool result)";if(d==="tool_use")return `\u2699 ${t.match(/"name"\s*:\s*"([^"]+)"/)?.[1]??"tool"}()`;if(d==="result"){let T=t.match(/"result"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(T)try{return `\u2713 ${JSON.parse(`"${T[1]}"`).slice(0,180)}`}catch{}return "\u2713 Agent finished"}return d==="rate_limit_event"?"\u23F3 Rate limited":`[${d??f}]`}function ra(t,n,o,l){let d=f=>l?.get(f);switch(t.type){case "agent:started":n("Started task",e.green,{agentId:t.agentId,taskId:t.taskId,msgType:"lifecycle"});break;case "agent:output":{let{summary:f,detail:T}=zr(t.data);if(f){let b=Dr(f);n(f,b.color,{agentId:t.agentId,taskId:d(t.runId),detail:T,msgType:b.msgType});}break}case "agent:file_changed":n(`${t.path}`,e.purple,{agentId:t.agentId,taskId:d(t.runId),msgType:"file"});break;case "agent:completed":n(t.success?"Completed successfully":"Failed",t.success?e.green:e.red,{agentId:t.agentId,taskId:d(t.runId),msgType:"lifecycle"});break;case "agent:error":n(`${t.error.slice(0,150)}`,e.red,{agentId:t.agentId,taskId:d(t.runId),detail:t.error,msgType:"error"});break;case "task:status_changed":n(`${t.from} \u2192 ${t.to}`,e.cyan,{taskId:t.taskId,msgType:"system"});break;case "task:assigned":n(`Assigned \u2192 ${t.agentId}`,e.cyan,{taskId:t.taskId,msgType:"system"});break;case "task:created":n(`Created: ${t.task.title}`,e.amber,{taskId:t.task.id,msgType:"system"});break;case "run:retry":n(`Retry #${t.attempt} (${Math.round(t.delay_ms/1e3)}s delay)`,e.yellow,{agentId:o?.get(t.runId),taskId:d(t.runId),msgType:"lifecycle"});break;case "orchestrator:tick":(t.running>0||t.queued>0)&&n(`${t.running} running \xB7 ${t.queued} queued`,e.ghost,{msgType:"system"});break;case "orchestrator:stall_detected":n("Stall detected",e.yellow,{agentId:o?.get(t.runId),taskId:d(t.runId),msgType:"error"});break}}export{zl as App,Gl as _resetPendingDeletionSeq};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {d,a,e}from'./chunk-5AJ4LYO5.js';import {j,o,q,d as d$1,l,h,m}from'./chunk-L26TK7Y5.js';function T(h$1,o$1){let s=h$1.command("agent").description("Manage agents");s.command("add <name>").description("Add a new agent").requiredOption("--adapter <adapter>","Adapter type: claude, shell, codex, cursor").option("--role <role>","Agent role description").option("--command <cmd>","Shell command (for shell adapter)").option("--model <model>","Model name (for AI adapters)").option("--max-turns <n>","Max turns per run").option("--timeout <ms>","Timeout in ms").option("--approval-policy <policy>","suggest|auto|manual").option("--workspace-mode <mode>","shared|worktree|isolated").option("--skills <skills>","Comma-separated list of agent skills").option("-e, --edit","Open $EDITOR to write the role description").action(async(t,e$1)=>{await o$1.paths.requireInit();let a$1=e$1.role;if(e$1.edit){let n=d({name:t,model:e$1.model,role:a$1}),l=await a(n),d$1=e(l);d$1.name&&(t=d$1.name),d$1.model&&(e$1.model=d$1.model),d$1.role&&(a$1=d$1.role);}let i=await o$1.agentService.create({name:t,adapter:e$1.adapter,role:a$1,command:e$1.command,model:e$1.model,max_turns:e$1.maxTurns?parseInt(e$1.maxTurns,10):void 0,timeout_ms:e$1.timeout?parseInt(e$1.timeout,10):void 0,approval_policy:e$1.approvalPolicy,workspace_mode:e$1.workspaceMode,skills:e$1.skills?e$1.skills.split(",").map(n=>n.trim()):void 0});o$1.context.json?console.log(JSON.stringify(i,null,2)):o$1.context.quiet?console.log(i.id):j(`Added agent ${o(i.name)} (${i.adapter}) \u2192 ${i.id}`);}),s.command("list").description("List all agents").action(async()=>{await o$1.paths.requireInit();let t=await o$1.agentService.list();if(o$1.context.json){console.log(JSON.stringify(t,null,2));return}if(o$1.context.quiet){t.forEach(n=>console.log(n.id));return}if(t.length===0){console.log(`
|
|
3
|
+
No agents. Add one: ${q("orch agent add <name> --adapter claude")}
|
|
4
|
+
`);return}let e=["STATUS","AGENT","ADAPTER","TASK","TIME"],a=t.map(n=>[`${d$1(n.status)} ${n.status}`,o(n.name),n.adapter,n.current_task??q("\u2014"),q("\u2014")]);console.log(),l(e,a);let i=t.filter(n=>n.status==="running").length;console.log(`
|
|
5
|
+
${t.length} agents \xB7 ${i} running \xB7 ${h(t.reduce((n,l)=>n+(l.stats.tokens_used??0),0))} tokens total
|
|
6
|
+
`);}),s.command("status <id>").description("Show agent details").action(async t=>{await o$1.paths.requireInit();let e=await o$1.agentService.get(t);if(o$1.context.json){console.log(JSON.stringify(e,null,2));return}console.log(`
|
|
7
|
+
${e.name}`),console.log(` ${"\u2550".repeat(42)}`),console.log();let a=[["Adapter",`${e.adapter}${e.config.model?` (${e.config.model})`:""}`],["Status",`${d$1(e.status)} ${e.status}`],["Policy",e.config.approval_policy??"auto"]];e.current_task&&a.push(["Task",e.current_task]),e.role&&a.push(["Role",e.role]),e.config.skills?.length&&a.push(["Skills",e.config.skills.join(", ")]),m(a),console.log(`
|
|
8
|
+
Stats
|
|
9
|
+
${"\u2500".repeat(42)}`),m([["Tasks completed",String(e.stats.tasks_completed)],["Tasks failed",String(e.stats.tasks_failed)],["Total runs",String(e.stats.total_runs)],["Tokens used",h(e.stats.tokens_used??0)]]),console.log();}),s.command("edit <id>").description("Edit an agent in $EDITOR").action(async t=>{await o$1.paths.requireInit();let e$1=await o$1.agentService.get(t),a$1=d({name:e$1.name,model:e$1.config.model,role:e$1.role}),i=await a(a$1),n=e(i),l=await o$1.agentService.update(t,{name:n.name,role:n.role,model:n.model});o$1.context.json?console.log(JSON.stringify(l,null,2)):o$1.context.quiet?console.log(l.id):j(`Updated agent ${o(l.name)} (${l.id})`);}),s.command("remove <id>").description("Remove an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.remove(t),j(`Removed agent ${t}`);}),s.command("disable <id>").description("Disable an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.disable(t),j(`Disabled agent ${t}`);}),s.command("enable <id>").description("Enable an agent").action(async t=>{await o$1.paths.requireInit(),await o$1.agentService.enable(t),j(`Enabled agent ${t}`);}),s.command("autonomous <id>").description("Toggle autonomous mode for an agent").option("--on","Enable autonomous mode").option("--off","Disable autonomous mode").action(async(t,e)=>{await o$1.paths.requireInit();let a=await o$1.agentService.get(t),i=e.on?true:e.off?false:!a.autonomous,n=await o$1.agentService.setAutonomous(t,i);o$1.context.json?console.log(JSON.stringify(n,null,2)):o$1.context.quiet?console.log(n.id):j(`Autonomous mode ${i?"enabled":"disabled"} for agent ${o(n.name)} (${n.id})`);});}export{T as registerAgentCommand};
|