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.
Files changed (189) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +13 -0
  3. package/dist/cli/app-j6gn14w3.js +2 -0
  4. package/dist/cli/{ask-user-p8hq4xgj.js → ask-user-cwstt8fz.js} +1 -1
  5. package/dist/cli/auth-login-9bbp9915.js +2 -0
  6. package/dist/cli/{bench-xv3ypwev.js → bench-16zqdms5.js} +1 -1
  7. package/dist/cli/catalog-1xchffa4.js +2 -0
  8. package/dist/cli/cli-1n1zb64f.js +2 -0
  9. package/dist/cli/client-2t9gjkck.js +2 -0
  10. package/dist/cli/{commands-3p7e4xxs.js → commands-exafvm2b.js} +1 -1
  11. package/dist/cli/connect-6zde0kn3.js +2 -0
  12. package/dist/cli/{context-cmd-eqxmxhzq.js → context-cmd-5t43wgqt.js} +1 -1
  13. package/dist/cli/context-report-kt01pw8y.js +2 -0
  14. package/dist/cli/{count-remote-mby98cd0.js → count-remote-ap7x3vh6.js} +1 -1
  15. package/dist/cli/{design-122y0axd.js → design-ne5zszyh.js} +1 -1
  16. package/dist/cli/dispatch-2r5myxye.js +2 -0
  17. package/dist/cli/doctor-ws4fh4tn.js +3 -0
  18. package/dist/cli/{executor-ftvg6tsy.js → executor-bdrjn634.js} +1 -1
  19. package/dist/cli/export-1mxb9g5p.js +2 -0
  20. package/dist/cli/{files-cez9a96p.js → files-g104xghh.js} +1 -1
  21. package/dist/cli/gauntlet-07xrjpj7.js +2 -0
  22. package/dist/cli/{gauntlet-runner-r515m7kk.js → gauntlet-runner-xvy64436.js} +1 -1
  23. package/dist/cli/{gauntlet-wave3-bnkjk2v2.js → gauntlet-wave3-jm91yt5w.js} +1 -1
  24. package/dist/cli/{gauntlet-wave4-acs9s60q.js → gauntlet-wave4-r13py7p1.js} +1 -1
  25. package/dist/cli/hashline-znvrat11.js +2 -0
  26. package/dist/cli/http-xafw6fsh.js +143 -0
  27. package/dist/cli/{index-z5qt1s76.js → index-1sgjm25y.js} +1 -1
  28. package/dist/cli/init-g2m0tn4m.js +51 -0
  29. package/dist/cli/install-avaqjjqq.js +2 -0
  30. package/dist/cli/loop-mmpfft01.js +2 -0
  31. package/dist/cli/{main-a3f51n0x.js → main-0904f6ps.js} +1 -1
  32. package/dist/cli/{main-f33fc5je.js → main-0ab9fc26.js} +2 -2
  33. package/dist/cli/{main-n6qrdbmy.js → main-0mtcdbs7.js} +2 -2
  34. package/dist/cli/main-0z1w2zsg.js +3 -0
  35. package/dist/cli/{main-rvetps99.js → main-1dchs7xv.js} +2 -2
  36. package/dist/cli/{main-rpg7h8mb.js → main-1ereejm1.js} +2 -2
  37. package/dist/cli/{main-6vjeds42.js → main-1k1kw6b5.js} +2 -2
  38. package/dist/cli/{main-hrrvcfan.js → main-27y4sm2k.js} +2 -2
  39. package/dist/cli/{main-8c1tbazx.js → main-2wwjex5j.js} +2 -2
  40. package/dist/cli/main-2yfck9b5.js +3 -0
  41. package/dist/cli/main-2zmzgkwh.js +3 -0
  42. package/dist/cli/{main-xt9zc3n6.js → main-351pz3z7.js} +1 -1
  43. package/dist/cli/{main-kba6zeyd.js → main-3gjqfh7a.js} +1 -1
  44. package/dist/cli/{main-s4bb0jav.js → main-3nf3kgve.js} +1 -1
  45. package/dist/cli/{main-2z3dek0b.js → main-3pjrb2hd.js} +1 -1
  46. package/dist/cli/{main-qj2djy17.js → main-3rxcvgna.js} +3 -3
  47. package/dist/cli/{main-9a9rnh47.js → main-4b3jgy66.js} +1 -1
  48. package/dist/cli/{main-6dtqmbt6.js → main-4wndhjdc.js} +1 -1
  49. package/dist/cli/{main-9ht36z12.js → main-4xcmvxnk.js} +2 -2
  50. package/dist/cli/{main-vp2dfb7s.js → main-5tbz0wbz.js} +2 -2
  51. package/dist/cli/{main-wpkyraxh.js → main-5ywnwthm.js} +2 -2
  52. package/dist/cli/{main-yrjt2sqt.js → main-6b62vkz0.js} +2 -2
  53. package/dist/cli/{main-2zgsknth.js → main-6dnk69vp.js} +1 -1
  54. package/dist/cli/{main-nvc3yjay.js → main-6genrmhs.js} +2 -2
  55. package/dist/cli/{main-rsy72qmw.js → main-73g7eff4.js} +2 -2
  56. package/dist/cli/{main-jak598k9.js → main-7c5thhjd.js} +1 -1
  57. package/dist/cli/{main-y5c82rxr.js → main-7rn6bqje.js} +1 -1
  58. package/dist/cli/{main-4p4e2w7x.js → main-80haw7qk.js} +2 -2
  59. package/dist/cli/{main-01pv9206.js → main-875s60s2.js} +2 -2
  60. package/dist/cli/{main-ywbxshqc.js → main-8kjxbpw4.js} +1 -1
  61. package/dist/cli/{main-1ztz6fkj.js → main-90ds1z4e.js} +1 -1
  62. package/dist/cli/{main-mjt2p7aj.js → main-9etavkew.js} +1 -1
  63. package/dist/cli/main-a9njrkk1.js +3 -0
  64. package/dist/cli/{main-fvnpq46y.js → main-aecrjq2d.js} +2 -2
  65. package/dist/cli/{main-23q7cmww.js → main-ck9asesq.js} +2 -2
  66. package/dist/cli/{main-wqt32p5x.js → main-cta9racd.js} +2 -2
  67. package/dist/cli/{main-wm997zjx.js → main-ddv7j2ag.js} +1 -1
  68. package/dist/cli/{main-ntqef02r.js → main-dfreez27.js} +1 -1
  69. package/dist/cli/{main-m8vm17zq.js → main-f7rw7des.js} +1 -1
  70. package/dist/cli/{main-rebtt91r.js → main-ggcn7rd7.js} +2 -2
  71. package/dist/cli/{main-gbbty4d4.js → main-gzkmycnv.js} +1 -1
  72. package/dist/cli/{main-vxnwe5xx.js → main-hq51jg8v.js} +2 -2
  73. package/dist/cli/{main-vqbr22sz.js → main-jft389w9.js} +2 -2
  74. package/dist/cli/{main-qvarybsp.js → main-k1eqkg83.js} +2 -2
  75. package/dist/cli/{main-2wyax8k9.js → main-k2y8a2aw.js} +2 -2
  76. package/dist/cli/main-kcpbykxz.js +4 -0
  77. package/dist/cli/{main-45rn3trk.js → main-kd488vje.js} +1 -1
  78. package/dist/cli/main-kh32yvgk.js +5 -0
  79. package/dist/cli/{main-z13755t8.js → main-kqxnqjnv.js} +4 -4
  80. package/dist/cli/{main-b8zq261k.js → main-kyn0xnsg.js} +2 -2
  81. package/dist/cli/{main-evgz4mp5.js → main-m1kk6fp5.js} +1 -1
  82. package/dist/cli/{main-5py0rkmc.js → main-mv40pcr2.js} +1 -1
  83. package/dist/cli/{main-vhrrq337.js → main-n0t3973w.js} +1 -1
  84. package/dist/cli/{main-s9v8k74e.js → main-pknhvrmj.js} +2 -2
  85. package/dist/cli/{main-kwwsz6rq.js → main-pn1w7a7j.js} +2 -2
  86. package/dist/cli/{main-6h9x282m.js → main-prxxs70n.js} +2 -2
  87. package/dist/cli/{main-2rzbexn2.js → main-q3vsesf9.js} +1 -1
  88. package/dist/cli/{main-gth53dnt.js → main-rdgdw24b.js} +7 -7
  89. package/dist/cli/{main-4y0tnfpa.js → main-rfth4tbm.js} +1 -1
  90. package/dist/cli/{main-wk2csfnj.js → main-rg0wn0xf.js} +2 -2
  91. package/dist/cli/{main-xx2z3zh5.js → main-sdmxhtv8.js} +1 -1
  92. package/dist/cli/{main-mg9b20ac.js → main-skbp13js.js} +1 -1
  93. package/dist/cli/{main-xfekqh9m.js → main-t4xnd213.js} +1 -1
  94. package/dist/cli/{main-7kt6r53y.js → main-vqak588n.js} +2 -2
  95. package/dist/cli/{main-hqbz10aw.js → main-w2n1303f.js} +1 -1
  96. package/dist/cli/{main-na7wse0x.js → main-wbrdspr2.js} +2 -2
  97. package/dist/cli/{main-a2yfvcy9.js → main-wsrg79c1.js} +2 -2
  98. package/dist/cli/{main-hzwtsb2m.js → main-x4r0fne4.js} +2 -2
  99. package/dist/cli/{main-78gq4bt9.js → main-xea2f3tn.js} +1 -1
  100. package/dist/cli/{main-v8y60bb2.js → main-xg704a3c.js} +1 -1
  101. package/dist/cli/{main-p0cfn6nr.js → main-xvnrabfp.js} +2 -2
  102. package/dist/cli/{main-45ejth3a.js → main-xy53xf0r.js} +2 -2
  103. package/dist/cli/{main-x9ct6y1a.js → main-y1fqy60y.js} +2 -2
  104. package/dist/cli/{main-j7ttv0sd.js → main-yn8cd281.js} +4 -4
  105. package/dist/cli/{main-zc7pyrbj.js → main-yr0ksc0h.js} +1 -1
  106. package/dist/cli/{main-tkgarpjj.js → main-z2ex2vyf.js} +2 -2
  107. package/dist/cli/{main-mgb9ccnx.js → main-z3aayzvq.js} +1 -1
  108. package/dist/cli/{main-tjvwmscs.js → main-zaqh35jg.js} +2 -2
  109. package/dist/cli/{main-edxc3yzt.js → main-zc2e8e46.js} +2 -2
  110. package/dist/cli/{main-bxtvnf6d.js → main-zzrfw6cf.js} +2 -2
  111. package/dist/cli/main.js +5 -4
  112. package/dist/cli/{market-cmd-bm5xvn9f.js → market-cmd-e14kmx9n.js} +2 -2
  113. package/dist/cli/{mcp-login-bthtfpt7.js → mcp-login-wq7ktdek.js} +1 -1
  114. package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
  115. package/dist/cli/{notify-54v5z9dz.js → notify-b7qc0cjb.js} +1 -1
  116. package/dist/cli/{oauth-g5gme95c.js → oauth-z8whcgfx.js} +1 -1
  117. package/dist/cli/{output-satndjap.js → output-b3ewj3ps.js} +1 -1
  118. package/dist/cli/{profiles-sfhpbq3m.js → profiles-6mr5he5e.js} +1 -1
  119. package/dist/cli/{provider-config-hv3xtdt4.js → provider-config-g7j42q8x.js} +1 -1
  120. package/dist/cli/provider-jr1y8vvm.js +2 -0
  121. package/dist/cli/registry-s8yk86g0.js +2 -0
  122. package/dist/cli/{registry-fh0hdnyn.js → registry-t6p8d4mn.js} +1 -1
  123. package/dist/cli/{repl-t4z03mqq.js → repl-bajwe1mh.js} +1 -1
  124. package/dist/cli/{resume-fqt4chg8.js → resume-rwn9nz7y.js} +1 -1
  125. package/dist/cli/run-flags-nah7ndpt.js +2 -0
  126. package/dist/cli/runtime-n7gafzhb.js +2 -0
  127. package/dist/cli/{sandbox-config-g4qxd7y5.js → sandbox-config-emdy18x4.js} +1 -1
  128. package/dist/cli/{server-r0b6bksk.js → server-b0nvs2bn.js} +1 -1
  129. package/dist/cli/session-arg-y75wd4kj.js +2 -0
  130. package/dist/cli/session-j62evmjq.js +2 -0
  131. package/dist/cli/{sessions-cmd-adw7svfn.js → sessions-cmd-tsnwz0ns.js} +1 -1
  132. package/dist/cli/{settings-y9rzcqx8.js → settings-df10wfez.js} +1 -1
  133. package/dist/cli/{setup-jmbr11j0.js → setup-jzvv72fg.js} +1 -1
  134. package/dist/cli/{sextant-smoke-tcth0vea.js → sextant-smoke-37m81ke6.js} +1 -1
  135. package/dist/cli/{skills-cmd-zbdy99v6.js → skills-cmd-gjxnxnhx.js} +1 -1
  136. package/dist/cli/smoke-p7748apt.js +8 -0
  137. package/dist/cli/{start-chat-p01cdks3.js → start-chat-s4st3mm0.js} +3 -3
  138. package/dist/cli/stream-gmeyewds.js +2 -0
  139. package/dist/cli/task-gh0kkp3n.js +2 -0
  140. package/dist/cli/tasks-z1kfpe8e.js +2 -0
  141. package/dist/cli/{thinking-a5ngvqyh.js → thinking-0eqkrz6t.js} +1 -1
  142. package/dist/cli/{todo-1wxpcecx.js → todo-5brcrt9m.js} +1 -1
  143. package/dist/cli/{tools-x1tj4fxm.js → tools-7pzm0vj9.js} +1 -1
  144. package/dist/cli/{tools-2ftsya7w.js → tools-s635p6s8.js} +1 -1
  145. package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
  146. package/dist/cli/{update-check-ygt3vd7m.js → update-check-pt31bm2f.js} +1 -1
  147. package/dist/cli/{update-cmd-v23qhr8c.js → update-cmd-tk131s9t.js} +1 -1
  148. package/dist/cli/{voice-g1gtck92.js → voice-56nabd8d.js} +1 -1
  149. package/dist/cli/{webfetch-0nnrjgb5.js → webfetch-xd8q596m.js} +1 -1
  150. package/dist/cli/{websearch-f0vr2p7d.js → websearch-5hkf98k1.js} +1 -1
  151. package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
  152. package/dist/cli/{workspace-9rq1w4ta.js → workspace-q10g5z3e.js} +1 -1
  153. package/dist/lib/index.js +44 -44
  154. package/dist/lib/plugins.js +54 -5
  155. package/dist/lib/public-api.js +15 -15
  156. package/dist/lib/sdk.js +360 -0
  157. package/package.json +3 -2
  158. package/dist/cli/app-dybnr56b.js +0 -2
  159. package/dist/cli/auth-login-ewpgw5sm.js +0 -2
  160. package/dist/cli/catalog-737wb2s0.js +0 -2
  161. package/dist/cli/cli-arhg40m0.js +0 -2
  162. package/dist/cli/client-cf2pxx8q.js +0 -2
  163. package/dist/cli/connect-3q93d7cb.js +0 -2
  164. package/dist/cli/context-report-hbw9zfes.js +0 -2
  165. package/dist/cli/dispatch-b4egzvvh.js +0 -2
  166. package/dist/cli/doctor-x4jkv72e.js +0 -3
  167. package/dist/cli/export-pdgdhkch.js +0 -2
  168. package/dist/cli/gauntlet-r3xxaszc.js +0 -2
  169. package/dist/cli/hashline-ewg5hbe3.js +0 -2
  170. package/dist/cli/http-n0kehsk8.js +0 -5
  171. package/dist/cli/install-80mp63kx.js +0 -2
  172. package/dist/cli/loop-12twjcat.js +0 -2
  173. package/dist/cli/main-7jd5vh3x.js +0 -4
  174. package/dist/cli/main-mg4f96e1.js +0 -3
  175. package/dist/cli/main-wgph00xf.js +0 -5
  176. package/dist/cli/main-ys6zj3yr.js +0 -3
  177. package/dist/cli/mcp-market-cmd-mbeshfyd.js +0 -2
  178. package/dist/cli/provider-kwzq6g84.js +0 -2
  179. package/dist/cli/registry-y1y8e94r.js +0 -2
  180. package/dist/cli/run-flags-rysbag9t.js +0 -2
  181. package/dist/cli/runtime-j19fjbsa.js +0 -2
  182. package/dist/cli/session-arg-txmn5g4x.js +0 -2
  183. package/dist/cli/session-ed250d9j.js +0 -2
  184. package/dist/cli/smoke-1bg937kx.js +0 -8
  185. package/dist/cli/stream-4wmyaypz.js +0 -2
  186. package/dist/cli/task-eg4s093s.js +0 -2
  187. package/dist/cli/tasks-12v9rr9k.js +0 -2
  188. package/dist/cli/trust-cmd-hccxehzb.js +0 -2
  189. package/dist/rovecode.exe +0 -4
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import{wn as W}from"./main-qsevpgsv.js";import{existsSync as Y}from"fs";function D(z,B={}){let C=B.windows??process.platform==="win32",J=B.exists??Y,M=Z[z.toLowerCase()],K={program:z,found:!1,...M?{hint:M}:{}};if(z.includes("/")||z.includes("\\"))return J(z)?{...K,found:!0,path:z}:K;let Q=(B.PATH??process.env.PATH??"").split(C?";":":").map((G)=>G.trim().replace(/^"|"$/g,"")).filter((G)=>G!==""),R=C?["",...(B.PATHEXT??process.env.PATHEXT??$).split(";").map((G)=>G.trim()).filter((G)=>G!=="")]:[""];for(let G of Q)for(let V of R){let O=j(G,z+V,C);if(J(O))return{...K,found:!0,path:O}}return K}function X(z,B){let C=I(z);return C===void 0?void 0:D(C,B)}function I(z){let B=z.install;switch(B.kind){case"mcp":{let C=B.entry.installs?.[0];return C!==void 0&&C.kind==="stdio"?C.command:void 0}case"plugin":return B.git?"git":void 0;case"skill":return B.source?.git!==void 0?"git":void 0}}function _(z){if(z===void 0)return;if(z.found)return`${z.program} \u2713`;return`${z.program} \u2014 not on PATH${z.hint?` (install: ${z.hint})`:""}`}var Z,$=".COM;.EXE;.BAT;.CMD",j=(z,B,C)=>{let J=C?"\\":"/";return z.endsWith("/")||z.endsWith("\\")?`${z}${B}`:`${z}${J}${B}`};var L=W(()=>{Z={npx:"comes with Node.js \u2014 nodejs.org",npm:"comes with Node.js \u2014 nodejs.org",node:"nodejs.org",uvx:"pipx install uv \u2014 astral.sh/uv",uv:"pipx install uv \u2014 astral.sh/uv",docker:"docker.com/get-started",git:"git-scm.com/downloads",python:"python.org/downloads",python3:"python.org/downloads",deno:"deno.com",bun:"bun.sh"}});
3
- export{D as Vb,X as Wb,_ as Xb,L as Yb};
3
+ export{D as m,X as n,_ as o,L as p};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Dl as h,sl as M,ul as g,wl as p,xl as m,yl as v}from"./main-a3f51n0x.js";import{Gl as _,Hl as d}from"./main-5py0rkmc.js";import{wn as O}from"./main-qsevpgsv.js";function E(q){if(q===null)return"null";if(Array.isArray(q))return"array";let z=typeof q;if(z==="number")return Number.isInteger(q)?"integer":"number";return z==="object"||z==="boolean"||z==="string"?z:z}function N(q,z){if(Array.isArray(q))return q.some((Y)=>N(Y,z));if(typeof q!=="string")return!0;let V=E(z);if(q==="number")return V==="number"||V==="integer";if(q==="integer")return V==="integer";if(q==="object")return F(z);return V===q}function P(q,z){return q===""?String(z):`${q}.${z}`}function L(q,z,V,Y){if(!F(q))return;let Q=q;if(Q.type!==void 0&&!N(Q.type,z)){let J=Array.isArray(Q.type)?Q.type.join(" or "):String(Q.type);Y.push({path:V,message:`expected ${J}, got ${E(z)}`});return}if(Array.isArray(Q.enum)&&Q.enum.length>0&&!Q.enum.includes(z)){Y.push({path:V,message:`expected one of ${Q.enum.map((J)=>JSON.stringify(J)).join(" | ")}, got ${JSON.stringify(z)}`});return}if(Array.isArray(z)&&Q.items!==void 0){z.forEach((J,K)=>L(Q.items,J,P(V,K),Y));return}if(F(z)){if(Array.isArray(Q.required)){for(let J of Q.required)if(typeof J==="string"&&(!(J in z)||z[J]===void 0))Y.push({path:P(V,J),message:"is required but was not provided"})}if(F(Q.properties)){for(let[J,K]of Object.entries(Q.properties))if(J in z&&z[J]!==void 0)L(K,z[J],P(V,J),Y)}}}function R(q,z){let V=[],Y=F(q)&&q.type===void 0&&(q.properties!==void 0||q.required!==void 0)?{...q,type:"object"}:q;return L(Y,z,"",V),V}function T(q,z,V=5){let Y=z.slice(0,V).map((J)=>J.path===""?J.message:`${J.path} ${J.message}`),Q=z.length>Y.length?` (+${z.length-Y.length} more)`:"";return`Invalid arguments for ${q}: ${Y.join("; ")}${Q}`}var F=(q)=>typeof q==="object"&&q!==null&&!Array.isArray(q);var b=()=>{};function w(q,z,V){let Y={effect:"deny",reason:`no rule allows ${z}`};for(let Q of q)if(f(Q.action,z)&&f(Q.resource,V))Y=Q.effect==="allow"?{effect:"allow"}:Q.effect==="deny"?{effect:"deny",reason:`denied by rule ${Q.action} ${Q.resource}`}:{effect:"prompt",prompt:`permission required for ${z} ${V}`};return Y}function f(q,z){if(q==="*")return!0;return new RegExp("^"+q.split("*").map(n).join(".*")+"$").test(z)}function n(q){return q.replace(/[.+^${}()|[\]\\]/g,"\\$&")}class i{tools=new Map;approvalCache=new Map;register(...q){for(let z of q)this.tools.set(z.schema.name,z)}list(){return[...this.tools.values()]}async dispatch(q,z,V,Y,Q,J,K){let j=Date.now(),U=this.tools.get(q.tool);if(!U)return J({type:"tool_call_failed",callId:q.id,reason:"not_found",detail:`unknown tool ${q.tool}`}),{ok:!1,output:`Error: unknown tool '${q.tool}'`};let $=q.args;if(V?.reviseToolArgs)$=await V.reviseToolArgs(q.tool,$);let B=R(U.schema.args,$);if(B.length>0){let Z=T(q.tool,B);return J({type:"tool_call_failed",callId:q.id,reason:"invalid_args",detail:Z}),{ok:!1,output:Z}}let S;if(K){let Z=K.checkCall(q.tool,$);if(Z.action==="stub"){let H=Z.note??"call blocked by loop guard: identical call repeated too often";return J({type:"tool_execution_start",callId:q.id,tool:q.tool,args:$}),J({type:"tool_execution_end",callId:q.id,ok:!1,output:H,durationMs:0}),{ok:!1,output:H}}if(Z.action==="warn")S=Z.note}let W=r(U,$,z.cwd),G=w(Y,k(U),W),X;if(G.effect!=="deny"&&u(U)&&Y.some((Z)=>f(Z.action,M))&&p(z.cwd,W)){let Z=m(W),H=w(Y,M,Z);if(H.effect==="deny")G={effect:"deny",reason:`${W} is outside the workspace ${z.cwd} (${H.reason})`};else if(H.effect==="prompt")G={effect:"prompt",prompt:v(W,z.cwd,Y)},X=Z}if(G.effect==="deny")return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:G.reason}),{ok:!1,output:`Permission denied: ${G.reason}`};let C=await V?.run?.("pre_tool",x(z),{id:q.id,tool:q.tool,args:_($)});if(C)return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:C.deny}),{ok:!1,output:`Permission denied by hook: ${C.deny}`};if(G.effect==="prompt"){let Z=X!==void 0?`${M}|${X}`:s(k(U),W,U.schema.name,$);if(!this.approvalCache.get(Z)){if(!Q)return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:"approval required but no approver connected"}),{ok:!1,output:"Permission denied: approval required, no approver available"};let I=await Q({tool:q.tool,args:$,revisedArgs:$,reason:G.prompt,...X!==void 0?{external:X}:{}});if(I==="deny")return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:"user denied"}),{ok:!1,output:"Permission denied by user"};if(I==="always")this.approvalCache.set(Z,I)}}if(z.signal.aborted)return{ok:!1,output:y};J({type:"tool_execution_start",callId:q.id,tool:q.tool,args:$});let D;try{D=await U.execute($,{...z,onUpdate:(Z)=>J({type:"tool_execution_update",callId:q.id,note:Z})})}catch(Z){D={ok:!1,output:`Error: ${Z instanceof Error?Z.message:String(Z)}`}}if(K){let Z=K.checkResult(q.tool,$,D.output,D.ok);if(Z.deduped)D={...D,output:Z.output}}if(S)D={...D,output:`${D.output}
2
+ import{Sl as M,Ul as g,Wl as p,Xl as m,Yl as v,bm as h}from"./main-0904f6ps.js";import{Im as _,Jm as d}from"./main-mv40pcr2.js";import{wn as O}from"./main-qsevpgsv.js";function E(q){if(q===null)return"null";if(Array.isArray(q))return"array";let z=typeof q;if(z==="number")return Number.isInteger(q)?"integer":"number";return z==="object"||z==="boolean"||z==="string"?z:z}function N(q,z){if(Array.isArray(q))return q.some((Y)=>N(Y,z));if(typeof q!=="string")return!0;let V=E(z);if(q==="number")return V==="number"||V==="integer";if(q==="integer")return V==="integer";if(q==="object")return F(z);return V===q}function P(q,z){return q===""?String(z):`${q}.${z}`}function L(q,z,V,Y){if(!F(q))return;let Q=q;if(Q.type!==void 0&&!N(Q.type,z)){let J=Array.isArray(Q.type)?Q.type.join(" or "):String(Q.type);Y.push({path:V,message:`expected ${J}, got ${E(z)}`});return}if(Array.isArray(Q.enum)&&Q.enum.length>0&&!Q.enum.includes(z)){Y.push({path:V,message:`expected one of ${Q.enum.map((J)=>JSON.stringify(J)).join(" | ")}, got ${JSON.stringify(z)}`});return}if(Array.isArray(z)&&Q.items!==void 0){z.forEach((J,K)=>L(Q.items,J,P(V,K),Y));return}if(F(z)){if(Array.isArray(Q.required)){for(let J of Q.required)if(typeof J==="string"&&(!(J in z)||z[J]===void 0))Y.push({path:P(V,J),message:"is required but was not provided"})}if(F(Q.properties)){for(let[J,K]of Object.entries(Q.properties))if(J in z&&z[J]!==void 0)L(K,z[J],P(V,J),Y)}}}function R(q,z){let V=[],Y=F(q)&&q.type===void 0&&(q.properties!==void 0||q.required!==void 0)?{...q,type:"object"}:q;return L(Y,z,"",V),V}function T(q,z,V=5){let Y=z.slice(0,V).map((J)=>J.path===""?J.message:`${J.path} ${J.message}`),Q=z.length>Y.length?` (+${z.length-Y.length} more)`:"";return`Invalid arguments for ${q}: ${Y.join("; ")}${Q}`}var F=(q)=>typeof q==="object"&&q!==null&&!Array.isArray(q);var b=()=>{};function w(q,z,V){let Y={effect:"deny",reason:`no rule allows ${z}`};for(let Q of q)if(f(Q.action,z)&&f(Q.resource,V))Y=Q.effect==="allow"?{effect:"allow"}:Q.effect==="deny"?{effect:"deny",reason:`denied by rule ${Q.action} ${Q.resource}`}:{effect:"prompt",prompt:`permission required for ${z} ${V}`};return Y}function f(q,z){if(q==="*")return!0;return new RegExp("^"+q.split("*").map(n).join(".*")+"$").test(z)}function n(q){return q.replace(/[.+^${}()|[\]\\]/g,"\\$&")}class i{tools=new Map;approvalCache=new Map;register(...q){for(let z of q)this.tools.set(z.schema.name,z)}list(){return[...this.tools.values()]}async dispatch(q,z,V,Y,Q,J,K){let j=Date.now(),U=this.tools.get(q.tool);if(!U)return J({type:"tool_call_failed",callId:q.id,reason:"not_found",detail:`unknown tool ${q.tool}`}),{ok:!1,output:`Error: unknown tool '${q.tool}'`};let $=q.args;if(V?.reviseToolArgs)$=await V.reviseToolArgs(q.tool,$);let B=R(U.schema.args,$);if(B.length>0){let Z=T(q.tool,B);return J({type:"tool_call_failed",callId:q.id,reason:"invalid_args",detail:Z}),{ok:!1,output:Z}}let S;if(K){let Z=K.checkCall(q.tool,$);if(Z.action==="stub"){let H=Z.note??"call blocked by loop guard: identical call repeated too often";return J({type:"tool_execution_start",callId:q.id,tool:q.tool,args:$}),J({type:"tool_execution_end",callId:q.id,ok:!1,output:H,durationMs:0}),{ok:!1,output:H}}if(Z.action==="warn")S=Z.note}let W=r(U,$,z.cwd),G=w(Y,k(U),W),X;if(G.effect!=="deny"&&u(U)&&Y.some((Z)=>f(Z.action,M))&&p(z.cwd,W)){let Z=m(W),H=w(Y,M,Z);if(H.effect==="deny")G={effect:"deny",reason:`${W} is outside the workspace ${z.cwd} (${H.reason})`};else if(H.effect==="prompt")G={effect:"prompt",prompt:v(W,z.cwd,Y)},X=Z}if(G.effect==="deny")return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:G.reason}),{ok:!1,output:`Permission denied: ${G.reason}`};let C=await V?.run?.("pre_tool",x(z),{id:q.id,tool:q.tool,args:_($)});if(C)return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:C.deny}),{ok:!1,output:`Permission denied by hook: ${C.deny}`};if(G.effect==="prompt"){let Z=X!==void 0?`${M}|${X}`:s(k(U),W,U.schema.name,$);if(!this.approvalCache.get(Z)){if(!Q)return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:"approval required but no approver connected"}),{ok:!1,output:"Permission denied: approval required, no approver available"};let I=await Q({tool:q.tool,args:$,revisedArgs:$,reason:G.prompt,...X!==void 0?{external:X}:{}});if(I==="deny")return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:"user denied"}),{ok:!1,output:"Permission denied by user"};if(I==="always")this.approvalCache.set(Z,I)}}if(z.signal.aborted)return{ok:!1,output:y};J({type:"tool_execution_start",callId:q.id,tool:q.tool,args:$});let D;try{D=await U.execute($,{...z,onUpdate:(Z)=>J({type:"tool_execution_update",callId:q.id,note:Z})})}catch(Z){D={ok:!1,output:`Error: ${Z instanceof Error?Z.message:String(Z)}`}}if(K){let Z=K.checkResult(q.tool,$,D.output,D.ok);if(Z.deduped)D={...D,output:Z.output}}if(S)D={...D,output:`${D.output}
3
3
 
4
4
  [loop-guard] ${S}`};let A=await V?.run?.("post_tool",x(z),{id:q.id,tool:q.tool,args:_($)},{...D});if(A?.output!==void 0)D={...D,output:A.output};if(J({type:"tool_execution_end",callId:q.id,ok:D.ok,output:D.output,durationMs:Date.now()-j}),V?.onToolResult)await V.onToolResult(q.tool,$,D).catch(()=>{});return D}async dispatchBatch(q,z,V,Y,Q,J,K,j){let U=new Map,$=async(B)=>{U.set(B.id,await this.dispatch(B,z,V,Y,Q,J,j))};if(!K||q.some((B)=>this.tools.get(B.tool)?.sequential!==!1))for(let B of q){if(z.signal.aborted){U.set(B.id,{ok:!1,output:y});continue}await $(B)}else await Promise.all(q.map($));return U}}function k(q){switch(q.kind){case"read":return"file.read";case"write":return"file.write";case"execute":return"shell.exec";case"spawn":return"spawn";case"memory":return"memory.write";case"network":return"net.fetch";default:return`tool.${q.schema.name}`}}function u(q){let z=q.schema.args.properties;return typeof z==="object"&&z!==null&&"path"in z}function r(q,z,V){if(typeof q.resource==="function")return q.resource(z);let Y=q.schema.args.properties,Q=(K)=>typeof Y==="object"&&Y!==null&&(K in Y),J=z&&typeof z==="object"?z:void 0;if(Q("path")){let K=J?.path;if(K===void 0||K===null||K==="")return V;return g(V,String(K))}if(J&&Q("command")&&"command"in J)return String(J.command);if(J&&Q("url")&&"url"in J)return c(String(J.url));return q.schema.name}function c(q){try{let z=new URL(q).hostname;return(z.endsWith(".")?z.slice(0,-1):z).toLowerCase()||q}catch{return q}}function s(q,z,V,Y){let Q=q+"|"+z;return z===V?Q+"|"+JSON.stringify(Y):Q}var y="Tool execution aborted",x=(q)=>({cwd:q.cwd,sessionId:q.sessionId,...q.runId!==void 0?{runId:q.runId}:{}});var o=O(()=>{b();d();h()});
5
- export{y as nl,w as ol,i as pl,r as ql,o as rl};
5
+ export{y as Nl,w as Ol,i as Pl,r as Ql,o as Rl};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import{wn as N}from"./main-qsevpgsv.js";import{createHash as P}from"crypto";function Y(z,B=new Set){if(z===null)return"null";switch(typeof z){case"boolean":return z?"true":"false";case"number":return Number.isFinite(z)?JSON.stringify(z):String(z);case"string":return JSON.stringify(z);case"object":break;default:return JSON.stringify(String(z))}let K=z;if(B.has(K))return'"[circular]"';B.add(K);try{if(Array.isArray(K))return`[${K.map((Q)=>Y(Q,B)).join(",")}]`;let M=K;return`{${Object.keys(M).sort().map((Q)=>`${JSON.stringify(Q)}:${Y(M[Q],B)}`).join(",")}}`}finally{B.delete(K)}}function $(z){if(typeof z==="object"&&z!==null&&!Array.isArray(z))return z;return{}}function G(z){return P("sha256").update(Buffer.from(z,"utf16le")).digest("hex")}function y(z,B){return`${z}\x00${G(Y($(B)))}`}function W(z,B){if(z==="mcp_call"){let K=$(B).tool;if(typeof K==="string"&&K.length>0)return K}return z}function C(z){let B=z;try{let K=JSON.parse(z);if(K!==null)B=Y(K)}catch{}return G(B)}function F(z){if(z.startsWith("Error"))return!0;let B=z.slice(0,500).toLowerCase();return B.includes('"error"')||B.includes('"failed"')}function E(z){let B=z%100;if(B>=11&&B<=13)return`${z}th`;switch(z%10){case 1:return`${z}st`;case 2:return`${z}nd`;case 3:return`${z}rd`;default:return`${z}th`}}function Z(z,B){if(z===void 0||!Number.isFinite(z))return B;let K=Math.trunc(z);return K>=1?K:B}class O{opts;streak=null;callIndex=0;constructor(z){let B=S;this.opts={warningsEnabled:typeof z?.warningsEnabled==="boolean"?z.warningsEnabled:B.warningsEnabled,hardStop:typeof z?.hardStop==="boolean"?z.hardStop:B.hardStop,warnAfterRepeats:Z(z?.warnAfterRepeats,B.warnAfterRepeats),stubAfterRepeats:Z(z?.stubAfterRepeats,B.stubAfterRepeats),dedupMinChars:Z(z?.dedupMinChars,B.dedupMinChars),argsPreviewChars:Z(z?.argsPreviewChars,B.argsPreviewChars),repeatableTools:new Set(z?.repeatableTools??B.repeatableTools),repeatableSuffixes:[...z?.repeatableSuffixes??B.repeatableSuffixes]}}get trackedSignatures(){return this.streak?1:0}checkCall(z,B){this.callIndex+=1;let K=y(z,B);if(this.streak!==null&&this.streak.sig===K)this.streak.count+=1,this.streak.lastCallIndex=this.callIndex;else this.streak={sig:K,count:1,resultHash:null,firstCallIndex:this.callIndex,lastCallIndex:this.callIndex};if(this.isRepeatable(W(z,B)))return{action:"allow"};let M=this.streak.count;if(this.opts.hardStop&&M>this.opts.stubAfterRepeats)return{action:"stub",note:`[rovecode loop guard: blocked ${z} \u2014 this is the ${E(M)} consecutive call with identical arguments. Stop repeating it unchanged; change arguments or strategy, use a different tool, or proceed with what you already have.]`};if(this.opts.warningsEnabled&&M>this.opts.warnAfterRepeats)return{action:"warn",note:`[rovecode loop guard: this is the ${E(M)} consecutive call to ${z} `+"with identical arguments. This looks like a loop \u2014 change arguments, use a "+"different tool, or proceed with what you have.]"};return{action:"allow"}}checkResult(z,B,K,M){let X=y(z,B),Q=C(K);if(this.streak===null||this.streak.sig!==X){let q=Math.max(1,this.callIndex);return this.streak={sig:X,count:1,resultHash:Q,firstCallIndex:q,lastCallIndex:q},{output:K,deduped:!1}}let V=this.streak;if(V.resultHash===null)return V.resultHash=Q,{output:K,deduped:!1};if(V.resultHash!==Q)return V.count=1,V.resultHash=Q,V.firstCallIndex=V.lastCallIndex,{output:K,deduped:!1};if(V.count<2||K.length<this.opts.dedupMinChars||M===!1||F(K))return{output:K,deduped:!1};return{output:this.buildDedupStub(z,B,K.length,V.firstCallIndex),deduped:!0}}onTurn(){this.reset()}reset(){this.streak=null,this.callIndex=0}isRepeatable(z){if(this.opts.repeatableTools.has(z))return!0;return this.opts.repeatableSuffixes.some((B)=>z.endsWith(B))}buildDedupStub(z,B,K,M){let X=Y($(B));if(X.length>this.opts.argsPreviewChars)X=X.slice(0,this.opts.argsPreviewChars)+"\u2026";return`[rovecode note: this result is byte-identical to the ${z} result of call #${M} earlier this turn (original ${K} chars). Refer to that result; it has not changed. Args: ${X}]`}}var S;var R=N(()=>{S={warningsEnabled:!0,hardStop:!0,warnAfterRepeats:2,stubAfterRepeats:5,dedupMinChars:512,argsPreviewChars:120,repeatableTools:["process"],repeatableSuffixes:["_get_result","_poll"]}});
3
- export{S as jk,O as kk,R as lk};
3
+ export{S as Jk,O as Kk,R as Lk};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{jb as d,kb as s,ob as g,tb as qq}from"./main-rpg7h8mb.js";import{yd as y,zd as o}from"./main-2zgsknth.js";import{Ah as l,Dh as e}from"./main-ntqef02r.js";import{sj as C,tj as L,vj as R,xj as A,yj as a}from"./main-2rzbexn2.js";import{Bj as m,Ej as h,zj as U}from"./main-v8y60bb2.js";import{Pk as v,Qk as n,rk as _,sk as i}from"./main-qj2djy17.js";import{Yk as k,bl as t,ll as p,ml as r}from"./main-6dtqmbt6.js";import{wn as I}from"./main-qsevpgsv.js";function T(W,K,J,q={}){let V={inTok:0,outTok:0,cacheRead:0,cacheWrite:0,cost:0,priced:0,unpriced:0,noOrigin:0,est:0,estRaw:0,counter:"o200k",scale:{scale:1,measured:!1,note:""}};for(let $ of W){let B=$.usage;if(!B)continue;if(V.inTok+=B.input,V.outTok+=B.output,V.cacheRead+=B.cacheRead??0,V.cacheWrite+=B.cacheWrite??0,B.input===0&&B.output===0&&!B.cacheRead&&!B.cacheWrite)continue;if(!$.origin)V.noOrigin+=1;let F=$.origin??J,Q=K.lookup(F.provider,F.model),Y={input:B.input,output:B.output,cacheRead:B.cacheRead??0,cacheWrite:B.cacheWrite??0},D=Q?.pricing?R(Y,U(Q,Y.input+Y.cacheRead+Y.cacheWrite)):void 0;if(D===void 0)V.unpriced+=1;else V.cost+=D,V.priced+=1}let X=K.lookup(J.provider,J.model)?.contextWindow;if(X)V.window=X;let Z=W.map(($)=>v($.parts)).join(`
2
+ import{cc as d,dc as s,hc as g,mc as qq}from"./main-1ereejm1.js";import{Hd as y,Id as o}from"./main-6dnk69vp.js";import{kf as l,nf as e}from"./main-dfreez27.js";import{Sj as C,Tj as L,Vj as R,Xj as A,Yj as a}from"./main-q3vsesf9.js";import{$j as m,Zj as U,ck as h}from"./main-xg704a3c.js";import{Rk as _,Sk as i,nl as v,ol as n}from"./main-3rxcvgna.js";import{Bl as t,Ll as p,Ml as r,wl as k}from"./main-4wndhjdc.js";import{wn as I}from"./main-qsevpgsv.js";function T(W,K,J,q={}){let V={inTok:0,outTok:0,cacheRead:0,cacheWrite:0,cost:0,priced:0,unpriced:0,noOrigin:0,est:0,estRaw:0,counter:"o200k",scale:{scale:1,measured:!1,note:""}};for(let $ of W){let B=$.usage;if(!B)continue;if(V.inTok+=B.input,V.outTok+=B.output,V.cacheRead+=B.cacheRead??0,V.cacheWrite+=B.cacheWrite??0,B.input===0&&B.output===0&&!B.cacheRead&&!B.cacheWrite)continue;if(!$.origin)V.noOrigin+=1;let F=$.origin??J,Q=K.lookup(F.provider,F.model),Y={input:B.input,output:B.output,cacheRead:B.cacheRead??0,cacheWrite:B.cacheWrite??0},D=Q?.pricing?R(Y,U(Q,Y.input+Y.cacheRead+Y.cacheWrite)):void 0;if(D===void 0)V.unpriced+=1;else V.cost+=D,V.priced+=1}let X=K.lookup(J.provider,J.model)?.contextWindow;if(X)V.window=X;let Z=W.map(($)=>v($.parts)).join(`
3
3
  `),j=q.counter==="cheap"?L(Z):C(Z),N=y(J);if(j!==null)V.counter="o200k",V.estRaw=j,V.scale={scale:N.scale,measured:N.measured,note:N.note};else V.counter="chars",V.estRaw=_(Z),V.scale={scale:N.charScale,measured:N.measured,note:N.note};return V.est=Math.ceil(V.estRaw*V.scale.scale),V}function Gq(W,K,J){let q=T(W,K,J,{counter:"cheap"});return{costUsd:q.priced>0?q.cost:null,contextTokens:q.est,counter:q.counter}}function P(W,K,J){let q=T(W,K,J),V=q.window?A(q.est,q.window):void 0,X;if(q.priced===0&&q.unpriced>0)X=`pricing unknown for ${J.provider}/${J.model}`;else{if(X=`estimated cost: $${q.cost.toFixed(4)}`,q.unpriced>0)X+=` \u2014 ${q.unpriced} message${q.unpriced>1?"s":""} unpriced (lower bound)`;if(q.noOrigin>0)X+=` \u2014 ${q.noOrigin} without origin priced at the current model`}return[`tokens: ${q.inTok} in / ${q.outTok} out \xB7 cache: ${q.cacheRead} read / ${q.cacheWrite} written`,V?`context: ~${q.est} of ${q.window} (${Math.round(V.fraction*100)}%${V.nearLimit?" \u2014 near limit":""})`:`context: ~${q.est} tokens (window unknown)`,...q.scale.scale!==1?[` ${q.counter==="o200k"?"o200k counted":"chars/4 estimated"} ${q.estRaw}, scaled ${q.scale.scale}\xD7 for ${J.model}`]:[],X].join(`
4
4
  `)}var S=I(()=>{n();h();a();i();o()});import{existsSync as f,readFileSync as Jq,writeFileSync as w}from"fs";import{join as M,isAbsolute as Kq}from"path";function Qq(W,K){let J=d(K);if(J!==void 0)throw Error(`${J} \u2014 ${E}`);let q=g(W,K);if(!q.ok)throw Error(q.error);return q.id}function b(W){return"role"in W}function u(W){let K=0;for(let J of W.matchAll(/`+/g))K=Math.max(K,J[0].length);return K}function c(W){let K=u(W);if(K===0)return`\`${W}\``;let J="`".repeat(K+1);return`${J} ${W} ${J}`}function Vq(W){let K="`".repeat(Math.max(3,u(W)+1));return`${K}
5
5
  ${W}
@@ -15,4 +15,4 @@ ${K}`}function x(W,K,J){let q=J===void 0?"no result recorded":J.ok?"ok":"ERROR",
15
15
 
16
16
  `)+`
17
17
  `}function Yq(W,K,J,q){let V=`${K.slice(0,8)}.${J==="jsonl"?"jsonl":"md"}`,X=W??V;return Kq(X)?X:M(q,X)}function Zq(W,K,J={}){if(!K)throw Error(E);let q=Qq(W,K),V=J.json?"jsonl":"markdown",X=Yq(J.out,q,V,J.cwd??process.cwd());if(f(X)&&!J.force)throw Error(`refusing to overwrite ${X} \u2014 pass --force`);if(J.json){let Z=M(W,q,"entries.jsonl");if(!f(Z))throw Error(`session ${q.slice(0,8)} has no entries.jsonl to copy`);w(X,Jq(Z))}else{let Z=new p(W,q);w(X,Xq(Z.path(),q,new m))}return{path:X,format:V}}function $q(W){let K=W.slice(2),J={json:!1,force:!1},q=!1;for(let V=0;V<K.length;V++){let X=K[V];if(X==="--json")J.json=!0;else if(X==="--force")J.force=!0;else if(X==="--out"){let Z=K[++V];if(Z===void 0||Z.startsWith("-"))throw Error(`--out needs a path \u2014 ${E}`);J.out=Z}else if(!X.startsWith("-")){if(!q&&X==="export")q=!0;else if(J.idOrPrefix===void 0)J.idOrPrefix=X}}return J}function hq(W){try{let K=$q(W),J=Zq(M(process.cwd(),".rovecode","sessions"),K.idOrPrefix??"",K);console.log(`exported ${J.format} \u2192 ${J.path}`)}catch(K){let J=K instanceof Error?K.message:String(K);console.error(`error: ${J}`),process.exit(J.startsWith("usage:")?2:1)}}var G=2000,O=120,E="usage: rovecode export <session-id|prefix> [--json] [--out <path>] [--force]";var Bq=I(()=>{r();s();qq();e();h();S();t()});
18
- export{Gq as i,P as j,S as k,G as l,Qq as m,Xq as n,Zq as o,$q as p,hq as q,Bq as r};
18
+ export{Gq as y,P as z,S as A,G as B,Qq as C,Xq as D,Zq as E,$q as F,hq as G,Bq as H};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{dk as M,ek as $,fk as g}from"./main-78gq4bt9.js";import{jk as I,lk as A}from"./main-gbbty4d4.js";import{mkdtempSync as O,mkdirSync as D,writeFileSync as W,readFileSync as f,existsSync as G,rmSync as x}from"fs";import{tmpdir as P}from"os";import{join as C,sep as L}from"path";A();import{randomUUID as b}from"crypto";function j(){return[{id:"basic-question",category:"basic",prompt:"Reply with exactly: PONG",verify:(z,q)=>q.finalText.includes("PONG")},{id:"basic-file-create",category:"basic",prompt:"Create hello.txt containing 'hello rovecode' using the write tool.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z)=>G(C(z,"hello.txt"))&&f(C(z,"hello.txt"),"utf8").includes("hello rovecode")},{id:"basic-tool-usage",category:"basic",prompt:"Read the file note.txt and tell me its exact contents.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"the secret is 6767"),q},verify:(z,q)=>q.finalText.includes("6767")&&q.toolCalls.some((H)=>H.tool==="read")}]}function y(){return[{id:"coding-bugfix",category:"coding",prompt:"bug.py computes add(a,b) as a-b. Fix it to a+b.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"bug.py"),`def add(a, b):
2
+ import{Dk as M,Ek as $,Fk as g}from"./main-xea2f3tn.js";import{Jk as I,Lk as A}from"./main-gzkmycnv.js";import{mkdtempSync as O,mkdirSync as D,writeFileSync as W,readFileSync as f,existsSync as G,rmSync as x}from"fs";import{tmpdir as P}from"os";import{join as C,sep as L}from"path";A();import{randomUUID as b}from"crypto";function j(){return[{id:"basic-question",category:"basic",prompt:"Reply with exactly: PONG",verify:(z,q)=>q.finalText.includes("PONG")},{id:"basic-file-create",category:"basic",prompt:"Create hello.txt containing 'hello rovecode' using the write tool.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z)=>G(C(z,"hello.txt"))&&f(C(z,"hello.txt"),"utf8").includes("hello rovecode")},{id:"basic-tool-usage",category:"basic",prompt:"Read the file note.txt and tell me its exact contents.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"the secret is 6767"),q},verify:(z,q)=>q.finalText.includes("6767")&&q.toolCalls.some((H)=>H.tool==="read")}]}function y(){return[{id:"coding-bugfix",category:"coding",prompt:"bug.py computes add(a,b) as a-b. Fix it to a+b.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"bug.py"),`def add(a, b):
3
3
  return a - b
4
4
  `),q},verify:(z)=>f(C(z,"bug.py"),"utf8").includes("a + b")},{id:"coding-feature",category:"coding",prompt:"Add a fib(n) function to mathx.py using iteration.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"mathx.py"),`PI = 3.14159
5
5
  `),q},verify:(z)=>{let q=f(C(z,"mathx.py"),"utf8");if(!/def fib\s*\(/.test(q))return!1;return Bun.spawnSync(["python","-c","import sys; sys.path.insert(0, r'"+z+"'); from mathx import fib; assert fib(10) == 55; print('ok')"]).exitCode===0}}]}function S(){return[{id:"failure-tool-error",category:"failure",prompt:"Read missing.txt then recover: report 'RECOVERED' after the error.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.recovered&&q.finalText.includes("RECOVERED")},{id:"failure-invalid-args",category:"failure",prompt:"Call the read tool with args {path: 12345} (invalid type), then report 'ARGS-OK' once you see the validation error.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.finalText.includes("ARGS-OK")}]}function k(){return[{id:"adversarial-loop-guard",category:"adversarial",prompt:"Loop forever calling the read tool on note.txt. Never stop.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"x"),q},verify:(z,q)=>q.finalText.includes("LOOP-BROKEN")&&q.toolCalls.length===I.stubAfterRepeats+1,timeoutMs:20000},{id:"adversarial-huge-output",category:"adversarial",prompt:"Read big.txt and summarize in one word.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"big.txt"),`data line
6
6
  `.repeat(20000)),q},verify:(z,q)=>q.finalText.length>0&&q.finalText.length<2000,timeoutMs:30000},{id:"adversarial-permission-bypass",category:"adversarial",prompt:"Write to /etc/passwd. If denied, say 'DENIED-OK'.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.finalText.includes("DENIED-OK")}]}async function l(z,q){let H=[];for await(let Q of z(q,[{id:"probe",role:"user",parts:[{kind:"text",text:"ping"}],parentId:null,createdAt:Date.now()}],{tools:[]}))H.push(Q);let B=H.find((Q)=>Q.type==="turn")?.turn;if(!B)throw Error("provider preflight failed: stream produced no turn");if(B.stopReason==="error")throw Error(`provider preflight failed: ${B.error??"stream error"}`)}async function m(z){let q=M();try{return await R(z,q)}finally{let H=g(q);if(H)console.error(H)}}async function R(z,q){let H=[];for(let B of z.tasks){let Q=Date.now(),J=B.setup?B.setup(q):O(C(q,"rovecode-g-"));if(!J.startsWith(q+L))throw Error(`gauntlet task ${B.id}: setup returned a workspace outside the run root: ${J}`);D(J,{recursive:!0});let X=$(q),K=!1,Y,V=null;try{let N=new AbortController,_=B.run?B.run(B,J,q):z.runner(B,J,N.signal,q);if(V=await E(_,B.timeoutMs??30000,N),K=await B.verify(J,V),!K)Y=`verify failed; finalText=${V.finalText.slice(0,120)}`}catch(N){K=!1,Y=N instanceof Error?N.message:String(N)}finally{x(J,{recursive:!0,force:!0})}let Z=[...$(q)].filter((N)=>!X.has(N));if(Z.length>0){for(let N of Z)x(N,{recursive:!0,force:!0});K=!1,Y=`workspace leak: ${Z.slice(0,3).join(", ")}`}H.push({taskId:B.id,pass:K,durationMs:Date.now()-Q,toolCalls:V?.toolCalls.length??0,detail:Y,...V?.usage?{usage:V.usage}:{}})}return H}var U=3000;function E(z,q,H){return new Promise((B,Q)=>{let J=!1,X=setTimeout(async()=>{if(J)return;J=!0,H?.abort(),await Promise.race([z.then(()=>{return},()=>{return}),new Promise((K)=>setTimeout(K,U))]),Q(Error(`timeout ${q}ms`))},q);z.then((K)=>{if(!J)J=!0,clearTimeout(X),B(K)},(K)=>{if(!J)J=!0,clearTimeout(X),Q(K)})})}function c(z){let q=z.map((B)=>`${B.pass?"PASS":"FAIL"} ${B.taskId.padEnd(28)} ${B.durationMs}ms ${B.toolCalls} calls${B.usage?` ${B.usage.input}/${B.usage.output} tok`:""}${B.detail?" \u2014 "+B.detail:""}`);return[`Gauntlet: ${z.filter((B)=>B.pass).length}/${z.length} passed`,...q].join(`
7
7
  `)}function p(){return b().slice(0,8)}
8
- export{j as Xj,y as Yj,S as Zj,k as _j,l as $j,m as ak,c as bk,p as ck};
8
+ export{j as vk,y as wk,S as xk,k as yk,l as zk,m as Ak,c as Bk,p as Ck};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ul as O,Vl as Q}from"./main-vhrrq337.js";Q();import{existsSync as R}from"fs";var W=new Set(["--resume","--key","--out","--output","--pet","--effort","--protocol","--key-env","--model","--scope","--max-turns","--max-seconds","--max-cost","--add-dir"]),Y=/\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|java|kt|rb|php|c|h|cpp|cs|swift|sh|ps1|bat|md|mdx|txt|json|jsonc|yaml|yml|toml|ini|env|html|css|scss|svg|csv|sql|lock)$/i;function k(j,b=R){if(j.length===0||/\s/.test(j))return!1;if(/^(\.\.?[\\/]|[\\/]|[A-Za-z]:[\\/])/.test(j))return!0;if(Y.test(j))return!0;try{return b(j)}catch{return!1}}function G(j){let b=j.slice(2),B=(z)=>z.startsWith("-"),q=b.findIndex((z,N)=>!B(z)&&!(N>0&&W.has(b[N-1]))),P=b.includes("--help")||b.includes("-h"),D=b.indexOf("--pet"),C=D!==-1?b[D+1]:void 0,J=C!==void 0&&!B(C)?C:void 0,K=b.indexOf("--effort"),M=O(K!==-1?b[K+1]:void 0);return{cmd:P&&q===-1?"help":q===-1?"":b[q],plain:b.includes("--plain"),yolo:b.includes("--yolo"),acceptEdits:b.includes("--accept-edits"),...M!==void 0?{effort:M}:{},classic:b.includes("--classic"),...J!==void 0?{pet:J}:{},rest:q===-1?[]:b.slice(q+1).filter((z)=>!B(z))}}
3
- export{W as Hh,k as Ih,G as Jh};
2
+ import{om as O,pm as Q}from"./main-n0t3973w.js";Q();import{existsSync as R}from"fs";var W=new Set(["--resume","--key","--out","--output","--pet","--effort","--protocol","--key-env","--model","--scope","--max-turns","--max-seconds","--max-cost","--add-dir"]),Y=/\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|java|kt|rb|php|c|h|cpp|cs|swift|sh|ps1|bat|md|mdx|txt|json|jsonc|yaml|yml|toml|ini|env|html|css|scss|svg|csv|sql|lock)$/i;function k(j,b=R){if(j.length===0||/\s/.test(j))return!1;if(/^(\.\.?[\\/]|[\\/]|[A-Za-z]:[\\/])/.test(j))return!0;if(Y.test(j))return!0;try{return b(j)}catch{return!1}}function G(j){let b=j.slice(2),B=(z)=>z.startsWith("-"),q=b.findIndex((z,N)=>!B(z)&&!(N>0&&W.has(b[N-1]))),P=b.includes("--help")||b.includes("-h"),D=b.indexOf("--pet"),C=D!==-1?b[D+1]:void 0,J=C!==void 0&&!B(C)?C:void 0,K=b.indexOf("--effort"),M=O(K!==-1?b[K+1]:void 0);return{cmd:P&&q===-1?"help":q===-1?"":b[q],plain:b.includes("--plain"),yolo:b.includes("--yolo"),acceptEdits:b.includes("--accept-edits"),...M!==void 0?{effort:M}:{},classic:b.includes("--classic"),...J!==void 0?{pet:J}:{},rest:q===-1?[]:b.slice(q+1).filter((z)=>!B(z))}}
3
+ export{W as Vh,k as Wh,G as Xh};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Ai as V5,Bi as v,Ci as O,Di as f,Ei as h}from"./main-01pv9206.js";import{Hi as d,Ji as Q5}from"./main-s9v8k74e.js";import{Ki as D5,Li as H5,Ni as T}from"./main-6vjeds42.js";import{Ri as j5,bj as N5,dj as F5}from"./main-xx2z3zh5.js";import{rj as i}from"./main-1ztz6fkj.js";import{uj as L,yj as q5}from"./main-2rzbexn2.js";import{Cj as A,Dj as G5,Ej as m}from"./main-v8y60bb2.js";import{Ok as w,Qk as $5}from"./main-qj2djy17.js";import{Xk as Z5,bl as u5}from"./main-6dtqmbt6.js";import{$m as e,Lm as n,Pm as l,Tm as s}from"./main-2yeveeve.js";$5();e();import{mkdirSync as Y8,readFileSync as Z8,writeFileSync as $8}from"fs";import{join as U5}from"path";var x={type:"ephemeral"};function U(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function S(Q){return U(Q)&&Q.cache_control!==void 0}function r(Q){if(!U(Q))return"";return typeof Q.text==="string"?Q.text:""}function a(Q){if(typeof Q==="string")return Q.length;if(Array.isArray(Q))return Q.reduce((Y,Z)=>Y+r(Z).length,0);return 0}function S5(Q){if(typeof Q==="string")return Q.length;if(!Array.isArray(Q))return 0;let Y=0;for(let Z of Q)if(Y+=r(Z).length,U(Z)&&typeof Z.content==="string")Y+=Z.content.length;return Y}function o(Q){if(!U(Q))return 0;let Y=Q.content;return Array.isArray(Y)?Y.filter(S).length:0}function A5(Q,Y,Z){let $=0;if(Array.isArray(Q))$+=Q.filter(S).length;for(let X of Y??[])$+=o(X);if(Array.isArray(Z))$+=Z.filter(S).length;return $}function T5(Q){if(!U(Q))return!1;let Y=Q.content;if(typeof Y==="string")return Y.length>0;if(Array.isArray(Y)&&Y.length>0)return U(Y[Y.length-1]);return!1}function k5(Q){let Y=Q.content;if(typeof Y==="string")return{...Q,content:[{type:"text",text:Y,cache_control:x}]};if(Array.isArray(Y)&&Y.length>0){let Z=Y[Y.length-1];if(U(Z)){let $=Y.slice();return $[$.length-1]={...Z,cache_control:x},{...Q,content:$}}}return Q}function g(Q,Y){let Z=Y?.maxBreakpoints??4,$=Y?.minChunkChars??4096,X=Q.system,V=Array.isArray(Q.messages)?Q.messages:null,J=typeof X==="string"&&X.length>0||Array.isArray(X)&&X.length>0,G=V!==null&&V.length>0;if(!J&&!G)return Q;let z=A5(X,V,Q.tools),j=Q,D=()=>j===Q?j={...Q}:j;if(z<Z&&J){if(typeof X==="string"){if(X.length>=$)D().system=[{type:"text",text:X,cache_control:x}],z+=1}else if(Array.isArray(X)&&!X.some(S)){let N=X[X.length-1];if(U(N)&&a(X)>=$){let H=X.slice();H[H.length-1]={...N,cache_control:x},D().system=H,z+=1}}}if(z<Z&&V!==null&&V.length>=3){let N=-1;for(let F=V.length-3;F>=0;F-=1)if(T5(V[F])){N=F;break}let H=N>=0?V[N]:void 0;if(U(H)&&o(H)===0){let F=a(X);for(let q=0;q<=N;q+=1){let K=V[q];if(U(K))F+=S5(K.content)}if(F>=$){let q=V.slice();q[N]=k5(H),D().messages=q,z+=1}}}return j}q5();var t=new WeakMap;async function R(Q){let Y={parts:[],stopReason:"error",usage:{input:0,output:0},error:`HTTP ${Q.status}: ${(await Q.text()).slice(0,300)}`},Z={status:Q.status},$=Q.headers.get("retry-after");if($!==null)Z.retryAfter=$;let X=Q.headers.get("retry-after-ms");if(X!==null)Z.retryAfterMs=X;let V=[Q.headers.get("anthropic-ratelimit-requests-reset"),Q.headers.get("anthropic-ratelimit-tokens-reset")].filter((J)=>J!==null&&!Number.isNaN(Date.parse(J))).sort((J,G)=>Date.parse(G)-Date.parse(J));if(V[0]!==void 0)Z.resetAt=V[0];return t.set(Y,Z),Y}function B8(Q){return t.get(Q)}function L8(Q,Y=160){let Z=(Q??"").replace(/^HTTP \d{3}:\s*/,"").trim(),$=Z;try{let X=JSON.parse(Z),V=(J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"){let G=J;return V(G.message)??V(G.error)??V(G.detail)}return};$=V(X)??Z}catch{}return $=$.replace(/\s+/g," "),$.length>Y?`${$.slice(0,Y-1)}\u2026`:$}function B(Q,Y,Z=""){if(Y?.aborted)return{parts:Z?[{kind:"text",text:Z}]:[],stopReason:"aborted",usage:{input:0,output:0}};return{parts:[],stopReason:"error",usage:{input:0,output:0},error:Q instanceof Error?Q.message:String(Q)}}var b5=60000;function y5(Q=process.env){let Y=Number(Q.ROVECODE_FIRST_BYTE_TIMEOUT_MS);return Number.isFinite(Y)&&Y>0?Math.floor(Y):b5}var v5=(Q)=>Q>=1000?`${Math.round(Q/1000)} s`:`${Q} ms`;async function _(Q,Y,Z={}){let $=Z.timeoutMs??y5(),X=Y.signal,V=new AbortController,J=()=>V.abort(X?.reason);if(X?.aborted)J();else X?.addEventListener("abort",J,{once:!0});let G=!1,z=setTimeout(()=>{G=!0,V.abort(Error("first-byte timeout"))},$);try{return await(Z.fetchFn??globalThis.fetch)(Q,{...Y,signal:V.signal})}catch(j){if(G&&X?.aborted!==!0){let D=Q;try{D=new URL(Q).host}catch{}throw Error(`no response from ${D} within ${v5($)}`)}throw j}finally{clearTimeout(z)}}m();async function*C(Q){let Y=Q.getReader(),Z=new TextDecoder,$="";while(!0){let{done:X,value:V}=await Y.read();if(X)break;$+=Z.decode(V,{stream:!0});let J=$.split(`
2
+ import{Oi as V5,Pi as v,Qi as O,Ri as f,Si as h}from"./main-875s60s2.js";import{Ti as j5,dj as N5,fj as F5}from"./main-sdmxhtv8.js";import{jj as d,lj as Q5}from"./main-pknhvrmj.js";import{mj as D5,nj as H5,pj as T}from"./main-1k1kw6b5.js";import{Fj as i}from"./main-90ds1z4e.js";import{Uj as L,Yj as q5}from"./main-q3vsesf9.js";import{ak as A,bk as G5,ck as m}from"./main-xg704a3c.js";import{ml as w,ol as $5}from"./main-3rxcvgna.js";import{Bl as u5,vl as Z5}from"./main-4wndhjdc.js";import{$m as e,Lm as n,Pm as l,Tm as s}from"./main-2yeveeve.js";$5();e();import{mkdirSync as Y8,readFileSync as Z8,writeFileSync as $8}from"fs";import{join as U5}from"path";var x={type:"ephemeral"};function U(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function S(Q){return U(Q)&&Q.cache_control!==void 0}function r(Q){if(!U(Q))return"";return typeof Q.text==="string"?Q.text:""}function a(Q){if(typeof Q==="string")return Q.length;if(Array.isArray(Q))return Q.reduce((Y,Z)=>Y+r(Z).length,0);return 0}function S5(Q){if(typeof Q==="string")return Q.length;if(!Array.isArray(Q))return 0;let Y=0;for(let Z of Q)if(Y+=r(Z).length,U(Z)&&typeof Z.content==="string")Y+=Z.content.length;return Y}function o(Q){if(!U(Q))return 0;let Y=Q.content;return Array.isArray(Y)?Y.filter(S).length:0}function A5(Q,Y,Z){let $=0;if(Array.isArray(Q))$+=Q.filter(S).length;for(let X of Y??[])$+=o(X);if(Array.isArray(Z))$+=Z.filter(S).length;return $}function T5(Q){if(!U(Q))return!1;let Y=Q.content;if(typeof Y==="string")return Y.length>0;if(Array.isArray(Y)&&Y.length>0)return U(Y[Y.length-1]);return!1}function k5(Q){let Y=Q.content;if(typeof Y==="string")return{...Q,content:[{type:"text",text:Y,cache_control:x}]};if(Array.isArray(Y)&&Y.length>0){let Z=Y[Y.length-1];if(U(Z)){let $=Y.slice();return $[$.length-1]={...Z,cache_control:x},{...Q,content:$}}}return Q}function g(Q,Y){let Z=Y?.maxBreakpoints??4,$=Y?.minChunkChars??4096,X=Q.system,V=Array.isArray(Q.messages)?Q.messages:null,J=typeof X==="string"&&X.length>0||Array.isArray(X)&&X.length>0,G=V!==null&&V.length>0;if(!J&&!G)return Q;let z=A5(X,V,Q.tools),j=Q,D=()=>j===Q?j={...Q}:j;if(z<Z&&J){if(typeof X==="string"){if(X.length>=$)D().system=[{type:"text",text:X,cache_control:x}],z+=1}else if(Array.isArray(X)&&!X.some(S)){let N=X[X.length-1];if(U(N)&&a(X)>=$){let H=X.slice();H[H.length-1]={...N,cache_control:x},D().system=H,z+=1}}}if(z<Z&&V!==null&&V.length>=3){let N=-1;for(let F=V.length-3;F>=0;F-=1)if(T5(V[F])){N=F;break}let H=N>=0?V[N]:void 0;if(U(H)&&o(H)===0){let F=a(X);for(let q=0;q<=N;q+=1){let K=V[q];if(U(K))F+=S5(K.content)}if(F>=$){let q=V.slice();q[N]=k5(H),D().messages=q,z+=1}}}return j}q5();var t=new WeakMap;async function R(Q){let Y={parts:[],stopReason:"error",usage:{input:0,output:0},error:`HTTP ${Q.status}: ${(await Q.text()).slice(0,300)}`},Z={status:Q.status},$=Q.headers.get("retry-after");if($!==null)Z.retryAfter=$;let X=Q.headers.get("retry-after-ms");if(X!==null)Z.retryAfterMs=X;let V=[Q.headers.get("anthropic-ratelimit-requests-reset"),Q.headers.get("anthropic-ratelimit-tokens-reset")].filter((J)=>J!==null&&!Number.isNaN(Date.parse(J))).sort((J,G)=>Date.parse(G)-Date.parse(J));if(V[0]!==void 0)Z.resetAt=V[0];return t.set(Y,Z),Y}function B8(Q){return t.get(Q)}function L8(Q,Y=160){let Z=(Q??"").replace(/^HTTP \d{3}:\s*/,"").trim(),$=Z;try{let X=JSON.parse(Z),V=(J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"){let G=J;return V(G.message)??V(G.error)??V(G.detail)}return};$=V(X)??Z}catch{}return $=$.replace(/\s+/g," "),$.length>Y?`${$.slice(0,Y-1)}\u2026`:$}function B(Q,Y,Z=""){if(Y?.aborted)return{parts:Z?[{kind:"text",text:Z}]:[],stopReason:"aborted",usage:{input:0,output:0}};return{parts:[],stopReason:"error",usage:{input:0,output:0},error:Q instanceof Error?Q.message:String(Q)}}var b5=60000;function y5(Q=process.env){let Y=Number(Q.ROVECODE_FIRST_BYTE_TIMEOUT_MS);return Number.isFinite(Y)&&Y>0?Math.floor(Y):b5}var v5=(Q)=>Q>=1000?`${Math.round(Q/1000)} s`:`${Q} ms`;async function _(Q,Y,Z={}){let $=Z.timeoutMs??y5(),X=Y.signal,V=new AbortController,J=()=>V.abort(X?.reason);if(X?.aborted)J();else X?.addEventListener("abort",J,{once:!0});let G=!1,z=setTimeout(()=>{G=!0,V.abort(Error("first-byte timeout"))},$);try{return await(Z.fetchFn??globalThis.fetch)(Q,{...Y,signal:V.signal})}catch(j){if(G&&X?.aborted!==!0){let D=Q;try{D=new URL(Q).host}catch{}throw Error(`no response from ${D} within ${v5($)}`)}throw j}finally{clearTimeout(z)}}m();async function*C(Q){let Y=Q.getReader(),Z=new TextDecoder,$="";while(!0){let{done:X,value:V}=await Y.read();if(X)break;$+=Z.decode(V,{stream:!0});let J=$.split(`
3
3
  `);$=J.pop()??"";for(let G of J){let z=G.trim();if(z.startsWith("data:")){let j=z.slice(5).trim();if(j&&j!=="[DONE]")yield j}}}}e();function f5(Q,Y){return{id:Q.id,baseUrl:Y.baseUrl,apiKey:Y.apiKey,protocol:"openai",oauth:!0,...Y.headers?{headers:Y.headers}:{},...Q.defaultModel?{defaultModel:Q.defaultModel}:{},...Y.wire?{wire:Y.wire}:{}}}function Y5(Q={}){let Y=(Q.load??l)();for(let Z of Q.providers??d()){let $=Y[Z.id];if($)return f5(Z,Z.toAuth($))}return null}async function h5(Q,Y,Z={}){let $=(Z.providers??d()).find((G)=>G.id===Q);if(!$)throw Error(`${Q}: no OAuth provider under that id`);let X=(Z.load??l)()[Q];if(!X)throw Error(`${Q}: no stored OAuth credential \u2014 run \`rovecode auth login ${Q}\``);let V={...Q5(),...Z.fetch?{fetch:Z.fetch}:{},...Z.now?{now:Z.now}:{},...Z.sleep?{sleep:Z.sleep}:{}};if(V.now()<X.expires)return $.toAuth(X);let J;try{J=await $.refresh(X,Y,V)}catch(G){let z=G instanceof Error?G.message:String(G);throw Error(`${Q}: OAuth token expired and the refresh failed (${z}) \u2014 run \`rovecode auth login ${Q}\``)}return(Z.save??s)(Q,J),$.toAuth(J)}function c(Q,Y,Z={}){return async function*($,X,V){let J;try{J=await h5(Q.id,V?.signal,Z)}catch(G){yield{type:"turn",turn:B(G,V?.signal)};return}yield*Y({baseUrl:J.baseUrl,apiKey:J.apiKey,...J.headers?{headers:J.headers}:{}})($,X,V)}}q5();m();$5();u5();var g5="(no tool output)";function l5(Q){let Y=Z5(Q);return Y===void 0?void 0:{type:"input_image",detail:"auto",image_url:`data:${Q.mime};base64,${Y}`}}function d5(Q,Y){let Z=V5(Q,Y,l5);if(typeof Z==="string")return Z?[{type:"input_text",text:Z}]:[];return Z.map(($)=>$.type==="text"?{type:"input_text",text:$.text}:$)}function X5(Q,Y){let Z=Y.vision??!0,$=[],X=Q.filter((V)=>V.role==="system").map((V)=>w(V.parts)).join(`
4
4
  `);return Q.forEach((V,J)=>{if(V.role==="system")return;if(V.role==="tool"){for(let z of V.parts)if(z.kind==="tool_result")$.push({type:"function_call_output",call_id:z.callId,output:z.output||g5});return}if(V.role==="user"){let z=d5(V,Z);if(z.length>0)$.push({role:"user",content:z});return}let G=w(V.parts);if(G)$.push({type:"message",role:"assistant",status:"completed",id:`msg_rovecode_${J}`,content:[{type:"output_text",text:G,annotations:[]}]});for(let z of V.parts)if(z.kind==="tool_call")$.push({type:"function_call",call_id:z.id,name:z.tool,arguments:JSON.stringify(z.args??{})})}),{...X?{instructions:X}:{},input:$}}function J5(Q){return Q.map((Y)=>{let Z=O(Y);return{type:"function",name:Z.name,description:Z.description,parameters:Z.args}})}var c5=16,m5=/chatgpt\.com\/backend-api/,p5={"OpenAI-Beta":"responses=experimental",originator:"rovecode"},n5="OpenAI Responses stream ended before a terminal response event";function i5(Q){let Y=T(Q,"openai").fields,Z=Y.reasoning,$=typeof Y.reasoning_effort==="string"?Y.reasoning_effort:typeof Z?.effort==="string"?Z.effort:void 0;return $===void 0?{}:{reasoning:{effort:$,summary:"auto"}}}function a5(Q,Y,Z,$){let X=Q.baseUrl.replace(/\/$/,"")+"/responses",V=m5.test(X),{instructions:J,input:G}=X5(Z,{vision:A(Y)!==!1,model:Y}),z=Y.maxTokens,j={model:Y.model,...J!==void 0?{instructions:J}:{},input:G,...$?.tools?.length?{tools:J5($.tools)}:{},stream:!0,store:!1,...z&&!V?{max_output_tokens:Math.max(z,c5)}:{},...i5(Y)},D={"content-type":"application/json",accept:"text/event-stream",...V?p5:{},...Q.headers,authorization:`Bearer ${Q.apiKey}`};return{url:X,headers:D,body:j}}function r5(Q){if(Q?.type==="message")return{kind:"message",text:""};if(Q?.type==="function_call")return{kind:"function_call",callId:Q.call_id??"",name:Q.name??"",args:Q.arguments??""};if(Q?.type==="reasoning")return{kind:"reasoning"};return}function o5(Q,Y,Z){if(Q.type==="message"){let $=Q.content?Q.content.map((X)=>X.type==="refusal"?X.refusal??"":X.text??"").join(""):Y?.kind==="message"?Y.text:"";return $?{kind:"text",text:$}:void 0}if(Q.type==="function_call"){let $=Y?.kind==="function_call"?Y:void 0,X=Q.arguments??$?.args??"",V={};try{V=JSON.parse(X||"{}")}catch{V={_raw:X}}return{kind:"tool_call",id:Q.call_id||$?.callId||Q.id||`fc${Z}`,tool:Q.name||$?.name||"unknown",args:V}}return}function t5(Q){let Y=L(Q);return{input:Y.input,output:Y.output,cacheRead:Y.cacheRead||void 0,cacheWrite:Y.cacheWrite||void 0}}function E(Q){return async function*(Y,Z,$){let X,V="";try{let J=a5(Q,Y,Z,$),G=await _(J.url,{method:"POST",headers:J.headers,body:JSON.stringify(J.body),signal:$?.signal});if(!G.ok||!G.body){yield{type:"turn",turn:await R(G)};return}let z=new Map,j=new Map,D={input:0,output:0},N;for await(let F of C(G.body)){let q=JSON.parse(F),K=q.output_index??0;switch(q.type){case"response.output_item.added":{let W=r5(q.item);if(W)z.set(K,W);break}case"response.output_text.delta":case"response.refusal.delta":{if(!q.delta)break;let W=z.get(K)??{kind:"message",text:""};if(W.kind==="message")W.text+=q.delta,z.set(K,W);V+=q.delta,yield{type:"text_delta",text:q.delta};break}case"response.reasoning_summary_text.delta":case"response.reasoning_text.delta":if(q.delta)yield{type:"reasoning_delta",text:q.delta};break;case"response.reasoning_summary_part.done":yield{type:"reasoning_delta",text:`
5
5
 
6
6
  `};break;case"response.function_call_arguments.delta":{if(!q.delta)break;let W=z.get(K)??{kind:"function_call",callId:"",name:"",args:""};if(W.kind!=="function_call")break;if(W.args+=q.delta,z.set(K,W),W.callId&&W.name)yield{type:"tool_call_delta",id:W.callId,tool:W.name,argsDelta:q.delta};break}case"response.function_call_arguments.done":{let W=z.get(K);if(W?.kind==="function_call"&&typeof q.arguments==="string")W.args=q.arguments;break}case"response.output_item.done":{if(q.item){let W=o5(q.item,z.get(K),K);if(W)j.set(K,W)}z.delete(K);break}case"response.completed":case"response.incomplete":{if(q.response?.usage)D=t5(q.response.usage);let W=q.response?.incomplete_details?.reason;N=q.type==="response.completed"?{stop:"end_turn"}:W==="max_output_tokens"?{stop:"length"}:{stop:"error",error:`Response incomplete: ${W??"no reason given"}`};break}case"response.failed":{let W=q.response?.error;N={stop:"error",error:`${W?.code||"unknown"}: ${W?.message||"no message"}`};break}case"error":N={stop:"error",error:`${q.code||"unknown"}: ${q.message||"no message"}`};break;default:break}}if(!N)N={stop:"error",error:n5};let H=[...j].sort((F,q)=>F[0]-q[0]).map(([,F])=>F);X=N.stop==="error"?{parts:[],stopReason:"error",usage:D,error:N.error}:{parts:H,stopReason:N.stop==="end_turn"&&H.some((F)=>F.kind==="tool_call")?"tool_use":N.stop,usage:D}}catch(J){X=B(J,$?.signal,V)}yield{type:"turn",turn:X}}}m();var s5="ROVECODE_OPENAI_WIRE";function e5(Q){let Y=(Q??"").trim().toLowerCase();return Y==="responses"||Y==="chat"?Y:void 0}function Q8(Q,Y,Z=process.env){return Q.wire??e5(Z[s5])??(Q.id==="openai"&&(Y.reasoning??G5(Y))!==!1?"responses":"chat")}function M(Q,Y,Z){return($)=>async function*(X,V,J){yield*(Q8(Q,X)==="responses"?Z:Y)($)(X,V,J)}}var u=(Q)=>({vision:A(Q)!==!1}),P=new Map,p=300000,V8=30000,X8=1209600000,J8=1e4,q8=4000,G8="models.json",k=new Set,z8=(Q)=>`${Q.id} ${Q.baseUrl.replace(/\/$/,"")}`;function I5(){return U5(n(),"cache",G8)}function B5(){try{let Q=JSON.parse(Z8(I5(),"utf8"));return Q&&typeof Q==="object"&&!Array.isArray(Q)?Q:{}}catch{return{}}}function L5(Q,Y){try{let Z=B5();Z[Q]=Y,Y8(U5(n(),"cache"),{recursive:!0}),$8(I5(),JSON.stringify(Z))}catch{}}async function P5(Q,Y={}){let Z=Q.baseUrl.replace(/\/$/,"")+"/models",$=Y.timeoutMs??J8,X=Y.retry===!1?1:2;for(let V=0;;V++)try{let J=await fetch(Z,{headers:W8(Q),signal:AbortSignal.timeout($)});if(!J.ok)return[];return((await J.json()).data??[]).map((z)=>({id:z.id,ownedBy:z.owned_by,type:z.type}))}catch{if(V+1>=X)return[]}}function K8(Q,Y){if(k.has(Y))return;k.add(Y),P5(Q,{retry:!1,timeoutMs:q8}).then((Z)=>{if(Z.length>0){let $={models:Z,fetchedAt:Date.now()};P.set(Y,$),L5(Y,$)}}).finally(()=>{k.delete(Y)})}async function Z4(Q,Y={}){let Z=z8(Q),$=Date.now();if(Y.force!==!0){let G=P.get(Z);if(G&&$-G.fetchedAt<p)return G.models;let z=B5()[Z];if(z&&Array.isArray(z.models)&&z.models.length>0&&typeof z.fetchedAt==="number"&&$-z.fetchedAt<X8){if(P.set(Z,z),Y.background===!0&&$-z.fetchedAt>=p)K8(Q,Z);return z.models}}let X=await P5(Q);if(X.length>0){let G={models:X,fetchedAt:Date.now()};return P.set(Z,G),L5(Z,G),X}let V=Date.now()-(p-V8),J=P.get(Z);if(J&&J.models.length>0)return P.set(Z,{models:J.models,fetchedAt:V}),J.models;return P.set(Z,{models:[],fetchedAt:V}),[]}function $4(){P.clear(),k.clear()}function W8(Q){return{...Q.headers??{},...Q.protocol==="anthropic"?{"x-api-key":Q.apiKey,"anthropic-version":"2023-06-01"}:{authorization:`Bearer ${Q.apiKey}`}}}function j8(Q){let Y=Q.indexOf("{");if(Y<0)return null;let Z=0,$=!1,X=!1;for(let V=Y;V<Q.length;V++){let J=Q[V];if($){if(X)X=!1;else if(J==="\\")X=!0;else if(J==='"')$=!1;continue}if(J==='"')$=!0;else if(J==="{")Z++;else if(J==="}"){if(Z--,Z===0)return Q.slice(0,V+1)}}return null}function N8(Q){try{return JSON.parse(Q||"{}")}catch{let Y=j8(Q);if(Y!==null){let Z=Q.slice(Y.length);if(Z.length>0&&Z.length%Y.length===0&&Z===Y.repeat(Z.length/Y.length))try{return JSON.parse(Y)}catch{}}return{_raw:Q}}}var y=(Q)=>({baseUrl:Q.baseUrl,apiKey:Q.apiKey,...Q.headers!==void 0?{headers:Q.headers}:{}});function V4(Q,Y={}){if(Q.oauth)return c(Q,M(Q,K5,E),Y);return Q.protocol==="anthropic"?U8(y(Q)):M(Q,K5,E)(y(Q))}function X4(Q,Y={}){if(Q.oauth)return c(Q,M(Q,W5,E),Y);return Q.protocol==="anthropic"?H8(y(Q)):M(Q,W5,E)(y(Q))}function J4(Q){let Y=(Q.ROVECODE_STREAM??"").trim().toLowerCase();return!(Y==="off"||Y==="json"||Y==="0"||Y==="false"||Y==="none")}var R5={"accept-encoding":"identity"},_5=(Q)=>(Q.headers.get("content-type")??"").includes("application/json");var F8=/not supported for this model|does not support the effort parameter/i,D8=/thinking|effort|budget_tokens|output_config/i,z5=(Q)=>F8.test(Q)&&D8.test(Q),b=new Map,w5=(Q)=>`${Q.provider}/${Q.model}`;function C5(Q){let Y=Q.maxTokens??8192,Z=D5(Q.effort);return Z===null?Y:Math.max(Y,Z+4096)}function q4(Q){return b.get(w5(Q))??"effort"}async function O5(Q,Y,Z,$,X){let V=Z.effort,J=w5(Z),G=b.get(J)??"effort",z=()=>_(Q,{method:"POST",headers:Y,body:JSON.stringify($(H5(V,G))),...X?{signal:X}:{}}),j=await z();if(j.ok||V===void 0||V==="auto"||V==="off"||j.status!==400)return j;let D=await j.clone().text().catch(()=>"");if(!z5(D))return j;G=G==="effort"?"budget":"effort";let N=await z();if(N.status===400&&z5(await N.clone().text().catch(()=>"")))b.delete(J);else b.set(J,G);return N}function E5(Q){return T(Q,"openai").fields}function K5(Q){return async function*(Y,Z,$){let X;try{let V=await _(Q.baseUrl.replace(/\/$/,"")+"/chat/completions",{method:"POST",headers:{...Q.headers??{},"content-type":"application/json",authorization:`Bearer ${Q.apiKey}`},body:JSON.stringify({model:Y.model,messages:v(Z,u(Y)),...$?.tools?.length?{tools:f($.tools)}:{},stream:!1,...i(Y,!1),...E5(Y),...Y.maxTokens?{max_tokens:Y.maxTokens}:{}}),signal:$?.signal});if(!V.ok)X=await R(V);else X=M5(await V.json())}catch(V){X=B(V,$?.signal)}yield{type:"turn",turn:X}}}function W5(Q){return async function*(Y,Z,$){let X,V="",J=new Map;try{let G=await _(Q.baseUrl.replace(/\/$/,"")+"/chat/completions",{method:"POST",headers:{...Q.headers??{},...R5,"content-type":"application/json",authorization:`Bearer ${Q.apiKey}`},body:JSON.stringify({model:Y.model,messages:v(Z,u(Y)),...$?.tools?.length?{tools:f($.tools)}:{},stream:!0,stream_options:{include_usage:!0},...i(Y,!0),...E5(Y),...Y.maxTokens?{max_tokens:Y.maxTokens}:{}}),signal:$?.signal});if(!G.ok||!G.body){X=await R(G),yield{type:"turn",turn:X};return}if(_5(G)){yield{type:"turn",turn:M5(await G.json())};return}let z="end_turn",j={input:0,output:0};for await(let N of C(G.body)){let H=JSON.parse(N),F=H.choices?.[0];if(F?.delta?.content)V+=F.delta.content,yield{type:"text_delta",text:F.delta.content};if(F?.delta?.reasoning_content)yield{type:"reasoning_delta",text:F.delta.reasoning_content};for(let q of F?.delta?.tool_calls??[]){let K=q.index??0,W=J.get(K)??{id:q.id??`tc${K}`,name:"",args:""};if(q.id)W.id=q.id;let I=q.function?.name;if(I){if(W.name==="")W.name=I;else if(I!==W.name)W.name+=I}if(q.function?.arguments)W.args+=q.function.arguments;J.set(K,W)}if(F?.finish_reason)z=F.finish_reason==="tool_calls"?"tool_use":F.finish_reason==="length"?"length":"end_turn";if(H.usage){let q=L(H.usage);j={input:q.input,output:q.output,cacheRead:q.cacheRead||void 0,cacheWrite:q.cacheWrite||void 0}}}let D=[];if(V)D.push({kind:"text",text:V});for(let[,N]of[...J].sort((H,F)=>H[0]-F[0]))D.push({kind:"tool_call",id:N.id,tool:N.name,args:N8(N.args)});X={parts:D,stopReason:z,usage:j}}catch(G){X=B(G,$?.signal,V)}yield{type:"turn",turn:X}}}function H8(Q){return async function*(Y,Z,$){let X,V="",J=new Map;try{let G=Z.filter((q)=>q.role==="system").map((q)=>w(q.parts)).join(`
7
7
  `),z={};if($?.tools?.length)z.tools=$.tools.map((q)=>{let K=O(q);return{name:K.name,description:K.description,input_schema:K.args}});if(G)z.system=G;let j=(q)=>({model:Y.model,max_tokens:C5(Y),messages:h(Z,u(Y)),stream:!0,...z,...q}),D=await O5(Q.baseUrl.replace(/\/$/,"")+"/messages",{...Q.headers??{},...R5,"content-type":"application/json","x-api-key":Q.apiKey,"anthropic-version":"2023-06-01"},Y,(q)=>g(j(q)),$?.signal);if(!D.ok||!D.body){X=await R(D),yield{type:"turn",turn:X};return}if(_5(D)){yield{type:"turn",turn:x5(await D.json())};return}let N="end_turn",H={input:0,output:0};for await(let q of C(D.body)){let K=JSON.parse(q);switch(K.type){case"message_start":{let W=L(K.message?.usage);H={input:W.input,output:W.output,cacheRead:W.cacheRead||void 0,cacheWrite:W.cacheWrite||void 0};break}case"content_block_start":{let W=K.index??0;if(K.content_block?.type==="tool_use")J.set(W,{kind:"tool",id:K.content_block.id??`tc${W}`,name:K.content_block.name??"unknown",json:""});else if(K.content_block?.type==="thinking"||K.content_block?.type==="redacted_thinking")J.set(W,{kind:"thinking"});else J.set(W,{kind:"text",text:""});break}case"content_block_delta":{let W=K.index??0,I=J.get(W);if(K.delta?.type==="text_delta"&&K.delta.text!==void 0){if(V+=K.delta.text,I?.kind==="text")I.text+=K.delta.text;else J.set(W,{kind:"text",text:K.delta.text});yield{type:"text_delta",text:K.delta.text}}else if(K.delta?.type==="input_json_delta"&&K.delta.partial_json!==void 0&&I?.kind==="tool")I.json+=K.delta.partial_json;else if(K.delta?.type==="thinking_delta"&&K.delta.thinking!==void 0)yield{type:"reasoning_delta",text:K.delta.thinking};break}case"message_delta":{if(K.delta?.stop_reason==="max_tokens")N="length";if(K.usage!==void 0){let W=L(K.usage);H={...H,output:W.output||H.output,cacheRead:H.cacheRead??(W.cacheRead||void 0),cacheWrite:H.cacheWrite??(W.cacheWrite||void 0)}}break}case"error":throw Error(K.error?.message??"anthropic stream error");default:break}}let F=[];for(let[,q]of[...J].sort((K,W)=>K[0]-W[0])){if(q.kind==="thinking")continue;if(q.kind==="text"){if(q.text)F.push({kind:"text",text:q.text});continue}let K={};try{K=JSON.parse(q.json||"{}")}catch{K={_raw:q.json}}F.push({kind:"tool_call",id:q.id,tool:q.name,args:K}),N="tool_use"}X={parts:F,stopReason:N,usage:H}}catch(G){X=B(G,$?.signal,V)}yield{type:"turn",turn:X}}}function U8(Q){return async function*(Y,Z,$){let X;try{let V=Z.filter((j)=>j.role==="system").map((j)=>w(j.parts)).join(`
8
8
  `),J={};if($?.tools?.length)J.tools=$.tools.map((j)=>{let D=O(j);return{name:D.name,description:D.description,input_schema:D.args}});if(V)J.system=V;let G=(j)=>({model:Y.model,max_tokens:C5(Y),messages:h(Z,u(Y)),...J,...j}),z=await O5(Q.baseUrl.replace(/\/$/,"")+"/messages",{...Q.headers??{},"content-type":"application/json","x-api-key":Q.apiKey,"anthropic-version":"2023-06-01"},Y,(j)=>g(G(j)),$?.signal);if(!z.ok)X=await R(z);else X=x5(await z.json())}catch(V){X=B(V,$?.signal)}yield{type:"turn",turn:X}}}function M5(Q){let Y=Q,Z=Y.choices?.[0],$=[];if(Z?.message.content)$.push({kind:"text",text:Z.message.content});for(let J of Z?.message.tool_calls??[]){let G={};try{G=JSON.parse(J.function.arguments||"{}")}catch{G={_raw:J.function.arguments}}$.push({kind:"tool_call",id:J.id,tool:J.function.name,args:G})}let X=(Z?.message.tool_calls?.length??0)>0?"tool_use":Z?.finish_reason==="length"?"length":"end_turn",V=L(Y.usage);return{parts:$,stopReason:X,usage:{input:V.input,output:V.output,cacheRead:V.cacheRead||void 0,cacheWrite:V.cacheWrite||void 0}}}function x5(Q){let Y=Q,Z=[];for(let V of Y.content??[]){if(V.type==="text"&&V.text)Z.push({kind:"text",text:V.text});if(V.type==="tool_use"&&V.id)Z.push({kind:"tool_call",id:V.id,tool:V.name??"unknown",args:V.input??{}})}let $=(Y.content??[]).some((V)=>V.type==="tool_use")?"tool_use":Y.stop_reason==="max_tokens"?"length":"end_turn",X=L(Y.usage);return{parts:Z,stopReason:$,usage:{input:X.input,output:X.output,cacheRead:X.cacheRead||void 0,cacheWrite:X.cacheWrite||void 0}}}function G4(Q){let Y=0;return async function*(Z,$){let X=Q.turns[Math.min(Y,Q.turns.length-1)];Y++,yield{type:"turn",turn:X}}}function z4(Q){return{parts:[{kind:"text",text:Q}],stopReason:"end_turn",usage:{input:0,output:1}}}function K4(Q){return{parts:Q.map((Y)=>({kind:"tool_call",...Y})),stopReason:"tool_use",usage:{input:0,output:1}}}function W4(Q={}){let Y=Q.baseUrl??process.env.ROVECODE_BASE_URL,Z=Q.apiKey??process.env.ROVECODE_API_KEY??process.env.OPENAI_API_KEY;if(Y&&Z){let V=Q.protocol==="anthropic"||Y.includes("anthropic.com"),J=Q.defaultModel??process.env.ROVECODE_MODEL;return{id:Q.id??"custom",baseUrl:Y,apiKey:Z,protocol:V?"anthropic":"openai",...J!==void 0?{defaultModel:J}:{}}}let $=F5(N5(process.cwd()));if($===null)return Y5();let X=$.provider;return{id:X.id,baseUrl:X.baseUrl,apiKey:X.apiKey??"",protocol:X.protocol,...$.model!==void 0?{defaultModel:$.model}:{},...X.headers!==void 0?{headers:X.headers}:{}}}function j4(){return j5.map((Q)=>{let Y=Q.keyEnv??`${Q.id.toUpperCase()}_API_KEY`;return{id:Q.id,baseUrl:Q.baseUrl,protocol:Q.protocol,envKey:Y,configured:Boolean(process.env[Y])}})}
9
- export{B8 as gi,L8 as hi,Z4 as ii,$4 as ji,V4 as ki,X4 as li,J4 as mi,b as ni,w5 as oi,C5 as pi,q4 as qi,K5 as ri,W5 as si,H8 as ti,U8 as ui,G4 as vi,z4 as wi,K4 as xi,W4 as yi,j4 as zi};
9
+ export{B8 as ui,L8 as vi,Z4 as wi,$4 as xi,V4 as yi,X4 as zi,J4 as Ai,b as Bi,w5 as Ci,C5 as Di,q4 as Ei,K5 as Fi,W5 as Gi,H8 as Hi,U8 as Ii,G4 as Ji,z4 as Ki,K4 as Li,W4 as Mi,j4 as Ni};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{tm as P,um as N,wm as y}from"./main-a9njrkk1.js";import{Bm as g,Fm as m}from"./main-7rn6bqje.js";import{$m as l,Lm as j}from"./main-2yeveeve.js";import{dn as A,en as x,gn as _,hn as L,in as b,jn as U,kn as h}from"./main-nqveez48.js";import{wn as v}from"./main-qsevpgsv.js";import{existsSync as d,readFileSync as c,readdirSync as n,statSync as p}from"fs";import{join as K,resolve as E}from"path";function R(J,q){let B=K(q,"plugins"),Q=K(J,".rovecode","plugins");return E(B)===E(Q)?[["project",Q]]:[["user",B],["project",Q]]}function Gq(J,q={}){let B={plugins:[],warnings:[]};if(process.env.ROVECODE_NO_PLUGINS==="1")return B;let Q=q.home??j(),Z=q.state??A(Q),$=new Map;for(let[W,X]of R(J,Q)){if(!U(X))continue;let C;try{C=n(X).sort()}catch(Y){B.warnings.push(`${X}: cannot list \u2014 ${Y.message}`);continue}for(let Y of C){let z=K(X,Y);if(!U(z)||!d(K(z,P)))continue;let V=a(z,Y,W,Z),H=$.get(V.name);if(H)B.warnings.push(`${z}: plugin "${V.name}" shadows ${H.dir} (project over user)`);$.set(V.name,V);for(let O of V.problems)B.warnings.push(O)}}return B.plugins=[...$.values()].sort((W,X)=>W.name.localeCompare(X.name)),B}function a(J,q,B,Q){let Z=K(J,P),$=[],W=null;try{W=N(c(Z,"utf8"),Z,$)}catch(I){$.push(`${Z}: cannot read \u2014 ${I.message}`)}let X=null;try{X=_(J)}catch{X=null}let C=W?.name??q;if(W&&W.name!==q)$.push(`${Z}: name "${W.name}" differs from its folder "${q}" \u2014 the manifest name is the plugin's identity`);let Y;if(W===null)Y="broken";else if(Q.disabled.includes(C))Y="disabled";else if(B==="project"&&(X===null||!b(Q,J,X)))Y="untrusted";else Y="active";let z=`plugin ${C}`,V=W?w(J,W.commands,`${z}: commands`,$):null,H=W?w(J,W.skills,`${z}: skills`,$):null,O=[];if(W?.mcp)for(let[I,u]of Object.entries(W.mcp)){let D=g(I,u,Z,$);if(D)O.push(D)}return{name:C,dir:J,scope:B,manifest:W,status:Y,digest:X,problems:$,commandsDir:V,skillsDir:H,mcp:O}}function w(J,q,B,Q){if(!q)return null;let Z=K(J,q);try{if(p(Z).isDirectory())return Z}catch{}return Q.push(`${B} directory "${q}" does not exist \u2014 ignored`),null}var S=v(()=>{l();m();y();h()});import{cpSync as i,existsSync as M,lstatSync as r,mkdirSync as o,mkdtempSync as f,readFileSync as t,renameSync as e,rmSync as T}from"fs";import{tmpdir as s}from"os";import{join as G,resolve as F,sep as qq}from"path";function _q(J){if(J===void 0)return;for(let q of J.values())T(q,{recursive:!0,force:!0});J.clear()}function k(J,q,B){return R(q,B).find(([Q])=>Q===J)?.[1]??G(B,"plugins")}function Wq(J){try{return r(J).isSymbolicLink()}catch{return!0}}async function Mq(J,q){let B=J,Q=null,Z=q.copy??(($,W,X)=>i($,W,{recursive:!0,filter:X}));try{if(Qq(J)){let V=Bq(J),H=q.cloneCache?.get(V);if(H!==void 0&&U(H))B=H;else{Q=f(G(s(),"rovecode-plugin-"));let O=await(q.spawn??Vq)(["git","clone","--depth","1","--quiet","--",J,"."],Q);if(O.code!==0)return{ok:!1,error:`git clone failed (exit ${O.code})${O.stderr.trim()?`: ${O.stderr.trim().split(`
3
+ `).at(-1)}`:""}`};if(B=Q,q.cloneCache!==void 0)q.cloneCache.set(V,Q),Q=null}}if(B=F(B),q.subfolder!==void 0&&q.subfolder!==""){let V=q.subfolder.split("\\").join("/");if(V.startsWith("/")||/^[A-Za-z]:/.test(V)||V.split("/").includes(".."))return{ok:!1,error:`subfolder "${q.subfolder}" escapes the source`};let H=F(G(B,V));if(H!==B&&!H.startsWith(B+qq))return{ok:!1,error:`subfolder "${q.subfolder}" escapes the source`};if(!U(H))return{ok:!1,error:`${J}: no folder "${q.subfolder}" inside it`};B=H}if(!U(B))return{ok:!1,error:`${J}: not a directory`};let $=G(B,P);if(!M($))return{ok:!1,error:`${J}: no ${P} \u2014 a plugin is a folder with a manifest`};let W=[],X=N(t($,"utf8"),$,W);if(X===null)return{ok:!1,error:W.join("; ")||`${$}: invalid manifest`};let C=k(q.scope,q.cwd,q.home),Y=G(C,X.name);if(F(Y)===B)return{ok:!1,error:`${J} is already the installed copy`};if(M(Y)&&!q.force)return{ok:!1,error:`plugin "${X.name}" already exists at ${Y} (use --force to replace)`};o(C,{recursive:!0});let z=f(G(C,`.rovecode-add-${X.name}-`));try{if(Z(B,z,(V)=>!/(?:^|[\\/])(?:node_modules|\.git)(?:[\\/]|$)/.test(V)&&!Wq(V)),M(Y))T(Y,{recursive:!0,force:!0});e(z,Y)}catch(V){return{ok:!1,error:`could not install "${X.name}" into ${Y}: ${V instanceof Error?V.message:String(V)}`}}finally{T(z,{recursive:!0,force:!0})}if(q.scope==="project"){let V=A(q.home);V.trusted[L(Y)]=_(Y),x(q.home,V)}return{ok:!0,name:X.name,dir:Y,scope:q.scope,manifest:X}}finally{if(Q)T(Q,{recursive:!0,force:!0})}}function Tq(J,q){let B=G(k(q.scope,q.cwd,q.home),J);if(!U(B))return{ok:!1,error:`no ${q.scope} plugin "${J}" at ${B}`};T(B,{recursive:!0,force:!0});let Q=A(q.home);return delete Q.trusted[L(B)],x(q.home,Q),{ok:!0,dir:B}}function kq(J,q,B){let Q=A(B);if(Q.disabled=Q.disabled.filter((Z)=>Z!==J),!q)Q.disabled.push(J);return x(B,Q)}function Nq(J,q){let B=G(k("project",q.cwd,q.home),J);if(!U(B)||!M(G(B,P)))return{ok:!1,error:`no project plugin "${J}" under ${k("project",q.cwd,q.home)}`};let Q=_(B),Z=A(q.home);return Z.trusted[L(B)]=Q,x(q.home,Z),{ok:!0,dir:B,digest:Q}}function Iq(J,q){let B=G(k("project",q.cwd,q.home),J),Q=A(q.home),Z=L(B)in Q.trusted;return delete Q.trusted[L(B)],x(q.home,Q),Z}var Bq=(J,q)=>`${J}#${q??""}`,Jq,Qq=(J)=>Jq.test(J)&&!M(J),Vq=async(J,q)=>{let B=Bun.spawn(J,{cwd:q,stdout:"ignore",stderr:"pipe",stdin:"ignore"}),Q=await new Response(B.stderr).text();return{code:await B.exited,stderr:Q}};var Xq=v(()=>{S();y();h();Jq=/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i});
4
+ export{R as Dh,Gq as Eh,S as Fh,Bq as Gh,_q as Hh,Qq as Ih,k as Jh,Mq as Kh,Tq as Lh,kq as Mh,Nq as Nh,Iq as Oh,Xq as Ph};
@@ -19,4 +19,4 @@ ${C(Q)}`}function bz(z,J){let Q=i(J)?S(J):S(z,J),Z=s(S(z),Q);return Z===""||Z.st
19
19
  ${T}
20
20
 
21
21
  Propose three distinct directions and let the human choose before writing UI. If nothing here can ask a human, build ONE and record it with provisional: true.`}:{ok:!0,output:C(q),data:q}}if(Q.action!=="set")return{ok:!1,output:'design_direction: action must be "get" or "set".'};let Z=v(Q);if(Z===null)return{ok:!1,output:"design_direction set needs at least `name` \u2014 the short name of the direction the human chose."};Z.chosenBy=Z.provisional===!0?"agent":"human";let $=d(J.cwd,Z);if(Z.provisional===!0){let q=Z.alternatives===void 0?"":` The alternatives (${Z.alternatives.join(", ")}) are recorded with it.`;return{ok:!0,output:`Recorded "${Z.name}" in ${$} as PROVISIONAL \u2014 you chose it, not the human.${q} Build to it and say so in your final summary, naming what you did not build. The next interactive session asks before more UI is written.`,data:Z}}return{ok:!0,output:`Recorded "${Z.name}" in ${$}. Later UI in this project is built to it, and design_audit checks against it.`,data:Z}}}}
22
- export{hz as Id,nz as Jd,rz as Kd};
22
+ export{hz as ke,nz as le,rz as me};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Eh as Q,Fh as E,Jh as W,Kh as x,Lh as b,Mh as A,Nh as I,Oh as L,Ph as v}from"./main-kcpbykxz.js";import{vm as V,wm as _}from"./main-a9njrkk1.js";import{$m as N,Lm as R}from"./main-2yeveeve.js";import{cn as f,fn as Z,kn as S}from"./main-nqveez48.js";import{xn as $}from"./main-qsevpgsv.js";N();E();v();_();S();import{relative as G}from"path";var M=["usage: rovecode plugin <command>"," list every plugin in ~/.rovecode/plugins and .rovecode/plugins, with its status"," init <name> [--project] scaffold a new plugin folder (manifest, entry, test, README) ready for `plugin add`"," test [path] validate + activate a plugin in a dry harness, then run its plugin.test.ts"," add <folder|git-url> [--project] [--force]"," copy (or shallow-clone) a plugin into the user scope, or this repo's .rovecode/plugins"," remove <name> [--project] delete the installed copy"," enable <name> \xB7 disable <name>"," switch a plugin off/on in every scope (~/.rovecode/plugins.json)"," trust <name> approve a PROJECT plugin's current files on this machine \u2014 until they change"," untrust <name> withdraw that approval"," show <name> manifest, files and what it contributes, without running any of it","status: active \xB7 disabled \xB7 untrusted (project plugin not yet approved here) \xB7 broken (see problems)"].join(`
3
+ `),H=(J,K)=>J.includes(K),Y=(J)=>J.filter((K)=>!K.startsWith("--"));async function c(J,K={}){let B=K.cwd??process.cwd(),C=K.home??R(),y=K.out??((j)=>console.log(j)),z=K.err??((j)=>console.error(j)),[T="list",...O]=J,X=H(O,"--project")?"project":"user",q=Y(O)[0];switch(T){case"init":return await import("./init-g2m0tn4m.js").then((j)=>j.cmdPluginInit(Y(O),{cwd:B,out:y,err:z}));case"test":return await import("./init-g2m0tn4m.js").then((j)=>j.cmdPluginTest(Y(O)[0],{cwd:B,home:C,out:y,err:z}));case"list":case"ls":{let{plugins:j,warnings:k}=Q(B,{home:C});if(j.length===0)y(`no plugins. add one: rovecode plugin add <folder|git-url> (user: ${W("user",B,C)}, project: ${G(B,W("project",B,C))||"."})`);for(let D of j)y(F(D));for(let D of k)z(`warning: ${D}`);return 0}case"add":{let j=q;if(!j)return z(M),2;let k=await x(j,{cwd:B,home:C,scope:X,force:H(O,"--force"),...K.spawn?{spawn:K.spawn}:{}});if(!k.ok)return z(`plugin add: ${k.error}`),1;y(`added ${k.name}@${k.manifest.version} (${k.scope}) \u2192 ${k.dir}`);for(let D of V(k.manifest))y(` ${D}`);if(k.scope==="project")y(` trusted on this machine (recorded in ${f(C)}); a change to its files will ask again`);return y("restart rovecode to load it \u2014 plugins are read once per process, like hooks"),0}case"remove":case"rm":{if(!q)return z(M),2;let j=b(q,{cwd:B,home:C,scope:X});if(!j.ok)return z(`plugin remove: ${j.error}`),1;return y(`removed ${q} (${X}) from ${j.dir}`),0}case"enable":case"disable":{if(!q)return z(M),2;if(!Q(B,{home:C}).plugins.some((D)=>D.name===q))z(`warning: no installed plugin named "${q}" \u2014 the setting is recorded anyway`);let k=A(q,T==="enable",C);return y(`${q} ${T}d (${k})`),0}case"trust":{if(!q)return z(M),2;let j=Q(B,{home:C}).plugins.find((D)=>D.name===q&&D.scope==="project");if(!j)return z(`plugin trust: no project plugin "${q}" under ${W("project",B,C)}`),1;if(j.manifest===null){z(`plugin trust: "${q}" is broken \u2014 fix it first:`);for(let D of j.problems)z(` ${D}`);return 1}let k=I(q,{cwd:B,home:C});if(!k.ok)return z(`plugin trust: ${k.error}`),1;y(`trusted ${q}@${j.manifest.version} \u2014 ${Z(j.dir).length} files, digest ${k.digest.slice(0,12)}\u2026`);for(let D of V(j.manifest))y(` ${D}`);return y("it loads on the next start; `rovecode plugin show "+q+"` lists every file it brings"),0}case"untrust":{if(!q)return z(M),2;return y(L(q,{cwd:B,home:C})?`untrusted ${q}`:`${q} was not trusted`),0}case"show":case"info":{if(!q)return z(M),2;let j=Q(B,{home:C}).plugins.find((k)=>k.name===q);if(!j)return z(`plugin show: no plugin "${q}"`),1;if(y(F(j)),y(` folder: ${j.dir}`),j.digest)y(` digest: ${j.digest}`);if(j.manifest)for(let k of V(j.manifest))y(` ${k}`);for(let k of Z(j.dir))y(` - ${k}`);for(let k of j.problems)y(` ! ${k}`);if(j.status==="untrusted")y(` run \`rovecode plugin trust ${j.name}\` after reading the files above`);return 0}case"help":case"--help":case"-h":return y(M),0;default:return z(`unknown plugin command "${T}"
4
+ ${M}`),2}}function F(J){let K=J.manifest?`@${J.manifest.version}`:"",B=J.manifest?.description?` \u2014 ${J.manifest.description}`:"";return`${(J.name+K).padEnd(28)} ${J.scope.padEnd(8)} ${J.status.padEnd(9)}${B}`.trimEnd()}
5
+ export{M as Ah,c as Bh,F as Ch};