rovecode 0.4.0-beta.2 → 0.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +13 -0
- package/dist/cli/app-j6gn14w3.js +2 -0
- package/dist/cli/{ask-user-p8hq4xgj.js → ask-user-cwstt8fz.js} +1 -1
- package/dist/cli/auth-login-9bbp9915.js +2 -0
- package/dist/cli/{bench-xv3ypwev.js → bench-16zqdms5.js} +1 -1
- package/dist/cli/catalog-1xchffa4.js +2 -0
- package/dist/cli/cli-1n1zb64f.js +2 -0
- package/dist/cli/client-2t9gjkck.js +2 -0
- package/dist/cli/{commands-3p7e4xxs.js → commands-exafvm2b.js} +1 -1
- package/dist/cli/connect-6zde0kn3.js +2 -0
- package/dist/cli/{context-cmd-eqxmxhzq.js → context-cmd-5t43wgqt.js} +1 -1
- package/dist/cli/context-report-kt01pw8y.js +2 -0
- package/dist/cli/{count-remote-mby98cd0.js → count-remote-ap7x3vh6.js} +1 -1
- package/dist/cli/{design-122y0axd.js → design-ne5zszyh.js} +1 -1
- package/dist/cli/dispatch-2r5myxye.js +2 -0
- package/dist/cli/doctor-ws4fh4tn.js +3 -0
- package/dist/cli/{executor-ftvg6tsy.js → executor-bdrjn634.js} +1 -1
- package/dist/cli/export-1mxb9g5p.js +2 -0
- package/dist/cli/{files-cez9a96p.js → files-g104xghh.js} +1 -1
- package/dist/cli/gauntlet-07xrjpj7.js +2 -0
- package/dist/cli/{gauntlet-runner-r515m7kk.js → gauntlet-runner-xvy64436.js} +1 -1
- package/dist/cli/{gauntlet-wave3-bnkjk2v2.js → gauntlet-wave3-jm91yt5w.js} +1 -1
- package/dist/cli/{gauntlet-wave4-acs9s60q.js → gauntlet-wave4-r13py7p1.js} +1 -1
- package/dist/cli/hashline-znvrat11.js +2 -0
- package/dist/cli/http-xafw6fsh.js +143 -0
- package/dist/cli/{index-z5qt1s76.js → index-1sgjm25y.js} +1 -1
- package/dist/cli/init-g2m0tn4m.js +51 -0
- package/dist/cli/install-avaqjjqq.js +2 -0
- package/dist/cli/loop-mmpfft01.js +2 -0
- package/dist/cli/{main-a3f51n0x.js → main-0904f6ps.js} +1 -1
- package/dist/cli/{main-f33fc5je.js → main-0ab9fc26.js} +2 -2
- package/dist/cli/{main-n6qrdbmy.js → main-0mtcdbs7.js} +2 -2
- package/dist/cli/main-0z1w2zsg.js +3 -0
- package/dist/cli/{main-rvetps99.js → main-1dchs7xv.js} +2 -2
- package/dist/cli/{main-rpg7h8mb.js → main-1ereejm1.js} +2 -2
- package/dist/cli/{main-6vjeds42.js → main-1k1kw6b5.js} +2 -2
- package/dist/cli/{main-hrrvcfan.js → main-27y4sm2k.js} +2 -2
- package/dist/cli/{main-8c1tbazx.js → main-2wwjex5j.js} +2 -2
- package/dist/cli/main-2yfck9b5.js +3 -0
- package/dist/cli/main-2zmzgkwh.js +3 -0
- package/dist/cli/{main-xt9zc3n6.js → main-351pz3z7.js} +1 -1
- package/dist/cli/{main-kba6zeyd.js → main-3gjqfh7a.js} +1 -1
- package/dist/cli/{main-s4bb0jav.js → main-3nf3kgve.js} +1 -1
- package/dist/cli/{main-2z3dek0b.js → main-3pjrb2hd.js} +1 -1
- package/dist/cli/{main-qj2djy17.js → main-3rxcvgna.js} +3 -3
- package/dist/cli/{main-9a9rnh47.js → main-4b3jgy66.js} +1 -1
- package/dist/cli/{main-6dtqmbt6.js → main-4wndhjdc.js} +1 -1
- package/dist/cli/{main-9ht36z12.js → main-4xcmvxnk.js} +2 -2
- package/dist/cli/{main-vp2dfb7s.js → main-5tbz0wbz.js} +2 -2
- package/dist/cli/{main-wpkyraxh.js → main-5ywnwthm.js} +2 -2
- package/dist/cli/{main-yrjt2sqt.js → main-6b62vkz0.js} +2 -2
- package/dist/cli/{main-2zgsknth.js → main-6dnk69vp.js} +1 -1
- package/dist/cli/{main-nvc3yjay.js → main-6genrmhs.js} +2 -2
- package/dist/cli/{main-rsy72qmw.js → main-73g7eff4.js} +2 -2
- package/dist/cli/{main-jak598k9.js → main-7c5thhjd.js} +1 -1
- package/dist/cli/{main-y5c82rxr.js → main-7rn6bqje.js} +1 -1
- package/dist/cli/{main-4p4e2w7x.js → main-80haw7qk.js} +2 -2
- package/dist/cli/{main-01pv9206.js → main-875s60s2.js} +2 -2
- package/dist/cli/{main-ywbxshqc.js → main-8kjxbpw4.js} +1 -1
- package/dist/cli/{main-1ztz6fkj.js → main-90ds1z4e.js} +1 -1
- package/dist/cli/{main-mjt2p7aj.js → main-9etavkew.js} +1 -1
- package/dist/cli/main-a9njrkk1.js +3 -0
- package/dist/cli/{main-fvnpq46y.js → main-aecrjq2d.js} +2 -2
- package/dist/cli/{main-23q7cmww.js → main-ck9asesq.js} +2 -2
- package/dist/cli/{main-wqt32p5x.js → main-cta9racd.js} +2 -2
- package/dist/cli/{main-wm997zjx.js → main-ddv7j2ag.js} +1 -1
- package/dist/cli/{main-ntqef02r.js → main-dfreez27.js} +1 -1
- package/dist/cli/{main-m8vm17zq.js → main-f7rw7des.js} +1 -1
- package/dist/cli/{main-rebtt91r.js → main-ggcn7rd7.js} +2 -2
- package/dist/cli/{main-gbbty4d4.js → main-gzkmycnv.js} +1 -1
- package/dist/cli/{main-vxnwe5xx.js → main-hq51jg8v.js} +2 -2
- package/dist/cli/{main-vqbr22sz.js → main-jft389w9.js} +2 -2
- package/dist/cli/{main-qvarybsp.js → main-k1eqkg83.js} +2 -2
- package/dist/cli/{main-2wyax8k9.js → main-k2y8a2aw.js} +2 -2
- package/dist/cli/main-kcpbykxz.js +4 -0
- package/dist/cli/{main-45rn3trk.js → main-kd488vje.js} +1 -1
- package/dist/cli/main-kh32yvgk.js +5 -0
- package/dist/cli/{main-z13755t8.js → main-kqxnqjnv.js} +4 -4
- package/dist/cli/{main-b8zq261k.js → main-kyn0xnsg.js} +2 -2
- package/dist/cli/{main-evgz4mp5.js → main-m1kk6fp5.js} +1 -1
- package/dist/cli/{main-5py0rkmc.js → main-mv40pcr2.js} +1 -1
- package/dist/cli/{main-vhrrq337.js → main-n0t3973w.js} +1 -1
- package/dist/cli/{main-s9v8k74e.js → main-pknhvrmj.js} +2 -2
- package/dist/cli/{main-kwwsz6rq.js → main-pn1w7a7j.js} +2 -2
- package/dist/cli/{main-6h9x282m.js → main-prxxs70n.js} +2 -2
- package/dist/cli/{main-2rzbexn2.js → main-q3vsesf9.js} +1 -1
- package/dist/cli/{main-gth53dnt.js → main-rdgdw24b.js} +7 -7
- package/dist/cli/{main-4y0tnfpa.js → main-rfth4tbm.js} +1 -1
- package/dist/cli/{main-wk2csfnj.js → main-rg0wn0xf.js} +2 -2
- package/dist/cli/{main-xx2z3zh5.js → main-sdmxhtv8.js} +1 -1
- package/dist/cli/{main-mg9b20ac.js → main-skbp13js.js} +1 -1
- package/dist/cli/{main-xfekqh9m.js → main-t4xnd213.js} +1 -1
- package/dist/cli/{main-7kt6r53y.js → main-vqak588n.js} +2 -2
- package/dist/cli/{main-hqbz10aw.js → main-w2n1303f.js} +1 -1
- package/dist/cli/{main-na7wse0x.js → main-wbrdspr2.js} +2 -2
- package/dist/cli/{main-a2yfvcy9.js → main-wsrg79c1.js} +2 -2
- package/dist/cli/{main-hzwtsb2m.js → main-x4r0fne4.js} +2 -2
- package/dist/cli/{main-78gq4bt9.js → main-xea2f3tn.js} +1 -1
- package/dist/cli/{main-v8y60bb2.js → main-xg704a3c.js} +1 -1
- package/dist/cli/{main-p0cfn6nr.js → main-xvnrabfp.js} +2 -2
- package/dist/cli/{main-45ejth3a.js → main-xy53xf0r.js} +2 -2
- package/dist/cli/{main-x9ct6y1a.js → main-y1fqy60y.js} +2 -2
- package/dist/cli/{main-j7ttv0sd.js → main-yn8cd281.js} +4 -4
- package/dist/cli/{main-zc7pyrbj.js → main-yr0ksc0h.js} +1 -1
- package/dist/cli/{main-tkgarpjj.js → main-z2ex2vyf.js} +2 -2
- package/dist/cli/{main-mgb9ccnx.js → main-z3aayzvq.js} +1 -1
- package/dist/cli/{main-tjvwmscs.js → main-zaqh35jg.js} +2 -2
- package/dist/cli/{main-edxc3yzt.js → main-zc2e8e46.js} +2 -2
- package/dist/cli/{main-bxtvnf6d.js → main-zzrfw6cf.js} +2 -2
- package/dist/cli/main.js +5 -4
- package/dist/cli/{market-cmd-bm5xvn9f.js → market-cmd-e14kmx9n.js} +2 -2
- package/dist/cli/{mcp-login-bthtfpt7.js → mcp-login-wq7ktdek.js} +1 -1
- package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
- package/dist/cli/{notify-54v5z9dz.js → notify-b7qc0cjb.js} +1 -1
- package/dist/cli/{oauth-g5gme95c.js → oauth-z8whcgfx.js} +1 -1
- package/dist/cli/{output-satndjap.js → output-b3ewj3ps.js} +1 -1
- package/dist/cli/{profiles-sfhpbq3m.js → profiles-6mr5he5e.js} +1 -1
- package/dist/cli/{provider-config-hv3xtdt4.js → provider-config-g7j42q8x.js} +1 -1
- package/dist/cli/provider-jr1y8vvm.js +2 -0
- package/dist/cli/registry-s8yk86g0.js +2 -0
- package/dist/cli/{registry-fh0hdnyn.js → registry-t6p8d4mn.js} +1 -1
- package/dist/cli/{repl-t4z03mqq.js → repl-bajwe1mh.js} +1 -1
- package/dist/cli/{resume-fqt4chg8.js → resume-rwn9nz7y.js} +1 -1
- package/dist/cli/run-flags-nah7ndpt.js +2 -0
- package/dist/cli/runtime-n7gafzhb.js +2 -0
- package/dist/cli/{sandbox-config-g4qxd7y5.js → sandbox-config-emdy18x4.js} +1 -1
- package/dist/cli/{server-r0b6bksk.js → server-b0nvs2bn.js} +1 -1
- package/dist/cli/session-arg-y75wd4kj.js +2 -0
- package/dist/cli/session-j62evmjq.js +2 -0
- package/dist/cli/{sessions-cmd-adw7svfn.js → sessions-cmd-tsnwz0ns.js} +1 -1
- package/dist/cli/{settings-y9rzcqx8.js → settings-df10wfez.js} +1 -1
- package/dist/cli/{setup-jmbr11j0.js → setup-jzvv72fg.js} +1 -1
- package/dist/cli/{sextant-smoke-tcth0vea.js → sextant-smoke-37m81ke6.js} +1 -1
- package/dist/cli/{skills-cmd-zbdy99v6.js → skills-cmd-gjxnxnhx.js} +1 -1
- package/dist/cli/smoke-p7748apt.js +8 -0
- package/dist/cli/{start-chat-p01cdks3.js → start-chat-s4st3mm0.js} +3 -3
- package/dist/cli/stream-gmeyewds.js +2 -0
- package/dist/cli/task-gh0kkp3n.js +2 -0
- package/dist/cli/tasks-z1kfpe8e.js +2 -0
- package/dist/cli/{thinking-a5ngvqyh.js → thinking-0eqkrz6t.js} +1 -1
- package/dist/cli/{todo-1wxpcecx.js → todo-5brcrt9m.js} +1 -1
- package/dist/cli/{tools-x1tj4fxm.js → tools-7pzm0vj9.js} +1 -1
- package/dist/cli/{tools-2ftsya7w.js → tools-s635p6s8.js} +1 -1
- package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
- package/dist/cli/{update-check-ygt3vd7m.js → update-check-pt31bm2f.js} +1 -1
- package/dist/cli/{update-cmd-v23qhr8c.js → update-cmd-tk131s9t.js} +1 -1
- package/dist/cli/{voice-g1gtck92.js → voice-56nabd8d.js} +1 -1
- package/dist/cli/{webfetch-0nnrjgb5.js → webfetch-xd8q596m.js} +1 -1
- package/dist/cli/{websearch-f0vr2p7d.js → websearch-5hkf98k1.js} +1 -1
- package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
- package/dist/cli/{workspace-9rq1w4ta.js → workspace-q10g5z3e.js} +1 -1
- package/dist/lib/index.js +44 -44
- package/dist/lib/plugins.js +54 -5
- package/dist/lib/public-api.js +15 -15
- package/dist/lib/sdk.js +360 -0
- package/package.json +3 -2
- package/dist/cli/app-dybnr56b.js +0 -2
- package/dist/cli/auth-login-ewpgw5sm.js +0 -2
- package/dist/cli/catalog-737wb2s0.js +0 -2
- package/dist/cli/cli-arhg40m0.js +0 -2
- package/dist/cli/client-cf2pxx8q.js +0 -2
- package/dist/cli/connect-3q93d7cb.js +0 -2
- package/dist/cli/context-report-hbw9zfes.js +0 -2
- package/dist/cli/dispatch-b4egzvvh.js +0 -2
- package/dist/cli/doctor-x4jkv72e.js +0 -3
- package/dist/cli/export-pdgdhkch.js +0 -2
- package/dist/cli/gauntlet-r3xxaszc.js +0 -2
- package/dist/cli/hashline-ewg5hbe3.js +0 -2
- package/dist/cli/http-n0kehsk8.js +0 -5
- package/dist/cli/install-80mp63kx.js +0 -2
- package/dist/cli/loop-12twjcat.js +0 -2
- package/dist/cli/main-7jd5vh3x.js +0 -4
- package/dist/cli/main-mg4f96e1.js +0 -3
- package/dist/cli/main-wgph00xf.js +0 -5
- package/dist/cli/main-ys6zj3yr.js +0 -3
- package/dist/cli/mcp-market-cmd-mbeshfyd.js +0 -2
- package/dist/cli/provider-kwzq6g84.js +0 -2
- package/dist/cli/registry-y1y8e94r.js +0 -2
- package/dist/cli/run-flags-rysbag9t.js +0 -2
- package/dist/cli/runtime-j19fjbsa.js +0 -2
- package/dist/cli/session-arg-txmn5g4x.js +0 -2
- package/dist/cli/session-ed250d9j.js +0 -2
- package/dist/cli/smoke-1bg937kx.js +0 -8
- package/dist/cli/stream-4wmyaypz.js +0 -2
- package/dist/cli/task-eg4s093s.js +0 -2
- package/dist/cli/tasks-12v9rr9k.js +0 -2
- package/dist/cli/trust-cmd-hccxehzb.js +0 -2
- package/dist/rovecode.exe +0 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{I as O5,K as h9,L as bJ,M as N1}from"./main-2wwjex5j.js";import{ia as E9,qa as P6}from"./main-7c5thhjd.js";import{$b as v$,Ab as n4,Bb as I4,Cb as X5,Db as n,Eb as z4,Fb as EJ,Gb as IJ,Hb as x5,Ib as SJ,Jb as J0,Lb as D$,Mb as m$,Nb as H$,Ob as q5,Pb as m0,Qb as A5,Rb as B0,Sb as qJ,Tb as L0,Ub as K8,Vb as N$,Wb as R5,Xb as t$,Yb as E5,Zb as e$,_b as zJ,ac as DJ,bc as X0,db as A,eb as _0,fb as A$,gb as kJ,hb as BJ,ib as I0,jb as p,kb as t0,lb as b5,mb as M8,nb as l$,ob as WJ,pb as O8,qb as _J,rb as PJ,sb as x8,tb as _4,ub as P4,vb as u5,wb as A4,xb as AJ,yb as o0,zb as E4}from"./main-73g7eff4.js";import{Ve as v4,Xe as xZ}from"./main-3pjrb2hd.js";import{jg as FJ,sg as K1}from"./main-t4xnd213.js";import{Rg as J4,Sg as Z4,bh as i7}from"./main-1dchs7xv.js";import{Th as Y1,Uh as OJ}from"./main-0z1w2zsg.js";import{tk as G0,uk as J8}from"./main-8kjxbpw4.js";import{un as H1,vn as G1,wn as k,xn as N5}from"./main-qsevpgsv.js";function h($,J,Z){let Q=Math.round(($>>16&255)+((J>>16&255)-($>>16&255))*Z),V=Math.round(($>>8&255)+((J>>8&255)-($>>8&255))*Z),j=Math.round(($&255)+((J&255)-($&255))*Z);return Q<<16|V<<8|j}function d5($){return Object.hasOwn(a8,$)}function h5($){let J=d5($)?$:"night",Z=a8[J],Q=l(Z.bg),V=l(Z.fg),j=l(Z.fg2),X=l(Z.accent),U=l(Z.ok),G=l(Z.err);return{name:J,label:Z.label,bg:Q,bg2:l(Z.bg2),fg:V,fg2:j,muted:l(Z.muted),dim:l(Z.dim),rule:l(Z.rule),rule2:l(Z.rule2),accent:X,accent2:l(Z.accent2),ok:U,err:G,warn:l(Z.warn),info:l(Z.info),str:l(Z.str),ty:l(Z.ty),hlBg:h(Q,X,0.12),addBg:h(Q,U,0.15),delBg:h(Q,G,0.15),selBg:h(Q,V,0.08),accentDim:h(Q,X,0.45),okDim:h(Q,U,0.55),mixDim:h(Q,j,0.55),frame:h(Q,V,0.28),frameDim:h(Q,V,0.17)}}var a8,l=($)=>parseInt($.slice(1),16),p5=($)=>"#"+($>>>0).toString(16).padStart(6,"0"),q=($,J=-1,Z=0)=>({fg:$,bg:J,a:Z});var Q0=k(()=>{p();a8={night:{label:"Gece + nane",bg:"#0b0e12",bg2:"#11161c",fg:"#e6edf3",fg2:"#aab4bf",muted:"#7d8590",dim:"#4b545e",rule:"#2a323b",rule2:"#3a4550",accent:"#3ddbb9",accent2:"#9af2df",ok:"#3fb950",err:"#f0605d",warn:"#e3b341",info:"#79c0ff",str:"#9ee7d6",ty:"#b6c2ce"},ember:{label:"M\xFCrekkep + kor",bg:"#0f0c0b",bg2:"#171210",fg:"#f2eae2",fg2:"#c9bcb0",muted:"#8c817a",dim:"#554c46",rule:"#332b27",rule2:"#463a34",accent:"#ff7a45",accent2:"#ffb08a",ok:"#6cc783",err:"#ef5a5a",warn:"#f4b942",info:"#8fb8e8",str:"#ffb38a",ty:"#cdbfb3"},contrast:{label:"Saf kontrast",bg:"#000000",bg2:"#0b0b0b",fg:"#ffffff",fg2:"#d4d4d4",muted:"#8a8a8a",dim:"#4c4c4c",rule:"#3a3a3a",rule2:"#4a4a4a",accent:"#ffffff",accent2:"#ffffff",ok:"#4ade80",err:"#f87171",warn:"#fbbf24",info:"#93c5fd",str:"#d4d4d4",ty:"#bdbdbd"}}});import{eastAsianWidth as fJ}from"get-east-asian-width";function s8($,J=!1){if($<128)return 1;if(r8($))return 0;if(J?uJ($):$<4352)return 1;return fJ($,{ambiguousAsWide:J})}function*m5($,J=!1){let Z="",Q=1,V=!1;for(let j of $){let X=j.codePointAt(0),U=s8(X,J);if(Z&&(U===0||V&&X>=128)){Z+=j,V=X===xJ;continue}if(U===0)continue;if(Z)yield[Z,Q];Z=j,Q=U,V=!1}if(Z)yield[Z,Q]}function f($,J=!1){let Z=0;for(let[,Q]of m5($,J))Z+=Q;return Z}function i8($,J){let Z=($>>16&255)-(J>>16&255),Q=($>>8&255)-(J>>8&255),V=($&255)-(J&255);return Z*Z+Q*Q+V*V}function n8($){if($<16)return pJ[$]??0;if($<232){let Z=$-16;return w5[Math.floor(Z/36)]<<16|w5[Math.floor(Z/6)%6]<<8|w5[Z%6]}let J=8+10*Math.min(23,$-232);return J<<16|J<<8|J}function o8($){let J=$>>16&255,Z=$>>8&255,Q=$&255,V=16+36*l5(J)+6*l5(Z)+l5(Q),j=232+Math.max(0,Math.min(23,Math.round(((J+Z+Q)/3-8)/10)));return i8($,n8(j))<i8($,n8(V))?j:V}function dJ($,J,Z,Q=!0){let V=E0+"0";if(Z&A.BOLD)V+=";1";if(Z&A.DIM)V+=";2";if(Z&A.ITALIC)V+=";3";if(Z&A.UNDERLINE)V+=";4";if(Z&A.INVERSE)V+=";7";if(Z&A.STRIKE)V+=";9";if($>=0)V+=Q?`;38;2;${$>>16&255};${$>>8&255};${$&255}`:`;38;5;${o8($)}`;if(J>=0)V+=Q?`;48;2;${J>>16&255};${J>>8&255};${J&255}`:`;48;5;${o8(J)}`;return V+"m"}class Z5{sink;w=0;h=0;ch=[];wd=new Uint8Array(0);fg=new Int32Array(0);bg=new Int32Array(0);at=new Uint8Array(0);prev=null;truecolor;ambiguousAsWide;constructor($,J,Z,Q={}){this.sink=$;this.truecolor=Q.truecolor??!0,this.ambiguousAsWide=Q.ambiguousAsWide??!1,this.resize(J,Z)}resize($,J){this.w=Math.max(v0,Number.isFinite($)?Math.floor($):0),this.h=Math.max(f0,Number.isFinite(J)?Math.floor(J):0);let Z=this.w*this.h;this.ch=Array(Z).fill(" "),this.wd=new Uint8Array(Z).fill(1),this.fg=new Int32Array(Z).fill(-1),this.bg=new Int32Array(Z).fill(-1),this.at=new Uint8Array(Z),this.prev=null}begin($){this.ch.fill(" "),this.wd.fill(1),this.fg.fill(-1),this.bg.fill($==null?-1:$),this.at.fill(0)}cellAt($,J){if($<0||J<0||$>=this.w||J>=this.h)return null;let Z=J*this.w+$;return{ch:this.ch[Z],fg:this.fg[Z],bg:this.bg[Z],a:this.at[Z],width:this.wd[Z]}}breakWide($){let J=this.wd[$];if(J===0&&$>0)this.ch[$-1]=" ",this.wd[$-1]=1;else if(J===2&&$+1<this.wd.length)this.ch[$+1]=" ",this.wd[$+1]=1}set($,J,Z,Q,V,j){if(this.breakWide($),Z===2)this.breakWide($+1);if(this.ch[$]=J,this.wd[$]=Z,this.fg[$]=Q,V>=0)this.bg[$]=V;if(this.at[$]=j,Z===2){if(this.ch[$+1]="",this.wd[$+1]=0,this.fg[$+1]=Q,V>=0)this.bg[$+1]=V;this.at[$+1]=j}}head($,J){let Z="",Q=0;for(let[V,j]of m5($,this.ambiguousAsWide)){if(Q+j>J)break;Z+=V,Q+=j}return Z}put($,J,Z,Q,V=1/0){if(J<0||J>=this.h||!Z)return $;let j=Q?Q.fg:-1,X=Q?Q.bg:-1,U=Q?Q.a:0,G=$,Y=Math.min(this.w,$+V);for(let[K,z]of m5(Z.replace(c8," "),this.ambiguousAsWide)){if(G>=Y)break;if(z===2&&G+2>Y)break;if(G>=0)this.set(J*this.w+G,K,z,j,X,U);G+=z}return G}text($,J,Z,Q=1/0){let V=$,j=$+Q;for(let[X,U]of Z){if(V>=j)break;V=this.put(V,J,X,U,j-V)}return V}clip($,J,Z,Q,V){if(V<=0)return $;if(f(Z,this.ambiguousAsWide)>V)Z=V>1?this.head(Z,V-1)+"\u2026":this.head(Z,V);return this.put($,J,Z,Q,V)}fill($,J,Z,Q,V,j){let X=j?j.fg:-1,U=j?j.bg:-1,G=j?j.a:0,Y=V.replace(c8," ").codePointAt(0)??32;if(r8(Y))Y=32;let K=String.fromCodePoint(Y),z=s8(Y,this.ambiguousAsWide)||1;for(let D=J;D<J+Q;D++){if(D<0||D>=this.h)continue;for(let H=$;H<$+Z;H+=z){if(H<0||H+z>this.w||H+z>$+Z)continue;this.set(D*this.w+H,K,z,X,U,G)}}}tint($,J,Z,Q,V){for(let j=J;j<J+Q;j++){if(j<0||j>=this.h)continue;for(let X=$;X<$+Z;X++){if(X<0||X>=this.w)continue;this.bg[j*this.w+X]=V}}}hline($,J,Z,Q,V="\u2500"){for(let j=0;j<Z;j++)this.put($+j,J,V,Q)}vline($,J,Z,Q,V="\u2502"){for(let j=0;j<Z;j++)this.put($,J+j,V,Q)}box($,J,Z,Q,V,j){if(j!=null)this.fill($,J,Z,Q," ",{fg:-1,bg:j,a:0});this.put($,J,"\u256D",V),this.put($+Z-1,J,"\u256E",V),this.put($,J+Q-1,"\u2570",V),this.put($+Z-1,J+Q-1,"\u256F",V),this.hline($+1,J,Z-2,V),this.hline($+1,J+Q-1,Z-2,V),this.vline($,J+1,Q-2,V),this.vline($+Z-1,J+1,Q-2,V)}flush($){let J=this.w*this.h,Z=!1;if(!this.prev||this.prev.ch.length!==J)this.prev={ch:Array(J).fill(null),fg:new Int32Array(J).fill(-2),bg:new Int32Array(J).fill(-2),at:new Uint8Array(J).fill(255)},Z=!0;let Q=this.prev,V=Z?E0+"2J":"",j=null,X=null,U=null,G=-1,Y=-1,K=J-1;for(let z=0;z<this.h;z++)for(let D=0;D<this.w;D++){let H=z*this.w+D,N=this.wd[H];if(N===0)continue;if(H+N-1>=K)continue;if(!Z&&this.ch[H]===Q.ch[H]&&this.fg[H]===Q.fg[H]&&this.bg[H]===Q.bg[H]&&this.at[H]===Q.at[H])continue;if(!(Y===z&&G===D))V+=E0+(z+1)+";"+(D+1)+"H";let M=this.fg[H],O=this.bg[H],_=this.at[H];if(M!==j||O!==X||_!==U)V+=dJ(M,O,_,this.truecolor),j=M,X=O,U=_;if(V+=this.ch[H],G=D+N,Y=z,Q.ch[H]=this.ch[H],Q.fg[H]=M,Q.bg[H]=O,Q.at[H]=_,N===2)Q.ch[H+1]="",Q.fg[H+1]=M,Q.bg[H+1]=O,Q.at[H+1]=_}V+=$?E0+($.y+1)+";"+($.x+1)+"H"+E0+"?25h":E0+"?25l",this.sink.write(V)}toText(){let $=[];for(let J=0;J<this.h;J++)$.push(this.ch.slice(J*this.w,(J+1)*this.w).join("").replace(/\s+$/,""));return $.join(`
|
|
3
3
|
`)}toHTML($="Cascadia Mono"){let J="";for(let Z=0;Z<this.h;Z++){let Q="",V="",j=null,X=()=>{if(!V||!j)return;let U=j;Q+=`<span style="color:${U.fg>=0?p5(U.fg):"inherit"};background:${U.bg>=0?p5(U.bg):"transparent"};${U.a&A.BOLD?"font-weight:600;":""}${U.a&A.ITALIC?"font-style:italic;":""}${U.a&A.STRIKE?"text-decoration:line-through;":""}">${V.replace(/&/g,"&").replace(/</g,"<")}</span>`,V=""};for(let U=0;U<this.w;U++){let G=Z*this.w+U,Y={fg:this.fg[G],bg:this.bg[G],a:this.at[G]};if(!j||j.fg!==Y.fg||j.bg!==Y.bg||j.a!==Y.a)X(),j=Y;V+=this.ch[G]}X(),J+=Q+`
|
|
4
4
|
`}return`<!doctype html><meta charset="utf-8"><body style="margin:0;background:#000"><pre style="margin:0;font:14px/1.25 '${$}',Consolas,monospace;display:inline-block">${J}</pre></body>`}}var yJ="\x1B",E0,v0=40,f0=12,gJ,r8=($)=>$>=768&&gJ.test(String.fromCodePoint($)),uJ=($)=>$>=9472&&$<9632||$===8230,xJ=8205,c8,w5,pJ,l5=($)=>$<48?0:$<115?1:Math.min(5,Math.floor(($-35)/40));var D0=k(()=>{Q0();p();E0=yJ+"[",gJ=/^[\p{Mn}\p{Me}\p{Cf}\u200B-\u200D\uFE00-\uFE0F]$/u,c8=/[\x00-\x1f\x7f-\x9f]/g;w5=[0,95,135,175,215,255],pJ=[0,8388608,32768,8421376,128,8388736,32896,12632256,8421504,16711680,65280,16776960,255,16711935,65535,16777215]});function a5($,J,Z){let Q=Math.max(v0,$),V=Math.max(f0,J),j={x:0,y:0,w:Q-1,h:V},X=2,U=Q-4,G=1,Y=V-2,K=Q>=140,z=Q>=110,D=K?Q>=150?30:26:0,H=z?Q>=150?34:28:0,N=Y-1+1,M=K?{x:2,y:1,w:D,h:N}:null,O=z?{x:U-H+1,y:1,w:H,h:N}:null,_=2+(K?D+1:0),E=(O?O.x-1:U+1)-_,I=Math.max(8,Math.round(N*0.34)),T={x:_,y:1,w:E,h:N-I},F={x:_,y:1+T.h,w:E,h:I},P=Z.pet&&N>=36?14:0,W=null,R=null,b=null;if(O)W={x:O.x,y:1,w:H,h:N-5},R={x:O.x,y:1+W.h,w:H,h:5};if(P&&M)M.h=N-P,b={x:2,y:1+M.h,w:D,h:P};else if(P&&O&&W)W.h-=P,b={x:O.x,y:1+W.h,w:H,h:P};return{w:Q,h:V,frame:j,files:M,code:T,messages:F,plan:W,usage:R,pet:b}}function hJ($,J){let Z="",Q=0;for(let V of $){let j=f(V);if(Q+j>J)break;Z+=V,Q+=j}return Z}function wJ($,J){let Z=$.filter(([G])=>G.length>0),Q=w(Z);if(Q<=J)return Z;if(J<6)return[];let V=0;Z.forEach(([G],Y)=>{if(f(G)>f(Z[V]?.[0]??""))V=Y});let[j,X]=Z[V],U=f(j)-(Q-J)-1;if(U<3)return[];return Z=Z.map((G,Y)=>Y===V?[hJ(j,U)+"\u2026",X]:G),Q=w(Z),Q<=J?Z:[]}function e($,J,Z,Q,V,j,X){let U=X??(Q?j.accent:j.frame);if($.box(J.x,J.y,J.w,J.h,q(U),j.bg),Z)$.text(J.x+2,J.y,[[" ",q(-1)],[Z,q(X??(Q?j.accent:j.fg2),-1,A.BOLD)],[" ",q(-1)]],Math.max(0,J.w-4));if(V&&V.length){let G=wJ(V,J.w-8-f(Z)),Y=w(G);if(Y>0)$.text(J.x+J.w-3-Y,J.y,[[" ",q(-1)],...G,[" ",q(-1)]])}return{x:J.x+2,y:J.y+1,w:J.w-4,h:J.h-2}}var w=($)=>$.reduce((J,[Z])=>J+f(Z),0);var H0=k(()=>{D0();Q0();p()});function lJ($){let J=$.split(`
|
|
5
5
|
`);if(J.length&&J[J.length-1]==="")J.pop();return J}function V5($){if(Q5&&Q5.src===$)return Q5.lines;let J=lJ($);return Q5={src:$,lines:J},J}function i($,J){let Z=Math.max(1,J),Q=[];for(let V of String($).split(`
|
|
6
6
|
`)){let j="",X=0;for(let U of V.split(" ")){let G=[...U];if(j&&X+1+G.length<=Z){j+=" "+U,X+=1+G.length;continue}if(j)Q.push(j);while(G.length>Z)Q.push(G.splice(0,Z).join(""));j=G.join(""),X=G.length}Q.push(j)}return Q}function c5($,J){let Z=Math.max(1,J),Q=[...$];if(Q.length<=Z)return[$];let V=[];for(let j=0;j<Q.length;j+=Z)V.push(Q.slice(j,j+Z).join(""));return V}var N0=($)=>I0[Math.floor($/140)%I0.length]??"\u25C7",Q5=null,a=($)=>({x:$.x+2,y:$.y+1,w:$.w-4,h:$.h-2});var $0=k(()=>{p();Q0();H0()});function U5($,J=0){switch($){case"queued":return"\u25C7";case"running":return N0(J);case"done":return"\u25C6";case"failed":return"\xD7";default:return"\u25AA"}}function G5($,J){switch($){case"queued":return J.dim;case"running":return J.accent;case"done":return J.ok;case"failed":return J.err;default:return J.muted}}function Y5($,J){return Math.max(0,($.finishedAt??J)-($.startedAt??$.createdAt))}function i5($,J){switch($.status){case"queued":return"queued";case"running":return`working ${$9(Y5($,J))}`;default:return $.status}}function sJ($){switch($.status){case"done":return`done: ${e8($.summary)||"(no output)"}`;case"failed":return`failed: ${e8($.error)||"(no reason)"}`;case"cancelled":return"cancelled";case"queued":return"queued \xB7 waiting for a slot";default:return"running"}}function J9($){if(!$.isolated||$.patchLines===void 0)return null;return $.patchLines>0?`+${$.patchLines} lines merged`:"nothing merged"}function Z9($){let J={total:$.length,queued:0,running:0,done:0,failed:0,cancelled:0};for(let V of $)J[V.status]++;let Z=J.queued+J.running,Q=Z?`${Z} working`:J.total?`${J.done}/${J.total} done`:"no background tasks";return{...J,working:Z,needsYou:0,text:Q}}function n5($,J){if(J<=0)return{cols:0,rows:0};let Z=Math.min(J,$<t8[0]?1:$<t8[1]?2:3);return{cols:Z,rows:Math.ceil(J/Z)}}function tJ($,J){let Z=Math.max(1,$),Q=Math.max(1,Math.floor(Z/4)),V=Math.floor(Math.max(0,J)/nJ)%(Z+Q);return Array.from({length:Z},(j,X)=>X<V&&X>=V-Q)}function o5($,J){let Z=J.crew.length;if(Z===0||$.w<aJ||$.h<3)return{cells:[],page:0,pages:0,footer:!1};let Q=K5(J);if(J.code.laneOpen)return{cells:[{index:Q,rect:$}],page:0,pages:1,footer:!1};let{cols:V,rows:j}=n5($.w,Z),X=(_)=>V*Math.max(1,Math.min(j,Math.floor(_/mJ))),U=X($.h)<Z,G=X($.h-(U?1:0)),Y=$.h-(U?1:0),K=Math.ceil(Z/G),z=Math.floor(Q/G),D=z*G,H=Math.min(G,Z-D),N=Math.floor($.w/V),M=Math.floor(Y/Math.ceil(H/V));return{cells:Array.from({length:H},(_,E)=>({index:D+E,rect:{x:$.x+E%V*N,y:$.y+Math.floor(E/V)*M,w:N,h:M}})),page:z,pages:K,footer:U}}function V9($){if($.status==="done")return $.summary?.trim()||"(no output)";if($.status==="failed"||$.status==="cancelled")return $.error?.trim()||$.status;return"no result yet"}function eJ($,J,Z){let Q=Math.max(0,Math.min(cJ,Z-1)),V=i($.goal,J).filter((X)=>X!=="").slice(0,Q).map((X)=>[{text:X,tone:"muted"}]);V.push([{text:`${$.id} \xB7 ${$.agent}${$.isolated?" \xB7 isolated":""}`,tone:"dim"}]);let j=J9($);if(j)V.push([{text:j,tone:$.patchLines?"ok":"dim"}]);return V}function j9($,J,Z){let Q=i($.goal,Math.max(1,J-j5.length-2)).filter((j)=>j!=="").slice(0,iJ).map((j)=>[{text:j,tone:"muted"}]);if(!Q.length)Q.push([{text:"",tone:"muted"}]);if(Q.push([{text:`${$.id} \xB7 ${$.agent} \xB7 depth ${$.depth}${$.isolated?" \xB7 isolated":""}`,tone:"dim"}]),Q.push([{text:U5($.status,Z)+" ",tone:$6($.status)},{text:i5($,Z),tone:"fg2"}]),$.usage){let j=$.usage.costUsd!==void 0?` \xB7 $${$.usage.costUsd.toFixed(3)}`:"";Q.push([{text:"tokens ",tone:"muted"},{text:`${n($.usage.input)} in \xB7 ${n($.usage.output)} out${j}`,tone:"fg2"}])}let V=J9($);if(V)Q.push([{text:V,tone:$.patchLines?"ok":"dim"}]);return Q.push([]),Q}function r5($,J){if(!J.code.laneOpen||!J.crew.length)return 0;let Z=J.crew[K5(J)],Q=Q9($);if(Q.w<4||Q.h<3)return 0;let V=Q.h-2-j9(Z,Q.w,0).length,j=Math.max(0,i(V9(Z),Q.w).length-V);return Math.max(0,Math.min(J.code.scroll,j))}function Q6($,J,Z,Q,V,j){let X=`${$9(Y5(Z,V))} \xB7 ${rJ(Z)}`,U=X.length+6<=J.w,G=$.put(J.x,J.y,U5(Z.status,V)+" ",q(G5(Z.status,Q)),J.w);if($.clip(G,J.y,Z.label,q(j?Q.accent:Q.fg,-1,A.BOLD),J.x+J.w-G-(U?X.length+1:0)),U)$.put(J.x+J.w-X.length,J.y,X,q(Q.dim))}function V6($,J,Z,Q,V,j,X){if(V.status==="running"){let D=Q-7-2;if(D<4){$.put(J,Z,"running",q(j.muted),Q);return}tJ(D,X).forEach((H,N)=>$.put(J+N,Z,H?"\u2501":"\u2500",q(H?j.accent:j.rule2))),$.put(J+D+2,Z,"running",q(j.muted));return}let U=sJ(V),G=U.indexOf(": "),Y=G5(V.status,j);if(G<0){$.clip(J,Z,U,q(V.status==="queued"?j.dim:Y),Q);return}let K=$.put(J,Z,U.slice(0,G+2),q(Y),Q);$.clip(K,Z,U.slice(G+2),q(V.status==="failed"?j.err:j.fg2),J+Q-K)}function j6($,J,Z,Q,V,j,X){let U=Q.focus==="code",G=Q.code.laneOpen;$.box(J.x,J.y,J.w,J.h,q(X?U?V.accent:V.frame:V.frameDim));let Y=Q9(J);if(Y.w<4||Y.h<1)return;if(Q6($,Y,Z,V,j,X),Y.h<2)return;let K=Y.y+Y.h-1,z=G?j9(Z,Y.w,j):eJ(Z,Y.w,Y.h-2),D=Y.y+1;for(let H of z){if(D>=K)break;Z6($,Y.x,D++,Y.w,H,V)}if(G){if(Y.w>j5.length+4&&Y.y+1<K)$.put(Y.x+Y.w-j5.length,Y.y+1,j5,q(V.dim));let H=i(V9(Z),Y.w),N=r5(J,Q),M=Z.status==="failed"?V.err:Z.status==="done"?V.fg2:V.muted;for(let O=N;O<H.length&&D<K;O++)$.put(Y.x,D++,H[O],q(M),Y.w)}V6($,Y.x,K,Y.w,Z,V,j)}function X6($,J,Z,Q,V){let j=K5(Z);Z.crew.slice(0,J.h).forEach((X,U)=>{let G=i5(X,V),Y=J.w-G.length-1,K=$.put(J.x,J.y+U,U5(X.status,V)+" ",q(G5(X.status,Q)),J.w);if($.clip(K,J.y+U,X.label,q(U===j?Q.accent:Q.fg),Math.max(0,Math.min(J.x+J.w,J.x+Y)-K)),Y>8)$.put(J.x+J.w-G.length,J.y+U,G,q(Q.dim))})}function X9($,J,Z,Q,V){if(J.w<=0||J.h<=0)return;if($.fill(J.x,J.y,J.w,J.h," ",q(-1,Q.bg)),!Z.crew.length){$.clip(J.x,J.y,oJ,q(Q.muted),J.w);return}let j=o5(J,Z);if(!j.cells.length){X6($,J,Z,Q,V);return}let X=K5(Z);for(let{index:U,rect:G}of j.cells)j6($,G,Z.crew[U],Z,Q,V,U===X);if(j.footer)$.clip(J.x,J.y+J.h-1,`${j.page+1}/${j.pages} \xB7 ${Z.crew.length} tasks \xB7 \u2190\u2192\u2191\u2193 select`,q(Q.dim),J.w)}var t8,mJ=5,aJ=12,cJ=2,iJ=4,nJ=100,oJ="no background tasks \u2014 I start them with the task tool for parallel work",j5="esc back",$9=($)=>X5($).replace(/\.\d$/,""),rJ=($)=>$.usage?n($.usage.input+$.usage.output):"\u2014",e8=($)=>($??"").split(`
|
|
7
|
-
`).map((J)=>J.trim()).find((J)=>J!=="")??"",K5=($)=>Math.max(0,Math.min($.code.lane,$.crew.length-1)),Q9=($)=>({x:$.x+2,y:$.y+1,w:$.w-4,h:$.h-2}),$6=($)=>$==="queued"?"dim":$==="running"?"accent":$==="done"?"ok":$==="failed"?"err":"muted",J6=($,J)=>q(J[$.tone],-1,$.bold?A.BOLD:0),Z6=($,J,Z,Q,V,j)=>{if(V.length)$.text(J,Z,V.map((X)=>[X.text,J6(X,j)]),Q)};var S0=k(()=>{p();$0();J0();t8=[70,120]});function q9($,J,Z={kind:"ready"},Q=[]){L0($,"market"),$.market={tab:"all",query:"",sel:0,rows:J,status:Z,notes:Q,plan:null,choice:null,docs:!1,docScroll:0,docRows:12}}function z9($){$.market=null}function D9($,J=q5){let Z=$.rows.filter((V)=>$.tab==="all"||V.kind===$.tab),Q=$.query.trim();if(!Q)return Z;return Z.map((V)=>({r:V,hit:J(Q,`${V.title} ${V.id} ${V.publisher} ${V.description}`)})).filter((V)=>V.hit!==null).sort((V,j)=>j.hit.score-V.hit.score).map((V)=>V.r)}function G6($){return{all:$.rows.length,mcp:$.rows.filter((J)=>J.kind==="mcp").length,skill:$.rows.filter((J)=>J.kind==="skill").length,plugin:$.rows.filter((J)=>J.kind==="plugin").length}}function Y6($){if(!$.installed)return null;if($.installed.updateAvailable)return{text:"update",tone:"warn"};if($.installed.scope==="project"&&$.installed.trusted===!1)return{text:"not approved",tone:"warn"};return{text:"installed",tone:"ok"}}function K6($,J){if($.status.kind==="loading")return{text:"reading the catalogs\u2026",tone:"muted"};if($.status.kind==="error")return{text:$.status.reason,tone:"err"};if($.status.kind==="offline")return{text:$.status.note,tone:"warn"};if(J===0)return $.query.trim()||$.tab!=="all"?{text:`nothing matches${$.query.trim()?` "${$.query.trim()}"`:""}${$.tab!=="all"?` in ${$.tab}`:""}`,tone:"muted"}:{text:"the catalog is empty",tone:"muted"};return null}function G9($,J,Z,Q,V){let j=Q.plan;if(!j){if(Q.choice)q6($,J,Z,Q,V);return}let X=Math.min(76,J.w-8),U=[...j.preview,...j.replaces?[`replaces ${j.replaces}`]:[],...j.asks.map((D)=>`asks ${D.name}${D.secret?" (secret, masked)":""}${D.required?"":" \u2014 optional"}`),...j.pending.map((D)=>`you supply ${D}`)],G=Math.min(J.h-4,U.length+7),Y=Math.floor((J.w-X)/2),K=Math.max(1,Math.floor((J.h-G)/2));$.box(Y,K,X,G,q(Z.accent),Z.bg2),$.text(Y+2,K,[[" install plan ",q(Z.accent,-1,A.BOLD)]]),$.clip(Y+3,K+1,j.title,q(Z.fg,Z.bg2,A.BOLD),X-6),$.clip(Y+3,K+2,`${j.scope} scope \xB7 ${j.target}`,q(Z.muted,Z.bg2),X-6),$.hline(Y+1,K+3,X-2,q(Z.rule2,Z.bg2),"\u254C"),U.slice(0,G-6).forEach((D,H)=>$.clip(Y+3,K+4+H,D,q(Z.fg2,Z.bg2),X-6));let z=K+G-2;if(j.outcome){$.clip(Y+3,z,j.outcome.text,q(j.outcome.ok?Z.ok:Z.err,Z.bg2),X-6),V?.push({rect:{x:Y,y:K,w:X,h:G},onClick:()=>{Q.plan=null}});return}if(j.running){$.put(Y+3,z,"installing\u2026",q(Z.muted,Z.bg2)),V?.push({rect:{x:Y,y:K,w:X,h:G},onClick:()=>{}});return}$.text(Y+3,z,[["\u23CE install",q(Z.accent,Z.bg2,A.BOLD)],[" esc cancel",q(Z.dim,Z.bg2)]],X-6),V?.push({rect:{x:Y,y:K,w:X,h:G},onClick:()=>{}}),V?.push({rect:{x:Y+3,y:z,w:9,h:1},onClick:()=>{},key:K9})}function q6($,J,Z,Q,V){let j=Q.choice;if(!j)return;let X=Math.min(84,J.w-8),U=X-6,G=[];U6.forEach((H,N)=>{G.push({text:`${N===j.sel?"\u25CF":"\u25CB"} ${H.label}`,sel:N===j.sel,head:!0});for(let M of g0(H.hint,U-4))G.push({text:` ${M}`,sel:!1,head:!1})});let Y=Math.min(J.h-4,G.length+6),K=Math.floor((J.w-X)/2),z=Math.max(1,Math.floor((J.h-Y)/2));$.box(K,z,X,Y,q(Z.accent),Z.bg2),$.text(K+2,z,[[" how to start it ",q(Z.accent,-1,A.BOLD)]]),$.clip(K+3,z+1,`${j.row.title} \xB7 ${j.row.localOffer??j.row.runs}`,q(Z.fg,Z.bg2,A.BOLD),U),$.hline(K+1,z+2,X-2,q(Z.rule2,Z.bg2),"\u254C");let D=-1;G.slice(0,Y-5).forEach((H,N)=>{let M=z+3+N;if($.clip(K+3,M,H.text,H.head?q(H.sel?Z.accent:Z.fg,Z.bg2,H.sel?A.BOLD:0):q(Z.muted,Z.bg2),U),H.head){D+=1;let O=D;V?.push({rect:{x:K+3,y:M,w:U,h:1},onClick:()=>{j.sel=O}})}}),$.text(K+3,z+Y-2,[["\u2191\u2193 choose \u23CE show the plan",q(Z.accent,Z.bg2,A.BOLD)],[" esc back",q(Z.dim,Z.bg2)]],U),V?.push({rect:{x:K,y:z,w:X,h:Y},onClick:()=>{}})}function z6($,J,Z,Q,V,j,X){let U=Z,G=(Y,K,z=0)=>{if(U>=Z+V)return;if(U+=z,U>=Z+V)return;$.clip(J,U,Y,K,Q),U+=1};$.text(J,U,[[X.title,q(j.fg,j.bg2,A.BOLD)],[X.version?` ${X.version}`:"",q(j.dim,j.bg2)]],Q),U+=1,G(X.publisher,q(j.muted,j.bg2));for(let Y of g0(X.description,Q).slice(0,4))G(Y,q(j.fg2,j.bg2));G("what it runs",q(j.dim,j.bg2),1);for(let Y of g0(X.runs,Q).slice(0,3))G(Y,q(j.fg,j.bg2));for(let Y of(X.alternatives??[]).slice(0,2))G(`also ${Y}`,q(j.dim,j.bg2));if(G("environment",q(j.dim,j.bg2),1),X.env.length===0)G("nothing \u2014 it needs no key",q(j.fg2,j.bg2));for(let Y of X.env.slice(0,4))if(G(`${Y.name}${Y.secret?" \xB7 secret":""}${Y.required?"":" \xB7 optional"}`,q(Y.secret?j.warn:j.fg,j.bg2)),Y.description)for(let K of g0(Y.description,Q-2).slice(0,2))G(` ${K}`,q(j.muted,j.bg2));if((X.pending??[]).length){G("you supply",q(j.dim,j.bg2),1);for(let Y of X.pending.slice(0,3))G(Y,q(j.fg2,j.bg2))}if(G("where it lands",q(j.dim,j.bg2),1),G(X.installed?X.installed.path:"shown in the plan before anything is written",q(j.fg2,j.bg2)),X.installed)G(`${X.installed.scope} scope${X.installed.version?` \xB7 ${X.installed.version}`:""}${X.installed.trusted===!1?" \xB7 not approved here":""}`,q(j.muted,j.bg2))}function s5($,J){return Math.max(0,($?.docs?.lines.length??0)-Math.max(1,J))}function D6($,J){if(J<8)return[...$];let Z=[];for(let Q of $)if(Q.kind==="text"){if(Q.text.length<=J){Z.push(Q);continue}let V="";for(let j of Q.text.split(/\s+/).filter(Boolean)){let X=j.length>J?j.slice(0,J):j;if(!V){V=X;continue}if(V.length+1+X.length<=J)V+=` ${X}`;else Z.push({kind:"text",text:V}),V=X}if(V)Z.push({kind:"text",text:V})}else if(Q.kind==="code"&&Q.text.length>J)for(let V=0;V<Q.text.length;V+=J)Z.push({kind:"code",text:Q.text.slice(V,V+J)});else Z.push(Q);return Z}function H6($,J,Z,Q,V,j,X,U){let G=D6(X.docs?.lines??[],Q);if(G.length===0)return $.clip(J,Z,`documentation \xB7 ${X.title}`,q(j.fg,j.bg2,A.BOLD),Q),$.clip(J,Z+2,"reading\u2026",q(j.muted,j.bg2),Q),0;let Y=Math.max(1,V-4),K=Math.max(0,G.length-Y),z=Math.max(0,Math.min(U,K));$.clip(J,Z,`documentation \xB7 ${X.title}`,q(j.fg,j.bg2,A.BOLD),Q),$.clip(J,Z+1,X.docs?.source??"",q(j.dim,j.bg2),Q);for(let N=0;N<Y;N++){let M=G[z+N];if(!M)break;let O=Z+2+N;if(M.kind==="head")$.clip(J,O,M.text,q(j.accent,j.bg2,A.BOLD),Q);else if(M.kind==="code")$.clip(J,O,M.text,q(j.fg2,j.selBg),Q);else if(M.kind==="rule")$.hline(J,O,Math.min(Q,24),q(j.rule2,j.bg2),"\u254C");else if(M.kind==="text")$.clip(J,O,M.text,q(j.fg2,j.bg2),Q)}let D=z<K?`${z+Y}/${G.length}`:`${G.length}/${G.length}`,H=X.docs?.truncated?`${D} \xB7 the rest is at the source`:D;return $.clip(J,Z+V-1,H,q(j.dim,j.bg2),Q),K}function g0($,J){if(J<=0)return[];let Z=[],Q="";for(let V of $.split(/\s+/).filter(Boolean)){let j=V.length>J?V.slice(0,J):V;if(!Q){Q=j;continue}if(f(Q)+1+f(j)<=J)Q+=` ${j}`;else Z.push(Q),Q=j}if(Q)Z.push(Q);return Z}function H9($,J,Z,Q,V=q5,j){let X=Q.market;if(!X)return null;j?.push({rect:{x:0,y:0,w:J.w,h:J.h},onClick:()=>{if(!X.plan?.running)z9(Q)}});let U=Math.max(X.rows.length+6,20),G=Math.min(J.w-6,120),Y=Math.max(12,Math.min(J.h-4,30,U)),K=Math.floor((J.w-G)/2),z=Math.max(1,Math.floor((J.h-Y)/2));$.box(K,z,G,Y,q(Z.accent),Z.bg2),$.text(K+2,z,[[" market ",q(Z.accent,-1,A.BOLD)]]),$.put(K+G-14,z," esc closes ",q(Z.dim)),j?.push({rect:{x:K,y:z,w:G,h:Y},onClick:()=>{}});let D=G6(X),H=K+3;for(let C of y0){let d=`${C==="all"?"all":U9[C]} ${D[C]}`,u=X.tab===C;$.put(H,z+1,d,q(u?Z.accent:Z.muted,Z.bg2,u?A.BOLD:0)),j?.push({rect:{x:H,y:z+1,w:f(d),h:1},onClick:()=>{X.tab=C,X.sel=0}}),H+=f(d)+3}if($.put(K+3,z+2,"\u258C",q(Z.accent,Z.bg2)),X.query)$.put(K+5,z+2,X.query,q(Z.fg,Z.bg2,A.BOLD),G-12);else $.put(K+5,z+2,"type to search the market\u2026",q(Z.dim,Z.bg2),G-12);$.hline(K+1,z+3,G-2,q(Z.rule2,Z.bg2),"\u254C");let N=D9(X,V);X.sel=Math.max(0,Math.min(X.sel,Math.max(N.length-1,0)));let M=Math.max(24,Math.floor((G-5)*0.42)),O=K+3+M+2,_=K+G-2-O,E=Y-6,I=K6(X,N.length);if(I&&N.length===0){let C=I.tone==="err"?Z.err:I.tone==="warn"?Z.warn:Z.muted;for(let[d,u]of g0(I.text,G-8).slice(0,3).entries())$.clip(K+4,z+5+d,u,q(C,Z.bg2),G-8);if(X.status.kind==="error")$.clip(K+4,z+9,"the curated shelf still works offline \xB7 esc closes",q(Z.dim,Z.bg2),G-8);return G9($,J,Z,X,j),{x:K+5+f(X.query),y:z+2}}let T=z+4;if(I&&N.length>0)$.clip(K+3,T,I.text,q(I.tone==="err"?Z.err:Z.warn,Z.bg2),G-6),T+=1;let F=Math.max(1,z+Y-2-T),P=X.sel>=F?X.sel-F+1:0;for(let C=0;C<F;C++){let d=N[P+C];if(!d)break;let u=T+C,t=P+C===X.sel;if(t)$.tint(K+2,u,M+2,1,Z.selBg);let U0=Y6(d),C0=U0?f(U0.text)+1:0;if($.text(K+2,u,[[t?"\u25B8 ":" ",q(Z.accent,t?Z.selBg:Z.bg2)],[`${U9[d.kind]} `.padEnd(7),q(Z.dim,t?Z.selBg:Z.bg2)],[d.title,q(t?Z.fg:Z.fg2,t?Z.selBg:Z.bg2,t?A.BOLD:0)],[` ${d.publisher}`,q(Z.dim,t?Z.selBg:Z.bg2)]],M-C0),U0)$.put(K+3+M-C0,u,U0.text,q(U0.tone==="ok"?Z.ok:U0.tone==="warn"?Z.warn:Z.info,t?Z.selBg:Z.bg2));let L=P+C;if(!X.plan)j?.push({rect:{x:K+2,y:u,w:M+2,h:1},onClick:()=>{X.sel=L},key:K9})}$.vline(O-2,T,E,q(Z.rule2,Z.bg2),"\u2502");let W=N[X.sel],R=z+Y-2-T;if(W&&X.docs&&W.docs)X.docRows=Math.max(1,R-4),H6($,O,T,_,R,Z,W,X.docScroll);else if(W)z6($,O,T,_,R,Z,W);let b=W?.docs?X.docs?" \xB7 d closes the docs":" \xB7 \u2325d docs":"",x=W?X.docs?`\u2191\u2193 scroll${b} \xB7 esc closes`:W.installed&&!W.installed.updateAvailable?`\u23CE install again \xB7 \u2191\u2193 move \xB7 \u21E5 next kind${b} \xB7 esc closes`:`\u23CE install \xB7 \u2191\u2193 move \xB7 \u21E5 next kind${b} \xB7 esc closes`:"\u2191\u2193 move \xB7 \u21E5 next kind \xB7 esc closes";return $.clip(K+3,z+Y-1,x,q(Z.dim),G-6),G9($,J,Z,X,j),{x:K+5+f(X.query),y:z+2}}function Y9($,J){if(J.localOffer!==void 0)return $.choice={row:J,sel:0},{kind:"none"};return{kind:"plan",row:J}}function N9($,J,Z=q5){let Q=$.market;if(!Q)return{kind:"none"};let{name:V,ctrl:j,alt:X,ch:U}=J;if(Q.plan){let D=Q.plan;if(D.running)return{kind:"none"};if(V==="escape"||j&&V==="c")return Q.plan=null,{kind:"none"};if(V==="enter"){if(D.outcome)return Q.plan=null,{kind:"none"};return D.running=!0,{kind:"install",plan:D}}return{kind:"none"}}if(Q.choice){let D=Q.choice;if(V==="escape"||j&&V==="c")return Q.choice=null,{kind:"none"};if(V==="up"||V==="down")return D.sel=D.sel===0?1:0,{kind:"none"};if(V==="enter")return Q.choice=null,{kind:"plan",row:D.row,local:D.sel===0};return{kind:"none"}}if(V==="escape"||j&&V==="m"){if(Q.docs)return Q.docs=!1,Q.docScroll=0,{kind:"none"};return z9($),{kind:"none"}}let G=D9(Q,Z),Y=Math.max(1,G.length),K=G[Q.sel];if(U==="d"&&X&&!j){if(Q.docs)return Q.docs=!1,Q.docScroll=0,{kind:"none"};if(!K?.docs)return{kind:"none"};return Q.docs=!0,Q.docScroll=0,K.docs.lines.length===0?{kind:"docs",row:K}:{kind:"none"}}if(V==="tab"||V==="shift-tab"){let D=y0.indexOf(Q.tab),H=V==="tab"?1:y0.length-1;return Q.tab=y0[(D+H)%y0.length],Q.sel=0,Q.docs=!1,Q.docScroll=0,{kind:"none"}}if(Q.docs){if(U==="d"&&!j&&!X)return Q.docs=!1,Q.docScroll=0,{kind:"none"};if(V==="up")return Q.docScroll=Math.max(0,Q.docScroll-1),{kind:"none"};if(V==="down")return Q.docScroll=Math.min(Q.docScroll+1,s5(K,Q.docRows)),{kind:"none"};if(V==="pageup")return Q.docScroll=Math.max(0,Q.docScroll-12),{kind:"none"};if(V==="pagedown")return Q.docScroll=Math.min(Q.docScroll+12,s5(K,Q.docRows)),{kind:"none"};if(V==="home")return Q.docScroll=0,{kind:"none"};if(V==="end")return Q.docScroll=s5(K,Q.docRows),{kind:"none"};if(V==="enter")return K?Y9(Q,K):{kind:"none"};return{kind:"none"}}if(V==="up")return Q.sel=(Q.sel-1+Y)%Y,{kind:"none"};if(V==="down")return Q.sel=(Q.sel+1)%Y,{kind:"none"};if(V==="pageup")return Q.sel=Math.max(0,Q.sel-10),{kind:"none"};if(V==="pagedown")return Q.sel=Math.min(Y-1,Q.sel+10),{kind:"none"};if(V==="home")return Q.sel=0,{kind:"none"};if(V==="end")return Q.sel=Y-1,{kind:"none"};if(V==="enter"){let D=G[Q.sel];return D?Y9(Q,D):{kind:"none"}}if(V==="backspace")return Q.query=[...Q.query].slice(0,-1).join(""),Q.sel=0,{kind:"none"};let z=V==="space"?" ":U;if(z&&!j&&!X)Q.query+=z,Q.sel=0;return{kind:"none"}}var K9,y0,U6,U9;var z5=k(()=>{$0();D0();X0();p();K9={type:"key",name:"enter"},y0=["all","mcp","skill","plugin"],U6=[{label:"install once \u2014 node starts it in ~0.4 s",hint:"npm install runs now, AFTER the plan is approved: the package's code lands under ~/.rovecode/mcp (typically 20\u201330 MB, once); no network needed to start"},{label:"run through npx at every start \u2014 as today",hint:"~2 s per start, re-resolves the package and asks the npm registry each time; nothing is installed now"}];U9={mcp:"mcp",skill:"skill",plugin:"plugin"}});function O9($,J){L0($,null),$.wizard={step:0,providers:J,selected:0,idTyped:"",urlTyped:"",urlField:!1,secret:"",keyAccepted:!1,models:[],modelSel:0,modelChecked:[],modelDefaultTo:void 0,modelTyped:"",modelsLoading:!1}}function D5($){$.wizard=null}function M6($){let J=[...$].length;return N6.repeat(Math.min(J,t5))+(J>t5?` ${J-t5} more`:"")}function O6($,J){return $<J?"\u2713":$===J?"\u25CF":"\u25CB"}function F6($){let J=$.providers[$.selected],Z=[];if($.step===0)return Z.push({text:"Which provider? \u2191\u2193 choose, \u23CE confirm.",tone:"head"}),$.providers.forEach((Q,V)=>Z.push({text:`${V===$.selected?"\u276F ":" "}${Q.label}${Q.configured?" \xB7 already set up":""}`,tone:V===$.selected?"accent":"normal"})),Z;if(J===void 0)return Z;if($.step===1){let Q=!$.urlField;if(Z.push({text:`${J.label.split(" (")[0]??J.label} \u2014 name it and point it at the server.`,tone:"head"}),Z.push({text:`Short name? ${$.idTyped}${Q?"\u258C":""}`,tone:Q?"normal":"dim",...Q?{caret:!0}:{}}),Z.push({text:`Base URL? ${$.urlTyped}${$.urlField?"\u258C":""}`,tone:$.urlField?"normal":"dim",...$.urlField?{caret:!0}:{}}),Z.push({text:"\u21E5 switches the field \xB7 \u23CE registers it and moves to the key",tone:"dim"}),$.error!==void 0)Z.push({text:$.error,tone:"warn"});return Z}if($.step===2){if(Z.push({text:`Paste the API key for ${J.label.split(" \u2014 ")[0]??J.label}.`,tone:"head"}),Z.push({text:"It is stored in the credentials file, never in the transcript.",tone:"dim"}),Z.push({text:"",tone:"dim"}),Z.push({text:M6($.secret)||"",tone:"normal",caret:!0}),$.error!==void 0)Z.push({text:$.error,tone:"warn"});return Z}if($.step===3){if(Z.push({text:`Which models on ${J.label.split(" \u2014 ")[0]??J.label}? Space checks, \u23CE confirms.`,tone:"head"}),$.modelsLoading&&$.models.length===0)return Z.push({text:"Fetching the model list from the endpoint\u2026",tone:"accent"}),Z;if($.models.length>0)$.models.forEach((Q,V)=>{let j=$.modelChecked.includes(Q.id),X=`${Q.active===!0?" \xB7 active":""}${Q.defaultModel===!0?" \xB7 default":""}`,U=j&&$.modelDefaultTo===Q.id?"\u2022":"";Z.push({text:`${V===$.modelSel?"\u276F ":" "}${j?"\u2713":"\u2610"} ${Q.id}${X}${U?` ${U}`:""}`,tone:V===$.modelSel?"accent":"normal"})});else Z.push({text:"No model list from this endpoint \u2014 type the model id:",tone:"dim"}),Z.push({text:$.modelTyped,tone:"normal",caret:!0});if($.error!==void 0)Z.push({text:$.error,tone:"warn"});return Z}return Z}function F9($,J,Z,Q,V){let j=Q.wizard;if(!j)return null;V?.push({rect:{x:0,y:0,w:J.w,h:J.h},onClick:()=>{}});let X=F6(j),U=Math.min(J.w-4,64),G=Math.max(10,Math.min(J.h-4,Math.max(M9.length,X.length)+5)),Y=Math.floor((J.w-U)/2),K=Math.max(1,Math.floor((J.h-G)/2));$.box(Y,K,U,G,q(Z.accent),Z.bg2),$.text(Y+2,K,[[" connect a model ",q(Z.accent,-1,A.BOLD)]]),$.put(Y+U-13,K," esc closes ",q(Z.dim,Z.bg2)),V?.push({rect:{x:Y,y:K,w:U,h:G},onClick:()=>{}});let z=13;M9.forEach((O,_)=>{let E=_===j.step;$.put(Y+2,K+2+_,`${O6(_,j.step)} ${O}`,E?q(Z.accent,Z.bg2,A.BOLD):_<j.step?q(Z.fg2,Z.bg2):q(Z.muted,Z.bg2))});let D=Y+2+z+2,H=Math.max(10,U-(D-Y)-3),N=G-3;X.slice(0,N).forEach((O,_)=>{let E=O.tone==="head"?q(Z.fg,Z.bg2,A.BOLD):O.tone==="warn"?q(Z.warn,Z.bg2):O.tone==="ok"?q(Z.ok,Z.bg2):O.tone==="accent"?q(Z.accent,Z.bg2):O.tone==="dim"?q(Z.muted,Z.bg2):q(Z.fg2,Z.bg2),I=O.text===""&&O.caret?"":O.text;$.clip(D,K+1+_,O.caret&&O.text===""?`${I}\u258C`:I,E,H+1)});let M=j.step>0?" \u2190 back":"";return $.put(Y+2,K+G-1,`\u23CE ${j.step===0?"choose":"next"}${M} esc cancel`,q(Z.dim,Z.bg2)),null}function W9($,J){let Z=$.wizard;if(!Z)return!1;let Q=J.replace(/\s+/g," ");if(Z.step===1)if(Z.urlField)Z.urlTyped+=Q;else Z.idTyped+=Q;else if(Z.step===2)Z.secret+=Q;else if(Z.step===3&&Z.models.length===0)Z.modelTyped+=Q;else return!0;return Z.error=void 0,!0}function _9($,J){let Z=$.wizard;if(!Z)return{kind:"none"};let{name:Q,ctrl:V,ch:j,alt:X}=J;if(Q==="escape"||V&&Q==="c")return D5($),{kind:"none"};if(Z.step===1){if(Q==="tab"||Q==="shift-tab")return Z.urlField=!Z.urlField,{kind:"none"}}if(Z.step===0||Z.step===3&&Z.models.length>0){let Y=Z.step===0?Z.providers.length:Z.models.length;if(Q==="up"||Q==="k"){if(Z.step===0)Z.selected=(Z.selected-1+Y)%Y;else Z.modelSel=(Z.modelSel-1+Y)%Y;return{kind:"none"}}if(Q==="down"||Q==="j"){if(Z.step===0)Z.selected=(Z.selected+1)%Y;else Z.modelSel=(Z.modelSel+1)%Y;return{kind:"none"}}if(Q==="tab"&&Z.step===3)return Z.modelSel=(Z.modelSel+1)%Y,{kind:"none"};if((Q==="space"||j===" "&&!V&&!X)&&Z.step===3)return _6(Z),{kind:"none"}}if(Q==="left"&&Z.step>0)return Z.step-=1,Z.error=void 0,{kind:"none"};if(Q==="enter")return W6($);if(Z.step===1||Z.step===2||Z.step===3&&Z.models.length===0&&!Z.modelsLoading){if(Q==="backspace"){if(Z.step===1)if(Z.urlField)Z.urlTyped=[...Z.urlTyped].slice(0,-1).join("");else Z.idTyped=[...Z.idTyped].slice(0,-1).join("");else if(Z.step===2)Z.secret=[...Z.secret].slice(0,-1).join("");else Z.modelTyped=[...Z.modelTyped].slice(0,-1).join("");return Z.error=void 0,{kind:"none"}}let Y=Q==="space"?" ":j;if(!Y||X||V)return{kind:"none"};if(Z.step===1)if(Z.urlField)Z.urlTyped+=Y;else Z.idTyped+=Y;else if(Z.step===2)Z.secret+=Y;else Z.modelTyped+=Y;return Z.error=void 0,{kind:"none"}}return{kind:"none"}}function W6($){let J=$.wizard,Z=J.providers[J.selected];if(J.step===0){if(Z===void 0)return{kind:"none"};J.error=void 0;let Q=Z.url!==void 0?1:Z.local===!0||Z.configured===!0?3:2;return J.step=Q,Q===3?{kind:"loadModels"}:{kind:"none"}}if(J.step===1){if(Z===void 0||Z.url===void 0)return{kind:"none"};let Q=J.idTyped.trim().toLowerCase();if(Q.length===0)return J.error="the short name is empty \u2014 it becomes the registry row's id",{kind:"none"};if(!/^[a-z0-9][a-z0-9._-]*$/.test(Q))return J.error=`"${Q}" won't work as an id \u2014 letters, digits, - _ . (myproxy, vllm-home)`,{kind:"none"};if(!/^https?:\/\//.test(J.urlTyped.trim()))return J.error=`"${J.urlTyped.trim()}" is not an http(s) URL \u2014 the base URL the server answers on`,{kind:"none"};return J.error=void 0,{kind:"registerEndpoint",id:Q,url:J.urlTyped.trim(),protocol:Z.url}}if(J.step===2){let Q=J.secret.trim();if(Q.length===0)return J.error="the key is empty \u2014 paste it, or \u2190 back to change provider",{kind:"none"};if(Z===void 0)return{kind:"none"};return J.error=void 0,{kind:"storeKey",provider:Z.key,secret:Q}}if(J.step===3){if(Z===void 0)return{kind:"none"};if(J.models.length>0){let V=J.models.filter((X)=>J.modelChecked.includes(X.id)).map((X)=>X.id);if(V.length===0)return J.error="no model checked \u2014 space checks a row, or \u2190 back to the key",{kind:"none"};J.error=void 0;let j=J.modelDefaultTo!==void 0&&V.includes(J.modelDefaultTo)?J.modelDefaultTo:V[0];return{kind:"confirmModels",provider:Z.key,models:V,makeDefault:j}}let Q=J.modelTyped.trim();if(Q.length===0)return J.error="no model chosen \u2014 pick a row or type the id",{kind:"none"};return J.error=void 0,{kind:"confirmModel",model:Q}}return{kind:"none"}}function P9($,J,Z){if(J)$.step=2,$.error=void 0;else $.error=Z??"the endpoint could not be registered"}function A9($,J,Z){if(J)$.keyAccepted=!0,$.step=3,$.modelsLoading=!0,$.error=void 0;else $.keyAccepted=!1,$.error=Z??"the key could not be stored"}function e5($,J){$.models=J,$.modelsLoading=!1,$.modelSel=0,$.modelChecked=J.filter((Q)=>Q.active===!0).map((Q)=>Q.id);let Z=J.find((Q)=>Q.defaultModel===!0);$.modelDefaultTo=Z!==void 0&&$.modelChecked.includes(Z.id)?Z.id:$.modelChecked[0],$.step=3,$.error=void 0}function _6($){let J=$.models[$.modelSel];if(J===void 0)return;let Q=$.modelChecked.includes(J.id)?$.modelChecked.filter((V)=>V!==J.id):[...$.modelChecked,J.id];if($.modelChecked=Q,$.modelDefaultTo===void 0||!Q.includes($.modelDefaultTo))$.modelDefaultTo=Q[0];$.error=void 0}var M9,N6="\u2022",t5=24;var H5=k(()=>{$0();X0();p();M9=["PROVIDER","ENDPOINT","KEY","MODEL"]});async function M5(){try{let[$,J]=await Promise.all([import("./registry-fh0hdnyn.js"),import("./install-80mp63kx.js")]);if(typeof $.searchMarket!=="function"||typeof J.planInstall!=="function")return null;return{registry:$,install:J}}catch{return null}}function A6($){let J=$.install;if(!J)return"";if(J.kind==="mcp"){let Z=J.entry?.installs?.[0];if(!Z)return"";return Z.kind==="http"?`remote ${Z.url??""}`:[Z.command,...Z.args??[]].join(" ")}if(J.kind==="plugin")return`${J.git?"clone":"copy"} ${String(J.source??"")}`;if(J.kind==="skill"){if(J.files?.length)return`${J.files.length} file(s), written verbatim \u2014 runs nothing`;let Z=J.source;return Z?.git?`clone ${Z.git}${Z.subfolder?` (${Z.subfolder})`:""}`:"a SKILL.md the model reads when it matches"}return""}function E6($){let J=$.install;if(J?.kind!=="mcp")return[];return(J.entry?.installs??[]).slice(1).map((Z)=>Z.kind==="http"?`remote ${Z.url??""}`:`${Z.runtime??"stdio"}: ${[Z.command,...Z.args??[]].join(" ")}`)}function I6($){let J=$.install;if(J?.kind!=="mcp")return;let Z=J.entry?.installs?.[0];if(Z===void 0||typeof Z!=="object"||Z===null)return;return E9(Z)?.spec}function S6($){let J=I6($);return{...J!==void 0?{localOffer:J}:{},id:$.id,kind:$.kind,title:$.title,publisher:$.publisher,description:$.description,...$.version!==void 0?{version:$.version}:{},runs:A6($),env:$.env.map((Z)=>({name:Z.name,required:Z.required,secret:Z.secret,...Z.description!==void 0?{description:Z.description}:{}})),alternatives:E6($),pending:$.planNote??[],...$.installed?{installed:$.installed}:{},...$.docs?{docs:{source:$.docs.source,truncated:$.docs.truncated===!0,lines:typeof $.docs.body==="string"&&$.docs.body!==""?I9($.docs.body):[]}}:{}}}function I9($,J=96){let Z=$.replace(/\r\n?/g,`
|
|
7
|
+
`).map((J)=>J.trim()).find((J)=>J!=="")??"",K5=($)=>Math.max(0,Math.min($.code.lane,$.crew.length-1)),Q9=($)=>({x:$.x+2,y:$.y+1,w:$.w-4,h:$.h-2}),$6=($)=>$==="queued"?"dim":$==="running"?"accent":$==="done"?"ok":$==="failed"?"err":"muted",J6=($,J)=>q(J[$.tone],-1,$.bold?A.BOLD:0),Z6=($,J,Z,Q,V,j)=>{if(V.length)$.text(J,Z,V.map((X)=>[X.text,J6(X,j)]),Q)};var S0=k(()=>{p();$0();J0();t8=[70,120]});function q9($,J,Z={kind:"ready"},Q=[]){L0($,"market"),$.market={tab:"all",query:"",sel:0,rows:J,status:Z,notes:Q,plan:null,choice:null,docs:!1,docScroll:0,docRows:12}}function z9($){$.market=null}function D9($,J=q5){let Z=$.rows.filter((V)=>$.tab==="all"||V.kind===$.tab),Q=$.query.trim();if(!Q)return Z;return Z.map((V)=>({r:V,hit:J(Q,`${V.title} ${V.id} ${V.publisher} ${V.description}`)})).filter((V)=>V.hit!==null).sort((V,j)=>j.hit.score-V.hit.score).map((V)=>V.r)}function G6($){return{all:$.rows.length,mcp:$.rows.filter((J)=>J.kind==="mcp").length,skill:$.rows.filter((J)=>J.kind==="skill").length,plugin:$.rows.filter((J)=>J.kind==="plugin").length}}function Y6($){if(!$.installed)return null;if($.installed.updateAvailable)return{text:"update",tone:"warn"};if($.installed.scope==="project"&&$.installed.trusted===!1)return{text:"not approved",tone:"warn"};return{text:"installed",tone:"ok"}}function K6($,J){if($.status.kind==="loading")return{text:"reading the catalogs\u2026",tone:"muted"};if($.status.kind==="error")return{text:$.status.reason,tone:"err"};if($.status.kind==="offline")return{text:$.status.note,tone:"warn"};if(J===0)return $.query.trim()||$.tab!=="all"?{text:`nothing matches${$.query.trim()?` "${$.query.trim()}"`:""}${$.tab!=="all"?` in ${$.tab}`:""}`,tone:"muted"}:{text:"the catalog is empty",tone:"muted"};return null}function G9($,J,Z,Q,V){let j=Q.plan;if(!j){if(Q.choice)q6($,J,Z,Q,V);return}let X=Math.min(76,J.w-8),U=[...j.preview,...j.replaces?[`replaces ${j.replaces}`]:[],...j.asks.map((D)=>`asks ${D.name}${D.secret?" (secret, masked)":""}${D.required?"":" \u2014 optional"}`),...j.pending.map((D)=>`you supply ${D}`)],G=Math.min(J.h-4,U.length+7),Y=Math.floor((J.w-X)/2),K=Math.max(1,Math.floor((J.h-G)/2));$.box(Y,K,X,G,q(Z.accent),Z.bg2),$.text(Y+2,K,[[" install plan ",q(Z.accent,-1,A.BOLD)]]),$.clip(Y+3,K+1,j.title,q(Z.fg,Z.bg2,A.BOLD),X-6),$.clip(Y+3,K+2,`${j.scope} scope \xB7 ${j.target}`,q(Z.muted,Z.bg2),X-6),$.hline(Y+1,K+3,X-2,q(Z.rule2,Z.bg2),"\u254C"),U.slice(0,G-6).forEach((D,H)=>$.clip(Y+3,K+4+H,D,q(Z.fg2,Z.bg2),X-6));let z=K+G-2;if(j.outcome){$.clip(Y+3,z,j.outcome.text,q(j.outcome.ok?Z.ok:Z.err,Z.bg2),X-6),V?.push({rect:{x:Y,y:K,w:X,h:G},onClick:()=>{Q.plan=null}});return}if(j.running){$.put(Y+3,z,"installing\u2026",q(Z.muted,Z.bg2)),V?.push({rect:{x:Y,y:K,w:X,h:G},onClick:()=>{}});return}$.text(Y+3,z,[["\u23CE install",q(Z.accent,Z.bg2,A.BOLD)],[" esc cancel",q(Z.dim,Z.bg2)]],X-6),V?.push({rect:{x:Y,y:K,w:X,h:G},onClick:()=>{}}),V?.push({rect:{x:Y+3,y:z,w:9,h:1},onClick:()=>{},key:K9})}function q6($,J,Z,Q,V){let j=Q.choice;if(!j)return;let X=Math.min(84,J.w-8),U=X-6,G=[];U6.forEach((H,N)=>{G.push({text:`${N===j.sel?"\u25CF":"\u25CB"} ${H.label}`,sel:N===j.sel,head:!0});for(let M of g0(H.hint,U-4))G.push({text:` ${M}`,sel:!1,head:!1})});let Y=Math.min(J.h-4,G.length+6),K=Math.floor((J.w-X)/2),z=Math.max(1,Math.floor((J.h-Y)/2));$.box(K,z,X,Y,q(Z.accent),Z.bg2),$.text(K+2,z,[[" how to start it ",q(Z.accent,-1,A.BOLD)]]),$.clip(K+3,z+1,`${j.row.title} \xB7 ${j.row.localOffer??j.row.runs}`,q(Z.fg,Z.bg2,A.BOLD),U),$.hline(K+1,z+2,X-2,q(Z.rule2,Z.bg2),"\u254C");let D=-1;G.slice(0,Y-5).forEach((H,N)=>{let M=z+3+N;if($.clip(K+3,M,H.text,H.head?q(H.sel?Z.accent:Z.fg,Z.bg2,H.sel?A.BOLD:0):q(Z.muted,Z.bg2),U),H.head){D+=1;let O=D;V?.push({rect:{x:K+3,y:M,w:U,h:1},onClick:()=>{j.sel=O}})}}),$.text(K+3,z+Y-2,[["\u2191\u2193 choose \u23CE show the plan",q(Z.accent,Z.bg2,A.BOLD)],[" esc back",q(Z.dim,Z.bg2)]],U),V?.push({rect:{x:K,y:z,w:X,h:Y},onClick:()=>{}})}function z6($,J,Z,Q,V,j,X){let U=Z,G=(Y,K,z=0)=>{if(U>=Z+V)return;if(U+=z,U>=Z+V)return;$.clip(J,U,Y,K,Q),U+=1};$.text(J,U,[[X.title,q(j.fg,j.bg2,A.BOLD)],[X.version?` ${X.version}`:"",q(j.dim,j.bg2)]],Q),U+=1,G(X.publisher,q(j.muted,j.bg2));for(let Y of g0(X.description,Q).slice(0,4))G(Y,q(j.fg2,j.bg2));G("what it runs",q(j.dim,j.bg2),1);for(let Y of g0(X.runs,Q).slice(0,3))G(Y,q(j.fg,j.bg2));for(let Y of(X.alternatives??[]).slice(0,2))G(`also ${Y}`,q(j.dim,j.bg2));if(G("environment",q(j.dim,j.bg2),1),X.env.length===0)G("nothing \u2014 it needs no key",q(j.fg2,j.bg2));for(let Y of X.env.slice(0,4))if(G(`${Y.name}${Y.secret?" \xB7 secret":""}${Y.required?"":" \xB7 optional"}`,q(Y.secret?j.warn:j.fg,j.bg2)),Y.description)for(let K of g0(Y.description,Q-2).slice(0,2))G(` ${K}`,q(j.muted,j.bg2));if((X.pending??[]).length){G("you supply",q(j.dim,j.bg2),1);for(let Y of X.pending.slice(0,3))G(Y,q(j.fg2,j.bg2))}if(G("where it lands",q(j.dim,j.bg2),1),G(X.installed?X.installed.path:"shown in the plan before anything is written",q(j.fg2,j.bg2)),X.installed)G(`${X.installed.scope} scope${X.installed.version?` \xB7 ${X.installed.version}`:""}${X.installed.trusted===!1?" \xB7 not approved here":""}`,q(j.muted,j.bg2))}function s5($,J){return Math.max(0,($?.docs?.lines.length??0)-Math.max(1,J))}function D6($,J){if(J<8)return[...$];let Z=[];for(let Q of $)if(Q.kind==="text"){if(Q.text.length<=J){Z.push(Q);continue}let V="";for(let j of Q.text.split(/\s+/).filter(Boolean)){let X=j.length>J?j.slice(0,J):j;if(!V){V=X;continue}if(V.length+1+X.length<=J)V+=` ${X}`;else Z.push({kind:"text",text:V}),V=X}if(V)Z.push({kind:"text",text:V})}else if(Q.kind==="code"&&Q.text.length>J)for(let V=0;V<Q.text.length;V+=J)Z.push({kind:"code",text:Q.text.slice(V,V+J)});else Z.push(Q);return Z}function H6($,J,Z,Q,V,j,X,U){let G=D6(X.docs?.lines??[],Q);if(G.length===0)return $.clip(J,Z,`documentation \xB7 ${X.title}`,q(j.fg,j.bg2,A.BOLD),Q),$.clip(J,Z+2,"reading\u2026",q(j.muted,j.bg2),Q),0;let Y=Math.max(1,V-4),K=Math.max(0,G.length-Y),z=Math.max(0,Math.min(U,K));$.clip(J,Z,`documentation \xB7 ${X.title}`,q(j.fg,j.bg2,A.BOLD),Q),$.clip(J,Z+1,X.docs?.source??"",q(j.dim,j.bg2),Q);for(let N=0;N<Y;N++){let M=G[z+N];if(!M)break;let O=Z+2+N;if(M.kind==="head")$.clip(J,O,M.text,q(j.accent,j.bg2,A.BOLD),Q);else if(M.kind==="code")$.clip(J,O,M.text,q(j.fg2,j.selBg),Q);else if(M.kind==="rule")$.hline(J,O,Math.min(Q,24),q(j.rule2,j.bg2),"\u254C");else if(M.kind==="text")$.clip(J,O,M.text,q(j.fg2,j.bg2),Q)}let D=z<K?`${z+Y}/${G.length}`:`${G.length}/${G.length}`,H=X.docs?.truncated?`${D} \xB7 the rest is at the source`:D;return $.clip(J,Z+V-1,H,q(j.dim,j.bg2),Q),K}function g0($,J){if(J<=0)return[];let Z=[],Q="";for(let V of $.split(/\s+/).filter(Boolean)){let j=V.length>J?V.slice(0,J):V;if(!Q){Q=j;continue}if(f(Q)+1+f(j)<=J)Q+=` ${j}`;else Z.push(Q),Q=j}if(Q)Z.push(Q);return Z}function H9($,J,Z,Q,V=q5,j){let X=Q.market;if(!X)return null;j?.push({rect:{x:0,y:0,w:J.w,h:J.h},onClick:()=>{if(!X.plan?.running)z9(Q)}});let U=Math.max(X.rows.length+6,20),G=Math.min(J.w-6,120),Y=Math.max(12,Math.min(J.h-4,30,U)),K=Math.floor((J.w-G)/2),z=Math.max(1,Math.floor((J.h-Y)/2));$.box(K,z,G,Y,q(Z.accent),Z.bg2),$.text(K+2,z,[[" market ",q(Z.accent,-1,A.BOLD)]]),$.put(K+G-14,z," esc closes ",q(Z.dim)),j?.push({rect:{x:K,y:z,w:G,h:Y},onClick:()=>{}});let D=G6(X),H=K+3;for(let C of y0){let d=`${C==="all"?"all":U9[C]} ${D[C]}`,u=X.tab===C;$.put(H,z+1,d,q(u?Z.accent:Z.muted,Z.bg2,u?A.BOLD:0)),j?.push({rect:{x:H,y:z+1,w:f(d),h:1},onClick:()=>{X.tab=C,X.sel=0}}),H+=f(d)+3}if($.put(K+3,z+2,"\u258C",q(Z.accent,Z.bg2)),X.query)$.put(K+5,z+2,X.query,q(Z.fg,Z.bg2,A.BOLD),G-12);else $.put(K+5,z+2,"type to search the market\u2026",q(Z.dim,Z.bg2),G-12);$.hline(K+1,z+3,G-2,q(Z.rule2,Z.bg2),"\u254C");let N=D9(X,V);X.sel=Math.max(0,Math.min(X.sel,Math.max(N.length-1,0)));let M=Math.max(24,Math.floor((G-5)*0.42)),O=K+3+M+2,_=K+G-2-O,E=Y-6,I=K6(X,N.length);if(I&&N.length===0){let C=I.tone==="err"?Z.err:I.tone==="warn"?Z.warn:Z.muted;for(let[d,u]of g0(I.text,G-8).slice(0,3).entries())$.clip(K+4,z+5+d,u,q(C,Z.bg2),G-8);if(X.status.kind==="error")$.clip(K+4,z+9,"the curated shelf still works offline \xB7 esc closes",q(Z.dim,Z.bg2),G-8);return G9($,J,Z,X,j),{x:K+5+f(X.query),y:z+2}}let T=z+4;if(I&&N.length>0)$.clip(K+3,T,I.text,q(I.tone==="err"?Z.err:Z.warn,Z.bg2),G-6),T+=1;let F=Math.max(1,z+Y-2-T),P=X.sel>=F?X.sel-F+1:0;for(let C=0;C<F;C++){let d=N[P+C];if(!d)break;let u=T+C,t=P+C===X.sel;if(t)$.tint(K+2,u,M+2,1,Z.selBg);let U0=Y6(d),C0=U0?f(U0.text)+1:0;if($.text(K+2,u,[[t?"\u25B8 ":" ",q(Z.accent,t?Z.selBg:Z.bg2)],[`${U9[d.kind]} `.padEnd(7),q(Z.dim,t?Z.selBg:Z.bg2)],[d.title,q(t?Z.fg:Z.fg2,t?Z.selBg:Z.bg2,t?A.BOLD:0)],[` ${d.publisher}`,q(Z.dim,t?Z.selBg:Z.bg2)]],M-C0),U0)$.put(K+3+M-C0,u,U0.text,q(U0.tone==="ok"?Z.ok:U0.tone==="warn"?Z.warn:Z.info,t?Z.selBg:Z.bg2));let L=P+C;if(!X.plan)j?.push({rect:{x:K+2,y:u,w:M+2,h:1},onClick:()=>{X.sel=L},key:K9})}$.vline(O-2,T,E,q(Z.rule2,Z.bg2),"\u2502");let W=N[X.sel],R=z+Y-2-T;if(W&&X.docs&&W.docs)X.docRows=Math.max(1,R-4),H6($,O,T,_,R,Z,W,X.docScroll);else if(W)z6($,O,T,_,R,Z,W);let b=W?.docs?X.docs?" \xB7 d closes the docs":" \xB7 \u2325d docs":"",x=W?X.docs?`\u2191\u2193 scroll${b} \xB7 esc closes`:W.installed&&!W.installed.updateAvailable?`\u23CE install again \xB7 \u2191\u2193 move \xB7 \u21E5 next kind${b} \xB7 esc closes`:`\u23CE install \xB7 \u2191\u2193 move \xB7 \u21E5 next kind${b} \xB7 esc closes`:"\u2191\u2193 move \xB7 \u21E5 next kind \xB7 esc closes";return $.clip(K+3,z+Y-1,x,q(Z.dim),G-6),G9($,J,Z,X,j),{x:K+5+f(X.query),y:z+2}}function Y9($,J){if(J.localOffer!==void 0)return $.choice={row:J,sel:0},{kind:"none"};return{kind:"plan",row:J}}function N9($,J,Z=q5){let Q=$.market;if(!Q)return{kind:"none"};let{name:V,ctrl:j,alt:X,ch:U}=J;if(Q.plan){let D=Q.plan;if(D.running)return{kind:"none"};if(V==="escape"||j&&V==="c")return Q.plan=null,{kind:"none"};if(V==="enter"){if(D.outcome)return Q.plan=null,{kind:"none"};return D.running=!0,{kind:"install",plan:D}}return{kind:"none"}}if(Q.choice){let D=Q.choice;if(V==="escape"||j&&V==="c")return Q.choice=null,{kind:"none"};if(V==="up"||V==="down")return D.sel=D.sel===0?1:0,{kind:"none"};if(V==="enter")return Q.choice=null,{kind:"plan",row:D.row,local:D.sel===0};return{kind:"none"}}if(V==="escape"||j&&V==="m"){if(Q.docs)return Q.docs=!1,Q.docScroll=0,{kind:"none"};return z9($),{kind:"none"}}let G=D9(Q,Z),Y=Math.max(1,G.length),K=G[Q.sel];if(U==="d"&&X&&!j){if(Q.docs)return Q.docs=!1,Q.docScroll=0,{kind:"none"};if(!K?.docs)return{kind:"none"};return Q.docs=!0,Q.docScroll=0,K.docs.lines.length===0?{kind:"docs",row:K}:{kind:"none"}}if(V==="tab"||V==="shift-tab"){let D=y0.indexOf(Q.tab),H=V==="tab"?1:y0.length-1;return Q.tab=y0[(D+H)%y0.length],Q.sel=0,Q.docs=!1,Q.docScroll=0,{kind:"none"}}if(Q.docs){if(U==="d"&&!j&&!X)return Q.docs=!1,Q.docScroll=0,{kind:"none"};if(V==="up")return Q.docScroll=Math.max(0,Q.docScroll-1),{kind:"none"};if(V==="down")return Q.docScroll=Math.min(Q.docScroll+1,s5(K,Q.docRows)),{kind:"none"};if(V==="pageup")return Q.docScroll=Math.max(0,Q.docScroll-12),{kind:"none"};if(V==="pagedown")return Q.docScroll=Math.min(Q.docScroll+12,s5(K,Q.docRows)),{kind:"none"};if(V==="home")return Q.docScroll=0,{kind:"none"};if(V==="end")return Q.docScroll=s5(K,Q.docRows),{kind:"none"};if(V==="enter")return K?Y9(Q,K):{kind:"none"};return{kind:"none"}}if(V==="up")return Q.sel=(Q.sel-1+Y)%Y,{kind:"none"};if(V==="down")return Q.sel=(Q.sel+1)%Y,{kind:"none"};if(V==="pageup")return Q.sel=Math.max(0,Q.sel-10),{kind:"none"};if(V==="pagedown")return Q.sel=Math.min(Y-1,Q.sel+10),{kind:"none"};if(V==="home")return Q.sel=0,{kind:"none"};if(V==="end")return Q.sel=Y-1,{kind:"none"};if(V==="enter"){let D=G[Q.sel];return D?Y9(Q,D):{kind:"none"}}if(V==="backspace")return Q.query=[...Q.query].slice(0,-1).join(""),Q.sel=0,{kind:"none"};let z=V==="space"?" ":U;if(z&&!j&&!X)Q.query+=z,Q.sel=0;return{kind:"none"}}var K9,y0,U6,U9;var z5=k(()=>{$0();D0();X0();p();K9={type:"key",name:"enter"},y0=["all","mcp","skill","plugin"],U6=[{label:"install once \u2014 node starts it in ~0.4 s",hint:"npm install runs now, AFTER the plan is approved: the package's code lands under ~/.rovecode/mcp (typically 20\u201330 MB, once); no network needed to start"},{label:"run through npx at every start \u2014 as today",hint:"~2 s per start, re-resolves the package and asks the npm registry each time; nothing is installed now"}];U9={mcp:"mcp",skill:"skill",plugin:"plugin"}});function O9($,J){L0($,null),$.wizard={step:0,providers:J,selected:0,idTyped:"",urlTyped:"",urlField:!1,secret:"",keyAccepted:!1,models:[],modelSel:0,modelChecked:[],modelDefaultTo:void 0,modelTyped:"",modelsLoading:!1}}function D5($){$.wizard=null}function M6($){let J=[...$].length;return N6.repeat(Math.min(J,t5))+(J>t5?` ${J-t5} more`:"")}function O6($,J){return $<J?"\u2713":$===J?"\u25CF":"\u25CB"}function F6($){let J=$.providers[$.selected],Z=[];if($.step===0)return Z.push({text:"Which provider? \u2191\u2193 choose, \u23CE confirm.",tone:"head"}),$.providers.forEach((Q,V)=>Z.push({text:`${V===$.selected?"\u276F ":" "}${Q.label}${Q.configured?" \xB7 already set up":""}`,tone:V===$.selected?"accent":"normal"})),Z;if(J===void 0)return Z;if($.step===1){let Q=!$.urlField;if(Z.push({text:`${J.label.split(" (")[0]??J.label} \u2014 name it and point it at the server.`,tone:"head"}),Z.push({text:`Short name? ${$.idTyped}${Q?"\u258C":""}`,tone:Q?"normal":"dim",...Q?{caret:!0}:{}}),Z.push({text:`Base URL? ${$.urlTyped}${$.urlField?"\u258C":""}`,tone:$.urlField?"normal":"dim",...$.urlField?{caret:!0}:{}}),Z.push({text:"\u21E5 switches the field \xB7 \u23CE registers it and moves to the key",tone:"dim"}),$.error!==void 0)Z.push({text:$.error,tone:"warn"});return Z}if($.step===2){if(Z.push({text:`Paste the API key for ${J.label.split(" \u2014 ")[0]??J.label}.`,tone:"head"}),Z.push({text:"It is stored in the credentials file, never in the transcript.",tone:"dim"}),Z.push({text:"",tone:"dim"}),Z.push({text:M6($.secret)||"",tone:"normal",caret:!0}),$.error!==void 0)Z.push({text:$.error,tone:"warn"});return Z}if($.step===3){if(Z.push({text:`Which models on ${J.label.split(" \u2014 ")[0]??J.label}? Space checks, \u23CE confirms.`,tone:"head"}),$.modelsLoading&&$.models.length===0)return Z.push({text:"Fetching the model list from the endpoint\u2026",tone:"accent"}),Z;if($.models.length>0)$.models.forEach((Q,V)=>{let j=$.modelChecked.includes(Q.id),X=`${Q.active===!0?" \xB7 active":""}${Q.defaultModel===!0?" \xB7 default":""}`,U=j&&$.modelDefaultTo===Q.id?"\u2022":"";Z.push({text:`${V===$.modelSel?"\u276F ":" "}${j?"\u2713":"\u2610"} ${Q.id}${X}${U?` ${U}`:""}`,tone:V===$.modelSel?"accent":"normal"})});else Z.push({text:"No model list from this endpoint \u2014 type the model id:",tone:"dim"}),Z.push({text:$.modelTyped,tone:"normal",caret:!0});if($.error!==void 0)Z.push({text:$.error,tone:"warn"});return Z}return Z}function F9($,J,Z,Q,V){let j=Q.wizard;if(!j)return null;V?.push({rect:{x:0,y:0,w:J.w,h:J.h},onClick:()=>{}});let X=F6(j),U=Math.min(J.w-4,64),G=Math.max(10,Math.min(J.h-4,Math.max(M9.length,X.length)+5)),Y=Math.floor((J.w-U)/2),K=Math.max(1,Math.floor((J.h-G)/2));$.box(Y,K,U,G,q(Z.accent),Z.bg2),$.text(Y+2,K,[[" connect a model ",q(Z.accent,-1,A.BOLD)]]),$.put(Y+U-13,K," esc closes ",q(Z.dim,Z.bg2)),V?.push({rect:{x:Y,y:K,w:U,h:G},onClick:()=>{}});let z=13;M9.forEach((O,_)=>{let E=_===j.step;$.put(Y+2,K+2+_,`${O6(_,j.step)} ${O}`,E?q(Z.accent,Z.bg2,A.BOLD):_<j.step?q(Z.fg2,Z.bg2):q(Z.muted,Z.bg2))});let D=Y+2+z+2,H=Math.max(10,U-(D-Y)-3),N=G-3;X.slice(0,N).forEach((O,_)=>{let E=O.tone==="head"?q(Z.fg,Z.bg2,A.BOLD):O.tone==="warn"?q(Z.warn,Z.bg2):O.tone==="ok"?q(Z.ok,Z.bg2):O.tone==="accent"?q(Z.accent,Z.bg2):O.tone==="dim"?q(Z.muted,Z.bg2):q(Z.fg2,Z.bg2),I=O.text===""&&O.caret?"":O.text;$.clip(D,K+1+_,O.caret&&O.text===""?`${I}\u258C`:I,E,H+1)});let M=j.step>0?" \u2190 back":"";return $.put(Y+2,K+G-1,`\u23CE ${j.step===0?"choose":"next"}${M} esc cancel`,q(Z.dim,Z.bg2)),null}function W9($,J){let Z=$.wizard;if(!Z)return!1;let Q=J.replace(/\s+/g," ");if(Z.step===1)if(Z.urlField)Z.urlTyped+=Q;else Z.idTyped+=Q;else if(Z.step===2)Z.secret+=Q;else if(Z.step===3&&Z.models.length===0)Z.modelTyped+=Q;else return!0;return Z.error=void 0,!0}function _9($,J){let Z=$.wizard;if(!Z)return{kind:"none"};let{name:Q,ctrl:V,ch:j,alt:X}=J;if(Q==="escape"||V&&Q==="c")return D5($),{kind:"none"};if(Z.step===1){if(Q==="tab"||Q==="shift-tab")return Z.urlField=!Z.urlField,{kind:"none"}}if(Z.step===0||Z.step===3&&Z.models.length>0){let Y=Z.step===0?Z.providers.length:Z.models.length;if(Q==="up"||Q==="k"){if(Z.step===0)Z.selected=(Z.selected-1+Y)%Y;else Z.modelSel=(Z.modelSel-1+Y)%Y;return{kind:"none"}}if(Q==="down"||Q==="j"){if(Z.step===0)Z.selected=(Z.selected+1)%Y;else Z.modelSel=(Z.modelSel+1)%Y;return{kind:"none"}}if(Q==="tab"&&Z.step===3)return Z.modelSel=(Z.modelSel+1)%Y,{kind:"none"};if((Q==="space"||j===" "&&!V&&!X)&&Z.step===3)return _6(Z),{kind:"none"}}if(Q==="left"&&Z.step>0)return Z.step-=1,Z.error=void 0,{kind:"none"};if(Q==="enter")return W6($);if(Z.step===1||Z.step===2||Z.step===3&&Z.models.length===0&&!Z.modelsLoading){if(Q==="backspace"){if(Z.step===1)if(Z.urlField)Z.urlTyped=[...Z.urlTyped].slice(0,-1).join("");else Z.idTyped=[...Z.idTyped].slice(0,-1).join("");else if(Z.step===2)Z.secret=[...Z.secret].slice(0,-1).join("");else Z.modelTyped=[...Z.modelTyped].slice(0,-1).join("");return Z.error=void 0,{kind:"none"}}let Y=Q==="space"?" ":j;if(!Y||X||V)return{kind:"none"};if(Z.step===1)if(Z.urlField)Z.urlTyped+=Y;else Z.idTyped+=Y;else if(Z.step===2)Z.secret+=Y;else Z.modelTyped+=Y;return Z.error=void 0,{kind:"none"}}return{kind:"none"}}function W6($){let J=$.wizard,Z=J.providers[J.selected];if(J.step===0){if(Z===void 0)return{kind:"none"};J.error=void 0;let Q=Z.url!==void 0?1:Z.local===!0||Z.configured===!0?3:2;return J.step=Q,Q===3?{kind:"loadModels"}:{kind:"none"}}if(J.step===1){if(Z===void 0||Z.url===void 0)return{kind:"none"};let Q=J.idTyped.trim().toLowerCase();if(Q.length===0)return J.error="the short name is empty \u2014 it becomes the registry row's id",{kind:"none"};if(!/^[a-z0-9][a-z0-9._-]*$/.test(Q))return J.error=`"${Q}" won't work as an id \u2014 letters, digits, - _ . (myproxy, vllm-home)`,{kind:"none"};if(!/^https?:\/\//.test(J.urlTyped.trim()))return J.error=`"${J.urlTyped.trim()}" is not an http(s) URL \u2014 the base URL the server answers on`,{kind:"none"};return J.error=void 0,{kind:"registerEndpoint",id:Q,url:J.urlTyped.trim(),protocol:Z.url}}if(J.step===2){let Q=J.secret.trim();if(Q.length===0)return J.error="the key is empty \u2014 paste it, or \u2190 back to change provider",{kind:"none"};if(Z===void 0)return{kind:"none"};return J.error=void 0,{kind:"storeKey",provider:Z.key,secret:Q}}if(J.step===3){if(Z===void 0)return{kind:"none"};if(J.models.length>0){let V=J.models.filter((X)=>J.modelChecked.includes(X.id)).map((X)=>X.id);if(V.length===0)return J.error="no model checked \u2014 space checks a row, or \u2190 back to the key",{kind:"none"};J.error=void 0;let j=J.modelDefaultTo!==void 0&&V.includes(J.modelDefaultTo)?J.modelDefaultTo:V[0];return{kind:"confirmModels",provider:Z.key,models:V,makeDefault:j}}let Q=J.modelTyped.trim();if(Q.length===0)return J.error="no model chosen \u2014 pick a row or type the id",{kind:"none"};return J.error=void 0,{kind:"confirmModel",model:Q}}return{kind:"none"}}function P9($,J,Z){if(J)$.step=2,$.error=void 0;else $.error=Z??"the endpoint could not be registered"}function A9($,J,Z){if(J)$.keyAccepted=!0,$.step=3,$.modelsLoading=!0,$.error=void 0;else $.keyAccepted=!1,$.error=Z??"the key could not be stored"}function e5($,J){$.models=J,$.modelsLoading=!1,$.modelSel=0,$.modelChecked=J.filter((Q)=>Q.active===!0).map((Q)=>Q.id);let Z=J.find((Q)=>Q.defaultModel===!0);$.modelDefaultTo=Z!==void 0&&$.modelChecked.includes(Z.id)?Z.id:$.modelChecked[0],$.step=3,$.error=void 0}function _6($){let J=$.models[$.modelSel];if(J===void 0)return;let Q=$.modelChecked.includes(J.id)?$.modelChecked.filter((V)=>V!==J.id):[...$.modelChecked,J.id];if($.modelChecked=Q,$.modelDefaultTo===void 0||!Q.includes($.modelDefaultTo))$.modelDefaultTo=Q[0];$.error=void 0}var M9,N6="\u2022",t5=24;var H5=k(()=>{$0();X0();p();M9=["PROVIDER","ENDPOINT","KEY","MODEL"]});async function M5(){try{let[$,J]=await Promise.all([import("./registry-t6p8d4mn.js"),import("./install-avaqjjqq.js")]);if(typeof $.searchMarket!=="function"||typeof J.planInstall!=="function")return null;return{registry:$,install:J}}catch{return null}}function A6($){let J=$.install;if(!J)return"";if(J.kind==="mcp"){let Z=J.entry?.installs?.[0];if(!Z)return"";return Z.kind==="http"?`remote ${Z.url??""}`:[Z.command,...Z.args??[]].join(" ")}if(J.kind==="plugin")return`${J.git?"clone":"copy"} ${String(J.source??"")}`;if(J.kind==="skill"){if(J.files?.length)return`${J.files.length} file(s), written verbatim \u2014 runs nothing`;let Z=J.source;return Z?.git?`clone ${Z.git}${Z.subfolder?` (${Z.subfolder})`:""}`:"a SKILL.md the model reads when it matches"}return""}function E6($){let J=$.install;if(J?.kind!=="mcp")return[];return(J.entry?.installs??[]).slice(1).map((Z)=>Z.kind==="http"?`remote ${Z.url??""}`:`${Z.runtime??"stdio"}: ${[Z.command,...Z.args??[]].join(" ")}`)}function I6($){let J=$.install;if(J?.kind!=="mcp")return;let Z=J.entry?.installs?.[0];if(Z===void 0||typeof Z!=="object"||Z===null)return;return E9(Z)?.spec}function S6($){let J=I6($);return{...J!==void 0?{localOffer:J}:{},id:$.id,kind:$.kind,title:$.title,publisher:$.publisher,description:$.description,...$.version!==void 0?{version:$.version}:{},runs:A6($),env:$.env.map((Z)=>({name:Z.name,required:Z.required,secret:Z.secret,...Z.description!==void 0?{description:Z.description}:{}})),alternatives:E6($),pending:$.planNote??[],...$.installed?{installed:$.installed}:{},...$.docs?{docs:{source:$.docs.source,truncated:$.docs.truncated===!0,lines:typeof $.docs.body==="string"&&$.docs.body!==""?I9($.docs.body):[]}}:{}}}function I9($,J=96){let Z=$.replace(/\r\n?/g,`
|
|
8
8
|
`).replace(/<(script|style|iframe|object|embed|template|noscript)\b[\s\S]*?<\/\1\s*>/gi,"").replace(/<\/?[a-zA-Z][^>]*>/g,"").replace(L6,"").replace(/\t/g," ").replace(/^---\n[\s\S]*?\n---\n/,""),Q=[],V=!1;for(let j of Z.split(`
|
|
9
|
-
`)){if(/^\s*```/.test(j)){V=!V,Q.push({kind:"rule",text:""});continue}if(V){Q.push({kind:"code",text:j.slice(0,J)});continue}let X=/^(#{1,6})\s+(.*)$/.exec(j);if(X){Q.push({kind:"head",text:X[2].replace(/[`*]/g,"").slice(0,J)});continue}let U=j.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[`*]/g,"");if(U.trim()===""){Q.push({kind:"blank",text:""});continue}let G="";for(let Y of U.split(/\s+/).filter(Boolean)){let K=Y.length>J?Y.slice(0,J):Y;if(!G){G=K;continue}if(G.length+1+K.length<=J)G+=` ${K}`;else Q.push({kind:"text",text:G}),G=K}if(G)Q.push({kind:"text",text:G})}return Q}function T6($){let J=Object.entries($).filter(([,V])=>!V.ok);if(J.length){let[V,j]=J[0];return{kind:"error",reason:J.length===1?`${V}: ${j.reason}`:`${V}: ${j.reason} (+${J.length-1} more)`}}let Z=Object.values($).find((V)=>V.ok&&V.from==="cache");if(Z){let V=Math.round(Z.ageMs/60000);return{kind:"offline",note:`showing cached results${V>0?`, ${V}m old`:""}`}}let Q=Object.values($).find((V)=>V.ok&&V.from==="skipped");if(Q)return{kind:"offline",note:Q.why};return{kind:"ready"}}async function S9($,J,Z={}){let Q=await M5();if(!Q)return{rows:[],status:{kind:"error",reason:$8},notes:[]};let V=await Q.registry.searchMarket("",Z.offline===!0?{offline:!0}:{}),j=V.items;try{j=Q.install.withInstalled(V.items,$,J)}catch{}return{rows:j.map(S6),status:T6(V.sources),notes:V.notes}}async function L9($){let J=await M5();if(!J||typeof J.registry.findItem!=="function")return null;let{item:Z}=await J.registry.findItem($.kind,$.id,{offline:!0}),Q=Z?.docs;if(!Q||typeof Q.body!=="string"||Q.body.trim()==="")return null;return{source:Q.source,truncated:Q.truncated===!0,lines:I9(Q.body)}}async function T9($,J,Z){let Q=await M5();if(!Q)return{error:$8};let j=(await Q.registry.searchMarket($.id,{offline:!0})).items.find((U)=>U.kind===$.kind&&U.id===$.id);if(!j)return{error:`${$.kind}:${$.id} is not in the catalog any more`};let X=Q.install.planInstall(j,{...J,...Z===!0?{local:!0}:{}});if("error"in X)return{error:X.error};return{row:$,title:`${X.item.kind}:${X.item.id} \u2014 ${X.item.title}`,target:X.target,scope:X.scope,preview:X.preview,asks:X.asks.map((U)=>({name:U.name,required:U.required,secret:U.secret})),pending:X.pending,...X.replaces!==void 0?{replaces:X.replaces}:{},...Z===!0?{local:!0}:{}}}async function R9($,J,Z={}){let Q=await M5();if(!Q)return{ok:!1,text:$8};let j=(await Q.registry.searchMarket($.id,{offline:!0})).items.find((K)=>K.kind===$.kind&&K.id===$.id);if(!j)return{ok:!1,text:`${$.kind}:${$.id} is not in the catalog any more`};let X={...J,...Z.local===!0?{local:!0}:{}},U=Q.install.planInstall(j,X);if("error"in U)return{ok:!1,text:U.error};if(U.asks.length>0)return{ok:!1,text:`${U.asks.map((z)=>z.name).join(", ")} must be typed where it can be masked \u2014 run: rovecode market install ${j.kind}:${j.id}`};let G=await Q.install.runInstall(U,{},X,Z.deps);if(!G.ok)return{ok:!1,text:G.error};let Y=[`installed into ${G.target}`];if(G.package){if(Y.push(`${G.package.name} ${G.package.version} installed once \u2192 ${G.package.prefix}${G.package.integrity!==void 0?" (integrity recorded)":""}`),G.package.missing?.length)Y.push(`record incomplete: ${G.package.missing.join("; ")}`)}if(G.envNames.length)Y.push(`export ${G.envNames.join(", ")}`);for(let K of U.pending)Y.push(`fill in ${K}`);if(G.next)Y.push(G.next);return{ok:!0,text:Y.join(" \xB7 ")}}var $8="the market module is not available in this build (src/market/ is still landing)",L6;var k9=k(()=>{P6();L6=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g});function B9($,J){L0($,"context"),$.context={...J,scroll:0}}function b9($){$.context=null}function R6($,J){let Z=Math.max(1,J),Q=Math.max(0,Math.min(Z,Math.round((Number.isFinite($)?Math.max(0,$):0)*Z)));return"\u2588".repeat(Q)+"\xB7".repeat(Z-Q)}function k6($,J,Z){if(Z<=0||$<=0)return"";let Q=J>0?$/J:0;return"\u258F".repeat(Math.max(1,Math.min(Z,Math.round(Q*Z))))}function B6($,J){let Z=[],Q=Math.max(24,J);if(Z.push({text:$.model,tone:"head"}),$.window!==void 0){let G=$.fraction??0;Z.push({text:`${R6(G,Math.max(8,Math.min(28,Q-30)))} ~${o($.estimated)} of ${o($.window)} (${T0(G)})`,tone:$.nearLimit?"warn":"normal"}),Z.push({text:`${o($.remaining??0)} left${$.nearLimit?" \u2014 near the limit, compaction is due":""}`,tone:$.nearLimit?"warn":"dim"})}else Z.push({text:`~${o($.estimated)} tokens \u2014 this model's window is not in the catalog`,tone:"dim"});if($.scale.factor!==1)Z.push({text:`o200k counted ${o($.raw)}, scaled ${$.scale.factor}\xD7 for this model \u2014 ${$.scale.note}`,tone:"dim"});else Z.push({text:`o200k counted ${o($.raw)} \u2014 ${$.scale.note}`,tone:"dim"});if(!$.live)Z.push({text:"system prompt and tool schemas are not counted \u2014 this total is a floor",tone:"warn"});else Z.push({text:"MCP tools are not counted \u2014 their schemas exist only once a server is connected",tone:"dim"});Z.push({text:"",tone:"dim"});let V=[...$.slices].sort((G,Y)=>Y.tokens-G.tokens),j=Math.max(10,...V.map((G)=>G.label.length)),X=V[0]?.share??0;for(let G of V){let Y=`${G.label.padEnd(j)} ${o(G.tokens).padStart(9)} ${T0(G.share).padStart(6)}`,K=Q-f(Y)-(G.note?G.note.length+4:1);Z.push({text:`${Y} ${k6(G.share,X,Math.min(12,K))}${G.note?` \u2014 ${G.note}`:""}`,tone:G.note?"dim":"normal"})}if(V.length===0)Z.push({text:"nothing in the window yet",tone:"dim"});if($.images>0)Z.push({text:`${"images".padEnd(j)} ${String($.images).padStart(9)} \u2014 not estimated; image tokens are provider-specific`,tone:"dim"});if(Z.push({text:"",tone:"dim"}),$.drift){let G=$.drift;Z.push({text:`drift provider counted ${o(G.reported)} for the last turn's prompt, we estimated ${o(G.estimated)}`,tone:G.beyondTolerance?"warn":"normal"}),Z.push({text:` ${o(Math.abs(G.delta))} ${G.delta>0?"more":"less"} than we estimate (${T0(G.fraction)})${G.beyondTolerance?` \u2014 beyond the ${T0($.tolerance)} tolerance; the meter reads ${G.delta>0?"LOW":"HIGH"} here`:""}`,tone:G.beyondTolerance?"warn":"dim"})}else Z.push({text:"drift no turn reported usage yet \u2014 nothing to compare the estimate against",tone:"dim"});Z.push({text:"",tone:"dim"});let U=$.billed;return Z.push({text:`billed ${o(U.input)} in \xB7 ${o(U.output)} out \xB7 ${o(U.cacheRead)} cache read \xB7 ${o(U.cacheWrite)} cache written`,tone:"normal"}),Z.push({text:$.costUsd!==void 0?`cost $${$.costUsd.toFixed(4)}${$.unpricedTurns>0?` \u2014 lower bound, ${$.unpricedTurns} turn${$.unpricedTurns>1?"s":""} unpriced`:""}`:`cost unknown \u2014 no pricing for ${$.model}`,tone:$.costUsd===void 0?"dim":"normal"}),Z}function C9($,J){if(!$)return;if(!$.beyondTolerance)return{text:`est \xB1${T0($.fraction)} of provider`,warn:!1};return{text:`est reads ${$.delta>0?"LOW":"HIGH"} ${T0($.fraction)}`,warn:!0}}function v9($,J,Z,Q,V){let j=Q.context;if(!j)return null;V?.push({rect:{x:0,y:0,w:J.w,h:J.h},onClick:()=>b9(Q)});let X=Math.min(J.w-6,92),U=X-6,G=B6(j,U),Y=Math.max(10,Math.min(J.h-4,G.length+4)),K=Math.floor((J.w-X)/2),z=Math.max(1,Math.floor((J.h-Y)/2));$.box(K,z,X,Y,q(Z.accent),Z.bg2),$.text(K+2,z,[[" context ",q(Z.accent,-1,A.BOLD)]]),$.put(K+X-14,z," esc closes ",q(Z.dim)),V?.push({rect:{x:K,y:z,w:X,h:Y},onClick:()=>{}});let D=Y-3,H=Math.max(0,Math.min(Math.max(0,G.length-D),j.scroll));if(j.scroll=H,G.slice(H,H+D).forEach((N,M)=>{let O=N.tone==="head"?q(Z.fg,Z.bg2,A.BOLD):N.tone==="warn"?q(Z.warn,Z.bg2):N.tone==="dim"?q(Z.muted,Z.bg2):q(Z.fg2,Z.bg2);$.clip(K+3,z+1+M,N.text,O,U)}),G.length>D)$.put(K+X-22,z+Y-1,` ${H+D} of ${G.length} lines `,q(Z.dim,Z.bg2));return null}function f9($,J,Z){let Q=$.context;if(!Q)return;let{name:V,ctrl:j}=J;if(V==="escape"||V==="enter"||j&&V==="g"){b9($);return}let X=Math.max(1,Z-1);if(V==="up"||V==="k")Q.scroll-=1;else if(V==="down"||V==="j")Q.scroll+=1;else if(V==="pageup")Q.scroll-=X;else if(V==="pagedown"||V==="space")Q.scroll+=X;else if(V==="home")Q.scroll=0;else if(V==="end")Q.scroll=Number.MAX_SAFE_INTEGER;Q.scroll=Math.max(0,Q.scroll)}var o=($)=>$.toLocaleString("en-US"),T0=($)=>`${($*100).toFixed(1)}%`;var u0=k(()=>{$0();D0();X0();p()});function y9($,J){if(!$)return{};try{let Z=$.registry.list().map((X)=>X.schema),V=$.buildDef({...J,effort:"auto"}).systemPrompt,j=typeof V==="string"?V:typeof V==="function"?String(V({})):void 0;if(j===void 0)return{};return{system:j,toolSchemas:JSON.stringify(Z)}}catch{return{}}}async function g9($){let J=$.tolerance??b6,Z=`${$.current.provider}/${$.current.model}`,Q;try{Q=($.report??(await import("./context-report-hbw9zfes.js")).contextReport)({messages:$.messages,current:$.current,lookup:$.lookup,...$.fixed.system!==void 0?{system:$.fixed.system}:{},...$.fixed.toolSchemas!==void 0?{toolSchemas:$.fixed.toolSchemas}:{}})}catch{return{model:Z,raw:0,estimated:0,scale:{factor:1,measured:!1,note:"the context report could not be built"},slices:[],images:0,billed:{input:0,output:0,cacheRead:0,cacheWrite:0},unpricedTurns:0,live:!1,tolerance:J}}let V=Q.totals;return{model:Z,...Q.window!==void 0?{window:Q.window}:{},raw:Q.estimated,estimated:Q.corrected,scale:Q.scale,...Q.remaining!==void 0?{remaining:Q.remaining}:{},...Q.fraction!==void 0?{fraction:Q.fraction}:{},...Q.nearLimit!==void 0?{nearLimit:Q.nearLimit}:{},slices:Q.slices.map((j)=>({label:j.label,tokens:j.tokens,share:j.share,...j.note?{note:j.note}:{}})),images:Q.images,...Q.drift?{drift:{...Q.drift}}:{},billed:{input:V.inputTokens??0,output:V.outputTokens??0,cacheRead:V.cacheReadTokens??0,cacheWrite:V.cacheWriteTokens??0},...Q.costUsd!==void 0?{costUsd:Q.costUsd}:{},unpricedTurns:Q.unpricedTurns,live:$.fixed.system!==void 0,tolerance:J}}var b6=0.05;var u9=()=>{};function x0($,J,Z,Q,V,j){if(!(Q>V&&Z>=2))return{x:$,trackY:J,trackH:Z,thumbY:J,thumbH:0,visible:!1};let U=Math.max(1,Math.round(Z*V/Q)),G=Math.max(1,Q-V),Y=Math.max(0,Z-U),K=J+Math.round(Y*Math.max(0,j)/G),z=Math.min(K,J+Z-U);return{x:$,trackY:J,trackH:Z,thumbY:z,thumbH:U,visible:!0}}function C6($,J,Z){if(!J.visible)return;let Q=q(Z.rule),V=q(Z.dim);for(let j=0;j<J.trackH;j++){let X=J.trackY+j,U=X>=J.thumbY&&X<J.thumbY+J.thumbH;$.put(J.x,X,U?"\u258C":"\u2502",U?V:Q)}}function R0($,J,Z,Q,V,j,X,U){let G=x0(Z,Q,V,j,X,U);return C6($,G,J),G}function x9($){return{x:$.x,y:$.thumbY,w:1,h:$.thumbH}}var p0=k(()=>{Q0()});function l9($){w9=$}function m9($){if(/\.(?:[cm]?[jt]sx?)$/.test($))return"ts";if($.endsWith(".json"))return"json";if($.endsWith(".md"))return"md";return"text"}function y6($,J,Z=-1){switch($){case"kw":return q(J.fg,Z,A.BOLD);case"str":case"num":case"dec":return q(J.str,Z);case"cm":return q(J.muted,Z,A.ITALIC);case"ty":return q(J.ty,Z);case"fn":return q(J.fg,Z);default:return q(J.fg2,Z)}}function F5($,J,Z,Q,V,j,X,U,G,Y){if(X<=0)return J;if(Y!==void 0)return $.put(J,Z,Q,q(Y,j),X);let K=J,z=J+X;for(let[D,H]of G(Q,V)){if(K>=z)break;let N=typeof H==="string"?y6(H,U,j):H?{...H,bg:H.bg>=0?H.bg:j}:q(U.fg2,j);K=$.put(K,Z,D,N,z-K)}return K}function u6($,J,Z){let Q=$.code;if(Q.mode==="run"){if(!Q.run)return{title:"run",extra:[]};return{title:"run",extra:[Q.run.status==="running"?[N0(Z),q(J.accent)]:Q.run.status==="ok"?["exit 0",q(J.muted)]:["failed",q(J.err)]]}}if(Q.mode==="search"){if(!Q.search)return{title:"search",extra:[]};return{title:"search",extra:[[Q.search.query,q(J.str)],[` ${Q.search.lines.length} results`,q(J.muted)]]}}if(Q.mode==="agents"){let U=$.crew.filter((z)=>z.status==="queued"||z.status==="running").length,G=$.crew.filter((z)=>z.status==="done").length,Y=$.crew.filter((z)=>z.status==="failed").length;if(!$.crew.length)return{title:"agents",extra:[["crew",q(J.muted)]]};let K=[[`${U} running`,q(U?J.accent:J.muted)],[` ${G} done`,q(J.muted)]];if(Y)K.push([` ${Y} failed`,q(J.err)]);return{title:"agents",extra:K}}let V=g6($),j=Q.mode==="diff"?"diff":"code";if(!V)return{title:j,extra:[]};let X=[[V,q(J.fg2)]];if(Q.diff&&Q.diff.file===V){if(Q.diff.add||Q.diff.del)X.push([" ",q(-1)],[Q.diff.add?`+${Q.diff.add}`:"",q(J.ok)],[Q.diff.del?`${Q.diff.add?" ":""}\u2212${Q.diff.del}`:"",q(J.err)]);if(Q.diff.base==="head")X.push([" vs HEAD",q(J.muted)])}if(Z8($)&&Q.mode==="code")X.push([` ${$.activity.state.toLowerCase()}`,q(J.accent)]);return{title:j,extra:X}}function x6($){let J=new Map;for(let Z of $){let Q=Z.newStart,V=0;while(V<Z.rows.length){if(Z.rows[V].op===" "){Q++,V++;continue}let j=[],X=!1;while(V<Z.rows.length&&Z.rows[V].op!==" "){if(Z.rows[V].op==="-")X=!0;else j.push(Q++);V++}for(let U of j)J.set(U,X?"changed":"added")}}return J}function W5($,J){let Z=$.code;if(Z.mode==="code")return Z.content===null?0:V5(Z.content).length;if(Z.mode==="diff")return Z.diff?c9(Z.diff.hunks,J>110).length:0;if(Z.mode==="search")return Z.search?Z.search.lines.length:0;return 0}function d0($,J){let Z=a($),Q=Z.h,V=Z.w-V0-2,j=W5(J,V),X=Math.max(0,j-Q);if(J.code.mode==="code"&&J.code.hl&&Z8(J))return Math.min(X,Math.max(0,J.code.hl[0]-1-Math.floor(Q/2)));return Math.max(0,Math.min(J.code.scroll,X))}function p6($,J,Z,Q,V,j){$.box(J.x,J.y,J.w,J.h,q(Q.frameDim)),v6.forEach(([z,D],H)=>{if(J.y+1+H>=J.y+J.h-1)return;let N=Z.code.mode===z||z==="code"&&Z.code.mode==="search";$.put(J.x+1,J.y+1+H,D,q(N?Q.accent:Q.dim,-1,N?A.BOLD:0))});let X=J.y+6,U=J.h-7;if(U<3||Z.code.mode!=="code"&&Z.code.mode!=="diff"||Z.code.content===null||!Z.code.file)return;let G=Math.max(1,V5(Z.code.content).length),Y=a9(Z),K=Math.min(U,G);for(let z=0;z<K;z++){let D=Math.floor(z/K*G),H=Math.max(D+1,Math.floor((z+1)/K*G)),N=Q.rule;for(let _=D;_<H;_++){let E=Y.get(_+1);if(E==="added")N=Q.ok;else if(E==="changed"&&N!==Q.ok)N=Q.warn}let M=H>V&&D<V+j,O=N!==Q.rule;$.put(J.x+1,X+z,M?"\u258C":"\u258F",q(O?N:M?Q.rule2:Q.rule))}}function d6($,J,Z,Q,V,j){let X=Z.code.file;if(!X){$.put(J.x,J.y,G0.code,q(Q.muted),J.w);return}if(Z.code.content===null){$.clip(J.x,J.y,`cannot read ${X}`,q(Q.muted),J.w);return}let U=V5(Z.code.content);if(!U.length){$.put(J.x,J.y,"(empty)",q(Q.dim),J.w);return}let G=m9(X),Y=a9(Z),K=Z.code.hl,z=Z8(Z)?`\u25C2 ${Z.activity.state.toLowerCase()}`:null,D=Math.max(3,String(U.length).length);for(let H=0;H<J.h;H++){let N=V+H,M=U[N];if(M===void 0)break;let O=J.y+H,_=K!==null&&N+1>=K[0]&&N+1<=K[1],E=Y.get(N+1),I=_?Q.hlBg:-1;if(_)$.tint(J.x,O,J.w,1,I);if($.put(J.x,O,String(N+1).padStart(D),q(_?Q.accent:Q.dim,I)),$.put(J.x+D+1,O,E?"\u258E":" ",q(E==="changed"?Q.warn:Q.ok,I)),F5($,J.x+D+3,O,M,G,I,J.w-D-3,Q,j),z&&_&&K!==null&&N+1===K[0]&&J.w>24)$.put(J.x+J.w-z.length,O,z,q(Q.accent,I))}}function p9($,J,Z,Q,V){return $.put(J,Z,Q?" PASS ":" FAIL ",q(V.bg,Q?V.ok:V.err,A.BOLD))}function w6($,J,Z){if(Z<=0)return[];let Q=c5("$ "+$,J);return Q.length>Z?[...Q.slice(0,Z-1),O5(Q.length-Z+1)]:Q}function l6($,J,Z,Q,V){let j=Z.code.run;if(!j){$.put(J.x,J.y,"nothing has run yet",q(Q.muted),J.w);return}let X=w6(j.cmd,J.w,J.h>=4?Math.min(h6,J.h-2):0);X.forEach((z,D)=>$.put(J.x,J.y+D,z,z.startsWith("\u2026")?q(Q.dim):q(Q.fg,-1,A.BOLD),J.w));let U=[];for(let z of j.lines)for(let[D,H]of c5(z,J.w).entries())U.push({kind:"out",text:H,first:D===0});U.push({kind:"tail",text:"",first:!0});let G=J.h-X.length,Y=Math.max(0,U.length-G),K=J.y+J.h-Math.min(U.length,G);for(let z=0;Y+z<U.length;z++){let D=U[Y+z],H=K+z;if(D.kind==="tail"){if(j.status==="running")$.text(J.x,H,[[N0(V),q(Q.accent)],[" running",q(Q.muted)]],J.w);else{let M=p9($,J.x,H,j.status==="ok",Q);$.put(M,H,j.status==="ok"?" exit 0":" non-zero exit",q(Q.muted),J.x+J.w-M)}continue}let N=D.first?/^\s*(PASS|FAIL)\b\s?(.*)$/.exec(D.text):null;if(N){let M=p9($,J.x,H,N[1]==="PASS",Q);$.put(M+1,H,N[2]??"",q(Q.fg),J.x+J.w-M-1);continue}$.put(J.x,H,D.text,q(Q.fg2),J.w)}}function m6($,J,Z,Q,V,j){let X=Z.code.search;if(!X){$.put(J.x,J.y,"no search yet",q(Q.muted),J.w);return}let U=Math.min(26,Math.floor(J.w*0.4)),G=J.y;for(let K=V;K<X.lines.length&&G<J.y+J.h;K++,G++){let z=X.lines[K],D=/^(\S+?:\d+(?::\d+)?):\s?(.*)$/.exec(z);if(D)$.clip(J.x,G,D[1],q(Q.muted),U),F5($,J.x+U+1,G,(D[2]??"").trimStart(),"ts",-1,J.w-U-1,Q,j);else $.text(J.x,G,[["\xB7 ",q(Q.dim)],[z,q(Q.fg2)]],J.w)}let Y=X.lines.length?`${X.lines.length} result${X.lines.length===1?"":"s"}`:"no results";if(G<J.y+J.h)$.put(J.x,Math.min(G+(G>J.y?1:0),J.y+J.h-1),Y,q(Q.muted),J.w)}function c9($,J){let Z=[];for(let Q of $){let{oldStart:V,newStart:j}=Q,X=Q.rows.map((K)=>({op:K.op,text:K.text,an:K.op==="+"?null:V++,bn:K.op==="-"?null:j++})),U=X.filter((K)=>K.op!=="+").length,G=X.filter((K)=>K.op!=="-").length;if(Z.push({t:"hunk",text:`@@ -${Q.oldStart},${U} +${Q.newStart},${G} @@`}),!J){for(let K of X)Z.push({t:"line",...K});continue}let Y=0;while(Y<X.length){if(X[Y].op===" "){Z.push({t:"pair",l:X[Y],r:X[Y]}),Y++;continue}let K=[],z=[];while(Y<X.length&&X[Y].op==="-")K.push(X[Y++]);while(Y<X.length&&X[Y].op==="+")z.push(X[Y++]);for(let D=0;D<Math.max(K.length,z.length);D++)Z.push({t:"pair",l:K[D]??null,r:z[D]??null})}}return Z}function d9($,J,Z,Q,V,j,X,U,G){if(!V||Q<8)return;let Y=V.op!==" ",K=!Y?-1:j==="add"?U.addBg:U.delBg;if(K>=0)$.tint(J,Z,Q,1,K);$.put(J,Z,String((j==="del"?V.an:V.bn)??"").padStart(4),q(U.dim,K)),$.put(J+5,Z,Y?j==="add"?"+":"\u2212":" ",q(j==="add"?U.ok:U.err,K)),F5($,J+7,Z,V.text,X,K,Q-7,U,G,j==="del"&&Y?U.muted:void 0)}function a6($,J,Z,Q,V,j,X,U){if(V.t==="hunk"){$.put(J,Z,V.text,q(X.dim),Q);return}if(V.t==="pair"){let z=Math.floor((Q-1)/2);d9($,J,Z,z,V.l,"del",j,X,U),d9($,J+z+1,Z,Q-z-1,V.r,"add",j,X,U);return}let G=V.op==="+",Y=V.op==="-",K=G?X.addBg:Y?X.delBg:-1;if(K>=0)$.tint(J,Z,Q,1,K);$.put(J,Z,String(V.an??"").padStart(4)+" "+String(V.bn??"").padStart(4),q(X.dim,K),Q),$.put(J+10,Z,G?"+":Y?"\u2212":" ",q(G?X.ok:X.err,K),Math.max(0,Q-10)),F5($,J+12,Z,V.text,j,K,Q-12,X,U,Y?X.muted:void 0)}function c6($,J,Z,Q,V,j){let X=Z.code.diff;if(!X||!X.hunks.length){$.put(J.x,J.y,"no changes in this file",q(Q.muted),J.w);return}let U=c9(X.hunks,J.w>110),G=m9(X.file);for(let Y=0;Y<J.h;Y++){let K=U[V+Y];if(!K)break;a6($,J.x,J.y+Y,J.w,K,G,Q,j)}}function i9($){let J=[],Z=null;for(let Q of $.split(/\r?\n/)){let V=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(Q);if(V){Z={rows:[],oldStart:Number(V[1]),newStart:Number(V[2])},J.push(Z);continue}if(!Z)continue;let j=Q[0];if(j==="+"||j==="-"||j===" ")Z.rows.push({op:j,text:Q.slice(1)})}return J}function i6($,J,Z,Q,V){let j=Z.crew.length;$.put(J.x,J.y,`crew: ${j} task${j===1?"":"s"}`,q(j?Q.fg2:Q.muted),J.w),Z.crew.forEach((X,U)=>{let G=J.y+2+U;if(G>=J.y+J.h)return;let Y=X.status==="running"?N0(V):X.status==="queued"?"\u25C7":X.status==="done"?"\u25C6":X.status==="failed"?"\xD7":"\u2212",K=X.status==="running"?Q.accent:X.status==="done"?Q.ok:X.status==="failed"?Q.err:Q.dim,z=X.status.length;$.text(J.x,G,[[Y+" ",q(K)],[X.label,q(Q.fg2)]],Math.max(0,J.w-z-2)),$.put(J.x+J.w-z,G,X.status,q(X.status==="failed"?Q.err:X.status==="done"?Q.ok:Q.muted))})}function n9($,J,Z,Q,V,j={}){if(J.w<4||J.h<3)return;let{title:X,extra:U}=u6(Z,Q,V),G=e($,J,X,Z.focus==="code",U,Q),Y={x:G.x+G.w-V0,y:G.y,w:V0,h:G.h},K={x:G.x,y:G.y,w:G.w-V0-2,h:G.h},z=d0(J,Z);if(K.w>=6&&K.h>=1){let D=j.tokenize??f6;switch(Z.code.mode){case"run":l6($,K,Z,Q,V);break;case"search":m6($,K,Z,Q,z,D);break;case"agents":(w9??i6)($,K,Z,Q,V);break;case"diff":c6($,K,Z,Q,z,D);break;default:d6($,K,Z,Q,z,D)}}if(G.w>=V0+2&&K.h>=2&&(Z.code.mode==="code"||Z.code.mode==="diff"||Z.code.mode==="search")){let D=W5(Z,K.w);R0($,Q,G.x+G.w-V0-1,G.y,K.h,D,K.h,z)}if(Y.h>=2&&G.w>=V0)p6($,Y,Z,Q,z,K.h)}var V0=3,v6,f6=($)=>[[$,"plain"]],w9=null,Z8=($)=>$.running&&($.activity.state==="READING"||$.activity.state==="EDITING"),g6=($)=>$.code.mode==="diff"&&$.code.diff?$.code.diff.file:$.code.file,a9=($)=>$.code.diff&&$.code.diff.file===$.code.file?x6($.code.diff.hunks):new Map,h6=3;var _5=k(()=>{p();$0();J8();h9();p0();v6=[["code","\u25A4"],["diff","\xB1"],["run","$"],["agents","\u2237"]]});import{diffLines as n6}from"diff";function s9($,J){if(J==="md")return r6($);if(J==="text")return[[$,"plain"]];let Z=[],Q=0,V;o9.lastIndex=0;while(V=o9.exec($)){if(V.index>Q)Z.push([$.slice(Q,V.index),"plain"]);let j=V[0],X;if(V[1])X="cm";else if(V[2])X=J==="json"&&/^\s*:/.test($.slice(V.index+j.length))?"key":"str";else if(V[3])X="num";else if(V[4]){let U=$[V.index-1],G=$.slice(V.index+j.length);if(j[0]==="@")X="dec";else if(o6.has(j))X="kw";else if(U===".")X="prop";else if(/^\s*\(/.test(G)||/^</.test(G)&&/^[a-z]/.test(j))X="fn";else if(/^[A-Z]/.test(j))X="ty";else if(/^\??:/.test(G))X="prop";else X="id"}else if(V[5]||V[6])X="pu";else X="op";Z.push([j,X]),Q=V.index+j.length}if(Q<$.length)Z.push([$.slice(Q),"plain"]);return Z}function r6($){if(/^#{1,6}\s/.test($))return[[$,"kw"]];if(/^\s{4}/.test($))return[[$,"str"]];let J=[],Z=0,Q,V=/`[^`]+`/g;while(Q=V.exec($)){if(Q.index>Z)J.push([$.slice(Z,Q.index),"plain"]);J.push([Q[0],"str"]),Z=Q.index+Q[0].length}if(Z<$.length)J.push([$.slice(Z),"plain"]);return J}function s6($){let J=[],Z=0,Q=0;for(let V of $){let j=V.value.split(`
|
|
9
|
+
`)){if(/^\s*```/.test(j)){V=!V,Q.push({kind:"rule",text:""});continue}if(V){Q.push({kind:"code",text:j.slice(0,J)});continue}let X=/^(#{1,6})\s+(.*)$/.exec(j);if(X){Q.push({kind:"head",text:X[2].replace(/[`*]/g,"").slice(0,J)});continue}let U=j.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[`*]/g,"");if(U.trim()===""){Q.push({kind:"blank",text:""});continue}let G="";for(let Y of U.split(/\s+/).filter(Boolean)){let K=Y.length>J?Y.slice(0,J):Y;if(!G){G=K;continue}if(G.length+1+K.length<=J)G+=` ${K}`;else Q.push({kind:"text",text:G}),G=K}if(G)Q.push({kind:"text",text:G})}return Q}function T6($){let J=Object.entries($).filter(([,V])=>!V.ok);if(J.length){let[V,j]=J[0];return{kind:"error",reason:J.length===1?`${V}: ${j.reason}`:`${V}: ${j.reason} (+${J.length-1} more)`}}let Z=Object.values($).find((V)=>V.ok&&V.from==="cache");if(Z){let V=Math.round(Z.ageMs/60000);return{kind:"offline",note:`showing cached results${V>0?`, ${V}m old`:""}`}}let Q=Object.values($).find((V)=>V.ok&&V.from==="skipped");if(Q)return{kind:"offline",note:Q.why};return{kind:"ready"}}async function S9($,J,Z={}){let Q=await M5();if(!Q)return{rows:[],status:{kind:"error",reason:$8},notes:[]};let V=await Q.registry.searchMarket("",Z.offline===!0?{offline:!0}:{}),j=V.items;try{j=Q.install.withInstalled(V.items,$,J)}catch{}return{rows:j.map(S6),status:T6(V.sources),notes:V.notes}}async function L9($){let J=await M5();if(!J||typeof J.registry.findItem!=="function")return null;let{item:Z}=await J.registry.findItem($.kind,$.id,{offline:!0}),Q=Z?.docs;if(!Q||typeof Q.body!=="string"||Q.body.trim()==="")return null;return{source:Q.source,truncated:Q.truncated===!0,lines:I9(Q.body)}}async function T9($,J,Z){let Q=await M5();if(!Q)return{error:$8};let j=(await Q.registry.searchMarket($.id,{offline:!0})).items.find((U)=>U.kind===$.kind&&U.id===$.id);if(!j)return{error:`${$.kind}:${$.id} is not in the catalog any more`};let X=Q.install.planInstall(j,{...J,...Z===!0?{local:!0}:{}});if("error"in X)return{error:X.error};return{row:$,title:`${X.item.kind}:${X.item.id} \u2014 ${X.item.title}`,target:X.target,scope:X.scope,preview:X.preview,asks:X.asks.map((U)=>({name:U.name,required:U.required,secret:U.secret})),pending:X.pending,...X.replaces!==void 0?{replaces:X.replaces}:{},...Z===!0?{local:!0}:{}}}async function R9($,J,Z={}){let Q=await M5();if(!Q)return{ok:!1,text:$8};let j=(await Q.registry.searchMarket($.id,{offline:!0})).items.find((K)=>K.kind===$.kind&&K.id===$.id);if(!j)return{ok:!1,text:`${$.kind}:${$.id} is not in the catalog any more`};let X={...J,...Z.local===!0?{local:!0}:{}},U=Q.install.planInstall(j,X);if("error"in U)return{ok:!1,text:U.error};if(U.asks.length>0)return{ok:!1,text:`${U.asks.map((z)=>z.name).join(", ")} must be typed where it can be masked \u2014 run: rovecode market install ${j.kind}:${j.id}`};let G=await Q.install.runInstall(U,{},X,Z.deps);if(!G.ok)return{ok:!1,text:G.error};let Y=[`installed into ${G.target}`];if(G.package){if(Y.push(`${G.package.name} ${G.package.version} installed once \u2192 ${G.package.prefix}${G.package.integrity!==void 0?" (integrity recorded)":""}`),G.package.missing?.length)Y.push(`record incomplete: ${G.package.missing.join("; ")}`)}if(G.envNames.length)Y.push(`export ${G.envNames.join(", ")}`);for(let K of U.pending)Y.push(`fill in ${K}`);if(G.next)Y.push(G.next);return{ok:!0,text:Y.join(" \xB7 ")}}var $8="the market module is not available in this build (src/market/ is still landing)",L6;var k9=k(()=>{P6();L6=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g});function B9($,J){L0($,"context"),$.context={...J,scroll:0}}function b9($){$.context=null}function R6($,J){let Z=Math.max(1,J),Q=Math.max(0,Math.min(Z,Math.round((Number.isFinite($)?Math.max(0,$):0)*Z)));return"\u2588".repeat(Q)+"\xB7".repeat(Z-Q)}function k6($,J,Z){if(Z<=0||$<=0)return"";let Q=J>0?$/J:0;return"\u258F".repeat(Math.max(1,Math.min(Z,Math.round(Q*Z))))}function B6($,J){let Z=[],Q=Math.max(24,J);if(Z.push({text:$.model,tone:"head"}),$.window!==void 0){let G=$.fraction??0;Z.push({text:`${R6(G,Math.max(8,Math.min(28,Q-30)))} ~${o($.estimated)} of ${o($.window)} (${T0(G)})`,tone:$.nearLimit?"warn":"normal"}),Z.push({text:`${o($.remaining??0)} left${$.nearLimit?" \u2014 near the limit, compaction is due":""}`,tone:$.nearLimit?"warn":"dim"})}else Z.push({text:`~${o($.estimated)} tokens \u2014 this model's window is not in the catalog`,tone:"dim"});if($.scale.factor!==1)Z.push({text:`o200k counted ${o($.raw)}, scaled ${$.scale.factor}\xD7 for this model \u2014 ${$.scale.note}`,tone:"dim"});else Z.push({text:`o200k counted ${o($.raw)} \u2014 ${$.scale.note}`,tone:"dim"});if(!$.live)Z.push({text:"system prompt and tool schemas are not counted \u2014 this total is a floor",tone:"warn"});else Z.push({text:"MCP tools are not counted \u2014 their schemas exist only once a server is connected",tone:"dim"});Z.push({text:"",tone:"dim"});let V=[...$.slices].sort((G,Y)=>Y.tokens-G.tokens),j=Math.max(10,...V.map((G)=>G.label.length)),X=V[0]?.share??0;for(let G of V){let Y=`${G.label.padEnd(j)} ${o(G.tokens).padStart(9)} ${T0(G.share).padStart(6)}`,K=Q-f(Y)-(G.note?G.note.length+4:1);Z.push({text:`${Y} ${k6(G.share,X,Math.min(12,K))}${G.note?` \u2014 ${G.note}`:""}`,tone:G.note?"dim":"normal"})}if(V.length===0)Z.push({text:"nothing in the window yet",tone:"dim"});if($.images>0)Z.push({text:`${"images".padEnd(j)} ${String($.images).padStart(9)} \u2014 not estimated; image tokens are provider-specific`,tone:"dim"});if(Z.push({text:"",tone:"dim"}),$.drift){let G=$.drift;Z.push({text:`drift provider counted ${o(G.reported)} for the last turn's prompt, we estimated ${o(G.estimated)}`,tone:G.beyondTolerance?"warn":"normal"}),Z.push({text:` ${o(Math.abs(G.delta))} ${G.delta>0?"more":"less"} than we estimate (${T0(G.fraction)})${G.beyondTolerance?` \u2014 beyond the ${T0($.tolerance)} tolerance; the meter reads ${G.delta>0?"LOW":"HIGH"} here`:""}`,tone:G.beyondTolerance?"warn":"dim"})}else Z.push({text:"drift no turn reported usage yet \u2014 nothing to compare the estimate against",tone:"dim"});Z.push({text:"",tone:"dim"});let U=$.billed;return Z.push({text:`billed ${o(U.input)} in \xB7 ${o(U.output)} out \xB7 ${o(U.cacheRead)} cache read \xB7 ${o(U.cacheWrite)} cache written`,tone:"normal"}),Z.push({text:$.costUsd!==void 0?`cost $${$.costUsd.toFixed(4)}${$.unpricedTurns>0?` \u2014 lower bound, ${$.unpricedTurns} turn${$.unpricedTurns>1?"s":""} unpriced`:""}`:`cost unknown \u2014 no pricing for ${$.model}`,tone:$.costUsd===void 0?"dim":"normal"}),Z}function C9($,J){if(!$)return;if(!$.beyondTolerance)return{text:`est \xB1${T0($.fraction)} of provider`,warn:!1};return{text:`est reads ${$.delta>0?"LOW":"HIGH"} ${T0($.fraction)}`,warn:!0}}function v9($,J,Z,Q,V){let j=Q.context;if(!j)return null;V?.push({rect:{x:0,y:0,w:J.w,h:J.h},onClick:()=>b9(Q)});let X=Math.min(J.w-6,92),U=X-6,G=B6(j,U),Y=Math.max(10,Math.min(J.h-4,G.length+4)),K=Math.floor((J.w-X)/2),z=Math.max(1,Math.floor((J.h-Y)/2));$.box(K,z,X,Y,q(Z.accent),Z.bg2),$.text(K+2,z,[[" context ",q(Z.accent,-1,A.BOLD)]]),$.put(K+X-14,z," esc closes ",q(Z.dim)),V?.push({rect:{x:K,y:z,w:X,h:Y},onClick:()=>{}});let D=Y-3,H=Math.max(0,Math.min(Math.max(0,G.length-D),j.scroll));if(j.scroll=H,G.slice(H,H+D).forEach((N,M)=>{let O=N.tone==="head"?q(Z.fg,Z.bg2,A.BOLD):N.tone==="warn"?q(Z.warn,Z.bg2):N.tone==="dim"?q(Z.muted,Z.bg2):q(Z.fg2,Z.bg2);$.clip(K+3,z+1+M,N.text,O,U)}),G.length>D)$.put(K+X-22,z+Y-1,` ${H+D} of ${G.length} lines `,q(Z.dim,Z.bg2));return null}function f9($,J,Z){let Q=$.context;if(!Q)return;let{name:V,ctrl:j}=J;if(V==="escape"||V==="enter"||j&&V==="g"){b9($);return}let X=Math.max(1,Z-1);if(V==="up"||V==="k")Q.scroll-=1;else if(V==="down"||V==="j")Q.scroll+=1;else if(V==="pageup")Q.scroll-=X;else if(V==="pagedown"||V==="space")Q.scroll+=X;else if(V==="home")Q.scroll=0;else if(V==="end")Q.scroll=Number.MAX_SAFE_INTEGER;Q.scroll=Math.max(0,Q.scroll)}var o=($)=>$.toLocaleString("en-US"),T0=($)=>`${($*100).toFixed(1)}%`;var u0=k(()=>{$0();D0();X0();p()});function y9($,J){if(!$)return{};try{let Z=$.registry.list().map((X)=>X.schema),V=$.buildDef({...J,effort:"auto"}).systemPrompt,j=typeof V==="string"?V:typeof V==="function"?String(V({})):void 0;if(j===void 0)return{};return{system:j,toolSchemas:JSON.stringify(Z)}}catch{return{}}}async function g9($){let J=$.tolerance??b6,Z=`${$.current.provider}/${$.current.model}`,Q;try{Q=($.report??(await import("./context-report-kt01pw8y.js")).contextReport)({messages:$.messages,current:$.current,lookup:$.lookup,...$.fixed.system!==void 0?{system:$.fixed.system}:{},...$.fixed.toolSchemas!==void 0?{toolSchemas:$.fixed.toolSchemas}:{}})}catch{return{model:Z,raw:0,estimated:0,scale:{factor:1,measured:!1,note:"the context report could not be built"},slices:[],images:0,billed:{input:0,output:0,cacheRead:0,cacheWrite:0},unpricedTurns:0,live:!1,tolerance:J}}let V=Q.totals;return{model:Z,...Q.window!==void 0?{window:Q.window}:{},raw:Q.estimated,estimated:Q.corrected,scale:Q.scale,...Q.remaining!==void 0?{remaining:Q.remaining}:{},...Q.fraction!==void 0?{fraction:Q.fraction}:{},...Q.nearLimit!==void 0?{nearLimit:Q.nearLimit}:{},slices:Q.slices.map((j)=>({label:j.label,tokens:j.tokens,share:j.share,...j.note?{note:j.note}:{}})),images:Q.images,...Q.drift?{drift:{...Q.drift}}:{},billed:{input:V.inputTokens??0,output:V.outputTokens??0,cacheRead:V.cacheReadTokens??0,cacheWrite:V.cacheWriteTokens??0},...Q.costUsd!==void 0?{costUsd:Q.costUsd}:{},unpricedTurns:Q.unpricedTurns,live:$.fixed.system!==void 0,tolerance:J}}var b6=0.05;var u9=()=>{};function x0($,J,Z,Q,V,j){if(!(Q>V&&Z>=2))return{x:$,trackY:J,trackH:Z,thumbY:J,thumbH:0,visible:!1};let U=Math.max(1,Math.round(Z*V/Q)),G=Math.max(1,Q-V),Y=Math.max(0,Z-U),K=J+Math.round(Y*Math.max(0,j)/G),z=Math.min(K,J+Z-U);return{x:$,trackY:J,trackH:Z,thumbY:z,thumbH:U,visible:!0}}function C6($,J,Z){if(!J.visible)return;let Q=q(Z.rule),V=q(Z.dim);for(let j=0;j<J.trackH;j++){let X=J.trackY+j,U=X>=J.thumbY&&X<J.thumbY+J.thumbH;$.put(J.x,X,U?"\u258C":"\u2502",U?V:Q)}}function R0($,J,Z,Q,V,j,X,U){let G=x0(Z,Q,V,j,X,U);return C6($,G,J),G}function x9($){return{x:$.x,y:$.thumbY,w:1,h:$.thumbH}}var p0=k(()=>{Q0()});function l9($){w9=$}function m9($){if(/\.(?:[cm]?[jt]sx?)$/.test($))return"ts";if($.endsWith(".json"))return"json";if($.endsWith(".md"))return"md";return"text"}function y6($,J,Z=-1){switch($){case"kw":return q(J.fg,Z,A.BOLD);case"str":case"num":case"dec":return q(J.str,Z);case"cm":return q(J.muted,Z,A.ITALIC);case"ty":return q(J.ty,Z);case"fn":return q(J.fg,Z);default:return q(J.fg2,Z)}}function F5($,J,Z,Q,V,j,X,U,G,Y){if(X<=0)return J;if(Y!==void 0)return $.put(J,Z,Q,q(Y,j),X);let K=J,z=J+X;for(let[D,H]of G(Q,V)){if(K>=z)break;let N=typeof H==="string"?y6(H,U,j):H?{...H,bg:H.bg>=0?H.bg:j}:q(U.fg2,j);K=$.put(K,Z,D,N,z-K)}return K}function u6($,J,Z){let Q=$.code;if(Q.mode==="run"){if(!Q.run)return{title:"run",extra:[]};return{title:"run",extra:[Q.run.status==="running"?[N0(Z),q(J.accent)]:Q.run.status==="ok"?["exit 0",q(J.muted)]:["failed",q(J.err)]]}}if(Q.mode==="search"){if(!Q.search)return{title:"search",extra:[]};return{title:"search",extra:[[Q.search.query,q(J.str)],[` ${Q.search.lines.length} results`,q(J.muted)]]}}if(Q.mode==="agents"){let U=$.crew.filter((z)=>z.status==="queued"||z.status==="running").length,G=$.crew.filter((z)=>z.status==="done").length,Y=$.crew.filter((z)=>z.status==="failed").length;if(!$.crew.length)return{title:"agents",extra:[["crew",q(J.muted)]]};let K=[[`${U} running`,q(U?J.accent:J.muted)],[` ${G} done`,q(J.muted)]];if(Y)K.push([` ${Y} failed`,q(J.err)]);return{title:"agents",extra:K}}let V=g6($),j=Q.mode==="diff"?"diff":"code";if(!V)return{title:j,extra:[]};let X=[[V,q(J.fg2)]];if(Q.diff&&Q.diff.file===V){if(Q.diff.add||Q.diff.del)X.push([" ",q(-1)],[Q.diff.add?`+${Q.diff.add}`:"",q(J.ok)],[Q.diff.del?`${Q.diff.add?" ":""}\u2212${Q.diff.del}`:"",q(J.err)]);if(Q.diff.base==="head")X.push([" vs HEAD",q(J.muted)])}if(Z8($)&&Q.mode==="code")X.push([` ${$.activity.state.toLowerCase()}`,q(J.accent)]);return{title:j,extra:X}}function x6($){let J=new Map;for(let Z of $){let Q=Z.newStart,V=0;while(V<Z.rows.length){if(Z.rows[V].op===" "){Q++,V++;continue}let j=[],X=!1;while(V<Z.rows.length&&Z.rows[V].op!==" "){if(Z.rows[V].op==="-")X=!0;else j.push(Q++);V++}for(let U of j)J.set(U,X?"changed":"added")}}return J}function W5($,J){let Z=$.code;if(Z.mode==="code")return Z.content===null?0:V5(Z.content).length;if(Z.mode==="diff")return Z.diff?c9(Z.diff.hunks,J>110).length:0;if(Z.mode==="search")return Z.search?Z.search.lines.length:0;return 0}function d0($,J){let Z=a($),Q=Z.h,V=Z.w-V0-2,j=W5(J,V),X=Math.max(0,j-Q);if(J.code.mode==="code"&&J.code.hl&&Z8(J))return Math.min(X,Math.max(0,J.code.hl[0]-1-Math.floor(Q/2)));return Math.max(0,Math.min(J.code.scroll,X))}function p6($,J,Z,Q,V,j){$.box(J.x,J.y,J.w,J.h,q(Q.frameDim)),v6.forEach(([z,D],H)=>{if(J.y+1+H>=J.y+J.h-1)return;let N=Z.code.mode===z||z==="code"&&Z.code.mode==="search";$.put(J.x+1,J.y+1+H,D,q(N?Q.accent:Q.dim,-1,N?A.BOLD:0))});let X=J.y+6,U=J.h-7;if(U<3||Z.code.mode!=="code"&&Z.code.mode!=="diff"||Z.code.content===null||!Z.code.file)return;let G=Math.max(1,V5(Z.code.content).length),Y=a9(Z),K=Math.min(U,G);for(let z=0;z<K;z++){let D=Math.floor(z/K*G),H=Math.max(D+1,Math.floor((z+1)/K*G)),N=Q.rule;for(let _=D;_<H;_++){let E=Y.get(_+1);if(E==="added")N=Q.ok;else if(E==="changed"&&N!==Q.ok)N=Q.warn}let M=H>V&&D<V+j,O=N!==Q.rule;$.put(J.x+1,X+z,M?"\u258C":"\u258F",q(O?N:M?Q.rule2:Q.rule))}}function d6($,J,Z,Q,V,j){let X=Z.code.file;if(!X){$.put(J.x,J.y,G0.code,q(Q.muted),J.w);return}if(Z.code.content===null){$.clip(J.x,J.y,`cannot read ${X}`,q(Q.muted),J.w);return}let U=V5(Z.code.content);if(!U.length){$.put(J.x,J.y,"(empty)",q(Q.dim),J.w);return}let G=m9(X),Y=a9(Z),K=Z.code.hl,z=Z8(Z)?`\u25C2 ${Z.activity.state.toLowerCase()}`:null,D=Math.max(3,String(U.length).length);for(let H=0;H<J.h;H++){let N=V+H,M=U[N];if(M===void 0)break;let O=J.y+H,_=K!==null&&N+1>=K[0]&&N+1<=K[1],E=Y.get(N+1),I=_?Q.hlBg:-1;if(_)$.tint(J.x,O,J.w,1,I);if($.put(J.x,O,String(N+1).padStart(D),q(_?Q.accent:Q.dim,I)),$.put(J.x+D+1,O,E?"\u258E":" ",q(E==="changed"?Q.warn:Q.ok,I)),F5($,J.x+D+3,O,M,G,I,J.w-D-3,Q,j),z&&_&&K!==null&&N+1===K[0]&&J.w>24)$.put(J.x+J.w-z.length,O,z,q(Q.accent,I))}}function p9($,J,Z,Q,V){return $.put(J,Z,Q?" PASS ":" FAIL ",q(V.bg,Q?V.ok:V.err,A.BOLD))}function w6($,J,Z){if(Z<=0)return[];let Q=c5("$ "+$,J);return Q.length>Z?[...Q.slice(0,Z-1),O5(Q.length-Z+1)]:Q}function l6($,J,Z,Q,V){let j=Z.code.run;if(!j){$.put(J.x,J.y,"nothing has run yet",q(Q.muted),J.w);return}let X=w6(j.cmd,J.w,J.h>=4?Math.min(h6,J.h-2):0);X.forEach((z,D)=>$.put(J.x,J.y+D,z,z.startsWith("\u2026")?q(Q.dim):q(Q.fg,-1,A.BOLD),J.w));let U=[];for(let z of j.lines)for(let[D,H]of c5(z,J.w).entries())U.push({kind:"out",text:H,first:D===0});U.push({kind:"tail",text:"",first:!0});let G=J.h-X.length,Y=Math.max(0,U.length-G),K=J.y+J.h-Math.min(U.length,G);for(let z=0;Y+z<U.length;z++){let D=U[Y+z],H=K+z;if(D.kind==="tail"){if(j.status==="running")$.text(J.x,H,[[N0(V),q(Q.accent)],[" running",q(Q.muted)]],J.w);else{let M=p9($,J.x,H,j.status==="ok",Q);$.put(M,H,j.status==="ok"?" exit 0":" non-zero exit",q(Q.muted),J.x+J.w-M)}continue}let N=D.first?/^\s*(PASS|FAIL)\b\s?(.*)$/.exec(D.text):null;if(N){let M=p9($,J.x,H,N[1]==="PASS",Q);$.put(M+1,H,N[2]??"",q(Q.fg),J.x+J.w-M-1);continue}$.put(J.x,H,D.text,q(Q.fg2),J.w)}}function m6($,J,Z,Q,V,j){let X=Z.code.search;if(!X){$.put(J.x,J.y,"no search yet",q(Q.muted),J.w);return}let U=Math.min(26,Math.floor(J.w*0.4)),G=J.y;for(let K=V;K<X.lines.length&&G<J.y+J.h;K++,G++){let z=X.lines[K],D=/^(\S+?:\d+(?::\d+)?):\s?(.*)$/.exec(z);if(D)$.clip(J.x,G,D[1],q(Q.muted),U),F5($,J.x+U+1,G,(D[2]??"").trimStart(),"ts",-1,J.w-U-1,Q,j);else $.text(J.x,G,[["\xB7 ",q(Q.dim)],[z,q(Q.fg2)]],J.w)}let Y=X.lines.length?`${X.lines.length} result${X.lines.length===1?"":"s"}`:"no results";if(G<J.y+J.h)$.put(J.x,Math.min(G+(G>J.y?1:0),J.y+J.h-1),Y,q(Q.muted),J.w)}function c9($,J){let Z=[];for(let Q of $){let{oldStart:V,newStart:j}=Q,X=Q.rows.map((K)=>({op:K.op,text:K.text,an:K.op==="+"?null:V++,bn:K.op==="-"?null:j++})),U=X.filter((K)=>K.op!=="+").length,G=X.filter((K)=>K.op!=="-").length;if(Z.push({t:"hunk",text:`@@ -${Q.oldStart},${U} +${Q.newStart},${G} @@`}),!J){for(let K of X)Z.push({t:"line",...K});continue}let Y=0;while(Y<X.length){if(X[Y].op===" "){Z.push({t:"pair",l:X[Y],r:X[Y]}),Y++;continue}let K=[],z=[];while(Y<X.length&&X[Y].op==="-")K.push(X[Y++]);while(Y<X.length&&X[Y].op==="+")z.push(X[Y++]);for(let D=0;D<Math.max(K.length,z.length);D++)Z.push({t:"pair",l:K[D]??null,r:z[D]??null})}}return Z}function d9($,J,Z,Q,V,j,X,U,G){if(!V||Q<8)return;let Y=V.op!==" ",K=!Y?-1:j==="add"?U.addBg:U.delBg;if(K>=0)$.tint(J,Z,Q,1,K);$.put(J,Z,String((j==="del"?V.an:V.bn)??"").padStart(4),q(U.dim,K)),$.put(J+5,Z,Y?j==="add"?"+":"\u2212":" ",q(j==="add"?U.ok:U.err,K)),F5($,J+7,Z,V.text,X,K,Q-7,U,G,j==="del"&&Y?U.muted:void 0)}function a6($,J,Z,Q,V,j,X,U){if(V.t==="hunk"){$.put(J,Z,V.text,q(X.dim),Q);return}if(V.t==="pair"){let z=Math.floor((Q-1)/2);d9($,J,Z,z,V.l,"del",j,X,U),d9($,J+z+1,Z,Q-z-1,V.r,"add",j,X,U);return}let G=V.op==="+",Y=V.op==="-",K=G?X.addBg:Y?X.delBg:-1;if(K>=0)$.tint(J,Z,Q,1,K);$.put(J,Z,String(V.an??"").padStart(4)+" "+String(V.bn??"").padStart(4),q(X.dim,K),Q),$.put(J+10,Z,G?"+":Y?"\u2212":" ",q(G?X.ok:X.err,K),Math.max(0,Q-10)),F5($,J+12,Z,V.text,j,K,Q-12,X,U,Y?X.muted:void 0)}function c6($,J,Z,Q,V,j){let X=Z.code.diff;if(!X||!X.hunks.length){$.put(J.x,J.y,"no changes in this file",q(Q.muted),J.w);return}let U=c9(X.hunks,J.w>110),G=m9(X.file);for(let Y=0;Y<J.h;Y++){let K=U[V+Y];if(!K)break;a6($,J.x,J.y+Y,J.w,K,G,Q,j)}}function i9($){let J=[],Z=null;for(let Q of $.split(/\r?\n/)){let V=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(Q);if(V){Z={rows:[],oldStart:Number(V[1]),newStart:Number(V[2])},J.push(Z);continue}if(!Z)continue;let j=Q[0];if(j==="+"||j==="-"||j===" ")Z.rows.push({op:j,text:Q.slice(1)})}return J}function i6($,J,Z,Q,V){let j=Z.crew.length;$.put(J.x,J.y,`crew: ${j} task${j===1?"":"s"}`,q(j?Q.fg2:Q.muted),J.w),Z.crew.forEach((X,U)=>{let G=J.y+2+U;if(G>=J.y+J.h)return;let Y=X.status==="running"?N0(V):X.status==="queued"?"\u25C7":X.status==="done"?"\u25C6":X.status==="failed"?"\xD7":"\u2212",K=X.status==="running"?Q.accent:X.status==="done"?Q.ok:X.status==="failed"?Q.err:Q.dim,z=X.status.length;$.text(J.x,G,[[Y+" ",q(K)],[X.label,q(Q.fg2)]],Math.max(0,J.w-z-2)),$.put(J.x+J.w-z,G,X.status,q(X.status==="failed"?Q.err:X.status==="done"?Q.ok:Q.muted))})}function n9($,J,Z,Q,V,j={}){if(J.w<4||J.h<3)return;let{title:X,extra:U}=u6(Z,Q,V),G=e($,J,X,Z.focus==="code",U,Q),Y={x:G.x+G.w-V0,y:G.y,w:V0,h:G.h},K={x:G.x,y:G.y,w:G.w-V0-2,h:G.h},z=d0(J,Z);if(K.w>=6&&K.h>=1){let D=j.tokenize??f6;switch(Z.code.mode){case"run":l6($,K,Z,Q,V);break;case"search":m6($,K,Z,Q,z,D);break;case"agents":(w9??i6)($,K,Z,Q,V);break;case"diff":c6($,K,Z,Q,z,D);break;default:d6($,K,Z,Q,z,D)}}if(G.w>=V0+2&&K.h>=2&&(Z.code.mode==="code"||Z.code.mode==="diff"||Z.code.mode==="search")){let D=W5(Z,K.w);R0($,Q,G.x+G.w-V0-1,G.y,K.h,D,K.h,z)}if(Y.h>=2&&G.w>=V0)p6($,Y,Z,Q,z,K.h)}var V0=3,v6,f6=($)=>[[$,"plain"]],w9=null,Z8=($)=>$.running&&($.activity.state==="READING"||$.activity.state==="EDITING"),g6=($)=>$.code.mode==="diff"&&$.code.diff?$.code.diff.file:$.code.file,a9=($)=>$.code.diff&&$.code.diff.file===$.code.file?x6($.code.diff.hunks):new Map,h6=3;var _5=k(()=>{p();$0();J8();h9();p0();v6=[["code","\u25A4"],["diff","\xB1"],["run","$"],["agents","\u2237"]]});import{diffLines as n6}from"diff";function s9($,J){if(J==="md")return r6($);if(J==="text")return[[$,"plain"]];let Z=[],Q=0,V;o9.lastIndex=0;while(V=o9.exec($)){if(V.index>Q)Z.push([$.slice(Q,V.index),"plain"]);let j=V[0],X;if(V[1])X="cm";else if(V[2])X=J==="json"&&/^\s*:/.test($.slice(V.index+j.length))?"key":"str";else if(V[3])X="num";else if(V[4]){let U=$[V.index-1],G=$.slice(V.index+j.length);if(j[0]==="@")X="dec";else if(o6.has(j))X="kw";else if(U===".")X="prop";else if(/^\s*\(/.test(G)||/^</.test(G)&&/^[a-z]/.test(j))X="fn";else if(/^[A-Z]/.test(j))X="ty";else if(/^\??:/.test(G))X="prop";else X="id"}else if(V[5]||V[6])X="pu";else X="op";Z.push([j,X]),Q=V.index+j.length}if(Q<$.length)Z.push([$.slice(Q),"plain"]);return Z}function r6($){if(/^#{1,6}\s/.test($))return[[$,"kw"]];if(/^\s{4}/.test($))return[[$,"str"]];let J=[],Z=0,Q,V=/`[^`]+`/g;while(Q=V.exec($)){if(Q.index>Z)J.push([$.slice(Z,Q.index),"plain"]);J.push([Q[0],"str"]),Z=Q.index+Q[0].length}if(Z<$.length)J.push([$.slice(Z),"plain"]);return J}function s6($){let J=[],Z=0,Q=0;for(let V of $){let j=V.value.split(`
|
|
10
10
|
`);if(j.length>V.count)j.pop();for(let X of j)if(V.added)J.push({t:"ins",text:X,bn:++Q});else if(V.removed)J.push({t:"del",text:X,an:++Z});else J.push({t:"eq",text:X,an:++Z,bn:++Q})}return J}function t9($,J){return s6(n6($,J))}function r9($,J,Z){let Q=$.slice(J,Z),V=null,j=null,X=0,U=0;for(let G of Q){if(G.an){if(V==null)V=G.an;X++}if(G.bn){if(j==null)j=G.bn;U++}}return{ops:Q,as:V??0,bs:j??0,ac:X,bc:U}}function $$($,J){if(!isFinite(J))return $.length?[r9($,0,$.length)]:[];let Z=[],Q=0;while(Q<$.length){if($[Q].t==="eq"){Q++;continue}let V=Math.max(0,Q-J),j=Q+1,X=Q+1;while(X<$.length){if($[X].t!=="eq"){j=X+1,X++;continue}let U=X;while(U<$.length&&$[U].t==="eq")U++;if(U<$.length&&U-X<=J*2){X=U;continue}break}j=Math.min($.length,j+J),Z.push(r9($,V,j)),Q=j}return Z}function J$($){return{rows:$.ops.map((J)=>({op:J.t==="ins"?"+":J.t==="del"?"-":" ",text:J.text})),oldStart:$.as,newStart:$.bs}}function Y0($,J){$=$.toLowerCase(),J=J.toLowerCase();let Z=0,Q=0,V=-2,j=[];for(let X=0;X<J.length&&Z<$.length;X++)if(J[X]===$[Z])j.push(X),Q+=(V===X-1?3:1)+(X===0||J[X-1]===" "||J[X-1]==="/"?2:0),V=X,Z++;return Z===$.length?{score:Q,idx:j}:null}var o6,o9,e9=($)=>{let J=0,Z=0;for(let Q of $)if(Q.t==="ins")J++;else if(Q.t==="del")Z++;return{a:J,d:Z}};var h0=k(()=>{o6=new Set("import export from const let var function return if else async await new type interface extends implements class throw try catch finally for while of in as default void typeof instanceof null undefined true false this readonly declare satisfies keyof enum switch case break continue do yield static private public protected".split(" ")),o9=/(\/\/.*)|("(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|`(?:[^`\\]|\\.)*`)|(\b\d[\d_]*(?:\.\d+)?\b)|(@?[A-Za-z_$][\w$]*)|([{}()[\]])|([;,.:])|(=>|\?\?|\?\.|[<>=!+\-*/%&|^~?]+)/g});import{spawn as t6,spawnSync as P3}from"child_process";function J7($={}){let J=$.timeoutMs??e6,Z=$.argv??((Q,V)=>["git","-C",V,...Q]);return(Q,V,j)=>new Promise((X)=>{if(j?.aborted){X(null);return}let U=!1,G=(H)=>{if(!U)U=!0,j?.removeEventListener("abort",K),X(H)},Y,K=()=>{Y?.kill("SIGKILL")};try{let[H,...N]=Z(Q,V);Y=t6(H??"git",N,{timeout:J,killSignal:"SIGKILL",windowsHide:!0,stdio:["ignore","pipe","ignore"]})}catch{G(null);return}j?.addEventListener("abort",K,{once:!0});let z=[],D=0;Y.stdout?.on("data",(H)=>{if(D+=H.length,D>Z$)Y.kill("SIGKILL");else z.push(H)}),Y.on("error",()=>G(null)),Y.on("close",(H,N)=>G(H===null||N!==null||D>Z$?null:{status:H,stdout:Buffer.concat(z).toString("utf8")}))})}async function w0($,J,Z){try{let Q=await $(J,Z);return Q&&Q.status===0?Q.stdout:null}catch{return null}}async function Q8($,J=j0){let Z=(await w0(J,["rev-parse","--abbrev-ref","HEAD"],$))?.trim();if(!Z)return(await w0(J,["symbolic-ref","--short","-q","HEAD"],$))?.trim()||null;if(Z!=="HEAD")return Z;return(await w0(J,["rev-parse","--short","HEAD"],$))?.trim()||"HEAD"}function Z7($){if($.length<2||!$.startsWith('"')||!$.endsWith('"'))return $;let J=$.slice(1,-1),Z=[];for(let Q=0;Q<J.length;Q++){let V=J[Q];if(V!=="\\"){Z.push(...Buffer.from(V,"utf8"));continue}let j=J[Q+1]??"";if(/[0-7]/.test(j)){let X=/^[0-7]{1,3}/.exec(J.slice(Q+1))[0];Z.push(parseInt(X,8)&255),Q+=X.length;continue}Z.push(j==="n"?10:j==="t"?9:j==="r"?13:j.charCodeAt(0)||92),Q++}return Buffer.from(Z).toString("utf8")}function Q7($,J){if($==="!"&&J==="!")return null;if($==="?"&&J==="?")return"A";if($==="D"||J==="D")return"D";if($==="A")return"A";return"M"}function V7($){let J=new Map,Z=$.includes("\x00"),Q=Z?$.split("\x00"):$.split(/\r?\n/);for(let V=0;V<Q.length;V++){let j=Q[V];if(j.length<4)continue;let X=j[0],U=j[1],G=j.slice(3);if(X==="R"||U==="R"||X==="C"||U==="C")if(Z)V++;else{let K=G.indexOf(" -> ");if(K>=0)G=G.slice(K+4)}if(!Z)G=Z7(G);if(G=V$(G),!G||G.startsWith("../"))continue;let Y=Q7(X,U);if(Y)J.set(G,Y)}return J}async function V8($,J=j0){let Z=await w0(J,$7,$);return Z===null?null:V7(Z)}function j7($){let J=V$($);return!J||J.startsWith("../")?null:`HEAD:./${J}`}async function j$($,J,Z=j0){let Q=j7(J);return Q===null?null:w0(Z,["show",Q],$)}var e6=5000,Z$=67108864,$7,j0,Q$=($)=>(J,Z)=>Promise.resolve().then(()=>$(J,Z)),V$=($)=>$.replace(/\\/g,"/").replace(/^\.\/+/,"");var j8=k(()=>{$7=["status","--porcelain=v1","-z","--untracked-files=all"];j0=J7()});function U8($,J){let Z=(J?Number(J):1)-1;return{type:"key",name:$,shift:!!(Z&1),alt:!!(Z&2),ctrl:!!(Z&4)}}function G$($,J=""){let Z=J+$,Q=[],V=0;while(V<Z.length){let j=Z[V];if(j==="\x1B"){let G=Z.slice(V);if(G.startsWith(X8)){let H=Z.indexOf(X$,V+X8.length);if(H<0)return{events:Q,rest:G};Q.push({type:"paste",text:Z.slice(V+X8.length,H)}),V=H+X$.length;continue}let Y;if(Y=G7.exec(G)){Q.push({type:"mouse",b:+Y[1],x:+Y[2]-1,y:+Y[3]-1,press:Y[4]==="M"}),V+=Y[0].length;continue}if(Y=Y7.exec(G)){Q.push(U8(X7[Y[1]]??"unknown",Y[2])),V+=Y[0].length;continue}if(Y=K7.exec(G)){Q.push(U8(U$[Y[3]]??"unknown",Y[2])),V+=Y[0].length;continue}if(Y=q7.exec(G)){Q.push(U8(U$[Y[1]]??"unknown",void 0)),V+=Y[0].length;continue}if(G.length===1){Q.push({type:"key",name:"escape"}),V++;continue}let K=Z.codePointAt(V+1);if(K<32||K===127){Q.push({type:"key",name:"escape"}),V++;continue}let z=String.fromCodePoint(K);if(z!=="["&&z!=="O"){Q.push({type:"key",name:z.toLowerCase(),alt:!0,ch:z}),V+=1+z.length;continue}let D=V+2;while(D<Z.length&&!z7.test(Z[D]))D++;if(D>=Z.length){if(G.length>32){V=Z.length;continue}return{events:Q,rest:G}}V=D+1;continue}if(j==="\r"||j===`
|
|
11
11
|
`){Q.push({type:"key",name:"enter"}),V++;continue}if(j==="\t"){Q.push({type:"key",name:"tab"}),V++;continue}if(j==="\x7F"||j==="\b"){Q.push({type:"key",name:"backspace"}),V++;continue}let X=j.charCodeAt(0);if(X<32){Q.push({type:"key",name:U7[X]??String.fromCharCode(X+96),ctrl:!0}),V++;continue}let U=String.fromCodePoint(Z.codePointAt(V));Q.push({type:"key",name:U,ch:U}),V+=U.length}return{events:Q,rest:""}}function P5($){if(!$.press)return"release";let J=$.b&-29;if(J===64)return"wheel-up";if(J===65)return"wheel-down";if(($.b&31)!==0)return"other";return $.b&32?"drag":"click"}function Y$($=!0){return y+"?1049h"+y+"?25l"+y+"?7l"+y+"2J"+y+"H"+($?y+"?1000h"+y+"?1002h"+y+"?1006h":"")+y+"?2004h"}function K$(){return y+"?2004l"+y+"?1006l"+y+"?1002l"+y+"?1000l"+y+"0m"+y+"?7h"+y+"?25h"+y+"?1049l"}function q$(){return y+"?1000h"+y+"?1002h"+y+"?1006h"}function z$(){return y+"?1006l"+y+"?1002l"+y+"?1000l"}var y="\x1B[",X8,X$,U$,X7,U7,G7,Y7,K7,q7,z7;var l0=k(()=>{X8=y+"200~",X$=y+"201~",U$={A:"up",B:"down",C:"right",D:"left",H:"home",F:"end",Z:"shift-tab",P:"f1",Q:"f2",R:"f3",S:"f4"},X7={1:"home",2:"insert",3:"delete",4:"end",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},U7={0:"space",28:"\\",29:"]",30:"^",31:"/"},G7=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])/,Y7=/^\x1b\[(\d+)(?:;(\d+))?~/,K7=/^\x1b\[(?:(\d+);(\d+))?([A-Z])/,q7=/^\x1bO([A-Z])/,z7=/[A-Za-z~]/});function I5($,J,Z){$.theme=Z,J.local.setTheme(Z)}function M0($,J,Z){$.code.mode=Z,$.code.scroll=0,J.local.setMode(Z)}function G8($,J){M0($,J,"agents"),$.code.laneOpen=!1,$.focus="code"}function a0($,J,Z){let Q=Z.split("/");for(let V=1;V<Q.length;V++)$.files.expanded.add(Q.slice(0,V).join("/"));$.code.file=Z,$.code.mode="code",$.code.scroll=0,J.local.openFile(Z)}function S5($,J,Z){if(Z==="files"&&!J.layout.files)$.page="files";$.focus=Z}function Y8($,J,Z){if(J==="/setup"||J==="/connect"){Z.local.openWizard();return}let Q=m0(J);if(Q.kind==="text"&&Q.mentions.length>0){let V=D$(J,{cwd:$.cwd,mentions:Q.mentions,resolve:(j)=>A5(j,$.files.paths),attachImage:Z.local.attachImage?.bind(Z.local)});for(let j of V.notes)Z.local.toast(j);Z.hooks.onSubmit(V.text);return}if(Q.kind!=="slash"||!H7($,Q.cmd??"",Q.arg??"",Z))Z.hooks.onSubmit(J)}function H7($,J,Z,Q){switch(J){case"help":return N$($),!1;case"notices":return E5($),!0;case"market":return Q.local.openMarket(),!0;case"context":Q.local.openContext();case"wizard":return Q.local.openWizard(),!0;return!0;case"theme":if(M$(Z))I5($,Q,Z);else Q.local.toast(`unknown theme "${Z}" \xB7 night, ember or contrast`);return!0;case"open":{let V=A5(Z,$.files.paths,Q.fuzzy);if(!V)return Q.local.toast(Z?`no file matches "${Z}"`:"usage: /open <file>"),!0;return a0($,Q,V),$.focus="code",!0}case"diff":{if(Z){let V=A5(Z,$.files.paths,Q.fuzzy);if(!V)return Q.local.toast(`no file matches "${Z}"`),!0;$.code.file=V}return M0($,Q,"diff"),!0}case"focus":if(Z==="messages"||Z==="code"||Z==="files")S5($,Q,Z);else Q.local.toast("focus is messages, code or files");return!0;case"agents":if(Z)return!1;return G8($,Q),!0;default:{let V=D7[J];if(V&&!$.commands.some((j)=>j.name===J))return Q.local.toast(V),!0;return!1}}}function O$($,J,Z){if(J.startsWith("/")){let X=m0(J);if(["theme","open","focus"].includes(X.cmd??"")&&!X.arg){$.input.text=J+" ",$.input.cur=$.input.text.length,$.input.sgSel=0,$.focus="messages";return}Y8($,J,Z);return}let Q=J.indexOf(":"),V=J.slice(0,Q),j=J.slice(Q+1);if(V==="theme"&&M$(j))I5($,Z,j);else if(V==="mode"){if(M0($,Z,j),j==="agents")$.code.laneOpen=!1}else if(V==="focus")S5($,Z,j);else if(V==="open")a0($,Z,j),$.focus="code"}var D7,M$=($)=>_0.includes($);var F$=k(()=>{X0();H$();p();X0();D7={permissions:"/permissions \u2192 use /yolo",mode:"/mode \u2192 use /plan or /act"}});function _$($,J,Z){let{name:Q}=Z,V=J.kind==="approval"?J.verdicts.length:(J.prompt.options?.length??0)+(J.prompt.allowFreeText!==!1?1:0)+1;if(Q==="left"||Q==="up")return W$(J,V,-1);if(Q==="right"||Q==="down"||Q==="tab")return W$(J,V,1);if(Q==="escape")return L5($),!0;if(J.kind==="approval"){if(Q!=="enter")return!1;return $.card=null,J.resolve(J.verdicts[J.selected]??"deny"),!0}let j=J.prompt.options?.length??0,X=J.prompt.allowFreeText!==!1?j:-1;if(Q==="enter"){if(J.selected===V-1)return L5($),!0;if(J.selected!==X)return $.card=null,J.resolve({kind:"option",index:J.selected}),!0;let G=J.freeText.trim();if(G)$.card=null,J.resolve({kind:"text",text:G});return!0}if(J.selected!==X)return!1;if(Q==="backspace")return J.freeText=[...J.freeText].slice(0,-1).join(""),!0;let U=Q==="space"?" ":Z.ch;if(!U||Z.alt)return!1;return J.freeText+=U,!0}function W$($,J,Z){let Q=($.selected+Z+J)%J;return $.selected=Q,!0}function L5($){let J=$.card;if($.card=null,J?.kind==="approval")J.resolve("deny");else J?.resolve(null)}var P$=()=>{};function S$($,J){return J==="files"?$.files===null:J==="plan"?$.plan===null:!1}function O0($,J){return S$($,J.page)?J.page:"code"}function L$($,J){let Z=A$.filter((Y)=>S$($,Y));if(Z.length===0)return[];let Q=["code",...Z],V=O0($,J),j=$.code.y,X=$.code.x+$.code.w-2,U=$.code.x+2,G=[];for(let[Y,K]of Q.entries()){let z=f(E$[K])+2;if(U+z>X)break;G.push({page:K,rect:{x:U,y:j,w:z,h:1},active:K===V}),U+=z+(Y<Q.length-1?f(I$):0)}return G}function T$($,J,Z,Q){let V=L$(J,Z);if(V.length===0)return V;let j=Z.focus==="code"||Z.focus==="files";for(let[X,U]of V.entries()){let G=U.active?q(Q.bg,j?Q.accent:Q.fg2,A.BOLD):q(Q.muted);$.text(U.rect.x,U.rect.y,[[` ${E$[U.page]} `,G]],U.rect.w);let Y=V[X+1];if(Y)$.text(U.rect.x+U.rect.w,U.rect.y,[[I$,q(Q.frame)]],Y.rect.x-(U.rect.x+U.rect.w))}return V}function R$($,J){let Z=L$($,J);if(Z.length<2)return J.page;let Q=Z.findIndex((V)=>V.active);return Z[(Q+1)%Z.length].page}var E$,I$=" \xB7 ";var T5=k(()=>{$0();D0();p();E$={code:"code",files:"files",plan:"plan"}});function O7($,J="code"){return N7.filter((Z)=>Z!=="files"||$.files!==null||J==="files")}function z8($,J,Z,Q){if(J.type==="mouse")return b7($,J,Z,Q);if(J.type==="paste")return B7($,J.text,Z);if($.palette){if(J.ctrl&&J.name==="c")return c0($,Z);return v$($,J,(j)=>O$($,j,Z),Z.fuzzy),S()}if($.market){if(J.ctrl&&J.name==="c")return c0($,Z);let j=N9($,J,Z.fuzzy);if(j.kind==="plan")Z.local.marketPlan(j.row,j.local);else if(j.kind==="docs")Z.local.marketDocs(j.row);else if(j.kind==="install")Z.local.marketInstall(j.plan.row,j.plan.local);return S()}if($.context){if(J.ctrl&&J.name==="c")return c0($,Z);return f9($,J,Math.max(4,Math.min(Z.layout.h-4,24))),S()}if($.wizard){if(J.ctrl&&J.name==="c")return c0($,Z);let j=_9($,J);if(j.kind==="registerEndpoint")Z.local.wizardRegister(j.id,j.url,j.protocol);else if(j.kind==="storeKey")Z.local.wizardStoreKey(j.provider,j.secret);else if(j.kind==="confirmModels")Z.local.wizardActivate(j.provider,j.models,j.makeDefault===void 0?void 0:j.makeDefault);else if(j.kind==="confirmModel")Z.local.wizardModel(j.model);else if(j.kind==="loadModels")Z.local.wizardLoadModels();return S()}if($.help){if(J.name==="escape"||J.name==="enter"||J.name==="space"||J.ctrl&&J.name==="c"||J.ch&&!J.ctrl)$.help=!1;return S()}if(J.ctrl)return W7($,J,Z);if($.card&&_$($,$.card,J))return S();let{name:V}=J;if(V==="escape")return _7($,Z,Q);if(V==="tab"||V==="shift-tab")return P7($,V,Z);if(V==="enter")return A7($,Z);if($.focus==="files"){let j=I7($,V,Z);if(j)return j}if($.focus==="code"){let j=L7($,V,Z);if(j)return j}return T7($,J,Z)}function W7($,J,Z){if($.card&&J.name!==void 0&&F7.has(J.name))return S();switch(J.name){case"c":return c0($,Z);case"k":case"p":return R5($),S();case"g":return Z.local.openContext(),S();case"t":{let Q=_0[(_0.indexOf($.theme)+1)%_0.length];return I5($,Z,Q),S()}case"e":return S5($,Z,"files"),S();case"o":{let Q=R$(Z.layout,$);if(Q!==$.page)$.page=Q,$.focus=Q==="files"?"files":"code";return S()}case"b":return E5($),S();case"m":return Z.local.openMarket(),S();case"v":return Z.hooks.onSubmit("/paste"),S();case"s":return M0($,Z,"code"),$.focus="code",S();case"d":return M0($,Z,$.code.mode==="diff"?"code":"diff"),S();case"r":return M0($,Z,"run"),S();case"a":return G8($,Z),S();case"n":return Z.hooks.onSubmit("/new"),S();case"u":return D8($),S();case"left":case"right":return $.input.cur=g$($.input.text,$.input.cur,J.name==="left"?-1:1),S();default:return r()}}function c0($,J){if($.card)L5($);if($.running)J.hooks.onInterrupt();else J.hooks.onExit();return S()}function D8($){$.input.text="",$.input.cur=0,$.input.sgSel=0,$.input.histIdx=-1}function _7($,J,Z){if($.focus!=="messages"){if($.code.laneOpen)$.code.laneOpen=!1;else $.focus="messages";return S()}if(k5($,J).length)return $.input.sgSel=-1,S();if($.running){if(Z<$.escUntil)$.escUntil=0,J.hooks.onInterrupt();else $.escUntil=Z+q8;return S()}if($.input.text)return D8($),S();return r()}function P7($,J,Z){let Q=k5($,Z);if($.focus==="messages"&&Q.length)return y$($,Q[k0($.input.sgSel,0,Q.length-1)]),S();let V=O7(Z.layout,$.page),j=Math.max(0,V.indexOf($.focus));return $.focus=V[(j+(J==="tab"?1:V.length-1))%V.length],S()}function A7($,J){if($.focus==="files"){let Q=J.rows[$.files.cursor];if(Q?.dir)if($.files.expanded.has(Q.path))$.files.expanded.delete(Q.path);else $.files.expanded.add(Q.path);else if(Q)a0($,J,Q.path);return S()}if($.focus==="code"){if($.code.mode==="agents"&&$.crew.length)$.code.laneOpen=!$.code.laneOpen,$.code.scroll=$.code.laneOpen?M7:0;return S()}let Z=k5($,J);if(Z.length){let Q=Z[k0($.input.sgSel,0,Z.length-1)];if(!E7($,Q))return B$($,$.input.text,J);if(y$($,Q),Q.enter==="complete")return S()}return B$($,$.input.text,J)}function E7($,J){if(J.kind!=="slash"||$.input.sgSel!==0)return!0;let Z=(m0($.input.text).cmd??"").toLowerCase();return Z.length>=2&&J.label.slice(1).toLowerCase().startsWith(Z)}function B$($,J,Z){let Q=J.trim();if(!Q)return r();return $.input.history.push(Q),D8($),Y8($,Q,Z),S()}function I7($,J,Z){let Q=Z.rows,V=$.files;if(J==="up"||J==="down"){V.cursor=k0(V.cursor+(J==="up"?-1:1),0,Math.max(0,Q.length-1));let j=Math.max(1,(Z.layout.files?.h??3)-2);if(V.cursor<V.scroll)V.scroll=V.cursor;else if(V.cursor>=V.scroll+j)V.scroll=V.cursor-j+1;let X=Q[V.cursor];if(X&&!X.dir)a0($,Z,X.path);return S()}if(J==="left"||J==="right"){let j=Q[V.cursor];if(j?.dir)if(J==="right")V.expanded.add(j.path);else V.expanded.delete(j.path);return S()}return null}function L7($,J,Z){let Q=$.code,V=$.crew.length;if(Q.mode==="agents"&&V&&!Q.laneOpen){let{cols:j}=n5(S7(Z.layout.code),V),X={left:V-1,right:1,up:V-j,down:j};if(Object.hasOwn(X,J))return Q.lane=(Q.lane+X[J])%V,S()}if(J==="up")return Q.scroll=Math.max(0,Q.scroll-1),S();if(J==="down")return Q.scroll+=1,S();if(J==="pageup")return Q.scroll=Math.max(0,Q.scroll-10),S();if(J==="pagedown")return Q.scroll+=10,S();if(J==="left"||J==="right"){let j=Q.search?[...k$,"search"]:[...k$],X=Math.max(0,j.indexOf(Q.mode));return M0($,Z,j[(X+(J==="right"?1:j.length-1))%j.length]),S()}return null}function T7($,J,Z){let{name:Q}=J,V=$.input;if(Q==="pageup")return $.stick=!1,$.msgScroll=Math.max(0,$.msgScroll-5),S();if(Q==="pagedown")return $.msgScroll+=5,S();if(Q==="up"||Q==="down")return R7($,Q==="up"?-1:1,Z);if(Q==="left"||Q==="right"){let X=Q==="left"?-1:1;if(J.alt)V.cur=g$(V.text,V.cur,X);else V.cur=k0(X<0?V.cur-b$(V.text,V.cur):V.cur+C$(V.text,V.cur),0,V.text.length);return S()}if(Q==="home")return V.cur=0,S();if(Q==="end")return V.cur=V.text.length,$.stick=!0,S();if(Q==="backspace"){if(V.cur>0){let X=b$(V.text,V.cur);V.text=V.text.slice(0,V.cur-X)+V.text.slice(V.cur),V.cur-=X,V.sgSel=0,V.histIdx=-1}return $.focus="messages",S()}if(Q==="delete"){if(V.cur<V.text.length)V.text=V.text.slice(0,V.cur)+V.text.slice(V.cur+C$(V.text,V.cur)),V.sgSel=0;return S()}let j=Q==="space"?" ":J.ch;if(j&&!J.alt)return f$($,j),S();return r()}function R7($,J,Z){let Q=$.input,V=Q.histIdx<0?k5($,Z):[];if(V.length)return Q.sgSel=(k0(Q.sgSel,0,V.length-1)+J+V.length)%V.length,S();let j=Q.history;if(!j.length)return r();if(Q.histIdx<0)Q.histIdx=j.length;return Q.histIdx=k0(Q.histIdx+J,0,j.length),Q.text=j[Q.histIdx]??"",Q.cur=Q.text.length,Q.sgSel=0,S()}function k7($){let J=$.trim();if(J.length===0||J.includes(`
|
|
12
12
|
`))return null;let Z=/^(?:"([^"]+)"|'([^']+)'|(\S+))$/.exec(J),Q=Z?.[1]??Z?.[2]??Z?.[3];return Q!==void 0&&/\.(png|jpe?g|gif|webp)$/i.test(Q)?Q:null}function B7($,J,Z){if($.help)return r();if($.palette)return $.palette.query+=J.replace(/\s+/g," "),$.palette.sel=0,S();if($.wizard)return W9($,J),S();if(!$.card){let V=k7(J);if(V!==null)return Z.hooks.onSubmit(`/attach "${V}"`),S()}let Q=$.card;if(Q?.kind==="question"&&Q.prompt.allowFreeText!==!1){if(Q.selected===(Q.prompt.options?.length??0))return Q.freeText+=J,S()}return f$($,J),S()}function f$($,J){let Z=$.input;Z.text=Z.text.slice(0,Z.cur)+J+Z.text.slice(Z.cur),Z.cur+=J.length,Z.sgSel=0,Z.histIdx=-1,$.focus="messages"}function y$($,J){$.input.text=J.apply.text,$.input.cur=J.apply.cur,$.input.sgSel=0,$.input.histIdx=-1}function k5($,J){return $.input.sgSel<0?[]:B0($,$.files.paths,J.fuzzy)}function b$($,J){return J>=2&&$.codePointAt(J-2)>65535?2:1}function C$($,J){return($.codePointAt(J)??0)>65535?2:1}function g$($,J,Z){let Q=J;if(Z<0){while(Q>0&&/\s/.test($[Q-1]))Q--;while(Q>0&&!/\s/.test($[Q-1]))Q--}else{while(Q<$.length&&/\s/.test($[Q]))Q++;while(Q<$.length&&!/\s/.test($[Q]))Q++}return Q}function b7($,J,Z,Q){let V=P5(J),j=Z.layout;if(V==="wheel-up"||V==="wheel-down")return C7($,J,j,V==="wheel-up"?-1:1,Z);if(V==="release"){let G=Z.drag.zone!==null;return Z.drag.zone=null,G?S():r()}if(V==="drag"){let G=Z.drag.zone;if(G?.onDrag)return G.onDrag(J.y,J.y-Z.drag.y0),S();return r()}if(V!=="click")return r();for(let G=Z.hits.length-1;G>=0;G--){let Y=Z.hits[G];if(!i0(J.x,J.y,Y.rect))continue;if(Z.drag.zone=Y.onDrag?Y:null,Z.drag.y0=J.y,Y.onClick(),Y.key)z8($,Y.key,Z,Q);return S()}if(K8($).length>0)return r();let X=O0(j,$),U=[["messages",j.messages],["code",X==="code"?j.code:null],["files",j.files??(X==="files"?j.code:null)]];for(let[G,Y]of U)if(Y&&i0(J.x,J.y,Y))return $.focus=G,S();return r()}function C7($,J,Z,Q,V){if(K8($).length>0)return r();if(i0(J.x,J.y,Z.messages)){if($.msgScroll=Math.max(0,$.msgScroll+Q*2),Q<0)$.stick=!1;return S()}let j=O0(Z,$),X=Z.files??(j==="files"?Z.code:null);if(X&&i0(J.x,J.y,X)){let U=Math.max(1,X.h-2),G=$.files;return G.scroll=Math.max(0,Math.min(G.scroll+Q*2,Math.max(0,V.rows.length-U))),G.cursor=Math.max(G.scroll,Math.min(G.cursor,G.scroll+U-1)),S()}if(j==="code"&&i0(J.x,J.y,Z.code))return $.code.scroll=Math.max(0,$.code.scroll+Q*3),S();return r()}var q8=1500,N7,k$,M7=1e9,S=()=>["render"],r=()=>[],k0=($,J,Z)=>Math.max(J,Math.min($,Z)),i0=($,J,Z)=>$>=Z.x&&$<Z.x+Z.w&&J>=Z.y&&J<Z.y+Z.h,F7,S7=($)=>$.w-9;var H8=k(()=>{p();X0();z5();H5();u0();F$();P$();S0();l0();T5();X0();N7=["messages","code","files"],k$=["code","diff","run","agents"];F7=new Set(["k","p","b","m","g"])});function y7($){let J=$>>>0;return()=>{J=J+1831565813>>>0;let Z=J;return Z=Math.imul(Z^Z>>>15,Z|1),Z^=Z+Math.imul(Z^Z>>>7,Z|61),((Z^Z>>>14)>>>0)/4294967296}}function p$($){let J=($.ROVECODE_PET??"").trim().toLowerCase();return!(J==="0"||J==="false"||J==="off"||J==="no")}function d$($,J){let Z=$.activity;return{state:Z.state,running:$.running,waiting:$.card!=null,delegating:$.crew.some((Q)=>Q.status==="queued"||Q.status==="running"),errorAt:Z.state==="ERROR"?Z.errorAt??Z.endedAt??Z.startedAt??0:null,tokens:$.usage.tokensIn+$.usage.tokensOut,activeAt:Math.max(Z.startedAt??0,Z.endedAt??0),runStartedAt:$.running?Z.startedAt:null,changed:$.repo.modified,typing:$.input.text.length>0,booting:J-$.bootAt<1300}}function h$($={}){let J=y7($.seed??7),Z={name:($.name||"rovecode").slice(0,14),pokes:0,quip:null,lastQuipAt:0,lastEventKind:null,lastActiveAt:null,fx:[],glance:null,nextObserveAt:0,pendingObserve:null,nextSuggestAt:0,lastSuggest:"",saidLong:!1,stormUntil:0,wasError:!1,todosDone:0},Q=(F,P)=>F[(P??Math.floor(J()*1e6))%F.length]??"",V=(F,P)=>F.replace(/\{(\w+)\}/g,(W,R)=>{let b=P?.[R];return b==null?"":String(b)}),j=(F)=>{if(Z.lastActiveAt==null)Z.lastActiveAt=F,Z.lastQuipAt=F-5000},X=(F,P,W=4200,R="event")=>{j(P),Z.quip={text:F,until:P+W,kind:R},Z.lastQuipAt=P},U=(F)=>Z.quip!=null&&Z.quip.until>F,G=(F)=>U(F)&&Z.quip?.kind==="event",Y=(F,P,W)=>{Z.glance={dir:F,until:P+W}},K=(F,P,W)=>{Z.fx.push({kind:F,until:P+W,seed:Math.floor(J()*9973)})},z=(F)=>{Z.stormUntil=Math.max(Z.stormUntil,F+5000+Math.floor(J()*2000))};function D(F,P,W){if(j(W),W<Z.nextObserveAt)return;let R=P==="del"?f7:v7,b=null;for(let x of F.split(/\r?\n/)){let C=R.find(([d])=>d.test(x));if(C){b=C[1];break}}if(b==null)return;if(Z.nextObserveAt=W+5500,G(W))Z.pendingObserve={text:b,at:W};else X(b,W,3200,"observe")}function H(F,P){if(j(P),Z.lastActiveAt=P,F==="fail-line")X(Q(Z0.failLine),P,2600),K("shiver",P,640),z(P);else if(F==="pass-line")K("bounce",P,400);else if(F==="risk")X(Q(Z0.risk),P,3600,"observe")}function N(F,P){if(j(P),F===Z.lastSuggest)return;if(Z.lastSuggest=F,P<Z.nextSuggestAt||G(P))return;X(`${F}? sure.`,P,2200,"observe"),Z.nextSuggestAt=P+4000}function M(F,P,W){if(j(W),Z.lastActiveAt=W,F==="todo_done"){let x=Number(P?.d??Z.todosDone+1),C=P?.n;Z.todosDone=x;let d=C==null?Z0.todo.filter((u)=>!u.includes("{n}")):Z0.todo;X(V(Q(d),{d:x,n:C}),W,2600,"observe"),K("bounce",W,240);return}if(F==="tool_fail"){X(V(Q(Z0.error),P),W),K("shiver",W,640),z(W);return}if(!u7.has(F)&&G(W)&&(F===Z.lastEventKind||W-Z.lastQuipAt<x7)){if(u$.includes(F))Y(1,W,2600);return}if(Z.lastEventKind=F,F==="poke")Z.pokes++;let R=Z0[F],b=F==="poke"?Q(R,Z.pokes-1):Q(R);if(X(V(b,P),W,F==="permission"?120000:F==="done"||F==="pass"?6000:4200),F==="pass"||F==="done")K("sparkle",W,3600);if(F==="allowed")K("hearts",W,1800);if(F==="poke")K("bounce",W,800),K("hearts",W,1800),Y(0,W,1500);if(F==="theme")K("sparkle",W,1400);if(F==="error"||F==="fail")z(W);if(g7.includes(F))Z.stormUntil=0;if(u$.includes(F))Y(1,W,2600);if(F==="start")Z.saidLong=!1,Z.lastSuggest=""}function O(F){M("poke",void 0,F)}let _=(F)=>1+Math.floor(Math.sqrt(Math.max(0,F)/1500));function E(F,P){if(F.state==="ERROR"||P<Z.stormUntil)return"furious";if(F.waiting||F.state==="WAITING")return"patient";if(F.delegating||F.state==="DELEGATING")return"conducting";if(F.state==="EDITING")return"focused";if(F.state==="RUNNING"||F.state==="TESTING")return"zapping";if(F.state==="SUCCESS")return"sunny";let W=Math.max(Z.lastActiveAt??P,F.activeAt);if(!F.running&&P-W>=45000)return"sleepy";return"humming"}let I=(F)=>U(F)||F<Z.stormUntil||Z.fx.some((P)=>P.until>F);function T(F,P){if(j(F),Z.fx=Z.fx.filter((b)=>b.until>F),Z.glance&&Z.glance.until<=F)Z.glance=null;if(Z.quip&&Z.quip.until<=F)Z.quip=null;if(Z.pendingObserve!=null){if(F-Z.pendingObserve.at>1e4)Z.pendingObserve=null;else if(!G(F))X(Z.pendingObserve.text,F,3200,"observe"),Z.pendingObserve=null}if(!P)return;let W=P.state==="ERROR";if(W&&!Z.wasError)z(F);if(Z.wasError=W,P.state==="SUCCESS")Z.stormUntil=0;let R=E(P,F)==="sleepy";if(!P.running&&!P.booting&&!U(F)&&F-Z.lastQuipAt>(R?16000:11000)){let b=R?Z0.sleep:P.changed>8?[...Z0.idle,"{changed} modified files. busy branch."]:Z0.idle;X(V(Q(b),{changed:P.changed}),F,3800,"ambient")}if(P.running&&P.runStartedAt!=null&&F-P.runStartedAt>25000&&!Z.saidLong&&!U(F))Z.saidLong=!0,X(Q(Z0.long),F,3500,"ambient")}return{state:Z,observe:D,react:H,event:M,suggest:N,poke:O,say:X,level:_,mood:E,animating:I,tick:T}}var n0,K0,x$,N8="{};=()<>:.",Z0,B5=($)=>Z0.thinking[Math.floor(Math.max(0,$)/4000)%Z0.thinking.length]??"thinking",v7,f7,u$,g7,u7,x7=1500;var b0=k(()=>{n0=[" \u256D\u2500\u256E\u256D\u2500\u2500\u256E\u256D\u2500\u256E "," \u256D\u256F \u2570\u256F \u2570\u256F \u2570\u2500\u256E "," \u256D\u256F \u2570\u256E "," \u2502 \u2502 "," \u2570\u256E \u256D\u256F "," \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F "],K0={EYE_L:6,EYE_R:12,MOUTH:9,EYE_ROW:3,MOUTH_ROW:4},x$=n0.map(($)=>{let J=$.search(/\S/),Z=$.length-1-[...$].reverse().join("").search(/\S/);return[J,Z]}),Z0={start:["on it.","let's see what we've got.","rolling in."],glob:["sniffing for {q}\u2026","where is {q}\u2026","looking for {q}."],grep:["found {n}.","{n}. noted."],fetch:["fetching {f}.","off to {f}.","knocking on {f}."],crew:["checking on {a}.","{a}, how's it going.","peeking at {a}."],tinker:["poking at {f}.","a look at {f}.","fiddling with {f}."],read:["reading {f}.","let me skim {f}."],plan:["{n} steps. easy.","got a plan. {n} steps."],permission:["your call \u25B8","need a nod from you."],allowed:["thanks \u2665","\u2665 on it."],denied:["okay, hands off.","fair. stopping."],edit:["raining code on {f}.","sprinkling {f}.","a light shower over {f}."],write:["a fresh {f}.","new file, new weather: {f}."],remove:["blowing {f} away.","bye, {f}."],run:["thunder time.","rumble rumble.","charging up\u2026"],pass:["{r}. sunny skies.","clear skies \u263C {r}.","{r}. told you."],fail:["{r}. GRR.","red. i hate red.","{r}. fixing it. NOW."],error:["storm's here.","who wrote THAT.","no. no no no.","grr."],done:["all clear \u263C","nice work, us.","sun's out."],stopped:["okay, stopping.","pausing the rain."],fresh:["fresh sky.","clean slate."],theme:["ooh, new sky.","i like this light."],poke:["hi.","hehe.","\u266A","that tickles.","yes?"],idle:["humming \u266A","ready when you are.","the files look calm.","nice day for a refactor.","\u266A \u266A"],sleep:["zzz\u2026","\u2026","mm."],todo:["one down.","{d}/{n}. moving.","check.","that's {d} of {n}."],long:["still going. hang tight.","big one. i'm here."],failLine:["GRR.","red. RED.","that one leaked. grr."],risk:["hm. that one's risky.","i'd look at that twice."],spawn:["sending {a} in.","{a}, you're up.","go, {a}. i'll watch."],laneDone:["{a} is back \xB7 {r}.","{a}: {r}. nice.","{a} done. {r}."],laneFail:["{a} tripped \xB7 {r}.","hm. {a} didn't make it."],merge:["stitching it together.","all hands back. merging."],thinking:["thinking","brewing","gathering","mulling","sifting","condensing","circling","weighing"]},v7=[[/httpOnly/i,"httpOnly. good call."],[/secure:\s*true/,"secure cookie \u2665"],[/sameSite/i,"sameSite too. tidy."],[/TODO|FIXME/,"a TODO. i'll remember it."],[/console\.log/,"leftover console.log?"],[/throw new/,"throwing. brave."],[/try \{/,"try\u2026 fingers crossed for the catch."],[/catch \(/,"\u2026and a catch. phew."],[/^import .* from/,"imports rolling in."],[/^export (default |async )?(function|const|class)/,"a new export."],[/status\(4\d\d\)/,"a 4xx. firm but fair."],[/status\(5\d\d\)/,"a 5xx? hope that's on purpose."],[/sqlite|\bdb\.|prepare\(/i,"talking to the database."],[/crypto|randomBytes|timingSafeEqual/,"crypto. spooky."],[/\b(test|it|describe)\(/,"a test! my favorite."],[/req\.ip|forwarded/i,"who's calling? checking the ip."],[/SIGTERM|process\.exit|\.close\(/,"graceful. i like graceful."],[/rateLimit|429/,"rate limits. slow down, world."],[/csrf|verifyState|\bstate\b/i,"state check. no sneaky redirects."],[/expires|maxAge/i,"expiry set. nothing lives forever."],[/cookie/i,"cookies. i want one."],[/redirect\(/,"and\u2026 redirect."],[/async /,"async. i'll wait."]],f7=[[/legacy/i,"goodbye, legacy."],[/new Map\(\)/,"bye, in-memory Map."],[/console\.log/,"console.log, gone. clean."],[/token\.access_token/,"raw token in a cookie, gone. good."]];u$=["read","edit","write","plan","grep","glob","run","remove","spawn","laneDone","fetch","crew","tinker"],g7=["done","pass","start","fresh","stopped"],u7=new Set(["start","done","stopped","pass","fail","error","failLine","denied","permission","allowed","poke","theme","fresh","laneDone","laneFail","merge","risk","long","todo","todo_done","tool_fail"])});function i$($,J){let Z=$.split(`
|
|
@@ -22,4 +22,4 @@ import{s as O5,u as h9,v as bJ,w as N1}from"./main-8c1tbazx.js";import{$a as K8,
|
|
|
22
22
|
`)}copy($){let J=this.selectedText();if(J==="")return;this.d.write(`\x1B]52;c;${Buffer.from(J,"utf8").toString("base64")}\x07`),o0(this.d.state,`copied ${[...J].length} characters to the clipboard`,$)}}var s4=($,J,Z)=>$>=Z.x&&$<Z.x+Z.w&&J>=Z.y&&J<Z.y+Z.h;var t4=k(()=>{l0();J0()});function e4($,J,Z){let Q=J.card;if(Q===null||Q===void 0)return[];if($.w<4||$.h<3)return[];let V=a($),{cardH:j,msgH:X,maxDetail:U}=q0(V,J);if(j<=0)return[];let G=L8(Q,V.w,U,Z),Y=G.length-j,K=(E)=>{let I=E-Y;return I<0||I>=j?null:V.y+X+I},z=[];if(Q.kind==="approval"){let E=K(G.length-1);if(E===null)return[];let I=V.x+y8;for(let[T,F]of Q.verdicts.entries()){let P=f(I8[F]??String(F))+f8;if(I+P>V.x+V.w)break;z.push({rect:{x:I,y:E,w:P,h:1},index:T,confirm:!0}),I+=P+J1}return z}let D=Q.prompt.options??[],{q:H,freeRows:N}=e0(Q,V.w);if(y5(Q,V.w,U).total!==1+H+D.length+N+2)return[];let O=(E,I,T,F,P=1)=>{let W=K(E);if(W!==null&&T>0)z.push({rect:{x:V.x+y8,y:W,w:T,h:P},index:I,confirm:F})},_=Math.max(0,V.w-y8);for(let[E,I]of D.entries())O(1+H+E,E,Math.min(f(I)+f8,_),!0);if(N>0){let E=1+H+D.length,I=Math.max(E,Y),T=E+N-I;if(T>0)O(I,D.length,_,!1,T)}return O(1+H+D.length+N,D.length+(N>0?1:0),Math.min(f(S8)+f8,_),!0),z}var f8=2,J1=2,y8=2;var $J=k(()=>{$5();$0();D0()});function JJ($,J,Z){if($===null||Z.length===0)return[];let Q=a($);if(Q.w<=0||Q.h<=0)return[];let V=[];for(let j=0;j<Q.h;j++){let X=J.files.scroll+j;if(X>=Z.length)break;V.push({rect:{x:Q.x,y:Q.y+j,w:Q.w,h:1},index:X})}return V}var ZJ=k(()=>{$0()});function Z1($,J,Z,Q){let V=Math.max(0,Z-Q),j=$.trackH-$.thumbH;if(j<=0||V===0)return 0;let X=Math.max($.trackY,Math.min($.trackY+j,$.thumbY+J));return Math.round((X-$.trackY)/j*V)}function g8($,J,Z,Q){if(!$.visible)return null;return{rect:x9($),onClick:()=>{},onDrag:(V,j)=>Q(Z1($,j,J,Z))}}function QJ($,J,Z,Q){if(J.stick)return;let{max:V}=P0($.messages,J,Z,Q);if(J.msgScroll>=V)J.stick=!0,J.msgScroll=V}function VJ($,J,Z,Q,V,j){let X=[];{let Y=a($.messages),{msgH:K}=q0(Y,Z),{offset:z,max:D}=P0($.messages,Z,Q,V),H=D+K,N=g8(x0(Y.x+Y.w-1,Y.y,K,H,K,z),H,K,(M)=>{Z.msgScroll=M,Z.stick=M>=D});if(N)X.push(N)}let U=$.files??(J==="files"?$.code:null);if(U){let Y=a(U),K=g8(x0(Y.x+Y.w-1,Y.y,Y.h,j.length,Y.h,Z.files.scroll),j.length,Y.h,(z)=>{Z.files.scroll=z,Z.files.cursor=Math.max(z,Math.min(Z.files.cursor,z+Y.h-1))});if(K)X.push(K)}let G=Z.code;if(J==="code"&&(G.mode==="code"||G.mode==="diff"||G.mode==="search")){let Y=a($.code);if(Y.w>=V0+2){let K=W5(Z,Y.w-V0-2),z=d0($.code,Z),D=g8(x0(Y.x+Y.w-V0-1,Y.y,Y.h,K,Y.h,z),K,Y.h,(H)=>{G.scroll=H});if(D)X.push(D)}}return X}var jJ=k(()=>{_5();$5();$0();p0()});function XJ($,J,Z,Q){let V=[],j=T8(J,Z,Q),X=$.x+$.w-2-w(j.segs);if(j.badge)V.push({rect:{x:X+j.badge[0],y:$.y,w:j.badge[1],h:1},onClick:()=>{},key:{type:"key",name:"b",ctrl:!0}});let U=R8(J,Z),G=$.x+$.w-2-w(U.segs),Y=$.y+$.h-1;if(U.effort)V.push({rect:{x:G+U.effort[0],y:Y,w:U.effort[1],h:1},onClick:()=>{J.input.text="/effort ",J.input.cur=J.input.text.length,J.input.sgSel=0,J.focus="messages"}});return V.push({rect:{x:G+U.theme[0],y:Y,w:U.theme[1],h:1},onClick:()=>{},key:{type:"key",name:"t",ctrl:!0}}),V}var UJ=k(()=>{k8();H0()});function GJ($,J,Z,Q){let V=a($);if(V.w<3||V.h<1)return[];let{msgH:j}=q0(V,J);if(j<=0)return[];let X=f5(J,V.w,Z,Q),{offset:U}=P0($,J,Z,Q),G=[];for(let Y=0;Y<j;Y++){let K=X[U+Y];if(!K?.path)continue;let z=V.x+(K.indent??0);G.push({rect:{x:z,y:V.y+Y,w:Math.max(1,V.w-(K.indent??0)-1),h:1},path:K.path})}return G}var YJ=k(()=>{$5();$0()});class u8{d;screen=null;timer=null;dueAt=0;_pace=A0;ambientDue=-1/0;unsubs=[];carry="";held="";holdTimer=null;dirty=!0;lastRender=-1/0;L;hits=[];drag={zone:null,y0:0};selection;rows=[];frames=0;constructor($){this.d=$;let{cols:J,rows:Z}=$.io.size();this.L=a5(J,Z,this.layoutOpts()),this.selection=new v8({state:$.state,messagesRect:()=>this.L.messages,hits:()=>this.hits,screenText:()=>this.screen?.toText()??null,write:(Q)=>{$.io.write(Q)},markDirty:()=>this.markDirty(),forward:(Q,V)=>this.forward(Q,V)})}layoutOpts(){return{pet:p$(this.d.io.env)}}get active(){return this.timer!==null}get layout(){return this.L}get pace(){return this._pace}markDirty(){this.dirty=!0,this.wake()}frameText(){return this.screen?.toText()??""}prepare(){let{cols:$,rows:J}=this.d.io.size();this.screen=new Z5(this.d.io,$,J,{truecolor:this.d.truecolor}),this.render(this.d.clock(),!1)}start($,J=!1){if(this.timer)return;let{cols:Z,rows:Q}=this.d.io.size(),V=$;this.screen=new Z5({write:(j)=>{let X=V;if(V=void 0,X&&J){let U=String.fromCharCode(27);this.d.io.write(`${U}[?2026h`);try{X(),this.d.io.write(j)}finally{this.d.io.write(`${U}[?2026l`)}}else X?.(),this.d.io.write(j)}},Z,Q,{truecolor:this.d.truecolor}),this.unsubs.push(this.d.io.onInput((j)=>this.feed(j))),this.unsubs.push(this.d.io.onResize((j,X)=>{this.screen?.resize(j,X),this.selection.cancel(),this.markDirty()})),this._pace=A0,this.arm(A0),this.render(this.d.clock())}arm($){if(this.timer!==null)clearTimeout(this.timer);this.dueAt=performance.now()+$,this.timer=setTimeout(()=>this.fire(),$)}fire(){let $=this.timer;if(this.tick(),this.timer===$)this.timer=null,this.arm(this._pace)}wake(){if(this.timer!==null&&this.dueAt-performance.now()>A0)this.arm(A0)}stop(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(this.holdTimer)clearTimeout(this.holdTimer),this.holdTimer=null;this.held="",this.selection.cancel();for(let $ of this.unsubs)$();this.unsubs=[]}feed($){if(this.holdTimer)clearTimeout(this.holdTimer),this.holdTimer=null;let J=this.held+$;if(this.held="",J.endsWith("\x1B")){this.held=J,this.holdTimer=setTimeout(()=>{this.holdTimer=null,this.flushInput()},U1);return}this.parse(J)}flushInput(){if(this.holdTimer)clearTimeout(this.holdTimer),this.holdTimer=null;let $=this.held;if(this.held="",$)this.parse($)}parse($){let J=G$($,this.carry);this.carry=J.rest;for(let Z of J.events)this.dispatch(Z);if(this.timer!==null&&J.events.length>0)this.render(this.d.clock())}dispatch($){let J=this.d.clock();if(this.markDirty(),this.d.beforeInput?.($,J))return;if($.type==="key"&&this.selection.active)this.selection.cancel();if($.type==="mouse"&&this.selection.onMouseEvent($,J))return;this.forward($,J)}forward($,J){let Z=this.d.keyCtx(),Q={layout:this.L,hooks:Z.hooks,local:Z.local,hits:this.hits,rows:this.rows,fuzzy:Y0,drag:this.drag};z8(this.d.state,$,Q,J),this.d.afterInput?.($,J)}moving($){let J=this.d.state,Z=this.d.pet.state;return J.running||J.card!==null||J.files.touched.size>0||$-J.bootAt<X1||$<Z.stormUntil||Z.fx.some((Q)=>Q.until>$)}nextAmbient($){let J=this.d.state,Z=this.d.pet.state,Q=1/0;if(J.card===null&&J.activity.state==="IDLE")Q=Math.min(Q,(Math.floor($/KJ)+1)*KJ);if(this.L.pet)Q=Math.min(Q,(Math.floor($/g5)+1)*g5);if(Z.quip&&Z.quip.until>$)Q=Math.min(Q,Z.quip.until);if(Z.glance&&Z.glance.until>$)Q=Math.min(Q,Z.glance.until);for(let V of J.toasts)if(V.until>$)Q=Math.min(Q,V.until);if($<J.escUntil)Q=Math.min(Q,J.escUntil);return Q}tick(){let $=this.d.clock();if(this.d.onTick?.($),this.dirty||this.moving($)||$>=this.ambientDue||$-this.lastRender>=Q1)this.render($);this._pace=this.nextPace($)}nextPace($){if(this.dirty||this.moving($))return this.ambientDue=-1/0,A0;return this.ambientDue=this.nextAmbient($),Math.min(V1,Math.max(A0,this.ambientDue-$))}render($,J=!0){let Z=this.screen;if(!Z)return;let Q=this.d.state,V=this.d.theme(),j=this.d.pet;Z.begin(V.bg),this.rows=u5(Q,$);let X=[],U=o4(Z,Q,V,$,{layout:a5,layoutOpts:this.layoutOpts(),painters:{code:(_,E,I,T,F)=>n9(_,E,I,T,F,{tokenize:s9}),messages:N4,pet:(_,E,I,T,F)=>O4(_,E,j,I,T,F)}});if(this.L=U,U.pet)X.push({rect:U.pet,onClick:()=>j.poke(this.d.clock())});for(let _ of XJ(U.frame,Q,V,$))X.push(_);let G=O0(U,Q);for(let _ of T$(Z,U,Q,V))X.push({rect:_.rect,onClick:()=>{Q.page=_.page,Q.focus=_.page==="files"?"files":"code"}});let Y={x:U.code.x+2,y:U.code.y+1,w:U.code.w-9,h:U.code.h-2};if(G==="code"&&Q.code.mode==="agents"&&!Q.code.laneOpen)for(let{index:_,rect:E}of o5(Y,Q).cells)X.push({rect:E,onClick:()=>{Q.code.lane=_,Q.focus="code"}});let K=U.files??(G==="files"?U.code:null);for(let _ of JJ(K,Q,this.rows))X.push({rect:_.rect,onClick:()=>{Q.focus="files",Q.files.cursor=_.index},key:{type:"key",name:"enter"}});for(let _ of VJ(U,G,Q,V,$,this.rows))X.push(_);QJ(U,Q,V,$);for(let _ of GJ(U.messages,Q,V,$))X.push({rect:_.rect,onClick:()=>this.d.keyCtx().local.openFile(_.path)});for(let _ of e4(U.messages,Q,V))X.push({rect:_.rect,onClick:()=>{if(Q.card)Q.card.selected=_.index},..._.confirm?{key:{type:"key",name:"enter"}}:{}});let z=this.selection.highlight();if(z)Z.tint(z.x,z.y,z.w,z.h,h(V.bg,V.accent,0.35));qJ(Z,U.messages,Q,B0(Q,Q.files.paths,Y0).slice(0,j1),V,X);let D=zJ(Z,U,V,Q,Y0,X),H=H9(Z,U,V,Q,Y0,X),N=v9(Z,U,V,Q,X),M=F9(Z,U,V,Q,X);if(Q.help)DJ(Z,U,V,Q,X);this.hits=X,Q.code.scroll=Q.code.mode==="agents"?r5(Y,Q):d0(U.code,Q),Q.msgScroll=P0(U.messages,Q,V,$).offset;let O=Q.palette?D:Q.market?H:Q.context?N:Q.wizard?M:Q.help?null:H4(U.messages,Q);if(J)Z.flush(O),this.frames++;this.dirty=!1,this.lastRender=$}}var A0=40,Q1=170,V1=2000,KJ=500,j1=8,X1=600,U1=20;var HJ=k(()=>{S0();_5();$5();F4();h0();r4();l0();H8();H0();J0();X0();z5();H5();u0();b0();D0();t4();Q0();$J();ZJ();jJ();UJ();YJ();T5()});class d8{d;wanted;timer=null;deferred=new Set;inFlight=!1;lastScanAt=-1/0;hasGit=!1;stopped=!1;ac=new AbortController;live=null;constructor($,J){this.d=$;this.wanted=J?"full":null}afterMutation(){if(this.wanted!==null||this.hasGit||this.inFlight)this.wanted="full"}afterAttach(){if(this.wanted!==null||this.lastScanAt!==-1/0)this.wanted="full"}get scanning(){return this.inFlight}prepare(){if(this.stopped)return Promise.resolve();if(this.timer)clearTimeout(this.timer),this.timer=null;if(!this.live)this.live=this.scan();return this.live}onTick($,J){if(this.wanted===null&&this.hasGit&&!J&&$-this.lastScanAt>=p8)this.wanted="status";if(this.wanted!==null&&!this.inFlight&&!this.timer&&!this.stopped)this.timer=setTimeout(()=>{this.timer=null,this.live=this.scan()},0)}async scan(){if(this.stopped||this.wanted===null)return;let $=this.wanted,J=this.d.state;this.wanted=null,this.lastScanAt=this.d.clock(),this.inFlight=!0;let Z=(Q,V)=>this.d.git(Q,V,this.ac.signal);try{if($==="full"){let Q=await U4(J.cwd,Z);if(this.stopped)return;x8(J,Q.paths,Q.statuses),J.repo.branch=Q.branch,this.hasGit=Q.git}else{let Q=await G4(J.cwd,Z);if(this.stopped)return;if(Q)x8(J,J.files.paths,Q)}this.d.dirty()}finally{this.inFlight=!1}}scheduleDiff($,J,Z,Q){this.defer(async()=>{let V=await A8(this.d.state.cwd,J,Z,this.d.git,Q);if(this.stopped||!V)return;if(V.base!=="head")$.add=V.add,$.del=V.del;this.show(J,V,!0)})}loadDiff($){this.defer(async()=>{let J=await Y4(this.d.state.cwd,$,this.d.git);if(this.stopped)return;if(J)this.show($,J,!1);else this.d.state.code.diff=null,this.d.dirty()})}show($,J,Z){let Q=this.d.state;if(Q.code.diff={file:$,hunks:J.hunks,add:J.add,del:J.del,...J.base?{base:J.base}:{}},Z)Q.code.mode="diff";this.d.dirty()}defer($){if(this.stopped)return;let J=setTimeout(()=>{if(this.deferred.delete(J),!this.stopped)$()},0);this.deferred.add(J)}stop(){if(this.stopped=!0,this.timer)clearTimeout(this.timer),this.timer=null;for(let $ of this.deferred)clearTimeout($);return this.deferred.clear(),this.ac.abort(),this.live??Promise.resolve()}}var p8=5000;var h8=k(()=>{J0();E8()});var TJ={};G1(TJ,{SextantRenderer:()=>LJ,IDLE_SCAN_MS:()=>p8});import{homedir as w8}from"os";import{basename as NJ,join as q1}from"path";class LJ{state;theme;io;clock;pet;loop;repo;applyEv;truecolor;hooks=null;ctx=null;unsubTasks=null;started=!1;stopped=!1;mouseTracking=!0;busy=!1;dropNotes=0;cards;liveCalls=new Map;before=new Map;editOps=new Map;loadedFile=null;planLoaded=!1;todoDone=0;fetchWizardModels(){let $=this.state.wizard;if(!$)return;$.modelsLoading=!0,this.loop.markDirty();let J=$.providers[$.selected]?.key??"";(this.ctx?.wizardModels?.(J)??Promise.resolve([])).then((Z)=>{if(!this.state.wizard)return;if(e5(this.state.wizard,Z),Z.length===0)this.state.wizard.error="the endpoint listed no models \u2014 type the id by hand (it still pins)";this.loop.markDirty()}).catch(()=>{if(!this.state.wizard)return;this.state.wizard.modelsLoading=!1,this.state.wizard.error="the model list could not be read \u2014 type the id by hand",this.loop.markDirty()})}constructor($){this.io=$.io,this.clock=$.clock??Date.now,this.truecolor=$.truecolor??!0;let J=d5($.theme??"")?$.theme:"night";this.theme=h5(J);let Z=$.cwd??process.cwd();this.state=_J({cwd:Z,repo:{name:NJ(Z)||Z,branch:null},version:OJ.version,theme:J,mode:"act",yolo:!1,commands:[],now:this.clock()}),this.pet=h$({name:$.pet}),this.applyEv=PJ(),this.repo=new d8({state:this.state,clock:this.clock,git:$.git?Q$($.git):j0,dirty:()=>this.loop.markDirty()},$.scan??!0),this.cards=new _8({state:this.state,dirty:()=>this.loop.markDirty(),stopped:()=>this.stopped,onApprovalOpen:()=>this.pet.event("permission",void 0,this.clock()),onAllowed:()=>this.pet.event("allowed",void 0,this.clock())}),l9(X9),this.loop=new u8({io:this.io,clock:this.clock,state:this.state,theme:()=>this.theme,pet:this.pet,truecolor:this.truecolor,keyCtx:()=>({hooks:this.hooks??D1,local:this.local}),beforeInput:(Q,V)=>this.beforeInput(Q,V),afterInput:(Q,V)=>this.afterInput(Q,V),onTick:(Q)=>this.onTick(Q)})}frameText(){return this.loop.frameText()}get active(){return this.loop.active}get frames(){return this.loop.frames}get themeName(){return this.theme.name}tick(){this.loop.tick()}flushInput(){this.loop.flushInput()}setMouse($){if(this.mouseTracking===$)return;if(this.mouseTracking=$,this.terminalEntered&&!this.stopped)this.io.write($?q$():z$())}get mouse(){return this.mouseTracking}start($,J){if(this.started)return;this.started=!0,this.hooks=$,this.state.bootAt=J?.animate===!1?-1/0:this.clock(),J?.beforeFirstRender?.();let Z=()=>{if(this.stopped)return;this.loop.start(()=>{J?.onReveal?.(),this.terminalEntered=!0,this.io.enterRaw(),this.io.write(Y$(this.mouseTracking))},J?.beforeReveal!==void 0)};if(!J?.beforeReveal){Z();return}this.loop.prepare();let Q=this.repo.prepare().catch(()=>{if(!this.stopped)this.addSystemNote("initial file list unavailable \u2014 file tools remain available","warn")});return Promise.all([Q,J.beforeReveal()]).then(Z)}terminalEntered=!1;drained=null;drain(){return this.drained??this.repo.stop()}stop(){if(this.stopped)return;this.stopped=!0,this.loop.stop(),this.drained=this.repo.stop(),this.unsubTasks?.(),this.unsubTasks=null,this.cards.settleAll(),this.restoreTerminal(),this.hooks=null}restoreTerminal(){if(!this.terminalEntered||this.restored)return;this.restored=!0;try{this.io.write(K$())}catch{}try{this.io.leaveRaw()}catch{}}restored=!1;attach($){this.ctx=$;let J=this.state;if(J.cwd=$.cwd,J.repo.name=NJ($.cwd)||$.cwd,$.petName)this.pet.state.name=$.petName.slice(0,14);this.unsubTasks?.();let Z=()=>{let Q=$.tasks.list();if(Q.length>J.crew.length)J.code.lane=Q.length-1;SJ(J,Q),this.loop.markDirty()};Z(),this.unsubTasks=$.tasks.subscribe((Q)=>{Z(),r$(this.pet,Q,this.clock())}),this.repo.afterAttach(),this.refreshPlan()}onEvent($){let J=this.clock(),Z=this.state;if(this.applyEv(Z,$,J),o$(this.pet,$,this.liveCalls,Z.cwd,J),this.dropNotes+=n$($),$.type==="tool_execution_start"&&$.tool==="edit")this.editOps.set($.callId,Q4($.args));if($.type==="tool_execution_end"||$.type==="tool_call_failed"){let Q=this.rowOf($.callId),V=Q?.path!==void 0?this.before.get(Q.path):void 0;if(Q?.path!==void 0)this.before.delete(Q.path);let j=this.editOps.get($.callId)??[];if(this.editOps.delete($.callId),Q&&(Q.verb==="edit"||Q.verb==="write"||Q.verb==="remove"||Q.verb==="run")){if(this.repo.afterMutation(),Q.path!==void 0&&Q.path===Z.code.file)Z.code.content=null;if(this.loadedFile=null,$.type==="tool_execution_end"&&$.ok&&Q.path!==void 0&&(Q.verb==="edit"||Q.verb==="write"))this.repo.scheduleDiff(Q,Q.path,V,j)}}this.loop.markDirty()}previewInCodePanel($,J,Z){if($!=="edit"&&$!=="write")return null;let Q=F8(J).path;if(typeof Q!=="string"||!Q)return null;let V=b5(this.state.cwd,Q);this.before.set(V,r0(this.state.cwd,V));let j=Z?i9(Z):[];if(!j.length)return V;let X=j.flatMap((U)=>U.rows);return this.state.code.diff={file:V,hunks:j,add:X.filter((U)=>U.op==="+").length,del:X.filter((U)=>U.op==="-").length},this.state.code.mode="diff",V}setCommands($){this.state.commands=$.map((J)=>({name:J.name,description:J.description,...J.choices?{choices:J.choices}:{},...J.choicesThen?{choicesThen:J.choicesThen}:{}})),this.loop.markDirty()}addUser($){this.push(i$($,this.clock()))}addSystemNote($,J="info"){if(this.dropNotes>0){this.dropNotes--;return}if(this.push({kind:"system",text:$,tone:J}),J!=="info"||!$.includes(`
|
|
23
23
|
`)&&$.length<=MJ)this.toast($.split(`
|
|
24
24
|
`)[0]??"",J)}beginAssistant(){if(this.busy)return z1;let $={kind:"assistant",text:"",streaming:!0};return this.push($),{append:(J)=>{$.text+=J,this.loop.markDirty()},done:()=>{$.streaming=!1,this.loop.markDirty()}}}toolStart($,J,Z){if(this.busy)return;this.push(W8($,J,Z,this.state.cwd))}toolUpdate($,J){if(this.busy)return;let Z=this.rowOf($);if(Z)Z.detail=t0(J,80),this.loop.markDirty()}toolEnd($,J,Z,Q){if(this.busy)return;let V=this.rowOf($);if(!V)V=W8($,"tool","{}",this.state.cwd),this.push(V);V.running=!1,V.ok=J,V.ms=Q;let j=WJ({verb:V.verb},V.tool,J,Z);if(j.detail)V.detail=j.detail;this.loop.markDirty()}askApproval($,J,Z){let Q=this.previewInCodePanel($,J,Z),V=this.cards.approval($,J,Z);if(Q!==null)V.then((j)=>{if(j==="deny")this.before.delete(Q)});return V}pickOne($,J){return this.cards.pick($,J)}askQuestion($,J){return this.cards.question($,J)}clearTranscript(){this.state.messages=[],this.state.stick=!0,this.pet.event("fresh",void 0,this.clock()),this.loop.markDirty()}prefillEditor($){let J=this.state.input;J.text=$,J.cur=$.length,J.sgSel=0,J.histIdx=-1,this.state.focus="messages",this.loop.markDirty()}setBusy($,J){let Z=this.state,Q=this.clock();if(this.busy=$,$){if(Z.running=!0,J)Z.activity.label=J.replace(/\u2026$/,"")}else{if(this.dropNotes=0,Z.running){if(Z.running=!1,Z.activity.startedAt!==null&&Z.activity.endedAt===null)Z.activity.endedAt=Q;if(Z.activity.state!=="SUCCESS"&&Z.activity.state!=="ERROR")Z.activity.state="IDLE",Z.activity.label="stopped";for(let V of Z.messages)if(V.kind==="tool"&&V.running)V.running=!1,V.ok=!1,V.detail??="interrupted";this.pet.event("stopped",void 0,Q)}Z.escUntil=0,delete Z.ctrlCUntil}this.loop.markDirty()}setStatus($){let J=this.state;if(J.yolo=$.yolo,J.acceptEdits=$.permission==="accept-edits",$.mode)J.mode=$.mode;let Z=this.ctx?.usage?.();EJ(J,{provider:$.provider,model:$.model,turns:$.turns,tokensIn:$.tokensIn,tokensOut:$.tokensOut,...$.effort!==void 0?{effort:$.effort}:{},contextTokens:Z?.contextTokens??0,contextWindow:this.ctx?.contextWindow(),costUsd:Z?Z.costUsd:null}),this.refreshPlan(),this.loop.markDirty()}push($){this.state.messages.push($),this.state.stick=!0,this.loop.markDirty()}rowOf($){for(let J=this.state.messages.length-1;J>=0;J--){let Z=this.state.messages[J];if(Z.kind==="tool"&&Z.callId===$)return Z}return}toast($,J="info"){AJ(this.state,t0($.trim(),MJ),this.clock(),J),this.loop.markDirty()}refreshPlan(){if(!this.ctx)return;IJ(this.state,FJ(q1(this.ctx.sessionsDir,this.ctx.store().id)));let $=x5(this.state);if(this.planLoaded&&$.completed>this.todoDone)this.pet.event("todo_done",{d:$.completed,n:$.total},this.clock());this.planLoaded=!0,this.todoDone=$.completed}local={setTheme:($)=>{this.theme=h5($),this.state.theme=$,this.toast(`theme \xB7 ${$}`),this.pet.event("theme",void 0,this.clock())},attachImage:($)=>this.ctx?.attachImage?.($),setMode:($)=>{if($==="diff"&&this.state.code.file)this.repo.loadDiff(this.state.code.file)},openFile:($)=>{this.state.code.content=r0(this.state.cwd,$),this.state.code.hl=null,this.loadedFile=$},toast:($)=>this.toast($),openMarket:()=>{q9(this.state,[],{kind:"loading"}),this.loop.markDirty(),S9(this.state.cwd,w8()).then(($)=>{if(this.state.market)this.state.market.rows=$.rows,this.state.market.status=$.status,this.state.market.notes=$.notes,this.loop.markDirty()}).catch(($)=>{if(this.state.market)this.state.market.status={kind:"error",reason:$ instanceof Error?$.message:String($)},this.loop.markDirty()})},openWizard:()=>{let $=this.ctx?.wizardProviders?.();if(!$||$.length===0){this.toast("no provider table behind this surface");return}O9(this.state,$),this.loop.markDirty()},openContext:()=>{let $=this.ctx?.model()??{provider:"unknown",model:"unknown"},J=this.ctx?.contextInputs?.();if(B9(this.state,{model:`${$.provider}/${$.model}`,raw:0,estimated:0,scale:{factor:1,measured:!1,note:"counting\u2026"},slices:[],images:0,billed:{input:0,output:0,cacheRead:0,cacheWrite:0},unpricedTurns:0,live:!1,tolerance:0.05}),this.loop.markDirty(),!J)return;g9({messages:J.messages,current:$,lookup:J.lookup,fixed:y9(J.runtime,$)}).then((Z)=>{if(!this.state.context)return;this.state.context={...Z,scroll:this.state.context.scroll},this.loop.markDirty()}).catch(()=>{})},marketPlan:($,J)=>{T9($,{scope:"user",cwd:this.state.cwd,home:w8()},J).then((Z)=>{let Q=this.state.market;if(!Q)return;if("error"in Z){this.toast(Z.error);return}Q.plan=Z,this.loop.markDirty()})},wizardRegister:($,J,Z)=>{let Q=this.state.wizard,V=this.ctx?.wizardRegister?.($,J,Z);if(!Q)return;if(P9(Q,V?.ok??!1,V?.error??"this surface cannot register endpoints \u2014 use rovecode provider add"),V?.ok)Q.providers[Q.selected]={key:$,label:`${$} \u2014 ${J}`,configured:!1};this.loop.markDirty()},wizardStoreKey:($,J)=>{let Z=this.state.wizard,Q=this.ctx?.wizardStoreKey?.($,J);if(!Z)return;if(A9(Z,Q?.ok??!1,Q?.error??"this surface cannot store keys \u2014 use rovecode auth set"),Q?.ok)this.fetchWizardModels();this.loop.markDirty()},wizardLoadModels:()=>{this.fetchWizardModels()},wizardActivate:($,J,Z)=>{let Q=this.state.wizard;if(!Q)return;let V=this.ctx?.wizardActivateModels?.($,J,Z);if(V?.ok)D5(this.state),this.toast(`connected \u2014 ${V.models!==void 0&&V.models.length>0?`${V.models.length} models active`:"all models live"}`);else Q.error=V?.error??"the model list could not be written";this.loop.markDirty()},wizardModel:($)=>{let J=this.state.wizard;if(!J)return;let Z=J.providers[J.selected]?.key??"";(this.ctx?.wizardModels?.(Z)??Promise.resolve([])).then((Q)=>{if(!this.state.wizard)return;if(Q.length===0)D5(this.state),this.toast(`connected \u2014 ${$} pinned by hand`);else e5(this.state.wizard,Q);this.loop.markDirty()}).catch(()=>{if(this.state.wizard)this.state.wizard.error="the model list could not be read \u2014 type the id instead",this.loop.markDirty()})},marketDocs:($)=>{L9($).then((J)=>{let Z=this.state.market;if(!Z||!J)return;let Q=Z.rows.find((V)=>V.kind===$.kind&&V.id===$.id);if(Q)Q.docs=J;this.loop.markDirty()})},marketInstall:($,J)=>{R9($,{scope:"user",cwd:this.state.cwd,home:w8()},J===!0?{local:!0}:{}).then(async(Z)=>{let Q=Z.text;if(Z.ok&&$.kind==="mcp"&&this.ctx?.reloadMcp)try{let j=await this.ctx.reloadMcp(),X=j.failed.find((G)=>j.added.includes(G.name));Q=Q.replace(/ \u00B7 restart rovecode[^\u00B7]*/,"");let U=j.skipped.length>0?` \xB7 ${j.skipped.join(" \xB7 ")}`:"";Q+=X?` \xB7 ${X.name} did not connect: ${X.error}`:j.added.length>0?` \xB7 connected as ${j.added.join(", ")} \u2014 no restart needed${U}`:U}catch{}let V=this.state.market;if(!V?.plan)return;V.plan.running=!1,V.plan.outcome={...Z,text:Q},this.loop.markDirty()})}};beforeInput($,J){let Z=this.state;if(this.cards.interceptKey($))return!0;if($.type==="key"&&$.ctrl&&$.name==="c"&&Z.running&&Z.ctrlCUntil!==void 0&&J<Z.ctrlCUntil)return this.hooks?.onExit(),!0;return!1}afterInput($,J){let Z=this.state;if(this.cards.afterKey(),$.type==="key"&&$.ctrl&&$.name==="c"&&Z.running)Z.ctrlCUntil=J+q8;if($.type==="key"&&!$.ctrl&&Z.input.text.startsWith("/")){let Q=B0(Z,Z.files.paths,Y0)[0];if(Q?.kind==="slash")this.pet.suggest(Q.label,J)}}onTick($){let J=this.state;if(J.code.file&&J.code.content===null&&this.loadedFile!==J.code.file)J.code.content=r0(J.cwd,J.code.file),this.loadedFile=J.code.file,this.loop.markDirty();let Z=this.ctx?.staged?.()??[];if(Z.length!==J.staged.length||Z.some((Q,V)=>Q!==J.staged[V]))J.staged=Z,this.loop.markDirty();this.repo.onTick($,J.running)}}var MJ=48,z1,D1;var RJ=k(()=>{Y1();K1();S0();z5();H5();k9();u0();u9();_5();h0();j8();l0();H8();J0();X0();b0();s$();$4();P8();E8();HJ();h8();Q0();O8();h8();z1={append(){},done(){}},D1={onSubmit(){},onInterrupt(){},onExit(){}}});N1();D0();p();import{createRequire as M1}from"module";import{join as O1}from"path";var F1=M1(import.meta.url),W1=new URL("../../vendor/pi-tui/src/terminal.ts",import.meta.url).href;function _1($=process.arch,J=process.execPath){return bJ(O1("native","win32","prebuilds",`win32-${$}`,"win32-console-mode.node"),{moduleUrl:W1,execPath:J})}function P1($=process.arch){if($!=="x64"&&$!=="arm64")return!1;for(let J of _1($))try{return F1(J).enableVirtualTerminalInput?.()??!1}catch{}return!1}class CJ{stdin;stdout;env;opts;wasRaw=!1;constructor($=process.stdin,J=process.stdout,Z=process.env,Q={}){this.stdin=$;this.stdout=J;this.env=Z;this.opts=Q}write($){this.stdout.write($)}onInput($){let J=(Q)=>{let V=typeof Q==="string"?Q:Q.toString("utf8"),j=this.opts.focus?this.opts.focus.feed(V):V;if(j.length>0)$(j)};this.stdin.on("data",J);let Z=()=>{$("\x03")};return this.stdin.on("end",Z),()=>{this.stdin.off("data",J),this.stdin.off("end",Z)}}onResize($){let J=()=>{let{cols:Z,rows:Q}=this.size();$(Z,Q)};return this.stdout.on("resize",J),()=>{this.stdout.off("resize",J)}}size(){return{cols:this.stdout.columns||80,rows:this.stdout.rows||24}}enterRaw(){if(this.wasRaw=this.stdin.isRaw??!1,this.stdin.setRawMode?.(!0),this.stdin.setEncoding("utf8"),this.stdin.resume(),(this.opts.platform??process.platform)==="win32")(this.opts.vtInput??P1)()}leaveRaw(){this.stdin.setRawMode?.(this.wasRaw),this.stdin.pause()}}class A1{cols;rows;env;writes=[];raw=!1;inputs=new Set;resizes=new Set;constructor($=160,J=44,Z={}){this.cols=$;this.rows=J;this.env=Z}write($){this.writes.push($)}onInput($){return this.inputs.add($),()=>{this.inputs.delete($)}}onResize($){return this.resizes.add($),()=>{this.resizes.delete($)}}size(){return{cols:this.cols,rows:this.rows}}enterRaw(){this.raw=!0}leaveRaw(){this.raw=!1}feed($){for(let J of[...this.inputs])J($)}resize($,J){this.cols=$,this.rows=J;for(let Z of[...this.resizes])Z($,J)}output(){return this.writes.join("")}get listeners(){return this.inputs.size+this.resizes.size}}var E1=new Set(["vscode","iTerm.app","WezTerm","ghostty"]);function I1($){let J=($.COLORTERM??"").toLowerCase();if(J==="truecolor"||J==="24bit")return!0;if($.WT_SESSION)return!0;if(E1.has($.TERM_PROGRAM??""))return!0;return/kitty|direct/.test($.TERM??"")}function vJ($){if(I1($))return"truecolor";if(!($.COLORTERM??"").trim()&&/256color/.test($.TERM??""))return"256";return"none"}function S1($,J){return!!J.isTTY&&(J.columns??0)>=kJ&&(J.rows??0)>=BJ&&vJ($)!=="none"}function L1($){return($.columns??80)>=v0&&($.rows??24)>=f0}function T1($,J,Z){if($.classic)return"classic";let Q=(J.ROVECODE_TUI??"").trim().toLowerCase();if(Q==="classic")return"classic";if(Q==="sextant")return Z.isTTY&&L1(Z)?"sextant":"classic";return S1(J,Z)?"sextant":"classic"}function b2($,J=process.env,Z=process.stdout,Q={}){if(T1($,J,Z)!=="sextant")return;let{SextantRenderer:V}=(RJ(),H1(TJ));return new V({io:new CJ(Q.stdin??process.stdin,Z,J,Q.focus?{focus:Q.focus}:{}),truecolor:vJ(J)==="truecolor",...$.pet!==void 0?{pet:$.pet}:{},...J.ROVECODE_THEME?{theme:J.ROVECODE_THEME}:{}})}
|
|
25
|
-
export{LJ as
|
|
25
|
+
export{LJ as q,RJ as r,A1 as s,b2 as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{x as
|
|
2
|
+
import{ih as V,jh as C,mh as h}from"./main-rg0wn0xf.js";import{Th as E,Uh as b}from"./main-0z1w2zsg.js";import{Gj as F,Hj as T,Kj as I,Lj as k,Nj as R,Oj as u,Qj as N,Rj as g}from"./main-9etavkew.js";import{$m as l,Qm as P,Rm as S,Sm as _}from"./main-2yeveeve.js";import{wn as w}from"./main-qsevpgsv.js";import{auth as W,extractWWWAuthenticateParams as f}from"@modelcontextprotocol/sdk/client/auth.js";import{OAuthError as p}from"@modelcontextprotocol/sdk/server/auth/errors.js";import{LATEST_PROTOCOL_VERSION as d}from"@modelcontextprotocol/sdk/types.js";function x(q){return`mcp:${q}`}function a(q,H){let J=S(x(q));if(H===void 0||!P(J)||J.url!==H)return;return J}function O(q,H){_(x(q),H)}function m(q,H){return typeof q.expires_in==="number"&&Number.isFinite(q.expires_in)?H+Math.max(0,q.expires_in)*1000:Number.MAX_SAFE_INTEGER}function L(q,H){let J=q.oauth?.clientId;return J?{client_id:J}:H}function y(q){let H={client_id:q.client_id};if(typeof q.client_secret==="string")H.client_secret=q.client_secret;if(typeof q.client_id_issued_at==="number")H.client_id_issued_at=q.client_id_issued_at;if(typeof q.client_secret_expires_at==="number")H.client_secret_expires_at=q.client_secret_expires_at;return H}function M(q,H){return{client_name:"rovecode",redirect_uris:[q],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",...H?{scope:H}:{}}}function c(q){let H=q.discovery;return H!==void 0&&typeof H.authorizationServerUrl==="string"?H:void 0}class v{config;record;now;refreshes=0;constructor(q,H,J=Date.now){this.config=q;this.record=H;this.now=J}get redirectUrl(){return U}get clientMetadata(){return M(U,this.config.oauth?.scope)}clientInformation(){let q=L(this.config,this.record.clientInformation);if(!q)throw new V(this.config.name);return q}saveClientInformation(){throw new V(this.config.name)}discoveryState(){return c(this.record)}saveDiscoveryState(q){this.persist({...this.record,discovery:q})}tokens(){let{access:q,refresh:H,expires:J}=this.record;if(q.length===0)return;let Q={access_token:q,token_type:"Bearer"};if(H.length>0&&this.refreshes===0)Q.refresh_token=H;if(J<Number.MAX_SAFE_INTEGER)Q.expires_in=Math.max(0,Math.floor((J-this.now())/1000));return Q}saveTokens(q){this.refreshes+=1,this.persist({...this.record,access:q.access_token,refresh:q.refresh_token??this.record.refresh,expires:m(q,this.now())})}redirectToAuthorization(){throw new V(this.config.name)}saveCodeVerifier(){}codeVerifier(){throw new V(this.config.name)}invalidateCredentials(q){let H={...this.record};if(q==="all"||q==="tokens")H.access="",H.refresh="",H.expires=0;if(q==="all"||q==="client")delete H.clientInformation;if(q==="all"||q==="discovery")delete H.discovery;this.persist(H)}persist(q){this.record=q,O(this.config.name,q)}}class A{config;callbackUrl;nonce;io;now;registered;verifier;discovery;stored;constructor(q,H,J,Q,j){this.config=q;this.callbackUrl=H;this.nonce=J;this.io=Q;this.now=j}get redirectUrl(){return this.callbackUrl}get clientMetadata(){return M(this.callbackUrl,this.config.oauth?.scope)}state(){return this.nonce}clientInformation(){return L(this.config,this.registered)}saveClientInformation(q){this.registered=y(q)}discoveryState(){return this.discovery}saveDiscoveryState(q){this.discovery=q}tokens(){return}saveTokens(q){let H=this.clientInformation(),J={type:"mcp-oauth",url:this.config.url??"",access:q.access_token,refresh:q.refresh_token??"",expires:m(q,this.now()),...H?{clientInformation:y(H)}:{},...this.discovery?{discovery:this.discovery}:{}};O(this.config.name,J),this.stored=J}redirectToAuthorization(q){this.io.notify({type:"auth_url",url:q.toString(),callbackUrl:this.callbackUrl})}saveCodeVerifier(q){this.verifier=q}codeVerifier(){if(this.verifier===void 0)throw Error("no PKCE verifier for this login");return this.verifier}}function D(q,H){if(H instanceof V||H instanceof Error&&H.message===F)return H;if(H instanceof p)return Error(`${q} failed (${H.name}: ${H.errorCode})`);let J=H instanceof Error?`${H.constructor.name}: ${H.message.slice(0,200)}`:String(H).slice(0,200);return Error(`${q} failed (${J})`)}async function Xq(q,H,J){let Q=q.name;if(q.transport==="stdio"||q.url===void 0)throw Error(`MCP server "${Q}" is a stdio server \u2014 OAuth login applies to url servers only`);if(H.signal.aborted)throw T();let j=q.url,X=`MCP server "${Q}"`,G=N(),$,Y={},z=R({nonce:G,signal:H.signal,what:X,retryHint:`Run rovecode mcp login ${Q} again.`,exchange:"token exchange",requireStateParam:!0,...J.timeoutMs!==void 0?{timeoutMs:J.timeoutMs}:{},onCode:async(Z)=>{if(!$)throw Error(`${X} token exchange failed (callback before the authorization request)`);if(await W($,{serverUrl:j,authorizationCode:Z,resourceMetadataUrl:Y.resourceMetadataUrl,scope:Y.scope,fetchFn:J.fetch}).catch((K)=>{throw D(`${X} token exchange`,K)})!=="AUTHORIZED"||!$.stored)throw Error(`${X} token exchange failed (no tokens were issued)`);return $.stored}});try{let Z;try{Z=await I(J,j,{method:"POST",headers:{"content-type":"application/json",accept:"application/json, text/event-stream"},body:s},H.signal)}catch(K){throw K instanceof Error&&K.message===F?K:Error(`${X} probe failed (${K instanceof Error?K.message.slice(0,200):String(K).slice(0,200)})`)}if(await Z.body?.cancel().catch(()=>{}),Z.status!==401)throw Error(`server does not require OAuth (HTTP ${Z.status})`);Y=f(Z),$=new A(q,z.callbackUrl,G,H,J.now);let B=await W($,{serverUrl:j,resourceMetadataUrl:Y.resourceMetadataUrl,scope:Y.scope,fetchFn:J.fetch}).catch((K)=>{throw D(`${X} authorization`,K)});if(B!=="REDIRECT")throw Error(`${X} authorization failed (expected a browser redirect, got ${B})`);return await z.result}finally{z.stop()}}function Zq(q){if(q.transport==="stdio"||q.url===void 0)return;if(C(q))return;let H=a(q.name,q.url);return H?new v(q,H):void 0}var U="http://127.0.0.1/callback/needs-login",s;var i=w(()=>{l();k();u();g();h();E();s=JSON.stringify({jsonrpc:"2.0",id:0,method:"initialize",params:{protocolVersion:d,capabilities:{},clientInfo:{name:"rovecode",version:b.version}}})});
|
|
3
|
+
export{x as dd,a as ed,O as fd,v as gd,A as hd,Xq as id,Zq as jd,i as kd};
|
|
@@ -18,4 +18,4 @@ import{wn as D}from"./main-qsevpgsv.js";import{execFile as R}from"child_process"
|
|
|
18
18
|
summary: ${O}`}catch(O){X+=`
|
|
19
19
|
|
|
20
20
|
(summarize step failed: ${O instanceof Error?O.message:String(O)}; hits above are unaffected)`}return{ok:!0,output:X,data:{hits:V}}}}}var m=10,b=5,v=120,p=40,d=3,F=512,c=2,i=1,o;var t=D(()=>{o=/(?:ignore previous|disregard above|system prompt)/i});
|
|
21
|
-
export{JB as
|
|
21
|
+
export{JB as Xd,ZB as Yd,I as Zd,A as _d,y as $d,E as ae,zB as be,t as ce};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{$m as H,Lm as y}from"./main-2yeveeve.js";import{on as P,sn as I,tn as h}from"./main-nqveez48.js";import{wn as A}from"./main-qsevpgsv.js";import{existsSync as b}from"fs";import{join as X,resolve as F}from"path";import{pathToFileURL as S}from"url";async function O(Q,Z={}){let $={hooks:[],sources:[],warnings:[]};if(process.env.ROVECODE_NO_HOOKS==="1")return $;let z=Z.home??y(),Y=Z.trusted??((V)=>P(z,V)),B=new Set;for(let[V,W]of[["user",z],["project",X(Q,".rovecode")]]){let J=_(W,$.warnings);if(J===null||B.has(F(J)))continue;if(B.add(F(J)),V==="project"&&!Y(J)){$.warnings.push(I(J,"its hooks stay off (they would run code from this repo in-process, with your privileges)"));continue}let D=await p(J,Z.timeoutMs??N(),$.warnings);if(D)$.hooks.push(D),$.sources.push(J)}return $}function _(Q,Z){let $=X(Q,"hooks.ts"),z=X(Q,"hooks.js"),Y=b($),B=b(z);if(Y&&B)Z.push(`${z}: ignored \u2014 ${$} takes precedence`);return Y?$:B?z:null}async function p(Q,Z,$){let z;try{z=await E(import(S(Q).href),Z)}catch(Y){return $.push(`${Q}: failed to load \u2014 ${K(Y)}`),null}if(z===L)return $.push(`${Q}: load timed out after ${Z}ms (top-level await?) \u2014 skipped`),null;return g(Q,C(z)?z.default:void 0,$)}function g(Q,Z,$){if(!C(Z))return $.push(`${Q}: default export must be { version: ${G}, hooks: {\u2026} } \u2014 skipped`),null;if(Z.version!==G){let Y=Z.version,B=Y===void 0?"missing":typeof Y==="string"?JSON.stringify(Y):String(Y);return $.push(`${Q}: hooks API version ${B} is not supported (this rovecode speaks ${G}) \u2014 skipped`),null}if(!C(Z.hooks))return $.push(`${Q}: "hooks" must be an object of hook functions \u2014 skipped`),null;let z={};for(let[Y,B]of Object.entries(Z.hooks)){if(!k.includes(Y)){$.push(`${Q}: unknown hook "${Y}" ignored (known: ${k.join(", ")})`);continue}if(typeof B!=="function"){$.push(`${Q}: hook "${Y}" is not a function \u2014 ignored`);continue}z[Y]=B}return z}function N(Q=process.env){let Z=Number(Q.ROVECODE_HOOK_TIMEOUT_MS??"");return Number.isFinite(Z)&&Z>=1?Math.floor(Z):M}class u{base;warnings=[];timeoutMs;entries=[];loading=null;opened=!1;closing=null;pending=new Set;listener;constructor(Q,Z={}){this.base=Q;this.timeoutMs=Z.timeoutMs??N(),this.listener=Z.onWarning}add(Q,Z="programmatic"){this.entries.push({source:Z,set:Q})}get size(){return this.entries.length}has(Q){return this.entries.some((Z)=>typeof Z.set[Q]==="function")}get ready(){return this.loading??Promise.resolve()}open(Q=this.base.cwd,Z={}){if(this.opened)return this.ready;this.opened=!0;let $=O(Q,{...Z,timeoutMs:this.timeoutMs}).then(async(z)=>{z.hooks.forEach((Y,B)=>this.add(Y,z.sources[B]??"file"));for(let Y of z.warnings)this.warn(Y);await this.dispatch("session_open",[this.base])}).then(()=>{this.loading=null});return this.loading=$,$}async run(Q,...Z){if(this.loading)await this.loading;return this.dispatch(Q,Z)}async dispatch(Q,Z){let $;for(let z of this.entries){let Y=z.set[Q];if(typeof Y!=="function")continue;let B=await this.invoke(z.source,Q,Y,Z),V=f(Q,B,Z,(D)=>this.warn(`${z.source}: ${D}`));if(V===void 0)continue;if(Q!=="post_tool")return V;$=V;let W=Z,J=V.output;if(J!==void 0)W[2]={...W[2],output:J}}return $}invoke(Q,Z,$,z){let Y;try{Y=Promise.resolve($(...z))}catch(B){return this.warn(`${Q}: ${Z} hook threw: ${K(B)} \u2014 ignored, run continues`),Promise.resolve(void 0)}return E(Y,this.timeoutMs).then((B)=>{if(B!==L)return B;this.warn(`${Q}: ${Z} hook timed out after ${this.timeoutMs}ms \u2014 ignored, run continues`);return},(B)=>{this.warn(`${Q}: ${Z} hook threw: ${K(B)} \u2014 ignored, run continues`);return})}observer(Q){let Z={cwd:Q.cwd,sessionId:Q.sessionId},$=!1;return{observe:async(z)=>{if(z.type==="run_start")Z={...Z,runId:z.runId};if(this.tap(Z,z),z.type==="run_start")await this.run("pre_run",Z);else if(z.type==="compaction")await this.run("compaction",Z,z);else if(z.type==="run_end")$=!0,await this.run("post_run",Z,{status:z.status,summary:z.summary})},close:async()=>{if($||Z.runId===void 0)return;$=!0,await this.run("post_run",Z,{status:"stopped",summary:"run aborted"})}}}approver(Q){return async(Z)=>{let $=await this.run("approval",this.base,{...Z,args:q(Z.args),revisedArgs:q(Z.revisedArgs)});if($==="allow")return"once";if($==="deny")return"deny";return Q?Q(Z):"deny"}}tap(Q,Z){if(!this.loading&&!this.has("on_event"))return;let $=this.run("on_event",Q,Z).then(()=>{return},()=>{return});this.pending.add($),$.then(()=>{this.pending.delete($)})}async settle(){await Promise.all([...this.pending])}close(){return this.closing??=(async()=>{if(this.loading)await this.loading;await this.settle(),await this.dispatch("session_close",[this.base])})(),this.closing}onWarning(Q){this.listener=Q;for(let Z of this.warnings)Q(Z)}drainWarnings(){return this.warnings.splice(0)}warn(Q){let Z=U(Q,x);if(this.warnings.push(Z),this.warnings.length>T)this.warnings.shift();this.listener?.(Z)}}function q(Q){try{return structuredClone(Q)}catch{return Q}}function f(Q,Z,$,z){if(Z===void 0||Z===null)return;switch(Q){case"pre_tool":{let Y=C(Z)?Z.deny:void 0;if(typeof Y==="string"&&Y.trim().length>0)return{deny:U(Y.trim(),R)};break}case"approval":if(Z==="allow"||Z==="deny")return Z;break;case"post_tool":{if(!C(Z))break;if(Z.output===void 0)return;if(typeof Z.output!=="string")break;let Y=$[2].output;return{output:c(Z.output,Y.length)}}default:return}z(`${Q} hook returned an invalid result (${w(Z)}) \u2014 ignored`);return}function c(Q,Z){let $=Z+j;if(Q.length<=$)return Q;return Q.slice(0,$)+`
|
|
3
3
|
\u2026 [post_tool output truncated: hooks may add at most ${j} chars]`}function E(Q,Z){return new Promise(($,z)=>{let Y=setTimeout(()=>$(L),Z);Y.ref?.(),Q.then((B)=>{clearTimeout(Y),$(B)},(B)=>{clearTimeout(Y),z(B)})})}function C(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function U(Q,Z){return Q.length<=Z?Q:Q.slice(0,Z)+"\u2026"}function K(Q){if(Q instanceof Error)return Q.message;if(C(Q)&&typeof Q.message==="string")return Q.message;return String(Q)}function w(Q){if(typeof Q==="string")return JSON.stringify(U(Q,40));if(Array.isArray(Q))return"array";if(C(Q))return`object with keys ${Object.keys(Q).slice(0,5).join(",")||"(none)"}`;return typeof Q}var G=1,M=5000,R=400,j=16000,T=50,x=300,k,L;var m=A(()=>{H();h();k=Object.keys({pre_run:0,post_run:0,pre_tool:0,post_tool:0,approval:0,compaction:0,session_open:0,session_close:0,on_event:0});L=Symbol("rovecode.hook.timeout")});
|
|
4
|
-
export{k as
|
|
4
|
+
export{k as Gm,u as Hm,q as Im,m as Jm};
|