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,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{m as
|
|
2
|
+
import{hj as X,ij as Y,kj as Z,lj as $}from"./main-pknhvrmj.js";import{$m as b,Nm as J,Tm as Q,Xm as W}from"./main-2yeveeve.js";b();var m=`usage: rovecode auth login <${X.join("|")}>`;function C(j,k=Date.now()){if(j>=Number.MAX_SAFE_INTEGER||j>8640000000000000)return"never expires";if(!(j>=-8640000000000000))return"EXPIRED (invalid expiry)";let q=new Date(j).toISOString();return j<=k?`EXPIRED ${q}`:`expires ${q}`}function G(j=W(),k=Date.now()){return j.map((q)=>{let z=q.kind==="oauth"&&q.expires!==void 0?` ${C(q.expires,k)}`:"";return`${q.provider.padEnd(14)} ${q.kind.padEnd(6)} ${q.keyName.padEnd(24)} ${q.redacted}${z}`})}function f(){let j=G();if(j.length===0){console.log(`no stored credentials (${J()}) \u2014 run: rovecode auth set <provider> | rovecode auth login <provider>`);return}for(let k of j)console.log(k)}function H(j){switch(j.type){case"device_code":return[`open ${j.verificationUri}`,`enter ${j.userCode}`,`waiting for authorization \u2014 polling every ${j.intervalSeconds}s, up to ${Math.max(1,Math.round(j.expiresInSeconds/60))} min (Ctrl-C cancels)`];case"auth_url":return[`open ${j.url}`,`waiting for the browser to return to ${j.callbackUrl} (loopback \u2014 the browser must run on this machine; Ctrl-C cancels)`];case"progress":return[j.message]}}async function L(j,k){let q=k.provider===void 0?Y[j]:void 0;if(q!==void 0)return k.err(`rovecode auth login ${j}: refused \u2014 ${q}`),1;let z=(k.provider??Z)(j);if(!z){if(j.length>0)k.err(`error: no OAuth login for "${j}"`);return k.err(m),1}let K=k.signal??new AbortController().signal,M={...$(),...k.oauth};k.out(`rovecode auth login ${j} \u2014 ${z.label}`);try{let B=await z.login({notify:(F)=>{for(let V of H(F))k.out(` ${V}`)},signal:K},M);return(k.save??Q)(j,B),k.out(`stored OAuth token for ${j} in ${J()} (${C(B.expires,M.now())})`),0}catch(B){if(K.aborted)return k.err("login cancelled"),130;return k.err(`error: ${B instanceof Error?B.message:String(B)}`),1}}async function y(j){let k=new AbortController,q=()=>k.abort();process.once("SIGINT",q);try{return await L(j[0]??"",{out:(z)=>console.log(z),err:(z)=>console.error(z),signal:k.signal})}finally{process.removeListener("SIGINT",q)}}
|
|
3
|
+
export{m as Gc,C as Hc,G as Ic,f as Jc,H as Kc,L as Lc,y as Mc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Df as c,Ef as I,Ff as p,Gf as i,Hf as a}from"./main-skbp13js.js";import{Th as s,Uh as d}from"./main-0z1w2zsg.js";s();var w="https://mcp.exa.ai/mcp",U=8,h=20,C=1000,n=500,m=200,r=2000,v=16000,R=1048576,S=5,E=25000,t=`Mozilla/5.0 (compatible; rovecode/${d.version} web_search)`,e="application/json, text/event-stream",zz=new Set([301,302,303,307,308]),Zz=96;function $z($){let z=typeof $==="string"&&$.trim()!==""?Number($):$;return typeof z==="number"&&Number.isFinite(z)&&z>0?Math.min(Math.floor(z),h):U}function k($,z){return $.length<=z?$:$.slice(0,z-1).replace(/[\uD800-\uDBFF]$/,"")+"\u2026"}function T($){let z;try{z=JSON.parse($)}catch{return null}if(!z||typeof z!=="object")return null;let G=z;if(G.error&&typeof G.error==="object"){let J=G.error.message;return{error:typeof J==="string"&&J!==""?J:JSON.stringify(G.error)}}if(!G.result||typeof G.result!=="object")return null;let V=G.result,Z=(Array.isArray(V.content)?V.content:[]).map((J)=>J&&typeof J==="object"?J.text:void 0).find((J)=>typeof J==="string"&&J!=="");if(V.isError===!0)return{error:Z??"backend reported an error without a message"};return Z===void 0?null:{text:Z}}function Gz($){let z=$.trim();if(z.startsWith("{")){let G=T(z);if(G)return G}for(let G of $.split(`
|
|
3
3
|
`)){if(!G.startsWith("data:"))continue;let V=T(G.slice(5).trim());if(V)return V}return null}function u($){let z=[];for(let G of $.split(/\r?\n/)){let V=G.trim();if(V==="")continue;if(V==="..."){if(z.length>0&&z[z.length-1]!=="\u2026")z.push("\u2026");continue}z.push(V)}while(z.length>0&&z[z.length-1]==="\u2026")z.pop();return z.join(" ").replace(/\s+/g," ").trim()}var Jz=/^(Title|URL|Published|Author|Score|ID|Image|Favicon):\s*(.*)$/,Vz=/^(Highlights|Text|Summary):\s*$/;function Wz($){let z=[];for(let G of $.split(/\r?\n\s*---\s*\r?\n/)){let V=G.split(/\r?\n/),K={},Z=0;for(;Z<V.length;Z++){let W=V[Z].trim();if(W===""){if(Object.keys(K).length>0)break;continue}let Q=Jz.exec(W);if(!Q)break;K[Q[1]]=Q[2].trim()}while(Z<V.length&&V[Z].trim()==="")Z++;if(Z<V.length&&Vz.test(V[Z].trim()))Z++;let J=K.URL??"";if(!/^https?:\/\//i.test(J))continue;let Y=K.Published;z.push({title:K.Title||J,url:J,snippet:u(V.slice(Z).join(`
|
|
4
4
|
`)),...Y&&Y.toUpperCase()!=="N/A"?{publishedDate:Y}:{}})}return z}function Kz($){let z;try{z=JSON.parse($)}catch{return null}let G=z&&typeof z==="object"?z.results:void 0;if(!Array.isArray(G))return null;let V=[];for(let K of G){if(!K||typeof K!=="object")continue;let Z=K,J=typeof Z.url==="string"?Z.url:"";if(!/^https?:\/\//i.test(J))continue;let Y=Array.isArray(Z.highlights)?Z.highlights.filter((X)=>typeof X==="string"):[],W=typeof Z.text==="string"?Z.text:Y.length>0?Y.join(`
|
|
5
5
|
...
|
|
@@ -11,4 +11,4 @@ ${W}`,J++}let Y=J<K.length;if(Y)Z+=`
|
|
|
11
11
|
(Showing ${J} of ${z.length} results: output capped at ${G} characters.)`;return{output:Z,shown:J,truncated:Y}}function L($){return $.origin+$.pathname}function Bz($={}){let z=$.fetch??((W,Q)=>fetch(W,Q)),G=$.resolve??c,V=typeof $.timeoutMs==="number"&&Number.isFinite($.timeoutMs)&&$.timeoutMs>0?Math.floor($.timeoutMs):E,K=typeof $.apiKey==="string"?$.apiKey.trim():"",Z=K===""?w:`${w}?exaApiKey=${encodeURIComponent(K)}`,J=(W,Q)=>{let X=W.split(Z).join(w).split(Q.href).join(L(Q));if(K!=="")for(let g of new Set([K,encodeURIComponent(K)]))X=X.split(g).join("[key]");return X};async function Y(W,Q){let X=typeof W.query==="string"?W.query.trim():"";if(X==="")return{ok:!1,output:"web_search: query is required"};if(X.length>C)return{ok:!1,output:`web_search: query too long (${X.length} characters; max ${C})`};let g=$z(W.max_results);if(Q.signal.aborted)return{ok:!1,output:"web_search: aborted"};let o=JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:"web_search_exa",arguments:{query:X,type:"auto",numResults:g,livecrawl:"fallback",contextMaxCharacters:Math.max(1e4,g*1500)}}}),N=new AbortController,x=!1,B=new URL(Z),A=setTimeout(()=>{x=!0,N.abort()},V);A.ref?.();let _=()=>N.abort();Q.signal.addEventListener("abort",_,{once:!0});let P=(q)=>{if(N.signal.aborted)return{ok:!1,output:x?`web_search: timed out after ${V}ms`:"web_search: aborted"};return{ok:!1,output:`web_search: request failed: ${J(q instanceof Error?q.message:String(q),B)}`}};try{let q=I(B.hostname),l=0;for(;;){if(B.protocol!=="http:"&&B.protocol!=="https:")return{ok:!1,output:`web_search: backend redirected to unsupported URL scheme ${B.protocol} (http/https only)`};let b;try{b=await i(p(B.hostname,G),N.signal)}catch(F){return P(F)}if(b!==null)return{ok:!1,output:`web_search: refused ${L(B)}: ${J(b,B)}`};if(I(B.hostname)!==q)return{ok:!1,output:`web_search: backend redirected to ${L(B)} (${I(B.hostname)} is not ${q}); not followed`};let j;try{j=await z(B.href,{method:"POST",redirect:"manual",signal:N.signal,body:o,headers:{"User-Agent":t,Accept:e,"Content-Type":"application/json"}})}catch(F){return P(F)}if(zz.has(j.status)){let F=j.headers.get("location");if(await j.body?.cancel().catch(()=>{}),!F)return{ok:!1,output:`web_search: HTTP ${j.status} redirect from ${L(B)} without a Location header`};if(++l>S)return{ok:!1,output:`web_search: too many redirects (more than ${S}) from ${w}`};try{B=new URL(F,B)}catch{return{ok:!1,output:`web_search: invalid redirect target ${F}`}}continue}let D;try{D=await a(j,j.ok?R:2048)}catch(F){return P(F)}let y=new TextDecoder().decode(D.bytes);if(!j.ok){let F=y.split(/\r?\n/).map((f)=>f.trim()).find((f)=>f!=="")??"";return{ok:!1,output:`web_search: backend HTTP ${j.status}${F===""?"":`: ${k(J(F,B),200)}`}`}}let O=Gz(y);if(O===null)return{ok:!1,output:`web_search: malformed backend response (${D.truncated?`body truncated at ${R} bytes`:`${D.bytes.length} bytes, no JSON-RPC result with text`})`};if("error"in O)return{ok:!1,output:`web_search: backend error: ${k(J(O.error,B).replace(/\s+/g," ").trim(),300)}`};let M=Qz(O.text);if(M===null){let F=O.text.trim(),f=k(F,v);return{ok:!0,output:`web_search "${k(X,m)}": the backend answered in an unrecognized format; shown verbatim${f.length<F.length?` (capped at ${v} characters)`:""}:
|
|
12
12
|
|
|
13
13
|
${f}`,data:{query:X,count:0,total:0,unstructured:!0,truncated:f.length<F.length}}}if(M.length===0)return{ok:!0,output:`No results for "${k(X,m)}" (Exa web search). Try different or fewer terms.`,data:{query:X,count:0,total:0,results:[],truncated:!1}};let H=Xz(X,M.slice(0,g));return{ok:!0,output:H.output,data:{query:X,count:H.shown,total:M.length,results:M.slice(0,H.shown),truncated:H.shown<M.length}}}}finally{clearTimeout(A),Q.signal.removeEventListener("abort",_)}}return{schema:{name:"web_search",description:`Search the web and return up to max_results ranked results (default ${U}, cap ${h}), each as "N. title \xB7 url \xB7 published date (when known)" followed by a snippet of at most ${n} characters; the whole output is capped at ${v} characters (trailing results dropped, with a marker). Results are search snippets, not pages: call web_fetch on a result's url to read it. Backend: Exa via its hosted MCP endpoint (${w}); no API key is required. Times out after ${E/1000}s; a backend that redirects elsewhere or resolves to a private address is refused. The current year is ${new Date().getFullYear()}: put it in queries about recent events.`,args:{type:"object",properties:{query:{type:"string",description:`search query in plain words (at most ${C} characters)`},max_results:{type:"integer",description:`results to return (default ${U}, cap ${h})`}},required:["query"]}},kind:"network",sequential:!1,execute:(W,Q)=>Y(W??{},Q)}}var jz=Bz();
|
|
14
|
-
export{w as
|
|
14
|
+
export{w as ne,U as oe,h as pe,C as qe,n as re,m as se,r as te,v as ue,R as ve,S as we,E as xe,$z as ye,Gz as ze,Wz as Ae,Qz as Be,Xz as Ce,Bz as De,jz as Ee};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{wn as G}from"./main-qsevpgsv.js";function W(x){let y=x.provider.toLowerCase(),B=x.model.toLowerCase();if(L.has(y))return J;let b=K.find((z)=>z.provider===y&&z.match.test(B));return b?{scale:b.scale,charScale:b.charScale,measured:!0,note:b.note}:H}var H,J,K,L;var Q=G(()=>{H={scale:1,charScale:1,measured:!1,note:"no measurement for this model \u2014 the estimate is used as-is; bun scripts/measure-tokenizer.ts measures it"},J={scale:1,charScale:1,measured:!0,note:"o200k is this vendor's own tokenizer \u2014 the estimate is exact"},K=[{provider:"anthropic",match:/(opus-5|sonnet-5|fable-5|mythos-5)/,scale:1.8,charScale:1.82,note:"measured 2026-09-05 against /v1/messages/count_tokens over 20 samples \u2014 o200k reads up to 1.79\xD7 low on Claude 5"},{provider:"anthropic",match:/(haiku-4-5|opus-4-5|sonnet-4-6)/,scale:1.29,charScale:1.46,note:"measured 2026-09-05 against /v1/messages/count_tokens over 20 samples \u2014 o200k reads up to 1.29\xD7 low on Claude 4.5/4.6"}],L=new Set(["openai"])});
|
|
3
|
-
export{W as
|
|
3
|
+
export{W as Hd,Q as Id};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Uc as H2,Vc as B2,Wc as YZ}from"./main-bxtvnf6d.js";import{$c as W2,cd as K4}from"./main-4p4e2w7x.js";import{fd as N2}from"./main-hqbz10aw.js";import{kd as P4,ld as U4}from"./main-n6qrdbmy.js";import{md as P2,nd as U2,pd as O2,qd as X4,sd as zZ,td as j4}from"./main-evgz4mp5.js";import{vd as tQ,wd as o0,xd as V4}from"./main-f33fc5je.js";import{yd as V2,zd as q4}from"./main-2zgsknth.js";import{Ed as W4}from"./main-kwwsz6rq.js";import{Gd as eQ,Hd as $2}from"./main-23q7cmww.js";import{Id as Z2,Jd as Q2,Kd as J2}from"./main-45rn3trk.js";import{$d as j2}from"./main-yrjt2sqt.js";import{de as WZ,ee as qZ}from"./main-a2yfvcy9.js";import{fe as J9,ge as k3,ie as Y9,je as x3,me as k9,se as F2,te as x9}from"./main-gth53dnt.js";import{ue as _0,ve as q2,xe as H9}from"./main-2z3dek0b.js";import{Ae as v$,Be as SZ,Ce as H0,Fe as r0,ye as C$,ze as a}from"./main-9a9rnh47.js";import{Te as X2}from"./main-mg9b20ac.js";import{Ue as m0,Ve as K$,We as LQ,Xe as n$,Ye as o$,Ze as NQ,jf as ZZ,kf as QZ,lf as JZ}from"./main-p0cfn6nr.js";import{Bf as C2,Cf as B4,tf as VZ,xf as I2}from"./main-xfekqh9m.js";import{Kf as L2}from"./main-s4bb0jav.js";import{Qf as sQ}from"./main-wqt32p5x.js";import{Vf as K2,Wf as G2,Xf as g$,Yf as V9,Zf as t0,hg as s0,jg as e0,kg as $Z,lg as G4}from"./main-rvetps99.js";import{qg as D2,rg as _2,tg as H4}from"./main-x9ct6y1a.js";import{yg as z2}from"./main-mg4f96e1.js";import{Kg as Y2}from"./main-7jd5vh3x.js";import{sh as X9,uh as rQ,vh as j9}from"./main-xt9zc3n6.js";import{Eh as O$,Fh as FQ}from"./main-mgb9ccnx.js";import{ci as vQ,fi as Q4}from"./main-kba6zeyd.js";import{gi as A0,hi as D9}from"./main-2wyax8k9.js";import{fj as iQ,mj as aQ,qj as nQ}from"./main-1ztz6fkj.js";import{vj as dQ,wj as n9,yj as o9}from"./main-2rzbexn2.js";import{Bj as l$,Ej as x0,zj as lQ}from"./main-v8y60bb2.js";import{Nj as AQ,Wj as t8}from"./main-ywbxshqc.js";import{kk as oQ,lk as z4}from"./main-gbbty4d4.js";import{Ck as gQ,Dk as uQ,Ek as mQ,Fk as pQ,Gk as J4,Hk as cQ,Qk as Y4,mk as bQ,nk as yQ,ok as A$,pk as TQ,qk as F0,rk as G$,sk as OQ,uk as wQ,xk as Z4}from"./main-qj2djy17.js";import{ll as hQ,ml as $4}from"./main-6dtqmbt6.js";import{nl as tZ,pl as n0,rl as sZ}from"./main-rebtt91r.js";import{Bl as MQ,Cl as SQ,Dl as e8,sl as EQ}from"./main-a3f51n0x.js";import{Fl as RQ,Hl as s8}from"./main-5py0rkmc.js";import{Nl as kQ,Ql as xQ,Sl as fQ}from"./main-6h9x282m.js";import{cm as f0,fm as B$,gm as QQ,lm as i$,mm as M8}from"./main-wk2csfnj.js";import{pm as a$,qm as r,vm as ZQ}from"./main-y5c82rxr.js";import{wm as D8,xm as y0}from"./main-ys6zj3yr.js";import{$m as X0,Lm as n}from"./main-2yeveeve.js";import{dn as i0,mn as a0,on as EZ,pn as j0,sn as MZ,tn as k2}from"./main-nqveez48.js";import{un as h$,vn as k0,wn as o}from"./main-qsevpgsv.js";import{randomBytes as U8}from"crypto";function b0($){let Z=$.trim().replace(/\/+$/,"");return Z.endsWith(R$)?Z:Z+R$}function E$($){try{let Z=new URL($.trim());return(Z.protocol==="http:"||Z.protocol==="https:")&&Z.hostname!==""}catch{return!1}}function T9($){let Z=p$($.endpoint),Q=E$($.endpoint),J={...$.headers??{},"content-type":"application/json"},Y=$.fetch??fetch,z=$.timeoutMs??S0,V=new Set,K=new Set,q=(W)=>`${Z}/v1/${W}`,G=async(W,j)=>{if(!Q||K.has(W))return;let H=q(W),B=(N)=>$.warn(`OTLP export to ${H} failed: ${N}`),L=new AbortController;try{let N=await L8(Y(H,{method:"POST",headers:J,body:j,signal:L.signal}),z,L);if(N===h9){B(`timed out after ${z}ms`);return}if(await N.arrayBuffer().catch(()=>{return}),N.ok)return;if(O8.has(N.status)){if(!K.has(W))K.add(W),$.warn(`OTLP collector ${Z} does not accept ${W} (HTTP ${N.status}) \u2014 ${W} export disabled`);return}B(`HTTP ${N.status}`)}catch(N){B(N8(N))}};return{base:Z,usable:Q,url:q,post(W,j){let H=G(W,j);V.add(H),H.then(()=>{V.delete(H)})},async flush(){while(V.size>0)await Promise.all([...V])},disabled:(W)=>K.has(W)}}function W$($){let Z;do Z=U8($).toString("hex");while(/^0+$/.test(Z));return Z}function L8($,Z,Q){return new Promise((J,Y)=>{let z=setTimeout(()=>{Q.abort(),J(h9)},Z);z.ref?.(),$.then((V)=>{clearTimeout(z),J(V)},(V)=>{clearTimeout(z),Y(V)})})}function N8($){if($ instanceof Error)return $.message;if(typeof $==="object"&&$!==null&&typeof $.message==="string")return $.message;return String($)}var S0=5000,R$="/v1/traces",O8,p$=($)=>b0($).slice(0,-R$.length),y9=($,Z)=>`${p$($)}/v1/${Z}`,h9;var c$=o(()=>{O8=new Set([404,405,501]);h9=Symbol("rovecode.otel.timeout")});function y$($,Z){return{resourceSpans:[{resource:{attributes:S$($)},scopeSpans:[{scope:b$(),spans:Z.map((Q)=>({traceId:Q.traceId,spanId:Q.spanId,...Q.parentSpanId?{parentSpanId:Q.parentSpanId}:{},name:Q.name,kind:1,startTimeUnixNano:d(Q.start),endTimeUnixNano:d(Q.end??Q.start),attributes:q$(Q.attrs),...Q.events.length>0?{events:Q.events.map((J)=>({name:J.name,timeUnixNano:d(J.time),attributes:q$(J.attrs)}))}:{},status:Q.status.message!==void 0?{code:Q.status.code,message:Q.status.message}:{code:Q.status.code}}))}]}]}}function d($){let Z=Math.floor($);return(BigInt(Z)*1000000n+BigInt(Math.round(($-Z)*1e6))).toString()}var b=($)=>({stringValue:$}),v=($)=>({intValue:String(Math.trunc($))}),w9=($)=>({doubleValue:$}),M$=($)=>({boolValue:$}),q$=($)=>[...$].map(([Z,Q])=>({key:Z,value:Q})),S$=($)=>q$([["service.name",b($)],["service.version",b(y0.version)]]),b$=()=>({name:"rovecode",version:y0.version});var H$=o(()=>{D8()});function f9($,Z,Q=Date.now){let J=new Map;return $.subscribe((Y)=>{if(Y.kind!=="external")return;if(Y.status==="running"){if(J.has(Y.id))return;let V={traceId:W$(16),spanId:W$(8),name:"rovecode.lane",start:Y.startedAt??Q(),attrs:new Map,events:[],status:{code:0}};V.attrs.set("rovecode.task_id",b(Y.id)),V.attrs.set("rovecode.lane",b(Y.agent)),V.attrs.set("rovecode.depth",v(Y.depth)),J.set(Y.id,V);return}if(!k9(Y.status))return;let z=J.get(Y.id);if(!z)return;J.delete(Y.id),Z(_8(z,Y))})}function _8($,Z){if($.attrs.set("rovecode.status",b(Z.status)),typeof Z.laneExit==="number")$.attrs.set("rovecode.exit_code",v(Z.laneExit));if(Z.laneModel)$.attrs.set("rovecode.lane.model",b(Z.laneModel));let Q=Z.usage;if(Q&&(Q.input!==0||Q.output!==0||(Q.cacheRead??0)!==0||(Q.cacheWrite??0)!==0))$.attrs.set("rovecode.tokens.input",v(Q.input)),$.attrs.set("rovecode.tokens.output",v(Q.output)),$.attrs.set("rovecode.tokens.cacheRead",v(Q.cacheRead??0)),$.attrs.set("rovecode.tokens.cacheWrite",v(Q.cacheWrite??0));if(Z.patchLines!==void 0)$.attrs.set("rovecode.patch_lines",v(Z.patchLines));return $.attrs.set("rovecode.lane.resumable",M$(Z.laneSession!==void 0&&Z.laneSession!=="")),$.end=Z.finishedAt??Date.now(),$.status=Z.status==="failed"?{code:2,message:"lane failed"}:{code:1},$}var v9=o(()=>{x9();c$();H$()});function g9($,Z){return{resourceLogs:[{resource:{attributes:S$($)},scopeLogs:[{scope:b$(),logRecords:Z.map((Q)=>({timeUnixNano:d(Q.time),observedTimeUnixNano:d(Q.time),severityNumber:Q.severityNumber,severityText:Q.severityText,body:{stringValue:Q.body},attributes:q$(Q.attrs),...Q.traceId?{traceId:Q.traceId}:{},...Q.spanId?{spanId:Q.spanId}:{}}))}]}]}}function u9(){let $=[],Z=[],Q=(J,Y,z,V)=>{let K=new Map([["rovecode.tool",b(J.tool)],["rovecode.session_id",b(J.sessionId)],["rovecode.decision",b(Y)]]);if(J.lane)K.set("rovecode.lane",b(J.lane));if(V)K.set("rovecode.call_id",b(V.callId));let q=Y==="deny";Z.push({time:z,severityNumber:q?C8:I8,severityText:q?"WARN":"INFO",body:"rovecode.approval",attrs:K,...V?{traceId:V.traceId,spanId:V.spanId}:{}})};return{request(J){$.push(J)},resolve(J,Y,z,V,K){let q=$.findIndex((W)=>W.tool===J&&(W.fp===null||Y===null||W.fp===Y));if(q<0)return!1;let[G]=$.splice(q,1);return Q(G,z,V,K),!0},pendingFor:(J)=>$.filter((Y)=>Y.tool===J).length,drain(J){for(let Y of $.splice(0))Q(Y,"unanswered",J)},take(){let J=Z;return Z=[],J},get size(){return Z.length}}}function T0($){try{return JSON.stringify($,(Z,Q)=>Q&&typeof Q==="object"&&!Array.isArray(Q)?Object.fromEntries(Object.entries(Q).sort(([J],[Y])=>J<Y?-1:J>Y?1:0)):Q)??null}catch{return null}}var I8=9,C8=13;var m9=o(()=>{H$()});function l9($){let Z=new Map,Q=!1,J=(z,V,K)=>{let q=Z.get(z);if(!q)q={kind:"sum",name:z,unit:V,asDouble:K,series:new Map},Z.set(z,q);if(q.kind!=="sum")throw Error(`metric ${z} is a ${q.kind}`);return q},Y=(z,V,K)=>{let q=Z.get(z);if(!q)q={kind:"histogram",name:z,unit:V,bounds:K,series:new Map},Z.set(z,q);if(q.kind!=="histogram")throw Error(`metric ${z} is a ${q.kind}`);return q};return{startMs:$,get dirty(){return Q},addSum(z,V,K,q,G=!1){if(!(q>=0)||!Number.isFinite(q))return;let W=J(z,V,G),j=c9(K),H=W.series.get(j)??{attrs:new Map(K),value:0};H.value+=q,W.series.set(j,H),Q=!0},recordHistogram(z,V,K,q,G){if(!Number.isFinite(G))return;let W=Y(z,V,K),j=c9(q),H=W.series.get(j)??{attrs:new Map(q),count:0,sum:0,buckets:Array(K.length+1).fill(0)};H.count++,H.sum+=G;let B=0;while(B<K.length&&G>K[B])B++;H.buckets[B]++,W.series.set(j,H),Q=!0},encode(z,V){return Q=!1,F8(z,[...Z.values()],$,V)}}}function F8($,Z,Q,J){let Y=d(Q),z=d(J),V=(q)=>({attributes:q$(q),startTimeUnixNano:Y,timeUnixNano:z}),K=Z.map((q)=>q.kind==="sum"?{name:q.name,unit:q.unit,sum:{dataPoints:[...q.series.values()].map((G)=>({...V(G.attrs),...q.asDouble?{asDouble:G.value}:{asInt:String(Math.trunc(G.value))}})),aggregationTemporality:p9,isMonotonic:!0}}:{name:q.name,unit:q.unit,histogram:{dataPoints:[...q.series.values()].map((G)=>({...V(G.attrs),count:String(G.count),sum:G.sum,bucketCounts:G.buckets.map(String),explicitBounds:[...q.bounds]})),aggregationTemporality:p9}});return{resourceMetrics:[{resource:{attributes:S$($)},scopeMetrics:[{scope:b$(),metrics:K}]}]}}var p9=2,d9,c9=($)=>JSON.stringify([...$].sort(([Z],[Q])=>Z<Q?-1:Z>Q?1:0));var i9=o(()=>{H$();d9=[100,250,500,1000,2500,5000,1e4,30000,60000]});var t9={};k0(t9,{validEndpoint:()=>E$,unixNano:()=>d,signalUrl:()=>y9,parseOtelHeaders:()=>r9,otelOptionsFromEnv:()=>A8,otelDebug:()=>w0,normalizeEndpoint:()=>b0,encodeTraceRequest:()=>y$,createOtelHooks:()=>R8,baseOf:()=>p$,OTLP_TRACES_PATH:()=>R$,DEFAULT_EXPORT_TIMEOUT_MS:()=>S0});function A8($=process.env){let Z=($.ROVECODE_OTEL_ENDPOINT??"").trim();return Z?{endpoint:Z,headers:r9($.ROVECODE_OTEL_HEADERS)}:null}function r9($){let Z={};for(let Q of($??"").split(",")){let J=Q.indexOf("=");if(J<=0)continue;let Y=Q.slice(0,J).trim();if(Y)Z[Y]=Q.slice(J+1).trim()}return Z}function R8($){w0.constructed++;let Z=$.now??E8,Q=$.serviceName??"rovecode",J=$.isLane??((P)=>!1),Y=$.pricing,z=new Map,V=0,K="",q=(P)=>{if($.onWarning){$.onWarning(P);return}V++,K=P},G=T9({endpoint:$.endpoint,headers:$.headers,fetch:$.fetch,timeoutMs:$.timeoutMs,warn:q}),W=l9(Z()),j=u9(),H=[];if(!E$($.endpoint))q(`ROVECODE_OTEL_ENDPOINT ${JSON.stringify($.endpoint)} is not an absolute http(s) URL \u2014 OTel export disabled`);let B=(P)=>P.runId===void 0?void 0:z.get(P.runId),L=(P,U,O)=>{let F={traceId:P.run.traceId,spanId:W$(8),parentSpanId:O.spanId,name:U,start:Z(),attrs:new Map,events:[],status:{code:0}};return P.spans.push(F),F},N=(P,U)=>{if(P.end===void 0)P.end=Z(),P.status=U},D=(P,U,O)=>{P.events.push({name:U,time:Z(),attrs:new Map(O)})},A=(P,U)=>{let O=P.attrs.get(U);return O&&"stringValue"in O?O.stringValue:void 0},h=(P)=>P.lastTurn??P.run,y=(P,U)=>`${h(P).spanId}:${U}`,I=(P,U,O,F=!1)=>{let w=y(P,U),T=P.tools.get(w);if(!T){if(T=L(P,"rovecode.tool",h(P)),T.attrs.set("rovecode.call_id",b(U)),F)T.attrs.set("rovecode.failure_reason",b("loop_guard"));P.tools.set(w,T),P.calls++}if(O!==void 0&&!T.attrs.has("rovecode.tool"))T.attrs.set("rovecode.tool",b(O));return T},S=(P,U,O)=>{if(P.end!==void 0)return;P.attrs.set("rovecode.ok",M$(U)),P.attrs.set("rovecode.output_bytes",v(Buffer.byteLength(O,"utf8"))),N(P,U?h0:d$(`tool ${A(P,"rovecode.tool")??"call"} failed`))},E=(P,U)=>{let O={input:0,output:0,cacheRead:0,cacheWrite:0},F=0;for(let T of U){if(!T.usage)continue;let x={input:T.usage.input,output:T.usage.output,cacheRead:T.usage.cacheRead??0,cacheWrite:T.usage.cacheWrite??0};if(O.input+=x.input,O.output+=x.output,O.cacheRead+=x.cacheRead,O.cacheWrite+=x.cacheWrite,F===null||x.input===0&&x.output===0&&x.cacheRead===0&&x.cacheWrite===0)continue;let z$=T.origin?(Y??=new l$).lookup(T.origin.provider,T.origin.model)?.pricing:void 0,L$=z$?n9(x,z$):void 0;F=L$===void 0?null:F+L$}for(let T of a9)P.attrs.set(`rovecode.tokens.${T}`,v(O[T]));if(F!==null)P.attrs.set("rovecode.cost_usd",w9(F));let w=U.at(-1)?.origin;if(w)P.attrs.set("rovecode.model.provider",b(w.provider)),P.attrs.set("rovecode.model.model",b(w.model));return{u:O,cost:F,served:w}},M=(P)=>P?[["rovecode.model.provider",b(P.provider)],["rovecode.model.model",b(P.model)]]:[],l=(P,U,O)=>{let F=M(U.served);for(let w of a9)W.addSum("rovecode.tokens","{token}",[["rovecode.token.type",b(w)],...F],U.u[w]);if(U.cost!==null)W.addSum("rovecode.cost_usd","USD",F,U.cost,!0);W.recordHistogram("rovecode.request.duration","ms",d9,[...F,["rovecode.stop_reason",b(O)]],(P.end??Z())-P.start)},i=(P)=>{let U=0;for(let O of z.values())for(let F of O.awaiting.keys())if(A(F,"rovecode.tool")===P)U++;return U},$$=(P,U,O)=>{let F=P.awaiting.get(U);if(F===void 0)return;let w=A(U,"rovecode.tool");if(w===void 0||j.pendingFor(w)===0){P.awaiting.delete(U);return}let T=i(w)===1;P.awaiting.delete(U);let x=T?{traceId:U.traceId,spanId:U.spanId,callId:A(U,"rovecode.call_id")??""}:void 0;j.resolve(w,F,O,Z(),x)},Z$=()=>{if(V===0)return;let P=V;throw V=0,Error(P===1?K:`${K} (${P} exports failed)`)},f=()=>{if(W.dirty)G.post("metrics",JSON.stringify(W.encode(Q,Z())))},t=()=>{let P=j.take();if(P.length>0)G.post("logs",JSON.stringify(g9(Q,P)))},Y$=(P,U)=>{let O=Z();for(let F of P.spans)if(F.end===void 0&&F!==P.run)F.end=O;P.run.attrs.set("rovecode.status",b(U)),P.run.attrs.set("rovecode.turns",v(P.spans.filter((F)=>F.name==="rovecode.turn").length)),P.run.attrs.set("rovecode.tool_calls",v(P.calls)),E(P.run,$.messages().slice(P.baseline).filter((F)=>F.role==="assistant")),P.run.end=O,P.run.status=U==="done"||U==="stopped"?h0:d$(U),G.post("traces",JSON.stringify(y$(Q,P.spans))),j.drain(O),f(),t()};return{flush:()=>G.flush(),openRuns:()=>z.size,observeTasks(P){w0.lanesObserved++;let U=f9(P,(O)=>G.post("traces",JSON.stringify(y$(Q,[O]))),Z);return H.push(U),U},recordRetry(P){let U=A$(P.reason).status;W.addSum("rovecode.request.retries","{retry}",[...M(P.model),...U!==void 0?[["rovecode.retry.status",v(U)]]:[]],1)},pre_run(P){if(P.runId===void 0)return;let U={traceId:W$(16),spanId:W$(8),name:"rovecode.run",start:Z(),attrs:new Map,events:[],status:{code:0}};U.attrs.set("rovecode.session_id",b(P.sessionId)),U.attrs.set("rovecode.run_id",b(P.runId));let O=$.messages().length;z.set(P.runId,{run:U,spans:[U],tools:new Map,awaiting:new Map,calls:0,baseline:O,seen:O}),Z$()},on_event(P,U){let O=B(P);if(!O)return;switch(U.type){case"turn_start":{if(O.turn)N(O.turn,O.turn.status);O.turn=O.lastTurn=L(O,"rovecode.turn",O.run),O.turn.attrs.set("rovecode.turn",v(U.turn));break}case"turn_end":{let F=O.turn??O.lastTurn;if(!F)break;F.attrs.set("rovecode.stop_reason",b(U.stopReason));let w=$.messages(),T=E(F,w.slice(O.seen).filter((x)=>x.role==="assistant"));O.seen=w.length,N(F,U.stopReason==="error"?d$("error"):h0),l(F,T,U.stopReason),O.turn=void 0;break}case"tool_execution_start":$$(O,I(O,U.callId,U.tool,!0),"allow");break;case"tool_execution_end":{let F=I(O,U.callId);O.awaiting.delete(F),F.attrs.set("rovecode.duration_ms",v(U.durationMs)),S(F,U.ok,U.output);break}case"tool_call_failed":{let F=O.tools.get(y(O,U.callId));if(F){if(U.reason==="permission_denied")$$(O,F,"deny");else O.awaiting.delete(F);F.attrs.set("rovecode.ok",M$(!1)),F.attrs.set("rovecode.failure_reason",b(U.reason)),N(F,d$(U.reason))}else O.calls++,D(O.turn??O.lastTurn??O.run,"rovecode.tool_call_failed",[["rovecode.call_id",b(U.callId)],["rovecode.failure_reason",b(U.reason)]]);break}case"compaction":D(O.turn??O.run,"rovecode.compaction",[["rovecode.compaction.strategy",b(U.strategy)],...U.trigger?[["rovecode.compaction.trigger",b(U.trigger)]]:[],["rovecode.compaction.tokens_before",v(U.tokensBefore)],["rovecode.compaction.tokens_after",v(U.tokensAfter)]]);break;default:break}},pre_tool(P,U){let O=B(P);if(!O)return;let F=I(O,U.id,U.tool);if(F.end===void 0&&!F.attrs.has("rovecode.ok"))O.awaiting.set(F,T0(U.args))},post_tool(P,U,O){let F=B(P);if(!F)return;let w=I(F,U.id,U.tool);$$(F,w,"allow"),S(w,O.ok,O.output)},approval(P,U){let O=U.revisedArgs,F=U.tool==="task"&&typeof O==="object"&&O!==null?O.agent:void 0,w=T0(U.args),T=w!==null&&[...z.values()].some((x)=>[...x.awaiting].some(([z$,L$])=>L$===w&&A(z$,"rovecode.tool")===U.tool));j.request({tool:U.tool,sessionId:P.sessionId,...J(F)?{lane:F}:{},fp:T?w:null,at:Z()})},post_run(P,U){let O=B(P);if(!O)return;z.delete(P.runId),Y$(O,U.status)},async session_close(){for(let[P,U]of z)z.delete(P),Y$(U,"stopped");for(let P of H.splice(0))P();j.drain(Z()),f(),t(),await G.flush(),Z$()}}}var w0,h0,d$=($)=>({code:2,message:$}),a9,E8=()=>performance.timeOrigin+performance.now();var s9=o(()=>{o9();x0();F0();c$();v9();m9();i9();H$();H$();c$();w0={constructed:0,lanesObserved:0},h0={code:1},a9=["input","output","cacheRead","cacheWrite"]});class JQ{manager;prompts=new Map;resources=new Map;gens=new Map;constructor($){this.manager=$;$.onListChanged((Z,Q)=>{if(Q==="tools")return;(Q==="prompts"?this.prompts:this.resources).delete(Z),this.gens.set(`${Q}:${Z}`,this.gen(Q,Z)+1)})}gen($,Z){return this.gens.get(`${$}:${Z}`)??0}opts($){return{timeout:this.manager.requestTimeoutMs,signal:$}}async promptsOf($,Z){let Q=this.prompts.get($),J=Date.now();if(Q&&J-Q.at<this.manager.ttlMs)return Q.items;let{client:Y,caps:z}=this.manager.connection($),V=this.gen("prompts",$),K=!z.prompts?[]:await i$("prompt",$,async(q)=>{let G=await B$(Z,(W)=>Y.listPrompts(q===void 0?void 0:{cursor:q},this.opts(W)));return{items:G.prompts.map((W)=>({server:$,name:W.name,description:u(W.description),arguments:(W.arguments??[]).map((j)=>({name:j.name,description:u(j.description),required:j.required===!0}))})),nextCursor:G.nextCursor}},Z);if(this.gen("prompts",$)===V)this.prompts.set($,{at:J,items:K});return K}async resourcesOf($,Z){let Q=this.resources.get($),J=Date.now();if(Q&&J-Q.at<this.manager.ttlMs)return Q.index;let{client:Y,caps:z}=this.manager.connection($),V=this.gen("resources",$),K={resources:[],templates:[]};if(z.resources){K.resources=await i$("resource",$,async(q)=>{let G=await B$(Z,(W)=>Y.listResources(q===void 0?void 0:{cursor:q},this.opts(W)));return{items:G.resources.map((W)=>({server:$,uri:W.uri,name:u(W.name),description:u(W.description),...e9(W.mimeType)})),nextCursor:G.nextCursor}},Z);try{K.templates=await i$("resource template",$,async(q)=>{let G=await B$(Z,(W)=>Y.listResourceTemplates(q===void 0?void 0:{cursor:q},this.opts(W)));return{items:G.resourceTemplates.map((W)=>({server:$,uriTemplate:W.uriTemplate,name:u(W.name),description:u(W.description),...e9(W.mimeType)})),nextCursor:G.nextCursor}},Z)}catch(q){if(!QQ(q))throw q}}if(this.gen("resources",$)===V)this.resources.set($,{at:J,index:K});return K}async listPrompts($){let Z=[],Q=[];for(let J of this.manager.connectedNames())try{Z.push(...await this.promptsOf(J,$))}catch(Y){Q.push(`${J}: ${r(Y)}`)}return{prompts:Z,notes:Q}}async listResources($){let Z={resources:[],templates:[]},Q=[];for(let J of this.manager.connectedNames())try{let Y=await this.resourcesOf(J,$);Z.resources.push(...Y.resources),Z.templates.push(...Y.templates)}catch(Y){Q.push(`${J}: ${r(Y)}`)}return{index:Z,notes:Q}}async getPrompt($,Z,Q,J){if(Q!==void 0&&Q!==null&&!a$(Q))return{ok:!1,output:`args for prompt ${$}/${Z} must be a JSON object (got ${Array.isArray(Q)?"array":typeof Q})`};let Y;try{Y=this.manager.connection($)}catch(V){return{ok:!1,output:r(V)}}if(!Y.caps.prompts)return{ok:!1,output:`MCP server "${$}" advertises no prompts`};let z={};for(let[V,K]of Object.entries(Q??{}))z[V]=typeof K==="string"?K:JSON.stringify(K);try{let V=await B$(J,(q)=>Y.client.getPrompt({name:Z,...Object.keys(z).length>0?{arguments:z}:{}},this.opts(q))),K=[];if(u(V.description))K.push(`# ${V.description}`);for(let q of V.messages)K.push(`[${q.role}] ${S8(q.content)}`);return{ok:!0,output:f0(K.join(`
|
|
2
|
+
import{sd as H2,td as B2,ud as YZ}from"./main-zzrfw6cf.js";import{wd as tQ,xd as o0,yd as V4}from"./main-0ab9fc26.js";import{Dd as W2,Gd as K4}from"./main-80haw7qk.js";import{Hd as V2,Id as q4}from"./main-6dnk69vp.js";import{Ld as N2}from"./main-w2n1303f.js";import{Qd as P4,Rd as U4}from"./main-0mtcdbs7.js";import{Wd as W4}from"./main-pn1w7a7j.js";import{$d as X4,Xd as P2,Yd as U2,_d as O2,be as zZ,ce as j4}from"./main-m1kk6fp5.js";import{fe as WZ,ge as qZ}from"./main-wsrg79c1.js";import{ie as eQ,je as $2}from"./main-ck9asesq.js";import{ke as Z2,le as Q2,me as J2}from"./main-kd488vje.js";import{De as j2}from"./main-6b62vkz0.js";import{Fe as J9,Ge as k3,Ie as Y9,Je as x3,Me as k9,Se as F2,Te as x9}from"./main-rdgdw24b.js";import{Ue as _0,Ve as q2,Xe as H9}from"./main-3pjrb2hd.js";import{cf as X9,ef as rQ,ff as j9}from"./main-351pz3z7.js";import{of as C$,pf as a,qf as v$,rf as SZ,sf as H0,vf as r0}from"./main-4b3jgy66.js";import{Jf as X2}from"./main-skbp13js.js";import{$f as ZZ,Kf as m0,Lf as K$,Mf as LQ,Nf as n$,Of as o$,Pf as NQ,ag as QZ,bg as JZ}from"./main-xvnrabfp.js";import{jg as VZ,ng as I2,rg as C2,sg as B4}from"./main-t4xnd213.js";import{Ag as L2}from"./main-3nf3kgve.js";import{Gg as sQ}from"./main-cta9racd.js";import{$g as e0,Lg as K2,Mg as G2,Ng as g$,Og as V9,Pg as t0,Zg as s0,ah as $Z,bh as G4}from"./main-1dchs7xv.js";import{ch as f0,fh as B$,gh as QQ,lh as i$,mh as M8}from"./main-rg0wn0xf.js";import{rh as D2,sh as _2,uh as H4}from"./main-y1fqy60y.js";import{Eh as Y2}from"./main-kcpbykxz.js";import{Qh as O$,Rh as FQ}from"./main-z3aayzvq.js";import{Th as D8,Uh as y0}from"./main-0z1w2zsg.js";import{qi as vQ,ti as Q4}from"./main-3gjqfh7a.js";import{ui as A0,vi as D9}from"./main-k2y8a2aw.js";import{Aj as aQ,Ej as nQ,tj as iQ}from"./main-90ds1z4e.js";import{Vj as dQ,Wj as n9,Yj as o9}from"./main-q3vsesf9.js";import{$j as l$,Zj as lQ,ck as x0}from"./main-xg704a3c.js";import{lk as AQ,uk as t8}from"./main-8kjxbpw4.js";import{Kk as oQ,Lk as z4}from"./main-gzkmycnv.js";import{Mk as bQ,Nk as yQ,Ok as A$,Pk as TQ,Qk as F0,Rk as G$,Sk as OQ,Uk as wQ,Xk as Z4,al as gQ,bl as uQ,cl as mQ,dl as pQ,el as J4,fl as cQ,ol as Y4}from"./main-3rxcvgna.js";import{Ll as hQ,Ml as $4}from"./main-4wndhjdc.js";import{Nl as tZ,Pl as n0,Rl as sZ}from"./main-ggcn7rd7.js";import{$l as MQ,Sl as EQ,am as SQ,bm as e8}from"./main-0904f6ps.js";import{hm as kQ,km as xQ,mm as fQ}from"./main-prxxs70n.js";import{rm as z2}from"./main-2zmzgkwh.js";import{Am as r,Fm as ZQ,zm as a$}from"./main-7rn6bqje.js";import{Hm as RQ,Jm as s8}from"./main-mv40pcr2.js";import{$m as X0,Lm as n}from"./main-2yeveeve.js";import{dn as i0,mn as a0,on as EZ,pn as j0,sn as MZ,tn as k2}from"./main-nqveez48.js";import{un as h$,vn as k0,wn as o}from"./main-qsevpgsv.js";import{randomBytes as U8}from"crypto";function b0($){let Z=$.trim().replace(/\/+$/,"");return Z.endsWith(R$)?Z:Z+R$}function E$($){try{let Z=new URL($.trim());return(Z.protocol==="http:"||Z.protocol==="https:")&&Z.hostname!==""}catch{return!1}}function T9($){let Z=p$($.endpoint),Q=E$($.endpoint),J={...$.headers??{},"content-type":"application/json"},Y=$.fetch??fetch,z=$.timeoutMs??S0,V=new Set,K=new Set,q=(W)=>`${Z}/v1/${W}`,G=async(W,j)=>{if(!Q||K.has(W))return;let H=q(W),B=(N)=>$.warn(`OTLP export to ${H} failed: ${N}`),L=new AbortController;try{let N=await L8(Y(H,{method:"POST",headers:J,body:j,signal:L.signal}),z,L);if(N===h9){B(`timed out after ${z}ms`);return}if(await N.arrayBuffer().catch(()=>{return}),N.ok)return;if(O8.has(N.status)){if(!K.has(W))K.add(W),$.warn(`OTLP collector ${Z} does not accept ${W} (HTTP ${N.status}) \u2014 ${W} export disabled`);return}B(`HTTP ${N.status}`)}catch(N){B(N8(N))}};return{base:Z,usable:Q,url:q,post(W,j){let H=G(W,j);V.add(H),H.then(()=>{V.delete(H)})},async flush(){while(V.size>0)await Promise.all([...V])},disabled:(W)=>K.has(W)}}function W$($){let Z;do Z=U8($).toString("hex");while(/^0+$/.test(Z));return Z}function L8($,Z,Q){return new Promise((J,Y)=>{let z=setTimeout(()=>{Q.abort(),J(h9)},Z);z.ref?.(),$.then((V)=>{clearTimeout(z),J(V)},(V)=>{clearTimeout(z),Y(V)})})}function N8($){if($ instanceof Error)return $.message;if(typeof $==="object"&&$!==null&&typeof $.message==="string")return $.message;return String($)}var S0=5000,R$="/v1/traces",O8,p$=($)=>b0($).slice(0,-R$.length),y9=($,Z)=>`${p$($)}/v1/${Z}`,h9;var c$=o(()=>{O8=new Set([404,405,501]);h9=Symbol("rovecode.otel.timeout")});function y$($,Z){return{resourceSpans:[{resource:{attributes:S$($)},scopeSpans:[{scope:b$(),spans:Z.map((Q)=>({traceId:Q.traceId,spanId:Q.spanId,...Q.parentSpanId?{parentSpanId:Q.parentSpanId}:{},name:Q.name,kind:1,startTimeUnixNano:d(Q.start),endTimeUnixNano:d(Q.end??Q.start),attributes:q$(Q.attrs),...Q.events.length>0?{events:Q.events.map((J)=>({name:J.name,timeUnixNano:d(J.time),attributes:q$(J.attrs)}))}:{},status:Q.status.message!==void 0?{code:Q.status.code,message:Q.status.message}:{code:Q.status.code}}))}]}]}}function d($){let Z=Math.floor($);return(BigInt(Z)*1000000n+BigInt(Math.round(($-Z)*1e6))).toString()}var b=($)=>({stringValue:$}),v=($)=>({intValue:String(Math.trunc($))}),w9=($)=>({doubleValue:$}),M$=($)=>({boolValue:$}),q$=($)=>[...$].map(([Z,Q])=>({key:Z,value:Q})),S$=($)=>q$([["service.name",b($)],["service.version",b(y0.version)]]),b$=()=>({name:"rovecode",version:y0.version});var H$=o(()=>{D8()});function f9($,Z,Q=Date.now){let J=new Map;return $.subscribe((Y)=>{if(Y.kind!=="external")return;if(Y.status==="running"){if(J.has(Y.id))return;let V={traceId:W$(16),spanId:W$(8),name:"rovecode.lane",start:Y.startedAt??Q(),attrs:new Map,events:[],status:{code:0}};V.attrs.set("rovecode.task_id",b(Y.id)),V.attrs.set("rovecode.lane",b(Y.agent)),V.attrs.set("rovecode.depth",v(Y.depth)),J.set(Y.id,V);return}if(!k9(Y.status))return;let z=J.get(Y.id);if(!z)return;J.delete(Y.id),Z(_8(z,Y))})}function _8($,Z){if($.attrs.set("rovecode.status",b(Z.status)),typeof Z.laneExit==="number")$.attrs.set("rovecode.exit_code",v(Z.laneExit));if(Z.laneModel)$.attrs.set("rovecode.lane.model",b(Z.laneModel));let Q=Z.usage;if(Q&&(Q.input!==0||Q.output!==0||(Q.cacheRead??0)!==0||(Q.cacheWrite??0)!==0))$.attrs.set("rovecode.tokens.input",v(Q.input)),$.attrs.set("rovecode.tokens.output",v(Q.output)),$.attrs.set("rovecode.tokens.cacheRead",v(Q.cacheRead??0)),$.attrs.set("rovecode.tokens.cacheWrite",v(Q.cacheWrite??0));if(Z.patchLines!==void 0)$.attrs.set("rovecode.patch_lines",v(Z.patchLines));return $.attrs.set("rovecode.lane.resumable",M$(Z.laneSession!==void 0&&Z.laneSession!=="")),$.end=Z.finishedAt??Date.now(),$.status=Z.status==="failed"?{code:2,message:"lane failed"}:{code:1},$}var v9=o(()=>{x9();c$();H$()});function g9($,Z){return{resourceLogs:[{resource:{attributes:S$($)},scopeLogs:[{scope:b$(),logRecords:Z.map((Q)=>({timeUnixNano:d(Q.time),observedTimeUnixNano:d(Q.time),severityNumber:Q.severityNumber,severityText:Q.severityText,body:{stringValue:Q.body},attributes:q$(Q.attrs),...Q.traceId?{traceId:Q.traceId}:{},...Q.spanId?{spanId:Q.spanId}:{}}))}]}]}}function u9(){let $=[],Z=[],Q=(J,Y,z,V)=>{let K=new Map([["rovecode.tool",b(J.tool)],["rovecode.session_id",b(J.sessionId)],["rovecode.decision",b(Y)]]);if(J.lane)K.set("rovecode.lane",b(J.lane));if(V)K.set("rovecode.call_id",b(V.callId));let q=Y==="deny";Z.push({time:z,severityNumber:q?C8:I8,severityText:q?"WARN":"INFO",body:"rovecode.approval",attrs:K,...V?{traceId:V.traceId,spanId:V.spanId}:{}})};return{request(J){$.push(J)},resolve(J,Y,z,V,K){let q=$.findIndex((W)=>W.tool===J&&(W.fp===null||Y===null||W.fp===Y));if(q<0)return!1;let[G]=$.splice(q,1);return Q(G,z,V,K),!0},pendingFor:(J)=>$.filter((Y)=>Y.tool===J).length,drain(J){for(let Y of $.splice(0))Q(Y,"unanswered",J)},take(){let J=Z;return Z=[],J},get size(){return Z.length}}}function T0($){try{return JSON.stringify($,(Z,Q)=>Q&&typeof Q==="object"&&!Array.isArray(Q)?Object.fromEntries(Object.entries(Q).sort(([J],[Y])=>J<Y?-1:J>Y?1:0)):Q)??null}catch{return null}}var I8=9,C8=13;var m9=o(()=>{H$()});function l9($){let Z=new Map,Q=!1,J=(z,V,K)=>{let q=Z.get(z);if(!q)q={kind:"sum",name:z,unit:V,asDouble:K,series:new Map},Z.set(z,q);if(q.kind!=="sum")throw Error(`metric ${z} is a ${q.kind}`);return q},Y=(z,V,K)=>{let q=Z.get(z);if(!q)q={kind:"histogram",name:z,unit:V,bounds:K,series:new Map},Z.set(z,q);if(q.kind!=="histogram")throw Error(`metric ${z} is a ${q.kind}`);return q};return{startMs:$,get dirty(){return Q},addSum(z,V,K,q,G=!1){if(!(q>=0)||!Number.isFinite(q))return;let W=J(z,V,G),j=c9(K),H=W.series.get(j)??{attrs:new Map(K),value:0};H.value+=q,W.series.set(j,H),Q=!0},recordHistogram(z,V,K,q,G){if(!Number.isFinite(G))return;let W=Y(z,V,K),j=c9(q),H=W.series.get(j)??{attrs:new Map(q),count:0,sum:0,buckets:Array(K.length+1).fill(0)};H.count++,H.sum+=G;let B=0;while(B<K.length&&G>K[B])B++;H.buckets[B]++,W.series.set(j,H),Q=!0},encode(z,V){return Q=!1,F8(z,[...Z.values()],$,V)}}}function F8($,Z,Q,J){let Y=d(Q),z=d(J),V=(q)=>({attributes:q$(q),startTimeUnixNano:Y,timeUnixNano:z}),K=Z.map((q)=>q.kind==="sum"?{name:q.name,unit:q.unit,sum:{dataPoints:[...q.series.values()].map((G)=>({...V(G.attrs),...q.asDouble?{asDouble:G.value}:{asInt:String(Math.trunc(G.value))}})),aggregationTemporality:p9,isMonotonic:!0}}:{name:q.name,unit:q.unit,histogram:{dataPoints:[...q.series.values()].map((G)=>({...V(G.attrs),count:String(G.count),sum:G.sum,bucketCounts:G.buckets.map(String),explicitBounds:[...q.bounds]})),aggregationTemporality:p9}});return{resourceMetrics:[{resource:{attributes:S$($)},scopeMetrics:[{scope:b$(),metrics:K}]}]}}var p9=2,d9,c9=($)=>JSON.stringify([...$].sort(([Z],[Q])=>Z<Q?-1:Z>Q?1:0));var i9=o(()=>{H$();d9=[100,250,500,1000,2500,5000,1e4,30000,60000]});var t9={};k0(t9,{validEndpoint:()=>E$,unixNano:()=>d,signalUrl:()=>y9,parseOtelHeaders:()=>r9,otelOptionsFromEnv:()=>A8,otelDebug:()=>w0,normalizeEndpoint:()=>b0,encodeTraceRequest:()=>y$,createOtelHooks:()=>R8,baseOf:()=>p$,OTLP_TRACES_PATH:()=>R$,DEFAULT_EXPORT_TIMEOUT_MS:()=>S0});function A8($=process.env){let Z=($.ROVECODE_OTEL_ENDPOINT??"").trim();return Z?{endpoint:Z,headers:r9($.ROVECODE_OTEL_HEADERS)}:null}function r9($){let Z={};for(let Q of($??"").split(",")){let J=Q.indexOf("=");if(J<=0)continue;let Y=Q.slice(0,J).trim();if(Y)Z[Y]=Q.slice(J+1).trim()}return Z}function R8($){w0.constructed++;let Z=$.now??E8,Q=$.serviceName??"rovecode",J=$.isLane??((P)=>!1),Y=$.pricing,z=new Map,V=0,K="",q=(P)=>{if($.onWarning){$.onWarning(P);return}V++,K=P},G=T9({endpoint:$.endpoint,headers:$.headers,fetch:$.fetch,timeoutMs:$.timeoutMs,warn:q}),W=l9(Z()),j=u9(),H=[];if(!E$($.endpoint))q(`ROVECODE_OTEL_ENDPOINT ${JSON.stringify($.endpoint)} is not an absolute http(s) URL \u2014 OTel export disabled`);let B=(P)=>P.runId===void 0?void 0:z.get(P.runId),L=(P,U,O)=>{let F={traceId:P.run.traceId,spanId:W$(8),parentSpanId:O.spanId,name:U,start:Z(),attrs:new Map,events:[],status:{code:0}};return P.spans.push(F),F},N=(P,U)=>{if(P.end===void 0)P.end=Z(),P.status=U},D=(P,U,O)=>{P.events.push({name:U,time:Z(),attrs:new Map(O)})},A=(P,U)=>{let O=P.attrs.get(U);return O&&"stringValue"in O?O.stringValue:void 0},h=(P)=>P.lastTurn??P.run,y=(P,U)=>`${h(P).spanId}:${U}`,I=(P,U,O,F=!1)=>{let w=y(P,U),T=P.tools.get(w);if(!T){if(T=L(P,"rovecode.tool",h(P)),T.attrs.set("rovecode.call_id",b(U)),F)T.attrs.set("rovecode.failure_reason",b("loop_guard"));P.tools.set(w,T),P.calls++}if(O!==void 0&&!T.attrs.has("rovecode.tool"))T.attrs.set("rovecode.tool",b(O));return T},S=(P,U,O)=>{if(P.end!==void 0)return;P.attrs.set("rovecode.ok",M$(U)),P.attrs.set("rovecode.output_bytes",v(Buffer.byteLength(O,"utf8"))),N(P,U?h0:d$(`tool ${A(P,"rovecode.tool")??"call"} failed`))},E=(P,U)=>{let O={input:0,output:0,cacheRead:0,cacheWrite:0},F=0;for(let T of U){if(!T.usage)continue;let x={input:T.usage.input,output:T.usage.output,cacheRead:T.usage.cacheRead??0,cacheWrite:T.usage.cacheWrite??0};if(O.input+=x.input,O.output+=x.output,O.cacheRead+=x.cacheRead,O.cacheWrite+=x.cacheWrite,F===null||x.input===0&&x.output===0&&x.cacheRead===0&&x.cacheWrite===0)continue;let z$=T.origin?(Y??=new l$).lookup(T.origin.provider,T.origin.model)?.pricing:void 0,L$=z$?n9(x,z$):void 0;F=L$===void 0?null:F+L$}for(let T of a9)P.attrs.set(`rovecode.tokens.${T}`,v(O[T]));if(F!==null)P.attrs.set("rovecode.cost_usd",w9(F));let w=U.at(-1)?.origin;if(w)P.attrs.set("rovecode.model.provider",b(w.provider)),P.attrs.set("rovecode.model.model",b(w.model));return{u:O,cost:F,served:w}},M=(P)=>P?[["rovecode.model.provider",b(P.provider)],["rovecode.model.model",b(P.model)]]:[],l=(P,U,O)=>{let F=M(U.served);for(let w of a9)W.addSum("rovecode.tokens","{token}",[["rovecode.token.type",b(w)],...F],U.u[w]);if(U.cost!==null)W.addSum("rovecode.cost_usd","USD",F,U.cost,!0);W.recordHistogram("rovecode.request.duration","ms",d9,[...F,["rovecode.stop_reason",b(O)]],(P.end??Z())-P.start)},i=(P)=>{let U=0;for(let O of z.values())for(let F of O.awaiting.keys())if(A(F,"rovecode.tool")===P)U++;return U},$$=(P,U,O)=>{let F=P.awaiting.get(U);if(F===void 0)return;let w=A(U,"rovecode.tool");if(w===void 0||j.pendingFor(w)===0){P.awaiting.delete(U);return}let T=i(w)===1;P.awaiting.delete(U);let x=T?{traceId:U.traceId,spanId:U.spanId,callId:A(U,"rovecode.call_id")??""}:void 0;j.resolve(w,F,O,Z(),x)},Z$=()=>{if(V===0)return;let P=V;throw V=0,Error(P===1?K:`${K} (${P} exports failed)`)},f=()=>{if(W.dirty)G.post("metrics",JSON.stringify(W.encode(Q,Z())))},t=()=>{let P=j.take();if(P.length>0)G.post("logs",JSON.stringify(g9(Q,P)))},Y$=(P,U)=>{let O=Z();for(let F of P.spans)if(F.end===void 0&&F!==P.run)F.end=O;P.run.attrs.set("rovecode.status",b(U)),P.run.attrs.set("rovecode.turns",v(P.spans.filter((F)=>F.name==="rovecode.turn").length)),P.run.attrs.set("rovecode.tool_calls",v(P.calls)),E(P.run,$.messages().slice(P.baseline).filter((F)=>F.role==="assistant")),P.run.end=O,P.run.status=U==="done"||U==="stopped"?h0:d$(U),G.post("traces",JSON.stringify(y$(Q,P.spans))),j.drain(O),f(),t()};return{flush:()=>G.flush(),openRuns:()=>z.size,observeTasks(P){w0.lanesObserved++;let U=f9(P,(O)=>G.post("traces",JSON.stringify(y$(Q,[O]))),Z);return H.push(U),U},recordRetry(P){let U=A$(P.reason).status;W.addSum("rovecode.request.retries","{retry}",[...M(P.model),...U!==void 0?[["rovecode.retry.status",v(U)]]:[]],1)},pre_run(P){if(P.runId===void 0)return;let U={traceId:W$(16),spanId:W$(8),name:"rovecode.run",start:Z(),attrs:new Map,events:[],status:{code:0}};U.attrs.set("rovecode.session_id",b(P.sessionId)),U.attrs.set("rovecode.run_id",b(P.runId));let O=$.messages().length;z.set(P.runId,{run:U,spans:[U],tools:new Map,awaiting:new Map,calls:0,baseline:O,seen:O}),Z$()},on_event(P,U){let O=B(P);if(!O)return;switch(U.type){case"turn_start":{if(O.turn)N(O.turn,O.turn.status);O.turn=O.lastTurn=L(O,"rovecode.turn",O.run),O.turn.attrs.set("rovecode.turn",v(U.turn));break}case"turn_end":{let F=O.turn??O.lastTurn;if(!F)break;F.attrs.set("rovecode.stop_reason",b(U.stopReason));let w=$.messages(),T=E(F,w.slice(O.seen).filter((x)=>x.role==="assistant"));O.seen=w.length,N(F,U.stopReason==="error"?d$("error"):h0),l(F,T,U.stopReason),O.turn=void 0;break}case"tool_execution_start":$$(O,I(O,U.callId,U.tool,!0),"allow");break;case"tool_execution_end":{let F=I(O,U.callId);O.awaiting.delete(F),F.attrs.set("rovecode.duration_ms",v(U.durationMs)),S(F,U.ok,U.output);break}case"tool_call_failed":{let F=O.tools.get(y(O,U.callId));if(F){if(U.reason==="permission_denied")$$(O,F,"deny");else O.awaiting.delete(F);F.attrs.set("rovecode.ok",M$(!1)),F.attrs.set("rovecode.failure_reason",b(U.reason)),N(F,d$(U.reason))}else O.calls++,D(O.turn??O.lastTurn??O.run,"rovecode.tool_call_failed",[["rovecode.call_id",b(U.callId)],["rovecode.failure_reason",b(U.reason)]]);break}case"compaction":D(O.turn??O.run,"rovecode.compaction",[["rovecode.compaction.strategy",b(U.strategy)],...U.trigger?[["rovecode.compaction.trigger",b(U.trigger)]]:[],["rovecode.compaction.tokens_before",v(U.tokensBefore)],["rovecode.compaction.tokens_after",v(U.tokensAfter)]]);break;default:break}},pre_tool(P,U){let O=B(P);if(!O)return;let F=I(O,U.id,U.tool);if(F.end===void 0&&!F.attrs.has("rovecode.ok"))O.awaiting.set(F,T0(U.args))},post_tool(P,U,O){let F=B(P);if(!F)return;let w=I(F,U.id,U.tool);$$(F,w,"allow"),S(w,O.ok,O.output)},approval(P,U){let O=U.revisedArgs,F=U.tool==="task"&&typeof O==="object"&&O!==null?O.agent:void 0,w=T0(U.args),T=w!==null&&[...z.values()].some((x)=>[...x.awaiting].some(([z$,L$])=>L$===w&&A(z$,"rovecode.tool")===U.tool));j.request({tool:U.tool,sessionId:P.sessionId,...J(F)?{lane:F}:{},fp:T?w:null,at:Z()})},post_run(P,U){let O=B(P);if(!O)return;z.delete(P.runId),Y$(O,U.status)},async session_close(){for(let[P,U]of z)z.delete(P),Y$(U,"stopped");for(let P of H.splice(0))P();j.drain(Z()),f(),t(),await G.flush(),Z$()}}}var w0,h0,d$=($)=>({code:2,message:$}),a9,E8=()=>performance.timeOrigin+performance.now();var s9=o(()=>{o9();x0();F0();c$();v9();m9();i9();H$();H$();c$();w0={constructed:0,lanesObserved:0},h0={code:1},a9=["input","output","cacheRead","cacheWrite"]});class JQ{manager;prompts=new Map;resources=new Map;gens=new Map;constructor($){this.manager=$;$.onListChanged((Z,Q)=>{if(Q==="tools")return;(Q==="prompts"?this.prompts:this.resources).delete(Z),this.gens.set(`${Q}:${Z}`,this.gen(Q,Z)+1)})}gen($,Z){return this.gens.get(`${$}:${Z}`)??0}opts($){return{timeout:this.manager.requestTimeoutMs,signal:$}}async promptsOf($,Z){let Q=this.prompts.get($),J=Date.now();if(Q&&J-Q.at<this.manager.ttlMs)return Q.items;let{client:Y,caps:z}=this.manager.connection($),V=this.gen("prompts",$),K=!z.prompts?[]:await i$("prompt",$,async(q)=>{let G=await B$(Z,(W)=>Y.listPrompts(q===void 0?void 0:{cursor:q},this.opts(W)));return{items:G.prompts.map((W)=>({server:$,name:W.name,description:u(W.description),arguments:(W.arguments??[]).map((j)=>({name:j.name,description:u(j.description),required:j.required===!0}))})),nextCursor:G.nextCursor}},Z);if(this.gen("prompts",$)===V)this.prompts.set($,{at:J,items:K});return K}async resourcesOf($,Z){let Q=this.resources.get($),J=Date.now();if(Q&&J-Q.at<this.manager.ttlMs)return Q.index;let{client:Y,caps:z}=this.manager.connection($),V=this.gen("resources",$),K={resources:[],templates:[]};if(z.resources){K.resources=await i$("resource",$,async(q)=>{let G=await B$(Z,(W)=>Y.listResources(q===void 0?void 0:{cursor:q},this.opts(W)));return{items:G.resources.map((W)=>({server:$,uri:W.uri,name:u(W.name),description:u(W.description),...e9(W.mimeType)})),nextCursor:G.nextCursor}},Z);try{K.templates=await i$("resource template",$,async(q)=>{let G=await B$(Z,(W)=>Y.listResourceTemplates(q===void 0?void 0:{cursor:q},this.opts(W)));return{items:G.resourceTemplates.map((W)=>({server:$,uriTemplate:W.uriTemplate,name:u(W.name),description:u(W.description),...e9(W.mimeType)})),nextCursor:G.nextCursor}},Z)}catch(q){if(!QQ(q))throw q}}if(this.gen("resources",$)===V)this.resources.set($,{at:J,index:K});return K}async listPrompts($){let Z=[],Q=[];for(let J of this.manager.connectedNames())try{Z.push(...await this.promptsOf(J,$))}catch(Y){Q.push(`${J}: ${r(Y)}`)}return{prompts:Z,notes:Q}}async listResources($){let Z={resources:[],templates:[]},Q=[];for(let J of this.manager.connectedNames())try{let Y=await this.resourcesOf(J,$);Z.resources.push(...Y.resources),Z.templates.push(...Y.templates)}catch(Y){Q.push(`${J}: ${r(Y)}`)}return{index:Z,notes:Q}}async getPrompt($,Z,Q,J){if(Q!==void 0&&Q!==null&&!a$(Q))return{ok:!1,output:`args for prompt ${$}/${Z} must be a JSON object (got ${Array.isArray(Q)?"array":typeof Q})`};let Y;try{Y=this.manager.connection($)}catch(V){return{ok:!1,output:r(V)}}if(!Y.caps.prompts)return{ok:!1,output:`MCP server "${$}" advertises no prompts`};let z={};for(let[V,K]of Object.entries(Q??{}))z[V]=typeof K==="string"?K:JSON.stringify(K);try{let V=await B$(J,(q)=>Y.client.getPrompt({name:Z,...Object.keys(z).length>0?{arguments:z}:{}},this.opts(q))),K=[];if(u(V.description))K.push(`# ${V.description}`);for(let q of V.messages)K.push(`[${q.role}] ${S8(q.content)}`);return{ok:!0,output:f0(K.join(`
|
|
3
3
|
`),"mcp prompt")}}catch(V){let K="";try{let q=(await this.promptsOf($,J)).map((G)=>G.name);if(!q.includes(Z))K=`. Available prompts: ${q.length>0?q.join(", "):"(none)"}`}catch{}return{ok:!1,output:`mcp prompt ${$}/${Z} failed: ${r(V)}${K}`}}}async readResource($,Z,Q){let J;try{J=this.manager.connection($)}catch(Y){return{ok:!1,output:r(Y)}}if(!J.caps.resources)return{ok:!1,output:`MCP server "${$}" advertises no resources`};try{let z=(await B$(Q,(V)=>J.client.readResource({uri:Z},this.opts(V)))).contents.map((V)=>YQ(V)).join(`
|
|
4
4
|
`);return{ok:!0,output:f0(z,"mcp resource")||`(empty resource ${Z})`}}catch(Y){return{ok:!1,output:`mcp read ${$} ${Z} failed: ${r(Y)}`}}}counts($){let Z={},Q=this.prompts.get($);if(Q)Z.prompts=Q.items.length;let J=this.resources.get($);if(J)Z.resources=J.index.resources.length,Z.templates=J.index.templates.length;return Z}async prefetch($){return await this.manager.listTools(!1,$),[...(await this.listPrompts($)).notes,...(await this.listResources($)).notes]}}function YQ($){if(!a$($))return"";if(typeof $.text==="string")return $.text;if(typeof $.blob==="string"){let Z=$.blob,Q=Math.floor(Z.length*3/4)-(Z.endsWith("==")?2:Z.endsWith("=")?1:0);return`[blob ${u($.uri)} ${u($.mimeType)||"application/octet-stream"} ${Q} bytes, base64 follows]
|
|
5
5
|
${Z}`}return`[resource ${u($.uri)}: no text or blob content]`}function S8($){if(!a$($))return"";switch($.type){case"text":return u($.text);case"resource":return`[embedded resource]
|
|
@@ -133,4 +133,4 @@ MCP servers configured for this session: ${R.join(", ")}. mcp_list returns their
|
|
|
133
133
|
|
|
134
134
|
# Tool calling
|
|
135
135
|
${O0(B.list().map((_$)=>_$.schema))}`:X$,...OZ().length>0?{contextChunks:OZ()}:{}}},y2=`${Z.replace(/[\/]$/,"")}${L4}*`,k$={},DZ=(X,_)=>{let C=X===!0?"auto":X===!1?"ask":X,R=C==="auto",k=k$.maxSeconds??O$(process.env.ROVECODE_MAX_SECONDS),m=k$.maxCostUsd??FQ(process.env.ROVECODE_MAX_COST),D$=(g,c)=>{let I$=N$.lookup(c.provider,c.model);if(!I$?.pricing)return;let f$={input:g.input,output:g.output,cacheRead:g.cacheRead??0,cacheWrite:g.cacheWrite??0};return dQ(f$,lQ(I$,f$.input+f$.cacheRead+f$.cacheWrite))},X$=()=>{try{let g=VZ(e(V,j.id)).items;return g.length===0?null:{open:g.filter((c)=>c.status!=="completed").length,total:g.length}}catch{return null}},_$=process.env.ROVECODE_VERIFY==="1",CZ=(O$(process.env.ROVECODE_VERIFY_TIMEOUT)??mQ/1000)*1000,w2=()=>{let g=($.verifyResolver??gQ)(Z);return{resolution:g,timeoutMs:CZ,run:async(c)=>{let I$=await pQ(g??{commands:[]},Z,{signal:c,timeoutMs:CZ});return uQ(Z,I$),I$}}};return _Z={maxTurns:k$.maxTurns??O$(process.env.ROVECODE_MAX_TURNS)??Number.MAX_SAFE_INTEGER,..._$?{verify:w2()}:{},...k!==void 0?{maxSeconds:k}:{},...m!==void 0?{maxCostUsd:m,priceUsd:D$}:{},finishCheck:process.env.ROVECODE_FINISH_CHECK!=="0",todoState:X$,contextBudgetTokens:(()=>{let g=G0??Z0,c=N$.lookup(g.provider,g.model);return W2({...c?.contextWindow!==void 0?{window:c.contextWindow}:{},...c?.maxOutput!==void 0?{maxOutput:c.maxOutput}:{},...O$(process.env.ROVECODE_CONTEXT_BUDGET)!==void 0?{override:O$(process.env.ROVECODE_CONTEXT_BUDGET)}:{},scale:V2(g).charScale})})(),compactionThreshold:0.8,compactionStrategy:wQ(process.env.ROVECODE_COMPACTION)??"head-summarize",parallelTools:!0,permissionRules:R?[{action:"*",resource:"*",effect:"allow"}]:[{action:"file.read",resource:"*",effect:"allow"},{action:EQ,resource:"*",effect:"prompt"},...z.rules(),{action:"memory.write",resource:"*",effect:"allow"},{action:"tool.skill_view",resource:"*",effect:"allow"},{action:"tool.skills_list",resource:"*",effect:"allow"},{action:"file.write",resource:"*",effect:"prompt"},{action:"shell.exec",resource:"*",effect:"prompt"},{action:"spawn",resource:"*",effect:"prompt"},{action:"tool.mcp_call",resource:"*",effect:"prompt"},{action:"tool.provider_edit",resource:"*",effect:"prompt"},{action:"tool.design_direction",resource:"*",effect:"prompt"},{action:"tool.design_direction",resource:"get",effect:"allow"},{action:"net.fetch",resource:"*",effect:"prompt"},...C==="accept-edits"?[{action:"file.write",resource:y2,effect:"allow"},...z.acceptEditsRules()]:[]],approval:R?void 0:z9(N2(O.approver(_)),$.lanes?.env)}},_Z=null,G0=null,x$=new cQ,T2=(X,_,C)=>{let R=new n0,k=[s0,e0,$Z,t0,ZZ,QZ,JZ,...o0(M),zZ(V)];if(C)k.push(WZ(V$,{parentDepth:C.depth,notify:C.steering,caller:C.taskId,owner:C.signal,agents:Y$,parentDir:C.dir??_,parentTools:()=>new Set(R.list().map((m)=>m.schema.name))}),qZ(V$,{caller:C.taskId}));if(s)k.push(...GZ(s));return R.register(...U9(k,X.tools,C?.parentTools??new Set(B.list().map((m)=>m.schema.name)))),R},h2=(X)=>{let _=new Map([["main",K0(X,{child:!0})]]);for(let C of t.agents)_.set(C.name,K0(C.model!==void 0?bQ(C.model,X.provider):X,{agent:C,child:!0}));return _},V$=new F2({deps:()=>Q0?{defs:h2(G0??Z0),stream:Q0,registryFactory:T2,rootDir:Z,sessionsDir:V,toolPrompt:(X,_)=>NZ(X)?O0(_):"",baseConfig:_Z??DZ(!1),hooks:O}:null,lanes:$.lanes});if(V$.attach(x$),Y0?.observeTasks(V$),$9())O.add(Z9({steering:x$,owns:(X)=>X.sessionId===j.id}),"reflection");B.register(WZ(V$,{parentDepth:0,agents:Y$}),qZ(V$));let IZ=new K2({notify:x$});return G2(IZ),B.register(...q9),{cwd:Z,sessionId:K,store:q,registry:B,skillStore:M,get blockStore(){return i},setBlockStore(X){i=X,B.register(r0(X))},guard:U,planReminder:Z$,get mcp(){return s},reloadMcp:R2,projectContext:z0,router:HZ,roots:z,agents:t,get effort(){return q0},setEffort(X){q0=X},setRunLimits(X){k$=X},drainRouterNotes:()=>s$.splice(0),onRouterNote(X){for(let _ of s$.splice(0))X(_);e$.push(X)},checkpointsFor:W,setSessionStore(X){j=X},sandbox:Y,setAskUser(X){P=X},hooks:O,plugins:T,providers:f,get provider(){return f.defaultConfig()},stream:Q0,get defaultModel(){return f.defaultRef()?.model??process.env.ROVECODE_MODEL??""},noProviderReason:()=>$.stream===void 0&&!f.configured()?C4:null,systemPrompt:LZ,buildDef:K0,buildCfg:DZ,warmRepoMap:b2,stopRepoMapWarmup:S2,steering:x$,tasks:V$,bashJobs:IZ}}var C4=AQ("cli");async function n1($={}){let Z=I4($);try{await Z.sandbox.ready,await Z.hooks.ready,await Z.plugins.ready}catch(Q){throw await Z.mcp?.close().catch(()=>{}),Q}return Z}
|
|
136
|
-
export{b4 as
|
|
136
|
+
export{b4 as ld,G9 as md,d3 as nd,D4 as od,I4 as pd,C4 as qd,n1 as rd};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cf as rJ,vf as XJ}from"./main-xfekqh9m.js";import{$f as PJ,ag as NJ,bg as RJ,cg as a,lg as WQ}from"./main-rvetps99.js";import{xj as HJ,yj as lJ}from"./main-2rzbexn2.js";import{Mk as DJ,Nk as BJ,Qk as pJ,rk as KJ,sk as cJ}from"./main-qj2djy17.js";import{Sk as n,bl as $Q}from"./main-6dtqmbt6.js";import{wn as x}from"./main-qsevpgsv.js";var E,w,AQ,d=50,yQ=100,xQ=30,fQ;var c=x(()=>{E={BOLD:1,DIM:2,ITALIC:4,UNDERLINE:8,INVERSE:16,STRIKE:32},w=["night","ember","contrast"],AQ=["code","files","plan"],fQ=["\u25C7","\u25C8","\u25C6","\u25C8"]});import{isAbsolute as JJ,relative as yJ}from"path";function M(J,Q){let Z=[...J];return Z.length<=Q?J:Z.slice(0,Math.max(0,Q-1)).join("")+"\u2026"}function r(J,Q=ZJ){let Z=J.split(/\r?\n/).find(($)=>$.trim().length>0)??"";return M(Z.replace(/\s+/g," ").trim(),Q)}function CJ(J,Q=ZJ){let Z=J.split(/\r?\n/).filter(($)=>$.trim().length>0);return M((Z[Z.length-1]??"").replace(/\s+/g," ").trim(),Q)}function $J(J,Q){if(!Q)return"";let Z=Q;if(JJ(Q)){let $=yJ(J,Q);Z=$&&!$.startsWith("..")&&!JJ($)?$:Q}else if(hJ.test(Q)){let $=l(Q),V=l(J).replace(/\/+$/,"");if(V&&$.toLowerCase().startsWith(V.toLowerCase()+"/"))Z=$.slice(V.length+1)}return l(Z).replace(/^\.\/+/,"")}function mJ(J){try{return new URL(J).host||M(J,g)}catch{return M(J,g)||"url"}}function WJ(J,Q,Z){let $=QJ(Q);switch(J){case"read":{let V=p($.offset),Y=p($.limit),W=V!==void 0||Y!==void 0?[V??1,(V??1)+(Y??2000)-1]:null;return C("read",Z,$,"READING","reading",{hl:W})}case"edit":{let V=Array.isArray($.edits)?$.edits:[],Y=0,W=1/0,G=-1/0;for(let D of V){let j=QJ(D),U=Array.isArray(j.newLines)?j.newLines.length:0;Y+=U;let F=p(j.anchorLine);if(F!==void 0)W=Math.min(W,F),G=Math.max(G,F+Math.max(0,U-1))}return C("edit",Z,$,"EDITING","editing",{add:Y,del:V.length,hl:W<=G?[W,G]:null})}case"write":{let V=R($.content);return C("write",Z,$,"EDITING","writing",{add:V?V.split(/\r?\n/).length:0})}case"remove":case"rm":case"delete":case"unlink":return C("remove",Z,$,"EDITING","removing");case"bash":case"shell":case"run":{let V=R($.command)||R($.cmd),Y=uJ(V)||"command",W=fJ.test(V);return{verb:"run",label:Y,path:null,touch:!1,state:W?"TESTING":"RUNNING",activity:W?"running tests":`running ${Y}`,hl:null,add:0,del:0,cmd:V}}case"glob":case"grep":{let V=M(R($.pattern),g)||J;return{verb:"search",label:V,path:null,touch:!1,state:"READING",activity:`searching ${V}`,hl:null,add:0,del:0,cmd:null}}case"ls":{let V=$J(Z,R($.path))||".";return{verb:"other",label:V,path:null,touch:!1,state:"READING",activity:`listing ${V}`,hl:null,add:0,del:0,cmd:null}}case"web_fetch":{let V=mJ(R($.url));return{verb:"fetch",label:V,path:null,touch:!1,state:"READING",activity:`fetching ${V}`,hl:null,add:0,del:0,cmd:null}}case"task":{let V=M(R($.label)||R($.agent)||"task",g);return{verb:"task",label:V,path:null,touch:!1,state:"DELEGATING",activity:`delegating ${V}`,hl:null,add:0,del:0,cmd:null}}case"ask_user":return{verb:"other",label:M(r(R($.question),g)||"question",g),path:null,touch:!1,state:"WAITING",activity:"waiting for you",hl:null,add:0,del:0,cmd:null};case"todo_write":case"todo_read":return{verb:"other",label:"todos",path:null,touch:!1,state:"THINKING",activity:"planning",hl:null,add:0,del:0,cmd:null};default:return{verb:"other",label:M(J,g),path:null,touch:!1,state:"RUNNING",activity:`running ${J}`,hl:null,add:0,del:0,cmd:null}}}function wJ(J){let Q=/\(showing lines (\d+)-(\d+) of (\d+)\)/.exec(J);if(Q){let Z=Number(Q[1]),$=Number(Q[2]);return $>=Z&&Z>0?$-Z+1:0}return J.split(/\r?\n/).filter((Z)=>/^\d+#/.test(Z)).length}function VJ(J,Q,Z,$){if(J.verb==="run"){let V=/^exit=(-?\d+)\r?\n?/.exec($),Y=V?$.slice(V[0].length):$,W=Y.split(/\r?\n/);while(W.length&&W[W.length-1].trim()==="")W.pop();return{detail:CJ(Y)||(V?`exit ${V[1]}`:""),runLines:W,...V?{exitCode:Number(V[1])}:{}}}if(!Z)return{detail:r(J.verb==="edit"||J.verb==="write"?dJ($):$)};switch(J.verb){case"read":return{detail:`${wJ($)} lines`};case"edit":return{};case"write":{let V=/\((\d+) bytes/.exec($);return V?{detail:`${V[1]} bytes`}:{}}case"remove":return{};case"search":{let V=$.split(/\r?\n/).filter((W)=>W.trim().length>0),Y=V.filter((W)=>!W.startsWith("(")).length;return{detail:`${Y} ${Q==="glob"?Y===1?"file":"files":Y===1?"match":"matches"}`,searchLines:V.slice(0,xJ)}}case"fetch":return{detail:`${$.length} chars`};default:return{detail:r($)}}}var g=48,ZJ=80,xJ=500,fJ,QJ=(J)=>J&&typeof J==="object"&&!Array.isArray(J)?J:{},R=(J)=>typeof J==="string"?J:"",p=(J)=>typeof J==="number"&&Number.isFinite(J)&&J>0?Math.floor(J):void 0,hJ,l=(J)=>J.replace(/\\/g,"/"),vJ=(J)=>J.slice(J.lastIndexOf("/")+1)||J,uJ=(J)=>M(J.replace(/\s+/g," ").trim(),g),C=(J,Q,Z,$,V,Y={})=>{let W=$J(Q,R(Z.path)),G=vJ(W)||"file";return{verb:J,label:G,path:W||null,touch:!0,state:$,activity:`${V} ${G}`,hl:null,add:0,del:0,cmd:null,...Y}},dJ=(J)=>J.replace(/ at \S.*?:\d+(?=\s|$)/,"");var jJ=x(()=>{fJ=/\b(tests?|vitest|jest|pytest|mocha|spec)\b/i;hJ=/^[A-Za-z]:[\\/]/});function lQ(J){return{cwd:J.cwd,repo:{name:J.repo.name,branch:J.repo.branch,modified:J.repo.modified??0},files:{paths:[],statuses:new Map,expanded:new Set,touched:new Map,cursor:0,scroll:0,version:0},activity:{state:"IDLE",label:"idle",runId:null,startedAt:null,endedAt:null},code:{mode:"code",file:null,content:null,hl:null,scroll:0,search:null,run:null,diff:null,lane:0,laneOpen:!1},messages:[],msgScroll:0,stick:!0,card:null,plan:{todos:[]},crew:[],usage:{provider:J.model?.provider??"",model:J.model?.model??"",turns:0,tokensIn:0,tokensOut:0,contextPct:null,costUsd:null},input:{text:"",cur:0,history:[],histIdx:-1,sgSel:0},focus:"messages",page:"code",palette:null,market:null,context:null,wizard:null,help:!1,toasts:[],notices:[],staged:[],escUntil:0,running:!1,mode:J.mode,yolo:J.yolo,theme:J.theme,bootAt:J.now,commands:J.commands,version:J.version}}function f(J){for(let Q of J.messages)if(Q.kind==="assistant")Q.streaming=!1}function i(J,Q){for(let Z=J.messages.length-1;Z>=0;Z--){let $=J.messages[Z];if($.kind==="tool"&&$.callId===Q)return $}return}function oJ(J,Q){let Z=Q.split(/\r?\n/).find((Y)=>Y.trim())?.trim()??"",$=J?`${J} \xB7 ${Z}`:Z,V=[...$];return V.length>UJ?"\u2026"+V.slice(V.length-UJ+1).join(""):$}function eJ(J,Q,Z){if(J.code.file!==Q)J.code.content=null,J.code.scroll=0;J.code.mode="code",J.code.file=Q,J.code.hl=Z}function tJ(J={}){let Q=new Map,Z=!1,$=0,V=(W)=>{if(W.activity.turnAt===void 0)return;let G=W.messages[W.messages.length-1];W.activity.tokens=$+(G&&G.kind==="assistant"&&G.streaming?KJ(G.text):0)},Y=(W)=>{delete W.activity.turnAt,delete W.activity.tokens};return(W,G,D)=>{switch(G.type){case"run_start":W.activity={state:"THINKING",label:"thinking",runId:G.runId,startedAt:D,endedAt:null},W.running=!0,W.stick=!0,Z=!1,$=0,Q.clear();break;case"turn_start":f(W),_(W,"THINKING","thinking"),W.usage.turns+=1,W.activity.turnAt=D,W.activity.tokens=0,$=0;break;case"message_update":{let j=W.messages[W.messages.length-1];if(j&&j.kind==="assistant"&&j.streaming)j.text+=G.delta;else f(W),N(W,{kind:"assistant",text:G.delta,streaming:!0,id:G.messageId});Z=!0,_(W,"WRITING","writing"),V(W);break}case"reasoning_update":$=G.tokens,V(W);break;case"tool_execution_start":{f(W),Y(W);let j=WJ(G.tool,G.args,W.cwd);Q.set(G.callId,{tool:G.tool,verb:j.verb,path:j.path,add:j.add,del:j.del,cmd:j.cmd});let U={kind:"tool",callId:G.callId,tool:G.tool,verb:j.verb,label:j.label,running:!0};if(j.path)U.path=j.path;if(j.verb==="edit"||j.verb==="write")U.add=j.add,U.del=j.del;if(N(W,U),_(W,j.state,j.activity),j.path&&j.touch)W.files.touched.set(j.path,D+iJ),JQ(W,j.path),W.files.version++;if(j.path&&(j.verb==="read"||j.verb==="edit"||j.verb==="write"))eJ(W,j.path,j.hl);if(j.verb==="run")W.code.mode="run",W.code.run={cmd:j.cmd??j.label,lines:[],status:"running"};if(j.verb==="search")W.code.mode="search",W.code.search={query:j.label,lines:[]};break}case"tool_execution_update":{let j=i(W,G.callId);if(j)j.detail=oJ(j.detail,G.note);break}case"tool_execution_end":{let j=Q.get(G.callId);Q.delete(G.callId);let U=i(W,G.callId);if(!U)U={kind:"tool",callId:G.callId,tool:j?.tool??"tool",verb:j?.verb??"other",label:j?.tool??G.callId,running:!0},N(W,U);U.running=!1,U.ok=G.ok,U.ms=G.durationMs;let F=VJ({verb:U.verb},U.tool,G.ok,G.output);if(F.detail)U.detail=F.detail;if(F.runLines&&W.code.run&&(!j?.cmd||W.code.run.cmd===j.cmd)){if(W.code.run.lines=F.runLines,W.code.run.status=G.ok?"ok":"fail",F.exitCode!==void 0)W.code.run.exitCode=F.exitCode}if(F.searchLines&&W.code.search)W.code.search.lines=F.searchLines;if(G.ok&&j?.path&&(U.verb==="edit"||U.verb==="write")){if(U.verb==="write")sJ(W,j.path);let K=J.diffFor?.(j.path,U.tool,W)??null;if(K)U.add=K.add,U.del=K.del,W.code.diff={file:j.path,...K},W.code.mode="diff"}if(!G.ok)_(W,"ERROR",`${U.verb} failed`,D);else if(!aJ(W))_(W,"THINKING","thinking");break}case"tool_call_failed":{Q.delete(G.callId),Y(W);let j=i(W,G.callId),U=G.reason.replace(/_/g," ");if(j)j.running=!1,j.ok=!1,j.detail=U;N(W,{kind:"system",tone:"error",text:`${U}: ${G.detail}`});let F=G.reason==="permission_denied"?"denied":U;_(W,"ERROR",j?`${j.label} ${F}`:F,D),h(W,j?`${j.label} ${F}`:`tool ${F}`,D,"error","error");break}case"compaction":N(W,{kind:"compaction",text:`compacted (${G.strategy}${G.trigger?`, ${G.trigger}`:""}): ${FJ(G.tokensBefore)} \u2192 ${FJ(G.tokensAfter)} tokens`});break;case"steer":N(W,{kind:"steer",text:G.text});break;case"verify":N(W,{kind:"system",tone:G.state==="running"||G.state==="passed"?"info":"warn",text:G.state==="running"?`\u29D7 verify: ${G.command}`:`verify ${G.state}: ${G.detail??""}`});break;case"turn_end":f(W),Y(W);break;case"run_end":{if(f(W),Y(W),G.status==="done"){if(_(W,"SUCCESS","done"),!Z&&G.summary)N(W,{kind:"assistant",text:G.summary,streaming:!1});let j=G.outstanding?DJ(G.outstanding):null,U=G.outstanding?BJ(G.outstanding):"info";if(j!==null)N(W,{kind:"system",tone:U,text:`done \xB7 ${j}`});h(W,j!==null?`run done \xB7 ${j}`:"run done",D,U,"done")}else if(G.status==="error"){if(_(W,"ERROR","error",D),G.summary)N(W,{kind:"system",tone:"error",text:G.summary});h(W,`run failed${G.summary?`: ${G.summary.split(`
|
|
2
|
+
import{lg as XJ,sg as rJ}from"./main-t4xnd213.js";import{Rg as PJ,Sg as NJ,Tg as RJ,Ug as a,bh as WQ}from"./main-1dchs7xv.js";import{Xj as HJ,Yj as lJ}from"./main-q3vsesf9.js";import{Rk as KJ,Sk as cJ,kl as DJ,ll as BJ,ol as pJ}from"./main-3rxcvgna.js";import{Bl as $Q,ql as n}from"./main-4wndhjdc.js";import{wn as x}from"./main-qsevpgsv.js";var E,w,AQ,d=50,yQ=100,xQ=30,fQ;var c=x(()=>{E={BOLD:1,DIM:2,ITALIC:4,UNDERLINE:8,INVERSE:16,STRIKE:32},w=["night","ember","contrast"],AQ=["code","files","plan"],fQ=["\u25C7","\u25C8","\u25C6","\u25C8"]});import{isAbsolute as JJ,relative as yJ}from"path";function M(J,Q){let Z=[...J];return Z.length<=Q?J:Z.slice(0,Math.max(0,Q-1)).join("")+"\u2026"}function r(J,Q=ZJ){let Z=J.split(/\r?\n/).find(($)=>$.trim().length>0)??"";return M(Z.replace(/\s+/g," ").trim(),Q)}function CJ(J,Q=ZJ){let Z=J.split(/\r?\n/).filter(($)=>$.trim().length>0);return M((Z[Z.length-1]??"").replace(/\s+/g," ").trim(),Q)}function $J(J,Q){if(!Q)return"";let Z=Q;if(JJ(Q)){let $=yJ(J,Q);Z=$&&!$.startsWith("..")&&!JJ($)?$:Q}else if(hJ.test(Q)){let $=l(Q),V=l(J).replace(/\/+$/,"");if(V&&$.toLowerCase().startsWith(V.toLowerCase()+"/"))Z=$.slice(V.length+1)}return l(Z).replace(/^\.\/+/,"")}function mJ(J){try{return new URL(J).host||M(J,g)}catch{return M(J,g)||"url"}}function WJ(J,Q,Z){let $=QJ(Q);switch(J){case"read":{let V=p($.offset),Y=p($.limit),W=V!==void 0||Y!==void 0?[V??1,(V??1)+(Y??2000)-1]:null;return C("read",Z,$,"READING","reading",{hl:W})}case"edit":{let V=Array.isArray($.edits)?$.edits:[],Y=0,W=1/0,G=-1/0;for(let D of V){let j=QJ(D),U=Array.isArray(j.newLines)?j.newLines.length:0;Y+=U;let F=p(j.anchorLine);if(F!==void 0)W=Math.min(W,F),G=Math.max(G,F+Math.max(0,U-1))}return C("edit",Z,$,"EDITING","editing",{add:Y,del:V.length,hl:W<=G?[W,G]:null})}case"write":{let V=R($.content);return C("write",Z,$,"EDITING","writing",{add:V?V.split(/\r?\n/).length:0})}case"remove":case"rm":case"delete":case"unlink":return C("remove",Z,$,"EDITING","removing");case"bash":case"shell":case"run":{let V=R($.command)||R($.cmd),Y=uJ(V)||"command",W=fJ.test(V);return{verb:"run",label:Y,path:null,touch:!1,state:W?"TESTING":"RUNNING",activity:W?"running tests":`running ${Y}`,hl:null,add:0,del:0,cmd:V}}case"glob":case"grep":{let V=M(R($.pattern),g)||J;return{verb:"search",label:V,path:null,touch:!1,state:"READING",activity:`searching ${V}`,hl:null,add:0,del:0,cmd:null}}case"ls":{let V=$J(Z,R($.path))||".";return{verb:"other",label:V,path:null,touch:!1,state:"READING",activity:`listing ${V}`,hl:null,add:0,del:0,cmd:null}}case"web_fetch":{let V=mJ(R($.url));return{verb:"fetch",label:V,path:null,touch:!1,state:"READING",activity:`fetching ${V}`,hl:null,add:0,del:0,cmd:null}}case"task":{let V=M(R($.label)||R($.agent)||"task",g);return{verb:"task",label:V,path:null,touch:!1,state:"DELEGATING",activity:`delegating ${V}`,hl:null,add:0,del:0,cmd:null}}case"ask_user":return{verb:"other",label:M(r(R($.question),g)||"question",g),path:null,touch:!1,state:"WAITING",activity:"waiting for you",hl:null,add:0,del:0,cmd:null};case"todo_write":case"todo_read":return{verb:"other",label:"todos",path:null,touch:!1,state:"THINKING",activity:"planning",hl:null,add:0,del:0,cmd:null};default:return{verb:"other",label:M(J,g),path:null,touch:!1,state:"RUNNING",activity:`running ${J}`,hl:null,add:0,del:0,cmd:null}}}function wJ(J){let Q=/\(showing lines (\d+)-(\d+) of (\d+)\)/.exec(J);if(Q){let Z=Number(Q[1]),$=Number(Q[2]);return $>=Z&&Z>0?$-Z+1:0}return J.split(/\r?\n/).filter((Z)=>/^\d+#/.test(Z)).length}function VJ(J,Q,Z,$){if(J.verb==="run"){let V=/^exit=(-?\d+)\r?\n?/.exec($),Y=V?$.slice(V[0].length):$,W=Y.split(/\r?\n/);while(W.length&&W[W.length-1].trim()==="")W.pop();return{detail:CJ(Y)||(V?`exit ${V[1]}`:""),runLines:W,...V?{exitCode:Number(V[1])}:{}}}if(!Z)return{detail:r(J.verb==="edit"||J.verb==="write"?dJ($):$)};switch(J.verb){case"read":return{detail:`${wJ($)} lines`};case"edit":return{};case"write":{let V=/\((\d+) bytes/.exec($);return V?{detail:`${V[1]} bytes`}:{}}case"remove":return{};case"search":{let V=$.split(/\r?\n/).filter((W)=>W.trim().length>0),Y=V.filter((W)=>!W.startsWith("(")).length;return{detail:`${Y} ${Q==="glob"?Y===1?"file":"files":Y===1?"match":"matches"}`,searchLines:V.slice(0,xJ)}}case"fetch":return{detail:`${$.length} chars`};default:return{detail:r($)}}}var g=48,ZJ=80,xJ=500,fJ,QJ=(J)=>J&&typeof J==="object"&&!Array.isArray(J)?J:{},R=(J)=>typeof J==="string"?J:"",p=(J)=>typeof J==="number"&&Number.isFinite(J)&&J>0?Math.floor(J):void 0,hJ,l=(J)=>J.replace(/\\/g,"/"),vJ=(J)=>J.slice(J.lastIndexOf("/")+1)||J,uJ=(J)=>M(J.replace(/\s+/g," ").trim(),g),C=(J,Q,Z,$,V,Y={})=>{let W=$J(Q,R(Z.path)),G=vJ(W)||"file";return{verb:J,label:G,path:W||null,touch:!0,state:$,activity:`${V} ${G}`,hl:null,add:0,del:0,cmd:null,...Y}},dJ=(J)=>J.replace(/ at \S.*?:\d+(?=\s|$)/,"");var jJ=x(()=>{fJ=/\b(tests?|vitest|jest|pytest|mocha|spec)\b/i;hJ=/^[A-Za-z]:[\\/]/});function lQ(J){return{cwd:J.cwd,repo:{name:J.repo.name,branch:J.repo.branch,modified:J.repo.modified??0},files:{paths:[],statuses:new Map,expanded:new Set,touched:new Map,cursor:0,scroll:0,version:0},activity:{state:"IDLE",label:"idle",runId:null,startedAt:null,endedAt:null},code:{mode:"code",file:null,content:null,hl:null,scroll:0,search:null,run:null,diff:null,lane:0,laneOpen:!1},messages:[],msgScroll:0,stick:!0,card:null,plan:{todos:[]},crew:[],usage:{provider:J.model?.provider??"",model:J.model?.model??"",turns:0,tokensIn:0,tokensOut:0,contextPct:null,costUsd:null},input:{text:"",cur:0,history:[],histIdx:-1,sgSel:0},focus:"messages",page:"code",palette:null,market:null,context:null,wizard:null,help:!1,toasts:[],notices:[],staged:[],escUntil:0,running:!1,mode:J.mode,yolo:J.yolo,theme:J.theme,bootAt:J.now,commands:J.commands,version:J.version}}function f(J){for(let Q of J.messages)if(Q.kind==="assistant")Q.streaming=!1}function i(J,Q){for(let Z=J.messages.length-1;Z>=0;Z--){let $=J.messages[Z];if($.kind==="tool"&&$.callId===Q)return $}return}function oJ(J,Q){let Z=Q.split(/\r?\n/).find((Y)=>Y.trim())?.trim()??"",$=J?`${J} \xB7 ${Z}`:Z,V=[...$];return V.length>UJ?"\u2026"+V.slice(V.length-UJ+1).join(""):$}function eJ(J,Q,Z){if(J.code.file!==Q)J.code.content=null,J.code.scroll=0;J.code.mode="code",J.code.file=Q,J.code.hl=Z}function tJ(J={}){let Q=new Map,Z=!1,$=0,V=(W)=>{if(W.activity.turnAt===void 0)return;let G=W.messages[W.messages.length-1];W.activity.tokens=$+(G&&G.kind==="assistant"&&G.streaming?KJ(G.text):0)},Y=(W)=>{delete W.activity.turnAt,delete W.activity.tokens};return(W,G,D)=>{switch(G.type){case"run_start":W.activity={state:"THINKING",label:"thinking",runId:G.runId,startedAt:D,endedAt:null},W.running=!0,W.stick=!0,Z=!1,$=0,Q.clear();break;case"turn_start":f(W),_(W,"THINKING","thinking"),W.usage.turns+=1,W.activity.turnAt=D,W.activity.tokens=0,$=0;break;case"message_update":{let j=W.messages[W.messages.length-1];if(j&&j.kind==="assistant"&&j.streaming)j.text+=G.delta;else f(W),N(W,{kind:"assistant",text:G.delta,streaming:!0,id:G.messageId});Z=!0,_(W,"WRITING","writing"),V(W);break}case"reasoning_update":$=G.tokens,V(W);break;case"tool_execution_start":{f(W),Y(W);let j=WJ(G.tool,G.args,W.cwd);Q.set(G.callId,{tool:G.tool,verb:j.verb,path:j.path,add:j.add,del:j.del,cmd:j.cmd});let U={kind:"tool",callId:G.callId,tool:G.tool,verb:j.verb,label:j.label,running:!0};if(j.path)U.path=j.path;if(j.verb==="edit"||j.verb==="write")U.add=j.add,U.del=j.del;if(N(W,U),_(W,j.state,j.activity),j.path&&j.touch)W.files.touched.set(j.path,D+iJ),JQ(W,j.path),W.files.version++;if(j.path&&(j.verb==="read"||j.verb==="edit"||j.verb==="write"))eJ(W,j.path,j.hl);if(j.verb==="run")W.code.mode="run",W.code.run={cmd:j.cmd??j.label,lines:[],status:"running"};if(j.verb==="search")W.code.mode="search",W.code.search={query:j.label,lines:[]};break}case"tool_execution_update":{let j=i(W,G.callId);if(j)j.detail=oJ(j.detail,G.note);break}case"tool_execution_end":{let j=Q.get(G.callId);Q.delete(G.callId);let U=i(W,G.callId);if(!U)U={kind:"tool",callId:G.callId,tool:j?.tool??"tool",verb:j?.verb??"other",label:j?.tool??G.callId,running:!0},N(W,U);U.running=!1,U.ok=G.ok,U.ms=G.durationMs;let F=VJ({verb:U.verb},U.tool,G.ok,G.output);if(F.detail)U.detail=F.detail;if(F.runLines&&W.code.run&&(!j?.cmd||W.code.run.cmd===j.cmd)){if(W.code.run.lines=F.runLines,W.code.run.status=G.ok?"ok":"fail",F.exitCode!==void 0)W.code.run.exitCode=F.exitCode}if(F.searchLines&&W.code.search)W.code.search.lines=F.searchLines;if(G.ok&&j?.path&&(U.verb==="edit"||U.verb==="write")){if(U.verb==="write")sJ(W,j.path);let K=J.diffFor?.(j.path,U.tool,W)??null;if(K)U.add=K.add,U.del=K.del,W.code.diff={file:j.path,...K},W.code.mode="diff"}if(!G.ok)_(W,"ERROR",`${U.verb} failed`,D);else if(!aJ(W))_(W,"THINKING","thinking");break}case"tool_call_failed":{Q.delete(G.callId),Y(W);let j=i(W,G.callId),U=G.reason.replace(/_/g," ");if(j)j.running=!1,j.ok=!1,j.detail=U;N(W,{kind:"system",tone:"error",text:`${U}: ${G.detail}`});let F=G.reason==="permission_denied"?"denied":U;_(W,"ERROR",j?`${j.label} ${F}`:F,D),h(W,j?`${j.label} ${F}`:`tool ${F}`,D,"error","error");break}case"compaction":N(W,{kind:"compaction",text:`compacted (${G.strategy}${G.trigger?`, ${G.trigger}`:""}): ${FJ(G.tokensBefore)} \u2192 ${FJ(G.tokensAfter)} tokens`});break;case"steer":N(W,{kind:"steer",text:G.text});break;case"verify":N(W,{kind:"system",tone:G.state==="running"||G.state==="passed"?"info":"warn",text:G.state==="running"?`\u29D7 verify: ${G.command}`:`verify ${G.state}: ${G.detail??""}`});break;case"turn_end":f(W),Y(W);break;case"run_end":{if(f(W),Y(W),G.status==="done"){if(_(W,"SUCCESS","done"),!Z&&G.summary)N(W,{kind:"assistant",text:G.summary,streaming:!1});let j=G.outstanding?DJ(G.outstanding):null,U=G.outstanding?BJ(G.outstanding):"info";if(j!==null)N(W,{kind:"system",tone:U,text:`done \xB7 ${j}`});h(W,j!==null?`run done \xB7 ${j}`:"run done",D,U,"done")}else if(G.status==="error"){if(_(W,"ERROR","error",D),G.summary)N(W,{kind:"system",tone:"error",text:G.summary});h(W,`run failed${G.summary?`: ${G.summary.split(`
|
|
3
3
|
`)[0].slice(0,80)}`:""}`,D,"error","error")}else _(W,"IDLE",G.status),N(W,{kind:"system",tone:"warn",text:`run ${G.status}: ${G.summary}`}),h(W,`run ${G.status}`,D,"warn","done");W.activity.endedAt=D,W.running=!1;for(let j of W.messages)if(j.kind==="tool"&&j.running)j.running=!1,j.ok=!1,j.detail??="interrupted";{let j=W.files.touched.size;for(let[U,F]of W.files.touched)if(F<=D)W.files.touched.delete(U);if(W.files.touched.size!==j)W.files.version++}Q.clear();break}}}}function iQ(J,Q,Z){J.files.paths=[...new Set(Q.map(YJ).filter(Boolean))].sort(v),J.files.statuses=new Map(Z?[...Z].map(([$,V])=>[YJ($),V]):[]),J.repo.modified=J.files.statuses.size,J.files.version++}function sJ(J,Q){if(J.files.paths.includes(Q))return;J.files.paths.push(Q),J.files.paths.sort(v),J.files.version++}function JQ(J,Q){let Z=Q.split("/"),$=!1;for(let V=1;V<Z.length;V++){let Y=Z.slice(0,V).join("/");if(!J.files.expanded.has(Y))J.files.expanded.add(Y),$=!0}if($)J.files.version++}function aQ(J){let Q=new Set(J.files.paths);for(let[Z,$]of J.files.statuses)if($==="D")Q.delete(Z);else Q.add(Z);return Q.size}function oQ(J,Q=-1){let Z=J.files.expanded.size;if(k&&k.files===J.files&&k.version===J.files.version&&k.expSz===Z&&k.now===Q)return k.rows;let $=new Set(J.files.paths);for(let D of J.files.statuses.keys())$.add(D);let V={name:"",path:"",kids:new Map};for(let D of[...$].sort(v)){let j=D.split("/").filter(Boolean),U=V;j.forEach((F,K)=>{let H=K===j.length-1,B=U.kids.get(F);if(!B)B={name:F,path:j.slice(0,K+1).join("/"),kids:H?null:new Map},U.kids.set(F,B);else if(!H&&!B.kids)B.kids=new Map;U=B})}let Y=(D)=>D.kids?[...D.kids.values()].some(Y):J.files.statuses.has(D.path),W=[],G=(D,j)=>{let U=[...D.kids.values()].sort((F,K)=>Number(!!K.kids)-Number(!!F.kids)||v(F.name,K.name));for(let F of U)if(F.kids){let K=J.files.expanded.has(F.path),H={path:F.path,name:F.name,depth:j,dir:!0,expanded:K};if(!K&&Y(F))H.hasChanges=!0;if(W.push(H),K)G(F,j+1)}else{let K={path:F.path,name:F.name,depth:j,dir:!1},H=J.files.statuses.get(F.path);if(H)K.status=H;let B=J.files.touched.get(F.path);if(B!==void 0)K.touchedUntil=B;W.push(K)}};return G(V,0),k={files:J.files,version:J.files.version,expSz:Z,now:Q,rows:W},W}function eQ(J){let Q=J.length,Z=Array(Q).fill(!0),$=[];for(let W=Q-1;W>=0;W--){let G=J[W].depth;Z[W]=!$[G],$[G]=!0,$.length=G+1}let V=[],Y=[];for(let W=0;W<Q;W++){let G=J[W].depth;Y[G]=Z[W];let D=[];for(let j=1;j<=G;j++)D.push(j===G?Z[W]?"end":"tee":Y[j]?"blank":"bar");V.push(D)}return V}function QQ(J,Q,Z,$="info"){if(J.toasts.push({text:Q,until:Z+nJ,tone:$}),J.toasts.length>GJ)J.toasts.splice(0,J.toasts.length-GJ)}function h(J,Q,Z,$="info",V="info"){QQ(J,Q,Z,$);let Y=(J.notices[J.notices.length-1]?.id??0)+1;if(J.notices.push({id:Y,at:Z,tone:$,kind:V,text:Q,read:!1}),J.notices.length>d)J.notices.splice(0,J.notices.length-d)}function tQ(J){return J.notices.reduce((Q,Z)=>Q+(Z.read?0:1),0)}function IJ(J){for(let Q of J.notices)Q.read=!0}function sQ(J,Q){if(J.toasts.some((Z)=>Z.until<=Q))J.toasts=J.toasts.filter((Z)=>Z.until>Q)}function JZ(J,Q){let Z=J.activity;return Z.startedAt===null?0:Math.max(0,(Z.endedAt??Q)-Z.startedAt)}function QZ(J){let Q=Math.max(0,J)/1000,Z=Math.floor(Q/60),$=Q-Z*60;return`${String(Z).padStart(2,"0")}:${$.toFixed(1).padStart(4,"0")}`}function ZZ(J){let Q=Math.floor(Math.max(0,J)/1000);if(Q<60)return`${Q}s`;let Z=Math.floor(Q/60);if(Z<60)return`${Z}m ${Q-Z*60}s`;return`${Math.floor(Z/60)}h ${Z%60}m`}function ZQ(J,Q){if(Q===void 0)return null;return Math.min(100,Math.round(HJ(J,Q).fraction*100))}function $Z(J,Q){if(Q.provider!==void 0)J.usage.provider=Q.provider;if(Q.model!==void 0)J.usage.model=Q.model;if(Q.effort!==void 0)J.usage.effort=Q.effort;if(Q.turns!==void 0)J.usage.turns=Q.turns;if(Q.tokensIn!==void 0)J.usage.tokensIn=Q.tokensIn;if(Q.tokensOut!==void 0)J.usage.tokensOut=Q.tokensOut;if("contextTokens"in Q||"contextWindow"in Q){if(J.usage.contextPct=ZQ(Q.contextTokens??0,Q.contextWindow),Q.contextTokens!==void 0)J.usage.contextTokens=Q.contextTokens;if(Q.contextWindow!==void 0)J.usage.contextWindow=Q.contextWindow;else delete J.usage.contextWindow}if(Q.costUsd!==void 0)J.usage.costUsd=Q.costUsd}function WZ(J,Q){J.plan=Q.note?{todos:Q.items,note:Q.note}:{todos:Q.items}}function jZ(J,Q){J.crew=[...Q]}var iJ=1500,nJ=2600,GJ=6,UJ=120,_=(J,Q,Z,$)=>{if(J.activity.state=Q,J.activity.label=Z,Q==="ERROR"&&$!==void 0)J.activity.errorAt=$},N=(J,Q)=>{J.messages.push(Q),J.stick=!0},aJ=(J)=>J.messages.some((Q)=>Q.kind==="tool"&&Q.running),rQ,v=(J,Q)=>{let Z=J.toLowerCase(),$=Q.toLowerCase();return Z<$?-1:Z>$?1:J<Q?-1:J>Q?1:0},YJ=(J)=>J.replace(/\\/g,"/").replace(/^\.\/+/,""),nQ=(J)=>J.files.statuses.size,k=null,FJ=(J)=>J>=1000?`${(J/1000).toFixed(1)}k`:String(Math.max(0,Math.round(J))),VZ=(J)=>XJ(J.plan.todos);var SJ=x(()=>{lJ();pJ();cJ();rJ();c();jJ();rQ=tJ()});import{existsSync as VQ,openSync as jQ,closeSync as GQ,readSync as UQ,readFileSync as YQ,statSync as FQ}from"fs";import{homedir as KQ}from"os";import{isAbsolute as zJ,resolve as L,sep as MJ}from"path";function DQ(J){let Q=J.trim();if(Q[0]==="/"||Q[0]==="!")return[];return[...Q.matchAll(o)].map((Z)=>Z[1])}function SQ(J,Q){let Z=Q.exists??VQ;if(J==="~"||J.startsWith("~/")||J.startsWith("~\\"))return{abs:L(KQ(),J.slice(2)),label:J};if(zJ(J))return{abs:L(J),label:J};let $=Q.resolve(J);if($!==null)return{abs:L(Q.cwd,$),label:$};for(let V of Q.roots??[]){let Y=L(V,J);if((Y===L(V)||Y.startsWith(L(V)+MJ))&&Z(Y))return{abs:Y,label:J,root:V}}return null}function OQ(J,Q){try{if(Q.read){let $=Buffer.from(Q.read(J).slice(0,32),"binary");return n($)??null}let Z=jQ(J,"r");try{let $=Buffer.alloc(32),V=UQ(Z,$,0,32,0);return n($.subarray(0,V))??null}finally{GQ(Z)}}catch{return null}}function BZ(J,Q){let Z=[...new Set(Q.mentions??DQ(J))],$=[],V=[],Y=[];if(Z.length===0)return{text:J,attached:V,notes:$};let W=L(Q.cwd),G=Q.stat??((j)=>FQ(j)),D=OJ;for(let j of Z){if(V.length>=qJ){$.push(`@${j}: not attached \u2014 ${qJ} files per message is the cap; ask me to read it`);continue}let U=SQ(j,Q);if(U===null){$.push(`@${j}: no file in the workspace matches`);continue}let{abs:F}=U,K=U.label;if(U.root===void 0&&!zJ(j)&&!j.startsWith("~")&&F!==W&&!F.startsWith(W+MJ)){$.push(`@${K}: outside the workspace \u2014 not attached`);continue}let H;try{H=G(F)}catch{$.push(`@${K}: cannot be read \u2014 not attached`);continue}if(!H.isFile()){$.push(`@${K}: a directory \u2014 name a file in it`);continue}if(Q.attachImage){let b=OQ(F,Q);if(b!==null){Q.attachImage(F),$.push(`@${K}: attached as an image (${b})${U.root?` (from ${U.root})`:""}`);continue}}if(H.size>HQ){$.push(`@${K}: ${(H.size/1048576).toFixed(1)} MB is too large to attach \u2014 ask me to read a window of it`);continue}let B;try{B=Q.read?Q.read(F):YQ(F,"utf8")}catch{$.push(`@${K}: cannot be read \u2014 not attached`);continue}if(B.slice(0,qQ).includes("\x00")){$.push(`@${K}: a binary file \u2014 not attached`);continue}if(D<XQ){$.push(`@${K}: not attached \u2014 this message already carries ${OJ.toLocaleString()} characters of files; ask me to read it`);continue}let q=Q.read?PQ(F,B):RJ(F),P=q.lines.length,S=Math.min(P,BQ),I=a({...q,lines:q.lines.slice(0,S)}).replace(/\n$/,"");while(I.length>D&&S>1)S=Math.max(1,Math.floor(S*D/I.length)),I=a({...q,lines:q.lines.slice(0,S)}).replace(/\n$/,"");let O=S<P;D-=I.length;let z=O?`[@${K} \u2014 attached: ${S} of ${P} lines, capped: read it with offset ${S+1} for the rest]`:`[@${K} \u2014 attached: ${P} lines]`;if(Y.push(`${z}
|
|
4
4
|
${I}
|
|
5
5
|
(showing lines ${P===0?0:1}-${S} of ${P})`),V.push({path:K,shown:S,total:P,capped:O}),O)$.push(`@${K}: ${P} lines \u2014 attached the first ${S}; the rest is a read away`)}if(Y.length===0)return{text:J,attached:V,notes:$};return{text:`${J.trimEnd()}
|
|
@@ -12,4 +12,4 @@ ${Y.join(`
|
|
|
12
12
|
`).map((Z,$)=>({n:$+1,hash:PJ(Z),text:Z}))}}function HZ(J){let Q=J.split(`
|
|
13
13
|
`),Z=Q.indexOf(_J);if(Z<0)return{text:J,files:[]};let $=[];for(let V of Q.slice(Z+1)){let Y=IQ.exec(V);if(Y)$.push(Y[3]!==void 0?`${Y[1]} \xB7 ${Y[2]}/${Y[3]} lines, capped`:`${Y[1]} \xB7 ${Y[2]} lines`)}return{text:Q.slice(0,Z).join(`
|
|
14
14
|
`).trimEnd(),files:$}}var o,BQ=400,qJ=8,OJ=60000,HQ=2097152,XQ=500,_J="(files attached by @mention \u2014 each block is what `read` returns for the file; its edit anchors are valid)",IQ,qQ=8192;var gJ=x(()=>{$Q();WQ();o=/(?:^|\s)@([\w./\\:~-]+)/g;IQ=/^\[@(\S+) \u2014 attached: (\d+)(?: of (\d+))? lines(, capped[^\]]*)?\]$/});function kJ(J){let Q=J.trim();if(Q[0]==="/"){let Z=/^\/(\S*)(\s+(.*))?$/s.exec(J.trimStart());return{kind:"slash",cmd:Z?.[1]??"",arg:Z?.[2]===void 0?void 0:(Z[3]??"").trim(),mentions:[]}}if(Q[0]==="!"&&Q.length>1&&Q[1]!=="!"&&!/\s/.test(Q[1]))return{kind:"shell",cmd:Q.slice(1).trim(),mentions:[]};return{kind:"text",mentions:[...Q.matchAll(o)].map((Z)=>Z[1])}}function NQ(J,Q){let Z=/(?:^|\s)@([\w./-]*)$/.exec(J.slice(0,Q));return Z?{start:Q-Z[1].length-1,query:Z[1]}:null}function OZ(J,Q,Z=y){if(!J)return null;let $=J.replace(/^@/,"");if(Q.includes($))return $;let V=Q.filter((Y)=>Y.endsWith("/"+$)||Y.split("/").pop()===$);if(V.length===1)return V[0];return T($,Q,Z)[0]??null}function T(J,Q,Z,$=String){if(!J)return[...Q];return Q.map((V)=>({it:V,m:Z(J,$(V))})).filter((V)=>V.m).sort((V,Y)=>Y.m.score-V.m.score).map((V)=>V.it)}function A(J){let Q=new Set(e.map((Z)=>Z.name));return[...e.map(({name:Z,description:$,arg:V,local:Y})=>({name:Z,description:$,arg:V,local:Y})),...J.commands.filter((Z)=>!Q.has(Z.name)).map((Z)=>{if(!Z.choices)return{name:Z.name,description:Z.description};let $=typeof Z.choices==="function"?"provider/model":Z.choices.join("\xB7");return{name:Z.name,description:Z.description,arg:$,choices:Z.choices,...Z.choicesThen?{choicesThen:Z.choicesThen}:{}}})]}function t(J,Q,Z,$=y){return T(Q,Z,$).slice(0,6).map((V)=>({label:V,hint:J.files.statuses.get(V)??""}))}function PZ(J,Q,Z=y){return _Q(J,Q,Z).slice(0,MQ)}function _Q(J,Q,Z){if(J.palette||J.help||J.card)return[];let $=J.input.text;if(!$.trim())return[];let V=NQ($,J.input.cur);if(V)return t(J,V.query,Q,Z).map((U)=>({kind:"mention",label:U.label,hint:U.hint,enter:"complete",apply:{text:$.slice(0,V.start)+"@"+U.label+" "+$.slice(J.input.cur),cur:V.start+U.label.length+2}}));let Y=kJ($);if(Y.kind!=="slash")return[];if(Y.arg===void 0)return T(Y.cmd??"",A(J),Z,(U)=>U.name).map((U)=>{let F=U.arg!==void 0&&!U.arg.endsWith("?"),K="/"+U.name+(U.arg?" ":"");return{kind:"slash",label:"/"+U.name,hint:U.description,arg:U.arg,apply:{text:K,cur:K.length},enter:F?"complete":"submit"}});let W=e.find((U)=>U.name===Y.cmd);if(W?.options)return W.options(J,Y.arg,Z).map((U)=>{let F="/"+W.name+" "+U.label;return{kind:"arg",label:U.label,hint:U.hint,apply:{text:F,cur:F.length},enter:"submit"}});let G=A(J).find((U)=>U.name===Y.cmd&&U.choices),D=G?RQ(G):[];if(!G||!D.length)return[];let j=G.choicesThen==="complete";return T(Y.arg,D,Z).map((U)=>{let F="/"+G.name+" "+U+(j?" ":"");return{kind:"arg",label:U,hint:"",apply:{text:F,cur:F.length},enter:j?"complete":"submit"}})}function NZ(J,Q,Z,$,V,Y){if(!$.length||Z.input.sgSel<0)return;let W=Math.min(Z.input.sgSel,$.length-1),G=$[0].kind,D=kJ(Z.input.text).cmd,j=G==="mention"?"mention a file":G==="slash"?"commands":`/${D} \xB7 ${A(Z).find((q)=>q.name===D)?.arg??""}`,U=Math.min(Q.w-4,76),F=Q.x+2,K=$.length+3,H=Math.max(Q.y+1,Q.y+Q.h-3-K);J.box(F,H,U,K,X(V.rule2),V.bg2),J.text(F+2,H+1,[[j,X(V.dim,V.bg2)]]);let B=G==="mention"?"tab insert":"tab complete \u23CE run";J.put(F+U-2-B.length,H+1,B,X(V.dim,V.bg2)),$.forEach((q,P)=>{let S=H+2+P,I=P===W,O=[[I?"\u25B8 ":" ",X(V.accent,V.bg2)],[q.label,X(I?V.fg:V.fg2,V.bg2,I?E.BOLD:0)]];if(q.arg)O.push([" "+q.arg,X(V.dim,V.bg2)]);if(J.text(F+2,S,O,U-4),q.hint){let z=Math.min(q.hint.length,34);J.clip(F+U-2-z,S,q.hint,X(V.muted,V.bg2),z)}Y?.push({rect:{x:F,y:S,w:U,h:1},onClick:()=>{Z.input.sgSel=P},key:TJ})})}function gQ(J){let Q=A(J).map(($)=>({label:"/"+$.name,group:"commands",action:"/"+$.name}));for(let $ of w)Q.push({label:`theme ${$}`,group:"theme",action:`theme:${$}`});let Z=[["code view","code"],["diff view","diff"],["run output","run"],["agents board","agents"]];for(let[$,V]of Z)Q.push({label:$,group:"view",action:`mode:${V}`});for(let $ of["messages","code","files"])Q.push({label:`focus ${$}`,group:"view",action:`focus:${$}`});for(let $ of J.files.paths)Q.push({label:$,group:"open",action:`open:${$}`});return Q}function bJ(J,Q){if(Q!=="palette")J.palette=null;if(Q!=="market")J.market=null;if(Q!=="help")J.help=!1;if(Q!=="context")J.context=null;if(Q!=="wizard")J.wizard=null}function RZ(J){let Q=[];if(J.palette)Q.push("palette");if(J.market)Q.push("market");if(J.help)Q.push("help");if(J.context)Q.push("context");if(J.wizard)Q.push("wizard");return Q}function zZ(J){bJ(J,"help"),J.help=!0}function EQ(J,Q=gQ(J),Z){bJ(J,"palette"),J.palette={query:"",sel:0,items:Q,...Z!==void 0?{title:Z}:{}}}function s(J){J.palette=null}function MZ(J,Q=Date.now()){let Z=[...J.notices].reverse().map(($)=>({label:`${$.tone==="error"?"\u2717":$.tone==="warn"?"\u25C6":"\xB7"} ${$.text}`,group:"notices",action:"noop:",hint:kQ(Q-$.at)}));IJ(J),EQ(J,Z.length?Z:[{label:"no notifications yet",group:"notices",action:"noop:",hint:""}],"notifications")}function kQ(J){let Q=Math.max(0,Math.round(J/1000));if(Q<5)return"just now";if(Q<60)return`${Q}s`;if(Q<3600)return`${Math.round(Q/60)}m`;return`${Math.round(Q/3600)}h`}function AJ(J,Q=y){let Z=J.query.trim();if(!Z){let $=0;return J.items.filter((V)=>V.group!=="open"||$++<6)}return T(Z,J.items,Q,($)=>$.label).sort(($,V)=>EJ.indexOf($.group)-EJ.indexOf(V.group))}function LQ(J,Q){if(Q.hint!==void 0)return Q.hint;if(Q.action.startsWith("/"))return A(J).find((Y)=>"/"+Y.name===Q.action)?.description??"";let Z=Q.action.indexOf(":"),$=Q.action.slice(0,Z),V=Q.action.slice(Z+1);switch($){case"theme":return LJ[V]??"";case"mode":return zQ[V]??"";case"focus":return V==="files"?"\u2303e":"";case"open":return J.files.statuses.get(V)??"";default:return""}}function _Z(J,Q,Z,$,V=y,Y){let W=$.palette;if(!W)return null;Y?.push({rect:{x:0,y:0,w:Q.w,h:Q.h},onClick:()=>s($)});let G=AJ(W,V);W.sel=Math.max(0,Math.min(W.sel,G.length-1));let D=[],j="";G.forEach((I,O)=>{if(I.group!==j)j=I.group,D.push({type:"group",name:j});D.push({type:"item",it:I,idx:O})});let U=Math.min(72,Q.w-10),F=Math.floor((Q.w-U)/2),K=Math.max(3,Math.min(D.length||1,Math.floor(Q.h/2))),H=K+5,B=Math.max(2,Math.floor(Q.h*0.14));J.box(F,B,U,H,X(Z.accent),Z.bg2);let q=` ${W.title??"commands"} `;if(J.clip(F+2,B,q,X(Z.accent,-1,E.BOLD),Math.max(0,U-4)),Y?.push({rect:{x:F,y:B,w:U,h:H},onClick:()=>{}}),J.put(F+2,B+1,"\u258C",X(Z.accent,Z.bg2)),W.query)J.put(F+4,B+1,W.query,X(Z.fg,Z.bg2,E.BOLD),U-12);else J.put(F+4,B+1,W.title===void 0?"commands, themes, views, files\u2026":"type to filter\u2026",X(Z.dim,Z.bg2),U-12);J.put(F+U-6,B+1,"esc",X(Z.dim,Z.bg2)),J.hline(F+1,B+2,U-2,X(Z.rule2,Z.bg2),"\u254C");let P=D.findIndex((I)=>I.type==="item"&&I.idx===W.sel),S=P>=K-1?P-K+2:0;if(!D.length)J.put(F+4,B+3,"no matches",X(Z.muted,Z.bg2));for(let I=0;I<K;I++){let O=D[S+I];if(!O)break;let z=B+3+I;if(O.type==="group"){J.put(F+4,z,O.name,X(Z.dim,Z.bg2),U-6);continue}let b=O.idx===W.sel;J.text(F+2,z,[[b?"\u25B8 ":" ",X(Z.accent,Z.bg2)],[O.it.label,X(b?Z.fg:Z.fg2,Z.bg2,b?E.BOLD:0)]],U-30);let u=LQ($,O.it);if(u)J.clip(F+U-3-Math.min(u.length,24),z,u,X(Z.muted,Z.bg2),24);Y?.push({rect:{x:F,y:z,w:U,h:1},onClick:()=>{W.sel=O.idx},key:TJ})}return{x:F+4+W.query.length,y:B+1}}function gZ(J,Q,Z,$=y){let V=J.palette;if(!V)return;let{name:Y,ctrl:W,alt:G,ch:D}=Q;if(Y==="escape"||W&&(Y==="k"||Y==="p")){s(J);return}let j=AJ(V,$),U=Math.max(1,j.length);if(Y==="up"){V.sel=(V.sel-1+U)%U;return}if(Y==="down"){V.sel=(V.sel+1)%U;return}if(Y==="enter"){let K=j[V.sel];if(s(J),K)Z(K.action);return}if(Y==="backspace"){V.query=[...V.query].slice(0,-1).join(""),V.sel=0;return}let F=Y==="space"?" ":D;if(F&&!W&&!G)V.query+=F,V.sel=0}function TQ(J){return A(J).map((Q)=>["/"+Q.name,Q.description,Q.arg??""])}function EZ(J,Q,Z,$,V){let Y=TQ($),W=Math.min(Q.w-8,112),G=W>=110,D=Math.max(1,Q.h-8),j=Y.length>D?[...Y.slice(0,D-1),["\u2026",`${Y.length-D+1} more \xB7 /help lists all`,""]]:Y,U=m.length>D?[...m.slice(0,D-1),["\u2026",`${m.length-D+1} more`]]:[...m],F=Math.max(j.length,U.length)+6,K=Math.floor((Q.w-W)/2),H=Math.max(1,Math.floor((Q.h-F)/2));J.box(K,H,W,F,X(Z.accent),Z.bg2),J.text(K+2,H,[[" help ",X(Z.accent,-1,E.BOLD)]]),J.put(K+W-14,H," esc closes ",X(Z.dim));let B=G?K+70:K+50;J.put(K+3,H+2,"commands",X(Z.muted,Z.bg2)),J.put(B,H+2,"keys",X(Z.muted,Z.bg2)),j.forEach(([q,P,S],I)=>{let O=H+3+I;if(J.put(K+3,O,q,X(Z.accent,Z.bg2),13),J.put(K+17,O,P,X(Z.fg2,Z.bg2),G?28:30),G&&S)J.put(K+46,O,S,X(Z.dim,Z.bg2),22)}),U.forEach(([q,P],S)=>{let I=H+3+S;J.put(B,I,q,X(Z.fg,Z.bg2,E.BOLD),10),J.put(B+11,I,P,X(Z.fg2,Z.bg2),W-(B-K)-13)}),J.put(K+3,H+F-2,"plain text and !commands reach the agent as typed \xB7 @file attaches the file as a read (400 lines, 8 files)",X(Z.dim,Z.bg2),W-6),V?.push({rect:{x:0,y:0,w:Q.w,h:Q.h},onClick:()=>{$.help=!1}})}var y=(J,Q)=>{J=J.toLowerCase(),Q=Q.toLowerCase();let Z=0,$=0,V=-2,Y=[];for(let W=0;W<Q.length&&Z<J.length;W++)if(Q[W]===J[Z])Y.push(W),$+=(V===W-1?3:1)+(W===0||Q[W-1]===" "||Q[W-1]==="/"?2:0),V=W,Z++;return Z===J.length?{score:$,idx:Y}:null},RQ=(J)=>typeof J.choices==="function"?J.choices():J.choices??[],e,LJ,zQ,MQ=10,X=(J,Q=-1,Z=0)=>({fg:J,bg:Q,a:Z}),TJ,EJ,m;var bQ=x(()=>{c();SJ();gJ();e=[{name:"help",description:"commands + keys card",local:!0},{name:"theme",description:"switch palette",arg:"night\xB7ember\xB7contrast",local:!0,options:(J,Q,Z)=>T(Q,w,Z).map(($)=>({label:$,hint:LJ[$]}))},{name:"open",description:"open a file in the code view",arg:"path",local:!0,options:(J,Q,Z)=>t(J,Q,J.files.paths,Z)},{name:"diff",description:"diff of a file (or the current one)",arg:"path?",local:!0,options:(J,Q,Z)=>{let $=J.files.paths.filter((V)=>J.files.statuses.has(V));return t(J,Q,$.length?$:J.files.paths,Z)}},{name:"focus",description:"move keyboard focus",arg:"messages\xB7code\xB7files",local:!0,options:(J,Q,Z)=>T(Q,["messages","code","files"],Z).map(($)=>({label:$,hint:""}))},{name:"agents",description:"the crew board (code panel \u2237)",local:!0},{name:"notices",description:"notification history (\u2303b)",local:!0},{name:"market",description:"install MCP servers, skills, plugins (\u2303m)",local:!0},{name:"context",description:"what is in the window right now, item by item (\u2303g)",local:!0}],LJ={night:"night + mint",ember:"ink + ember",contrast:"pure contrast"},zQ={code:"\u2303s",diff:"\u2303d",run:"\u2303r",agents:"\u2303a"};TJ={type:"key",name:"enter"};EJ=["commands","theme","view","open"];m=[["\u23CE","send \xB7 confirm a card \xB7 run the suggestion"],["tab \u21E7tab","complete a suggestion \xB7 cycle focus"],["esc esc","stop the run (the first esc warns)"],["\u2303c","quit (interrupts a run first)"],["\u2303k \u2303p","command palette"],["\u2303s \u2303d \u2303r","code \xB7 diff \xB7 run view"],["\u2303a","agents board"],["\u2303e","files panel"],["\u2303o","next tab (narrow terminal)"],["\u2303b","notifications"],["\u2303m","market (install servers, skills, plugins)"],["\u2303g","context (what is in the window, and how far our count is from the provider\u2019s)"],["\u2325d","market: the selected item's documentation"],["\u2303v","paste image \xB7 drop a file to attach"],["\u2303t","next theme"],["\u2303n","new session (/new)"],["\u2303u","clear the prompt line"],["\u2191\u2193 \u2190\u2192","files: pick \xB7 fold \u2014 code: scroll \xB7 mode \u2014 prompt: history"],["\u2303\u2190 \u2303\u2192","prompt: jump by word"],["home end","prompt: line start \xB7 end (end re-sticks the tail)"],["pgup pgdn","scroll messages \xB7 end sticks to the tail"],["mouse","click \xB7 wheel \xB7 drag a scrollbar \u2014 drag over the chat to select and copy it"],["@file","mention a file (picker)"]]});
|
|
15
|
-
export{E as
|
|
15
|
+
export{E as db,w as eb,AQ as fb,yQ as gb,xQ as hb,fQ as ib,c as jb,M as kb,$J as lb,vJ as mb,WJ as nb,VJ as ob,jJ as pb,lQ as qb,tJ as rb,iQ as sb,nQ as tb,aQ as ub,oQ as vb,eQ as wb,QQ as xb,h as yb,tQ as zb,sQ as Ab,JZ as Bb,QZ as Cb,FJ as Db,ZZ as Eb,$Z as Fb,WZ as Gb,VZ as Hb,jZ as Ib,SJ as Jb,DQ as Kb,BZ as Lb,HZ as Mb,gJ as Nb,y as Ob,kJ as Pb,OZ as Qb,PZ as Rb,NZ as Sb,bJ as Tb,RZ as Ub,zZ as Vb,EQ as Wb,s as Xb,MZ as Yb,AJ as Zb,_Z as _b,gZ as $b,EZ as ac,bQ as bc};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import{wn as X}from"./main-qsevpgsv.js";import{existsSync as Z,mkdirSync as C,readFileSync as U,writeFileSync as G}from"fs";import{join as W,resolve as I}from"path";function u(q){if(q.kind!=="stdio"||q.runtime!=="npx"||q.command!=="npx")return;let z=0;while(z<q.args.length&&q.args[z].startsWith("-")){if(!N.has(q.args[z]))return;z+=1}let D=q.args[z];if(D===void 0)return;let H=O.exec(D);if(!H)return;let B={name:H[1],spec:D,rest:q.args.slice(z+1)};if(H[2]!==void 0)B.version=H[2];return B}function w(q){return W(q,"mcp")}function V(q,z){return["npm","install","--prefix",z,"--save","--no-fund","--no-audit","--loglevel=error",q.spec]}async function S(q,z,D={}){let H=D.spawn??R;try{C(z,{recursive:!0});let B=W(z,"package.json");if(!Z(B))G(B,JSON.stringify({name:"rovecode-mcp-servers",private:!0,description:"MCP servers installed once by rovecode's market \u2014 launched with node, not npx (docs/mcp-market.md)"},null,2)+`
|
|
3
3
|
`);let J=await H(V(q,z),z);if(J.code!==0)return{ok:!1,error:`npm install ${q.spec} failed (exit ${J.code})${J.stderr.trim()?`: ${J.stderr.trim().split(`
|
|
4
4
|
`).slice(-3).join(" \xB7 ")}`:""}`}}catch(B){return{ok:!1,error:`npm install ${q.spec} could not run: ${B instanceof Error?B.message:String(B)}`}}return L(q.name,z)}function L(q,z){let D=W(z,"node_modules",...q.split("/")),H=W(D,"package.json");if(!Z(H))return{ok:!1,error:`npm reported success but ${H} is not there`};let B;try{B=JSON.parse(U(H,"utf8"))}catch(K){return{ok:!1,error:`${H}: ${K instanceof Error?K.message:String(K)}`}}let J=typeof B.version==="string"?B.version:void 0;if(J===void 0)return{ok:!1,error:`${H} states no version`};let Q=E(q,B.bin);if(Q===void 0)return{ok:!1,error:`${q} declares no bin \u2014 there is nothing for node to run; npx would have failed the same way`};let M=I(D,Q);if(!Z(M))return{ok:!1,error:`${q}'s bin ${M} is not on disk`};let T=[],Y=F(z,q,T),$={name:q,version:J,bin:M,missing:T};if(Y?.integrity!==void 0)$.integrity=Y.integrity;if(Y?.resolved!==void 0)$.resolved=Y.resolved;return{ok:!0,pkg:$}}function E(q,z){if(typeof z==="string")return z;if(typeof z!=="object"||z===null)return;let D=Object.entries(z).filter((B)=>typeof B[1]==="string");if(D.length===0)return;let H=q.split("/").pop();return(D.find(([B])=>B===H)??D[0])[1]}function F(q,z,D){let H=W(q,"package-lock.json");if(!Z(H)){D.push(`integrity: ${H} was not written by npm`);return}let B;try{B=JSON.parse(U(H,"utf8"))}catch{D.push(`integrity: ${H} is not valid JSON`);return}let J=typeof B==="object"&&B!==null?B.packages:void 0;if(typeof J!=="object"||J===null){D.push(`integrity: ${H} has no "packages" map (lockfileVersion 1?)`);return}let Q=J[`node_modules/${z}`];if(typeof Q!=="object"||Q===null){D.push(`integrity: ${H} has no entry for node_modules/${z}`);return}let M=Q,T={};if(typeof M.integrity==="string")T.integrity=M.integrity;else D.push(`integrity: the lockfile entry for ${z} carries no integrity field`);if(typeof M.resolved==="string")T.resolved=M.resolved;return T}function v(q,z){return{command:"node",args:[q.bin,...z]}}function y(q,z){return["node",`${W(z,"node_modules",...q.name.split("/"))}${process.platform==="win32"?"\\":"/"}<its bin, read after the install>`,...q.rest].join(" ")}function P(q,z){return[` installs ${V(q,z).join(" ")}`,` rovecode runs a package manager for you here. npm downloads ${q.spec} and everything it depends`,` on and puts their CODE on this machine, under ${z} \u2014 typically 20\u201330 MB and a few seconds, once.`," In return the server starts in ~0.4 s instead of ~2 s and needs no network to start."," Requires npm (it comes with Node.js, as npx does)."," records package name, version and npm's integrity hash in installed.json \u2014 what ran is on record",' (an npx line runs whatever "latest" is at every start, and records nothing)']}function h(q){return q.transport==="stdio"&&q.command==="npx"&&q.enabled!==!1}function b(q){if(q.length===0)return;let z=q.length;return`${z} server${z===1?"":"s"} start${z===1?"s":""} through npx, which re-resolves the package at every start (~2 s each): ${q.join(", ")}. To start in ~0.4 s, reinstall with \`rovecode mcp add <catalog name> --local --force\` (the name you installed it by; add \`--as <server name>\` if you renamed it; installs the package once, ~25 MB). Nothing changes until you do.`}var N,O,R=async(q,z)=>{let D=Bun.spawn(q,{cwd:z,stdout:"ignore",stderr:"pipe",stdin:"ignore"});return{code:await D.exited,stderr:await new Response(D.stderr).text()}};var _=X(()=>{N=new Set(["-y","--yes","-q","--quiet","--no-install","--prefer-offline","--prefer-online"]),O=/^(@[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*|[a-z0-9][a-z0-9._-]*)(?:@([^@\s/]+))?$/});
|
|
5
|
-
export{u as
|
|
5
|
+
export{u as ia,w as ja,S as ka,v as la,y as ma,P as na,h as oa,b as pa,_ as qa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{ln as N,tn as E}from"./main-nqveez48.js";import{wn as C}from"./main-qsevpgsv.js";import{existsSync as F,readFileSync as x}from"fs";import{join as L}from"path";function y(B,q){return`${B}: not trusted on this machine \u2014 its ${q} MCP server${q===1?"":"s"} stay off (they would run commands from this repo). Review: rovecode mcp show \xB7 approve: rovecode mcp trust (or rovecode trust for every gated file)`}function c(B){return b(B).project}function b(B,q){return{...q!==void 0?{user:L(q,"mcp.json")}:{},harvest:L(B,".mcp.json"),project:L(B,".rovecode","mcp.json")}}function R(B,q,I){return B.replace(S,(J,U)=>{let K=q[U];if(K===void 0)return I.push(U),"";return K})}function O(B){return typeof B==="object"&&B!==null&&!Array.isArray(B)}function _(B){return B instanceof Error?B.message:String(B)}function k(B,q,I,J,U=process.env,K={}){if(!O(q)){J.push(`${I}: server "${B}" is not an object; skipped`);return}let W=[],G=(X)=>R(X,U,W),M=typeof q.command==="string"&&q.command.length>0?q.command:void 0,Q=typeof q.url==="string"&&q.url.length>0?G(q.url):void 0,Z=typeof q.transport==="string"?q.transport:typeof q.type==="string"?q.type:void 0,T;if(Z==="stdio")T="stdio";else if(Z==="http"||Z==="streamable-http"||Z==="streamable_http")T="http";else if(Z==="sse")T="sse";else if(Z!==void 0){J.push(`${I}: server "${B}" has unknown transport "${Z}"; skipped`);return}else T=Q!==void 0?"http":M!==void 0?"stdio":void 0;if(T===void 0){J.push(`${I}: server "${B}" has neither command nor url; skipped`);return}if(T==="stdio"&&M===void 0){J.push(`${I}: stdio server "${B}" is missing command; skipped`);return}if(T==="http"||T==="sse"){if(Q===void 0){J.push(`${I}: ${T} server "${B}" is missing url; skipped`);return}try{new URL(Q)}catch{J.push(`${I}: ${T} server "${B}" has invalid url "${Q}"; skipped`);return}}let H;if(q.args!==void 0)if(Array.isArray(q.args)&&q.args.every((X)=>typeof X==="string"))H=q.args.map(G);else{J.push(`${I}: server "${B}" has non-string args; skipped`);return}let P;if(O(q.env)){P={};for(let[X,A]of Object.entries(q.env))if(typeof A==="string")P[X]=G(A)}let z;if(O(q.headers)){z={};for(let[X,A]of Object.entries(q.headers))if(typeof A==="string")z[X]=G(A)}let $;if(O(q.oauth)){if($={},typeof q.oauth.clientId==="string"&&q.oauth.clientId.length>0)$.clientId=q.oauth.clientId;if(typeof q.oauth.scope==="string"&&q.oauth.scope.length>0)$.scope=q.oauth.scope;if(Object.keys($).length===0)$=void 0}if(W.length>0){J.push(`${I}: server "${B}" needs ${[...new Set(W)].map((X)=>`\${${X}}`).join(", ")} set in the environment; skipped`);return}let V=v({args:H,env:P,headers:z,url:Q});if(V.length>0&&K.allowPlaceholders!==!0){J.push(`${I}: server "${B}" still has ${V.join(", ")} to fill in; skipped (edit that line and it will connect)`);return}let Y={name:B,transport:T};if(M!==void 0)Y.command=M;if(H!==void 0)Y.args=H;if(P!==void 0)Y.env=P;if(Q!==void 0)Y.url=Q;if(z!==void 0)Y.headers=z;if($!==void 0)Y.oauth=$;if(typeof q.enabled==="boolean")Y.enabled=q.enabled;return Y}function v(B){return[...new Set([...B.args??[],...Object.values(B.env??{}),...Object.values(B.headers??{}),...B.url!==void 0?[B.url]:[]].flatMap((q)=>[...q.matchAll(j)].map((I)=>I[0])))]}function D(B,q,I=process.env,J={}){if(!F(B))return[];let U;try{U=x(B,"utf8")}catch(G){return q.push(`${B}: unreadable (${_(G)}); file skipped`),[]}let K;try{K=JSON.parse(U)}catch(G){return q.push(`${B}: invalid JSON (${_(G)}); file skipped`),[]}if(!O(K))return q.push(`${B}: root is not an object; file skipped`),[];let W=[];if(K.mcpServers!==void 0)if(O(K.mcpServers))for(let[G,M]of Object.entries(K.mcpServers)){let Q=k(G,M,B,q,I,J);if(Q)W.push(Q)}else q.push(`${B}: "mcpServers" is not an object; ignored`);if(K.servers!==void 0)if(Array.isArray(K.servers))for(let G of K.servers){let M=O(G)&&typeof G.name==="string"&&G.name.length>0?G.name:void 0;if(M===void 0){q.push(`${B}: servers[] entry without a name; skipped`);continue}let Q=k(M,G,B,q,I,J);if(Q)W.push(Q)}else q.push(`${B}: "servers" is not an array; ignored`);return W}function m(B,q=[],I={}){let J=b(B,I.home),U=new Map,K=new Proxy({},{get:()=>"set"});for(let[W,G]of[["user",J.user],["harvest",J.harvest],["project",J.project]]){if(G===void 0)continue;if(W!=="user"&&I.trusted!==void 0){let M=N(G);if(M!==void 0&&!I.trusted(G,M)){q.push(y(G,D(G,[],K).length));continue}}for(let M of D(G,q,I.env))U.set(M.name,M)}return[...U.values()]}var S,j;var f=C(()=>{E();S=/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,j=/<[^<>]*[a-z][^<>]*>/g});
|
|
3
|
-
export{c as
|
|
3
|
+
export{c as xm,b as ym,O as zm,_ as Am,k as Bm,v as Cm,D as Dm,m as Em,f as Fm};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Hd as O,Id as T}from"./main-6dnk69vp.js";import{Sj as b,Vj as E,Xj as y,Yj as k}from"./main-q3vsesf9.js";import{Zj as v,ck as f}from"./main-xg704a3c.js";import{nl as N,ol as x}from"./main-3rxcvgna.js";import{wn as g}from"./main-qsevpgsv.js";function o(Q){let{window:Y,maxOutput:W,override:$}=Q;if($!==void 0&&Number.isFinite($)&&$>0)return Math.floor($);if(!Y||!Number.isFinite(Y)||Y<=0)return l;let j=(Number.isFinite(W)&&(W??0)>0?W:m)+u,V=Y-j,G=V<c?Math.max(1,Math.floor(Y*0.6)):Math.floor(V),H=Q.scale!==void 0&&Number.isFinite(Q.scale)&&Q.scale>0?Q.scale:1;return Math.max(1,Math.floor(G/H))}function C(Q,Y){let W=Q.filter(($)=>$.kind===Y);return W.length===0?0:S(N(W))}function s(Q){let{messages:Y,current:W,lookup:$}=Q,j=$(W),V=Y.filter((J)=>J.role==="user"),G=Y.filter((J)=>J.role==="assistant"),H=Y.filter((J)=>J.role==="system"),z=[],K=(J,q,Z)=>{if(q>0)z.push({label:J,tokens:q,share:0,...Z?{note:Z}:{}})};K("system prompt",S(Q.system??"")+C(H.flatMap((J)=>J.parts),"text")),K("tool schemas",S(Q.toolSchemas??""),Q.toolSchemas?void 0:"not supplied"),K("your messages",C(V.flatMap((J)=>J.parts),"text")),K("assistant replies",C(G.flatMap((J)=>J.parts),"text"));let A=Y.flatMap((J)=>J.parts);K("tool calls",C(A,"tool_call")),K("tool results",C(A,"tool_result"));let I=z.reduce((J,q)=>J+q.tokens,0);for(let J of z)J.share=I>0?J.tokens/I:0;let B={input:0,output:0,cacheRead:0,cacheWrite:0},D=0,P=0,R=0;for(let J of Y){let q=J.usage;if(!q)continue;let Z={input:q.input,output:q.output,cacheRead:q.cacheRead??0,cacheWrite:q.cacheWrite??0};if(B.input+=Z.input,B.output+=Z.output,B.cacheRead+=Z.cacheRead,B.cacheWrite+=Z.cacheWrite,Z.input===0&&Z.output===0&&Z.cacheRead===0&&Z.cacheWrite===0)continue;let M=$(J.origin??W),_=M?.pricing?E(Z,v({...J.origin??W,pricing:M.pricing,...M.tier?{tier:M.tier}:{}},Z.input+Z.cacheRead+Z.cacheWrite)):void 0;if(_===void 0)R+=1;else D+=_,P+=1}let L=O(W),F=Math.ceil(I*L.scale),X={model:W,estimated:I,corrected:F,scale:{factor:L.scale,measured:L.measured,note:L.note},slices:z,totals:B,unpricedTurns:R,images:A.filter((J)=>J.kind==="image").length,...P>0?{costUsd:D}:{}};if(j?.contextWindow){let J=y(F,j.contextWindow);X.window=j.contextWindow,X.fraction=J.fraction,X.nearLimit=J.nearLimit,X.remaining=Math.max(0,j.contextWindow-F)}let w=(z.find((J)=>J.label==="system prompt")?.tokens??0)+(z.find((J)=>J.label==="tool schemas")?.tokens??0),U=d(Y,w);if(U)X.drift=U;return X}function d(Q,Y=0){for(let W=Q.length-1;W>=0;W--){let $=Q[W]?.usage;if(!$)continue;let j=$.input+($.cacheRead??0)+($.cacheWrite??0);if(j<=0)continue;let V=Q.slice(0,W),G=Y+(V.length===0?0:S(V.map((K)=>N(K.parts)).join(`
|
|
3
3
|
`))),H=j-G,z=j>0?Math.abs(H)/j:0;return{estimated:G,reported:j,delta:H,fraction:z,beyondTolerance:z>h}}return}var h=0.05,l=200000,c=32000,u=24000,m=32000,S=(Q)=>Q?b(Q):0;var p=g(()=>{x();T();k();f()});
|
|
4
|
-
export{h as
|
|
4
|
+
export{h as zd,l as Ad,c as Bd,u as Cd,o as Dd,s as Ed,d as Fd,p as Gd};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ml as M,ol as W}from"./main-3rxcvgna.js";import{Al as R,Bl as V,xl as N,zl as Q}from"./main-4wndhjdc.js";W();V();function U(F,G,J){if(!F.parts.some((D)=>D.kind==="image"))return M(F.parts);if(G&&F.role==="user"){let D=[];for(let H of F.parts)if(H.kind==="text"){if(H.text)D.push({type:"text",text:H.text})}else if(H.kind==="image")D.push(J(H)??{type:"text",text:N(H,"file unavailable")});return D}let E=[],A="";for(let D of F.parts)if(D.kind==="text")A+=D.text;else if(D.kind==="image"){if(A)E.push(A),A="";E.push(N(D,G?"file unavailable":void 0))}if(A)E.push(A);return E.join(`
|
|
3
3
|
`)}function _(F,G={}){let J=G.vision??!0,E=[];for(let A of F){let D=A.parts.filter((z)=>z.kind==="tool_call"),H=A.parts.filter((z)=>z.kind==="tool_result");if(A.role==="tool"){for(let z of H)if(z.kind==="tool_result")E.push({role:"tool",tool_call_id:z.callId,content:z.output});continue}if(A.role==="assistant"&&D.length>0)E.push({role:"assistant",content:M(A.parts)||null,tool_calls:D.map((z)=>z.kind==="tool_call"?{id:z.id,type:"function",function:{name:z.tool,arguments:JSON.stringify(z.args)}}:{})});else{let z=U(A,J,(K)=>R(K));if(z.length>0||A.role==="system")E.push({role:A.role,content:z})}}return E}function X(F){let G=F;return G.schema??{name:G.name??"unknown",description:G.description??"",args:G.args??{}}}function $(F){return F.map((G)=>{let J=X(G);return{type:"function",function:{name:J.name,description:J.description,parameters:J.args}}})}function j(F,G={}){let J=G.vision??!0,E=[];for(let A of F){if(A.role==="system")continue;let D=A.parts.filter((z)=>z.kind==="tool_call"),H=A.parts.filter((z)=>z.kind==="tool_result");if(A.role==="tool"){for(let z of H)if(z.kind==="tool_result")E.push({role:"user",content:[{type:"tool_result",tool_use_id:z.callId,content:z.output,is_error:!z.ok}]});continue}if(A.role==="assistant"&&D.length>0){let z=M(A.parts),K=[];if(z)K.push({type:"text",text:z});for(let L of D)if(L.kind==="tool_call")K.push({type:"tool_use",id:L.id,name:L.tool,input:L.args});E.push({role:"assistant",content:K})}else{let z=U(A,J,Q);if(z.length>0)E.push({role:A.role==="user"?"user":"assistant",content:z})}}return E}
|
|
4
|
-
export{U as
|
|
4
|
+
export{U as Oi,_ as Pi,X as Qi,$ as Ri,j as Si};
|
|
@@ -5,4 +5,4 @@ import{wn as U}from"./main-qsevpgsv.js";function V(f){return f?"auto (never asks
|
|
|
5
5
|
`);let F=f.connected.model.length>0?`${f.connected.provider}/${f.connected.model}`:f.connected.provider;return[`\u25C6 rovecode${j} here. Connected to ${F}.`,`Tell me what you want done; I read first, then ${f.yolo?"work without asking":"ask before I write or run anything"}.`,"/help lists commands by topic.",...q].join(`
|
|
6
6
|
`)}function E(f,k,j){return`\u25C6 back in session ${f.slice(0,8)} \xB7 ${k} \xB7 ${I(j)}`}function K(f,k){let j=f==="off"?"thinking: off \u2014 I answer straight away.":f==="auto"?"thinking: auto \u2014 the model decides how much to reason; I send no dial.":`thinking: ${f} \u2014 I reason before answering. It costs output tokens and delays the first word.`;return k?`${j}
|
|
7
7
|
${k}`:j}function W(f){return`mode: ${V(f)} \u2014 ${Y(f)}`}function A(f){return f?`mode: ${"accept edits"} \u2014 I write inside this folder without asking. Shell commands, subagents, network and any write outside it still ask, and deny rules still hold.`:`mode: ${"ask first"} \u2014 I ask before every write again.`}var B="ask first",C="auto (never asks)",T="accept edits",Z="\u2192 next:",J=(f)=>`${Z} ${f}`,_,G,$=46,M;var g=U(()=>{_=`Rovecode mock provider: no model is connected, so this is a canned reply. ${J("rovecode setup")} (or rovecode provider add <id> <baseUrl> + rovecode auth set <id>, or set ROVECODE_BASE_URL and ROVECODE_API_KEY)`,G=["\u2588\u2580\u2588 \u2588\u2580\u2588 \u2588 \u2588 \u2588\u2580\u2580 \u2588\u2580\u2580 \u2588\u2580\u2588 \u2588\u2580\u2584 \u2588\u2580\u2580","\u2588\u2580\u2584 \u2588\u2584\u2588 \u2580\u2584\u2580 \u2588\u2584\u2584 \u2588\u2584\u2584 \u2588\u2584\u2588 \u2588\u2584\u2580 \u2588\u2584\u2584"];M={code:"nothing open \u2014 when I read a file it shows here",files:["no files yet","they appear as I read them"],plan:["no plan yet","my steps show up here"],usage:"0 so far"}});
|
|
8
|
-
export{B as
|
|
8
|
+
export{B as dk,C as ek,T as fk,V as gk,I as hk,Y as ik,Z as jk,J as kk,X as lk,_ as mk,H as nk,D as ok,E as pk,K as qk,W as rk,A as sk,M as tk,g as uk};
|
|
@@ -7,4 +7,4 @@ import{$m as m,Lm as r}from"./main-2yeveeve.js";m();import{existsSync as g,readF
|
|
|
7
7
|
${h}
|
|
8
8
|
|
|
9
9
|
${o}`,wire:u,reasoningEffort:p},k={id:"glm-5.3-plain",matches:()=>!1,promptSection:o,wire:u,reasoningEffort:p},s=[y,k],i=new Set(["off","0","false","none","no"]);function l(e){return(e.ROVECODE_PROFILE??"").trim().toLowerCase()}function P(e,a=process.env){let t=l(a);if(i.has(t))return null;if(t.length>0)return s.find((n)=>n.id===t)??null;return s.find((n)=>n.matches(e))??null}function b(e,a=process.env){if(i.has(l(a)))return null;return s.find((t)=>t.matches(e))??null}function B(e=process.env){let a=l(e);if(a.length===0||i.has(a)||s.some((t)=>t.id===a))return null;return`ROVECODE_PROFILE=${a} names no profile (known: ${s.map((t)=>t.id).join(", ")}, off) \u2014 running without one`}function v(e,a,t=r()){return[c(a,".rovecode","profiles",`${e.id}.md`),c(t,"profiles",`${e.id}.md`)]}function M(e,a,t=r()){for(let n of v(e,a,t)){if(!g(n))continue;try{return f(n,"utf8").trim()}catch{return e.promptSection}}return e.promptSection}function W(e,a,t=process.env){return b(e,t)?.wire({streaming:a})??{}}
|
|
10
|
-
export{o as
|
|
10
|
+
export{o as tj,d as uj,h as vj,w as wj,y as xj,k as yj,s as zj,P as Aj,b as Bj,B as Cj,v as Dj,M as Ej,W as Fj};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{wn as K}from"./main-qsevpgsv.js";function F(){return Error("login cancelled")}async function f(j,z){let J="";try{let V=await z.json(),W=V?.error,$=typeof W==="string"?W:typeof W==="object"&&W!==null&&typeof W.code==="string"?W.code:"",G=typeof V?.error_description==="string"?V.error_description:"";if($)J=`: ${$.slice(0,80)}${G?` \u2014 ${G.slice(0,160)}`:""}`}catch{}return Error(`${j} failed (HTTP ${z.status})${J}`)}async function b(j,z){let J;try{J=await j.json()}catch{throw Error(`${z}: response is not JSON`)}if(typeof J!=="object"||J===null||Array.isArray(J))throw Error(`${z}: response is not a JSON object`);return J}async function u(j,z,J,V){if(V?.aborted)throw F();try{return await j.fetch(z,{...J,signal:V})}catch(W){if(V?.aborted)throw F();throw W}}var g="login cancelled";var M=()=>{};function w(j){return`${j} OAuth: state mismatch on the callback \u2014 login aborted`}function X(j,z){return new Response(`<!doctype html><meta charset="utf-8"><title>rovecode</title><p>${z}</p>`,{status:j,headers:{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}})}function v(j){return j>=60000?`${Math.round(j/60000)} minutes`:`${j} ms`}function d(j){let z=`/callback/${j.nonce}`,J=j.exchange??"key exchange",V=()=>{},W=new Promise((Q)=>{V=Q}),$=!1,G=!1,k=!1,Y=(Q)=>{if($)return;$=!0,V(Q)},D=(Q)=>{k=!0,setTimeout(()=>Y(Q),L)},x=()=>{return D({error:Error(w(j.what))}),X(400,`State mismatch \u2014 this login was aborted. ${j.retryHint}`)},H=Bun.serve({port:0,hostname:R,async fetch(Q){if(Q.method!=="GET")return X(404,"Not an OAuth callback.");let Z=new URL(Q.url);if(Z.hostname!==R)return X(404,"Not an OAuth callback.");if(!Z.pathname.startsWith("/callback/"))return X(404,"Not an OAuth callback.");if($||G||k)return X(409,"This OAuth callback has already been used.");if(Z.pathname!==z)return x();if(j.requireStateParam===!0&&Z.searchParams.get("state")!==j.nonce)return x();let E=Z.searchParams.get("error");if(E)return D({error:Error(`${j.what} authorization denied: ${(Z.searchParams.get("error_description")??E).slice(0,160)}`)}),X(400,`${j.what} authorization was denied.`);let S=Z.searchParams.get("code");if(!S)return X(400,`${j.what} returned no authorization code.`);G=!0;try{let N=await j.onCode(S);return D({value:N}),X(200,`Signed in to ${j.what} \u2014 you can close this tab and return to rovecode.`)}catch(N){return D({error:N instanceof Error?N:Error(String(N))}),X(502,`${j.what} ${J} failed \u2014 see the rovecode terminal.`)}}}),_=`http://${H.hostname}:${H.port}${z}`,q=j.timeoutMs??C,I=()=>Y({error:F()});j.signal.addEventListener("abort",I,{once:!0});let T=setTimeout(()=>Y({error:Error(`${j.what} OAuth login timed out (${v(q)})`)}),q),B=!1,O=()=>{if(B)return;B=!0,clearTimeout(T),j.signal.removeEventListener("abort",I),H.stop(!0),Y({error:Error(`${j.what} OAuth login aborted`)})};if(j.signal.aborted)I();let U=W.then((Q)=>{if(O(),"error"in Q)throw Q.error;return Q.value});return U.catch(()=>{}),{callbackUrl:_,result:U,stop:O}}var R="127.0.0.1",C=300000,L=20;var A=K(()=>{M()});function P(j){let z="";for(let J of j)z+=String.fromCharCode(J);return btoa(z).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function n(){let j=new Uint8Array(32);crypto.getRandomValues(j);let z=P(j),J=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(z));return{verifier:z,challenge:P(new Uint8Array(J))}}function p(){let j=new Uint8Array(32);return crypto.getRandomValues(j),P(j)}var y=()=>{};
|
|
3
|
-
export{g as
|
|
3
|
+
export{g as Gj,F as Hj,f as Ij,b as Jj,u as Kj,M as Lj,w as Mj,d as Nj,A as Oj,n as Pj,p as Qj,y as Rj};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Fm as X,zm as $}from"./main-7rn6bqje.js";import{wn as H}from"./main-qsevpgsv.js";function T(q){if(q.length===0||q.startsWith("/")||q.startsWith("\\")||/^[A-Za-z]:/.test(q))return!1;return!q.split(/[\\/]/).some((j)=>j==="..")}function M(q,j,F){let z;try{z=JSON.parse(q)}catch(B){return F.push(`${j}: not valid JSON \u2014 ${B.message}`),null}if(!$(z))return F.push(`${j}: must be an object`),null;let K=z.api;if(K!==Z){let B=K===void 0?"missing":typeof K==="string"?JSON.stringify(K):String(K);return F.push(`${j}: plugin API version ${B} is not supported (this rovecode speaks ${Z}) \u2014 skipped`),null}let W=z.name;if(typeof W!=="string"||!D.test(W))return F.push(`${j}: "name" must match ${D} \u2014 skipped`),null;let b=typeof z.version==="string"&&z.version.trim()?z.version.trim().slice(0,40):null;if(b===null)return F.push(`${j}: "version" must be a non-empty string \u2014 skipped`),null;let Q={name:W,version:b,description:"",api:Z};if(z.description!==void 0)if(typeof z.description==="string")Q.description=z.description.replace(/\s+/g," ").trim().slice(0,Y);else F.push(`${j}: "description" is not a string \u2014 ignored`);for(let B of["entry","commands","skills"]){let J=z[B];if(J===void 0)continue;if(typeof J!=="string"||!T(J)){F.push(`${j}: "${B}" must be a relative path inside the plugin \u2014 ignored`);continue}if(B==="entry"&&!C.test(J)){F.push(`${j}: "entry" must be a .ts or .js module \u2014 ignored`);continue}Q[B]=J.replace(/\\/g,"/")}if(z.mcp!==void 0)if($(z.mcp))Q.mcp=z.mcp;else F.push(`${j}: "mcp" must be an object of servers keyed by name \u2014 ignored`);if(z.permissions!==void 0){let B=z.permissions;if(Array.isArray(B)&&B.every((J)=>typeof J==="string"&&/^[a-z][a-z0-9.*-]{0,63}$/.test(J))){if(Q.permissions=B.slice(0,16),B.length>16)F.push(`${j}: "permissions" capped at 16 entries`)}else F.push(`${j}: "permissions" must be an array of action names (e.g. "shell.exec") \u2014 ignored`)}for(let B of Object.keys(z))if(!["name","version","description","api","entry","commands","skills","mcp","permissions"].includes(B))F.push(`${j}: unknown field "${B}" ignored`);return Q}function U(q){let j=[];if(q.entry)j.push(`code: ${q.entry}`);if(q.commands)j.push(`commands: ${q.commands}/`);if(q.skills)j.push(`skills: ${q.skills}/`);if(q.mcp)j.push(`mcp: ${Object.keys(q.mcp).join(", ")||"(none)"}`);if(q.permissions)j.push(`permissions: ${q.permissions.length>0?q.permissions.join(", "):"(none \u2014 read-only)"}`);return j}var Z=1,L="plugin.json",Y=200,D,C;var d=H(()=>{X();D=/^[a-z0-9][a-z0-9-]{0,63}$/,C=/\.(?:[cm]?[jt]s)$/i});
|
|
3
|
+
export{Z as sm,L as tm,M as um,U as vm,d as wm};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{bd as D,cd as k}from"./main-rfth4tbm.js";import{cf as A,ff as C}from"./main-351pz3z7.js";import{hf as F,if as I,jf as L,kf as N,nf as E}from"./main-dfreez27.js";import{$m as R,Lm as j}from"./main-2yeveeve.js";import{wn as H}from"./main-qsevpgsv.js";function O(z,J,K,V,Z){if(K.busy){V.addSystemNote("finish or interrupt the run first (Esc)","warn");return}if(!z.toggle(J)){V.addSystemNote(`already in ${J} mode`);return}let $=z.modelFor();K.mode=z.mode,K.model=$.model,K.provider=$.provider,V.addSystemNote(J==="plan"?"plan mode: read-only tools \u2014 writes/shell/spawn denied by policy":"act mode: full toolset restored"),Z()}function s(z,J,K){if(J.permissionRules=F(z.mode,J.permissionRules),z.mode!=="plan")return;delete J.verify;let V=K.systemPrompt;K.systemPrompt=(Z)=>(typeof V==="function"?V(Z):V)+`
|
|
3
3
|
|
|
4
4
|
`+I()}function d(z,J){let K=z.consumeSwitchNotice();if(K)J.append(L(K,J.messages().at(-1)?.id??null))}function c(z,J){let K=N(z);return K?`mode \u2192 ${K.to}`:J}var P=H(()=>{E()});import{readdirSync as S,readFileSync as v,statSync as b}from"fs";import{join as U,resolve as T}from"path";function M(z,J){return z.length>J?z.slice(0,J-1)+"\u2026":z}function g(z){let J=z.charCodeAt(0)===65279?z.slice(1):z,K={},V=J;if(J.startsWith("---")){if(!J.endsWith(`
|
|
5
5
|
`))J+=`
|
|
@@ -9,4 +9,4 @@ ${K}`}function Yz(z,J,K={}){let V=D(z,J);if(V!==void 0)return V;let Z=/^\/(\S+)(
|
|
|
9
9
|
custom:
|
|
10
10
|
`+z.map((J)=>`/${J.name}${J.hints.length>0?" "+J.hints.join(" "):""} \u2014 ${J.description} (${J.scope})`).join(`
|
|
11
11
|
`)}function qz(z,J,K,V){let Z=J.find((Y)=>Y.name===K);if(!Z)return!1;return n(z,Z,V),!0}async function n(z,J,K){if(z.state.busy){z.renderer.addSystemNote("finish or interrupt the run first (Esc)","warn");return}if(J.mode!==void 0&&J.mode!==z.modes.mode)O(z.modes,J.mode,z.state,z.renderer,z.pushStatus);let V=z.modes.modelFor().model,Z=J.model!==void 0&&J.model!==V;if(Z)z.modes.setModel({model:J.model}),z.state.model=z.modes.modelFor().model,z.renderer.addSystemNote(`model \u2192 ${J.model} for /${J.name} (restored after the run)`),z.pushStatus();try{await z.submit(_(J,K))}finally{if(Z&&z.modes.modelFor().model===J.model)z.modes.setModel({model:V}),z.state.model=V,z.pushStatus()}}var y,f,h,w,u=200;var m=H(()=>{R();C();P();k();y=/^[a-z0-9_-]+$/,f=/(?:"[^"]*"|'[^']*'|[^\s"']+)/g,h=/^["']|["']$/g,w=/\$(\$|ARGUMENTS|[1-9])/g});
|
|
12
|
-
export{O as
|
|
12
|
+
export{O as Nc,s as Oc,d as Pc,c as Qc,P as Rc,g as Sc,l as Tc,x as Uc,_ as Vc,Yz as Wc,Zz as Xc,$z as Yc,qz as Zc,n as _c,m as $c};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Kg as M}from"./main-cta9racd.js";import{Yi as J,cj as H}from"./main-sdmxhtv8.js";var O=/^(api[_-]?key|key|secret|token|password|auth(orization)?|bearer)$/i,Q=/^(sk-|sk_|key-|xai-|gsk_|AKIA|Bearer\s|ghp_)/;function W(w){if(typeof w!=="object"||w===null)return null;for(let[x,q]of Object.entries(w)){if(x==="keyEnv"||x==="noKey")continue;if(typeof q!=="string"||q.trim().length===0)continue;if(O.test(x))return x;if(Q.test(q.trim()))return x}return null}var X=(w)=>`provider_edit never accepts API keys (argument "${w}" looks like one) \u2014 nothing was stored. Keys stay with the human: ask them to run \`rovecode auth set <id>\` (masked prompt) or \`/provider key <id> <key>\` in the TUI, or to set the env var you name in keyEnv. Then retry without the key.`;function $(w){return{schema:{name:"provider_list",description:"Inspect model providers (never prompts, never mutates, never shows a key). `list` shows the configured providers, the default provider/model and where each key comes from (stored / env NAME / none; `all` adds keyless built-ins); `models` lists the model ids a provider offers (its providers.json entry or its /models endpoint); `test` makes one tiny real call to a provider (optionally a specific model) and reports ok or the error. Use it before switching models, or when a run ends with a `config:` error.",args:{type:"object",properties:{action:{type:"string",enum:["list","models","test"]},id:{type:"string",description:"provider id (models / test)"},model:{type:"string",description:"model id to test (default: the provider's default model)"},all:{type:"boolean",description:"list: include built-in providers that have no key yet"}},required:["action"]}},kind:"read",sequential:!1,async execute(x){let q=x&&typeof x==="object"?x:{};switch(q.action){case"list":return{ok:!0,output:M(w,{all:q.all===!0})};case"models":{if(!q.id)return{ok:!1,output:"models needs `id`"};let b=await w.models(q.id);if(!b.ok)return{ok:!1,output:b.error};return b.models.length>0?{ok:!0,output:`${q.id} models (${b.source}, ${b.models.length}):
|
|
3
3
|
${b.models.join(`
|
|
4
4
|
`)}`}:{ok:!0,output:`${q.id}: the endpoint listed no models (it may not implement /models \u2014 try a model id directly with test)`}}case"test":{if(!q.id)return{ok:!1,output:"test needs `id`"};let b=await w.probe(q.id,q.model);return{ok:b.ok,output:`${q.id}/${b.model}: ${b.detail}`}}default:return{ok:!1,output:"action must be list | models | test"}}}}}function A(w){return{schema:{name:"provider_edit",description:'Add, remove or select model providers; the human approves each call. `add` registers an endpoint {id, baseUrl, protocol? (openai|anthropic \u2014 inferred from the URL), keyEnv? (env var holding the key), defaultModel?, noKey? (local servers), scope? (user|project)} in providers.json. `remove` deletes a file-defined provider. `use` sets the default provider/model (`selector` = "provider/model" or a provider id) and takes effect immediately: the TUI switches now, the next run uses it, no restart. NEVER pass an API key here \u2014 the call is refused and nothing is stored. After `add`, tell the user to run `rovecode auth set <id>` (or `/provider key <id> <key>` in the TUI), or to set the keyEnv variable; the key is picked up live.',args:{type:"object",properties:{action:{type:"string",enum:["add","remove","use"]},id:{type:"string"},baseUrl:{type:"string",description:"http(s) endpoint root, e.g. https://llm.example.com/v1"},protocol:{type:"string",enum:["openai","anthropic"]},keyEnv:{type:"string",description:"env var that holds the key (default <ID>_API_KEY)"},defaultModel:{type:"string"},noKey:{type:"boolean",description:"local server: no key required"},scope:{type:"string",enum:["user","project"],description:"which providers.json: ~/.rovecode (default) or ./.rovecode"},selector:{type:"string",description:"use: provider/model"}},required:["action"]}},kind:"custom",sequential:!0,async execute(x){let q=W(x);if(q!==null)return{ok:!1,output:X(q)};let b=x&&typeof x==="object"?x:{},B=b.scope==="project"?"project":"user";switch(b.action){case"add":{if(!b.id||!b.baseUrl)return{ok:!1,output:"add needs `id` and `baseUrl`"};let j=w.add({id:b.id,baseUrl:b.baseUrl,protocol:b.protocol??J(b.baseUrl),...b.keyEnv!==void 0?{keyEnv:b.keyEnv}:{},...b.defaultModel!==void 0?{defaultModel:b.defaultModel}:{},...b.noKey===!0?{noKey:!0}:{}},B);if("error"in j)return{ok:!1,output:j.error};let z=!H(j)?`key: NOT SET \u2014 the user must run \`rovecode auth set ${j.id}\` (or \`/provider key ${j.id} <key>\` in the TUI), or set ${j.keyEnv}; it is picked up immediately, no restart`:j.keySource==="stored"?"key: stored credential":j.keySource==="env"?`key: env ${j.keyEnv} (present)`:"key: not needed";return{ok:!0,output:`added provider "${j.id}" (${j.protocol}, ${j.baseUrl}) to the ${B} providers.json
|
|
5
5
|
${z}${j.defaultModel!==void 0?`
|
|
6
6
|
default model: ${j.defaultModel}`:""}
|
|
7
7
|
select it with provider_edit use ${j.id}/<model>`}}case"remove":{if(!b.id)return{ok:!1,output:"remove needs `id`"};let j=w.remove(b.id);if("error"in j)return{ok:!1,output:j.error};return{ok:!0,output:j.removed.length>0?`removed provider "${b.id}" from the ${j.removed.join(" and ")} providers.json`:`provider "${b.id}" was not in any providers.json`}}case"use":{let j=b.selector??b.id;if(!j)return{ok:!1,output:"use needs `selector` (provider/model)"};let z=w.setDefault(j,B);if("error"in z)return{ok:!1,output:z.error};let G=w.get(z.provider),N=G!==void 0&&!H(G)?`
|
|
8
8
|
note: ${w.keyHint(G)}`:"";return{ok:!0,output:`default \u2192 ${z.provider}/${z.model} (saved to the ${B} providers.json; the TUI switches now, headless runs use it from the next run)${N}`}}default:return{ok:!1,output:"action must be add | remove | use"}}}}}
|
|
9
|
-
export{W as
|
|
9
|
+
export{W as he,$ as ie,A as je};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ai as E,wi as _,yi as b,zi as A}from"./main-k2y8a2aw.js";import{$i as L,Wi as I,Zi as k,_i as K,cj as X,ej as y,fj as T,gj as U}from"./main-sdmxhtv8.js";import{kk as M,uk as D}from"./main-8kjxbpw4.js";D();function W(j){return{id:j.id,baseUrl:j.baseUrl,apiKey:j.apiKey??"",protocol:j.protocol,...j.defaultModel!==void 0?{defaultModel:j.defaultModel}:{},...j.headers!==void 0?{headers:j.headers}:{}}}var x=(j,{sse:z})=>{let q=W(j);return z?A(q):b(q)},C="config: ";function G(j){return{parts:[],stopReason:"error",usage:{input:0,output:0},error:C+j}}function R(j,z){return z!==null&&z!==void 0&&z.length>0?j.split(z).join("\u2026"):j}class S{cwd;env;cfg;factory;adapters=new Map;constructor(j,z={}){this.cwd=j,this.env=z.env??process.env,this.factory=z.adapterFactory??x,this.cfg=new U(j,this.env,z.throttleMs)}snapshot(){return this.cfg.snapshot()}list(){return this.snapshot().providers}ids(){return this.list().map((j)=>j.id)}get(j){return this.list().find((z)=>z.id===j)}configured(){return this.list().some(X)}warnings(){return this.snapshot().warnings}onChange(j){return this.cfg.onChange(j)}refresh(){return this.cfg.invalidate(),this.cfg.snapshot()}defaultRef(){let j=T(this.snapshot());if(j===null)return null;return{provider:j.provider.id,model:this.env.ROVECODE_MODEL??j.model??""}}defaultConfig(){let j=T(this.snapshot());if(j===null)return null;return{...W(j.provider),...j.model!==void 0?{defaultModel:j.model}:{}}}defaultSelector(){return this.snapshot().defaultSelector}resolveSelector(j,z){let q=j.trim();if(q.length===0)return{error:"empty model selector"};let H=q.indexOf("/");if(H>0){let J=q.slice(0,H),Q=q.slice(H+1).trim();if(this.get(J)!==void 0)return Q.length>0?{provider:J,model:Q}:{error:`"${q}" names no model \u2014 use ${J}/<model>`}}return{provider:z,model:q}}add(j,z="user"){let{id:q,...H}=j,J=k(q,H);if("error"in J)return J;if(this.get(q)?.scope==="env")return{error:'"custom" is reserved for the ROVECODE_BASE_URL/ROVECODE_API_KEY pair \u2014 pick another id'};let Q=I(z,this.cwd),{data:V}=K(Q),{id:Z,...$}=J.spec;return V.providers={...V.providers??{},[q]:$},L(Q,V),this.refresh(),this.get(q)}remove(j){let z=this.get(j);if(z===void 0)return{error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(z.scope==="builtin")return{error:`"${j}" is built in; drop its key with \`rovecode auth remove ${j}\` instead`};if(z.scope==="env")return{error:'"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY \u2014 unset those env vars'};let q=[];for(let H of["user","project"]){let J=I(H,this.cwd),{data:Q}=K(J);if(Q.providers!==void 0&&j in Q.providers){if(delete Q.providers[j],Object.keys(Q.providers).length===0)delete Q.providers;L(J,Q),q.push(H)}}return this.refresh(),{removed:q}}setDefault(j,z="user"){let q=y(j),H=this.get(q.provider);if(H===void 0)return{error:`unknown provider "${q.provider}" \u2014 known: ${this.ids().join(" ")}`};let J=q.model??H.defaultModel;if(J===void 0)return{error:`"${j}" names no model and ${H.id} has no default \u2014 use ${H.id}/<model>`};let Q=I(z,this.cwd),{data:V}=K(Q);return V.default=`${H.id}/${J}`,L(Q,V),this.refresh(),{provider:H.id,model:J}}setModels(j,z,q="user"){let H=this.get(j);if(H===void 0)return{error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(H.scope==="env")return{error:'"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY \u2014 a model list cannot be pinned on it'};for(let N of z)if(N.trim().length===0)return{error:"model ids must be non-empty strings"};let J=I(q,this.cwd),{data:Q}=K(J),V=Q.providers??{},$=V[j]??{baseUrl:H.baseUrl},B=[...new Set(z.map((N)=>N.trim()))];if(B.length===0)delete $.models;else if($.models=B,$.defaultModel!==void 0&&!B.includes($.defaultModel))delete $.defaultModel;return V[j]=$,Q.providers=V,L(J,Q),this.refresh(),{models:B}}keyHint(j){return`no API key for provider "${j.id}" \u2014 I can't call it without one. ${M(`rovecode auth set ${j.id}`)} (masked prompt) \xB7 or /provider key ${j.id} <key> in the TUI \xB7 or set ${j.keyEnv}`}async models(j,z={}){let q=this.get(j);if(q===void 0)return{ok:!1,error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(q.models!==void 0&&q.models.length>0)return{ok:!0,models:q.models,source:"file"};if(!X(q))return{ok:!1,error:this.keyHint(q)};return{ok:!0,models:(await _(W(q),z)).map((J)=>J.id),source:"endpoint"}}async probe(j,z){let q=this.get(j);if(q===void 0)return{ok:!1,model:z??"",detail:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(!X(q))return{ok:!1,model:z??"",detail:this.keyHint(q)};let H=z??q.defaultModel;if(H===void 0)return{ok:!1,model:"",detail:`${q.id} has no default model \u2014 pass one: test ${q.id} <model>`};let J={id:"probe",role:"user",parts:[{kind:"text",text:"ping"}],parentId:null,createdAt:Date.now()},Q=Date.now(),V;try{for await(let Z of this.adapterFor(q)({provider:q.id,model:H,maxTokens:8},[J],{tools:[]}))if(Z.type==="turn")V=Z.turn}catch(Z){return{ok:!1,model:H,detail:R(Z instanceof Error?Z.message:String(Z),q.apiKey)}}if(V===void 0)return{ok:!1,model:H,detail:"stream produced no turn"};if(V.stopReason==="error")return{ok:!1,model:H,detail:R(V.error??"stream error",q.apiKey)};return{ok:!0,model:H,detail:`ok in ${Date.now()-Q} ms (${V.usage.input} in / ${V.usage.output} out tokens)`}}stream(){let j=this;return async function*(z,q,H){let J=j.get(z.provider);if(J===void 0){yield{type:"turn",turn:G(`provider "${z.provider}" is not configured \u2014 I can't route to it. ${M(`rovecode provider add ${z.provider} <baseUrl> [--protocol openai|anthropic]`)} (or /provider add in the TUI); known: ${j.ids().join(" ")}`)};return}if(!X(J)){yield{type:"turn",turn:G(j.keyHint(J))};return}yield*j.adapterFor(J)(z,q,H)}}adapterFor(j){let z=E({ROVECODE_STREAM:this.env.ROVECODE_STREAM}),q=[j.baseUrl,j.protocol,j.apiKey??"",JSON.stringify(j.headers??{}),z?"sse":"json"].join("\x00"),H=this.adapters.get(j.id);if(H!==void 0&&H.sig===q)return H.fn;let J=this.factory(j,{sse:z});return this.adapters.set(j.id,{sig:q,fn:J}),J}}var O="add <id> <baseUrl> [--protocol openai|anthropic] [--key-env NAME] [--model <id>] [--no-key] [--project]";function g(j){let z=[],q={},H="user",J=!1;for(let $=0;$<j.length;$++){let B=j[$],N=()=>{let Y=j[$+1];if(Y===void 0||Y.startsWith("-"))return{error:`${B} needs a value \u2014 ${O}`};return $++,Y};switch(B){case"--protocol":{let Y=N();if(typeof Y!=="string")return Y;q.protocol=Y;break}case"--key-env":{let Y=N();if(typeof Y!=="string")return Y;q.keyEnv=Y;break}case"--model":{let Y=N();if(typeof Y!=="string")return Y;q.defaultModel=Y;break}case"--scope":{let Y=N();if(typeof Y!=="string")return Y;if(Y!=="user"&&Y!=="project")return{error:"--scope must be user or project"};H=Y;break}case"--project":H="project";break;case"--user":H="user";break;case"--no-key":q.noKey=!0;break;case"--key":J=!0;break;default:if(B.startsWith("-"))return{error:`unknown flag ${B} \u2014 ${O}`};z.push(B)}}let[Q,V]=z;if(Q===void 0||V===void 0)return{error:`usage: ${O}`};q.baseUrl=V;let Z=k(Q,q);if("error"in Z)return Z;return{spec:Z.spec,scope:H,promptKey:J}}function F(j){let z=j.keySource==="stored"?"key: stored":j.keySource==="env"?`key: env ${j.keyEnv}`:j.keySource==="inline"?"key: ROVECODE_API_KEY":j.noKey===!0?"key: not needed":`key: NONE (rovecode auth set ${j.id} \xB7 or set ${j.keyEnv})`;return`${j.id.padEnd(12)} ${j.protocol.padEnd(9)} ${j.baseUrl.padEnd(40)} ${z}${j.defaultModel!==void 0?` model: ${j.defaultModel}`:""} [${j.scope}]`}function u(j,z={}){let q=j.defaultRef(),H=j.list(),J=H.filter((Z)=>z.all===!0||X(Z)||Z.scope!=="builtin"),Q=[q!==null?`default \u2192 ${q.provider}/${q.model||"(no model \u2014 pass one with /model or ROVECODE_MODEL)"}${j.defaultSelector()!==void 0?` (providers.json default: ${j.defaultSelector()})`:""}`:`default \u2192 none yet. ${M("rovecode setup")} (or rovecode provider add <id> <baseUrl>, then rovecode auth set <id>)`];Q.push(...J.map(F));let V=H.length-J.length;if(V>0)Q.push(`(+${V} built-in providers without a key \u2014 \`list --all\` shows them)`);return Q.push(...j.warnings().map((Z)=>`warning: ${Z}`)),Q.join(`
|
|
3
3
|
`)}
|
|
4
|
-
export{W as
|
|
4
|
+
export{W as Bg,x as Cg,C as Dg,G as Eg,R as Fg,S as Gg,O as Hg,g as Ig,F as Jg,u as Kg};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{$m as P,Lm as A}from"./main-2yeveeve.js";P();import{readFileSync as R,writeFileSync as x,mkdirSync as C}from"fs";import{execFile as E}from"child_process";import{join as N}from"path";var U="9Code-Labs/rovecode-community",O=21600000,_=8000;function W(q,z){let G=(K)=>{let J=K.trim().replace(/^v/i,""),[V="",...$]=J.split("-");return{nums:V.split(".").map((D)=>Number.parseInt(D,10)||0),pre:$.length>0}},B=G(q),Y=G(z),Z=Math.max(B.nums.length,Y.nums.length);for(let K=0;K<Z;K++){let J=B.nums[K]??0,V=Y.nums[K]??0;if(J!==V)return J>V}return Y.pre&&!B.pre}function k(q,z,G){try{let B=JSON.parse(R(q,"utf8"));if(typeof B.at!=="number"||!B.status)return null;if(G-B.at>z)return null;return{...B.status,from:"cache"}}catch{return null}}function j(q,z,G){try{C(N(q,".."),{recursive:!0}),x(q,JSON.stringify({at:G,status:{...z,from:"network"}}))}catch{}}function M(){return new Promise((q)=>{try{E("gh",["auth","token"],{timeout:1500,windowsHide:!0},(z,G)=>{let B=typeof G==="string"?G.trim():"";q(z!==null||B.length===0?void 0:B)})}catch{q(void 0)}})}async function g(q,z={}){if(z.fetchFn===void 0&&z.token===void 0&&z.cacheFile===void 0&&z.ghToken===void 0&&process.env.ROVECODE_NO_UPDATE_CHECK==="1")return{current:q,newer:!1,from:"cache",reason:"ROVECODE_NO_UPDATE_CHECK=1"};let B=(z.now??Date.now)(),Y=z.repo??U,Z=z.cacheFile??N(A(),`update-check-${Y.replace(/[^\w.-]+/g,"_")}.json`),K=z.ttlMs??O,J=k(Z,K,B);if(J)return{...J,current:q,newer:J.latest!==void 0&&W(J.latest,q)};if(z.cacheOnly===!0)return{current:q,newer:!1,from:"cache",reason:"not asked yet \u2014 rovecode checks at startup, at most once every six hours"};let V=z.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN??await(z.ghToken??M)(),$=new AbortController,D=setTimeout(()=>$.abort(),z.timeoutMs??_);try{let Q=await(z.fetchFn??fetch)(`https://api.github.com/repos/${z.repo??U}/releases/latest`,{headers:{accept:"application/vnd.github+json","user-agent":"rovecode",...V?{authorization:`Bearer ${V}`}:{}},signal:$.signal});if(Q.status===404){let L={current:q,newer:!1,from:"network",reason:"no release published yet"};return j(Z,L,B),L}if(!Q.ok)return{current:q,newer:!1,from:"network",reason:`GitHub answered ${Q.status}`};let X=await Q.json().catch(()=>null),H=typeof X?.tag_name==="string"?X.tag_name:void 0;if(!H)return{current:q,newer:!1,from:"network",reason:"the release carries no tag name"};let I={current:q,latest:H.replace(/^v/i,""),newer:W(H,q),from:"network",...typeof X?.html_url==="string"?{url:X.html_url}:{}};return j(Z,I,B),I}catch(Q){let X=Q instanceof Error?Q.message:String(Q);return{current:q,newer:!1,from:"network",reason:$.signal.aborted?"the check timed out":X}}finally{clearTimeout(D)}}function b(q,z=!1){if(q.newer&&q.latest!==void 0)return`update available: ${q.current} \u2192 ${q.latest}${q.url?` \xB7 ${q.url}`:""}`;if(!z)return null;if(q.reason!==void 0)return`update check: ${q.reason}`;return`up to date (${q.current})${q.from==="cache"?" \xB7 cached":""}`}
|
|
3
|
-
export{W as
|
|
3
|
+
export{W as Yh,g as Zh,b as _h};
|
|
@@ -7,4 +7,4 @@ You are in Plan mode. Your role is to explore, analyze, and plan -- not to execu
|
|
|
7
7
|
- Editing tools, shell commands, and sub-agents are unavailable in plan mode: attempts are denied by policy. If the task requires a mutation, put it in the plan; it happens only after the user switches to act mode.
|
|
8
8
|
|
|
9
9
|
Once you have presented your plan, end your turn and wait for the user's response. You do NOT have the ability to switch to act mode yourself -- the user must do it manually with the Plan/Act toggle once they are satisfied with the plan. If the task requires tools that are only available in act mode, ask the user to "toggle to Act mode" (use those words).`}function $(q,x){return`<mode_notice>The user switched from ${q} mode to ${x} mode before sending this message.</mode_notice>`}function j(){let q=null;return{record(x,z){if(x===z)return;if(q){q=q.from===z?null:{from:q.from,to:z};return}q={from:x,to:z}},consume(){let x=q;return q=null,x}}}function I(q,x){return{id:Q(),role:"system",parts:[{kind:"text",text:$(q.from,q.to)}],parentId:x,createdAt:Date.now(),modeSwitch:{from:q.from,to:q.to}}}function C(q){if(!q||typeof q!=="object")return null;let x=q;if(x.role!=="system")return null;let z=x.modeSwitch;if(!z||typeof z!=="object")return null;return G(z.from)&&G(z.to)?{from:z.from,to:z.to}:null}function U(q){for(let x=q.length-1;x>=0;x--){let z=C(q[x]);if(z)return z.to}return null}class L{currentMode;slots;fallback;separateModels;tracker=j();constructor(q={},x={}){this.currentMode=q.defaultMode??Y,this.separateModels=q.planActSeparateModels??!1,this.fallback={provider:x.provider,model:x.model},this.slots={plan:{provider:q.plan?.provider,model:q.plan?.model},act:{provider:q.act?.provider,model:q.act?.model}}}get mode(){return this.currentMode}get separate(){return this.separateModels}toggle(q){if(q===this.currentMode)return null;let x={from:this.currentMode,to:q};return this.currentMode=q,this.tracker.record(x.from,x.to),x}restore(q){this.currentMode=q,this.tracker.consume()}consumeSwitchNotice(){return this.tracker.consume()}modelFor(q=this.currentMode){let x=this.slots[q];return{provider:x.provider??this.fallback.provider??"",model:x.model??this.fallback.model??""}}setModel(q){let x=this.separateModels?[this.currentMode]:["plan","act"];for(let z of x){if(q.provider!==void 0)this.slots[z].provider=q.provider;if(q.model!==void 0)this.slots[z].model=q.model}}}var Y="act";var R=()=>{};
|
|
10
|
-
export{E as
|
|
10
|
+
export{E as gf,N as hf,D as if,I as jf,C as kf,U as lf,L as mf,R as nf};
|