@oxgeneral/orch 1.0.26 → 1.0.28
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-YVHDT4VD.js +23 -0
- package/dist/antigravity-O4HXTW5G.js +2 -0
- package/dist/{antigravity-W43JJLR2.js → antigravity-Q5KU76IE.js} +3 -3
- package/dist/{antigravity-W43JJLR2.js.map → antigravity-Q5KU76IE.js.map} +1 -1
- package/dist/{chunk-ITMAWW3J.js → chunk-5KNZ2OEV.js} +1 -1
- package/dist/{chunk-YKUO5PD4.js → chunk-6ZRSU2RC.js} +1 -1
- package/dist/chunk-COJCLTPD.js +3 -0
- package/dist/chunk-CY5VX7G5.js +102 -0
- package/dist/chunk-CY5VX7G5.js.map +1 -0
- package/dist/chunk-JEMJFAMY.js +6 -0
- package/dist/chunk-LWYSQ32X.js +2 -0
- package/dist/claude-MK3KXPCV.js +2 -0
- package/dist/{claude-KZMCTMDP.js → claude-TCPV5VGL.js} +3 -3
- package/dist/{claude-KZMCTMDP.js.map → claude-TCPV5VGL.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/codex-6TTUEMXU.js +2 -0
- package/dist/{codex-UR7Q22OV.js → codex-ZWDFBGE4.js} +3 -3
- package/dist/{codex-UR7Q22OV.js.map → codex-ZWDFBGE4.js.map} +1 -1
- package/dist/{container-WJJQSUHB.js → container-CH5HKCZU.js} +2 -2
- package/dist/{cursor-O6M6XOMT.js → cursor-E7X5BWGB.js} +9 -10
- package/dist/cursor-E7X5BWGB.js.map +1 -0
- package/dist/cursor-RCZXGZ3O.js +2 -0
- package/dist/{doctor-X2D67Q6Q.js → doctor-ITKGSHFU.js} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/opencode-3Q4KA3CM.js +2 -0
- package/dist/{opencode-HOX5TCMD.js → opencode-DA6U3KYP.js} +3 -3
- package/dist/{opencode-HOX5TCMD.js.map → opencode-DA6U3KYP.js.map} +1 -1
- package/dist/{pi-GFJCLRZJ.js → pi-AZBWGTUL.js} +6 -24
- package/dist/pi-AZBWGTUL.js.map +1 -0
- package/dist/pi-IDZOXOPE.js +2 -0
- package/dist/shell-YEHU4QG6.js +2 -0
- package/dist/{shell-C2J4AIAV.js → shell-ZQZBBNLC.js} +3 -3
- package/dist/{shell-C2J4AIAV.js.map → shell-ZQZBBNLC.js.map} +1 -1
- package/dist/{task-V72DFC6L.js → task-SZDRAD7V.js} +1 -1
- package/dist/{tui-GFT7LF67.js → tui-25JIN7MP.js} +1 -1
- package/package.json +1 -1
- package/dist/App-B4VWJWWG.js +0 -23
- package/dist/antigravity-LGKZHZL7.js +0 -2
- package/dist/chunk-C7C7Q7XO.js +0 -4
- package/dist/chunk-DEHFYICU.js +0 -2
- package/dist/chunk-RFN447MA.js +0 -73
- package/dist/chunk-RFN447MA.js.map +0 -1
- package/dist/chunk-SJG3HXO5.js +0 -5
- package/dist/claude-PH7LT3OH.js +0 -2
- package/dist/codex-URQN4JLZ.js +0 -2
- package/dist/cursor-EMX3ECDY.js +0 -2
- package/dist/cursor-O6M6XOMT.js.map +0 -1
- package/dist/opencode-K22RCQ5C.js +0 -2
- package/dist/pi-GFJCLRZJ.js.map +0 -1
- package/dist/pi-XEINSHUN.js +0 -2
- package/dist/shell-NPNTWDMU.js +0 -2
package/dist/App-B4VWJWWG.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a as a$5}from'./chunk-HYQXUJYV.js';import {a}from'./chunk-N4OXN2HW.js';import {c,a as a$1}from'./chunk-HXOMNULD.js';import {b,a as a$2}from'./chunk-3YGXRXS7.js';import {a as a$4}from'./chunk-SLMXPTXV.js';import {a as a$3,b as b$1}from'./chunk-DZK72HOZ.js';import {f,h,g}from'./chunk-64WUDYEM.js';import {n}from'./chunk-LRYVT4D4.js';import mo,{useState,useMemo,useEffect,useRef,useCallback}from'react';import {Box,Text,useInput,useApp,useStdout}from'ink';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var e={amber:"#ffaf00",amberDim:"#af8700",green:"#5faf87",red:"#d75f5f",blue:"#5fafd7",yellow:"#d7af00",cyan:"#5fd7d7",purple:"#af87ff",white:"#eeeeee",silver:"#bcbcbc",gray:"#808080",dim:"#585858",ghost:"#3a3a3a",void:"#262626",errorBg:"#3d1515",warnBg:"#3d2e0a",successBg:"#0f2d1f",infoBg:"#1a1a22",toolBg:"#0f1f2d"},Po="\u2501",He="\u2500",ge="\xB7",Qt="\u25C8",Lr="\u2605",bn="\u27F3",Ut="\u25C6",No={in_progress:e.green,retrying:e.yellow,review:e.blue,todo:e.dim,done:e.green,failed:e.red,cancelled:e.dim},Ds=new Map,Fs=new Map;function Ue(t){if(t<=0)return "";let n=Ds.get(t);return n||(n=Po.repeat(t),Ds.set(t,n)),n}function be(t){if(t<=0)return "";let n=Fs.get(t);return n||(n=He.repeat(t),Fs.set(t,n)),n}function it(t,n){return t.length>n?t.slice(0,n-1)+"\u2026":t}var xl=1e4;function Pr(t,n=xl){if(t)return t.length>n?t.slice(0,n)+`
|
|
3
|
-
\u2026[truncated]`:t}var Ws={active:e.green,paused:e.dim,achieved:e.amber,abandoned:e.ghost};var yl=120,Do=0,lo=null,Fo=new Set;function wl(){lo||(lo=setInterval(()=>{Do++;for(let t of Fo)t(Do);},yl));}function Sl(){lo&&Fo.size===0&&(clearInterval(lo),lo=null);}function Nn(t=true){let[n,o]=useState(Do);return useEffect(()=>{if(!t)return;o(Do);let r=s=>o(s);return Fo.add(r),wl(),()=>{Fo.delete(r),Sl();}},[t]),n}var Gs=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Xt({color:t}){let n=Nn();return jsx(Text,{color:t,children:Gs[n%Gs.length]})}var co={in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6};var vl="\u25CB",Vs="\u2713",js="\u2715",Ml="\u21BB",_l="\u2500",Rl="\u25B6",Dt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},Al={in_progress:{icon:Rl,label:"RUN",fg:e.green,bg:Dt.green,bold:true,spinner:true},retrying:{icon:Ml,label:"RETRY",fg:e.yellow,bg:Dt.yellow,spinner:true},review:{icon:Qt,label:"REVIEW",fg:e.blue,bg:Dt.blue},todo:{icon:vl,label:"TODO",fg:e.dim,bg:Dt.neutral},done:{icon:Vs,label:"DONE",fg:e.green,bg:Dt.green},failed:{icon:js,label:"FAIL",fg:e.red,bg:Dt.red,bold:true},cancelled:{icon:_l,label:"OFF",fg:e.dim,bg:Dt.neutral}},$l={1:{color:e.red,label:"!!!"},2:{color:e.yellow,label:"!!"},3:{color:e.dim,label:"!"},4:{color:e.ghost,label:ge}};var El=18,Ol="#2d1f0a",Wo=mo.memo(function({task:n,selected:o,width:r,agentNameMap:s,goalMap:m}){let h=Al[n.status],y=n.status==="in_progress"||n.status==="retrying",f$1=$l[n.priority]??{color:e.ghost,label:ge},T,w;if(n.status==="done")T=Vs,w=e.green;else if(n.status==="failed")T=js,w=e.red;else if(y){let G=Date.now()-new Date(n.updated_at).getTime();T=f(G),w=e.cyan;}else T="\u2014",w=void 0;let I=o?"\u25B8":" ",_=n.goalId?m?.get(n.goalId):void 0,v=!!_,L=10,M=4,R=14,C=v?El:0,z=7,P=2+L+M+R+C+z,B=r?Math.max(10,r-P):40,H=n.assignee?s?.get(n.assignee)??n.assignee:void 0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[I," "]}),jsx(Box,{width:L,children:jsx(Text,{backgroundColor:h.bg,color:h.fg,bold:h.bold,children:h.spinner?jsxs(Fragment,{children:[" ",jsx(Xt,{color:h.fg})," ",h.label," "]}):jsxs(Fragment,{children:[" ",h.icon," ",h.label," "]})})}),jsx(Box,{width:M,children:jsx(Text,{color:f$1.color,bold:n.priority<=2,children:f$1.label})}),jsxs(Box,{width:B,children:[jsx(Text,{wrap:"truncate",bold:o||y,color:o?e.white:y?e.silver:void 0,children:n.title.length>B?n.title.slice(0,B-1)+"\u2026":n.title}),(n.attachments?.length??0)>0&&jsxs(Text,{color:e.dim,children:[" ","\u{1F4CE}",n.attachments.length]})]}),v&&jsx(Box,{width:C,children:jsxs(Text,{backgroundColor:Ol,color:e.amberDim,wrap:"truncate",children:[" \u2295 ",it(_.title,13)," "]})}),jsx(Box,{width:R,children:H?jsxs(Text,{backgroundColor:Dt.green,color:e.green,wrap:"truncate",children:[" ",H.length>R-2?H.slice(0,R-3)+"\u2026":H," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:z,justifyContent:"flex-end",children:jsx(Text,{color:w,dimColor:!w,children:T})})]})});var Hs="\u2295";function Us({goalTitle:t,taskCount:n,doneCount:o,width:r}){let s=n>0?Math.round(o/n*100):0,m=` ${Hs} ${t.toUpperCase()} ${ge} ${n} task${n!==1?"s":""} ${ge} ${s}% done `,h=3,y=Math.max(0,r-h-m.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:be(h)}),jsx(Text,{backgroundColor:Dt.amber,color:e.amber,bold:true,children:m}),jsx(Text,{color:e.ghost,children:be(y)})]})}function Xs({taskCount:t,width:n}){let o=` ${Hs} UNGROUPED ${ge} ${t} task${t!==1?"s":""} `,r=3,s=Math.max(0,n-r-o.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:be(r)}),jsx(Text,{backgroundColor:Dt.neutral,color:e.dim,children:o}),jsx(Text,{color:e.ghost,children:be(s)})]})}var Pl="\u2715",qs="\u25CB",Nl="\u25B6",Dl="\u2713",Dn={green:"#0f2d1f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"},Fl={running:{icon:Nl,label:"ACTIVE",fg:e.green,bg:Dn.green,bold:true,spinner:true},idle:{icon:qs,label:"IDLE",fg:e.dim,bg:Dn.neutral},error:{icon:Pl,label:"ERROR",fg:e.red,bg:Dn.red,bold:true},disabled:{icon:qs,label:"OFF",fg:e.ghost,bg:Dn.neutral}},Nr={running:0,idle:1,error:2,disabled:3},Ys=mo.memo(function({agent:n$1,selected:o,width:r,runningEntry:s,currentTaskTitle:m,teamName:h,isLead:y}){let f$1=Fl[n$1.status],T=n$1.status==="running",w,I;if(T&&s){let H=Date.now()-new Date(s.started_at).getTime();w=f(H),I=e.cyan;}else n$1.stats.total_runs>0?(w=`${n$1.stats.tasks_completed}/${n$1.stats.total_runs}`,I=n$1.stats.tasks_completed>0?e.green:e.dim):(w="\u2014",I=void 0);let _=o?"\u25B8":" ",v=11,L=8,M=h?Math.min(h.length+2,12):0,R=10,C=2+v+L+M+R,z=r?Math.max(8,r-C):20,P=n$1.stats.total_runs>0,B=P?Math.round(n$1.stats.tasks_completed/n$1.stats.total_runs*100):0;return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[_," "]}),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(Xt,{color:f$1.fg})," ",f$1.label," "]}):jsxs(Fragment,{children:[" ",f$1.icon," ",f$1.label," "]})})}),jsx(Box,{width:z,children:jsxs(Text,{wrap:"truncate",bold:o||T,color:o?e.white:T?e.green:e.silver,children:[n$1.autonomous&&jsxs(Text,{color:e.cyan,children:[bn," "]}),y&&jsxs(Text,{color:e.amber,children:[Lr," "]}),n$1.name,T&&m&&jsxs(Text,{color:e.dim,children:[" ",ge," ",m]}),n$1.status==="error"&&n$1.last_error&&jsxs(Text,{color:e.red,children:[" ",ge," ",it(n[n$1.last_error.kind]?.message??n$1.last_error.message,30)]})]})}),jsx(Box,{width:L,children:jsx(Text,{color:e.dim,children:n$1.adapter})}),h&&jsx(Box,{width:M,children:jsx(Text,{color:e.amber,wrap:"truncate",children:h})}),jsx(Box,{width:R,justifyContent:"flex-end",children:P&&!T?jsxs(Text,{color:B>=80?e.green:B>=50?e.yellow:e.red,children:[w," ",Dl]}):jsx(Text,{color:I,dimColor:!I,children:w})})]})});function Zs({teamName:t,memberCount:n,leadName:o,width:r}){let s=`${n} agent${n!==1?"s":""}`,m=o?` ${ge} ${Lr} ${o}`:"",h=` ${Qt} ${t.toUpperCase()} ${ge} ${s}${m} `,y=3,f=Math.max(0,r-y-h.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:be(y)}),jsx(Text,{backgroundColor:Dn.amber,color:e.amber,bold:true,children:h}),jsx(Text,{color:e.ghost,children:be(f)})]})}var Wl="\u25C7";function Js({memberCount:t,width:n}){let o=`${t} agent${t!==1?"s":""}`,r=` ${Wl} UNASSIGNED ${ge} ${o} `,s=3,m=Math.max(0,n-s-r.length-4);return jsxs(Box,{paddingX:2,children:[jsx(Text,{color:e.ghost,children:be(s)}),jsx(Text,{backgroundColor:Dn.neutral,color:e.dim,children:r}),jsx(Text,{color:e.ghost,children:be(m)})]})}var Qs="\u2713",ei="\u2715",zl="\u2016",Vl="\u25C9",go={green:"#0f2d1f",amber:"#2d1f0a",neutral:"#1a1a22"},jl={active:{icon:Vl,label:"ACTIVE",fg:e.green,bg:go.green,bold:true},paused:{icon:zl,label:"PAUSED",fg:e.dim,bg:go.neutral},achieved:{icon:Qs,label:"DONE",fg:e.amber,bg:go.amber,bold:true},abandoned:{icon:ei,label:"DROP",fg:e.ghost,bg:go.neutral}},Hl="\u2588",Ul="\u2591",Xl=14,ti=mo.memo(function({goal:n,selected:o,width:r,agentNameMap:s,tasksByGoal:m}){let h=jl[n.status],y=o?"\u25B8":" ",f=m?.length??0,T=m?.filter(B=>B.status==="done").length??0,w=f>0,I=11,_=w?Xl:0,v=14,L=7,M=2+I+_+v+L,R=r?Math.max(10,r-M):40,C=n.assignee?s?.get(n.assignee)??n.assignee:void 0,z,P;if(n.status==="achieved")z=Qs,P=e.amber;else if(n.status==="abandoned")z=ei,P=e.ghost;else {let B=Date.now()-new Date(n.created_at).getTime(),H=Math.floor(B/864e5);z=H>0?`${H}d`:"<1d",P=e.dim;}return jsxs(Box,{children:[jsxs(Text,{color:o?e.amber:void 0,children:[y," "]}),jsx(Box,{width:I,children:jsxs(Text,{backgroundColor:h.bg,color:h.fg,bold:h.bold,children:[" ",h.icon," ",h.label," "]})}),jsx(Box,{width:R,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>R?n.title.slice(0,R-1)+"\u2026":n.title})}),w&&(()=>{let H=f>0?Math.round(T/f*6):0,G=6-H;return jsxs(Box,{width:_,children:[jsx(Text,{color:e.green,children:Hl.repeat(H)}),jsx(Text,{color:e.ghost,children:Ul.repeat(G)}),jsx(Text,{color:e.dim,children:` ${T}/${f}`})]})})(),jsx(Box,{width:v,children:C?jsxs(Text,{backgroundColor:go.green,color:e.green,wrap:"truncate",children:[" ",C.length>v-2?C.slice(0,v-3)+"\u2026":C," "]}):jsx(Text,{color:e.ghost,children:"\u2014"})}),jsx(Box,{width:L,justifyContent:"flex-end",children:jsx(Text,{color:P,dimColor:!P,children:z})})]})});var ql={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"};function Gn({label:t,width:n,color:o}){let r=n-4,s=` ${t} `,m=3,h=Math.max(0,r-m-s.length);return jsxs(Text,{color:o??e.ghost,children:[" ",be(m),s,be(h)]})}function ni({task:t,height:n,width:o,taskLogs:r,agentNameMap:s,taskTitleMap:m}){let h=No[t.status]??e.dim,y=t.priority<=2?t.priority===1?e.red:e.yellow:void 0,f=24,T=!!t.description?.trim(),w=!!t.proof?.agent_summary,I=(t.proof?.files_changed?.length??0)>0,_=(r?.length??0)>0,v=(t.attachments?.length??0)>0,L=T?t.description.split(`
|
|
4
|
-
`):[],M=w?t.proof.agent_summary.split(`
|
|
5
|
-
`):[],R=3;v&&(R+=2+t.attachments.length),T?(R+=1,R+=Math.min(L.length,Math.max(1,Math.ceil((n-10)*.3)))):w||(R+=2),w&&(R+=2),I&&(R+=1),_&&(R+=2);let C=Math.max(0,n-R),z=0,P=0;w&&_?(z=Math.max(1,Math.floor(C*.4)),P=Math.max(1,C-z)):w?z=C:_&&(P=C);let B=T?L.slice(0,Math.max(1,Math.ceil((n-10)*.3))):[],H=M.slice(0,z);return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:f,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:h,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?s?.get(t.assignee)??t.assignee:"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:f,children:[jsx(Text,{color:e.dim,children:" priority "}),jsxs(Text,{color:y,bold:t.priority<=2,children:["P",t.priority]})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" attempts "}),jsxs(Text,{children:[t.attempts,"/",t.max_attempts]})]})]}),jsxs(Box,{children:[jsxs(Box,{width:f,children:[jsx(Text,{color:e.dim,children:" labels "}),jsx(Text,{color:e.purple,children:t.labels.length>0?t.labels.join(", "):"\u2014"})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" depends "}),jsx(Text,{dimColor:true,children:t.depends_on.length>0?t.depends_on.map(G=>m?.get(G)??G).join(", "):"\u2014"})]})]}),v&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Gn,{label:`attachments (${t.attachments.length})`,width:o,color:e.dim}),t.attachments.map((G,W)=>jsxs(Text,{color:e.cyan,wrap:"truncate",children:[" ",G]},`a${W}`))]}),T&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),B.map((G,W)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",it(G,o-8)]},`d${W}`))]}),!T&&!w&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:" No description."})]}),w&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Gn,{label:"result",width:o,color:e.dim}),H.map((G,W)=>jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",it(G,o-8)]},`r${W}`))]}),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})]})]}),_&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Gn,{label:"activity",width:o,color:e.dim}),r.slice(-P).map((G,W)=>{let S=G.msgType??"info",U=ql[S]??"\u2502",ie=G.color;S==="tool"?ie=e.cyan:S==="file"?ie=e.purple:S==="error"?ie=e.red:S==="lifecycle"?ie=e.green:S==="system"&&(ie=e.dim);let oe=Math.max(10,o-12),ye=it(G.text,oe);return jsxs(Box,{children:[jsxs(Text,{color:e.ghost,children:[" ",G.time," "]}),jsxs(Text,{color:S==="error"?e.red:e.dim,children:[U," "]}),jsx(Text,{color:ie,bold:S==="lifecycle",children:ye})]},W)})]})]})}var Go=[{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 oi="\u25CF",ri="\u25CB",Kl="\u2713",Yl="\u2715",Zl="\u2191",Jl="\u2193",Ql="\u03A3",ec="\u25B6",tc="\u21BB",nc="\u{1F9E0}",Dr=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],tt={green:"#0f2d1f",blue:"#0f1f2d",yellow:"#2d2a0f",red:"#2d0f0f",neutral:"#1a1a22",amber:"#2d1f0a"};function oc({active:t}){let n=Nn(t),o=!t||Math.floor(n/10)%2===0;return jsx(Text,{color:o?e.amber:e.amberDim,bold:true,children:Ut})}function rc({width:t,active:n}){let o=Math.max(4,Math.floor(t*.08)),r=2,s=Nn(n),m=Math.ceil((t+o)/r),h=n?s%(m*2):0;if(!n)return jsx(Box,{paddingX:1,children:jsx(Text,{color:e.ghost,children:Ue(t)})});let y=h<m?h*r:(m*2-h)*r,f=Math.max(0,y-o),T=Math.min(t,y),w=f,I=Math.max(0,T-f),_=Math.max(0,t-T);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Ue(w)}),jsx(Text,{color:e.amber,children:Ue(I)}),jsx(Text,{color:e.ghost,children:Ue(_)})]})}function sc({data:t,width:n,color:o}){if(t.length===0)return null;let r=t.slice(-n),s=Math.max(...r,1),m=r.map(h=>{let y=Math.round(h/s*(Dr.length-1));return Dr[y]??Dr[0]}).join("");return jsx(Text,{color:o,children:m})}function ic({tab:t,flashColor:n,onComplete:o,badge:r}){let s=Nn(),m=mo.useRef(s),h=mo.useRef(false),y=s-m.current,f=2,T=6*f;return mo.useEffect(()=>{y>=T&&!h.current&&(h.current=true,o());},[y,o]),Math.floor(y/f)%2===0&&y<T?jsxs(Text,{backgroundColor:n,color:"#0a0a0c",bold:true,children:[" ",t.key," ",t.label,r," "]}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:t.key}),jsxs(Text,{color:e.dim,children:[" ",t.label.toLowerCase(),r]})]})}function ac({projectName:t,activeView:n,mode:o,stats:r,uptime:s,width:m,version:h,latestVersion:y,updateInstalled:f,taskBadge:T,flashTab:w,flashColor:I,onFlashComplete:_}){return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:m,children:[jsxs(Box,{gap:0,children:[jsx(oc,{active:r.running>0}),jsx(Text,{color:e.amber,bold:true,children:" ORCH"}),h&&jsxs(Text,{color:e.ghost,children:[" ",h]}),y&&y!==h&&(f?jsxs(Text,{backgroundColor:tt.green,color:e.green,bold:true,children:[" v",y," INSTALLED \u2014 RESTART TO APPLY "]}):jsxs(Text,{backgroundColor:tt.green,color:e.green,bold:true,children:[" UPDATE ",y," "]})),jsxs(Text,{color:e.ghost,children:[" ",ge," "]}),jsx(Text,{color:e.silver,children:t})]}),jsx(Box,{gap:0,children:Go.map((v,L)=>{let M=n===v.id,R=v.id==="tasks"&&T!=null&&T>0?` (${T})`:"",C=!M&&w===v.id&&I&&_;return jsxs(mo.Fragment,{children:[L>0&&jsx(Text,{children:" "}),M?jsxs(Text,{backgroundColor:e.amber,color:"#0a0a0c",bold:true,children:[" ",v.key," ",v.label,R," "]}):C?jsx(ic,{tab:v,flashColor:I,onComplete:_,badge:R}):jsxs(Box,{gap:0,children:[jsx(Text,{color:e.ghost,children:v.key}),jsxs(Text,{color:e.dim,children:[" ",v.label.toLowerCase(),R]})]})]},v.id)})}),jsxs(Box,{gap:0,children:[o==="watching"?jsxs(Text,{backgroundColor:tt.green,color:e.green,bold:true,children:[" ",oi," WATCHING"," "]}):o==="observing"?jsxs(Text,{backgroundColor:tt.amber,color:e.amber,bold:true,children:[" ",oi," OBSERVING"," "]}):jsxs(Text,{backgroundColor:tt.neutral,color:e.dim,children:[" ",ri," IDLE"," "]}),r.running>0&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{backgroundColor:tt.green,color:e.green,children:[" ",jsx(Xt,{color:e.green})," ",r.running," active"," "]})]}),s&&jsxs(Text,{color:e.ghost,children:[" ",s]})]})]})}function lc({stats:t,tokens:n,width:o,sparklineData:r}){let m=[{icon:ec,label:"RUN",count:t.running,fg:e.green,bg:tt.green,bold:true,spinner:true,show:t.running>0},{icon:tc,label:"RETRY",count:t.retrying,fg:e.yellow,bg:tt.yellow,show:t.retrying>0},{icon:Qt,label:"REVIEW",count:t.review,fg:e.blue,bg:tt.blue,show:t.review>0},{icon:ri,label:"TODO",count:t.todo,fg:e.dim,bg:tt.neutral,show:t.todo>0},{icon:Kl,label:"DONE",count:t.done,fg:e.green,bg:tt.green,show:t.done>0},{icon:Yl,label:"FAIL",count:t.failed,fg:e.red,bg:tt.red,bold:true,show:t.failed>0},{icon:Ut,label:"TEAMS",count:t.teams,fg:e.amber,bg:tt.amber,show:t.teams>0}].filter(f=>f.show),h$1=n.total>0,y=r&&r.length>0?Math.min(16,r.length):0;return jsxs(Box,{paddingX:1,justifyContent:"space-between",width:o,children:[jsxs(Box,{gap:1,children:[m.map(f=>jsx(Text,{backgroundColor:f.bg,color:f.fg,bold:f.bold,children:f.spinner?jsxs(Fragment,{children:[" ",jsx(Xt,{color:f.fg})," ",f.count," ",f.label," "]}):jsxs(Fragment,{children:[" ",f.icon," ",f.count," ",f.label," "]})},f.label)),m.length===0&&jsxs(Text,{backgroundColor:tt.neutral,color:e.dim,children:[" ","NO TASKS"," "]})]}),jsxs(Box,{gap:0,children:[y>0&&r&&jsxs(Fragment,{children:[jsx(sc,{data:r,width:y,color:e.amberDim}),jsx(Text,{children:" "})]}),h$1&&jsxs(Text,{backgroundColor:tt.amber,color:e.cyan,children:[" ",Zl,h(n.input)," ",Jl,h(n.output),n.reasoning>0?` ${nc}${h(n.reasoning)}`:""," ",ge," ",Ql,h(n.total)," "]})]})]})}var si=mo.memo(function(n){let o=Math.max(10,n.width-2),r=n.stats.running>0;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{height:1}),jsx(ac,{projectName:n.projectName,activeView:n.activeView,mode:n.mode,stats:n.stats,uptime:n.uptime,width:n.width,version:n.version,latestVersion:n.latestVersion,updateInstalled:n.updateInstalled,taskBadge:n.taskBadge,flashTab:n.flashTab,flashColor:n.flashColor,onFlashComplete:n.onFlashComplete}),jsx(Box,{height:1}),jsx(lc,{stats:n.stats,tokens:n.tokens,width:n.width,sparklineData:n.sparklineData}),jsx(rc,{width:o,active:r})]})});var fo="\u0423\u041F\u0420\u0410\u0412\u041B\u0415\u041D\u0418\u0415",zn="\u041C\u041E\u041D\u0418\u0422\u041E\u0420\u0418\u041D\u0413",Vo="\u041D\u0410\u0421\u0422\u0420\u041E\u0419\u041A\u0418",Tn={task:{sub:["add","list","show","cancel","retry","assign","approve","reject","delete"],help:"Manage tasks",category:fo},agent:{sub:["add","list","disable","enable","delete","autonomous","shop"],help:"Manage agents",category:fo},team:{sub:["create","list","join","leave","disband","set-lead"],help:"Manage teams",category:fo},goal:{sub:["add","list","show","status","delete"],help:"Manage goals",category:fo},run:{args:"[id]",help:"Run task (or selected)",category:zn},"run-all":{help:"Run all todo tasks",category:zn},watch:{help:"Start watch mode (auto-dispatch)",category:zn},pause:{help:"Pause watch mode",category:zn},status:{help:"Show orchestrator status",category:zn},config:{sub:["activity-filter","max-concurrent"],help:"TUI settings",category:Vo},help:{help:"List all commands",category:Vo},quit:{help:"Exit the TUI",category:Vo}};function Fr(t){if(!t.startsWith("/"))return null;let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let y=n;if(!y)return null;let f=Object.keys(Tn).find(T=>T.startsWith(y)&&T!==y);return f?f.slice(y.length):null}let r=n.slice(0,o),s=Tn[r];if(!s?.sub)return null;let m=n.slice(o+1);if(!m)return null;let h=s.sub.find(y=>y.startsWith(m)&&y!==m);return h?h.slice(m.length):null}function ii(t){if(!t.startsWith("/"))return [];let n=t.slice(1),o=n.indexOf(" ");if(o===-1){let y=n.toLowerCase(),f=[];if(!y){let T=[fo,zn,Vo];for(let w of T){f.push({cmd:"",desc:`\u2500\u2500 ${w} \u2500\u2500`});for(let[I,_]of Object.entries(Tn))if(_.category===w){let v=_.args?` ${_.args}`:"";f.push({cmd:`/${I}${v}`,desc:_.help,subs:_.sub?.join(" \xB7 ")});}}return f}for(let[T,w]of Object.entries(Tn))if(T.startsWith(y)){let I=w.args?` ${w.args}`:"";if(f.push({cmd:`/${T}${I}`,desc:w.help,subs:w.sub?.join(" \xB7 ")}),T===y&&w.sub)for(let _ of w.sub)f.push({cmd:`/${T} ${_}`,desc:`${w.help}: ${_}`});}return f}let r=n.slice(0,o),s=Tn[r];if(!s?.sub)return [];let m=n.slice(o+1).toLowerCase(),h=[];for(let y of s.sub)(!m||y.startsWith(m))&&h.push({cmd:`/${r} ${y}`,desc:`${s.help}: ${y}`});return h}var jo=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 dc="\u2588",ai=mo.memo(function({mode:n,value:o,completion:r,activeView:s,canRun:m,canNew:h,canApprove:y,canReject:f,canCancel:T,canDelete:w,canUndo:I,canEdit:_,canForceStop:v,canToggleAuto:L,autoActive:M,canPause:R,isPaused:C,canToggleShowAll:z,showAllActive:P,hasDetail:B,itemCount:H,itemLabel:G,width:W,hasSuggestions:S,onboardingCompleted:U}){if(n==="command"){let ie=S?" \u2191\u2193 select Tab fill Esc \u2715":" Enter exec \u2191\u2193 history Tab complete Esc \u2715",oe=Math.max(4,W-6-ie.length-(r?.length??0)-1),ye=o.length>oe?"\u2026"+o.slice(-(oe-1)):o;return jsx(Box,{paddingX:2,justifyContent:"space-between",width:W,children:jsxs(Box,{children:[jsx(Text,{color:e.amber,children:"/ "}),jsx(Text,{color:e.white,children:ye}),r&&jsx(Text,{color:e.ghost,children:r}),jsx(Text,{color:e.amber,children:dc}),jsx(Text,{color:e.dim,children:ie})]})})}return jsxs(Box,{paddingX:2,justifyContent:"space-between",width:W,children:[jsxs(Text,{color:e.dim,children:[jsx(Text,{bold:true,color:e.gray,children:"\u2191\u2193"})," ",jsx(Text,{bold:true,color:e.gray,children:"Tab"}),"/",jsx(Text,{bold:true,color:e.gray,children:"\u2190\u2192"})," ",jsx(Text,{bold:true,color:e.gray,children:"/"})," cmd",h&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"N"})," new"]}),m&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"R"})," run"]}),T&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"C"})," cancel"]}),y&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.green,children:"A"})," approve"]}),f&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"X"})," reject"]}),_&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"E"})," edit"]}),v&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.red,children:"S"})," stop"]}),R&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.amber,children:"P"}),C?" resume":" pause"]}),L&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.cyan,children:"U"}),M?" auto off":" auto on"]}),z&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"S"}),P?" collapse":" show all"]}),w&&!y&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"D"})," delete"]}),I&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.yellow,children:"Z"})," undo"]}),B&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Esc"})," close"]}),!B&&(s==="tasks"||s==="agents"||s==="goals")&&jsxs(Fragment,{children:[" ",jsx(Text,{bold:true,color:e.gray,children:"Enter"})," detail"]})," ",jsx(Text,{bold:true,color:e.gray,children:"Q"})," quit"," ",jsx(Text,{bold:true,color:U===false?e.amber:e.gray,children:"?"}),jsx(Text,{color:U===false?e.amber:void 0,children:" help"})]}),H>0&&jsxs(Text,{color:e.dim,children:[H," ",G]})]})});var di=new Intl.Segmenter(void 0,{granularity:"grapheme"});function li(t){return [...di.segment(t)].map(n=>n.segment)}function Ho(t){let n=t.codePointAt(0)??0;return n>=11904&&n<=40959||n>=4352&&n<=4447||n>=43360&&n<=43391||n>=44032&&n<=55215||n>=63744&&n<=64255||n>=65040&&n<=65135||n>=65281&&n<=65376||n>=65504&&n<=65510||n>=131072&&n<=195103||n>=127744&&n<=129791?2:1}function ui(t){let n=0;for(let o of di.segment(t))n+=Ho(o.segment);return n}function ci(t,n){if(n<=0)return 0;let o=n-1;for(;o>0&&t[o-1]===" ";)o--;for(;o>0&&t[o-1]!==" ";)o--;return o}function uc(t,n){let o=t.length;if(n>=o)return o;let r=n;for(;r<o&&t[r]!==" ";)r++;for(;r<o&&t[r]===" ";)r++;return r}var Vn=class t{text;pos;_segs;constructor(n,o){this.text=n.normalize("NFC"),this._segs=li(this.text),this.pos=o!==void 0?Math.max(0,Math.min(o,this._segs.length)):this._segs.length;}static _withPos(n,o,r){let s=Object.create(t.prototype);return Object.defineProperty(s,"text",{value:n,writable:false}),Object.defineProperty(s,"_segs",{value:o,writable:false}),Object.defineProperty(s,"pos",{value:Math.max(0,Math.min(r,o.length)),writable:false}),s}get length(){return this._segs.length}get beforeSegs(){return this._segs.slice(0,this.pos)}get afterSegs(){return this._segs.slice(this.pos)}get before(){return this.beforeSegs.join("")}get after(){return this.afterSegs.join("")}get isEmpty(){return this.text.length===0}moveLeft(n=1){return t._withPos(this.text,this._segs,this.pos-n)}moveRight(n=1){return t._withPos(this.text,this._segs,this.pos+n)}moveToStart(){return t._withPos(this.text,this._segs,0)}moveToEnd(){return t._withPos(this.text,this._segs,this._segs.length)}moveToWordBack(){return t._withPos(this.text,this._segs,ci(this._segs,this.pos))}moveToWordForward(){return t._withPos(this.text,this._segs,uc(this._segs,this.pos))}insert(n){let o=n.normalize("NFC"),r=li(o),s=this._segs.slice(0,this.pos).join("")+o+this._segs.slice(this.pos).join("");return new t(s,this.pos+r.length)}deleteBack(){if(this.pos<=0)return this;let n=this._segs,o=n.slice(0,this.pos-1).join("")+n.slice(this.pos).join("");return new t(o,this.pos-1)}deleteForward(){let n=this._segs;if(this.pos>=n.length)return this;let o=n.slice(0,this.pos).join("")+n.slice(this.pos+1).join("");return new t(o,this.pos)}killToEnd(){let n=this._segs,o=n.slice(this.pos).join(""),r=n.slice(0,this.pos).join("");return [new t(r,this.pos),o]}killToStart(){let n=this._segs,o=n.slice(0,this.pos).join(""),r=n.slice(this.pos).join("");return [new t(r,0),o]}killWordBack(){let n=this._segs,o=ci(n,this.pos),r=n.slice(o,this.pos).join(""),s=n.slice(0,o).join("")+n.slice(this.pos).join("");return [new t(s,o),r]}replaceAll(n){return new t(n)}clear(){return new t("")}};var fc=500;function Xo(t={}){let n=t.maxUndoDepth??50,[o,r]=useState(()=>new Vn(t.initialValue??"")),s=useRef([]),m=useRef(null),h=useRef(""),y=useRef(o);y.current=o;let f=useCallback(L=>{y.current=L,r(L);},[]),T=useCallback(()=>{m.current&&(clearTimeout(m.current),m.current=null);let L=s.current,M=y.current;L.length>0&&L[L.length-1].text===M.text||(L.push(M),L.length>n&&L.shift());},[n]),w=useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,T();},fc);},[T]);useEffect(()=>()=>{m.current&&clearTimeout(m.current);},[]);let I=useCallback((L,M)=>{if(!L&&!M.backspace&&!M.delete&&!M.leftArrow&&!M.rightArrow&&!M.home&&!M.end)return false;let R=y.current;if(M.ctrl)switch(L){case "a":return f(R.moveToStart()),true;case "e":return f(R.moveToEnd()),true;case "k":{T();let[C,z]=R.killToEnd();return h.current=z,f(C),true}case "u":{T();let[C,z]=R.killToStart();return h.current=z,f(C),true}case "w":{T();let[C,z]=R.killWordBack();return h.current=z,f(C),true}case "y":return h.current&&(T(),f(R.insert(h.current))),true;case "z":{let C=s.current;return C.length>0&&C[C.length-1].text===R.text&&C.pop(),C.length>0&&f(C.pop()),true}case "b":return f(R.moveLeft()),true;case "f":return f(R.moveRight()),true;case "d":return R.isEmpty||(w(),f(R.deleteForward())),true;case "h":return R.pos>0&&(w(),f(R.deleteBack())),true;default:return false}if(M.meta){if(L==="z"){let C=s.current;for(;C.length>0&&C[C.length-1].text===R.text;)C.pop();return C.length>0&&f(C.pop()),true}if(L==="a")return f(R.moveToStart()),true;if(M.backspace||M.delete){T();let[C,z]=R.killToStart();return h.current=z,f(C),true}return M.leftArrow||L==="b"?(f(R.moveToWordBack()),true):M.rightArrow||L==="f"?(f(R.moveToWordForward()),true):false}return M.home?(f(R.moveToStart()),true):M.end?(f(R.moveToEnd()),true):M.leftArrow?(f(R.moveLeft()),true):M.rightArrow?(f(R.moveRight()),true):M.backspace||M.delete?(R.pos>0&&(w(),f(R.deleteBack())),true):L&&!M.escape?(w(),f(R.insert(L)),true):false},[f,T,w]),_=useCallback(L=>{let M=new Vn(L??"");f(M),s.current=[],m.current&&(clearTimeout(m.current),m.current=null);},[f]),v=useCallback(L=>{f(new Vn(L)),s.current=[];},[f]);return {cursor:o,value:o.text,handleInput:I,reset:_,setValue:v,setCursor:f}}var mi="\u2588";function pc(t,n,o){let r=0,s=t.length;for(;s>0;){let w=t[s-1],I=Ho(w);if(r+I>o-1)break;r+=I,s--;}let m=t.slice(s).join(""),h=Math.max(0,o-r-1),y=0,f=0;for(;f<n.length;){let w=n[f],I=Ho(w);if(y+I>h)break;y+=I,f++;}let T=n.slice(0,f).join("");return {visibleBefore:m,visibleAfter:T}}function qo({cursor:t,width:n,prefix:o,prefixColor:r=e.amber,placeholder:s,ghost:m,ghostColor:h=e.ghost,showCursor:y=true,cursorColor:f=e.amber,textColor:T=e.white,placeholderColor:w=e.ghost,hasError:I=false}){let _=o??"",v=ui(_),L=Math.max(4,n-v),M=t.isEmpty,{visibleBefore:R,visibleAfter:C}=pc(t.beforeSegs,t.afterSegs,L),z=I?"round":void 0,P=I?e.red:void 0;return M?jsxs(Box,{borderStyle:z,borderColor:P,children:[_&&jsx(Text,{color:r,children:_}),s&&jsx(Text,{color:w,children:s}),y&&jsx(Text,{color:f,children:mi})]}):jsxs(Box,{borderStyle:z,borderColor:P,children:[_&&jsx(Text,{color:r,children:_}),jsx(Text,{color:T,children:R}),y&&jsx(Text,{color:f,children:mi}),jsx(Text,{color:T,children:C}),m&&jsx(Text,{color:h,children:m})]})}var bc="\u2588",Gr=process.platform==="darwin"?"\u2318":"Ctrl";function Tc(t,n){if(n<=0||t.length<=n)return [t];let o=[];for(let r=0;r<t.length;r+=n)o.push(t.slice(r,r+n));return o}function xi(t,n){if(n<=0)return 0;let o=n-1;for(;o>0&&t[o-1]===" ";)o--;for(;o>0&&t[o-1]!==" ";)o--;return o}function yc(t,n){if(n>=t.length)return t.length;let o=n;for(;o<t.length&&t[o]!==" ";)o++;for(;o<t.length&&t[o]===" ";)o++;return o}function bi({title:t,steps:n,onComplete:o,onCancel:r,width:s,height:m,onPasteImage:h,footerExtra:y,onSuggestionSelected:f}){let [T,w]=useState(0),[I,_]=useState({}),v=Xo({initialValue:(()=>{let N=n.find(O=>!O.skip?.({}));return N?.type==="text"&&N.defaultValue?N.defaultValue:""})()}),L=v.value,[M,R]=useState(()=>{let N=n.find(O=>!O.skip?.({}));return N?.type==="textarea"&&N.defaultValue?N.defaultValue.split(`
|
|
6
|
-
`):[""]}),[C,z]=useState(0),[P,B]=useState(0),[H,G]=useState(()=>{let N=n.find(O=>!O.skip?.({}));if(N?.type==="select"&&N.defaultValue){let D=(N.getOptions?.({})??N.options??[]).findIndex(A=>A.value===N.defaultValue);return D>=0?D:0}return 0}),W=useMemo(()=>n.filter(N=>!N.skip?.(I)),[n,I]),S=W[T],U=W.length,{taLineNumWidth:oe,taContentWidth:ye}=useMemo(()=>{let N=String(M.length).length;return {taLineNumWidth:N,taContentWidth:Math.max(1,s-N-4)}},[M.length,s]),Ge=useMemo(()=>{if(!S||S.type!=="textarea")return [];let N=[];for(let O=0;O<M.length;O++){let D=Tc(M[O]??"",ye);for(let A=0;A<D.length;A++)N.push({logicalRow:O,startCol:A*ye,text:D[A],isFirst:A===0});}return N},[S?.id,S?.type,M,ye]),ze=useMemo(()=>{for(let N=0;N<Ge.length;N++){let O=Ge[N];if(O.logicalRow===C&&(P>=O.startCol&&P<O.startCol+ye||P>=O.startCol&&(N+1>=Ge.length||Ge[N+1].logicalRow!==C)))return N}return 0},[Ge,C,P,ye]),[ut,Ct]=useState(new Set),[gt,mt]=useState(false),[Ze,Je]=useState(0),[ft,ke]=useState(false),[Gt,It]=useState(null),[ht,Qe]=useState(false),rt=useRef(null),qe=useRef(null),xo=useMemo(()=>S?S.type==="text"?L:S.type==="textarea"?M.join(`
|
|
7
|
-
`):"":"",[S,L,M]),an=useCallback((N,O)=>{if(rt.current&&clearTimeout(rt.current),!O){It(null);return}rt.current=setTimeout(()=>{It(O(N));},300);},[]);useEffect(()=>(S&&S.validate&&(S.type==="text"||S.type==="textarea")&&an(xo,S.validate),()=>{rt.current&&clearTimeout(rt.current);}),[xo,S,an]),useEffect(()=>()=>{qe.current&&clearTimeout(qe.current);},[]);let Bt=useMemo(()=>!S||S.type!=="select"&&S.type!=="multiselect"?[]:S.getOptions?.(I)??S.options??[],[S,I]),zt=Math.min(H,Math.max(0,Bt.length-1)),Vt=useMemo(()=>{if(!S?.suggestions)return [];if(!L.trim())return S.suggestions;let N=L.toLowerCase();return S.suggestions.filter(O=>O.label.toLowerCase().includes(N)||(O.hint??"").toLowerCase().includes(N))},[S?.suggestions,L]),Yt=Math.min(Ze,Math.max(0,Vt.length-1)),ln=N=>{let O={...I,[S.id]:N};_(O),v.reset(""),R([""]),z(0),B(0),G(0),Ct(new Set),mt(false),Je(0),ke(false),It(null),Qe(false),rt.current&&clearTimeout(rt.current);let D=S.id,q=n.findIndex(ne=>ne.id===D)+1;for(;q<n.length;){let ne=n[q];if(ne&&!ne.skip?.(O))break;q++;}if(q>=n.length)o(O);else {let ne=n[q].id,pe=n.filter(Ae=>!Ae.skip?.(O)).findIndex(Ae=>Ae.id===ne);w(pe>=0?pe:0);let ae=n[q];if(ae.type==="text")v.reset(ae.defaultValue??"");else if(ae.type==="textarea"){let Ae=ae.defaultValue?ae.defaultValue.split(`
|
|
8
|
-
`):[""];R(Ae),z(Ae.length-1),B(Ae[Ae.length-1].length);}else if(ae.type==="select"){let Ae=ae.getOptions?.(O)??ae.options??[];if(ae.defaultValue){let Ce=Ae.findIndex(qn=>qn.value===ae.defaultValue);G(Ce>=0?Ce:0);}else G(0);}else ae.type==="multiselect"&&(G(0),ae.defaultValue?Ct(new Set(ae.defaultValue.split(","))):Ct(new Set));}},cn=()=>{if(T===0){r();return}let N=S.id,D=n.findIndex(pe=>pe.id===N)-1;for(;D>=0;){let pe=n[D];if(pe&&!pe.skip?.(I))break;D--;}if(D<0){r();return}let A=n[D].id,q=W.findIndex(pe=>pe.id===A);w(q>=0?q:0),mt(false),Je(0),ke(false),It(null),Qe(false),rt.current&&clearTimeout(rt.current);let ne=n[D];if(I[ne.id]&&ke(true),ne.type==="text")v.reset(I[ne.id]??ne.defaultValue??"");else if(ne.type==="textarea"){let pe=I[ne.id]??ne.defaultValue??"",ae=pe?pe.split(`
|
|
9
|
-
`):[""];R(ae),z(ae.length-1),B(ae[ae.length-1].length);}else if(ne.type==="multiselect"){G(0);let pe=I[ne.id];Ct(pe?new Set(pe.split(",")):new Set);}else {let pe=ne.getOptions?.(I)??ne.options??[],ae=I[ne.id],Ae=pe.findIndex(Ce=>Ce.value===ae);G(Ae>=0?Ae:0);}};if(useInput((N,O)=>{if(S){if(O.escape){T===0?r():cn();return}if((O.ctrl||O.meta)&&(N==="v"||N==="i")&&h&&(S.type==="text"||S.type==="textarea")){h();return}if(S.type==="text"){if(gt&&Vt.length>0){if(O.upArrow){Yt<=0?mt(false):Je(A=>A-1);return}if(O.downArrow){Je(A=>Math.min(Vt.length-1,A+1));return}if(O.return){let A=Vt[Yt];A&&f&&f(A.value);return}mt(false);}if(O.return||O.tab){let A=L.trim();if(S.required&&!A){ke(true);return}if(Gt!==null){ke(true),Qe(true),qe.current&&clearTimeout(qe.current),qe.current=setTimeout(()=>Qe(false),2e3);return}ln(A);return}if(O.downArrow&&S.suggestions&&Vt.length>0){mt(true),Je(0);return}if((O.backspace||O.delete)&&v.cursor.isEmpty&&T>0){cn();return}v.handleInput(N,O)&&(ke(true),mt(false),Je(0));return}if(S.type==="textarea"){if(O.return&&(O.ctrl||O.meta)||O.tab){let D=M.join(`
|
|
10
|
-
`).trim();if(S.required&&!D){ke(true);return}if(Gt!==null){ke(true),Qe(true),qe.current&&clearTimeout(qe.current),qe.current=setTimeout(()=>Qe(false),2e3);return}ln(D);return}if(O.return){ke(true),R(D=>{let A=D[C]??"",q=A.slice(0,P),ne=A.slice(P),Ie=[...D];return Ie.splice(C,1,q,ne),Ie}),z(D=>D+1),B(0);return}if(O.ctrl&&N==="a"){B(0);return}if(O.ctrl&&N==="e"){B((M[C]??"").length);return}if(O.ctrl&&N==="k"){ke(true),R(D=>{let A=[...D];return A[C]=(A[C]??"").slice(0,P),A});return}if(O.ctrl&&N==="u"){ke(true),R(D=>{let A=[...D];return A[C]=(A[C]??"").slice(P),A}),B(0);return}if(O.ctrl&&N==="w"){ke(true);let D=C,A=P,q=M[D]??"",ne=xi(q,A);R(Ie=>{let pe=[...Ie];return pe[D]=q.slice(0,ne)+q.slice(A),pe}),B(ne);return}if(O.meta&&(O.leftArrow||N==="b")){B(xi(M[C]??"",P));return}if(O.meta&&(O.rightArrow||N==="f")){B(yc(M[C]??"",P));return}if(O.upArrow){if(ze>0){let D=Ge[ze],A=Ge[ze-1],q=P-(D?.startCol??0),ne=Math.min(A.startCol+q,A.startCol+A.text.length);z(A.logicalRow),B(ne);}return}if(O.downArrow){if(ze<Ge.length-1){let D=Ge[ze],A=Ge[ze+1],q=P-(D?.startCol??0),ne=Math.min(A.startCol+q,A.startCol+A.text.length);z(A.logicalRow),B(ne);}return}if(O.leftArrow){P>0?B(D=>D-1):C>0&&(z(D=>D-1),B((M[C-1]??"").length));return}if(O.rightArrow){let D=(M[C]??"").length;P<D?B(A=>A+1):C<M.length-1&&(z(A=>A+1),B(0));return}if(O.backspace||O.delete){if(P===0&&C===0)return;if(P>0)R(D=>{let A=[...D],q=A[C]??"";return A[C]=q.slice(0,P-1)+q.slice(P),A}),B(D=>D-1);else {let D=(M[C-1]??"").length;R(A=>{let q=[...A],ne=q[C-1]??"",Ie=q[C]??"";return q.splice(C-1,2,ne+Ie),q}),B(D),z(A=>A-1);}return}if(N&&!O.ctrl&&!O.meta&&!O.escape){ke(true);let D=N.split(/\r?\n/);if(D.length===1)R(A=>{let q=[...A],ne=q[C]??"";return q[C]=ne.slice(0,P)+N+ne.slice(P),q}),B(A=>A+N.length);else {let A=C,q=P;R(ne=>{let Ie=[...ne],pe=Ie[A]??"",ae=pe.slice(0,q),Ae=pe.slice(q),Ce=D[0]??"",qn=D[D.length-1]??"",le=[ae+Ce,...D.slice(1,-1),qn+Ae];return Ie.splice(A,1,...le),Ie}),z(A+D.length-1),B((D[D.length-1]??"").length);}}return}if(S.type==="select"||S.type==="multiselect"){if(O.upArrow||N==="k"){G(D=>Math.max(0,D-1));return}if(O.downArrow||N==="j"){G(D=>Math.min(Bt.length-1,D+1));return}if(O.backspace||O.delete){cn();return}if(S.type==="select"){if(O.return||O.tab){let D=Bt[zt];if(D){if(S.validate){let A=S.validate(D.value);if(A!==null){ke(true),It(A),Qe(true),qe.current&&clearTimeout(qe.current),qe.current=setTimeout(()=>Qe(false),2e3);return}}ln(D.value);}return}if(N>="1"&&N<="9"){let D=parseInt(N,10)-1;if(D<Bt.length){let A=Bt[D];A&&ln(A.value);}return}}else {if(N===" "){let D=Bt[zt];D&&Ct(A=>{let q=new Set(A);return q.has(D.value)?q.delete(D.value):q.add(D.value),q});return}if(O.return||O.tab){let D=Array.from(ut).join(",");ln(D);return}}}}}),!S)return null;let vt=ft?Gt:null,Sn=Math.max(20,s-6),dn=`${T+1}/${U}`,kn=Math.max(2,m-4),jt=0;zt>=kn&&(jt=zt-kn+1);let Mt=Bt.slice(jt,jt+kn);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:[" ",He,He," "]}),jsxs(Text,{color:e.dim,children:["step ",dn]})]}),jsxs(Box,{children:[jsx(Text,{children:" "}),W.map((N,O)=>jsxs(Text,{color:O===T?e.amber:O<T?e.green:e.ghost,children:[O===T?"\u25CF":O<T?"\u2713":"\u25CB"," "]},N.id))]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.white,bold:true,children:[" ",S.label]}),S.required&&jsx(Text,{color:e.red,children:" *"}),!S.required&&jsxs(Text,{color:e.dim,children:[" (optional, ",S.type==="textarea"?`${Gr}+Enter/Tab`:"Enter/Tab"," to skip)"]})]}),S.description&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ",S.description]})}),S.type==="text"&&jsxs(Box,{flexDirection:"column",paddingLeft:2,children:[jsx(qo,{cursor:v.cursor,width:Sn-4,prefix:"> ",placeholder:S.placeholder,hasError:!!vt}),vt&&jsxs(Text,{color:e.red,dimColor:true,children:[" ",vt]}),ht&&jsx(Text,{color:e.red,children:" Fix the error above"})]}),S.type==="text"&&S.suggestions&&Vt.length>0&&(()=>{let N=Math.max(2,m-6),O=0;gt&&Yt>=N&&(O=Yt-N+1);let D=Vt.slice(O,O+N);return jsxs(Box,{flexDirection:"column",children:[jsxs(Text,{color:e.ghost,children:[" ",He,He,He," or browse templates ",He.repeat(Math.max(0,Sn-28))]}),D.map((A,q)=>{let ne=q+O,Ie=gt&&ne===Yt;return jsxs(Box,{children:[jsx(Text,{color:Ie?e.amber:e.ghost,children:Ie?" \u25B8 ":" "}),jsx(Text,{color:Ie?e.white:e.silver,bold:Ie,children:A.label}),A.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",He," ",A.hint.replace(/\n/g," ")]})]},A.value)})]})})(),S.type==="textarea"&&(()=>{let N=Math.max(3,m-6),O=0;ze>=N&&(O=ze-N+1);let D=Ge.slice(O,O+N);return jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{flexDirection:"column",borderStyle:vt?"round":void 0,borderColor:vt?e.red:void 0,children:[D.map((A,q)=>{let ne=q+O,Ie=A.isFirst?String(A.logicalRow+1).padStart(oe," "):"".padStart(oe," "),pe=ne===ze,ae=P-A.startCol;return jsxs(Box,{children:[jsxs(Text,{color:e.dim,children:[" ",Ie," "]}),jsxs(Text,{color:e.ghost,children:["\u2502"," "]}),pe?jsxs(Fragment,{children:[jsx(Text,{color:e.white,children:A.text.slice(0,ae)}),jsx(Text,{color:e.amber,children:bc}),jsx(Text,{color:e.white,children:A.text.slice(ae)})]}):jsx(Text,{color:e.silver,children:A.text||(A.isFirst?" ":"")})]},`${A.logicalRow}-${A.startCol}`)}),M.length===1&&M[0]===""&&S.placeholder&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","".padStart(oe," ")," ",S.placeholder]})})]}),vt&&jsxs(Text,{color:e.red,dimColor:true,children:[" ",vt]}),ht&&jsx(Text,{color:e.red,children:" Fix the error above"})]})})(),S.type==="select"&&jsxs(Box,{flexDirection:"column",children:[Mt.map((N,O)=>{let D=O+jt,A=D===zt,q=String(D+1).padStart(Bt.length>=10?2:1);return jsxs(Box,{children:[jsx(Text,{color:A?e.amber:e.ghost,children:A?" \u25B8 ":` ${q} `}),jsx(Text,{color:A?e.white:e.silver,bold:A,children:N.label}),N.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",He," ",N.hint.replace(/\n/g," ")]})]},N.value)}),vt&&jsxs(Text,{color:e.red,dimColor:true,children:[" ",vt]}),ht&&jsx(Text,{color:e.red,children:" Fix the error above"})]}),S.type==="multiselect"&&jsxs(Box,{flexDirection:"column",children:[Mt.map((N,O)=>{let A=O+jt===zt,q=ut.has(N.value);return jsxs(Box,{children:[jsx(Text,{color:A?e.amber:e.ghost,children:A?" \u25B8 ":" "}),jsx(Text,{color:q?e.green:e.dim,children:q?"[\u2713]":"[ ]"}),jsxs(Text,{color:A?e.white:e.silver,bold:A,children:[" ",N.label]}),N.hint&&jsxs(Text,{color:e.dim,wrap:"truncate",children:[" ",He," ",N.hint.replace(/\n/g," ")]})]},N.value)}),ut.size>0&&jsx(Box,{children:jsxs(Text,{color:e.dim,children:[" ","\u2514"," ",ut.size," selected"]})})]}),jsxs(Box,{marginTop:0,children:[jsxs(Text,{color:e.ghost,children:[" ",S.type==="select"?"\u2191\u2193 select Enter/Tab confirm":S.type==="multiselect"?"\u2191\u2193 move Space toggle Enter/Tab confirm":S.type==="textarea"?`Enter newline ${Gr}+Enter/Tab confirm \u2190\u2191\u2192\u2193 navigate`:gt?"\u2191\u2193 browse Enter select Tab confirm \u2191 back to input":S.suggestions?"\u2190\u2192 move Enter/Tab confirm \u2193 browse templates":"\u2190\u2192 move Enter/Tab confirm",h&&(S.type==="text"||S.type==="textarea")?` ${Gr}+V paste image`:""," Esc ",T>0?"back":"cancel"]}),y&&jsxs(Text,{color:e.amber,children:[" ",y]})]})]})}var wi=mo.memo(function({agents:n,selected:o,msgCounts:r,colorMap:s,maxHeight:m,onConfirm:h,onCancel:y}){let [f,T]=useState(0),[w,I]=useState(()=>new Set(o));useMemo(()=>w.size===0||w.size===n.length,[w.size,n.length]);let v=Math.max(3,m-5),L=useMemo(()=>{if(n.length<=v)return 0;let C=Math.floor(v/2),z=n.length-v;return Math.min(z,Math.max(0,f-C))},[f,n.length,v]),M=n.slice(L,L+v);useInput((C,z)=>{if(z.upArrow){T(P=>P>0?P-1:n.length-1);return}if(z.downArrow){T(P=>P<n.length-1?P+1:0);return}if(C===" "){let P=n[f];if(!P)return;I(B=>{let H=new Set(B);return H.has(P.id)?H.delete(P.id):H.add(P.id),H});return}if(C==="a"||C==="A"){I(P=>new Set);return}if(z.return){h(new Set(w));return}if(z.escape){y();return}});let R=w.size===0?n.length:w.size;return jsxs(Box,{flexDirection:"column",borderStyle:"round",borderColor:e.amber,paddingX:1,children:[jsxs(Box,{gap:1,children:[jsx(Text,{color:e.amber,bold:true,children:" \u25C8 Agent Filter"}),jsxs(Text,{color:e.dim,children:[ge," ",R,"/",n.length," selected"]})]}),jsx(Text,{color:e.ghost,children:He.repeat(36)}),M.map((C,z)=>{let B=z+L===f,H=w.size===0||w.has(C.id),G=s.get(C.id)??e.silver,W=r.get(C.id)??0;return jsxs(Box,{gap:0,children:[jsx(Text,{color:B?e.amber:e.ghost,children:B?" \u25B8 ":" "}),jsx(Text,{color:H?e.green:e.ghost,children:H?"[\u2713]":"[ ]"}),jsxs(Text,{color:B?G:H?e.silver:e.dim,bold:B,children:[" ",C.name]}),W>0&&jsxs(Text,{color:e.dim,children:[" ",ge,W]})]},C.id)}),n.length>v&&jsxs(Text,{color:e.ghost,children:[" ",L>0?"\u2191":" "," ",L+v<n.length?"\u2193":" "," ",f+1,"/",n.length]}),jsx(Text,{color:e.ghost,children:He.repeat(36)}),jsxs(Text,{color:e.dim,children:[" Space toggle"," ",ge," ","a all"," ",ge," ","Enter confirm"," ",ge," ","Esc cancel"]})]})});var vc={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},Mc={system:"System",lifecycle:"Lifecycle",output:"Output",tool:"Tool calls",result:"Results",error:"Errors",file:"Files",info:"Info"},_c={system:e.purple,lifecycle:e.cyan,output:e.white,tool:e.blue,result:e.green,error:e.red,file:e.purple,info:e.silver},St=["system","lifecycle","output","tool","result","error","file","info"],Ci=[{key:"1",label:"all",types:St},{key:"2",label:"text",types:["output"]},{key:"3",label:"tools",types:["tool","result","file"]},{key:"4",label:"errors",types:["error"]},{key:"5",label:"events",types:["lifecycle","system"]}],Ii=mo.memo(function({selected:n,typeCounts:o,onConfirm:r,onCancel:s}){let[m,h]=useState(0),[y,f]=useState(()=>new Set(n)),T=useMemo(()=>y.size===St.length||St.every(I=>y.has(I)),[y]);useInput((I,_)=>{if(_.upArrow){h(v=>v>0?v-1:St.length-1);return}if(_.downArrow){h(v=>v<St.length-1?v+1:0);return}if(I===" "){let v=St[m];if(!v)return;f(L=>{let M=new Set(L);return M.has(v)?M.delete(v):M.add(v),M});return}if(I==="a"||I==="A"){f(v=>v.size===St.length?new Set:new Set(St));return}for(let v of Ci)if(I===v.key){f(new Set(v.types));return}if(_.return){let v=y.size===0?new Set(St):new Set(y);r(v);return}if(_.escape){s();return}});let w=T?St.length:y.size;return jsxs(Box,{flexDirection:"column",borderStyle:"round",borderColor:e.amber,paddingX:1,children:[jsxs(Box,{gap:1,children:[jsx(Text,{color:e.amber,bold:true,children:" \u25C8 Type Filter"}),jsxs(Text,{color:e.dim,children:[ge," ",w,"/",St.length," selected"]})]}),jsx(Text,{color:e.ghost,children:He.repeat(36)}),St.map((I,_)=>{let v=_===m,L=y.has(I),M=o[I]??0,R=_c[I];return jsxs(Box,{gap:0,children:[jsx(Text,{color:v?e.amber:e.ghost,children:v?" \u25B8 ":" "}),jsx(Text,{color:L?e.green:e.ghost,children:L?"[\u2713]":"[ ]"}),jsxs(Text,{color:v?R:e.dim,children:[" ",vc[I]," "]}),jsx(Text,{color:v?R:L?e.silver:e.dim,bold:v,children:Mc[I]}),M>0&&jsxs(Text,{color:e.dim,children:[" ",ge,M]})]},I)}),jsx(Text,{color:e.ghost,children:He.repeat(36)}),jsxs(Box,{gap:0,children:[jsx(Text,{color:e.dim,children:" "}),Ci.map((I,_)=>jsxs(mo.Fragment,{children:[_>0&&jsxs(Text,{color:e.ghost,children:[" ",ge," "]}),jsx(Text,{color:e.amberDim,children:I.key}),jsxs(Text,{color:e.dim,children:["=",I.label]})]},I.key))]}),jsxs(Text,{color:e.dim,children:[" Space toggle"," ",ge," ","a all"," ",ge," ","Enter confirm"," ",ge," ","Esc cancel"]})]})});var Zo="\u256D",Jo="\u256E",Qo="\u2570",er="\u256F",ve="\u2502";function sn({children:t,cw:n}){return jsxs(Text,{children:[jsx(Text,{color:e.ghost,children:ve}),jsxs(Text,{children:[" ",t.padEnd(n)," "]}),jsx(Text,{color:e.ghost,children:ve})]})}function Yo({cw:t}){return jsx(sn,{cw:t,children:""})}function vi({width:t,height:n}){let o=Math.min(t-4,50),r=o-6,s=be(o-2);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[jsxs(Text,{color:e.ghost,children:[Zo,s,Jo]}),jsx(sn,{cw:r,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.amber,children:Ut}),jsx(Text,{color:e.white,bold:true,children:" Welcome to Orch"}),jsx(Text,{children:" ".repeat(Math.max(0,r-15-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(sn,{cw:r,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.silver,children:"Press N to create your first task".padEnd(r)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(sn,{cw:r,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.amber,children:"N"}),jsx(Text,{color:e.gray,children:" new task"}),jsx(Text,{children:" ".repeat(Math.max(0,r-1-1-8))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(sn,{cw:r,children:""}),jsxs(Text,{color:e.ghost,children:[Qo,s,er]})]})}function Mi({step:t,width:n}){let o=Math.min(n-4,50),r=o-6,s=be(o-2),m,h=null;if(t==="task_created")m="Press R to run task",h={key:"R",label:"run task"};else if(t==="run_started")m="Agent is running your task...";else return null;return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[jsxs(Text,{color:e.ghost,children:[Zo,s,Jo]}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.amber,children:Ut}),jsxs(Text,{color:e.silver,children:[" ",m.padEnd(h?r-2-h.key.length-1-h.label.length-2:r-2)]}),h&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",h.key]}),jsxs(Text,{color:e.gray,children:[" ",h.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsxs(Text,{color:e.ghost,children:[Qo,s,er]})]})}function _i({width:t}){let n=Math.min(t-4,50),o=n-6,r=be(n-2);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[jsxs(Text,{color:e.ghost,children:[Zo,r,Jo]}),jsx(sn,{cw:o,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.green,bold:true,children:"First task completed!"}),jsx(Text,{children:" ".repeat(Math.max(0,o-21))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(sn,{cw:o,children:""}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.silver,children:"Type / to see all commands".padEnd(o)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(sn,{cw:o,children:""}),jsxs(Text,{color:e.ghost,children:[Qo,r,er]})]})}function tr({count:t,config:n,width:o}){if(t>=3)return null;let r=Math.min((o??44)-4,50),s=r-6,m=be(r-2),h=jsxs(Text,{color:e.ghost,children:[Zo,m,Jo]}),y=jsxs(Text,{color:e.ghost,children:[Qo,m,er]});if(t>0){let T=n.hints[0],w=T?` ${T.key} ${T.label}`:"";return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[h,jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.amber,children:Ut}),jsxs(Text,{color:e.silver,children:[" ",n.nudge.padEnd(s-2-w.length)]}),T&&jsxs(Fragment,{children:[jsxs(Text,{color:e.amber,children:[" ",T.key]}),jsxs(Text,{color:e.gray,children:[" ",T.label]})]}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),y]})}let f=n.hints.reduce((T,w,I)=>T+w.key.length+1+w.label.length+(I>0?3:0),0);return jsxs(Box,{flexDirection:"column",paddingX:2,marginTop:1,children:[h,jsx(Yo,{cw:s}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.amber,children:Ut}),jsxs(Text,{color:e.white,bold:true,children:[" ",n.title]}),jsx(Text,{children:" ".repeat(Math.max(0,s-n.title.length-2))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(Yo,{cw:s}),n.description.map((T,w)=>jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),jsx(Text,{color:e.silver,children:T.padEnd(s)}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]},w)),jsx(Yo,{cw:s}),jsxs(Text,{children:[jsxs(Text,{color:e.ghost,children:[ve," "]}),n.hints.map((T,w)=>jsxs(mo.Fragment,{children:[w>0&&jsx(Text,{color:e.ghost,children:" "}),jsx(Text,{color:e.amber,children:T.key}),jsxs(Text,{color:e.gray,children:[" ",T.label]})]},w)),jsx(Text,{children:" ".repeat(Math.max(0,s-f))}),jsx(Text,{children:" "}),jsx(Text,{color:e.ghost,children:ve})]}),jsx(Yo,{cw:s}),y]})}var Ai={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."},$i={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."},Bi={title:"Agents",description:["AI workers that execute your tasks.","Adapters: claude, opencode, codex, cursor,","pi, grok, antigravity, shell."],hints:[{key:"N",label:"new agent"},{key:"W",label:"start orchestrator"}],nudge:"Add more agents to increase parallelism."};var Ac=2,Li=360,$c={done:4e3,failed:8e3,review:6e3},Bc={done:"\u2713",failed:"\u2715",review:Qt},Ec={done:e.green,failed:e.red,review:e.blue},Oc={done:e.successBg,failed:e.errorBg,review:e.infoBg};function Lc(t){let n=t.agentName??"Agent";switch(t.type){case "done":return `Task completed by ${n}`;case "failed":return "Task failed \u2014 press Enter for details";case "review":return "Task ready for review \u2014 press A to approve"}}var Pc=mo.memo(function({toast:n,onDismiss:o}){let[r,s]=useState(true),[m,h]=useState(false);useEffect(()=>{let v=setTimeout(()=>s(false),Li);return ()=>clearTimeout(v)},[]),useEffect(()=>{let v=$c[n.type],L=setTimeout(()=>h(true),v),M=setTimeout(()=>o(n.id),v+Li);return ()=>{clearTimeout(L),clearTimeout(M);}},[n.id,n.type,o]);let y=r||m,f=Bc[n.type],T=Ec[n.type],w=Oc[n.type],I=Lc(n),_=n.title.length>40?n.title.slice(0,39)+"\u2026":n.title;return jsx(Box,{children:jsxs(Text,{backgroundColor:w,children:[jsxs(Text,{color:y?e.dim:T,children:[" ",f," "]}),jsx(Text,{color:y?e.dim:e.white,bold:!y,children:_}),jsxs(Text,{color:y?e.dim:e.silver,children:[" ",I," "]})]})})}),Di=mo.memo(function({toasts:n,onDismiss:o}){let r=n.slice(0,Ac);return r.length===0?null:jsx(Box,{flexDirection:"column",children:r.map(s=>jsx(Pc,{toast:s,onDismiss:o},s.id))})});var Fc="\u256D",Wc="\u256E",Gc="\u2570",zc="\u256F",dt="\u2502",jr=[{key:"\u2191\u2193/j/k",label:"Navigate"},{key:"Tab/\u2190\u2192",label:"Switch tabs"},{key:"Enter",label:"Detail view"},{key:"G",label:"Goals tab"},{key:"T",label:"Tasks tab"},{key:"A",label:"Agents tab"},{key:"L",label:"Logs tab"}],Hr=[{key:"N",label:"New item"},{key:"E",label:"Edit"},{key:"D",label:"Delete"},{key:"R",label:"Run task"},{key:"S",label:"Show / Stop"},{key:"C",label:"Cancel"},{key:"A",label:"Approve"},{key:"X",label:"Reject"},{key:"U",label:"Autonomous"},{key:"Z",label:"Undo delete"}],Ur=[{key:"/",label:"Command mode"},{key:"/task add",label:"Create task"},{key:"/run",label:"Execute"},{key:"/watch",label:"Auto-dispatch"},{key:"/config",label:"Settings"},{key:"/help",label:"Help"},{key:"/quit",label:"Exit"}],Hn=10,Kt=22;function Xr(t){let n=Math.max(0,Math.floor((Kt-t.length-2)/2)),o=Math.max(0,Kt-n-t.length-2);return be(n)+" "+t+" "+be(o)}var Fi=mo.memo(function({width:n,height:o}){let r=Kt*3+3+3+2,s=r+2,m=be(s-2),h="KEYBOARD SHORTCUTS",y=Math.max(0,Math.floor((r-h.length)/2)),f=Math.max(0,r-y-h.length),T="Press any key to dismiss",w=Math.max(0,Math.floor((r-T.length)/2)),I=Math.max(0,r-w-T.length),_=Math.max(jr.length,Hr.length,Ur.length),v=_+10,L=Math.max(0,Math.floor((o-v)/2)),M=[];for(let B=0;B<_;B++){let H=B<jr.length?jr[B]:null,G=B<Hr.length?Hr[B]:null,W=B<Ur.length?Ur[B]:null;M.push(jsxs(Text,{children:[jsx(Text,{color:e.amber,children:dt}),jsx(Text,{children:" "}),H?jsxs(Fragment,{children:[jsx(Text,{color:e.amber,bold:true,children:H.key.padEnd(Hn)}),jsx(Text,{color:e.silver,children:H.label.padEnd(Kt-Hn)})]}):jsx(Text,{children:" ".repeat(Kt)}),jsxs(Text,{color:e.dim,children:[" ",dt," "]}),G?jsxs(Fragment,{children:[jsx(Text,{color:e.amber,bold:true,children:G.key.padEnd(Hn)}),jsx(Text,{color:e.silver,children:G.label.padEnd(Kt-Hn)})]}):jsx(Text,{children:" ".repeat(Kt)}),jsxs(Text,{color:e.dim,children:[" ",dt," "]}),W?jsxs(Fragment,{children:[jsx(Text,{color:e.amber,bold:true,children:W.key.padEnd(Hn)}),jsx(Text,{color:e.silver,children:W.label.padEnd(Kt-Hn)})]}):jsx(Text,{children:" ".repeat(Kt)}),jsx(Text,{children:" "}),jsx(Text,{color:e.amber,children:dt})]},`r${B}`));}let R=B=>jsxs(Text,{children:[jsx(Text,{color:e.amber,children:dt}),jsx(Text,{children:" ".repeat(r)}),jsx(Text,{color:e.amber,children:dt})]},B),C=Xr("NAVIGATION"),z=Xr("ACTIONS"),P=Xr("COMMANDS");return jsxs(Box,{flexDirection:"column",paddingX:Math.max(0,Math.floor((n-s)/2)),marginTop:L,children:[jsxs(Text,{color:e.amber,children:[Fc,m,Wc]}),R("e1"),jsxs(Text,{children:[jsx(Text,{color:e.amber,children:dt}),jsx(Text,{children:" ".repeat(y)}),jsx(Text,{color:e.amber,bold:true,children:h}),jsx(Text,{children:" ".repeat(f)}),jsx(Text,{color:e.amber,children:dt})]}),R("e2"),jsxs(Text,{children:[jsx(Text,{color:e.amber,children:dt}),jsx(Text,{children:" "}),jsx(Text,{color:e.dim,children:C}),jsxs(Text,{color:e.dim,children:[" ",dt," "]}),jsx(Text,{color:e.dim,children:z}),jsxs(Text,{color:e.dim,children:[" ",dt," "]}),jsx(Text,{color:e.dim,children:P}),jsx(Text,{children:" "}),jsx(Text,{color:e.amber,children:dt})]}),R("e3"),M,R("e4"),jsxs(Text,{children:[jsx(Text,{color:e.amber,children:dt}),jsx(Text,{children:" ".repeat(w)}),jsx(Text,{color:e.dim,children:T}),jsx(Text,{children:" ".repeat(I)}),jsx(Text,{color:e.amber,children:dt})]}),R("e5"),jsxs(Text,{color:e.amber,children:[Gc,m,zc]})]})});function zi(t,n){if(!t){let r=n?.claude;return r?.length?r:a$5("claude")}if(!b$1(t))return a$5(t);let o=n?.[t];return o?.length?o:a$5(t)}var Vi=[{value:"",label:"Default",hint:"no override \u2014 use model default"},{value:"high",label:"High",hint:"deepest reasoning, best quality, slowest"},{value:"medium",label:"Medium",hint:"balanced speed and quality"},{value:"low",label:"Low",hint:"fastest responses, minimal reasoning"}],ji=new Set(["claude","pi","grok"]),Vc=[{value:"claude",label:"Claude",hint:"Claude Code CLI"},{value:"opencode",label:"OpenCode",hint:"OpenCode \u2014 multi-provider"},{value:"codex",label:"Codex",hint:"OpenAI Codex CLI"},{value:"cursor",label:"Cursor",hint:"Cursor Agent CLI"},{value:"pi",label:"Pi",hint:"Pi coding agent RPC"},{value:"grok",label:"Grok",hint:"Grok CLI"},{value:"antigravity",label:"Antigravity",hint:"Google Antigravity CLI (agy)"},{value:"shell",label:"Shell",hint:"custom shell command"}],Hi=[{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"}],Wi=60;function Ui(t){return t.filter(n=>n.status!=="disabled").map(n=>{let o=(n.role??"").split(`
|
|
11
|
-
`)[0].trim(),r=o.length>Wi?o.slice(0,Wi-1)+"\u2026":o,s=r?`[${n.adapter}] ${r}`:n.adapter;return {value:n.id,label:n.name,hint:s}})}function rr(t,n="Auto-assign",o="orchestrator picks the best agent"){return [{value:"",label:n,hint:o},...Ui(t)]}var Kr=[{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 Xi(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 qi(){return [{id:"shop_template",label:"Agent Shop \u2014 choose a template",type:"select",options:a$2.map(t=>({value:t.key,label:t.name,hint:t.description}))}]}function Yr(t,n,o){let r=a$3(o,n.tier);return t.map(s=>{switch(s.id){case "name":return {...s,defaultValue:n.name};case "adapter":return {...s,defaultValue:o};case "model":return {...s,defaultValue:r};case "role":return {...s,defaultValue:"__custom__"};case "role_custom":return {...s,defaultValue:n.role,skip:void 0};case "skills":{let m=o==="claude"?n.skills:n.skills.filter(h=>!a$4(h));return {...s,defaultValue:m.join(", ")}}case "approval_policy":return {...s,defaultValue:n.approval_policy};default:return s}})}function sr(t,n,o){let r=Xi(n);return [{id:"name",label:"Agent name",type:"text",placeholder:"e.g. alpha, frontend-bot, reviewer",required:true,validate:s=>s.trim()?t?.some(m=>m.name===s.trim())?"Agent with this name already exists":null:"Name is required",suggestions:a$2.map(s=>({value:s.key,label:s.name,hint:s.description}))},{id:"adapter",label:"Provider",type:"select",options:Vc},{id:"model",label:"Model",type:"select",getOptions:s=>zi(s.adapter,o)},{id:"effort",label:"Reasoning effort",type:"select",options:Vi,skip:s=>!ji.has(s.adapter??"")},{id:"role",label:"Role / specialization",type:"select",options:Kr},{id:"role_custom",label:"Describe the role",type:"textarea",placeholder:"e.g. Specialist in React and TypeScript",skip:s=>s.role!=="__custom__"},{id:"skills",label:"Skills (comma-separated)",type:"text",placeholder:"e.g. feature-dev:feature-dev, testing-suite:generate-tests"},{id:"approval_policy",label:"Approval policy",type:"text",skip:()=>true},{id:"team",label:"Join team",type:"select",options:r,skip:()=>r.length<=1}]}function Ki(t,n="claude"){let o=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0,r=t.skills?t.skills.split(",").map(h=>h.trim()).filter(Boolean):void 0,s=t.approval_policy||"auto",m=t.effort||void 0;return {name:t.name,adapter:t.adapter||n,role:o,model:t.model||void 0,effort:m,approval_policy:s,skills:r,team_id:t.team||void 0}}function Yi(t,n){let o=Ui(t);return [{id:"name",label:"Team name",type:"text",placeholder:"e.g. frontend, backend, qa",required:true,validate:r=>r.trim()?n?.some(s=>s.name===r.trim())?"Team with this name already exists":null:"Name is required"},{id:"lead",label:"Team lead",type:"select",options:o},{id:"members",label:"Team members",type:"multiselect",getOptions:r=>o.filter(s=>s.value!==r.lead),skip:r=>!o.some(s=>s.value!==r.lead)},{id:"description",label:"Description",type:"textarea",placeholder:"Optional team purpose..."}]}function Zi(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 Ji(t){let n=rr(t);return [{id:"title",label:"Task title",type:"text",placeholder:"What needs to be done?",required:true,validate:o=>o.trim()?null:"Title is required"},{id:"priority",label:"Priority",type:"select",options:Hi,defaultValue:"3",validate:o=>{let r=Number(o);return !Number.isInteger(r)||r<1||r>4?"Priority must be 1-4":null}},{id:"assignee",label:"Assignee",type:"select",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Optional details, context, acceptance criteria..."}]}function Qi(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 ea(t,n){let o=rr(n,"None / Auto","remove assignee");return [{id:"title",label:"Task title",type:"text",defaultValue:t.title,required:true,validate:r=>r.trim()?null:"Title is required"},{id:"priority",label:"Priority",type:"select",options:Hi,defaultValue:String(t.priority),validate:r=>{let s=Number(r);return !Number.isInteger(s)||s<1||s>4?"Priority must be 1-4":null}},{id:"assignee",label:"Assignee",type:"select",options:o,defaultValue:t.assignee??"",skip:()=>o.length<=1},{id:"description",label:"Description",type:"textarea",defaultValue:t.description||"",placeholder:"Optional details..."}]}function ta(t){return {title:t.title,priority:t.priority?parseInt(t.priority,10):void 0,assignee:t.assignee||void 0,description:t.description??""}}function na(t,n,o,r){let s=Kr.find(T=>T.value===t.role),m=s?t.role:t.role?"__custom__":"",h=zi(t.adapter,r),y=Xi(o),f=o?.find(T=>T.members.some(w=>w.agent_id===t.id))?.id;return [{id:"name",label:"Agent name",type:"text",defaultValue:t.name,required:true,validate:T=>T.trim()?n?.some(w=>w.id!==t.id&&w.name===T.trim())?"Agent with this name already exists":null:"Name is required"},{id:"model",label:"Model",type:"select",options:h,defaultValue:t.config.model??""},{id:"effort",label:"Reasoning effort",type:"select",options:Vi,defaultValue:t.config.effort??"",skip:()=>!ji.has(t.adapter)},{id:"role",label:"Role / specialization",type:"select",options:Kr,defaultValue:m},{id:"role_custom",label:"Describe the role",type:"textarea",defaultValue:t.role&&!s?t.role:"",placeholder:"e.g. Specialist in React and TypeScript",skip:T=>T.role!=="__custom__"},{id:"team",label:"Team",type:"select",options:y,defaultValue:f??"",skip:()=>y.length<=1}]}var jc=[{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"}],Hc=[{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"}],Gi=[{value:"true",label:"On"},{value:"false",label:"Off"}];function oa(t,n,o){let r=o??{toast:true,bell:false};return [{id:"activity_filter",label:"Activity filter preset",type:"select",options:Hc,defaultValue:t},{id:"max_concurrent",label:"Max concurrent agents",type:"select",options:jc,defaultValue:String(n)},{id:"notifications_toast",label:"Toast notifications",type:"select",options:Gi,defaultValue:String(r.toast)},{id:"notifications_bell",label:"Bell on completion",type:"select",options:Gi,defaultValue:String(r.bell)}]}function ra(t){let n=t.role==="__custom__"?t.role_custom||void 0:t.role||void 0,o=t.effort||void 0;return {name:t.name,role:n,model:t.model||void 0,effort:o,team_id:t.team||void 0}}function ir(t){let n=rr(t,"Any agent","auto-assign to autonomous agents");return [{id:"title",label:"Goal title",type:"text",placeholder:'e.g. "Implement OAuth2 login with Google and GitHub"',description:"Be specific \u2014 agents work better with clear, measurable objectives",required:true,validate:o=>o.trim()?null:"Title is required"},{id:"assignee",label:"Assignee",type:"select",description:"Assigned agent gets autonomous mode \u2014 it will plan and execute without prompts",options:n,skip:()=>n.length<=1},{id:"description",label:"Description",type:"textarea",placeholder:"Success criteria, constraints, technical context...",description:'Context matters \u2014 include tech stack, constraints, and what "done" looks like'}]}function sa(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description||void 0}}function ia(t,n){let o=rr(n,"Any agent","auto-assign");return [{id:"title",label:"Goal title",type:"text",defaultValue:t.title,description:"Be specific \u2014 agents work better with clear, measurable objectives",required:true,validate:r=>r.trim()?null:"Title is required"},{id:"assignee",label:"Assignee",type:"select",description:"Assigned agent gets autonomous mode \u2014 it will plan and execute without prompts",options:o,defaultValue:t.assignee??"",skip:()=>o.length<=1},{id:"description",label:"Description",type:"textarea",defaultValue:t.description||"",placeholder:"Success criteria, constraints, technical context...",description:'Context matters \u2014 include tech stack, constraints, and what "done" looks like'}]}function aa(t){return {title:t.title,assignee:t.assignee||void 0,description:t.description??""}}var la=10,ca=500,gr=2048,wn=500,da=5,Zr=new Set(["todo","failed","cancelled"]),ua=5e3,ma=0;function Hg(){ma=0;}var fa=/^\[[\w_]+\]$/;function pa(t){return fa.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 es=["#5faf87","#5fafd7","#af87ff","#d7af00","#5fd7d7","#d787af","#afaf5f","#d7875f"],Kc=" ".repeat(9),Xn={system:"\u2666",lifecycle:"\u25B6",output:"\u2502",tool:"\u2699",result:"\u2190",error:"\u2715",file:"\u270E",info:"\u2502"},dr=["system","lifecycle","output","tool","result","error","file","info"],Un=[{label:"all",types:dr},{label:"text",types:["output"]},{label:"tools",types:["tool","result","file"]},{label:"errors",types:["error"]},{label:"events",types:["lifecycle","system"]}];function Jr(t){let o=(Un.findIndex(r=>r.types.length===t.size&&r.types.every(s=>t.has(s)))+1)%Un.length;return Un[o]}function Qr(t,n){if(t.length!==n.length)return true;for(let o=0;o<t.length;o++)if(t[o].id!==n[o].id||t[o].updated_at!==n[o].updated_at)return true;return false}function Ug({projectName:t,tasks:n,agents:o=[],state:r,onRunTask:s,onCreateTask:m,onCancelTask:h,onRetryTask:y,onAssignTask:f,onRunAll:T,onDisableAgent:w,onEnableAgent:I,onSubscribeEvents:_,onRefreshTasks:v,onRefreshAgents:L,onRefreshState:M,onLoadHistory:R,onAddAgent:C,onDeleteAgent:z,onApproveTask:P,onRejectTask:B,onDeleteTask:H,onUpdateTask:G,onUpdateAgent:W,onForceStopAgent:S,onCreateTeam:U,onListTeams:ie,onJoinTeam:oe,onLeaveTeam:ye,onDisbandTeam:Ge,onSetTeamLead:ze,onStartWatch:ut,onStopWatch:Ct,onToggleAutonomous:gt,onRefreshGoals:mt,onCreateGoal:Ze,onUpdateGoal:Je,onUpdateGoalStatus:ft,onDeleteGoal:ke,onGetGoalProgress:Gt,onCompleteOnboarding:It,initialWatchActive:ht,observerMode:Qe,watchError:rt,messageBatchMs:qe=process.env.VITEST?0:80,initialActivityFilter:xo="all",onSaveActivityFilter:an,initialMaxConcurrent:Bt=a.scheduling.max_concurrent_agents,onSaveMaxConcurrent:zt,initialNotifications:Vt,onSaveNotifications:Yt,version:ln,latestVersion:cn,onCheckUpdate:vt,onBackgroundInstall:Sn,defaultAdapter:dn="claude",onLoadModelCatalog:kn}){let{exit:jt}=useApp(),{stdout:Mt}=useStdout(),[N,O]=useState(cn),D=useRef(vt);useEffect(()=>{if(cn||!D.current)return;let i=setTimeout(()=>{D.current?.().then(x=>{x&&O(x);}).catch(()=>{});},5e3);return ()=>clearTimeout(i)},[cn]);let[A,q]=useState(false),ne=useRef(false);useEffect(()=>{!N||!Sn||ne.current||A||(ne.current=true,Sn(N).then(i=>{i&&q(true);}).catch(()=>{}));},[N,Sn,A]);let[Ie,pe]=useState({w:Mt?.columns??80,h:Mt?.rows??24});useEffect(()=>{if(!Mt)return;let i=()=>pe({w:Mt.columns,h:Mt.rows});return Mt.on("resize",i),()=>{Mt.off("resize",i);}},[Mt]);let ae=Ie.w,Ae=Ie.h,[Ce,qn]=useState(n),[le,wa]=useState(o),[Ve,Sa]=useState(r),[bo,mr]=useState(ht??!!r.pid),[Zt,ka]=useState({}),[Kn,ts]=useState([]),[Ca,ns]=useState(void 0),[Jt,To]=useState(()=>r.onboardingCompleted||(r.stats?.total_tasks_completed??0)>0?"dismissed":Object.keys(r.running??{}).length>0?"run_started":n.length>0?"task_created":"welcome");useEffect(()=>{if(Jt!=="completed")return;let i=setTimeout(()=>{To("dismissed"),It?.().catch(()=>{});},5e3);return ()=>clearTimeout(i)},[Jt,It]);let[E,Cn]=useState("tasks"),[yo,Yn]=useState(0),[fr,os]=useState(0),[pr,rs]=useState(0),[$e,Zn]=useState(false),[je,ss]=useState([]),[Ne,Le]=useState("none"),xt=Xo(),un=xt.value,[bt,et]=useState(null),[gn,Jn]=useState([]),[Et,hr]=useState(false),[is,Ia]=useState(()=>new Set),[In,xr]=useState(false),[Qn,br]=useState(false),[as,ls]=useState(()=>new Set(dr)),[eo,Tr]=useState(-1),[va,to]=useState(0),[vn,yr]=useState(()=>{let i=Un.find(x=>x.label===xo);return new Set(i?.types??dr)}),wo=useMemo(()=>Un.find(x=>x.types.length===vn.size&&x.types.every(l=>vn.has(l)))?.label??"all",[vn]),wr=useMemo(()=>vn.size>=dr.length?je:je.filter(i=>vn.has(i.msgType??"info")),[je,vn]),[cs,Ma]=useState(Bt),[So,_a]=useState(Vt??{toast:true,bell:false}),[Ra,ds]=useState([]),Aa=useRef(0),[Sr,us]=useState(),gs=useRef(E);gs.current=E;let ms=useRef(Ce);ms.current=Ce;let fs=useRef(le);fs.current=le;let ko=useRef(So);ko.current=So;let Co=useCallback((i,x)=>{if(!ko.current.toast)return;let l=ms.current.find(b=>b.id===x),c=l?.title??x,u=l?.assignee?fs.current.find(b=>b.id===l.assignee):void 0;ds(b=>{let g=[...b,{id:`toast_${Aa.current++}`,type:i,title:c,agentName:u?.name,ts:Date.now()}];return g.length>da?g.slice(g.length-da):g}),ko.current.bell&&(i==="failed"||i==="review")&&process.stdout.write("\x07");},[]),$a=useCallback(i=>{ds(x=>x.filter(l=>l.id!==i));},[]),Io=mo.useRef(new jo).current,[Ba,Mn]=useState(0),[ps,hs]=useState(false),[no,Ea]=useState(false),[Oa,kr]=useState(0),[La,Cr]=useState(0),[Ir,_n]=useState(0),[vo,vr]=useState(false),[Pa,oo]=useState(0),[Mo,mn]=useState(0),[Ht,xs]=useState([]),[Rn,Mr]=useState([]),An=useRef(Ht);An.current=Ht;let bs=useRef(0),K=useCallback(async i=>{bs.current=Date.now();let[x,l,c,u,b]=await Promise.all([v?.()??Promise.resolve(Ce),L?.()??Promise.resolve(le),M?.()??Promise.resolve(Ve),i?.includeTeams?ie?.()??Promise.resolve(An.current):Promise.resolve(null),mt?.()??Promise.resolve(Kn)]);qn(g=>Qr(g,x)?x:g),wa(g=>Qr(g,l)?l:g),Sa(c),u!==null&&xs(u),ts(g=>Qr(g,b)?b:g),ht&&mr(!!c.pid);},[v,L,M,ie,mt,ht]),$n=useMemo(()=>{let i=new Map;for(let x of Kn)i.set(x.id,x);return i},[Kn]),Pe=useMemo(()=>{let i=[...Ce].sort((b,g)=>(co[b.status]??9)-(co[g.status]??9));if(!no)return i;let x=[],l=[],c=[],u=new Map;for(let b of i)b.goalId&&$n.has(b.goalId)?(u.has(b.goalId)||(c.push(b.goalId),u.set(b.goalId,[])),u.get(b.goalId).push(b)):l.push(b);for(let b of c)x.push(...u.get(b));return [...x,...l]},[Ce,no,$n]),Ot=ps?Pe:Pe.slice(0,la),Bn=Pe.length-Ot.length,j=Pe[yo],ro=useMemo(()=>{let i=new Map;for(let x of Ce)i.set(x.id,x.title);return i},[Ce]),fn=useMemo(()=>{let i=new Map;for(let x of le)i.set(x.id,x.name);return i},[le]),Na=useMemo(()=>{let i=new Map;for(let x of Ce)if(x.goalId){let l=i.get(x.goalId);l||(l=[],i.set(x.goalId,l)),l.push(x);}return i},[Ce]),_o=useMemo(()=>{let i=new Map;for(let x=0;x<le.length;x++)i.set(le[x].id,es[x%es.length]);return i},[le]),Ts=useMemo(()=>{let i=new Map;for(let x of je)x.agentId&&i.set(x.agentId,(i.get(x.agentId)??0)+1);return i},[je]),Da=useMemo(()=>{let i={};for(let x of je){let l=x.msgType??"info";i[l]=(i[l]??0)+1;}return i},[je]),{agentTeamMap:En,activeTeamCount:so,teamLeadSet:Fa}=useMemo(()=>{let i=new Map,x=new Set,l=0;for(let c of Ht)if(c.status==="active"){l++,x.add(c.lead_agent_id);for(let u of c.members)i.set(u.agent_id,c.name);}return {agentTeamMap:i,activeTeamCount:l,teamLeadSet:x}},[Ht]),De=useMemo(()=>{let i=[...le];return i.sort((x,l)=>{let c=En.get(x.id),u=En.get(l.id);return c&&!u?-1:!c&&u?1:c&&u&&c!==u?c.localeCompare(u):(Nr[x.status]??9)-(Nr[l.status]??9)}),i},[le,En]),Z=De[fr],pt=useMemo(()=>[...Kn].sort((i,x)=>(c[i.status]??9)-(c[x.status]??9)),[Kn]),ee=pt[pr],Wa=useMemo(()=>ee?Ce.filter(i=>i.goalId===ee.id):[],[ee,Ce]),_r=useRef(Gt);_r.current=Gt,useEffect(()=>{if(!ee||!_r.current){ns(void 0);return}let i=false;return _r.current(ee.id).then(x=>{i||ns(x);}).catch(()=>{}),()=>{i=true;}},[ee?.id]);let pn=useRef(new Map),Ro=useRef(new Map);useEffect(()=>{for(let[i,x]of Object.entries(Ve.running))pn.current.set(x.run_id,x.agent_id),Ro.current.set(x.run_id,i);if(pn.current.size>ca){let i=pn.current.size-ca,x=0;for(let l of pn.current.keys()){if(x++>=i)break;pn.current.delete(l),Ro.current.delete(l);}}},[Ve.running]);let hn=useRef([]),io=useRef(null),Rr=useCallback(()=>{if(io.current=null,hn.current.length===0)return;let i=hn.current;hn.current=[],ss(x=>{if(i.length>=wn)return i.slice(-wn);let l=wn-i.length;return (x.length>l?x.slice(-l):x).concat(i)});},[]);useEffect(()=>()=>{io.current&&clearTimeout(io.current);},[]);let a=useCallback((i,x,l)=>{let c=new Date,u=c.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),b=l?.detail&&l.detail.length>gr?l.detail.slice(0,gr)+"\u2026[truncated]":l?.detail;hn.current.push({text:i,color:x,time:u,ts:c.getTime(),...l,detail:b}),hn.current.length>wn&&(hn.current=hn.current.slice(-wn)),qe===0?Rr():io.current||(io.current=setTimeout(Rr,qe));},[Rr]);useEffect(()=>{Qe?a("Observer mode: watching external orchestrator via disk polling.",e.amber):rt&&a(`Watch mode failed: ${rt}. Tasks will not auto-dispatch.`,e.red);},[]),useEffect(()=>{let i=Qe?3e3:5e3,x=setInterval(()=>{Date.now()-bs.current>=i&&K().catch(()=>{});},i);return ()=>clearInterval(x)},[Qe,K]);let On=useCallback((i,x,l,c)=>{let u={key:++ma,entityType:i,entityId:x,entityName:l,expiresAt:Date.now()+ua,needsForceStop:c?.needsForceStop};Mr(b=>[...b,u]),a(`\u2717 "${l}" will be deleted in ${Math.round(ua/1e3)}s \u2014 press Z to undo`,e.yellow);},[a]),Ga=useCallback(()=>{Mr(i=>{if(i.length===0)return i;let x=i[i.length-1];return a(`\u21B6 Undo: "${x.entityName}" restored`,e.green),i.slice(0,-1)});},[a]),ys=useCallback(async i=>{try{i.entityType==="task"&&H?await H(i.entityId):i.entityType==="agent"?(i.needsForceStop&&S&&await S(i.entityId),z&&await z(i.entityId)):i.entityType==="goal"&&ke&&await ke(i.entityId),a(`\u2713 Deleted "${i.entityName}"`,e.green),K();}catch(x){a(`Failed to delete "${i.entityName}": ${x instanceof Error?x.message:String(x)}`,e.red);}},[H,z,ke,S,a,K]),ws=useRef(ys);ws.current=ys,useEffect(()=>{if(Rn.length===0)return;let i=setInterval(()=>{let x=Date.now(),l=[];Mr(c=>{let u=c.filter(b=>b.expiresAt<=x?(l.push(b),false):true);return l.length>0?u:c});for(let c of l)ws.current(c);},1e3);return ()=>clearInterval(i)},[Rn.length>0]),useEffect(()=>{if(!R)return;let i=x=>{let l=new Date(x.timestamp).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"}),c=typeof x.data=="string"?x.data:JSON.stringify(x.data),u,b=e.silver,g="output";if(x.type==="error")u=typeof x.data=="string"?x.data:JSON.stringify(x.data),u=u.slice(0,200),b=e.red,g="error";else if(x.type==="file_changed")u=String(x.data),b=e.purple,g="file";else if(x.type==="done")u="Completed",b=e.green,g="lifecycle";else if(x.type==="tool_call")u=`\u2699 ${x.data?.name??"tool"}()`,b=e.cyan,g="tool";else {let{summary:k}=ya(c);if(!k)return null;u=k;let Y=pa(u);g=Y.msgType,b=Y.color;}return {text:u,color:b,time:l,ts:new Date(x.timestamp).getTime(),agentId:x.agentId,taskId:x.taskId,msgType:g}};R(x=>{if(x.length===0)return;let l=x.map(i).filter(c=>c!==null);ss(c=>{let u=[...l,...c];return u.length>wn?u.slice(-wn):u});}).catch(x=>{process.stderr.write(`[TUI] onLoadHistory error: ${x instanceof Error?x.stack??x.message:String(x)}
|
|
12
|
-
`);});},[]),useEffect(()=>{ie?.().then(xs).catch(()=>{}),mt?.().then(ts).catch(()=>{});},[]),useEffect(()=>{let i=false;return kn?.().then(x=>{i||ka(x);}).catch(()=>{}),()=>{i=true;}},[kn]);let Ao=useCallback(()=>{et({title:"NEW AGENT",steps:sr(le,An.current,Zt),kind:"agent"}),Le("wizard");},[le,Zt]),Ss=useCallback(()=>{et({title:"AGENT SHOP",steps:qi(),kind:"agent_shop"}),Le("wizard");},[]),$o=useCallback(()=>{Jn([]),et({title:"NEW TASK",steps:Ji(le),kind:"task"}),Le("wizard");},[le]),za=useCallback(async()=>{try{let{detectClipboardType:i,getClipboardImage:x}=await import('./clipboard-service-AJTJG2DJ.js'),l=await i();if(l!=="image")return a(l==="text"?"Clipboard has text, not image":"Clipboard is empty",e.dim),l;let c=await x();if(!c)return a("Failed to read clipboard image",e.red),"empty";let{mkdtemp:u,writeFile:b}=await import('fs/promises'),{tmpdir:g}=await import('os'),{join:k}=await import('path'),Y=await u(k(g(),"orch-paste-")),Pt=k(Y,`clipboard-${Date.now()}.${c.ext}`);return await b(Pt,c.data),Jn(xn=>[...xn,Pt]),a(`\u{1F4CE} Image attached (${Math.round(c.data.length/1024)}KB)`,e.green),"image"}catch{return a("Clipboard paste failed",e.red),"empty"}},[a]),Va=useCallback(i=>{et({title:"EDIT TASK",steps:ea(i,le),kind:"edit_task",targetId:i.id}),Le("wizard");},[le]),ks=useCallback(()=>{et({title:"NEW TEAM",steps:Yi(le,Ht),kind:"team"}),Le("wizard");},[le]),ja=useCallback(i=>{et({title:"EDIT AGENT",steps:na(i,le,Ht,Zt),kind:"edit_agent",targetId:i.id}),Le("wizard");},[le,Ht,Zt]),Cs=useCallback(()=>{et({title:"SETTINGS",steps:oa(wo,cs,So),kind:"config"}),Le("wizard");},[wo,cs]),Ha=useCallback(i=>{Le("none");let x=bt?.kind,l=bt?.targetId;if(et(null),x==="agent_shop"){let c=i.shop_template,u=c?b(c):void 0;if(u){let b=sr(le,An.current,Zt),g=Yr(b,u,dn);et({title:`NEW AGENT \u2014 ${u.name}`,steps:g,kind:"agent_from_shop"}),Le("wizard");}else a("No template selected",e.yellow);return}if((x==="agent"||x==="agent_from_shop")&&C){let c=Ki(i,dn);a(`Creating agent "${c.name}"...`,e.amber),C(c.name,c.adapter,{model:c.model,effort:c.effort,role:c.role,approval_policy:c.approval_policy,skills:c.skills}).then(u=>{a(`\u2713 Created agent "${u.name}" (${u.id}, ${u.adapter})`,e.green),c.team_id&&oe?oe(c.team_id,u.id).then(b=>{a(`\u2713 Joined team "${b.name}"`,e.green),K({includeTeams:true});},b=>a(`Failed to join team: ${b instanceof Error?b.message:String(b)}`,e.red)):K();},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(x==="team"&&U){let c=Zi(i);a(`Creating team "${c.name}"...`,e.amber),U(c).then(u=>{a(`\u2713 Created team "${u.name}" (${u.id}, ${u.members.length} members)`,e.green),K({includeTeams:true});},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(x==="task"&&m){let c=Qi(i),u=gn.length>0?[...gn]:void 0;Jn([]),a(`Creating "${c.title}"...`,e.amber),m(c.title,{priority:c.priority,description:c.description,attachments:u}).then(b=>{a(`\u2713 Created "${b.title}" (${b.id})${u?` \u{1F4CE}${u.length}`:""}`,e.green),c.assignee&&f&&f(b.id,c.assignee).catch(()=>{}),K();},b=>a(`Failed: ${b instanceof Error?b.message:String(b)}`,e.red));}else if(x==="edit_task"&&l&&G){let c=ta(i),u=gn.length>0?[...gn]:void 0;Jn([]),a("Updating task...",e.amber),G(l,{...c,attachments:u}).then(b=>{a(`\u2713 Updated "${b.title}"${u?` \u{1F4CE}${u.length}`:""}`,e.green),c.assignee&&f&&f(l,c.assignee).catch(()=>{}),K();},b=>a(`Failed: ${b instanceof Error?b.message:String(b)}`,e.red));}else if(x==="edit_agent"&&l&&W){let c=ra(i),u=c.team_id??"",b=Ht.find(g=>g.members.some(k=>k.agent_id===l))?.id??"";a("Updating agent...",e.amber),W(l,{name:c.name,role:c.role,model:c.model,effort:c.effort}).then(g=>{a(`\u2713 Updated agent "${g.name}"`,e.green);let k=[];b&&b!==u&&ye&&k.push(ye(b,l).then(Y=>a(`\u2713 Left team "${Y.name}"`,e.green),Y=>a(`Failed to leave team: ${Y instanceof Error?Y.message:String(Y)}`,e.red))),u&&u!==b&&oe&&k.push(oe(u,l).then(Y=>a(`\u2713 Joined team "${Y.name}"`,e.green),Y=>a(`Failed to join team: ${Y instanceof Error?Y.message:String(Y)}`,e.red))),Promise.all(k).then(()=>K({includeTeams:k.length>0}));},g=>a(`Failed: ${g instanceof Error?g.message:String(g)}`,e.red));}else if(x==="config"){if(i.activity_filter){let g=Un.find(k=>k.label===i.activity_filter);g&&(yr(new Set(g.types)),an?.(g.label));}if(i.max_concurrent){let g=parseInt(i.max_concurrent,10);g>0&&(Ma(g),zt?.(g));}let c=i.notifications_toast==="true",u=i.notifications_bell==="true",b={toast:c,bell:u};_a(b),Yt?.(b),a("Settings saved",e.green);}else if(x==="goal"&&Ze){let c=sa(i);a(`Creating goal "${c.title}"...`,e.amber),Ze(c).then(u=>{a(`\u2713 Created goal "${u.title}" (${u.id})`,e.green),K();},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(x==="edit_goal"&&l&&Je){let c=aa(i);a("Updating goal...",e.amber),Je(l,c).then(u=>{a(`\u2713 Updated goal "${u.title}"`,e.green),K();},u=>a(`Failed: ${u instanceof Error?u.message:String(u)}`,e.red));}},[bt,C,m,U,oe,ye,f,G,W,gt,Ze,Je,a,K,an,zt,So,Yt,le,Ht,gn,Zt,dn]),Ua=useCallback(()=>{Le("none"),et(null),Jn([]);},[]),Xa=useCallback(i=>{let x=b(i);if(!x)return;let l=sr(le,An.current,Zt),c=Yr(l,x,dn);et({title:`NEW AGENT \u2014 ${x.name}`,steps:c,kind:"agent_from_shop"}),Le("wizard");},[le,Zt,dn]);useEffect(()=>{if(!_)return;let i=null,x=()=>{i||(i=setTimeout(()=>{i=null,K().catch(()=>{});},150));},l=_(c=>{if(c.type==="agent:started"&&(pn.current.set(c.runId,c.agentId),Ro.current.set(c.runId,c.taskId)),md(c,a,pn.current,Ro.current),c.type==="task:created"?To(u=>u==="welcome"?"task_created":u):c.type==="agent:started"?To(u=>u==="task_created"?"run_started":u):c.type==="task:status_changed"&&c.to==="done"&&To(u=>u==="run_started"?"completed":u),c.type==="task:status_changed"&&(c.to==="done"?Co("done",c.taskId):c.to==="failed"?Co("failed",c.taskId):c.to==="review"&&Co("review",c.taskId),ko.current.toast&&gs.current!=="tasks")){let u=c.to==="done"?e.green:c.to==="failed"?e.red:c.to==="review"?e.blue:void 0;u&&us({tab:"tasks",color:u});}(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")&&x();});return ()=>{l(),i&&clearTimeout(i);}},[_,a,K,Co]);let Ar=Qe?"observing":bo?"watching":"idle",qa=Ve.started_at?g(Ve.started_at):void 0,Is=Ve.stats.total_tokens.total,vs=useMemo(()=>{let i={running:0,retrying:0,review:0,todo:0,done:0,failed:0,cancelled:0};for(let x of Ce)x.status==="in_progress"?i.running++:x.status==="retrying"?i.retrying++:x.status==="review"?i.review++:x.status==="todo"?i.todo++:x.status==="done"?i.done++:x.status==="failed"?i.failed++:x.status==="cancelled"&&i.cancelled++;return {...i,teams:so}},[Ce,so]);vs.running;let Ka=useMemo(()=>({input:Ve.stats.total_tokens.input??0,output:Ve.stats.total_tokens.output??0,reasoning:Ve.stats.total_tokens.reasoning??0,total:Is,cache_read:Ve.stats.total_tokens.cache_read??0,cache_write:Ve.stats.total_tokens.cache_write??0}),[Ve.stats.total_tokens,Is]),_t=Math.max(4,Ae-9),Ya=En.size,Za=le.length>Ya,Ja=so>0?so+(Za?1:0):0,Qa=useMemo(()=>{if(!no||$n.size===0)return 0;let i=0,x=new Set,l=false;for(let c of Ot)c.goalId&&$n.has(c.goalId)?x.has(c.goalId)||(x.add(c.goalId),i++):l=true;return l&&i++,i},[no,$n,Ot]),el=E==="goals"?pt.length+1:E==="tasks"?Ot.length+1+(Bn>0?1:0)+Qa:E==="agents"?le.length+1+Ja:0,tl=Math.min(el+1,Math.ceil(_t*.5)),nl=E==="logs"?_t:Math.max(2,Math.min(tl,_t-4)),we,Lt;if(E==="logs")we=_t,Lt=0;else if(vo)we=0,Lt=Math.max(1,_t);else {let i=Math.max(3,Math.min(nl+Ir,_t-4));we=i,Lt=Math.max(1,_t-i);}let _e=Math.max(10,ae-2),Rt=useMemo(()=>Ne==="command"?ii(un):[],[Ne,un]),Ln=_t-4-3;useEffect(()=>{Ir>Ln&&_n(Ln),Ir<-Ln&&_n(-Ln);},[_t]),useEffect(()=>{Mn(i=>Math.min(i,Math.max(0,Ot.length-we)));},[Ot.length,we]),useEffect(()=>{kr(i=>Math.min(i,Math.max(0,De.length-we)));},[De.length,we]),useEffect(()=>{Cr(i=>Math.min(i,Math.max(0,pt.length-we)));},[pt.length,we]);let ol=useCallback(i=>{let l=i.trim().replace(/^\//,"").split(/\s+/),c=l[0]?.toLowerCase();if(!c)return;let u=b=>b instanceof Error?b.message:String(b);switch(c){case "cancel":{if(!j){a("No task selected",e.yellow);return}if(!h)return;a(`Cancelling "${j.title}"...`,e.amber),h(j.id).then(()=>{a(`\u2713 Cancelled "${j.title}"`,e.green),K();},b=>a(`Failed: ${u(b)}`,e.red));return}case "retry":{if(!j){a("No task selected",e.yellow);return}if(!y)return;a(`Retrying "${j.title}"...`,e.amber),y(j.id).then(()=>{a(`\u2713 Retried "${j.title}"`,e.green),K();},b=>a(`Failed: ${u(b)}`,e.red));return}case "assign":{if(!j){a("No task selected",e.yellow);return}if(!f||!l[1]){a("Usage: assign <agent>",e.yellow);return}a(`Assigning "${j.title}" to ${l[1]}...`,e.amber),f(j.id,l[1]).then(()=>{a(`\u2713 Assigned "${j.title}" to ${l[1]}`,e.green),K();},b=>a(`Failed: ${u(b)}`,e.red));return}case "task":{let b=l[1]?.toLowerCase();if(b==="add"){let g=l.slice(2).join(" ");if(!g){$o();return}if(!m){a("Create not available",e.yellow);return}a(`Creating "${g}"...`,e.amber),m(g).then(k=>{a(`\u2713 Created "${k.title}" (${k.id})`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="list"){let g=Pe.map(k=>` ${k.id} ${k.status.padEnd(11)} ${k.title}`);if(g.length===0)a("No tasks",e.dim);else for(let k of g)a(k,e.cyan);}else if(b==="show"){let g=l[2]?Pe.find(k=>k.id===l[2]):j;if(!g){a("No task selected or id given",e.yellow);return}a(`${g.id} ${g.status} P${g.priority} "${g.title}"`,e.cyan),g.assignee&&a(` agent: ${g.assignee}`,e.dim),g.description&&a(` ${g.description.slice(0,100)}`,e.dim);}else if(b==="cancel"){let g=l[2]?Pe.find(k=>k.id===l[2]):j;if(!g){a("No task selected or id given",e.yellow);return}if(!h)return;a(`Cancelling "${g.title}"...`,e.amber),h(g.id).then(()=>{a(`\u2713 Cancelled "${g.title}"`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="retry"){let g=l[2]?Pe.find(k=>k.id===l[2]):j;if(!g){a("No task selected or id given",e.yellow);return}if(!y)return;a(`Retrying "${g.title}"...`,e.amber),y(g.id).then(()=>{a(`\u2713 Retried "${g.title}"`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="assign"){let g=l[2]?Pe.find(Pt=>Pt.id===l[2]):void 0,k=g??j,Y=g?l[3]:l[2];if(!k){a("No task selected or id given",e.yellow);return}if(!Y){a("Usage: /task assign [id] <agent>",e.yellow);return}if(!f)return;a(`Assigning "${k.title}" to ${Y}...`,e.amber),f(k.id,Y).then(()=>{a(`\u2713 Assigned "${k.title}" to ${Y}`,e.green),K();},Pt=>a(`Failed: ${u(Pt)}`,e.red));}else if(b==="approve"){let g=l[2]?Pe.find(k=>k.id===l[2]):j;if(!g){a("No task selected or id given",e.yellow);return}if(g.status!=="review"){a(`Cannot approve \u2014 status is ${g.status}`,e.yellow);return}if(!P)return;a(`Approving "${g.title}"...`,e.amber),P(g.id).then(()=>{a(`\u2713 Approved "${g.title}"`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="reject"){let g=l[2]?Pe.find(Y=>Y.id===l[2]):j;if(!g){a("No task selected or id given",e.yellow);return}if(g.status!=="review"){a(`Cannot reject \u2014 status is ${g.status}`,e.yellow);return}if(!B)return;let k=l.slice(l[2]&&Pe.find(Y=>Y.id===l[2])?3:2).join(" ").trim()||void 0;a(`Rejecting "${g.title}"${k?" with feedback":""}...`,e.amber),B(g.id,k).then(()=>{a(`\u2713 Rejected "${g.title}" \u2192 todo`,e.green),K();},Y=>a(`Failed: ${u(Y)}`,e.red));}else if(b==="delete"){let g=l[2]?Pe.find(k=>k.id===l[2]):j;if(!g){a("No task selected or id given",e.yellow);return}if(g.status==="in_progress"){a("Cannot delete \u2014 task is running",e.yellow);return}if(!H)return;On("task",g.id,g.title);}else a("Usage: /task add|list|show|cancel|retry|assign|approve|reject|delete",e.yellow);return}case "agent":{let b=l[1]?.toLowerCase();if(b==="add"){let g=l[2];if(!g){Ao();return}if(!C){a("Agent creation not available",e.yellow);return}let k=l[3];a(`Creating agent "${g}"...`,e.amber),C(g,k).then(Y=>{a(`\u2713 Created agent "${Y.name}" (${Y.id}, ${Y.adapter})`,e.green),K();},Y=>a(`Failed: ${u(Y)}`,e.red));}else if(b==="list"){let g=De.map(k=>` ${k.id} ${k.status.padEnd(8)} ${k.name} (${k.adapter})`);if(g.length===0)a("No agents",e.dim);else for(let k of g)a(k,e.cyan);}else if(b==="disable"){let g=l[2]?De.find(k=>k.id===l[2]||k.name===l[2]):Z;if(!g){a("No agent selected or id given",e.yellow);return}if(!w)return;a(`Disabling ${g.name}...`,e.amber),w(g.id).then(()=>{a(`\u2713 Disabled ${g.name}`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="enable"){let g=l[2]?De.find(k=>k.id===l[2]||k.name===l[2]):Z;if(!g){a("No agent selected or id given",e.yellow);return}if(!I)return;a(`Enabling ${g.name}...`,e.amber),I(g.id).then(()=>{a(`\u2713 Enabled ${g.name}`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="delete"||b==="remove"){let g=l[2]?De.find(k=>k.id===l[2]||k.name===l[2]):Z;if(!g){a("No agent selected or id given",e.yellow);return}if(g.status==="running"){a("Cannot delete \u2014 agent is running",e.yellow);return}if(!z){a("Agent deletion not available",e.yellow);return}On("agent",g.id,g.name);}else if(b==="autonomous"||b==="auto"){let g=l[2]?De.find(k=>k.id===l[2]||k.name===l[2]):Z;if(!g){a("No agent selected or id given",e.yellow);return}if(!gt){a("Autonomous toggle not available",e.yellow);return}g.autonomous?(a(`Disabling autonomous mode for "${g.name}"...`,e.amber),gt(g.id,false).then(()=>{a(`${bn} ${g.name} autonomous OFF`,e.cyan),K();},k=>a(`Failed: ${u(k)}`,e.red))):(a(`Enabling autonomous mode for "${g.name}"...`,e.amber),gt(g.id,true).then(()=>{a(`${bn} ${g.name} autonomous ON`,e.cyan),K();},k=>a(`Failed: ${u(k)}`,e.red)));}else b==="shop"?Ss():a("Usage: /agent add|list|disable|enable|delete|autonomous|shop",e.yellow);return}case "team":{let b=l[1]?.toLowerCase();if(b==="create"||b==="add")ks();else if(b==="list"){let g=An.current;if(g.length===0)a("No teams",e.dim);else for(let k of g)a(` ${k.id} ${k.status.padEnd(8)} ${k.name} (${k.members.length} members)`,e.cyan);}else if(b==="join"){if(!oe){a("Join not available",e.yellow);return}let g=l[2],k=l[3]??Z?.id;if(!g||!k){a("Usage: /team join <teamId> [agentId]",e.yellow);return}a(`Joining team ${g}...`,e.amber),oe(g,k).then(Y=>{a(`\u2713 Agent joined team "${Y.name}"`,e.green),K({includeTeams:true});},Y=>a(`Failed: ${u(Y)}`,e.red));}else if(b==="leave"){if(!ye){a("Leave not available",e.yellow);return}let g=l[2],k=l[3]??Z?.id;if(!g||!k){a("Usage: /team leave <teamId> [agentId]",e.yellow);return}a(`Leaving team ${g}...`,e.amber),ye(g,k).then(Y=>{a(`\u2713 Agent left team "${Y.name}"`,e.green),K({includeTeams:true});},Y=>a(`Failed: ${u(Y)}`,e.red));}else if(b==="disband"){if(!Ge){a("Disband not available",e.yellow);return}let g=l[2];if(!g){a("Usage: /team disband <teamId>",e.yellow);return}a(`Disbanding team ${g}...`,e.amber),Ge(g).then(()=>{a("\u2713 Team disbanded",e.green),K({includeTeams:true});},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="set-lead"){if(!ze){a("Set-lead not available",e.yellow);return}let g=l[2],k=l[3];if(!g||!k){a("Usage: /team set-lead <teamId> <agentId>",e.yellow);return}a(`Setting lead for team ${g}...`,e.amber),ze(g,k).then(Y=>{a(`\u2713 New lead for team "${Y.name}"`,e.green),K({includeTeams:true});},Y=>a(`Failed: ${u(Y)}`,e.red));}else a("Usage: /team create|list|join|leave|disband|set-lead",e.yellow);return}case "goal":{let b=l[1]?.toLowerCase();if(b==="add"||b==="create"){let g=l.slice(2).join(" ").trim();if(!g){let k=ir(le);et({title:"New Goal",steps:k,kind:"goal"}),Le("wizard");return}if(!Ze){a("Goal creation not available",e.yellow);return}a(`Creating goal "${g}"...`,e.amber),Ze({title:g}).then(k=>{a(`\u2713 Created goal "${k.title}" (${k.id})`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));}else if(b==="list"){let g=pt.map(k=>` ${k.id} ${k.status.padEnd(8)} ${k.title}`);if(g.length===0)a("No goals",e.dim);else for(let k of g)a(k,e.cyan);}else if(b==="show"){let g=l[2]?pt.find(k=>k.id===l[2]):ee;if(!g){a("No goal selected or id given",e.yellow);return}a(`${g.id} ${g.status} "${g.title}"`,e.cyan),g.description&&a(` ${g.description.slice(0,100)}`,e.dim);}else if(b==="status"){let g=l[2]?pt.find(xn=>xn.id===l[2]):void 0,k=g??ee;if(!k){a("No goal selected or id given",e.yellow);return}let Y=l[g?3:2];if(!Y||!a$1.includes(Y)){a("Usage: /goal status [id] <active|paused|achieved|abandoned>",e.yellow);return}let Pt=Y;if(!ft){a("Status update not available",e.yellow);return}a(`Updating goal status to ${Pt}...`,e.amber),ft(k.id,Pt).then(xn=>{a(`\u2713 Goal "${xn.title}" \u2192 ${Pt}`,e.green),K();},xn=>a(`Failed: ${u(xn)}`,e.red));}else if(b==="delete"){let g=l[2]?pt.find(k=>k.id===l[2]):ee;if(!g){a("No goal selected or id given",e.yellow);return}if(!ke){a("Goal deletion not available",e.yellow);return}On("goal",g.id,g.title);}else a("Usage: /goal add|list|show|status|delete",e.yellow);return}case "run":{let b=l[1]??j?.id;if(!b){a("No task selected or id given",e.yellow);return}if(!s){a("Run not available",e.yellow);return}let g=Pe.find(k=>k.id===b);if(g&&!Zr.has(g.status)){a(`Cannot run \u2014 status is ${g.status}`,e.yellow);return}a(`Running ${b}...`,e.amber),s(b).then(()=>{a(`\u2713 Dispatched ${b}`,e.green),K();},k=>a(`Failed: ${u(k)}`,e.red));return}case "run-all":{if(!T){a("Run-all not available",e.yellow);return}a("Running all todo tasks...",e.amber),T().then(()=>{a("\u2713 Dispatched all todo tasks",e.green),K();},b=>a(`Failed: ${u(b)}`,e.red));return}case "watch":{if(bo){a("Watch mode already active",e.yellow);return}if(!ut){a("Watch not available",e.yellow);return}a("Starting watch mode...",e.amber),ut().then(()=>{mr(true),a("\u2713 Watch mode started",e.green);},b=>a(`Failed: ${u(b)}`,e.red));return}case "pause":{if(!bo){a("Watch mode not active",e.yellow);return}if(!Ct){a("Pause not available",e.yellow);return}a("Pausing watch mode...",e.amber),Ct().then(()=>{mr(false),a("\u2713 Watch mode paused",e.green);},b=>a(`Failed: ${u(b)}`,e.red));return}case "config":{l[1]?.toLowerCase()==="activity-filter"?yr(g=>{let k=Jr(g);return an?.(k.label),a(`Activity filter: ${k.label}`,e.amber),new Set(k.types)}):Cs();return}case "status":{let b=Ce.filter(g=>g.status==="in_progress").length;a(`${Ar} ${b} running ${Ce.length} tasks ${De.length} agents`,e.cyan);return}case "help":{for(let[b,g]of Object.entries(Tn)){let k=g.sub?" "+g.sub.join("|"):g.args?" "+g.args:"";a(` /${b}${k} \u2014 ${g.help}`,e.silver);}return}case "quit":{jt();return}case "disable":{if(!Z){a("No agent selected",e.yellow);return}if(!w)return;a(`Disabling ${Z.name}...`,e.amber),w(Z.id).then(()=>{a(`\u2713 Disabled ${Z.name}`,e.green),K();},b=>a(`Failed: ${u(b)}`,e.red));return}case "enable":{if(!Z){a("No agent selected",e.yellow);return}if(!I)return;a(`Enabling ${Z.name}...`,e.amber),I(Z.id).then(()=>{a(`\u2713 Enabled ${Z.name}`,e.green),K();},b=>a(`Failed: ${u(b)}`,e.red));return}default:a(`Unknown: ${c}. Type /help for commands`,e.yellow);}},[j,Z,Pe,De,Ce,Ar,bo,h,y,f,T,s,m,w,I,C,P,B,H,oe,ye,Ge,ze,ut,Ct,a,jt,K,$o,Ao,ks,Cs]);useInput((i,x)=>{if(!(Et&&(hr(false),i==="?"||x.escape||i==="\x1BOP"))&&!In){if((x.ctrl||x.meta)&&i==="s"&&Ne==="wizard"&&bt?.kind==="agent"){Ss();return}if(Ne!=="none"){if(x.escape){Le("none"),xt.reset(""),Io.reset();return}if(x.return){let c=un.trim();if(!c)return;if(Ne==="new_task"){if(!m)return;Le("none"),xt.reset(""),a(`Creating "${c}"...`,e.amber),m(c).then(u=>{a(`\u2713 Created "${u.title}" (${u.id})`,e.green),K();},u=>a(`Failed to create: ${u instanceof Error?u.message:String(u)}`,e.red));}else if(Ne==="command"){let u=c;if(Rt.length>0&&Rt[Mo]){let b=Rt[Mo],g=b.cmd.replace(/\s+\[.*\]$/,"");if((g.startsWith(c)||c==="/")&&(u=g),b.subs&&!g.includes(" ")){xt.setValue(g+" "),mn(0);return}}Le("none"),xt.reset(""),mn(0),Io.push(u),ol(u);}return}if(x.tab&&Ne==="command"){if(Rt.length>0){let c=Rt[Mo];if(c){let u=c.cmd.replace(/\s+\[.*\]$/,"");xt.setValue(u+(c.subs?" ":"")),mn(0);}}else {let c=Fr(un);c&&xt.setValue(un+c);}return}if(x.upArrow&&Ne==="command"){if(Rt.length>0)mn(c=>Math.max(0,c-1));else {let c=Io.prev();c!==null&&xt.setValue(c);}return}if(x.downArrow&&Ne==="command"){if(Rt.length>0)mn(c=>Math.min(Rt.length-1,c+1));else {let c=Io.next();xt.setValue(c??"");}return}xt.handleInput(i,x)&&mn(0);return}if(i.toLowerCase()==="q"){jt();return}if(x.escape){if($e){Zn(false),oo(0);return}if(E==="logs"&&eo>=0){Tr(-1),to(0);return}return}if((i==="+"||i==="=")&&E!=="logs"){vo?(vr(false),_n(-Math.floor(_t/2))):_n(l=>Math.max(-Ln,l-3));return}if(i==="-"&&E!=="logs"){vo?(vr(false),_n(Math.floor(_t/2))):_n(l=>Math.min(Ln,l+3));return}if(i==="M"&&E!=="logs"){vr(l=>!l);return}if(i==="?"){hr(true);return}if(i==="\x1BOP"){hr(true);return}if(i==="/"&&!$e){Le("command"),xt.setValue("/"),mn(0);return}if((i==="a"||i==="A")&&E==="logs"&&!$e&&!In&&!Qn){xr(true);return}if(i==="f"&&E==="logs"&&!$e&&!In&&!Qn){br(true);return}if(i==="F"&&E==="logs"&&!$e&&!In&&!Qn){ls(l=>new Set(Jr(l).types));return}if((i==="z"||i==="Z")&&Rn.length>0){Ga();return}if((i==="f"||i==="F")&&(E==="tasks"||E==="agents"||E==="goals")&&!$e){yr(l=>{let c=Jr(l);return an?.(c.label),new Set(c.types)});return}if((i==="n"||i==="N")&&E==="tasks"&&!$e&&m){$o();return}if((i==="n"||i==="N")&&E==="agents"&&!$e&&C){Ao();return}if((i==="n"||i==="N")&&E==="goals"&&!$e&&Ze){let l=ir(le);et({title:"New Goal",steps:l,kind:"goal"}),Le("wizard");return}if((i==="e"||i==="E")&&E==="goals"&&ee&&Je){let l=ia(ee,le);et({title:`Edit Goal: ${ee.title}`,steps:l,kind:"edit_goal",targetId:ee.id}),Le("wizard");return}if((i==="d"||i==="D")&&E==="goals"&&ee&&ke){On("goal",ee.id,ee.title);return}if((i==="c"||i==="C")&&E==="goals"&&ee&&ft){(ee.status==="active"||ee.status==="paused")&&(a(`Marking goal "${ee.title}" as achieved (pending tasks will be cancelled)...`,e.amber),ft(ee.id,"achieved",{force:true}).then(()=>{a(`\u2713 Goal "${ee.title}" achieved`,e.green),K();},l=>a(`Failed: ${l instanceof Error?l.message:String(l)}`,e.red)));return}if((i==="x"||i==="X")&&E==="goals"&&ee&&ft){(ee.status==="active"||ee.status==="paused")&&(a(`Abandoning goal "${ee.title}"...`,e.amber),ft(ee.id,"abandoned").then(()=>{a(`\u2713 Goal "${ee.title}" abandoned`,e.dim),K();},l=>a(`Failed: ${l instanceof Error?l.message:String(l)}`,e.red)));return}if((i==="p"||i==="P")&&E==="goals"&&ee&&ft){let l=ee.status==="paused"?"active":"paused";(ee.status==="active"||ee.status==="paused")&&ft(ee.id,l).then(()=>{a(`Goal "${ee.title}" ${l}`,e.cyan),K();},c=>a(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if((i==="a"||i==="A")&&E==="tasks"&&j?.status==="review"&&P){a(`Approving "${j.title}"...`,e.amber),P(j.id).then(()=>{a(`\u2713 Approved "${j.title}"`,e.green),K();},l=>a(`Failed: ${l instanceof Error?l.message:String(l)}`,e.red));return}if((i==="x"||i==="X")&&E==="tasks"&&j?.status==="review"&&B){a(`Rejecting "${j.title}"...`,e.amber),B(j.id).then(()=>{a(`\u2713 Rejected "${j.title}" \u2192 todo`,e.green),K();},l=>a(`Failed: ${l instanceof Error?l.message:String(l)}`,e.red));return}if((i==="c"||i==="C")&&E==="tasks"&&j&&h){if(j.status==="done"||j.status==="failed"||j.status==="cancelled"){a(`Cannot cancel \u2014 status is ${j.status}`,e.yellow);return}a(`Cancelling "${j.title}"...`,e.amber),h(j.id).then(()=>{a(`\u2713 Cancelled "${j.title}"`,e.green),K();},l=>a(`Failed: ${l instanceof Error?l.message:String(l)}`,e.red));return}if((i==="e"||i==="E")&&E==="tasks"&&j&&G){Va(j);return}if((i==="e"||i==="E")&&E==="agents"&&Z&&W){ja(Z);return}if((i==="s"||i==="S")&&E==="tasks"){hs(l=>!l),Yn(0),Mn(0);return}if((i==="g"||i==="G")&&E==="tasks"&&!$e){Ea(l=>!l),Yn(0),Mn(0);return}if((i==="s"||i==="S")&&E==="agents"&&Z&&S){if(!Object.values(Ve.running).some(c=>c.agent_id===Z.id)&&Z.status!=="running"){a(`Agent "${Z.name}" is not running`,e.yellow);return}a(`Force-stopping agent "${Z.name}"...`,e.amber),S(Z.id).then(()=>{a(`\u2713 Stopped agent "${Z.name}"`,e.green),K();},c=>a(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if((i==="d"||i==="D")&&E==="tasks"&&j&&j.status!=="in_progress"&&H){On("task",j.id,j.title);return}if((i==="d"||i==="D")&&E==="agents"&&Z&&z){let l=Object.values(Ve.running).some(c=>c.agent_id===Z.id);if(l&&!S){a(`Cannot delete \u2014 agent "${Z.name}" is running. Press S to stop first.`,e.yellow);return}On("agent",Z.id,Z.name,{needsForceStop:l});return}if((i==="u"||i==="U")&&E==="agents"&&Z&>){let l=!Z.autonomous;a(`${l?"Enabling":"Disabling"} autonomous mode for "${Z.name}"...`,e.amber),gt(Z.id,l).then(()=>{a(`${bn} ${Z.name} autonomous ${l?"ON":"OFF"}`,e.cyan),K();},c=>a(`Failed: ${c instanceof Error?c.message:String(c)}`,e.red));return}if(!$e){if(i==="g"||i==="G"){Cn("goals");return}if(i==="t"||i==="T"){Cn("tasks");return}if(i==="a"||i==="A"){Cn("agents");return}if(i==="l"||i==="L"){Cn("logs");return}}if(!$e){let l=Go.map(u=>u.id),c=l.indexOf(E);if(x.tab||x.rightArrow){Cn(l[(c+1)%l.length]);return}if(x.leftArrow){Cn(l[(c+l.length-1)%l.length]);return}}if(x.return){let l=Bn>0?Ot.length:-1;if(E==="tasks"&&yo===l){hs(u=>!u),Yn(0),Mn(0);return}let c=Ot.length+(Bn>0?1:0);if(E==="tasks"&&yo===c&&m){$o();return}if(E==="goals"&&pr===pt.length&&Ze){let u=ir(le);et({title:"New Goal",steps:u,kind:"goal"}),Le("wizard");return}if(E==="agents"&&fr===De.length&&C){Ao();return}if(E==="goals"&&ee){Zn(u=>!u),oo(0);return}if(E==="tasks"&&j){Zn(u=>!u);return}if(E==="agents"&&Z){Zn(u=>!u);return}if(E==="logs"&&eo>=0){Zn(u=>!u);return}}if((i==="r"||i==="R")&&E==="tasks"&&j&&s){if(!Zr.has(j.status)){a(`Cannot run "${j.title}" \u2014 status is ${j.status}`,e.yellow);return}a(`Running "${j.title}"...`,e.green),s(j.id).then(()=>{a(`Dispatched "${j.title}"`,e.green),K();},l=>a(`Failed to run: ${l instanceof Error?l.message:String(l)}`,e.red));return}if(x.upArrow||i==="k"){if(E==="goals"&&$e){oo(l=>Math.max(0,l-1));return}E==="goals"?rs(l=>{let c=Math.max(0,l-1);return Cr(u=>c<u?c:u),c}):E==="tasks"?Yn(l=>{let c=Math.max(0,l-1);return Mn(u=>c<u?c:u),c}):E==="agents"?os(l=>{let c=Math.max(0,l-1);return kr(u=>c<u?c:u),c}):E==="logs"&&Tr(l=>{if(l===-1){let u=je.length-1;return to(Math.max(0,u-we+2)),Math.max(0,u)}let c=Math.max(0,l-1);return to(u=>c<u?c:u),c});}if(x.downArrow||i==="j"){if(E==="goals"&&$e){oo(l=>l+1);return}if(E==="goals"){let l=pt.length+(Ze?1:0)-1;rs(c=>{let u=Math.min(Math.max(0,l),c+1);return Cr(b=>u>=b+we?u-we+1:b),u});}else if(E==="tasks"){let l=Ot.length+(m?1:0)+(Bn>0?1:0)-1;Yn(c=>{let u=Math.min(Math.max(0,l),c+1);return Mn(b=>u>=b+we?u-we+1:b),u});}else if(E==="agents"){let l=De.length+(C?1:0)-1;os(c=>{let u=Math.min(Math.max(0,l),c+1);return kr(b=>u>=b+we?u-we+1:b),u});}else E==="logs"&&Tr(l=>{if(l===-1)return -1;let c=je.length-1;if(l>=c)return to(0),-1;let u=l+1;return to(b=>u>=b+we-1?u-we+2:b),u});}}});let st=Ne!=="none",Ms=eo>=0?je[eo]:void 0,Bo=vo?"+/- exit max":"+/- resize \u2502 M max",_s=!st&&$e&&E==="tasks"&&j,Rs=!st&&$e&&E==="agents"&&Z,As=!st&&$e&&E==="goals"&&ee,rl=!st&&$e&&E==="logs"&&Ms,$r=j?.id,sl=useMemo(()=>$r?je.filter(i=>i.taskId===$r):[],[je,$r]),il=!st&&E==="tasks"&&j&&Zr.has(j.status)&&!!s,al=!st&&!$e&&(E==="goals"&&!!Ze||E==="tasks"&&!!m||E==="agents"&&!!C),ll=!st&&E==="tasks"&&j?.status==="review"&&!!P,cl=!st&&E==="tasks"&&j?.status==="review"&&!!B,dl=Z?Object.values(Ve.running).some(i=>i.agent_id===Z.id):false,ul=!st&&(E==="goals"&&ee&&!!ke||E==="tasks"&&j&&j.status!=="in_progress"&&!!H||E==="agents"&&Z&&!!z),gl=!st&&!$e&&(E==="goals"&&!!ee&&!!Je||E==="tasks"&&!!j&&!!G||E==="agents"&&!!Z&&!!W),ml=!st&&E==="agents"&&Z&&(dl||Z.status==="running")&&!!S,fl=!st&&E==="agents"&&!!Z&&!!gt,pl=!st&&E==="goals"&&!!ee&&(ee.status==="active"||ee.status==="paused")&&!!ft,hl=!st&&Rn.length>0,$s=Ne==="command"&&Rt.length>0,Bs=bt?.kind==="task"||bt?.kind==="edit_task";return jsxs(Box,{flexDirection:"column",width:ae,height:Ae,children:[jsx(si,{projectName:t,activeView:E,mode:Ar,stats:vs,tokens:Ka,uptime:qa,width:ae,version:ln,latestVersion:N,updateInstalled:A,taskBadge:Bn>0?Pe.length:void 0,flashTab:Sr?.tab,flashColor:Sr?.color,onFlashComplete:Sr?()=>us(void 0):void 0}),jsx(Box,{height:1}),Et&&jsx(Fi,{width:ae,height:Ae-7}),!Et&&Jt==="welcome"&&E==="tasks"&&jsx(vi,{width:ae,height:Ae}),!Et&&E==="goals"&&jsx(Jc,{goals:pt,selectedIndex:pr,scrollOffset:La,height:we,width:_e,showAddRow:!!Ze,agentNameMap:fn,tasksByGoalMap:Na}),!Et&&Jt!=="welcome"&&E==="tasks"&&jsx(ed,{tasks:Ot,selectedIndex:yo,scrollOffset:Ba,height:we,width:_e,showAddRow:!!m,agentNameMap:fn,hiddenCount:Bn,goalMap:$n,groupByGoal:no}),!Et&&E==="tasks"&&(Jt==="task_created"||Jt==="run_started")&&jsx(Mi,{step:Jt,width:ae}),!Et&&E==="tasks"&&Jt==="completed"&&jsx(_i,{width:ae}),!Et&&E==="agents"&&jsx(td,{agents:De,selectedIndex:fr,scrollOffset:Oa,height:we,width:_e,state:Ve,taskTitleMap:ro,showAddRow:!!C,agentTeamMap:En,teamLeadSet:Fa,activeTeamCount:so}),!Et&&E==="logs"&&jsxs(Fragment,{children:[jsx(od,{messages:je,height:In||Qn?Math.max(3,we-16):we,agents:De,logAgentFilter:is,logTypeFilter:as,selectedIndex:eo,scrollOffset:va,agentNameMap:fn,agentColorMap:_o,agentMsgCounts:Ts,taskTitleMap:ro,width:_e}),In&&jsx(Box,{paddingX:2,children:jsx(wi,{agents:De,selected:is,msgCounts:Ts,colorMap:_o,maxHeight:Math.min(we-4,18),onConfirm:i=>{Ia(i),xr(false);},onCancel:()=>xr(false)})}),Qn&&jsx(Box,{paddingX:2,children:jsx(Ii,{selected:as,typeCounts:Da,onConfirm:i=>{ls(i),br(false);},onCancel:()=>br(false)})})]}),jsx(Box,{height:1}),Et?null:Ne==="wizard"&&bt?jsx(bi,{title:bt.title,steps:bt.steps,onComplete:Ha,onCancel:Ua,width:_e,height:Lt,onPasteImage:Bs?za:void 0,onSuggestionSelected:bt.kind==="agent"?Xa:void 0,footerExtra:gn.length>0&&Bs?`\u{1F4CE}${gn.length}`:void 0},`${bt.kind}-${bt.title}`):$s?jsxs(Fragment,{children:[jsx(ar,{label:"COMMANDS",width:_e}),jsx(Zc,{suggestions:Rt,selectedIndex:Mo,height:Math.min(Rt.length,Lt),width:_e})]}):Ne==="new_task"?jsxs(Fragment,{children:[jsx(dd,{mode:Ne,width:_e}),jsx(ud,{mode:Ne,cursor:xt.cursor,width:_e})]}):_s?jsxs(Fragment,{children:[jsx(id,{task:j,width:_e,resizeHint:Bo}),jsx(ni,{task:j,height:Lt,width:_e,taskLogs:sl,agentNameMap:fn,taskTitleMap:ro})]}):As?jsxs(Fragment,{children:[jsx(ar,{label:`GOAL: ${ee.title}`,width:_e,suffixLen:Bo.length+2,suffix:jsxs(Text,{color:e.dim,children:[" ",Bo," "]})}),jsx(Qc,{goal:ee,height:Lt,width:_e,agentNameMap:fn,tasks:Wa,progressReport:Ca,scrollOffset:Pa,onClampScroll:oo})]}):Rs?jsxs(Fragment,{children:[jsx(ad,{agent:Z,width:_e,resizeHint:Bo}),jsx(ld,{agent:Z,height:Lt,state:Ve,taskTitleMap:ro,teamName:En.get(Z.id)})]}):rl?jsxs(Fragment,{children:[jsx(ar,{label:"LOG",width:_e}),jsx(sd,{message:Ms,height:Lt,width:_e,agents:De,agentNameMap:fn,agentColorMap:_o,taskTitleMap:ro})]}):je.length>0&&E!=="logs"?jsxs(Fragment,{children:[(()=>{let i=` F:${wo.toUpperCase()} \u2502 ${wr.length}/${je.length}`;return jsx(ar,{label:"ACTIVITY",width:_e,suffixLen:i.length,suffix:jsxs(Fragment,{children:[jsx(Text,{color:e.dim,children:" F:"}),jsx(Text,{color:e.amber,children:wo.toUpperCase()}),jsxs(Text,{color:e.ghost,children:[" ","\u2502"," ",wr.length,"/",je.length]})]})})})(),jsx(rd,{messages:wr,height:Math.max(1,Lt-1),width:_e,agents:De,agentNameMap:fn,agentColorMap:_o})]}):E==="goals"?jsx(tr,{count:pt.length,config:Ai,width:_e}):E==="tasks"?jsx(tr,{count:Pe.length,config:$i,width:_e}):E==="agents"?jsx(tr,{count:De.length,config:Bi,width:_e}):null,jsx(Box,{flexGrow:1}),jsx(Di,{toasts:Ra,onDismiss:$a}),Rn.length>0&&jsx(Yc,{deletions:Rn,width:ae}),jsx(ai,{mode:Ne==="command"?"command":"navigate",value:Ne==="command"?un:"",completion:Ne==="command"?Fr(un):null,activeView:E,canRun:!!il,canNew:!!al,canApprove:!!ll,canReject:!!cl,canCancel:E==="tasks"&&!!j&&j.status==="in_progress"&&!!h,canDelete:!!ul,canUndo:!!hl,canEdit:!!gl,canForceStop:!!ml,canToggleAuto:!!fl,autoActive:Z?.autonomous,canPause:!!pl,isPaused:ee?.status==="paused",canToggleShowAll:E==="tasks"&&Pe.length>la,showAllActive:ps,hasDetail:!!(_s||Rs||As),itemCount:E==="goals"?pt.length:E==="tasks"?Pe.length:E==="agents"?le.length:je.length,itemLabel:E==="goals"?"goals":E==="tasks"?"tasks":E==="agents"?"agents":"events",width:ae,hasSuggestions:$s,onboardingCompleted:r.onboardingCompleted})]})}var Yc=mo.memo(function({deletions:n,width:o}){let[,r]=useState(0);useEffect(()=>{let m=setInterval(()=>r(h=>h+1),1e3);return ()=>clearInterval(m)},[]);let s=Date.now();return jsx(Box,{flexDirection:"column",width:o,children:n.map(m=>{let h=Math.max(0,Math.ceil((m.expiresAt-s)/1e3)),y=Math.max(0,o-4),f=m.entityType==="task"?"Task":m.entityType==="agent"?"Agent":"Goal",T=Math.max(10,y-f.length-30),w=m.entityName.length>T?m.entityName.slice(0,T-1)+"\u2026":m.entityName;return jsx(Box,{paddingX:2,children:jsxs(Text,{color:e.yellow,children:["\u2717 ",jsx(Text,{bold:true,children:f}),` "${w}" \u2014 `,jsxs(Text,{color:e.amber,bold:true,children:[h,"s"]}),jsx(Text,{color:e.dim,children:" \u2502 "}),jsx(Text,{color:e.gray,bold:true,children:"Z"}),jsx(Text,{color:e.dim,children:" undo"})]})},m.key)})})});function Zc({suggestions:t,selectedIndex:n,height:o,width:r}){let s=o,m=0;n>=s&&(m=n-s+1);let h=t.slice(m,m+s);return jsx(Box,{flexDirection:"column",paddingX:2,children:h.map((y,f)=>{let T=f+m,w=T===n,I=w?"\u25B6":" ",_=Math.min(20,Math.max(14,...t.map(C=>C.cmd.length+1))),v=y.cmd.padEnd(_),L=y.subs?` ${y.subs}`:"",M=Math.max(4,r-_-L.length-8),R=y.desc.length>M?y.desc.slice(0,M-1)+"\u2026":y.desc;return jsxs(Text,{wrap:"truncate",children:[jsx(Text,{color:w?e.amber:e.ghost,children:` ${I} `}),jsx(Text,{color:w?e.white:e.silver,bold:w,children:v}),jsx(Text,{color:e.dim,children:R}),L&&jsx(Text,{color:e.ghost,children:L})]},T)})})}function Jc({goals:t,selectedIndex:n,scrollOffset:o=0,height:r,width:s,showAddRow:m,agentNameMap:h,tasksByGoalMap:y}){let f=t.length,T=t.slice(o,o+r),w=m&&f>=o&&f<o+r;return jsxs(Box,{flexDirection:"column",height:r,children:[T.map((I,_)=>jsx(Box,{paddingX:2,children:jsx(ti,{goal:I,selected:_+o===n,width:s-2,agentNameMap:h,tasksByGoal:y?.get(I.id)})},I.id)),w&&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 goal..."})]})},"__add__")]})}function Qc({goal:t,height:n,width:o,agentNameMap:r,tasks:s,progressReport:m,scrollOffset:h=0,onClampScroll:y}){let T=mo.useMemo(()=>{let M=s??[],R=t.assignee?r?.get(t.assignee)??t.assignee:"\u2014",C=Math.max(20,o-6),z=(S,U)=>{if(S.length<=U)return [S];let ie=[];for(let oe=0;oe<S.length;oe+=U)ie.push(S.slice(oe,oe+U));return ie},P=Pr(m)?.split(`
|
|
13
|
-
`).flatMap(S=>z(S,C))??[],B=Pr(t.description)?.split(`
|
|
14
|
-
`).flatMap(S=>z(S,C))??[],H=Ws[t.status]??e.dim,G=new Map;for(let S of M)G.set(S.status,(G.get(S.status)??0)+1);let W=[];if(W.push({key:"row-status",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:H,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:R})]})]})}),W.push({key:"row-id",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" id "}),jsx(Text,{color:e.dim,children:t.id})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" created "}),jsx(Text,{children:t.created_at.slice(0,10)})]})]})}),t.updated_at&&t.updated_at!==t.created_at&&W.push({key:"row-updated",node:jsxs(Box,{children:[jsx(Box,{width:24,children:jsxs(Text,{color:e.dim,children:[" "," "]})}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" Updated "}),jsx(Text,{children:t.updated_at.slice(0,10)})]})]})}),M.length>0){let S=[];for(let[U,ie]of G)S.push(`${ie} ${U}`);W.push({key:"row-tasks-summary",node:jsxs(Box,{children:[jsxs(Box,{width:24,children:[jsx(Text,{color:e.dim,children:" tasks "}),jsx(Text,{color:e.cyan,children:M.length})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" "}),jsx(Text,{color:e.dim,children:S.join(" \xB7 ")})]})]})});}if(B.length>0){W.push({key:"desc-gap",node:jsx(Text,{children:" "})});for(let S=0;S<B.length;S++)W.push({key:`desc-${S}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",B[S]]})});}else W.push({key:"desc-gap",node:jsx(Text,{children:" "})}),W.push({key:"desc-empty",node:jsx(Text,{color:e.dim,children:" No description."})});if(P.length>0){W.push({key:"prog-gap",node:jsx(Text,{children:" "})}),W.push({key:"prog-div",node:jsx(Gn,{label:"progress",width:o})});for(let S=0;S<P.length;S++)W.push({key:`prog-${S}`,node:jsxs(Text,{color:e.white,wrap:"truncate",children:[" ",P[S]]})});}if(M.length>0){W.push({key:"tasks-gap",node:jsx(Text,{children:" "})}),W.push({key:"tasks-div",node:jsx(Gn,{label:`tasks (${M.length})`,width:o})});for(let S of M){let U=No[S.status]??e.dim;W.push({key:`task-${S.id}`,node:jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",jsx(Text,{color:U,children:S.status.padEnd(12)}),S.title.slice(0,Math.max(10,o-22))]})});}}return W},[t,s,m,o,r]),w=Math.max(0,T.length-n),I=Math.min(h,w);mo.useEffect(()=>{y&&I!==h&&y(I);},[I,h,y]);let _=T.length>n&&I<w,v=_?n-1:n,L=T.slice(I,I+v);return jsxs(Box,{flexDirection:"column",height:n,paddingX:2,children:[L.map(M=>jsx(Box,{children:M.node},M.key)),_&&jsxs(Text,{color:e.ghost,children:[" ","\u2193"," ",T.length-I-v," more ","\u2014"," ","\u2191","\u2193"," to scroll"]})]})}function ed({tasks:t,selectedIndex:n,scrollOffset:o=0,height:r,width:s,showAddRow:m,agentNameMap:h,hiddenCount:y=0,goalMap:f,groupByGoal:T=false}){let w=y>0,I=w?t.length:-1,_=t.length+(w?1:0),v=t.slice(o,o+r),L=w&&I>=o&&I<o+r,M=m&&_>=o&&_<o+r,R=useMemo(()=>{if(!T||!f||f.size===0)return null;let H=new Map;for(let G of t)if(G.goalId&&f.has(G.goalId)){let W=H.get(G.goalId)??{total:0,done:0};W.total++,G.status==="done"&&W.done++,H.set(G.goalId,W);}return H},[t,T,f]),C=T&&f?t.filter(H=>!H.goalId||!f.has(H.goalId)).length:0,z=T&&f&&f.size>0&&R&&R.size>0,P=[],B=o>0?t[o-1]?.goalId??null:void 0;for(let H=0;H<v.length&&P.length<r;H++){let G=v[H],W=G.goalId&&f?.has(G.goalId)?G.goalId:null;if(z){if(W&&W!==B){let S=f.get(W),U=R.get(W)??{total:0,done:0};if(P.push(jsx(Us,{goalTitle:S.title,taskCount:U.total,doneCount:U.done,width:s},`gh_${W}`)),P.length>=r)break}if(!W&&B!==null&&B!==void 0&&(P.push(jsx(Xs,{taskCount:C,width:s},"__ungrouped__")),P.length>=r))break}B=W,P.push(jsx(Box,{paddingX:2,children:jsx(Wo,{task:G,selected:H+o===n,width:s-2,agentNameMap:h,goalMap:f})},G.id));}return L&&P.length<r&&P.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===I?e.amber:e.ghost,children:[n===I?" \u25B8 ":" ",jsxs(Text,{color:n===I?e.amber:e.dim,children:["\u25BC"," Show all (",y," more) \u2014 press ",jsx(Text,{bold:true,color:e.gray,children:"S"})]})]})},"__show_all__")),M&&P.length<r&&P.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===_?e.amber:e.ghost,children:[n===_?" \u25B8 ":" ",jsx(Text,{color:n===_?e.amber:e.dim,children:"+ add task..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:r,children:P})}function td({agents:t,selectedIndex:n,scrollOffset:o=0,height:r,width:s,state:m,taskTitleMap:h,showAddRow:y,agentTeamMap:f,teamLeadSet:T,activeTeamCount:w}){let I=new Map;for(let G of Object.values(m.running))I.set(G.agent_id,G);let _=new Map;if(w&&w>0)for(let G of t){let W=f?.get(G.id);W&&_.set(W,(_.get(W)??0)+1);}let v=t.length,L=t.slice(o,o+r),M=y&&v>=o&&v<o+r,R=w!=null&&w>0,C=new Map;if(R&&T&&f){for(let G of t)if(T.has(G.id)){let W=f.get(G.id);W&&C.set(W,G.name);}}let z=0;for(let G of _.values())z+=G;let P=t.length-z,B=[],H=o>0?f?.get(t[o-1]?.id??""):void 0;for(let G=0;G<L.length&&B.length<r;G++){let W=L[G],S=f?.get(W.id);if(R&&S&&S!==H&&(B.push(jsx(Zs,{teamName:S,memberCount:_.get(S)??0,leadName:C.get(S),width:s},`ts-${S}`)),B.length>=r)||R&&!S&&H&&(B.push(jsx(Js,{memberCount:P,width:s},"ts-unassigned")),B.length>=r))break;H=S,B.push(jsx(Box,{paddingX:2,children:jsx(Ys,{agent:W,selected:G+o===n,width:s-2,runningEntry:I.get(W.id),currentTaskTitle:W.current_task?h.get(W.current_task):void 0,teamName:S,isLead:T?.has(W.id)})},W.id));}return M&&B.length<r&&B.push(jsx(Box,{paddingX:2,children:jsxs(Text,{color:n===v?e.amber:e.ghost,children:[n===v?" \u25B8 ":" ",jsx(Text,{color:n===v?e.amber:e.dim,children:"+ add agent..."})]})},"__add__")),jsx(Box,{flexDirection:"column",height:r,children:B})}function ha(t=5e3){let[n,o]=useState(Date.now());return useEffect(()=>{let r=setInterval(()=>o(Date.now()),t);return ()=>clearInterval(r)},[t]),n}function xa(t,n){let o=Math.max(0,n-t);return o<3e3?"now":o<6e4?`${Math.floor(o/1e3)}s`:o<36e5?`${Math.floor(o/6e4)}m`:`${Math.floor(o/36e5)}h`}function nd(t){if(t==="error")return e.errorBg}function ba(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 od({messages:t,height:n,agents:o,logAgentFilter:r,logTypeFilter:s,selectedIndex:m,scrollOffset:h,agentNameMap:y,agentColorMap:f,agentMsgCounts:T,taskTitleMap:w,width:I}){let _=ha(),v=useMemo(()=>t.filter(U=>{if(r.size>0&&U.agentId&&!r.has(U.agentId))return false;let ie=U.msgType??"info";return s.has(ie)}),[t,r,s]);useMemo(()=>{let U={};for(let ie of t){let oe=ie.msgType??"info";U[oe]=(U[oe]??0)+1;}return U},[t]);let M=s.size>=8?"all":s.size===1&&s.has("output")?"text":s.size===1&&s.has("error")?"errors":s.has("tool")&&!s.has("output")?"tools":s.has("lifecycle")&&!s.has("output")?"events":`${s.size} types`,R=r.size>0,C=n-2,z=m===-1?v.slice(-C):v.slice(h,h+C),P=m===-1?-1:m-h,B=Math.min(10,Math.max(6,...o.map(U=>U.name.length))),H=11+B,G=U=>{if(U===0)return true;let ie=z[U],oe=z[U-1];return ie.agentId!==oe.agentId?true:ie.agentId?ie.ts-oe.ts>3e4:false},W=Math.max(4,Math.floor((I-20)/Math.max(1,o.length))-1),S=Math.min(W,10);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsxs(Box,{gap:0,justifyContent:"space-between",width:I,children:[jsxs(Box,{gap:0,children:[m===-1?jsxs(Box,{gap:0,children:[jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" "}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:jsx(Xt,{color:e.green})}),jsx(Text,{backgroundColor:e.successBg,color:e.green,children:" LIVE "})]}):jsxs(Text,{backgroundColor:e.warnBg,color:e.amber,children:[" \u2191\u2193 ",m+1,"/",v.length," "]}),jsxs(Text,{color:e.dim,children:[" ",v.length," events"]}),M!=="all"&&jsxs(Text,{color:e.amber,children:[" f:",M]}),R&&jsxs(Text,{color:e.cyan,children:[" ",r.size,"/",o.length," agents"]})]}),jsxs(Box,{gap:0,children:[jsx(Text,{color:e.amber,bold:true,children:"a"}),jsx(Text,{color:e.dim,children:" filter "}),jsx(Text,{color:e.amber,bold:true,children:"f"}),jsx(Text,{color:e.dim,children:" type "}),jsx(Text,{color:e.amber,bold:true,children:"F"}),jsx(Text,{color:e.dim,children:" cycle"})]})]}),jsx(Box,{gap:0,children:o.map(U=>{let ie=f.get(U.id)??es[0],oe=r.size===0||r.has(U.id),ye=U.name.length>S?U.name.slice(0,S-1)+"\u2026":U.name;return jsxs(Text,{color:oe?ie:e.ghost,bold:oe,children:[" ",ye]},U.id)})}),z.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"})]})]}):z.map((U,ie)=>{let oe=ie===P,ye=U.msgType??"info",Ge=Xn[ye]??"\u2502",ze=U.agentId?y.get(U.agentId)??U.agentId.slice(0,8):void 0,ut=U.agentId?f.get(U.agentId):void 0,Ct=G(ie),mt=(ie>0?z[ie-1]:void 0)?.agentId===U.agentId&&!!U.agentId,Ze=!mt&&!!ze,Je=mt&&!!ze,ft=ba(ye,U.color),ke=oe?e.infoBg:ye==="error"?e.errorBg:void 0,Gt=U.taskId?w.get(U.taskId):void 0,It=xa(U.ts,_),ht=Gt&&I>80?`#${Gt.slice(0,20)}`:"",Qe=ht?ht.length+3:0,rt=Math.max(10,I-2-H-Qe),qe=it(U.text,rt);return jsxs(Box,{backgroundColor:ke,children:[jsx(Text,{color:ut??e.ghost,children:Ct&&Ze?"\u250C":Je?"\u2502":" "}),jsx(Text,{color:oe?e.amber:void 0,children:oe?"\u25B8":" "}),jsx(Box,{width:5,children:jsx(Text,{color:It==="now"?e.green:oe?e.silver:e.ghost,children:It.padStart(4)})}),jsx(Box,{width:B+1,children:Ze?jsxs(Text,{color:ut,bold:true,children:[" ",ze.slice(0,B).padEnd(B)]}):Je?jsxs(Text,{color:ut??e.ghost,children:[" ","\xB7".padEnd(B)]}):jsxs(Text,{color:e.ghost,children:[" "," ".padEnd(B)]})}),jsxs(Text,{color:ye==="error"?e.red:ut??e.dim,children:[" ",Ge," "]}),jsx(Text,{color:oe?e.white:ft,bold:oe||ye==="lifecycle",children:qe}),ht&&jsxs(Text,{color:e.ghost,children:[" ",jsx(Text,{color:e.dim,backgroundColor:e.void,children:` ${ht} `})]})]},ie)})]})}function rd({messages:t,height:n,width:o,agents:r,agentNameMap:s,agentColorMap:m}){let h=ha(),y=t.slice(-n),f=Math.max(10,o-2-17),T=Math.max(0,n-y.length),w=0,I=[];for(let _=0;_<y.length;_++)_>0&&y[_].agentId!==y[_-1].agentId&&w++,I.push(w);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[T>0&&jsx(Box,{height:T}),y.map((_,v)=>{let L=_.agentId?s.get(_.agentId)??_.agentId.slice(0,8):void 0,M=_.agentId?m.get(_.agentId):void 0,R=_.msgType??"info",C=Xn[R]??"\u2502",z=ba(R,_.color),B=(v>0?y[v-1]:void 0)?.agentId===_.agentId&&!!_.agentId,H=(I[v]&1)===1,G=nd(R)??(H?"#1a1a1a":void 0),W=xa(_.ts,h),S=it(_.text,f);return jsxs(Box,{backgroundColor:G,children:[jsx(Text,{color:M??e.ghost,children:!B&&L?"\u258D":B?"\u258F":" "}),jsx(Box,{width:5,children:jsx(Text,{color:B?e.ghost:W==="now"?e.green:e.dim,children:B?" ":W.padStart(4)})}),jsx(Box,{width:9,children:L&&!B?jsxs(Text,{color:M,bold:true,children:[" ",L.slice(0,8)]}):jsx(Text,{color:e.ghost,children:Kc})}),jsxs(Text,{color:R==="error"?e.red:B?e.ghost:M??e.dim,children:[C," "]}),jsx(Text,{color:z,children:S})]},v)})]})}function sd({message:t,height:n,width:o,agents:r,agentNameMap:s,agentColorMap:m,taskTitleMap:h}){let y=t.detail??t.text,f=t.msgType??"info",T=t.agentId?s.get(t.agentId)??t.agentId.slice(0,8):void 0,w=t.agentId?m.get(t.agentId):e.dim,I=t.taskId?h.get(t.taskId):void 0,_,v=false;try{let C=JSON.parse(y);_=JSON.stringify(C,null,2),v=!0;}catch{_=y;}let L=Math.max(4,o-6),M=Math.max(1,n-4),R=_.split(`
|
|
15
|
-
`).slice(0,M);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u256D",be(L+2),"\u256E"]})}),jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),jsx(Text,{color:e.dim,children:t.time}),jsx(Text,{color:e.ghost,children:" \u2502 "}),T&&jsx(Text,{color:w,bold:true,children:T}),T&&jsx(Text,{color:e.ghost,children:" \u2502 "}),jsxs(Text,{color:Xn[f]?f==="error"?e.red:e.dim:e.dim,children:[Xn[f]??"\u2502"," ",f]}),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,L)})]}),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u251C",be(L+2),"\u2524"]})}),R.map((C,z)=>jsxs(Box,{children:[jsx(Text,{color:e.ghost,children:"\u2502 "}),v&&jsxs(Text,{color:e.ghost,children:[String(z+1).padStart(3)," "]}),jsx(Text,{wrap:"truncate",color:v&&C.includes('"')?e.cyan:v&&/^\s*[}\]]/.test(C)?e.ghost:C.startsWith("error")||C.startsWith("Error")?e.red:e.silver,children:C.slice(0,v?L-4:L)})]},z)),jsx(Box,{children:jsxs(Text,{color:e.ghost,children:["\u2570",be(L+2),"\u256F"]})})]})}function ar({label:t,width:n,suffix:o,suffixLen:r=0}){let s=` ${t} `,m=3,h=m+s.length+2;if(!o){let T=Math.max(0,n-h);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Ue(m)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:s}),jsx(Text,{color:e.ghost,children:Ue(T)})]})}let y=2,f=Math.max(0,n-h-y-r);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Ue(m)}),jsx(Text,{backgroundColor:"#1a1a22",color:e.dim,bold:true,children:s}),jsx(Text,{color:e.ghost,children:Ue(y)}),o,jsx(Text,{color:e.ghost,children:Ue(f)})]})}function id({task:t,width:n,resizeHint:o}){let r=" DETAIL ",s=o?` ${o} `:"",m=n-r.length-s.length-10,h=t.title.length>m?t.title.slice(0,m-3)+"...":t.title,y=Math.max(0,n-3-r.length-h.length-s.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Ue(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:r}),jsxs(Text,{color:e.ghost,children:[Po," "]}),jsx(Text,{color:e.white,bold:true,children:h}),jsxs(Text,{color:e.ghost,children:[" ",Ue(Math.max(0,y))]}),s?jsx(Text,{color:e.dim,children:s}):null]})}function ad({agent:t,width:n,resizeHint:o}){let r=" AGENT ",s=o?` ${o} `:"",m=n-r.length-s.length-10,h=t.name.length>m?t.name.slice(0,m-3)+"...":t.name,y=Math.max(0,n-3-r.length-h.length-s.length-4);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Ue(3)}),jsx(Text,{backgroundColor:"#0f2d1f",color:e.green,bold:true,children:r}),jsxs(Text,{color:e.ghost,children:[Po," "]}),jsx(Text,{color:e.green,bold:true,children:h}),jsxs(Text,{color:e.ghost,children:[" ",Ue(Math.max(0,y))]}),s?jsx(Text,{color:e.dim,children:s}):null]})}function ld({agent:t,height:n$1,state:o,taskTitleMap:r,teamName:s}){let m=cd[t.status]??e.dim;Object.values(o.running).find(T=>T.agent_id===t.id);let y=t.current_task?r.get(t.current_task):void 0,f=24;return jsxs(Box,{flexDirection:"column",paddingX:2,children:[jsxs(Box,{children:[jsxs(Box,{width:f,children:[jsx(Text,{color:e.dim,children:" status "}),jsx(Text,{color:m,children:t.status})]}),jsxs(Box,{children:[jsx(Text,{color:e.dim,children:" adapter "}),jsx(Text,{color:e.cyan,children:t.adapter})]})]}),jsxs(Box,{children:[jsxs(Box,{width:f,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:y?e.white:e.dim,children:y??"\u2014"})]})]}),jsxs(Box,{children:[jsxs(Box,{width:f,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:s?e.amber:e.dim,children:s??"\u2014"})]})]}),t.autonomous&&jsx(Box,{children:jsxs(Box,{width:f,children:[jsx(Text,{color:e.dim,children:" auto "}),jsxs(Text,{color:e.cyan,children:[bn," 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:it(t.config.skills.join(", "),500)})]}),t.last_error&&(()=>{let T=t.last_error.kind,w=n[T],I=!w||T==="unknown",_=t.last_error.timestamp,v=_?g(_)+" ago":"";return jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Box,{flexDirection:"column",borderStyle:"single",borderColor:e.red,paddingX:1,children:[jsxs(Text,{color:e.red,bold:true,children:["\u26A0"," \u041E\u0448\u0438\u0431\u043A\u0430"]}),w&&jsx(Text,{color:e.white,children:w.message}),w&&jsx(Text,{color:e.cyan,children:w.fix}),w?.doctorHint&&jsx(Text,{color:e.yellow,children:"\u0414\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0430: orch doctor"}),I&&t.last_error.message&&jsx(Text,{color:e.dim,children:it(t.last_error.message,120)}),v&&jsx(Text,{color:e.dim,children:v})]})]})})(),jsx(Text,{children:" "}),t.role?t.role.split(`
|
|
16
|
-
`).slice(0,Math.max(1,n$1-(t.last_error?10:4))).map((T,w)=>jsxs(Text,{color:e.silver,wrap:"truncate",children:[" ",it(T,500)]},w)):jsx(Text,{color:e.dim,children:" No role description."})]})}var cd={idle:e.dim,running:e.green,error:e.red,disabled:e.ghost};function dd({mode:t,width:n}){let r=` ${t==="command"?"COMMAND":"NEW TASK"} `,s=Math.max(0,n-3-r.length-2);return jsxs(Box,{paddingX:1,children:[jsx(Text,{color:e.ghost,children:Ue(3)}),jsx(Text,{backgroundColor:"#2d1f0a",color:e.amber,bold:true,children:r}),jsx(Text,{color:e.ghost,children:Ue(s)})]})}function ud({mode:t,cursor:n,width:o}){let r=t==="command"?"/ ":"\u25B8 ";return jsx(Box,{paddingX:2,children:jsx(qo,{cursor:n,width:Math.max(10,o-4),prefix:r})})}function Ta(t,n){if(!n||typeof n!="object")return "";let o=n;if(o.file_path&&typeof o.file_path=="string")return o.file_path.split("/").slice(-2).join("/");if(o.command&&typeof o.command=="string")return o.command.slice(0,60);if(o.pattern&&typeof o.pattern=="string")return `"${o.pattern.slice(0,40)}"`;if(o.glob&&typeof o.glob=="string")return o.glob.slice(0,40);let r=JSON.stringify(o);return r.length>80?r.slice(0,77)+"...":r}function lr(t,n=200){if(typeof t=="string")return t.slice(0,n);if(!Array.isArray(t))return null;let o=[],r=0;for(let s of t){if(r>=n)break;if(s?.type==="text"&&typeof s.text=="string"){let m=s.text.split(`
|
|
17
|
-
`).find(h=>h.trim().length>0)??"";o.push(m.slice(0,n-r)),r+=m.length;}else if(s?.type==="tool_use"){let m=Ta(s.name??"tool",s.input),h=`\u2699 ${s.name??"tool"}(${m})`;o.push(h),r+=h.length;}else if(s?.type==="tool_result")o.push("\u2190 (result)"),r+=10;else if(s?.type==="thinking"&&typeof s.thinking=="string"){let m=s.thinking.slice(0,60).split(`
|
|
18
|
-
`)[0]??"";o.push(`\u{1F4AD} ${m}`),r+=m.length+3;}}return o.length>0?o.join(" "):null}function ga(t){if(typeof t=="string"){let o=t.split(`
|
|
19
|
-
`),r=o.find(s=>/\S/.test(s))??"";return o.length>3?`${r.slice(0,80)}... (${o.length} lines)`:r.slice(0,120)}if(!Array.isArray(t))return "(result)";let n=[];for(let o of t)if(o?.type==="tool_result"){o.tool_use_id?o.tool_use_id.slice(0,8):"";let s=o.is_error,m=typeof o.content=="string"?o.content:"",h=m.split(`
|
|
20
|
-
`).length;s?n.push(`\u2715 error: ${m.slice(0,60)}`):h>3?n.push(`\u2713 ${h} lines`):n.push(`\u2713 ${m.slice(0,80)}`);}else o?.type==="text"&&typeof o.text=="string"&&n.push(o.text.split(`
|
|
21
|
-
`)[0]?.slice(0,80)??"");return n.join(" ")||"(result)"}function cr(t,n){return t.indexOf(`
|
|
22
|
-
`)===-1?t.slice(0,n):(t.split(`
|
|
23
|
-
`).find(o=>/\S/.test(o))??t).slice(0,n)}function ya(t){let n=()=>t.length>gr?t.slice(0,gr)+"\u2026":t;if(fa.test(t.trim()))return {summary:t.trim(),detail:n()};try{let o=JSON.parse(t);if(typeof o.text=="string"&&o.text.length>0&&!o.type&&!o.role)return {summary:cr(o.text,200),detail:n()};if(typeof o.command=="string"&&!o.type){let r=typeof o.result=="string"&&o.result?` \u2192 ${cr(o.result,80)}`:"";return {summary:`$ ${o.command.slice(0,120)}${r}`,detail:n()}}if(Array.isArray(o.paths)&&o.paths.length>0&&!o.type)return {summary:`${Xn.file} ${o.paths.join(", ").slice(0,180)}`,detail:n()};if(typeof o.message=="string"&&!o.role&&!o.content&&!o.subtype)return {summary:`${Xn.error} ${cr(o.message,200)}`,detail:n()};if(typeof o.result=="string"&&!o.type)return {summary:`\u2713 ${cr(o.result,200)}`,detail:n()};if(o.type==="message"&&o.role==="assistant"){let r=lr(o.content);return r?{summary:r.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="assistant"||o.role==="assistant"){let r=o.message?.content??o.content,s=lr(r);return s?{summary:s.slice(0,200),detail:n()}:{summary:null,detail:""}}if(o.type==="user"||o.role==="user"){let r=o.message?.content??o.content;return {summary:`\u2190 ${ga(r).slice(0,180)}`,detail:n()}}if(o.type==="tool_use"||typeof o.name=="string"&&"input"in o){let r=o.name??"tool",s=Ta(r,o.input);return {summary:`\u2699 ${r}(${s})`,detail:n()}}if(o.type==="tool_result")return {summary:`\u2190 ${ga(o.content).slice(0,180)}`,detail:n()};if(o.type==="result"){let r=typeof o.result=="string"?o.result:null;return {summary:r?`\u2713 ${r.slice(0,180)}`:"\u2713 Agent finished",detail:n()}}if(o.type==="rate_limit_event")return {summary:`\u23F3 Rate limited (${o.rate_limit_info?.rateLimitType??"unknown"})`,detail:n()};if(o.subtype){if(o.message){let r=o.message.content??o.message,s=lr(r);if(s)return {summary:s.slice(0,200),detail:n()}}return {summary:`[${o.subtype}]`,detail:n()}}if(o.content){let r=lr(o.content);if(r)return {summary:r.slice(0,200),detail:n()}}return o.type?{summary:`[${o.type}]`,detail:n()}:{summary:t.slice(0,150),detail:n()}}catch{return {summary:gd(t),detail:n()}}}function gd(t){let n=t.match(/"subtype"\s*:\s*"([^"]+)"/);if(n)return `[${n[1]}]`;let o=t.match(/"type"\s*:\s*"([^"]+)"/),r=t.match(/"role"\s*:\s*"([^"]+)"/),s=o?.[1],m=r?.[1];if(!s&&!m)return t.slice(0,200);if(s==="assistant"||s==="message"||m==="assistant"){let h=t.match(/"text"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(h)try{return JSON.parse(`"${h[1]}"`).slice(0,200)}catch{}return "\u{1F4AC} (assistant)"}if(s==="user"||s==="tool_result"||m==="user")return "\u2190 (tool result)";if(s==="tool_use")return `\u2699 ${t.match(/"name"\s*:\s*"([^"]+)"/)?.[1]??"tool"}()`;if(s==="result"){let h=t.match(/"result"\s*:\s*"((?:[^"\\]|\\.)*)"/);if(h)try{return `\u2713 ${JSON.parse(`"${h[1]}"`).slice(0,180)}`}catch{}return "\u2713 Agent finished"}return s==="rate_limit_event"?"\u23F3 Rate limited":`[${s??m}]`}function md(t,n,o,r){let s=m=>r?.get(m);switch(t.type){case "agent:started":n("Started task",e.green,{agentId:t.agentId,taskId:t.taskId,msgType:"lifecycle"});break;case "agent:output":{let{summary:m,detail:h}=ya(t.data);if(m){let y=pa(m);n(m,y.color,{agentId:t.agentId,taskId:s(t.runId),detail:h,msgType:y.msgType});}break}case "agent:file_changed":n(`${t.path}`,e.purple,{agentId:t.agentId,taskId:s(t.runId),msgType:"file"});break;case "agent:completed":n(t.success?"Completed successfully":"Failed",t.success?e.green:e.red,{agentId:t.agentId,taskId:s(t.runId),msgType:"lifecycle"});break;case "agent:error":n(`${t.error.slice(0,150)}`,e.red,{agentId:t.agentId,taskId:s(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:s(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:s(t.runId),msgType:"error"});break;case "task:cascade_failed":n(`Cascade failed (dep: ${t.failedDependencyId})`,e.red,{taskId:t.taskId,detail:t.reason,msgType:"error"});break}}export{Ug as App,Hg as _resetPendingDeletionSeq};
|
package/dist/chunk-C7C7Q7XO.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a}from'./chunk-P4JTJBWO.js';import {o}from'./chunk-LRYVT4D4.js';import {b as b$1}from'./chunk-6MJ7V6VY.js';function b(n,s){return n?n+`
|
|
3
|
-
|
|
4
|
-
`+s:s}function y(n,s){let e=n.usage;if(!e&&s?.statsFallback&&(e=n.stats?.usage),e&&typeof e.input_tokens=="number"){let i=e.input_tokens,u=typeof e.output_tokens=="number"?e.output_tokens:0,a$1=typeof e.reasoning_tokens=="number"?e.reasoning_tokens:0,o=typeof e.cache_read_input_tokens=="number"?e.cache_read_input_tokens:0,c=typeof e.cache_creation_input_tokens=="number"?e.cache_creation_input_tokens:0;return a(i,u,{reasoning:a$1,cache_read:o,cache_write:c})}}function w(n,s,e,i){async function*u(){let a=false,o$1=null,c=null,g=new Promise(r=>{n.on("close",t=>{o$1=t,r();}),n.on("error",t=>{c=t,r();});});if(n.stdout)try{for await(let r of b$1(n.stdout)){if(i?.aborted)break;let t=s(r);t&&(t.type==="done"&&(a=!0),yield t);}}finally{n.stdout.destroy();}if(await g,c&&!i?.aborted&&!a){let r=c,t=o(r.message,o$1??void 0);throw Object.assign(new Error(r.message),{errorKind:t})}if(o$1!==0&&o$1!==null&&!i?.aborted&&!a){let r=`${e} process exited with code ${o$1}`,t=o(r,o$1);throw Object.assign(new Error(r),{errorKind:t})}}return u()}export{b as a,y as b,w as c};
|
package/dist/chunk-DEHFYICU.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {c,b}from'./chunk-C7C7Q7XO.js';import {o}from'./chunk-LRYVT4D4.js';import {execFile}from'child_process';import {promisify}from'util';var m=promisify(execFile),i=class{constructor(e){this.processManager=e;}kind="claude";async test(){try{let{stdout:e}=await m("claude",["--version"]);return {ok:!0,version:e.trim()}}catch(e){let t=e instanceof Error?e.message:String(e);return {ok:false,error:"Claude Code CLI not found. Install: npm i -g @anthropic-ai/claude-code",errorKind:o(t)}}}execute(e){let t=["--print","--output-format","stream-json","--max-turns",String(e.config.max_turns??50),"--verbose","--dangerously-skip-permissions"];e.config.model&&t.push("--model",e.config.model),e.config.effort&&t.push("--effort",e.config.effort);let r=e.systemPrompt??e.config.system_prompt;r&&t.push("--system-prompt",r),t.push(e.prompt);let{process:o,pid:u}=this.processManager.spawn("claude",t,{cwd:e.workspace,env:{...process.env,...e.env},signal:e.signal}),p=c(o,f,"Claude",e.signal);return {pid:u,events:p}}async stop(e){await this.processManager.killWithGrace(e);}};function f(s){if(!s.trim())return null;try{let e=JSON.parse(s),t=new Date().toISOString();switch(e.type){case "assistant":return {type:"output",timestamp:t,data:e.message??e};case "tool_use":return {type:"tool_call",timestamp:t,data:e};case "tool_result":return {type:"output",timestamp:t,data:e};case "error":{let r=e.error??e,o$1=typeof r=="string"?r:JSON.stringify(r);return {type:"error",timestamp:t,data:r,errorKind:o(o$1)}}case "result":{let r=b(e,{statsFallback:!0});return {type:"done",timestamp:t,data:e,tokens:r}}default:return {type:"output",timestamp:t,data:e}}}catch{return {type:"output",timestamp:new Date().toISOString(),data:s}}}export{i as a};
|
package/dist/chunk-RFN447MA.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { createTokenUsage } from './chunk-RHFRHCN5.js';
|
|
2
|
-
import { classifyAdapterError } from './chunk-IESAV453.js';
|
|
3
|
-
import { readLines } from './chunk-O2MSGW3V.js';
|
|
4
|
-
|
|
5
|
-
// src/infrastructure/adapters/utils.ts
|
|
6
|
-
function buildFullPrompt(systemPrompt, userPrompt) {
|
|
7
|
-
return systemPrompt ? systemPrompt + "\n\n" + userPrompt : userPrompt;
|
|
8
|
-
}
|
|
9
|
-
function extractTokens(parsed, opts) {
|
|
10
|
-
let usage = parsed.usage;
|
|
11
|
-
if (!usage && opts?.statsFallback) {
|
|
12
|
-
const stats = parsed.stats;
|
|
13
|
-
usage = stats?.usage;
|
|
14
|
-
}
|
|
15
|
-
if (usage && typeof usage.input_tokens === "number") {
|
|
16
|
-
const input = usage.input_tokens;
|
|
17
|
-
const output = typeof usage.output_tokens === "number" ? usage.output_tokens : 0;
|
|
18
|
-
const reasoning = typeof usage.reasoning_tokens === "number" ? usage.reasoning_tokens : 0;
|
|
19
|
-
const cache_read = typeof usage.cache_read_input_tokens === "number" ? usage.cache_read_input_tokens : 0;
|
|
20
|
-
const cache_write = typeof usage.cache_creation_input_tokens === "number" ? usage.cache_creation_input_tokens : 0;
|
|
21
|
-
return createTokenUsage(input, output, { reasoning, cache_read, cache_write });
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
}
|
|
25
|
-
function createStreamingEvents(proc, parseEvent, adapterName, signal) {
|
|
26
|
-
async function* generate() {
|
|
27
|
-
let gotDoneEvent = false;
|
|
28
|
-
let exitCode = null;
|
|
29
|
-
let exitError = null;
|
|
30
|
-
const exitPromise = new Promise((resolve) => {
|
|
31
|
-
proc.on("close", (code) => {
|
|
32
|
-
exitCode = code;
|
|
33
|
-
resolve();
|
|
34
|
-
});
|
|
35
|
-
proc.on("error", (err) => {
|
|
36
|
-
exitError = err;
|
|
37
|
-
resolve();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
if (proc.stdout) {
|
|
41
|
-
try {
|
|
42
|
-
for await (const line of readLines(proc.stdout)) {
|
|
43
|
-
if (signal?.aborted) break;
|
|
44
|
-
const event = parseEvent(line);
|
|
45
|
-
if (event) {
|
|
46
|
-
if (event.type === "done") gotDoneEvent = true;
|
|
47
|
-
yield event;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} finally {
|
|
51
|
-
proc.stdout.destroy();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
await exitPromise;
|
|
55
|
-
if (exitError && !signal?.aborted && !gotDoneEvent) {
|
|
56
|
-
const spawnErr = exitError;
|
|
57
|
-
const classified = classifyAdapterError(spawnErr.message, exitCode ?? void 0);
|
|
58
|
-
const err = Object.assign(new Error(spawnErr.message), { errorKind: classified });
|
|
59
|
-
throw err;
|
|
60
|
-
}
|
|
61
|
-
if (exitCode !== 0 && exitCode !== null && !signal?.aborted && !gotDoneEvent) {
|
|
62
|
-
const msg = `${adapterName} process exited with code ${exitCode}`;
|
|
63
|
-
const classified = classifyAdapterError(msg, exitCode);
|
|
64
|
-
const err = Object.assign(new Error(msg), { errorKind: classified });
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return generate();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { buildFullPrompt, createStreamingEvents, extractTokens };
|
|
72
|
-
//# sourceMappingURL=chunk-RFN447MA.js.map
|
|
73
|
-
//# sourceMappingURL=chunk-RFN447MA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/infrastructure/adapters/utils.ts"],"names":[],"mappings":";;;;;AAcO,SAAS,eAAA,CAAgB,cAAkC,UAAA,EAA4B;AAC5F,EAAA,OAAO,YAAA,GAAe,YAAA,GAAe,MAAA,GAAS,UAAA,GAAa,UAAA;AAC7D;AAQO,SAAS,aAAA,CACd,QACA,IAAA,EACwB;AACxB,EAAA,IAAI,QAAQ,MAAA,CAAO,KAAA;AAEnB,EAAA,IAAI,CAAC,KAAA,IAAS,IAAA,EAAM,aAAA,EAAe;AACjC,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,KAAA,GAAQ,KAAA,EAAO,KAAA;AAAA,EACjB;AAEA,EAAA,IAAI,KAAA,IAAS,OAAO,KAAA,CAAM,YAAA,KAAiB,QAAA,EAAU;AACnD,IAAA,MAAM,QAAQ,KAAA,CAAM,YAAA;AACpB,IAAA,MAAM,SAAS,OAAO,KAAA,CAAM,aAAA,KAAkB,QAAA,GAAW,MAAM,aAAA,GAAgB,CAAA;AAC/E,IAAA,MAAM,YAAY,OAAO,KAAA,CAAM,gBAAA,KAAqB,QAAA,GAAW,MAAM,gBAAA,GAAmB,CAAA;AACxF,IAAA,MAAM,aAAa,OAAO,KAAA,CAAM,uBAAA,KAA4B,QAAA,GAAW,MAAM,uBAAA,GAA0B,CAAA;AACvG,IAAA,MAAM,cAAc,OAAO,KAAA,CAAM,2BAAA,KAAgC,QAAA,GAAW,MAAM,2BAAA,GAA8B,CAAA;AAChH,IAAA,OAAO,iBAAiB,KAAA,EAAO,MAAA,EAAQ,EAAE,SAAA,EAAW,UAAA,EAAY,aAAa,CAAA;AAAA,EAC/E;AACA,EAAA,OAAO,MAAA;AACT;AAYO,SAAS,qBAAA,CACd,IAAA,EACA,UAAA,EACA,WAAA,EACA,MAAA,EAC4B;AAC5B,EAAA,gBAAgB,QAAA,GAAuC;AACrD,IAAA,IAAI,YAAA,GAAe,KAAA;AAEnB,IAAA,IAAI,QAAA,GAA0B,IAAA;AAC9B,IAAA,IAAI,SAAA,GAA0B,IAAA;AAC9B,IAAA,MAAM,WAAA,GAAc,IAAI,OAAA,CAAc,CAAC,OAAA,KAAY;AACjD,MAAA,IAAA,CAAK,EAAA,CAAG,OAAA,EAAS,CAAC,IAAA,KAAS;AAAE,QAAA,QAAA,GAAW,IAAA;AAAM,QAAA,OAAA,EAAQ;AAAA,MAAG,CAAC,CAAA;AAC1D,MAAA,IAAA,CAAK,EAAA,CAAG,OAAA,EAAS,CAAC,GAAA,KAAQ;AAAE,QAAA,SAAA,GAAY,GAAA;AAAK,QAAA,OAAA,EAAQ;AAAA,MAAG,CAAC,CAAA;AAAA,IAC3D,CAAC,CAAA;AAED,IAAA,IAAI,KAAK,MAAA,EAAQ;AACf,MAAA,IAAI;AACF,QAAA,WAAA,MAAiB,IAAA,IAAQ,SAAA,CAAU,IAAA,CAAK,MAAM,CAAA,EAAG;AAC/C,UAAA,IAAI,QAAQ,OAAA,EAAS;AACrB,UAAA,MAAM,KAAA,GAAQ,WAAW,IAAI,CAAA;AAC7B,UAAA,IAAI,KAAA,EAAO;AACT,YAAA,IAAI,KAAA,CAAM,IAAA,KAAS,MAAA,EAAQ,YAAA,GAAe,IAAA;AAC1C,YAAA,MAAM,KAAA;AAAA,UACR;AAAA,QACF;AAAA,MACF,CAAA,SAAE;AAIA,QAAA,IAAA,CAAK,OAAO,OAAA,EAAQ;AAAA,MACtB;AAAA,IACF;AAEA,IAAA,MAAM,WAAA;AAEN,IAAA,IAAI,SAAA,IAAa,CAAC,MAAA,EAAQ,OAAA,IAAW,CAAC,YAAA,EAAc;AAClD,MAAA,MAAM,QAAA,GAAW,SAAA;AACjB,MAAA,MAAM,UAAA,GAAa,oBAAA,CAAqB,QAAA,CAAS,OAAA,EAAS,YAAY,MAAS,CAAA;AAC/E,MAAA,MAAM,GAAA,GAAM,MAAA,CAAO,MAAA,CAAO,IAAI,KAAA,CAAM,QAAA,CAAS,OAAO,CAAA,EAAG,EAAE,SAAA,EAAW,UAAA,EAAY,CAAA;AAChF,MAAA,MAAM,GAAA;AAAA,IACR;AACA,IAAA,IAAI,QAAA,KAAa,KAAK,QAAA,KAAa,IAAA,IAAQ,CAAC,MAAA,EAAQ,OAAA,IAAW,CAAC,YAAA,EAAc;AAC5E,MAAA,MAAM,GAAA,GAAM,CAAA,EAAG,WAAW,CAAA,0BAAA,EAA6B,QAAQ,CAAA,CAAA;AAC/D,MAAA,MAAM,UAAA,GAAa,oBAAA,CAAqB,GAAA,EAAK,QAAQ,CAAA;AACrD,MAAA,MAAM,GAAA,GAAM,MAAA,CAAO,MAAA,CAAO,IAAI,KAAA,CAAM,GAAG,CAAA,EAAG,EAAE,SAAA,EAAW,UAAA,EAAY,CAAA;AACnE,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,OAAO,QAAA,EAAS;AAClB","file":"chunk-RFN447MA.js","sourcesContent":["/**\n * Shared utilities for agent adapters.\n *\n * Deduplicates extractTokens and streaming event generation logic\n * common to claude, codex, and cursor adapters.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport type { AgentEvent } from './interface.js';\nimport { readLines } from '../process/process-manager.js';\nimport { type TokenUsage, createTokenUsage } from '../../domain/run.js';\nimport { classifyAdapterError } from '../../domain/errors.js';\n\n/** Combine system and user prompts. Adapters without native system prompt support use this. */\nexport function buildFullPrompt(systemPrompt: string | undefined, userPrompt: string): string {\n return systemPrompt ? systemPrompt + '\\n\\n' + userPrompt : userPrompt;\n}\n\n/**\n * Extract token usage from a parsed JSON event.\n *\n * @param parsed - The parsed JSON object from an adapter event line.\n * @param opts.statsFallback - If true, also checks `parsed.stats?.usage` (Claude-specific).\n */\nexport function extractTokens(\n parsed: Record<string, unknown>,\n opts?: { statsFallback?: boolean },\n): TokenUsage | undefined {\n let usage = parsed.usage as Record<string, unknown> | undefined;\n\n if (!usage && opts?.statsFallback) {\n const stats = parsed.stats as Record<string, unknown> | undefined;\n usage = stats?.usage as Record<string, unknown> | undefined;\n }\n\n if (usage && typeof usage.input_tokens === 'number') {\n const input = usage.input_tokens;\n const output = typeof usage.output_tokens === 'number' ? usage.output_tokens : 0;\n const reasoning = typeof usage.reasoning_tokens === 'number' ? usage.reasoning_tokens : 0;\n const cache_read = typeof usage.cache_read_input_tokens === 'number' ? usage.cache_read_input_tokens : 0;\n const cache_write = typeof usage.cache_creation_input_tokens === 'number' ? usage.cache_creation_input_tokens : 0;\n return createTokenUsage(input, output, { reasoning, cache_read, cache_write });\n }\n return undefined;\n}\n\n/**\n * Create an async generator that streams AgentEvents from a child process.\n *\n * Handles: exit promise setup, line-by-line reading, abort signal, exit code checking.\n *\n * @param proc - The spawned child process.\n * @param parseEvent - Adapter-specific function to parse a line into an AgentEvent.\n * @param adapterName - Name used in error messages (e.g. \"Claude\", \"Codex\").\n * @param signal - Optional abort signal.\n */\nexport function createStreamingEvents(\n proc: ChildProcess,\n parseEvent: (line: string) => AgentEvent | null,\n adapterName: string,\n signal?: AbortSignal,\n): AsyncGenerator<AgentEvent> {\n async function* generate(): AsyncGenerator<AgentEvent> {\n let gotDoneEvent = false;\n\n let exitCode: number | null = null;\n let exitError: Error | null = null;\n const exitPromise = new Promise<void>((resolve) => {\n proc.on('close', (code) => { exitCode = code; resolve(); });\n proc.on('error', (err) => { exitError = err; resolve(); });\n });\n\n if (proc.stdout) {\n try {\n for await (const line of readLines(proc.stdout)) {\n if (signal?.aborted) break;\n const event = parseEvent(line);\n if (event) {\n if (event.type === 'done') gotDoneEvent = true;\n yield event;\n }\n }\n } finally {\n // Destroy the stream to release the FD immediately rather than waiting\n // for the process to die — critical for rapid abort/restart cycles.\n // destroy() is idempotent: safe on an already-ended stream.\n proc.stdout.destroy();\n }\n }\n\n await exitPromise;\n\n if (exitError && !signal?.aborted && !gotDoneEvent) {\n const spawnErr = exitError as Error;\n const classified = classifyAdapterError(spawnErr.message, exitCode ?? undefined);\n const err = Object.assign(new Error(spawnErr.message), { errorKind: classified });\n throw err;\n }\n if (exitCode !== 0 && exitCode !== null && !signal?.aborted && !gotDoneEvent) {\n const msg = `${adapterName} process exited with code ${exitCode}`;\n const classified = classifyAdapterError(msg, exitCode);\n const err = Object.assign(new Error(msg), { errorKind: classified });\n throw err;\n }\n }\n\n return generate();\n}\n"]}
|
package/dist/chunk-SJG3HXO5.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a}from'./chunk-P4JTJBWO.js';import {o}from'./chunk-LRYVT4D4.js';import {execFile}from'child_process';var E=class{constructor(e){this.processManager=e;}kind="pi";async test(){try{return {ok:!0,version:(await new Promise((t,r)=>{execFile("pi",["--version"],(o,s)=>{o?r(o):t(s);});})).trim()}}catch(e){let t=e instanceof Error?e.message:String(e);return {ok:false,error:"Pi CLI not found. Install: npm i -g @mariozechner/pi-coding-agent",errorKind:o(t)}}}execute(e){let t=["--mode","rpc"];e.config.model&&t.push("--model",e.config.model),e.config.effort&&t.push("--thinking",e.config.effort);let r=e.systemPrompt??e.config.system_prompt;r&&t.push("--append-system-prompt",r);let{process:o,pid:s}=this.processManager.spawn("pi",t,{cwd:e.workspace,env:{...process.env,...e.env},signal:e.signal,stdio:["pipe","pipe","pipe"]}),i=U(o.stderr);o.stdin&&o.stdin.write(JSON.stringify({id:`orch-${Date.now()}`,type:"prompt",message:e.prompt})+`
|
|
3
|
-
`);let u=R(o,s,this.processManager,i,e.signal);return {pid:s,events:u}}async stop(e){await this.processManager.killWithGrace(e);}};function R(n,e,t,r,o$1){async function*s(){let i=false,u=false,f="",p,d=null,y=null,T=new Promise(c=>{n.on("close",a=>{d=a,c();}),n.on("error",a=>{y=a,c();});}),m=null;try{if(n.stdout)try{for await(let c of J(n.stdout)){if(o$1?.aborted)break;let a=b(c,{finalText:f,lastTokens:p});if(a&&(a.finalText!==void 0&&(f=a.finalText),a.tokens&&(p=a.tokens),a.agentEvent&&(a.agentEvent.type==="done"&&(i=!0),yield a.agentEvent,a.agentEvent.type==="done"))){await t.killWithGrace(e,1e3).catch(()=>{});return}}}catch(c){m=c instanceof Error?c:new Error(String(c)),!o$1?.aborted&&!i&&(u=!0,yield {type:"error",timestamp:new Date().toISOString(),data:{message:m.message},errorKind:o(m.message)});}}finally{n.stdout?.destroy(),!i&&(o$1?.aborted||m)&&t.killWithGrace(e,1e3).catch(()=>{});}if(await T,u)return;let h=y;if(h&&!o$1?.aborted&&!i){let c=_(h.message,r()),a=o(c,d??void 0);throw Object.assign(new Error(c),{errorKind:a})}if(d!==0&&d!==null&&!o$1?.aborted&&!i){let c=`Pi process exited with code ${d}`,a=_(c,r()),P=o(a,d);throw Object.assign(new Error(a),{errorKind:P})}}return s()}function _(n,e){return e?`${n}
|
|
4
|
-
--- pi stderr (tail) ---
|
|
5
|
-
${e}`:n}function b(n,e){if(!n.trim())return null;let t;try{t=JSON.parse(n);}catch{return {agentEvent:{type:"output",timestamp:new Date().toISOString(),data:{text:n}}}}let r=new Date().toISOString();switch(typeof t.type=="string"?t.type:""){case "extension_ui_request":case "agent_start":case "turn_start":case "message_start":case "message_end":case "turn_end":case "queue_update":case "compaction_start":case "compaction_end":case "auto_retry_start":case "auto_retry_end":return O(t);case "response":{if(t.success===false){let s=typeof t.error=="string"?t.error:JSON.stringify(t);return {agentEvent:{type:"error",timestamp:r,data:{message:s,raw:t},errorKind:o(s)}}}return null}case "message_update":return A(t,r,e);case "tool_execution_start":return {agentEvent:{type:"tool_call",timestamp:r,data:{name:t.toolName,input:t.args,raw:t}}};case "tool_execution_update":return null;case "tool_execution_end":return B(t,r);case "agent_end":{let s=N(t)??e.finalText,i=K(t)??e.lastTokens;return {finalText:s,tokens:i,agentEvent:{type:"done",timestamp:r,data:{result:s,raw:t},tokens:i}}}case "extension_error":{let s=typeof t.message=="string"?t.message:JSON.stringify(t);return {agentEvent:{type:"error",timestamp:r,data:{message:s,raw:t},errorKind:o(s)}}}default:return null}}function A(n,e,t){let r=n.assistantMessageEvent,o$1=typeof r?.type=="string"?r.type:"";if(o$1==="text_delta"){let s=typeof r?.delta=="string"?r.delta:"";return {finalText:t.finalText+s}}if(o$1==="text_end"){let s=typeof r?.content=="string"?r.content:t.finalText;return s?{finalText:"",agentEvent:{type:"output",timestamp:e,data:{text:s}}}:{finalText:""}}if(o$1==="error"){let s=typeof r?.reason=="string"?r.reason:JSON.stringify(n);return {agentEvent:{type:"error",timestamp:e,data:{message:s,raw:n},errorKind:o(s)}}}return null}function B(n,e){let t=typeof n.toolName=="string"?n.toolName:"",r=n.args,o$1=I(n.result);if(n.isError===true){let i=o$1||JSON.stringify(n.result??n);return {agentEvent:{type:"error",timestamp:e,data:{message:i,raw:n},errorKind:o(i)}}}if(t==="bash"){let i=typeof r?.command=="string"?r.command:JSON.stringify(r??{});return {agentEvent:{type:"command",timestamp:e,data:{command:i,result:o$1,raw:n}}}}if(/^(write|edit)$/i.test(t)){let i=M(r);if(i)return {agentEvent:{type:"file_change",timestamp:e,data:{paths:[i],raw:n}}}}let s=o$1||`${t||"tool"} completed`;return {agentEvent:{type:"output",timestamp:e,data:{text:s,raw:n}}}}function I(n){return typeof n=="string"?n:!n||typeof n!="object"?"":x(n.content)??""}function O(n){let e=v(n);return e?{tokens:e}:null}function N(n){let e=n.messages;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--){let r=e[t];if(r.role!=="assistant")continue;let o=x(r.content);if(o)return o}}function x(n){if(typeof n=="string")return n;if(!Array.isArray(n))return;let e=n.map(t=>{let r=t;return typeof r.text=="string"?r.text:""}).filter(Boolean);return e.length?e.join(""):void 0}function M(n){if(n){if(typeof n.path=="string")return n.path;if(typeof n.file_path=="string")return n.file_path}}function K(n){let e=n.messages;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--){let r=e[t];if(r.role!=="assistant")continue;let o=v(r);if(o)return o}}var l={input:["input","input_tokens"],output:["output","output_tokens"],reasoning:["reasoning","reasoning_tokens"],cache_read:["cacheRead","cache_read","cache_read_input_tokens"],cache_write:["cacheWrite","cache_write","cache_creation_input_tokens"]};function v(n){let e=n.usage;if(!e)return;let t=f=>{for(let p of f){let d=e[p];if(typeof d=="number")return d}return 0},r=t(l.input),o=t(l.output),s=t(l.reasoning),i=t(l.cache_read),u=t(l.cache_write);if(!(r===0&&o===0&&s===0&&i===0&&u===0))return a(r,o,{reasoning:s,cache_read:i,cache_write:u})}var k=4096;function U(n){if(!n)return ()=>"";let e=Buffer.alloc(0);return n.on("data",t=>{let r=Buffer.isBuffer(t)?t:Buffer.from(t,"utf-8");e=e.length===0?r:Buffer.concat([e,r],e.length+r.length),e.length>k&&(e=Buffer.from(e.subarray(e.length-k)));}),n.on("error",()=>{}),()=>e.toString("utf-8").trimEnd()}async function*J(n){let e=[],t=0;for await(let r of n){let o=Buffer.isBuffer(r)?r:Buffer.from(r,"utf-8");if(o.length===0)continue;e.push(o),t+=o.length;let s=e.length===1?e[0]:Buffer.concat(e,t);e.length=0,t=0;let i=0,u;for(;(u=s.indexOf(10,i))!==-1;){if(u>i){let f=s.toString("utf-8",i,u);yield f.endsWith("\r")?f.slice(0,-1):f;}i=u+1;}if(i<s.length){let f=s.subarray(i);e.push(f),t=f.length;}}if(t>0){let o=(e.length===1?e[0]:Buffer.concat(e,t)).toString("utf-8");o&&(yield o.endsWith("\r")?o.slice(0,-1):o);}}export{E as a};
|
package/dist/claude-PH7LT3OH.js
DELETED
package/dist/codex-URQN4JLZ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a,c,b}from'./chunk-C7C7Q7XO.js';import'./chunk-P4JTJBWO.js';import {o}from'./chunk-LRYVT4D4.js';import'./chunk-6MJ7V6VY.js';import {execFile}from'child_process';import {promisify}from'util';var f=promisify(execFile),g=class{constructor(e){this.processManager=e;}kind="codex";async test(){try{let{stdout:e}=await f("codex",["--version"]);return {ok:!0,version:e.trim()}}catch(e){let r=e instanceof Error?e.message:String(e);return {ok:false,error:"Codex CLI not found. Install: npm i -g @openai/codex",errorKind:o(r)}}}execute(e){let r=["exec","--json","--sandbox","danger-full-access"];e.config.model&&r.push("--model",e.config.model),r.push("-");let{process:s,pid:t}=this.processManager.spawn("codex",r,{cwd:e.workspace,env:{...process.env,...e.env},signal:e.signal,stdio:["pipe","pipe","pipe"]});s.stdin&&(s.stdin.write(a(e.systemPrompt,e.prompt)),s.stdin.end());let n=c(s,h,"Codex",e.signal);return {pid:t,events:n}}async stop(e){await this.processManager.killWithGrace(e);}};function h(a){if(!a.trim())return null;try{let e=JSON.parse(a),r=new Date().toISOString();switch(e.type??""){case "thread.started":return {type:"output",timestamp:r,data:e};case "turn.started":return {type:"output",timestamp:r,data:e};case "turn.completed":{let t=b(e);return {type:"done",timestamp:r,data:e,tokens:t}}case "turn.failed":{let t=b(e),n=typeof e.error=="string"?e.error:JSON.stringify(e);return {type:"error",timestamp:r,data:e,tokens:t,errorKind:o(n)}}case "item.started":case "item.completed":{let t=e.item??{},n=t.type??"";if(n==="agent_message")return {type:"output",timestamp:r,data:t};if(n==="reasoning")return {type:"output",timestamp:r,data:t};if(n==="command_execution")return {type:"command",timestamp:r,data:t};if(n==="file_change"){let m=(Array.isArray(t.changes)?t.changes:[]).map(p=>typeof p.path=="string"?p.path:"").filter(Boolean);return {type:"file_change",timestamp:r,data:{paths:m,raw:t}}}if(n==="tool_use")return {type:"tool_call",timestamp:r,data:t};if(n==="tool_result")return {type:"output",timestamp:r,data:t};if(n==="error"){let c=typeof t.message=="string"?t.message:JSON.stringify(t);return {type:"error",timestamp:r,data:t,errorKind:o(c)}}return {type:"output",timestamp:r,data:t}}case "error":{let t=e.error??e,n=typeof t=="string"?t:JSON.stringify(t);return {type:"error",timestamp:r,data:t,errorKind:o(n)}}default:return {type:"output",timestamp:r,data:e}}}catch{return {type:"output",timestamp:new Date().toISOString(),data:a}}}export{g as CodexAdapter};
|
package/dist/cursor-EMX3ECDY.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a,c,b}from'./chunk-C7C7Q7XO.js';import'./chunk-P4JTJBWO.js';import {o}from'./chunk-LRYVT4D4.js';import'./chunk-6MJ7V6VY.js';import {execFile}from'child_process';import {promisify}from'util';var l=promisify(execFile);async function g(){for(let n of ["cursor-agent","agent"])try{let{stdout:e}=await l(n,["--version"]);return {command:n,version:e.trim()}}catch{}return null}var u=class{constructor(e){this.processManager=e;}kind="cursor";resolvedCommand="cursor-agent";async test(){let e=await g();return e?(this.resolvedCommand=e.command,{ok:true,version:e.version}):{ok:false,error:"Cursor Agent CLI not found. The headless agent CLI is required (cursor-agent or agent).",errorKind:"adapter_not_found"}}execute(e){let r=["-p","--output-format","stream-json","--workspace",e.workspace,"--yolo"];e.config.model&&r.push("--model",e.config.model);let{process:t,pid:o}=this.processManager.spawn(this.resolvedCommand,r,{cwd:e.workspace,env:{...process.env,...e.env},signal:e.signal,stdio:["pipe","pipe","pipe"]});t.stdin&&(t.stdin.write(a(e.systemPrompt,e.prompt)),t.stdin.end());let p=c(t,f,"Cursor agent",e.signal);return {pid:o,events:p}}async stop(e){await this.processManager.killWithGrace(e);}};function f(n){if(!n.trim())return null;try{let e=JSON.parse(n),r=new Date().toISOString();switch(e.type){case "assistant":return {type:"output",timestamp:r,data:e.message??e};case "tool_use":return {type:"tool_call",timestamp:r,data:e};case "tool_result":return {type:"output",timestamp:r,data:e};case "error":{let t=e.error??e,o$1=typeof t=="string"?t:JSON.stringify(t);return {type:"error",timestamp:r,data:t,errorKind:o(o$1)}}case "result":{let t=b(e);return {type:"done",timestamp:r,data:e,tokens:t}}default:return {type:"output",timestamp:r,data:e}}}catch{return {type:"output",timestamp:new Date().toISOString(),data:n}}}export{u as CursorAdapter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/infrastructure/adapters/cursor.ts"],"names":[],"mappings":";;;;;;;AAkBA,IAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AAGxC,eAAe,WAAA,GAAoE;AACjF,EAAA,KAAA,MAAW,GAAA,IAAO,CAAC,cAAA,EAAgB,OAAO,CAAA,EAAG;AAC3C,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,QAAO,GAAI,MAAM,cAAc,GAAA,EAAK,CAAC,WAAW,CAAC,CAAA;AACzD,MAAA,OAAO,EAAE,OAAA,EAAS,GAAA,EAAK,OAAA,EAAS,MAAA,CAAO,MAAK,EAAE;AAAA,IAChD,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAEO,IAAM,gBAAN,MAA6C;AAAA,EAKlD,YAA6B,cAAA,EAAiC;AAAjC,IAAA,IAAA,CAAA,cAAA,GAAA,cAAA;AAAA,EAAkC;AAAA,EAJtD,IAAA,GAAO,QAAA;AAAA,EAER,eAAA,GAA0B,cAAA;AAAA,EAIlC,MAAM,IAAA,GAAmC;AACvC,IAAA,MAAM,KAAA,GAAQ,MAAM,WAAA,EAAY;AAChC,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,IAAA,CAAK,kBAAkB,KAAA,CAAM,OAAA;AAC7B,MAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,IAC5C;AACA,IAAA,OAAO;AAAA,MACL,EAAA,EAAI,KAAA;AAAA,MACJ,KAAA,EAAO,yFAAA;AAAA,MACP,SAAA,EAAA,mBAAA;AAAA,KACF;AAAA,EACF;AAAA,EAEA,QAAQ,MAAA,EAAsC;AAC5C,IAAA,MAAM,IAAA,GAAO;AAAA,MACX,IAAA;AAAA,MACA,iBAAA;AAAA,MAAmB,aAAA;AAAA,MACnB,aAAA;AAAA,MAAe,MAAA,CAAO,SAAA;AAAA,MACtB;AAAA;AAAA,KACF;AAEA,IAAA,IAAI,MAAA,CAAO,OAAO,KAAA,EAAO;AACvB,MAAA,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA;AAAA,IAC1C;AAEA,IAAA,MAAM,EAAE,OAAA,EAAS,IAAA,EAAM,GAAA,EAAI,GAAI,KAAK,cAAA,CAAe,KAAA,CAAM,IAAA,CAAK,eAAA,EAAiB,IAAA,EAAM;AAAA,MACnF,KAAK,MAAA,CAAO,SAAA;AAAA,MACZ,KAAK,EAAE,GAAG,QAAQ,GAAA,EAAK,GAAG,OAAO,GAAA,EAAI;AAAA,MACrC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,KAAA,EAAO,CAAC,MAAA,EAAQ,MAAA,EAAQ,MAAM;AAAA;AAAA,KAC/B,CAAA;AAGD,IAAA,IAAI,KAAK,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,MAAM,KAAA,CAAM,eAAA,CAAgB,OAAO,YAAA,EAAc,MAAA,CAAO,MAAM,CAAC,CAAA;AACpE,MAAA,IAAA,CAAK,MAAM,GAAA,EAAI;AAAA,IACjB;AAEA,IAAA,MAAM,SAAS,qBAAA,CAAsB,IAAA,EAAM,gBAAA,EAAkB,cAAA,EAAgB,OAAO,MAAM,CAAA;AAE1F,IAAA,OAAO,EAAE,KAAK,MAAA,EAAO;AAAA,EACvB;AAAA,EAEA,MAAM,KAAK,GAAA,EAA4B;AACrC,IAAA,MAAM,IAAA,CAAK,cAAA,CAAe,aAAA,CAAc,GAAG,CAAA;AAAA,EAC7C;AACF;AAEA,SAAS,iBAAiB,IAAA,EAAiC;AACzD,EAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAK,EAAG,OAAO,IAAA;AAEzB,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAkC,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AACvD,IAAA,MAAM,SAAA,GAAA,iBAAY,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAGzC,IAAA,QAAQ,OAAO,IAAA;AAAM,MACnB,KAAK,WAAA;AACH,QAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,WAAW,IAAA,EAAO,MAAA,CAAO,WAAuB,MAAA,EAAO;AAAA,MAClF,KAAK,UAAA;AACH,QAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,SAAA,EAAW,MAAM,MAAA,EAAO;AAAA,MACtD,KAAK,aAAA;AACH,QAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,MAAM,MAAA,EAAO;AAAA,MACnD,KAAK,OAAA,EAAS;AACZ,QAAA,MAAM,OAAA,GAAW,OAAO,KAAA,IAAqB,MAAA;AAC7C,QAAA,MAAM,SAAS,OAAO,OAAA,KAAY,WAAW,OAAA,GAAU,IAAA,CAAK,UAAU,OAAO,CAAA;AAC7E,QAAA,OAAO,EAAE,MAAM,OAAA,EAAS,SAAA,EAAW,MAAM,OAAA,EAAS,SAAA,EAAW,oBAAA,CAAqB,MAAM,CAAA,EAAE;AAAA,MAC5F;AAAA,MACA,KAAK,QAAA,EAAU;AACb,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAA,EAAW,IAAA,EAAM,QAAQ,MAAA,EAAO;AAAA,MACzD;AAAA,MACA;AACE,QAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,MAAM,MAAA,EAAO;AAAA;AACrD,EACF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,SAAA,EAAA,iBAAW,IAAI,MAAK,EAAE,WAAA,EAAY,EAAG,IAAA,EAAM,IAAA,EAAK;AAAA,EAC3E;AACF","file":"cursor-O6M6XOMT.js","sourcesContent":["/**\n * Cursor Agent adapter.\n *\n * Spawns `cursor-agent` (Cursor's headless agent CLI) with `--output-format stream-json`.\n * Falls back to `agent` command if `cursor-agent` is not found.\n * Parses JSON-lines from stdout into AgentEvent stream.\n *\n * Note: This requires Cursor Agent CLI, not the regular `cursor` IDE command.\n * Install via: npm i -g @anthropic-ai/cursor-agent (when available)\n */\n\nimport type { IAgentAdapter, AdapterTestResult, ExecuteParams, AgentEvent, ExecuteHandle } from './interface.js';\nimport type { IProcessManager } from '../process/process-manager.js';\nimport { extractTokens, createStreamingEvents, buildFullPrompt } from './utils.js';\nimport { classifyAdapterError, AdapterErrorKind } from '../../domain/errors.js';\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nconst execFileAsync = promisify(execFile);\n\n/** Try multiple command names and return the first that works */\nasync function findCommand(): Promise<{ command: string; version: string } | null> {\n for (const cmd of ['cursor-agent', 'agent']) {\n try {\n const { stdout } = await execFileAsync(cmd, ['--version']);\n return { command: cmd, version: stdout.trim() };\n } catch {\n // try next\n }\n }\n return null;\n}\n\nexport class CursorAdapter implements IAgentAdapter {\n readonly kind = 'cursor';\n\n private resolvedCommand: string = 'cursor-agent';\n\n constructor(private readonly processManager: IProcessManager) {}\n\n async test(): Promise<AdapterTestResult> {\n const found = await findCommand();\n if (found) {\n this.resolvedCommand = found.command;\n return { ok: true, version: found.version };\n }\n return {\n ok: false,\n error: 'Cursor Agent CLI not found. The headless agent CLI is required (cursor-agent or agent).',\n errorKind: AdapterErrorKind.ADAPTER_NOT_FOUND,\n };\n }\n\n execute(params: ExecuteParams): ExecuteHandle {\n const args = [\n '-p',\n '--output-format', 'stream-json',\n '--workspace', params.workspace,\n '--yolo', // bypass interactive prompts for autonomous agents\n ];\n\n if (params.config.model) {\n args.push('--model', params.config.model);\n }\n\n const { process: proc, pid } = this.processManager.spawn(this.resolvedCommand, args, {\n cwd: params.workspace,\n env: { ...process.env, ...params.env },\n signal: params.signal,\n stdio: ['pipe', 'pipe', 'pipe'], // stdin must be 'pipe' to send prompt\n });\n\n // Pipe prompt via stdin — prepend system prompt if present (Cursor has no native --system-prompt)\n if (proc.stdin) {\n proc.stdin.write(buildFullPrompt(params.systemPrompt, params.prompt));\n proc.stdin.end();\n }\n\n const events = createStreamingEvents(proc, parseCursorEvent, 'Cursor agent', params.signal);\n\n return { pid, events };\n }\n\n async stop(pid: number): Promise<void> {\n await this.processManager.killWithGrace(pid);\n }\n}\n\nfunction parseCursorEvent(line: string): AgentEvent | null {\n if (!line.trim()) return null;\n\n try {\n const parsed: Record<string, unknown> = JSON.parse(line);\n const timestamp = new Date().toISOString();\n\n // Cursor stream-json uses the same format as Claude stream-json\n switch (parsed.type) {\n case 'assistant':\n return { type: 'output', timestamp, data: (parsed.message as unknown) ?? parsed };\n case 'tool_use':\n return { type: 'tool_call', timestamp, data: parsed };\n case 'tool_result':\n return { type: 'output', timestamp, data: parsed };\n case 'error': {\n const errData = (parsed.error as unknown) ?? parsed;\n const errMsg = typeof errData === 'string' ? errData : JSON.stringify(errData);\n return { type: 'error', timestamp, data: errData, errorKind: classifyAdapterError(errMsg) };\n }\n case 'result': {\n const tokens = extractTokens(parsed);\n return { type: 'done', timestamp, data: parsed, tokens };\n }\n default:\n return { type: 'output', timestamp, data: parsed };\n }\n } catch {\n return { type: 'output', timestamp: new Date().toISOString(), data: line };\n }\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a,c}from'./chunk-C7C7Q7XO.js';import {a as a$1}from'./chunk-P4JTJBWO.js';import {o}from'./chunk-LRYVT4D4.js';import'./chunk-6MJ7V6VY.js';import {execFile}from'child_process';import {promisify}from'util';var f=promisify(execFile),d=class{constructor(e){this.processManager=e;}kind="opencode";async test(){try{let{stdout:e}=await f("opencode",["--version"]);return {ok:!0,version:e.trim()}}catch(e){let r=e instanceof Error?e.message:String(e);return {ok:false,error:"OpenCode CLI not found. Install: npm i -g opencode",errorKind:o(r)}}}execute(e){let r=["run","--format","json"];e.config.model&&r.push("--model",e.config.model);let a$1=a(e.systemPrompt,e.prompt);r.push(a$1);let{process:t,pid:n}=this.processManager.spawn("opencode",r,{cwd:e.workspace,env:{...process.env,...e.env},signal:e.signal}),s=c(t,y,"OpenCode",e.signal);return {pid:n,events:s}}async stop(e){await this.processManager.killWithGrace(e);}};function y(o$1){if(!o$1.trim())return null;try{let e=JSON.parse(o$1),r=new Date().toISOString(),a=e.type??"",t=e.part??{};switch(a){case "step_start":return null;case "text":return {type:"output",timestamp:r,data:t.text??t};case "tool_use":{let n=t.state??{};if(n.status==="error"){let s=typeof n.error=="string"?n.error:JSON.stringify(n);return {type:"error",timestamp:r,data:n,errorKind:o(s)}}return {type:"tool_call",timestamp:r,data:{name:t.tool,input:n.input}}}case "step_finish":{let n=t.reason,s=k(t);if(n==="error"){let g=typeof t.error=="string"?t.error:JSON.stringify(t);return {type:"error",timestamp:r,data:t,tokens:s,errorKind:o(g)}}return n==="tool-calls"?null:{type:"done",timestamp:r,data:t,tokens:s}}default:return {type:"output",timestamp:r,data:e}}}catch{return {type:"output",timestamp:new Date().toISOString(),data:o$1}}}function k(o){let e=o.tokens;if(!e||typeof e.input!="number")return;let r=e.input,a=typeof e.output=="number"?e.output:0,t=typeof e.reasoning=="number"?e.reasoning:0;return a$1(r,a,{reasoning:t})}export{d as OpenCodeAdapter};
|