clawdi 0.14.73 → 0.14.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import{createRequire as Z_e}from"node:module";var z_e=Object.create;var{getProto
4
4
  `,"ascii"),oS=iS("sha256").update(lbe).digest("hex")});import dbe from"events";import Wr from"fs";import{EventEmitter as qI}from"node:events";import WW from"node:stream";import{StringDecoder as pbe}from"node:string_decoder";import JW from"node:path";import Rp from"node:fs";import{dirname as Abe,parse as Rbe}from"path";import{EventEmitter as Tbe}from"events";import RI from"assert";import{Buffer as cu}from"buffer";import*as gW from"zlib";import jbe from"zlib";import{posix as wp}from"node:path";import{basename as cSe}from"node:path";import DS from"fs";import _s from"fs";import kW from"path";import{win32 as SSe}from"node:path";import xW from"path";import c9 from"node:fs";import USe from"node:assert";import{randomBytes as u9}from"node:crypto";import Ke from"node:fs";import An from"node:path";import d9 from"fs";import HS from"node:fs";import Rh from"node:path";import ki from"node:fs";import WSe from"node:fs/promises";import NS from"node:path";import{join as S9}from"node:path";import Si from"node:fs";import E9 from"node:path";function OSe(e,t,n){let r=t,i=t?t.next:e.head,o=new XI(n,r,i,e);return o.next===void 0&&(e.tail=o),o.prev===void 0&&(e.head=o),e.length++,o}function DSe(e,t){e.tail=new XI(t,e.tail,void 0,e),e.head||(e.head=e.tail),e.length++}function TSe(e,t){e.head=new XI(t,void 0,e.head,e),e.tail||(e.tail=e.head),e.length++}var cbe,ube=(e,t)=>{for(var n in t)cbe(e,n,{get:t[n],enumerable:!0})},dW,mbe=(e)=>!!e&&typeof e=="object"&&(e instanceof pu||e instanceof WW||fbe(e)||gbe(e)),fbe=(e)=>!!e&&typeof e=="object"&&e instanceof qI&&typeof e.pipe=="function"&&e.pipe!==WW.Writable.prototype.pipe,gbe=(e)=>!!e&&typeof e=="object"&&e instanceof qI&&typeof e.write=="function"&&typeof e.end=="function",ua,da,ml,sS,lh,aS,pW,lS,mW,Eo,vp,Dn,ch,kp,Tn,Ar,jn,Yx,cS,dr,pn,Xx,Qx,fW,eI,hs,tI,uS,uh,eu,bi,dh=(e)=>Promise.resolve().then(e),hbe=(e)=>e(),ybe=(e)=>e==="end"||e==="finish"||e==="prefinish",vbe=(e)=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,wbe=(e)=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),KW=class{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[kp](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},_be,bbe=(e)=>!!e.objectMode,Sbe=(e)=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",pu,kbe,Sl,Co,ph,dt,nI,ga,rI,EI,AI,Eh,dS,Pp,Cp,iI,Ep,kl,Po,yl,ys,Ap,oI,fa,mh,sI,bS,tu,SS,lu,WI,Ebe,MS,GW,Pbe,Cbe=(e)=>!!e.sync&&!!e.file,$be=(e)=>!e.sync&&!!e.file,xbe=(e)=>!!e.sync&&!e.file,Ibe=(e)=>!e.sync&&!e.file,Obe=(e)=>!!e.file,Dbe=(e)=>Pbe.get(e)||e,KI=(e={})=>{if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let i=Dbe(n);t[i]=r}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t},Dh=(e,t,n,r,i)=>Object.assign((o=[],s,a)=>{Array.isArray(o)&&(s=o,o={}),typeof s=="function"&&(a=s,s=void 0),s=s?Array.from(s):[];let l=KI(o);if(i?.(l,s),Cbe(l)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return e(l,s)}else if($be(l)){let c=t(l,s);return a?c.then(()=>a(),a):c}else if(xbe(l)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return n(l,s)}else if(Ibe(l)){if(typeof a=="function")throw TypeError("callback only supported with file option");return r(l,s)}throw Error("impossible options??")},{syncFile:e,asyncFile:t,syncNoFile:n,asyncNoFile:r,validate:i}),Nbe,Ss,Mbe,hW,Lbe=(e)=>e,aI,uu,pS,lI,GI,ZW,Ube,Fbe,YW,zbe,Hbe,XW,Bbe,Vbe,qbe=(e,t)=>{if(Number.isSafeInteger(e))e<0?Kbe(e,t):Wbe(e,t);else throw Error("cannot encode number outside of javascript safe integer range");return t},Wbe=(e,t)=>{t[0]=128;for(var n=t.length;n>1;n--)t[n-1]=e&255,e=Math.floor(e/256)},Kbe=(e,t)=>{t[0]=255;var n=!1;e=e*-1;for(var r=t.length;r>1;r--){var i=e&255;e=Math.floor(e/256),n?t[r-1]=QW(i):i===0?t[r-1]=0:(n=!0,t[r-1]=e9(i))}},Gbe=(e)=>{let t=e[0],n=t===128?Zbe(e.subarray(1,e.length)):t===255?Jbe(e):null;if(n===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(n))throw Error("parsed number outside of javascript safe integer range");return n},Jbe=(e)=>{for(var t=e.length,n=0,r=!1,i=t-1;i>-1;i--){var o=Number(e[i]),s;r?s=QW(o):o===0?s=o:(r=!0,s=e9(o)),s!==0&&(n-=s*Math.pow(256,t-i-1))}return n},Zbe=(e)=>{for(var t=e.length,n=0,r=t-1;r>-1;r--){var i=Number(e[r]);i!==0&&(n+=i*Math.pow(256,t-r-1))}return n},QW=(e)=>(255^e)&255,e9=(e)=>(255^e)+1&255,Ybe,kS=(e)=>LS.has(e),Xbe=(e)=>JI.has(e),t9,LS,JI,Qbe=(e)=>e===void 0||e<0?void 0:e,du=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,t=0,n,r){Buffer.isBuffer(e)?this.decode(e,t||0,n,r):e&&this.#n(e)}decode(e,t,n,r){if(t||(t=0),!e||!(e.length>=t+512))throw Error("need 512 bytes for header");let i=nu(e,t+156,1),o=t9.has(i),s=o?n:void 0,a=o?r:void 0;if(this.path=s?.path??nu(e,t,100),this.mode=s?.mode??a?.mode??vl(e,t+100,8),this.uid=s?.uid??a?.uid??vl(e,t+108,8),this.gid=s?.gid??a?.gid??vl(e,t+116,8),this.size=Qbe(s?.size??a?.size??vl(e,t+124,12)),this.mtime=s?.mtime??a?.mtime??cI(e,t+136,12),this.cksum=vl(e,t+148,12),a&&this.#n(a,!0),s&&this.#n(s),kS(i)&&(this.#e=i||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=nu(e,t+157,100),e.subarray(t+257,t+265).toString()==="ustar\x0000")if(this.uname=s?.uname??a?.uname??nu(e,t+265,32),this.gname=s?.gname??a?.gname??nu(e,t+297,32),this.devmaj=s?.devmaj??a?.devmaj??vl(e,t+329,8)??0,this.devmin=s?.devmin??a?.devmin??vl(e,t+337,8)??0,e[t+475]!==0){let c=nu(e,t+345,155);this.path=c+"/"+this.path}else{let c=nu(e,t+345,130);c&&(this.path=c+"/"+this.path),this.atime=n?.atime??r?.atime??cI(e,t+476,12),this.ctime=n?.ctime??r?.ctime??cI(e,t+488,12)}let l=256;for(let c=t;c<t+148;c++)l+=e[c];for(let c=t+156;c<t+512;c++)l+=e[c];this.cksumValid=l===this.cksum,this.cksum===void 0&&l===256&&(this.nullBlock=!0)}#n(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,r])=>!(r==null||n==="size"&&Number(r)<0||n==="path"&&t||n==="linkpath"&&t||n==="global"))))}encode(e,t=0){if(e||(e=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=t+512))throw Error("need 512 bytes for header");let n=this.ctime||this.atime?130:155,r=eSe(this.path||"",n),i=r[0],o=r[1];this.needPax=!!r[2],this.needPax=ru(e,t,100,i)||this.needPax,this.needPax=wl(e,t+100,8,this.mode)||this.needPax,this.needPax=wl(e,t+108,8,this.uid)||this.needPax,this.needPax=wl(e,t+116,8,this.gid)||this.needPax,this.needPax=wl(e,t+124,12,this.size)||this.needPax,this.needPax=uI(e,t+136,12,this.mtime)||this.needPax,e[t+156]=Number(this.#e.codePointAt(0)),this.needPax=ru(e,t+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",t+257,8),this.needPax=ru(e,t+265,32,this.uname)||this.needPax,this.needPax=ru(e,t+297,32,this.gname)||this.needPax,this.needPax=wl(e,t+329,8,this.devmaj)||this.needPax,this.needPax=wl(e,t+337,8,this.devmin)||this.needPax,this.needPax=ru(e,t+345,n,o)||this.needPax,e[t+475]!==0?this.needPax=ru(e,t+345,155,o)||this.needPax:(this.needPax=ru(e,t+345,130,o)||this.needPax,this.needPax=uI(e,t+476,12,this.atime)||this.needPax,this.needPax=uI(e,t+488,12,this.ctime)||this.needPax);let s=256;for(let a=t;a<t+148;a++)s+=e[a];for(let a=t+156;a<t+512;a++)s+=e[a];return this.cksum=s,wl(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:LS.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(JI.get(e));if(kS(t)||t==="Unsupported")this.#e=t;else if(kS(e))this.#e=e;else throw TypeError("invalid entry type: "+e)}},eSe=(e,t)=>{let n=e,r="",i,o=wp.parse(e).root||".";if(Buffer.byteLength(n)<100)i=[n,r,!1];else{r=wp.dirname(n),n=wp.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(r)<=t?i=[n,r,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(r)<=t?i=[n.slice(0,99),r,!0]:(n=wp.join(wp.basename(r),n),r=wp.dirname(r));while(r!==o&&i===void 0);i||(i=[e.slice(0,99),"",!0])}return i},nu=(e,t,n)=>e.subarray(t,t+n).toString("utf8").replace(/\0.*/,""),cI=(e,t,n)=>tSe(vl(e,t,n)),tSe=(e)=>e===void 0?void 0:new Date(e*1000),vl=(e,t,n)=>Number(e[t])&128?Gbe(e.subarray(t,t+n)):rSe(e,t,n),nSe=(e)=>isNaN(e)?void 0:e,rSe=(e,t,n)=>nSe(parseInt(e.subarray(t,t+n).toString("utf8").replace(/\0.*$/,"").trim(),8)),iSe,wl=(e,t,n,r)=>r===void 0?!1:r>iSe[n]||r<0?(qbe(r,e.subarray(t,t+n)),!0):(oSe(e,t,n,r),!1),oSe=(e,t,n,r)=>e.write(sSe(r,n),t,n,"ascii"),sSe=(e,t)=>aSe(Math.floor(e).toString(8),t),aSe=(e,t)=>(e.length===t-1?e:Array(t-e.length-1).join("0")+e+" ")+"\x00",uI=(e,t,n,r)=>r===void 0?!1:wl(e,t,n,r.getTime()/1000),lSe,ru=(e,t,n,r)=>r===void 0?!1:(e.write(r+lSe,t,n,"utf8"),r.length!==Buffer.byteLength(r)||r.length>n),OS=class e{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,n=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=n,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){let t=this.encodeBody();if(t==="")return Buffer.allocUnsafe(0);let n=Buffer.byteLength(t),r=512*Math.ceil(1+n/512),i=Buffer.allocUnsafe(r);for(let o=0;o<512;o++)i[o]=0;new du({path:("PaxHeader/"+cSe(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:n,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(i),i.write(t,512,n,"utf8");for(let o=n+512;o<i.length;o++)i[o]=0;return i}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(this[t]===void 0)return"";let n=this[t],r=n instanceof Date?n.getTime()/1000:n,i=" "+(t==="dev"||t==="ino"||t==="nlink"?"SCHILY.":"")+t+"="+r+`
5
5
  `,o=Buffer.byteLength(i),s=Math.floor(Math.log(o)/Math.log(10))+1;return o+s>=Math.pow(10,s)&&(s+=1),s+o+i}static parse(t,n,r=!1){return new e(uSe(dSe(t),n),r)}},uSe=(e,t)=>t?Object.assign({},t,e):e,dSe=(e)=>e.replace(/\n$/,"").split(`
6
6
  `).reduce(pSe,Object.create(null)),pSe=(e,t)=>{let n=parseInt(t,10);if(n!==Buffer.byteLength(t)+1)return e;t=t.slice((n+" ").length);let r=t.split("="),i=r.shift();if(!i)return e;let o=i.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),s=r.join("=").replace(/\0.*/,"");switch(o){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":e[o]=s;break;case"ctime":case"atime":case"mtime":e[o]=new Date(Number(s)*1000);break;case"size":let a=+s;a>=0&&(e[o]=a);break;case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":e[o]=+s;break}return e},mSe,Ne,fSe,US=(e,t,n,r={})=>{e.file&&(r.file=e.file),e.cwd&&(r.cwd=e.cwd),r.code=n instanceof Error&&n.code||t,r.tarCode=t,!e.strict&&r.recoverable!==!1?(n instanceof Error&&(r=Object.assign(n,r),n=n.message),e.emit("warn",t,n,r)):n instanceof Error?e.emit("error",Object.assign(n,r)):e.emit("error",Object.assign(Error(`${t}: ${n}`),r))},gSe=1048576,PI,CI,hSe,Wi,iu,pa,dI,yW,vs,fh,fl,vW,Ut,ma,gl,pI,ou,rn,mS,fS,mI,wW,_W,gh,fI,gS,_p,ws,hS,su,yS,vS,bW,ySe=1000,hh,gI,SW,vSe=()=>!0,Oh,Ah=(e)=>{let t=e.length-1,n=-1;for(;t>-1&&e.charAt(t)==="/";)n=t,t--;return n===-1?e:e.slice(0,n)},wSe=(e)=>{let t=e.onReadEntry;e.onReadEntry=t?(n)=>{t(n),n.resume()}:(n)=>n.resume()},n9=(e,t)=>{let n=new Map(t.map((s)=>[Ah(s),!0])),r=e.filter,i=100,o=(s,a="",l=0)=>{if(l>=i)return n.set(s,!1),!1;let c=a||Rbe(s).root||".",u;if(s===c)u=!1;else{let d=n.get(s);u=d!==void 0?d:o(Abe(s),c,l+1)}return n.set(s,u),u};e.filter=r?(s,a)=>r(s,a)&&o(Ah(s)):(s)=>o(Ah(s))},_Se=(e)=>{let t=new Oh(e),n=e.file,r;try{r=Rp.openSync(n,"r");let i=Rp.fstatSync(r),o=e.maxReadSize||16777216;if(i.size<o){let s=Buffer.allocUnsafe(i.size),a=Rp.readSync(r,s,0,i.size,0);t.end(a===s.byteLength?s:s.subarray(0,a))}else{let s=0,a=Buffer.allocUnsafe(o);for(;s<i.size;){let l=Rp.readSync(r,a,0,o,s);if(l===0)break;s+=l,t.write(a.subarray(0,l))}t.end()}}finally{if(typeof r=="number")try{Rp.closeSync(r)}catch{}}},bSe=(e,t)=>{let n=new Oh(e),r=e.maxReadSize||16777216,i=e.file;return new Promise((o,s)=>{n.on("error",s),n.on("end",o),Rp.stat(i,(a,l)=>{if(a)s(a);else{let c=new WI(i,{readSize:r,size:l.size});c.on("error",s),c.pipe(n)}})})},El,r9=(e,t,n)=>(e&=4095,n&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e),kSe,EW,ZI=(e)=>{let t="",n=EW(e);for(;kSe(e)||n.root;){let r=e.charAt(0)==="/"&&e.slice(0,4)!=="//?/"?"/":n.root;e=e.slice(r.length),t+=r,n=EW(e)}return[t,e]},FS,YI,ESe,ASe,AW=(e)=>FS.reduce((t,n)=>t.split(n).join(ESe.get(n)),e),RSe=(e)=>YI.reduce((t,n)=>t.split(n).join(ASe.get(n)),e),i9=(e,t)=>t?(e=Ne(e).replace(/^\.(\/|$)/,""),Ah(t)+"/"+e):Ne(e),PSe=16777216,RW,PW,CW,$I,$W,yh,ES,xI,AS,II,OI,DI,TI,_l,TS,jI,hI,bs,o9,CSe,$Se,xSe=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":"Unsupported",ISe,XI=class{list;next;prev;value;constructor(e,t,n,r){this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}},IW=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(e,t){this.path=e||"./",this.absolute=t}},OW,RS,vh,Ao,wh,hl,au,_h,wS,Ro,yI,PS,DW,NI,MI,CS,$S,TW,vI,xS,s9,wI,zS,QI,jSe=(e,t)=>{let n=new QI(e),r=new GW(e.file,{mode:e.mode||438});n.pipe(r),a9(n,t)},NSe=(e,t)=>{let n=new zS(e),r=new MS(e.file,{mode:e.mode||438});n.pipe(r);let i=new Promise((o,s)=>{r.on("error",s),r.on("close",o),n.on("error",s)});return l9(n,t).catch((o)=>n.emit("error",o)),i},a9=(e,t)=>{t.forEach((n)=>{n.charAt(0)==="@"?El({file:JW.resolve(e.cwd,n.slice(1)),sync:!0,noResume:!0,onReadEntry:(r)=>e.add(r)}):e.add(n)}),e.end()},l9=async(e,t)=>{for(let n of t)n.charAt(0)==="@"?await El({file:JW.resolve(String(e.cwd),n.slice(1)),noResume:!0,onReadEntry:(r)=>{e.add(r)}}):e.add(n);e.end()},MSe=(e,t)=>{let n=new QI(e);return a9(n,t),n},LSe=(e,t)=>{let n=new zS(e);return l9(n,t).catch((r)=>n.emit("error",r)),n},eO,FSe,p9,m9,jW,f9,g9,h9,zSe,HSe=524288,BSe,NW,y9,LI=(e,t,n)=>{try{return HS.lchownSync(e,t,n)}catch(r){if(r?.code!=="ENOENT")throw r}},jS=(e,t,n,r)=>{HS.lchown(e,t,n,(i)=>{r(i&&i?.code!=="ENOENT"?i:null)})},VSe=(e,t,n,r,i)=>{if(t.isDirectory())v9(Rh.resolve(e,t.name),n,r,(o)=>{if(o)return i(o);let s=Rh.resolve(e,t.name);jS(s,n,r,i)});else{let o=Rh.resolve(e,t.name);jS(o,n,r,i)}},v9=(e,t,n,r)=>{HS.readdir(e,{withFileTypes:!0},(i,o)=>{if(i){if(i.code==="ENOENT")return r();if(i.code!=="ENOTDIR"&&i.code!=="ENOTSUP")return r(i)}if(i||!o.length)return jS(e,t,n,r);let s=o.length,a=null,l=(c)=>{if(!a){if(c)return r(a=c);if(--s===0)return jS(e,t,n,r)}};for(let c of o)VSe(e,c,t,n,l)})},qSe=(e,t,n,r)=>{t.isDirectory()&&w9(Rh.resolve(e,t.name),n,r),LI(Rh.resolve(e,t.name),n,r)},w9=(e,t,n)=>{let r;try{r=HS.readdirSync(e,{withFileTypes:!0})}catch(i){let o=i;if(o?.code==="ENOENT")return;if(o?.code==="ENOTDIR"||o?.code==="ENOTSUP")return LI(e,t,n);throw o}for(let i of r)qSe(e,i,t,n);return LI(e,t,n)},_9,BS,KSe=(e,t)=>{ki.stat(e,(n,r)=>{(n||!r.isDirectory())&&(n=new _9(e,n?.code||"ENOTDIR")),t(n)})},GSe=(e,t,n)=>{e=Ne(e);let r=t.umask??18,i=t.mode|448,o=(i&r)!==0,s=t.uid,a=t.gid,l=typeof s=="number"&&typeof a=="number"&&(s!==t.processUid||a!==t.processGid),c=t.preserve,u=t.unlink,d=Ne(t.cwd),p=(f,g)=>{f?n(f):g&&l?v9(g,s,a,(v)=>p(v)):o?ki.chmod(e,i,n):n()};if(e===d)return KSe(e,p);if(c)return WSe.mkdir(e,{mode:i,recursive:!0}).then((f)=>p(null,f??void 0),p);let m=Ne(NS.relative(d,e)).split("/");UI(d,m,i,u,d,void 0,p)},UI=(e,t,n,r,i,o,s)=>{if(t.length===0)return s(null,o);let a=t.shift(),l=Ne(NS.resolve(e+"/"+a));ki.mkdir(l,n,b9(l,t,n,r,i,o,s))},b9=(e,t,n,r,i,o,s)=>(a)=>{a?ki.lstat(e,(l,c)=>{if(l)l.path=l.path&&Ne(l.path),s(l);else if(c.isDirectory())UI(e,t,n,r,i,o,s);else if(r)ki.unlink(e,(u)=>{if(u)return s(u);ki.mkdir(e,n,b9(e,t,n,r,i,o,s))});else{if(c.isSymbolicLink())return s(new BS(e,e+"/"+t.join("/")));s(a)}}):(o=o||e,UI(e,t,n,r,i,o,s))},JSe=(e)=>{let t=!1,n;try{t=ki.statSync(e).isDirectory()}catch(r){n=r?.code}finally{if(!t)throw new _9(e,n??"ENOTDIR")}},ZSe=(e,t)=>{e=Ne(e);let n=t.umask??18,r=t.mode|448,i=(r&n)!==0,o=t.uid,s=t.gid,a=typeof o=="number"&&typeof s=="number"&&(o!==t.processUid||s!==t.processGid),l=t.preserve,c=t.unlink,u=Ne(t.cwd),d=(f)=>{f&&a&&w9(f,o,s),i&&ki.chmodSync(e,r)};if(e===u)return JSe(u),d();if(l)return d(ki.mkdirSync(e,{mode:r,recursive:!0})??void 0);let p=Ne(NS.relative(u,e)).split("/"),m;for(let f=p.shift(),g=u;f&&(g+="/"+f);f=p.shift()){g=Ne(NS.resolve(g));try{ki.mkdirSync(g,r),m=m||g}catch{let v=ki.lstatSync(g);if(v.isDirectory())continue;if(c){ki.unlinkSync(g),ki.mkdirSync(g,r),m=m||g;continue}else if(v.isSymbolicLink())return new BS(g,g+"/"+p.join("/"))}}return d(m)},_I,MW=1e4,bp,YSe=(e)=>{bp.has(e)?bp.delete(e):_I[e]=e.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),bp.add(e);let t=_I[e],n=bp.size-MW;if(n>MW/10){for(let r of bp)if(bp.delete(r),delete _I[r],--n<=0)break}return t},XSe,QSe,eke=(e)=>e.split("/").slice(0,-1).reduce((t,n)=>{let r=t.at(-1);return r!==void 0&&(n=S9(r,n)),t.push(n||"/"),t},[]),tke=class{#e=new Map;#n=new Map;#r=new Set;reserve(e,t){e=QSe?["win32 parallelization disabled"]:e.map((r)=>Ah(S9(YSe(r))));let n=new Set(e.map((r)=>eke(r)).reduce((r,i)=>r.concat(i)));this.#n.set(t,{dirs:n,paths:e});for(let r of e){let i=this.#e.get(r);i?i.push(t):this.#e.set(r,[t])}for(let r of n){let i=this.#e.get(r);if(!i)this.#e.set(r,[new Set([t])]);else{let o=i.at(-1);o instanceof Set?o.add(t):i.push(new Set([t]))}}return this.#i(t)}#o(e){let t=this.#n.get(e);if(!t)throw Error("function does not have any path reservations");return{paths:t.paths.map((n)=>this.#e.get(n)),dirs:[...t.dirs].map((n)=>this.#e.get(n))}}check(e){let{paths:t,dirs:n}=this.#o(e);return t.every((r)=>r&&r[0]===e)&&n.every((r)=>r&&r[0]instanceof Set&&r[0].has(e))}#i(e){return this.#r.has(e)||!this.check(e)?!1:(this.#r.add(e),e(()=>this.#t(e)),!0)}#t(e){if(!this.#r.has(e))return!1;let t=this.#n.get(e);if(!t)throw Error("invalid reservation");let{paths:n,dirs:r}=t,i=new Set;for(let o of n){let s=this.#e.get(o);if(!s||s?.[0]!==e)continue;let a=s[1];if(!a){this.#e.delete(o);continue}if(s.shift(),typeof a=="function")i.add(a);else for(let l of a)i.add(l)}for(let o of r){let s=this.#e.get(o),a=s?.[0];if(!(!s||!(a instanceof Set)))if(a.size===1&&s.length===1){this.#e.delete(o);continue}else if(a.size===1){s.shift();let l=s[0];typeof l=="function"&&i.add(l)}else a.delete(e)}return this.#r.delete(e),i.forEach((o)=>this.#i(o)),!0}},nke=()=>process.umask(),LW,FI,UW,zI,Ki,HI,BI,IS,FW,zW,kh,HW,BW,bI,bl,Nn,_S,VW,Sp,SI,kI,VI,Ph,Ch,$h,xh,rke,Ih,ike=1024,oke=(e,t)=>{if(!Ih)return Ke.unlink(e,t);let n=e+".DELETE."+u9(16).toString("hex");Ke.rename(e,n,(r)=>{if(r)return t(r);Ke.unlink(n,t)})},ske=(e)=>{if(!Ih)return Ke.unlinkSync(e);let t=e+".DELETE."+u9(16).toString("hex");Ke.renameSync(e,t),Ke.unlinkSync(t)},qW=(e,t,n)=>e!==void 0&&e===e>>>0?e:t!==void 0&&t===t>>>0?t:n,tO,bh=(e)=>{try{return[null,e()]}catch(t){return[t,null]}},k9,ake=(e)=>{let t=new k9(e),n=e.file,r=c9.statSync(n),i=e.maxReadSize||16777216;new Ebe(n,{readSize:i,size:r.size}).pipe(t)},lke=(e,t)=>{let n=new tO(e),r=e.maxReadSize||16777216,i=e.file;return new Promise((o,s)=>{n.on("error",s),n.on("close",o),c9.stat(i,(a,l)=>{if(a)s(a);else{let c=new WI(i,{readSize:r,size:l.size});c.on("error",s),c.pipe(n)}})})},Th,cke=(e,t)=>{let n=new QI(e),r=!0,i,o;try{try{i=Si.openSync(e.file,"r+")}catch(l){if(l?.code==="ENOENT")i=Si.openSync(e.file,"w+");else throw l}let s=Si.fstatSync(i),a=Buffer.alloc(512);e:for(o=0;o<s.size;o+=512){for(let u=0,d=0;u<512;u+=d){if(d=Si.readSync(i,a,u,a.length-u,o+u),o===0&&a[0]===31&&a[1]===139)throw Error("cannot append to compressed archives");if(!d)break e}let l=new du(a);if(!l.cksumValid)break;let c=512*Math.ceil((l.size||0)/512);if(o+c+512>s.size)break;o+=c,e.mtimeCache&&l.mtime&&e.mtimeCache.set(String(l.path),l.mtime)}r=!1,uke(e,n,o,i,t)}finally{if(r)try{Si.closeSync(i)}catch{}}},uke=(e,t,n,r,i)=>{let o=new GW(e.file,{fd:r,start:n});t.pipe(o),pke(t,i)},dke=(e,t)=>{t=Array.from(t);let n=new zS(e),r=(i,o,s)=>{let a=(p,m)=>{p?Si.close(i,(f)=>s(p)):s(null,m)},l=0;if(o===0)return a(null,0);let c=0,u=Buffer.alloc(512),d=(p,m)=>{if(p||m===void 0)return a(p);if(c+=m,c<512&&m)return Si.read(i,u,c,u.length-c,l+c,d);if(l===0&&u[0]===31&&u[1]===139)return a(Error("cannot append to compressed archives"));if(c<512)return a(null,l);let f=new du(u);if(!f.cksumValid)return a(null,l);let g=512*Math.ceil((f.size??0)/512);if(l+g+512>o||(l+=g+512,l>=o))return a(null,l);e.mtimeCache&&f.mtime&&e.mtimeCache.set(String(f.path),f.mtime),c=0,Si.read(i,u,0,512,l,d)};Si.read(i,u,0,512,l,d)};return new Promise((i,o)=>{n.on("error",o);let s="r+",a=(l,c)=>{if(l&&l.code==="ENOENT"&&s==="r+")return s="w+",Si.open(e.file,s,a);if(l||!c)return o(l);Si.fstat(c,(u,d)=>{if(u)return Si.close(c,()=>o(u));r(c,d.size,(p,m)=>{if(p)return o(p);let f=new MS(e.file,{fd:c,start:m});n.pipe(f),f.on("error",o),f.on("close",i),mke(n,t)})})};Si.open(e.file,s,a)})},pke=(e,t)=>{t.forEach((n)=>{n.charAt(0)==="@"?El({file:E9.resolve(e.cwd,n.slice(1)),sync:!0,noResume:!0,onReadEntry:(r)=>e.add(r)}):e.add(n)}),e.end()},mke=async(e,t)=>{for(let n of t)n.charAt(0)==="@"?await El({file:E9.resolve(String(e.cwd),n.slice(1)),noResume:!0,onReadEntry:(r)=>e.add(r)}):e.add(n);e.end()},Sh,Fyt,fke=(e)=>{let t=e.filter;e.mtimeCache||(e.mtimeCache=new Map),e.filter=t?(n,r)=>t(n,r)&&!((e.mtimeCache?.get(n)??r.mtime??0)>(r.mtime??0)):(n,r)=>!((e.mtimeCache?.get(n)??r.mtime??0)>(r.mtime??0))};var nO=b(()=>{cbe=Object.defineProperty,dW=typeof process=="object"&&process?process:{stdout:null,stderr:null},ua=Symbol("EOF"),da=Symbol("maybeEmitEnd"),ml=Symbol("emittedEnd"),sS=Symbol("emittingEnd"),lh=Symbol("emittedError"),aS=Symbol("closed"),pW=Symbol("read"),lS=Symbol("flush"),mW=Symbol("flushChunk"),Eo=Symbol("encoding"),vp=Symbol("decoder"),Dn=Symbol("flowing"),ch=Symbol("paused"),kp=Symbol("resume"),Tn=Symbol("buffer"),Ar=Symbol("pipes"),jn=Symbol("bufferLength"),Yx=Symbol("bufferPush"),cS=Symbol("bufferShift"),dr=Symbol("objectMode"),pn=Symbol("destroyed"),Xx=Symbol("error"),Qx=Symbol("emitData"),fW=Symbol("emitEnd"),eI=Symbol("emitEnd2"),hs=Symbol("async"),tI=Symbol("abort"),uS=Symbol("aborted"),uh=Symbol("signal"),eu=Symbol("dataListeners"),bi=Symbol("discarded"),_be=class extends KW{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=(r)=>this.dest.emit("error",r),e.on("error",this.proxyErrors)}},pu=class extends qI{[Dn]=!1;[ch]=!1;[Ar]=[];[Tn]=[];[dr];[Eo];[hs];[vp];[ua]=!1;[ml]=!1;[sS]=!1;[aS]=!1;[lh]=null;[jn]=0;[pn]=!1;[uh];[uS]=!1;[eu]=0;[bi]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");bbe(t)?(this[dr]=!0,this[Eo]=null):Sbe(t)?(this[Eo]=t.encoding,this[dr]=!1):(this[dr]=!1,this[Eo]=null),this[hs]=!!t.async,this[vp]=this[Eo]?new pbe(this[Eo]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Tn]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ar]});let{signal:n}=t;n&&(this[uh]=n,n.aborted?this[tI]():n.addEventListener("abort",()=>this[tI]()))}get bufferLength(){return this[jn]}get encoding(){return this[Eo]}set encoding(e){throw Error("Encoding must be set at instantiation time")}setEncoding(e){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[dr]}set objectMode(e){throw Error("objectMode must be set at instantiation time")}get async(){return this[hs]}set async(e){this[hs]=this[hs]||!!e}[tI](){this[uS]=!0,this.emit("abort",this[uh]?.reason),this.destroy(this[uh]?.reason)}get aborted(){return this[uS]}set aborted(e){}write(e,t,n){if(this[uS])return!1;if(this[ua])throw Error("write after end");if(this[pn])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(n=t,t="utf8"),t||(t="utf8");let r=this[hs]?dh:hbe;if(!this[dr]&&!Buffer.isBuffer(e)){if(wbe(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(vbe(e))e=Buffer.from(e);else if(typeof e!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[dr]?(this[Dn]&&this[jn]!==0&&this[lS](!0),this[Dn]?this.emit("data",e):this[Yx](e),this[jn]!==0&&this.emit("readable"),n&&r(n),this[Dn]):e.length?(typeof e=="string"&&!(t===this[Eo]&&!this[vp]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Eo]&&(e=this[vp].write(e)),this[Dn]&&this[jn]!==0&&this[lS](!0),this[Dn]?this.emit("data",e):this[Yx](e),this[jn]!==0&&this.emit("readable"),n&&r(n),this[Dn]):(this[jn]!==0&&this.emit("readable"),n&&r(n),this[Dn])}read(e){if(this[pn])return null;if(this[bi]=!1,this[jn]===0||e===0||e&&e>this[jn])return this[da](),null;this[dr]&&(e=null),this[Tn].length>1&&!this[dr]&&(this[Tn]=[this[Eo]?this[Tn].join(""):Buffer.concat(this[Tn],this[jn])]);let t=this[pW](e||null,this[Tn][0]);return this[da](),t}[pW](e,t){if(this[dr])this[cS]();else{let n=t;e===n.length||e===null?this[cS]():typeof n=="string"?(this[Tn][0]=n.slice(e),t=n.slice(0,e),this[jn]-=e):(this[Tn][0]=n.subarray(e),t=n.subarray(0,e),this[jn]-=e)}return this.emit("data",t),!this[Tn].length&&!this[ua]&&this.emit("drain"),t}end(e,t,n){return typeof e=="function"&&(n=e,e=void 0),typeof t=="function"&&(n=t,t="utf8"),e!==void 0&&this.write(e,t),n&&this.once("end",n),this[ua]=!0,this.writable=!1,(this[Dn]||!this[ch])&&this[da](),this}[kp](){this[pn]||(!this[eu]&&!this[Ar].length&&(this[bi]=!0),this[ch]=!1,this[Dn]=!0,this.emit("resume"),this[Tn].length?this[lS]():this[ua]?this[da]():this.emit("drain"))}resume(){return this[kp]()}pause(){this[Dn]=!1,this[ch]=!0,this[bi]=!1}get destroyed(){return this[pn]}get flowing(){return this[Dn]}get paused(){return this[ch]}[Yx](e){this[dr]?this[jn]+=1:this[jn]+=e.length,this[Tn].push(e)}[cS](){return this[dr]?this[jn]-=1:this[jn]-=this[Tn][0].length,this[Tn].shift()}[lS](e=!1){do;while(this[mW](this[cS]())&&this[Tn].length);!e&&!this[Tn].length&&!this[ua]&&this.emit("drain")}[mW](e){return this.emit("data",e),this[Dn]}pipe(e,t){if(this[pn])return e;this[bi]=!1;let n=this[ml];return t=t||{},e===dW.stdout||e===dW.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[Ar].push(t.proxyErrors?new _be(this,e,t):new KW(this,e,t)),this[hs]?dh(()=>this[kp]()):this[kp]()),e}unpipe(e){let t=this[Ar].find((n)=>n.dest===e);t&&(this[Ar].length===1?(this[Dn]&&this[eu]===0&&(this[Dn]=!1),this[Ar]=[]):this[Ar].splice(this[Ar].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e==="data")this[bi]=!1,this[eu]++,!this[Ar].length&&!this[Dn]&&this[kp]();else if(e==="readable"&&this[jn]!==0)super.emit("readable");else if(ybe(e)&&this[ml])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[lh]){let r=t;this[hs]?dh(()=>r.call(this,this[lh])):r.call(this,this[lh])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e==="data"&&(this[eu]=this.listeners("data").length,this[eu]===0&&!this[bi]&&!this[Ar].length&&(this[Dn]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[eu]=0,!this[bi]&&!this[Ar].length&&(this[Dn]=!1)),t}get emittedEnd(){return this[ml]}[da](){!this[sS]&&!this[ml]&&!this[pn]&&this[Tn].length===0&&this[ua]&&(this[sS]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[aS]&&this.emit("close"),this[sS]=!1)}emit(e,...t){let n=t[0];if(e!=="error"&&e!=="close"&&e!==pn&&this[pn])return!1;if(e==="data")return!this[dr]&&!n?!1:this[hs]?(dh(()=>this[Qx](n)),!0):this[Qx](n);if(e==="end")return this[fW]();if(e==="close"){if(this[aS]=!0,!this[ml]&&!this[pn])return!1;let i=super.emit("close");return this.removeAllListeners("close"),i}else if(e==="error"){this[lh]=n,super.emit(Xx,n);let i=!this[uh]||this.listeners("error").length?super.emit("error",n):!1;return this[da](),i}else if(e==="resume"){let i=super.emit("resume");return this[da](),i}else if(e==="finish"||e==="prefinish"){let i=super.emit(e);return this.removeAllListeners(e),i}let r=super.emit(e,...t);return this[da](),r}[Qx](e){for(let n of this[Ar])n.dest.write(e)===!1&&this.pause();let t=this[bi]?!1:super.emit("data",e);return this[da](),t}[fW](){return this[ml]?!1:(this[ml]=!0,this.readable=!1,this[hs]?(dh(()=>this[eI]()),!0):this[eI]())}[eI](){if(this[vp]){let t=this[vp].end();if(t){for(let n of this[Ar])n.dest.write(t);this[bi]||super.emit("data",t)}}for(let t of this[Ar])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[dr]||(e.dataLength=0);let t=this.promise();return this.on("data",(n)=>{e.push(n),this[dr]||(e.dataLength+=n.length)}),await t,e}async concat(){if(this[dr])throw Error("cannot concat in objectMode");let e=await this.collect();return this[Eo]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(pn,()=>t(Error("stream destroyed"))),this.on("error",(n)=>t(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[bi]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[ua])return t();let r,i,o=(c)=>{this.off("data",s),this.off("end",a),this.off(pn,l),t(),i(c)},s=(c)=>{this.off("error",o),this.off("end",a),this.off(pn,l),this.pause(),r({value:c,done:!!this[ua]})},a=()=>{this.off("error",o),this.off("data",s),this.off(pn,l),t(),r({done:!0,value:void 0})},l=()=>o(Error("stream destroyed"));return new Promise((c,u)=>{i=u,r=c,this.once(pn,l),this.once("error",o),this.once("end",a),this.once("data",s)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[bi]=!1;let e=!1,t=()=>(this.pause(),this.off(Xx,t),this.off(pn,t),this.off("end",t),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return t();let r=this.read();return r===null?t():{done:!1,value:r}};return this.once("end",t),this.once(Xx,t),this.once(pn,t),{next:n,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[pn])return e?this.emit("error",e):this.emit(pn),this;this[pn]=!0,this[bi]=!0,this[Tn].length=0,this[jn]=0;let t=this;return typeof t.close=="function"&&!this[aS]&&t.close(),e?this.emit("error",e):this.emit(pn),this}static get isStream(){return mbe}},kbe=Wr.writev,Sl=Symbol("_autoClose"),Co=Symbol("_close"),ph=Symbol("_ended"),dt=Symbol("_fd"),nI=Symbol("_finished"),ga=Symbol("_flags"),rI=Symbol("_flush"),EI=Symbol("_handleChunk"),AI=Symbol("_makeBuf"),Eh=Symbol("_mode"),dS=Symbol("_needDrain"),Pp=Symbol("_onerror"),Cp=Symbol("_onopen"),iI=Symbol("_onread"),Ep=Symbol("_onwrite"),kl=Symbol("_open"),Po=Symbol("_path"),yl=Symbol("_pos"),ys=Symbol("_queue"),Ap=Symbol("_read"),oI=Symbol("_readSize"),fa=Symbol("_reading"),mh=Symbol("_remain"),sI=Symbol("_size"),bS=Symbol("_write"),tu=Symbol("_writing"),SS=Symbol("_defaultFlag"),lu=Symbol("_errored"),WI=class extends pu{[lu]=!1;[dt];[Po];[oI];[fa]=!1;[sI];[mh];[Sl];constructor(e,t){if(t=t||{},super(t),this.readable=!0,this.writable=!1,typeof e!="string")throw TypeError("path must be a string");this[lu]=!1,this[dt]=typeof t.fd=="number"?t.fd:void 0,this[Po]=e,this[oI]=t.readSize||16777216,this[fa]=!1,this[sI]=typeof t.size=="number"?t.size:1/0,this[mh]=this[sI],this[Sl]=typeof t.autoClose=="boolean"?t.autoClose:!0,typeof this[dt]=="number"?this[Ap]():this[kl]()}get fd(){return this[dt]}get path(){return this[Po]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[kl](){Wr.open(this[Po],"r",(e,t)=>this[Cp](e,t))}[Cp](e,t){e?this[Pp](e):(this[dt]=t,this.emit("open",t),this[Ap]())}[AI](){return Buffer.allocUnsafe(Math.min(this[oI],this[mh]))}[Ap](){if(!this[fa]){this[fa]=!0;let e=this[AI]();if(e.length===0)return process.nextTick(()=>this[iI](null,0,e));Wr.read(this[dt],e,0,e.length,null,(t,n,r)=>this[iI](t,n,r))}}[iI](e,t,n){this[fa]=!1,e?this[Pp](e):this[EI](t,n)&&this[Ap]()}[Co](){if(this[Sl]&&typeof this[dt]=="number"){let e=this[dt];this[dt]=void 0,Wr.close(e,(t)=>t?this.emit("error",t):this.emit("close"))}}[Pp](e){this[fa]=!0,this[Co](),this.emit("error",e)}[EI](e,t){let n=!1;return this[mh]-=e,e>0&&(n=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[mh]<=0)&&(n=!1,this[Co](),super.end()),n}emit(e,...t){switch(e){case"prefinish":case"finish":return!1;case"drain":return typeof this[dt]=="number"&&this[Ap](),!1;case"error":return this[lu]?!1:(this[lu]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}},Ebe=class extends WI{[kl](){let e=!0;try{this[Cp](null,Wr.openSync(this[Po],"r")),e=!1}finally{e&&this[Co]()}}[Ap](){let e=!0;try{if(!this[fa]){this[fa]=!0;do{let t=this[AI](),n=t.length===0?0:Wr.readSync(this[dt],t,0,t.length,null);if(!this[EI](n,t))break}while(!0);this[fa]=!1}e=!1}finally{e&&this[Co]()}}[Co](){if(this[Sl]&&typeof this[dt]=="number"){let e=this[dt];this[dt]=void 0,Wr.closeSync(e),this.emit("close")}}},MS=class extends dbe{readable=!1;writable=!0;[lu]=!1;[tu]=!1;[ph]=!1;[ys]=[];[dS]=!1;[Po];[Eh];[Sl];[dt];[SS];[ga];[nI]=!1;[yl];constructor(e,t){t=t||{},super(t),this[Po]=e,this[dt]=typeof t.fd=="number"?t.fd:void 0,this[Eh]=t.mode===void 0?438:t.mode,this[yl]=typeof t.start=="number"?t.start:void 0,this[Sl]=typeof t.autoClose=="boolean"?t.autoClose:!0;let n=this[yl]!==void 0?"r+":"w";this[SS]=t.flags===void 0,this[ga]=t.flags===void 0?n:t.flags,this[dt]===void 0&&this[kl]()}emit(e,...t){if(e==="error"){if(this[lu])return!1;this[lu]=!0}return super.emit(e,...t)}get fd(){return this[dt]}get path(){return this[Po]}[Pp](e){this[Co](),this[tu]=!0,this.emit("error",e)}[kl](){Wr.open(this[Po],this[ga],this[Eh],(e,t)=>this[Cp](e,t))}[Cp](e,t){this[SS]&&this[ga]==="r+"&&e&&e.code==="ENOENT"?(this[ga]="w",this[kl]()):e?this[Pp](e):(this[dt]=t,this.emit("open",t),this[tu]||this[rI]())}end(e,t){return e&&this.write(e,t),this[ph]=!0,!this[tu]&&!this[ys].length&&typeof this[dt]=="number"&&this[Ep](null,0),this}write(e,t){return typeof e=="string"&&(e=Buffer.from(e,t)),this[ph]?(this.emit("error",Error("write() after end()")),!1):this[dt]===void 0||this[tu]||this[ys].length?(this[ys].push(e),this[dS]=!0,!1):(this[tu]=!0,this[bS](e),!0)}[bS](e){Wr.write(this[dt],e,0,e.length,this[yl],(t,n)=>this[Ep](t,n))}[Ep](e,t){e?this[Pp](e):(this[yl]!==void 0&&typeof t=="number"&&(this[yl]+=t),this[ys].length?this[rI]():(this[tu]=!1,this[ph]&&!this[nI]?(this[nI]=!0,this[Co](),this.emit("finish")):this[dS]&&(this[dS]=!1,this.emit("drain"))))}[rI](){if(this[ys].length===0)this[ph]&&this[Ep](null,0);else if(this[ys].length===1)this[bS](this[ys].pop());else{let e=this[ys];this[ys]=[],kbe(this[dt],e,this[yl],(t,n)=>this[Ep](t,n))}}[Co](){if(this[Sl]&&typeof this[dt]=="number"){let e=this[dt];this[dt]=void 0,Wr.close(e,(t)=>t?this.emit("error",t):this.emit("close"))}}},GW=class extends MS{[kl](){let e;if(this[SS]&&this[ga]==="r+")try{e=Wr.openSync(this[Po],this[ga],this[Eh])}catch(t){if(t?.code==="ENOENT")return this[ga]="w",this[kl]();throw t}else e=Wr.openSync(this[Po],this[ga],this[Eh]);this[Cp](null,e)}[Co](){if(this[Sl]&&typeof this[dt]=="number"){let e=this[dt];this[dt]=void 0,Wr.closeSync(e),this.emit("close")}}[bS](e){let t=!0;try{this[Ep](null,Wr.writeSync(this[dt],e,0,e.length,this[yl])),t=!1}finally{if(t)try{this[Co]()}catch{}}}},Pbe=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),Nbe=jbe.constants||{ZLIB_VERNUM:4736},Ss=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Nbe)),Mbe=cu.concat,hW=Object.getOwnPropertyDescriptor(cu,"concat"),aI=hW?.writable===!0||hW?.set!==void 0?(e)=>{cu.concat=e?Lbe:Mbe}:(e)=>{},uu=Symbol("_superWrite"),pS=class extends Error{code;errno;constructor(e,t){super("zlib: "+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+e.message,Error.captureStackTrace(this,t??this.constructor)}get name(){return"ZlibError"}},lI=Symbol("flushFlag"),GI=class extends pu{#e=!1;#n=!1;#r;#o;#i;#t;#s;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(e,t){if(!e||typeof e!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(e),this.#r=e.flush??0,this.#o=e.finishFlush??0,this.#i=e.fullFlushFlag??0,typeof gW[t]!="function")throw TypeError("Compression method not supported: "+t);try{this.#t=new gW[t](e)}catch(n){throw new pS(n,this.constructor)}this.#s=(n)=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#t?.on("error",(n)=>this.#s(new pS(n))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return RI(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#i),this.write(Object.assign(cu.alloc(0),{[lI]:e})))}end(e,t,n){return typeof e=="function"&&(n=e,t=void 0,e=void 0),typeof t=="function"&&(n=t,t=void 0),e&&(t?this.write(e,t):this.write(e)),this.flush(this.#o),this.#n=!0,super.end(n)}get ended(){return this.#n}[uu](e){return super.write(e)}write(e,t,n){if(typeof t=="function"&&(n=t,t="utf8"),typeof e=="string"&&(e=cu.from(e,t)),this.#e)return;RI(this.#t,"zlib binding closed");let r=this.#t._handle,i=r.close;r.close=()=>{};let o=this.#t.close;this.#t.close=()=>{},aI(!0);let s;try{let l=typeof e[lI]=="number"?e[lI]:this.#r;s=this.#t._processChunk(e,l),aI(!1)}catch(l){aI(!1),this.#s(new pS(l,this.write))}finally{this.#t&&(this.#t._handle=r,r.close=i,this.#t.close=o,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",(l)=>this.#s(new pS(l,this.write)));let a;if(s)if(Array.isArray(s)&&s.length>0){let l=s[0];a=this[uu](cu.from(l));for(let c=1;c<s.length;c++)a=this[uu](s[c])}else a=this[uu](cu.from(s));return n&&n(),a}},ZW=class extends GI{#e;#n;constructor(e,t){e=e||{},e.flush=e.flush||Ss.Z_NO_FLUSH,e.finishFlush=e.finishFlush||Ss.Z_FINISH,e.fullFlushFlag=Ss.Z_FULL_FLUSH,super(e,t),this.#e=e.level,this.#n=e.strategy}params(e,t){if(!this.sawError){if(!this.handle)throw Error("cannot switch params when binding is closed");if(!this.handle.params)throw Error("not supported in this implementation");if(this.#e!==e||this.#n!==t){this.flush(Ss.Z_SYNC_FLUSH),RI(this.handle,"zlib binding closed");let n=this.handle.flush;this.handle.flush=(r,i)=>{typeof r=="function"&&(i=r,r=this.flushFlag),this.flush(r),i?.()};try{this.handle.params(e,t)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#n=t)}}}},Ube=class extends ZW{#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[uu](e){return this.#e?(this.#e=!1,e[9]=255,super[uu](e)):super[uu](e)}},Fbe=class extends ZW{constructor(e){super(e,"Unzip")}},YW=class extends GI{constructor(e,t){e=e||{},e.flush=e.flush||Ss.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||Ss.BROTLI_OPERATION_FINISH,e.fullFlushFlag=Ss.BROTLI_OPERATION_FLUSH,super(e,t)}},zbe=class extends YW{constructor(e){super(e,"BrotliCompress")}},Hbe=class extends YW{constructor(e){super(e,"BrotliDecompress")}},XW=class extends GI{constructor(e,t){e=e||{},e.flush=e.flush||Ss.ZSTD_e_continue,e.finishFlush=e.finishFlush||Ss.ZSTD_e_end,e.fullFlushFlag=Ss.ZSTD_e_flush,super(e,t)}},Bbe=class extends XW{constructor(e){super(e,"ZstdCompress")}},Vbe=class extends XW{constructor(e){super(e,"ZstdDecompress")}},Ybe={};ube(Ybe,{code:()=>JI,isCode:()=>kS,isName:()=>Xbe,name:()=>LS,normalFsTypes:()=>t9});t9=new Set(["0","","1","2","3","4","5","6","7","D"]),LS=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),JI=new Map(Array.from(LS).map((e)=>[e[1],e[0]])),iSe={12:8589934591,8:2097151},lSe=Array(156).join("\x00"),mSe=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ne=mSe!=="win32"?(e)=>String(e):(e)=>String(e).replaceAll(/\\/g,"/"),fSe=class extends pu{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,t,n){switch(super({}),this.pause(),this.extended=t,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw Error("no path provided for tar.ReadEntry");this.path=Ne(e.path),this.mode=e.mode,this.mode&&(this.mode=this.mode&4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?Ne(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,t&&this.#e(t),n&&this.#e(n,!0)}write(e){let t=e.length;if(t>this.blockRemain)throw Error("writing more to entry than is appropriate");let n=this.remain,r=this.blockRemain;return this.remain=Math.max(0,n-t),this.blockRemain=Math.max(0,r-t),this.ignore?!0:n>=t?super.write(e):super.write(e.subarray(0,n))}#e(e,t=!1){e.path&&(e.path=Ne(e.path)),e.linkpath&&(e.linkpath=Ne(e.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,r])=>!(r==null||n==="path"&&t))))}},PI=Buffer.from([31,139]),CI=Buffer.from([40,181,47,253]),hSe=Math.max(PI.length,CI.length),Wi=Symbol("state"),iu=Symbol("writeEntry"),pa=Symbol("readEntry"),dI=Symbol("nextEntry"),yW=Symbol("processEntry"),vs=Symbol("extendedHeader"),fh=Symbol("globalExtendedHeader"),fl=Symbol("meta"),vW=Symbol("emitMeta"),Ut=Symbol("buffer"),ma=Symbol("queue"),gl=Symbol("ended"),pI=Symbol("emittedEnd"),ou=Symbol("emit"),rn=Symbol("unzip"),mS=Symbol("consumeChunk"),fS=Symbol("consumeChunkSub"),mI=Symbol("consumeBody"),wW=Symbol("consumeMeta"),_W=Symbol("consumeHeader"),gh=Symbol("consuming"),fI=Symbol("bufferConcat"),gS=Symbol("maybeEnd"),_p=Symbol("writing"),ws=Symbol("aborted"),hS=Symbol("onDone"),su=Symbol("sawValidEntry"),yS=Symbol("sawNullBlock"),vS=Symbol("sawEOF"),bW=Symbol("closeStream"),hh=Symbol("compressedBytesRead"),gI=Symbol("decompressedBytesRead"),SW=Symbol("checkDecompressionRatio"),Oh=class extends Tbe{file;strict;maxMetaEntrySize;filter;brotli;zstd;maxDecompressionRatio;writable=!0;readable=!1;[ma]=[];[Ut];[pa];[iu];[Wi]="begin";[fl]="";[vs];[fh];[gl]=!1;[rn];[ws]=!1;[su];[yS]=!1;[vS]=!1;[_p]=!1;[gh]=!1;[pI]=!1;[hh]=0;[gI]=0;constructor(e={}){super(),this.file=e.file||"",this.on(hS,()=>{(this[Wi]==="begin"||this[su]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(hS,e.ondone):this.on(hS,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxDecompressionRatio=typeof e.maxDecompressionRatio=="number"?e.maxDecompressionRatio:ySe,this.maxMetaEntrySize=e.maxMetaEntrySize||gSe,this.filter=typeof e.filter=="function"?e.filter:vSe;let t=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:t?void 0:!1;let n=e.file&&(e.file.endsWith(".tar.zst")||e.file.endsWith(".tzst"));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:n?!0:void 0,this.on("end",()=>this[bW]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,t,n={}){US(this,e,t,n)}[_W](e,t){this[su]===void 0&&(this[su]=!1);let n;try{n=new du(e,t,this[vs],this[fh])}catch(r){return this.warn("TAR_ENTRY_INVALID",r)}if(n.nullBlock)this[yS]?(this[vS]=!0,this[Wi]==="begin"&&(this[Wi]="header"),this[ou]("eof")):(this[yS]=!0,this[ou]("nullBlock"));else if(this[yS]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let r=n.type;if(/^(Symbolic)?Link$/.test(r)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(r)&&!/^(Global)?ExtendedHeader$/.test(r)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let i=this[iu]=new fSe(n,this[vs],this[fh]);if(!this[su])if(i.remain){let o=()=>{i.invalid||(this[su]=!0)};i.on("end",o)}else this[su]=!0;i.meta?i.size>this.maxMetaEntrySize?(i.ignore=!0,this[ou]("ignoredEntry",i),this[Wi]="ignore",i.resume()):i.size>0&&(this[fl]="",i.on("data",(o)=>this[fl]+=o),this[Wi]="meta"):(this[vs]=void 0,i.ignore=i.ignore||!this.filter(i.path,i),i.ignore?(this[ou]("ignoredEntry",i),this[Wi]=i.remain?"ignore":"header",i.resume()):(i.remain?this[Wi]="body":(this[Wi]="header",i.end()),this[pa]?this[ma].push(i):(this[ma].push(i),this[dI]())))}}}[bW](){queueMicrotask(()=>this.emit("close"))}[yW](e){let t=!0;if(!e)this[pa]=void 0,t=!1;else if(Array.isArray(e)){let[n,...r]=e;this.emit(n,...r)}else this[pa]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[dI]()),t=!1);return t}[dI](){do;while(this[yW](this[ma].shift()));if(this[ma].length===0){let e=this[pa];!e||e.flowing||e.size===e.remain?this[_p]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[mI](e,t){let n=this[iu];if(!n)throw Error("attempt to consume body without entry??");let r=n.blockRemain??0,i=r>=e.length&&t===0?e:e.subarray(t,t+r);return n.write(i),n.blockRemain||(this[Wi]="header",this[iu]=void 0,n.end()),i.length}[wW](e,t){let n=this[iu],r=this[mI](e,t);return!this[iu]&&n&&this[vW](n),r}[ou](e,t,n){this[ma].length===0&&!this[pa]?this.emit(e,t,n):this[ma].push([e,t,n])}[vW](e){switch(this[ou]("meta",this[fl]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[vs]=OS.parse(this[fl],this[vs],!1);break;case"GlobalExtendedHeader":this[fh]=OS.parse(this[fl],this[fh],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[vs]??Object.create(null);this[vs]=t,t.path=this[fl].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[vs]||Object.create(null);this[vs]=t,t.linkpath=this[fl].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+e.type)}}abort(e){if(!this[ws]){if(this[rn]){let t=this[rn];t.write=()=>!0,t.end=()=>t,t.emit=()=>!1,t.destroy?.()}this[ws]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}}[SW](e){this[gI]+=e.length;let t=this[gI]/this[hh];return t>this.maxDecompressionRatio?(this.abort(Error(`max decompression ratio exceeded: ${t.toFixed(2)} > ${this.maxDecompressionRatio}`)),!1):!0}write(e,t,n){if(typeof t=="function"&&(n=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8")),this[ws])return n?.(),!1;if((this[rn]===void 0||this.brotli===void 0&&this[rn]===!1)&&e){if(this[Ut]&&(e=Buffer.concat([this[Ut],e]),this[Ut]=void 0),e.length<hSe)return this[Ut]=e,n?.(),!0;for(let s=0;this[rn]===void 0&&s<PI.length;s++)e[s]!==PI[s]&&(this[rn]=!1);let i=!1;if(this[rn]===!1&&this.zstd!==!1){i=!0;for(let s=0;s<CI.length;s++)if(e[s]!==CI[s]){i=!1;break}}let o=this.brotli===void 0&&!i;if(this[rn]===!1&&o)if(e.length<512)if(this[gl])this.brotli=!0;else return this[Ut]=e,n?.(),!0;else try{new du(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[rn]===void 0||this[rn]===!1&&(this.brotli||i)){let s=this[gl];this[gl]=!1,this[rn]=this[rn]===void 0?new Fbe({}):i?new Vbe({}):new Hbe({}),this[rn].on("data",(l)=>{this[SW](l)&&this[mS](l)}),this[rn].on("error",(l)=>{this[ws]||this.abort(l)}),this[rn].on("end",()=>{this[gl]=!0,this[mS]()}),this[_p]=!0,this[hh]+=e.length;let a=!!this[rn][s?"end":"write"](e);return this[_p]=!1,n?.(),a}}this[_p]=!0,this[rn]?(this[hh]+=e.length,this[rn].write(e)):this[mS](e),this[_p]=!1;let r=this[ma].length>0?!1:this[pa]?this[pa].flowing:!0;return!r&&this[ma].length===0&&this[pa]?.once("drain",()=>this.emit("drain")),n?.(),r}[fI](e){e&&!this[ws]&&(this[Ut]=this[Ut]?Buffer.concat([this[Ut],e]):e)}[gS](){if(this[gl]&&!this[pI]&&!this[ws]&&!this[gh]){this[pI]=!0;let e=this[iu];if(e?.blockRemain){let t=this[Ut]?this[Ut].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`,{entry:e}),this[Ut]&&e.write(this[Ut]),e.end()}this[ou](hS)}}[mS](e){if(this[gh]&&e)this[fI](e);else if(!e&&!this[Ut])this[gS]();else if(e){if(this[gh]=!0,this[Ut]){this[fI](e);let t=this[Ut];this[Ut]=void 0,this[fS](t)}else this[fS](e);for(;this[Ut]&&this[Ut]?.length>=512&&!this[ws]&&!this[vS];){let t=this[Ut];this[Ut]=void 0,this[fS](t)}this[gh]=!1}(!this[Ut]||this[gl])&&this[gS]()}[fS](e){let t=0,n=e.length;for(;t+512<=n&&!this[ws]&&!this[vS];)switch(this[Wi]){case"begin":case"header":this[_W](e,t),t+=512;break;case"ignore":case"body":t+=this[mI](e,t);break;case"meta":t+=this[wW](e,t);break;default:throw Error("invalid state: "+this[Wi])}t<n&&(this[Ut]=this[Ut]?Buffer.concat([e.subarray(t),this[Ut]]):e.subarray(t))}end(e,t,n){return typeof e=="function"&&(n=e,t=void 0,e=void 0),typeof t=="function"&&(n=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,t)),n&&this.once("finish",n),this[ws]||(this[rn]?(e&&(this[hh]+=e.length,this[rn].write(e)),this[rn].end()):(this[gl]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e=e||Buffer.alloc(0)),e&&this.write(e),this[gS]())),this}},El=Dh(_Se,bSe,(e)=>new Oh(e),(e)=>new Oh(e),(e,t)=>{t?.length&&n9(e,t),e.noResume||wSe(e)}),{isAbsolute:kSe,parse:EW}=SSe,FS=["|","<",">","?",":"],YI=FS.map((e)=>String.fromCodePoint(61440+Number(e.codePointAt(0)))),ESe=new Map(FS.map((e,t)=>[e,YI[t]])),ASe=new Map(YI.map((e,t)=>[e,FS[t]])),RW=Symbol("process"),PW=Symbol("file"),CW=Symbol("directory"),$I=Symbol("symlink"),$W=Symbol("hardlink"),yh=Symbol("header"),ES=Symbol("read"),xI=Symbol("lstat"),AS=Symbol("onlstat"),II=Symbol("onread"),OI=Symbol("onreadlink"),DI=Symbol("openfile"),TI=Symbol("onopenfile"),_l=Symbol("close"),TS=Symbol("mode"),jI=Symbol("awaitDrain"),hI=Symbol("ondrain"),bs=Symbol("prefix"),o9=class extends pu{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,t={}){let n=KI(t);super(),this.path=Ne(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||PSe,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=Ne(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?Ne(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let r=!1;if(!this.preservePaths){let[o,s]=ZI(this.path);o&&typeof s=="string"&&(this.path=s,r=o)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=RSe(this.path.replaceAll(/\\/g,"/")),e=e.replaceAll(/\\/g,"/")),this.absolute=Ne(n.absolute||kW.resolve(this.cwd,e)),this.path===""&&(this.path="./"),r&&this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:this,path:r+this.path});let i=this.statCache.get(this.absolute);i?this[AS](i):this[xI]()}warn(e,t,n={}){return US(this,e,t,n)}emit(e,...t){return e==="error"&&(this.#e=!0),super.emit(e,...t)}[xI](){_s.lstat(this.absolute,(e,t)=>{if(e)return this.emit("error",e);this[AS](t)})}[AS](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=xSe(e),this.emit("stat",e),this[RW]()}[RW](){switch(this.type){case"File":return this[PW]();case"Directory":return this[CW]();case"SymbolicLink":return this[$I]();default:return this.end()}}[TS](e){return r9(e,this.type==="Directory",this.portable)}[bs](e){return i9(e,this.prefix)}[yh](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new du({path:this[bs](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bs](this.linkpath):this.linkpath,mode:this[TS](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new OS({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[bs](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bs](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw Error("failed to encode header");super.write(e)}[CW](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[yh](),this.end()}[$I](){_s.readlink(this.absolute,(e,t)=>{if(e)return this.emit("error",e);this[OI](t)})}[OI](e){this.linkpath=Ne(e),this[yh](),this.end()}[$W](e){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=Ne(kW.relative(this.cwd,e)),this.stat.size=0,this[yh](),this.end()}[PW](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,t=this.linkCache.get(e);if(t?.indexOf(this.cwd)===0)return this[$W](t);this.linkCache.set(e,this.absolute)}if(this[yh](),this.stat.size===0)return this.end();this[DI]()}[DI](){_s.open(this.absolute,"r",(e,t)=>{if(e)return this.emit("error",e);this[TI](t)})}[TI](e){if(this.fd=e,this.#e)return this[_l]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let t=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(t),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ES]()}[ES](){let{fd:e,buf:t,offset:n,length:r,pos:i}=this;if(e===void 0||t===void 0)throw Error("cannot read file without first opening");_s.read(e,t,n,r,i,(o,s)=>{if(o)return this[_l](()=>this.emit("error",o));this[II](s)})}[_l](e=()=>{}){this.fd!==void 0&&_s.close(this.fd,e)}[II](e){if(e<=0&&this.remain>0){let n=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[_l](()=>this.emit("error",n))}if(e>this.remain){let n=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[_l](()=>this.emit("error",n))}if(!this.buf)throw Error("should have created buffer prior to reading");if(e===this.remain)for(let n=e;n<this.length&&e<this.blockRemain;n++)this.buf[n+this.offset]=0,e++,this.remain++;let t=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(t)?this[hI]():this[jI](()=>this[hI]())}[jI](e){this.once("drain",e)}write(e,t,n){if(typeof t=="function"&&(n=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8")),this.blockRemain<e.length){let r=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",r)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,n)}[hI](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[_l]((e)=>e?this.emit("error",e):this.end());if(!this.buf)throw Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[ES]()}},CSe=class extends o9{sync=!0;[xI](){this[AS](_s.lstatSync(this.absolute))}[$I](){this[OI](_s.readlinkSync(this.absolute))}[DI](){this[TI](_s.openSync(this.absolute,"r"))}[ES](){let e=!0;try{let{fd:t,buf:n,offset:r,length:i,pos:o}=this;if(t===void 0||n===void 0)throw Error("fd and buf must be set in READ method");let s=_s.readSync(t,n,r,i,o);this[II](s),e=!1}finally{if(e)try{this[_l](()=>{})}catch{}}}[jI](e){e()}[_l](e=()=>{}){this.fd!==void 0&&_s.closeSync(this.fd),e()}},$Se=class extends pu{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(e,t,n={}){return US(this,e,t,n)}constructor(e,t={}){let n=KI(t);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.onWriteEntry,this.readEntry=e;let{type:r}=e;if(r==="Unsupported")throw Error("writing entry that should be ignored");this.type=r,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=Ne(e.path),this.mode=e.mode!==void 0?this[TS](e.mode):void 0,this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath!==void 0?Ne(e.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let i=!1;if(!this.preservePaths){let[s,a]=ZI(this.path);s&&typeof a=="string"&&(this.path=a,i=s)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.onWriteEntry?.(this),this.header=new du({path:this[bs](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bs](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path}),this.header.encode()&&!this.noPax&&super.write(new OS({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[bs](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bs](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let o=this.header?.block;if(!o)throw Error("failed to encode header");super.write(o),e.pipe(this)}[bs](e){return i9(e,this.prefix)}[TS](e){return r9(e,this.type==="Directory",this.portable)}write(e,t,n){typeof t=="function"&&(n=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8"));let r=e.length;if(r>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=r,super.write(e,n)}end(e,t,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e=="function"&&(n=e,t=void 0,e=void 0),typeof t=="function"&&(n=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,t??"utf8")),n&&this.once("finish",n),e?super.end(e,n):super.end(n),this}},ISe=class e{tail;head;length=0;static create(t=[]){return new e(t)}constructor(t=[]){for(let n of t)this.push(n)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw Error("removing node which does not belong to this list");let{next:n,prev:r}=t;return n&&(n.prev=r),r&&(r.next=n),t===this.head&&(this.head=n),t===this.tail&&(this.tail=r),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,n}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);let n=this.head;t.list=this,t.next=n,n&&(n.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);let n=this.tail;t.list=this,t.prev=n,n&&(n.next=t),this.tail=t,this.head||(this.head=t),this.length++}push(...t){for(let n=0,r=t.length;n<r;n++)DSe(this,t[n]);return this.length}unshift(...t){for(var n=0,r=t.length;n<r;n++)TSe(this,t[n]);return this.length}pop(){if(!this.tail)return;let t=this.tail.value,n=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,n.list=void 0,this.length--,t}shift(){if(!this.head)return;let t=this.head.value,n=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,n.list=void 0,this.length--,t}forEach(t,n){n=n||this;for(let r=this.head,i=0;r;i++)t.call(n,r.value,i,this),r=r.next}forEachReverse(t,n){n=n||this;for(let r=this.tail,i=this.length-1;r;i--)t.call(n,r.value,i,this),r=r.prev}get(t){let n=0,r=this.head;for(;r&&n<t;n++)r=r.next;if(n===t&&r)return r.value}getReverse(t){let n=0,r=this.tail;for(;r&&n<t;n++)r=r.prev;if(n===t&&r)return r.value}map(t,n){n=n||this;let r=new e;for(let i=this.head;i;)r.push(t.call(n,i.value,this)),i=i.next;return r}mapReverse(t,n){n=n||this;var r=new e;for(let i=this.tail;i;)r.push(t.call(n,i.value,this)),i=i.prev;return r}reduce(t,n){let r,i=this.head;if(arguments.length>1)r=n;else if(this.head)i=this.head.next,r=this.head.value;else throw TypeError("Reduce of empty list with no initial value");for(var o=0;i;o++)r=t(r,i.value,o),i=i.next;return r}reduceReverse(t,n){let r,i=this.tail;if(arguments.length>1)r=n;else if(this.tail)i=this.tail.prev,r=this.tail.value;else throw TypeError("Reduce of empty list with no initial value");for(let o=this.length-1;i;o--)r=t(r,i.value,o),i=i.prev;return r}toArray(){let t=Array(this.length);for(let n=0,r=this.head;r;n++)t[n]=r.value,r=r.next;return t}toArrayReverse(){let t=Array(this.length);for(let n=0,r=this.tail;r;n++)t[n]=r.value,r=r.prev;return t}slice(t=0,n=this.length){n<0&&(n+=this.length),t<0&&(t+=this.length);let r=new e;if(n<t||n<0)return r;t<0&&(t=0),n>this.length&&(n=this.length);let i=this.head,o=0;for(o=0;i&&o<t;o++)i=i.next;for(;i&&o<n;o++,i=i.next)r.push(i.value);return r}sliceReverse(t=0,n=this.length){n<0&&(n+=this.length),t<0&&(t+=this.length);let r=new e;if(n<t||n<0)return r;t<0&&(t=0),n>this.length&&(n=this.length);let i=this.length,o=this.tail;for(;o&&i>n;i--)o=o.prev;for(;o&&i>t;i--,o=o.prev)r.push(o.value);return r}splice(t,n=0,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let i=this.head;for(let s=0;i&&s<t;s++)i=i.next;let o=[];for(let s=0;i&&s<n;s++)o.push(i.value),i=this.removeNode(i);i?i!==this.tail&&(i=i.prev):i=this.tail;for(let s of r)i=OSe(this,i,s);return o}reverse(){let t=this.head,n=this.tail;for(let r=t;r;r=r.prev){let i=r.prev;r.prev=r.next,r.next=i}return this.head=n,this.tail=t,this}};OW=Buffer.alloc(1024),RS=Symbol("onStat"),vh=Symbol("ended"),Ao=Symbol("queue"),wh=Symbol("pendingLinks"),hl=Symbol("current"),au=Symbol("process"),_h=Symbol("processing"),wS=Symbol("processJob"),Ro=Symbol("jobs"),yI=Symbol("jobDone"),PS=Symbol("addFSEntry"),DW=Symbol("addTarEntry"),NI=Symbol("stat"),MI=Symbol("readdir"),CS=Symbol("onreaddir"),$S=Symbol("pipe"),TW=Symbol("entry"),vI=Symbol("entryOpt"),xS=Symbol("writeEntryClass"),s9=Symbol("write"),wI=Symbol("ondrain"),zS=class extends pu{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[xS];onWriteEntry;[Ao];[wh]=new Map;[Ro]=0;[_h]=!1;[vh]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||"",this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=Ne(e.prefix||""),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[xS]=o9,typeof e.onwarn=="function"&&this.on("warn",e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli||e.zstd){if((e.gzip?1:0)+(e.brotli?1:0)+(e.zstd?1:0)>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(e.gzip&&(typeof e.gzip!="object"&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new Ube(e.gzip)),e.brotli&&(typeof e.brotli!="object"&&(e.brotli={}),this.zip=new zbe(e.brotli)),e.zstd&&(typeof e.zstd!="object"&&(e.zstd={}),this.zip=new Bbe(e.zstd)),!this.zip)throw Error("impossible");let t=this.zip;t.on("data",(n)=>super.write(n)),t.on("end",()=>super.end()),t.on("drain",()=>this[wI]()),this.on("resume",()=>t.resume())}else this.on("drain",this[wI]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter=="function"?e.filter:()=>!0,this[Ao]=new ISe,this[Ro]=0,this.jobs=Number(e.jobs)||4,this[_h]=!1,this[vh]=!1}[s9](e){return super.write(e)}add(e){return this.write(e),this}end(e,t,n){return typeof e=="function"&&(n=e,e=void 0),typeof t=="function"&&(n=t,t=void 0),e&&this.add(e),this[vh]=!0,this[au](),n&&n(),this}write(e){if(this[vh])throw Error("write after end");return typeof e=="string"?this[PS](e):this[DW](e),this.flowing}[DW](e){let t=Ne(xW.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new IW(e.path,t);n.entry=new $Se(e,this[vI](n)),n.entry.on("end",()=>this[yI](n)),this[Ro]+=1,this[Ao].push(n)}this[au]()}[PS](e){let t=Ne(xW.resolve(this.cwd,e));this[Ao].push(new IW(e,t)),this[au]()}[NI](e){e.pending=!0,this[Ro]+=1;let t=this.follow?"stat":"lstat";DS[t](e.absolute,(n,r)=>{e.pending=!1,this[Ro]-=1,n?this.emit("error",n):this[RS](e,r)})}[RS](e,t){if(this.statCache.set(e.absolute,t),e.stat=t,!this.filter(e.path,t))e.ignore=!0;else if(t.isFile()&&t.nlink>1&&!this.linkCache.get(`${t.dev}:${t.ino}`)&&!this.sync)if(e===this[hl])this[wS](e);else{let n=`${t.dev}:${t.ino}`,r=this[wh].get(n);r?r.push(e):this[wh].set(n,[e]),e.pendingLink=!0,e.pending=!0}this[au]()}[MI](e){e.pending=!0,this[Ro]+=1,DS.readdir(e.absolute,(t,n)=>{if(e.pending=!1,this[Ro]-=1,t)return this.emit("error",t);this[CS](e,n)})}[CS](e,t){this.readdirCache.set(e.absolute,t),e.readdir=t,this[au]()}[au](){if(!this[_h]){this[_h]=!0;for(let e=this[Ao].head;e&&this[Ro]<this.jobs;e=e.next)if(this[wS](e.value),e.value.ignore){let t=e.next;this[Ao].removeNode(e),e.next=t}this[_h]=!1,this[vh]&&this[Ao].length===0&&this[Ro]===0&&(this.zip?this.zip.end(OW):(super.write(OW),super.end()))}}get[hl](){return this[Ao]&&this[Ao].head&&this[Ao].head.value}[yI](e){this[Ao].shift(),this[Ro]-=1;let{stat:t}=e;if(t&&t.isFile()&&t.nlink>1){let n=`${t.dev}:${t.ino}`,r=this[wh].get(n);if(r){this[wh].delete(n);for(let i of r)i.pending=!1,this[wS](i)}}this[au]()}[wS](e){if(e.pending&&e.pendingLink&&e===this[hl]&&(e.pending=!1,e.pendingLink=!1),!e.pending){if(e.entry){e===this[hl]&&!e.piped&&this[$S](e);return}if(!e.stat){let t=this.statCache.get(e.absolute);t?this[RS](e,t):this[NI](e)}if(e.stat&&!e.ignore){if(!this.noDirRecurse&&e.stat.isDirectory()&&!e.readdir){let t=this.readdirCache.get(e.absolute);if(t?this[CS](e,t):this[MI](e),!e.readdir)return}if(e.entry=this[TW](e),!e.entry){e.ignore=!0;return}e===this[hl]&&!e.piped&&this[$S](e)}}}[vI](e){return{onwarn:(t,n,r)=>this.warn(t,n,r),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[TW](e){this[Ro]+=1;try{return new this[xS](e.path,this[vI](e)).on("end",()=>this[yI](e)).on("error",(t)=>this.emit("error",t))}catch(t){this.emit("error",t)}}[wI](){this[hl]&&this[hl].entry&&this[hl].entry.resume()}[$S](e){e.piped=!0,e.readdir&&e.readdir.forEach((r)=>{let i=e.path,o=i==="./"?"":i.replace(/\/*$/,"/");this[PS](o+r)});let t=e.entry,n=this.zip;if(!t)throw Error("cannot pipe without source");n?t.on("data",(r)=>{n.write(r)||t.pause()}):t.on("data",(r)=>{super.write(r)||t.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,t,n={}){US(this,e,t,n)}},QI=class extends zS{sync=!0;constructor(e){super(e),this[xS]=CSe}pause(){}resume(){}[NI](e){let t=this.follow?"statSync":"lstatSync";this[RS](e,DS[t](e.absolute))}[MI](e){this[CS](e,DS.readdirSync(e.absolute))}[$S](e){let t=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach((r)=>{let i=e.path,o=i==="./"?"":i.replace(/\/*$/,"/");this[PS](o+r)}),!t)throw Error("Cannot pipe without source");n?t.on("data",(r)=>{n.write(r)}):t.on("data",(r)=>{super[s9](r)})}},eO=Dh(jSe,NSe,MSe,LSe,(e,t)=>{if(!t?.length)throw TypeError("no paths specified to add to archive")}),FSe=process.env.__FAKE_PLATFORM__||process.platform,p9=FSe==="win32",{O_CREAT:m9,O_NOFOLLOW:jW,O_TRUNC:f9,O_WRONLY:g9}=d9.constants,h9=Number(process.env.__FAKE_FS_O_FILENAME__)||d9.constants.UV_FS_O_FILEMAP||0,zSe=p9&&!!h9,BSe=h9|f9|m9|g9,NW=!p9&&typeof jW=="number"?jW|f9|m9|g9:null,y9=NW!==null?()=>NW:zSe?(e)=>e<HSe?BSe:"w":()=>"w",_9=class extends Error{path;code;syscall="chdir";constructor(e,t){super(`${t}: Cannot cd into '${e}'`),this.path=e,this.code=t}get name(){return"CwdError"}},BS=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,t){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=t}get name(){return"SymlinkError"}},_I=Object.create(null),bp=new Set,XSe=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,QSe=XSe==="win32",LW=Symbol("onEntry"),FI=Symbol("checkFs"),UW=Symbol("checkFs2"),zI=Symbol("isReusable"),Ki=Symbol("makeFs"),HI=Symbol("file"),BI=Symbol("directory"),IS=Symbol("link"),FW=Symbol("symlink"),zW=Symbol("hardlink"),kh=Symbol("ensureNoSymlink"),HW=Symbol("unsupported"),BW=Symbol("checkPath"),bI=Symbol("stripAbsolutePath"),bl=Symbol("mkdir"),Nn=Symbol("onError"),_S=Symbol("pending"),VW=Symbol("pend"),Sp=Symbol("unpend"),SI=Symbol("ended"),kI=Symbol("maybeClose"),VI=Symbol("skip"),Ph=Symbol("doChown"),Ch=Symbol("uid"),$h=Symbol("gid"),xh=Symbol("checkedCwd"),rke=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ih=rke==="win32",tO=class extends Oh{[SI]=!1;[xh]=!1;[_S]=0;reservations=new tke;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[SI]=!0,this[kI]()},super(e),this.transform=e.transform,this.chmod=!!e.chmod,typeof e.uid=="number"||typeof e.gid=="number"){if(typeof e.uid!="number"||typeof e.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(e.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=e.preserveOwner===void 0&&typeof e.uid!="number"?process.getuid?.()===0:!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:ike,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||Ih,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=Ne(An.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask=="number"?e.processUmask:nke():0,this.umask=typeof e.umask=="number"?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on("entry",(t)=>this[LW](t))}warn(e,t,n={}){return(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(n.recoverable=!1),super.warn(e,t,n)}[kI](){this[SI]&&this[_S]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[bI](e,t){let n=e[t],{type:r}=e;if(!n||this.preservePaths)return!0;let[i,o]=ZI(n),s=o.replaceAll(/\\/g,"/").split("/");if(s.includes("..")||Ih&&/^[a-z]:\.\.$/i.test(s[0]??"")){if(t==="path"||r==="Link")return this.warn("TAR_ENTRY_ERROR",`${t} contains '..'`,{entry:e,[t]:n}),!1;let a=An.posix.dirname(e.path),l=An.posix.normalize(An.posix.join(a,s.join("/")));if(l.startsWith("../")||l==="..")return this.warn("TAR_ENTRY_ERROR",`${t} escapes extraction directory`,{entry:e,[t]:n}),!1}return i&&(e[t]=String(o),this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute ${t}`,{entry:e,[t]:n})),!0}[BW](e){let t=Ne(e.path),n=t.split("/");if(this.strip){if(n.length<this.strip)return!1;if(e.type==="Link"){let r=Ne(String(e.linkpath)).split("/");if(r.length>=this.strip)e.linkpath=r.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),e.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:t,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this[bI](e,"path")||!this[bI](e,"linkpath"))return!1;if(e.absolute=An.isAbsolute(e.path)?Ne(An.resolve(e.path)):Ne(An.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute=="string"&&e.absolute.indexOf(this.cwd+"/")!==0&&e.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:Ne(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!=="Directory"&&e.type!=="GNUDumpDir")return!1;if(this.win32){let{root:r}=An.win32.parse(String(e.absolute));e.absolute=r+AW(String(e.absolute).slice(r.length));let{root:i}=An.win32.parse(e.path);e.path=i+AW(e.path.slice(i.length))}return!0}[LW](e){if(!this[BW](e))return e.resume();switch(USe.equal(typeof e.absolute,"string"),e.type){case"Directory":case"GNUDumpDir":e.mode&&(e.mode=e.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[FI](e);default:return this[HW](e)}}[Nn](e,t){e.name==="CwdError"?this.emit("error",e):(this.warn("TAR_ENTRY_ERROR",e,{entry:t}),this[Sp](),t.resume())}[bl](e,t,n){GSe(Ne(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:t},n)}[Ph](e){return this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Ch](e){return qW(this.uid,e.uid,this.processUid)}[$h](e){return qW(this.gid,e.gid,this.processGid)}[HI](e,t){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,r=new MS(String(e.absolute),{flags:y9(e.size),mode:n,autoClose:!1});r.on("error",(a)=>{r.fd&&Ke.close(r.fd,()=>{}),r.write=()=>!0,this[Nn](a,e),t()});let i=1,o=(a)=>{if(a){r.fd&&Ke.close(r.fd,()=>{}),this[Nn](a,e),t();return}--i===0&&r.fd!==void 0&&Ke.close(r.fd,(l)=>{l?this[Nn](l,e):this[Sp](),t()})};r.on("finish",()=>{let a=String(e.absolute),l=r.fd;if(typeof l=="number"&&e.mtime&&!this.noMtime){i++;let c=e.atime||new Date,u=e.mtime;Ke.futimes(l,c,u,(d)=>d?Ke.utimes(a,c,u,(p)=>o(p&&d)):o())}if(typeof l=="number"&&this[Ph](e)){i++;let c=this[Ch](e),u=this[$h](e);typeof c=="number"&&typeof u=="number"&&Ke.fchown(l,c,u,(d)=>d?Ke.chown(a,c,u,(p)=>o(p&&d)):o())}o()});let s=this.transform&&this.transform(e)||e;s!==e&&(s.on("error",(a)=>{this[Nn](a,e),t()}),e.pipe(s)),s.pipe(r)}[BI](e,t){let n=typeof e.mode=="number"?e.mode&4095:this.dmode;this[bl](String(e.absolute),n,(r)=>{if(r){this[Nn](r,e),t();return}let i=1,o=()=>{--i===0&&(t(),this[Sp](),e.resume())};e.mtime&&!this.noMtime&&(i++,Ke.utimes(String(e.absolute),e.atime||new Date,e.mtime,o)),this[Ph](e)&&(i++,Ke.chown(String(e.absolute),Number(this[Ch](e)),Number(this[$h](e)),o)),o()})}[HW](e){e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[FW](e,t){let n=Ne(An.relative(this.cwd,An.resolve(An.dirname(String(e.absolute)),String(e.linkpath)))).split("/");this[kh](e,this.cwd,n,()=>this[IS](e,String(e.linkpath),"symlink",t),(r)=>{this[Nn](r,e),t()})}[zW](e,t){let n=Ne(An.resolve(this.cwd,String(e.linkpath))),r=Ne(String(e.linkpath)).split("/");this[kh](e,this.cwd,r,()=>this[IS](e,n,"link",t),(i)=>{this[Nn](i,e),t()})}[kh](e,t,n,r,i){let o=n.shift();if(this.preservePaths||o===void 0)return r();let s=An.resolve(t,o);Ke.lstat(s,(a,l)=>{if(a)return r();if(l?.isSymbolicLink())return i(new BS(s,An.resolve(s,n.join("/"))));this[kh](e,s,n,r,i)})}[VW](){this[_S]++}[Sp](){this[_S]--,this[kI]()}[VI](e){this[Sp](),e.resume()}[zI](e,t){return e.type==="File"&&!this.unlink&&t.isFile()&&t.nlink<=1&&!Ih}[FI](e){this[VW]();let t=[e.path];e.linkpath&&t.push(e.linkpath),this.reservations.reserve(t,(n)=>this[UW](e,n))}[UW](e,t){let n=(s)=>{t(s)},r=()=>{this[bl](this.cwd,this.dmode,(s)=>{if(s){this[Nn](s,e),n();return}this[xh]=!0,i()})},i=()=>{if(e.absolute!==this.cwd){let s=Ne(An.dirname(String(e.absolute)));if(s!==this.cwd)return this[bl](s,this.dmode,(a)=>{if(a){this[Nn](a,e),n();return}o()})}o()},o=()=>{Ke.lstat(String(e.absolute),(s,a)=>{if(a&&(this.keep||this.newer&&a.mtime>(e.mtime??a.mtime))){this[VI](e),n();return}if(s||this[zI](e,a))return this[Ki](null,e,n);if(a.isDirectory()){if(e.type==="Directory"){let l=this.chmod&&e.mode&&(a.mode&4095)!==e.mode,c=(u)=>this[Ki](u??null,e,n);return l?Ke.chmod(String(e.absolute),Number(e.mode),c):c()}if(e.absolute!==this.cwd)return Ke.rmdir(String(e.absolute),(l)=>this[Ki](l??null,e,n))}if(e.absolute===this.cwd)return this[Ki](null,e,n);oke(String(e.absolute),(l)=>this[Ki](l??null,e,n))})};this[xh]?i():r()}[Ki](e,t,n){if(e){this[Nn](e,t),n();return}switch(t.type){case"File":case"OldFile":case"ContiguousFile":return this[HI](t,n);case"Link":return this[zW](t,n);case"SymbolicLink":return this[FW](t,n);case"Directory":case"GNUDumpDir":return this[BI](t,n)}}[IS](e,t,n,r){Ke[n](t,String(e.absolute),(i)=>{i?this[Nn](i,e):(this[Sp](),e.resume()),r()})}},k9=class extends tO{sync=!0;[Ki](e,t){return super[Ki](e,t,()=>{})}[FI](e){if(!this[xh]){let i=this[bl](this.cwd,this.dmode);if(i)return this[Nn](i,e);this[xh]=!0}if(e.absolute!==this.cwd){let i=Ne(An.dirname(String(e.absolute)));if(i!==this.cwd){let o=this[bl](i,this.dmode);if(o)return this[Nn](o,e)}}let[t,n]=bh(()=>Ke.lstatSync(String(e.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(e.mtime??n.mtime)))return this[VI](e);if(t||this[zI](e,n))return this[Ki](null,e);if(n.isDirectory()){if(e.type==="Directory"){let o=this.chmod&&e.mode&&(n.mode&4095)!==e.mode,[s]=o?bh(()=>{Ke.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[Ki](s,e)}let[i]=bh(()=>Ke.rmdirSync(String(e.absolute)));this[Ki](i,e)}let[r]=e.absolute===this.cwd?[]:bh(()=>ske(String(e.absolute)));this[Ki](r,e)}[HI](e,t){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,r=(s)=>{let a;try{Ke.closeSync(i)}catch(l){a=l}(s||a)&&this[Nn](s||a,e),t()},i;try{i=Ke.openSync(String(e.absolute),y9(e.size),n)}catch(s){return r(s)}let o=this.transform&&this.transform(e)||e;o!==e&&(o.on("error",(s)=>this[Nn](s,e)),e.pipe(o)),o.on("data",(s)=>{try{Ke.writeSync(i,s,0,s.length)}catch(a){r(a)}}),o.on("end",()=>{let s=null;if(e.mtime&&!this.noMtime){let a=e.atime||new Date,l=e.mtime;try{Ke.futimesSync(i,a,l)}catch(c){try{Ke.utimesSync(String(e.absolute),a,l)}catch{s=c}}}if(this[Ph](e)){let a=this[Ch](e),l=this[$h](e);try{Ke.fchownSync(i,Number(a),Number(l))}catch(c){try{Ke.chownSync(String(e.absolute),Number(a),Number(l))}catch{s=s||c}}}r(s)})}[BI](e,t){let n=typeof e.mode=="number"?e.mode&4095:this.dmode,r=this[bl](String(e.absolute),n);if(r){this[Nn](r,e),t();return}if(e.mtime&&!this.noMtime)try{Ke.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[Ph](e))try{Ke.chownSync(String(e.absolute),Number(this[Ch](e)),Number(this[$h](e)))}catch{}t(),e.resume()}[bl](e,t){try{return ZSe(Ne(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:t})}catch(n){return n}}[kh](e,t,n,r,i){if(this.preservePaths||n.length===0)return r();let o=t;for(let s of n){o=An.resolve(o,s);let[a,l]=bh(()=>Ke.lstatSync(o));if(a)return r();if(l.isSymbolicLink())return i(new BS(o,An.resolve(t,n.join("/"))))}r()}[IS](e,t,n,r){let i=`${n}Sync`;try{Ke[i](t,String(e.absolute)),r(),e.resume()}catch(o){return this[Nn](o,e)}}},Th=Dh(ake,lke,(e)=>new k9(e),(e)=>new tO(e),(e,t)=>{t?.length&&n9(e,t)}),Sh=Dh(cke,dke,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(e,t)=>{if(!Obe(e))throw TypeError("file is required");if(e.gzip||e.brotli||e.zstd||e.file.endsWith(".br")||e.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!t?.length)throw TypeError("no paths specified to add/replace")}),Fyt=Dh(Sh.syncFile,Sh.asyncFile,Sh.syncNoFile,Sh.asyncNoFile,(e,t=[])=>{Sh.validate?.(e,t),fke(e)})});var R9=()=>{};function P9(e){return Array.from(e.trim()).length}var rO=2,iO=500;var oO=200,C9="^[A-Za-z0-9][A-Za-z0-9._-]{0,199}(/[A-Za-z0-9][A-Za-z0-9._-]{0,199}){0,3}$",$9;var x9=b(()=>{$9=["download","content","install"]});var VS=b(()=>{R9();x9()});function yke(e){let t=e.split("/");return t.length>1&&hke.has(t[t.length-1]??"")}function Xt(e){return e.length<=oO&&gke.test(e)&&!yke(e)}function mu(e){if(!Xt(e))throw new qS(e)}function $p(e){let n=e.toLowerCase().replace(/[^a-z0-9._]+/g,"-").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").substring(0,oO)||"unnamed-skill";return mu(n),n}var gke,hke,qS;var $o=b(()=>{VS();gke=new RegExp(C9),hke=new Set($9);qS=class qS extends Error{constructor(e){super(`Invalid skill_key: ${JSON.stringify(e)}`);this.name="SkillKeyValidationError"}}});import{createHash as vke}from"node:crypto";import{existsSync as sO,lstatSync as wke,mkdirSync as I9,mkdtempSync as _ke,realpathSync as bke,renameSync as aO,rmSync as O9}from"node:fs";import{lstat as D9,readdir as Ske,realpath as WS}from"node:fs/promises";import{basename as T9,dirname as lO,isAbsolute as kke,join as KS,relative as Eke,resolve as Ake}from"node:path";import{createGunzip as Rke,gunzipSync as Pke}from"node:zlib";function uO(e){return e==="File"||e==="OldFile"||e==="ContiguousFile"}function Cke(e){return uO(e)||e==="Directory"}function j9(e){return e.split(/[\\/]/).some((t)=>t.toLowerCase().startsWith(".clawdi-managed"))}function N9(e){let t=e.limits??GS,n="fileCount"in t?t.fileCount:void 0,r=e.resourceLabel??"Skill archive",i=0,o=0,s=0;return(a,l)=>{if(e.filter&&!e.filter(a,l))return!1;if(a.includes("..")||a.startsWith("/"))return!1;if(!e.allowReservedManagementPaths&&j9(a))throw Error(`${r} contains reserved management metadata`);let c="type"in l?l.type:void 0;if(!Cke(c))throw Error(`${r} contains an unsupported entry type`);if(i+=1,i>t.entryCount)throw Error(`${r} exceeds ${t.entryCount} entries`);let u=l.size;if(!Number.isSafeInteger(u)||u<0)throw Error(`${r} contains an invalid entry size`);if(u>t.entryBytes)throw Error(`${r} entry exceeds ${t.entryBytes} bytes`);if(uO(c)){if(o+=1,n!==void 0&&o>n)throw Error(`${r} exceeds ${n} files`)}if(s+=u,s>t.totalEntryBytes)throw Error(`${r} exceeds ${t.totalEntryBytes} total entry bytes`);return!0}}function xo(e,t,n={}){let r=n.limits??GS,i=n.resourceLabel??"Skill archive";return $ke(t,r.expandedTarBytes,i).then(()=>new Promise((o,s)=>{let a=Th({cwd:e,gzip:!0,filter:N9(n)});a.on("close",()=>o()),a.on("error",s),a.end(t)}))}function M9(e,t,n={}){let r=n.limits??GS,i=n.resourceLabel??"Skill archive",o;try{o=Pke(t,{maxOutputLength:r.expandedTarBytes})}catch(a){throw Error(`${i} is invalid or exceeds ${r.expandedTarBytes} expanded tar bytes`,{cause:a})}Th({cwd:e,sync:!0,filter:N9(n)}).end(o)}function $ke(e,t=GS.expandedTarBytes,n="Skill archive"){return new Promise((r,i)=>{let o=0,s=!1,a=Rke(),l=(c)=>{if(s)return;s=!0,a.destroy(),i(c)};a.on("error",(c)=>l(c)),a.on("data",(c)=>{if(o+=c.length,o>t)l(Error(`${n} exceeds ${t} expanded tar bytes`))}),a.on("end",()=>{if(s)return;s=!0,r()}),a.end(e)})}async function ha(e,t,n,r,i,o=(s)=>s()){mu(e);let s=Eke(t,n);if(!s||s.startsWith("..")||kke(s))throw Error(`Skill target must be inside skills root: ${n}`);I9(t,{recursive:!0});let a=bke(t),l=lO(a),c=_ke(KS(l,`.${T9(t)}-stage-`)),u=KS(c,e),d=KS(c,".previous"),p=!1;try{if(await xo(c,r),!sO(u)||!wke(u).isDirectory())throw Error(`Skill tarball did not contain expected '${e}/' root entry`);I9(lO(n),{recursive:!0}),o(()=>{let m=!1;if(sO(n))aO(n,d),m=!0;try{i?.(),aO(u,n)}catch(f){if(!m)throw f;try{aO(d,n)}catch(g){p=!0;let v=f instanceof Error?f.message:String(f),w=g instanceof Error?g.message:String(g);throw Error(`Skill install failed: ${v}; restoring the previous version failed: ${w}; previous version retained at ${d}`,{cause:f})}throw f}if(sO(d))O9(d,{recursive:!0,force:!0})})}finally{if(!p)O9(c,{recursive:!0,force:!0})}}async function xke(e,t){let n=await WS(e),r=Array.isArray(t)?t:t!==void 0?[t]:[lO(n)],i=await Promise.all(r.map((u)=>WS(u).catch(()=>u))),o=(u)=>{for(let d of i)if(u===d||u.startsWith(`${d}/`))return!0;return!1},s=[],a=new Set,l=new Set,c=async(u)=>{let d;try{d=await WS(u)}catch{s.push(u);return}if(l.has(d)){s.push(u);return}if(a.has(d))return;l.add(d);let p=await Ske(u,{withFileTypes:!0});try{for(let m of p){if(cO.has(m.name))continue;let f=KS(u,m.name);if(m.isSymbolicLink()){try{let g=await WS(f);if(!o(g)){s.push(f);continue}if((await D9(g)).isDirectory())await c(g)}catch{s.push(f)}continue}if(m.isDirectory())try{if((await D9(f)).isDirectory())await c(f)}catch{}}}finally{l.delete(d),a.add(d)}};return await c(e),s}async function dO(e,t,n){let r=n??T9(e),i=r.split("/").filter(Boolean),o=e;for(let l=0;l<i.length;l++)o=Ake(o,"..");let s=await xke(e,t??o);if(s.length>0)throw Error(`Skill contains symlink(s) pointing outside the agent's skills directory, broken, or cyclic; refusing to upload: ${s.join(", ")}`);let a=[];return await eO({gzip:!0,cwd:o,follow:!0,filter:(l)=>{if(j9(l))throw Error("Skill contains reserved management metadata");return!l.split("/").slice(i.length).some((u)=>cO.has(u))}},[r]).on("data",(l)=>a.push(l)).promise(),Buffer.concat(a)}async function Ike(e,t){let n=t?t.split("/").length:1,r=[],i=El({gzip:!0,onReadEntry:(a)=>{if(!uO(a.type)){a.resume();return}let c=a.path.split("/").slice(n),u=c.join("/");if(!u||c.some((d)=>cO.has(d))){a.resume();return}r.push(a.concat().then((d)=>({relativePath:u,content:Buffer.from(d)})))}});await new Promise((a,l)=>{i.on("end",a),i.on("error",l),i.end(e)});let o=await Promise.all(r);o.sort((a,l)=>Oke(a.relativePath,l.relativePath));let s=vke("sha256");for(let a of o)s.update(a.relativePath),s.update(a.content);return s.digest("hex")}function Oke(e,t){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();while(!0){let i=n.next(),o=r.next();if(i.done||o.done){if(i.done&&o.done)return 0;return i.done?-1:1}let s=i.value.codePointAt(0),a=o.value.codePointAt(0);if(s===void 0||a===void 0)throw Error("Unicode iterator returned an empty code point");if(s!==a)return s<a?-1:1}}async function pr(e,t,n){let r=await dO(e,t,n);return{archive:r,hash:await Ike(r,n)}}async function L9(e,t){let{mkdtempSync:n,writeFileSync:r,mkdirSync:i,rmSync:o}=await import("node:fs"),{tmpdir:s}=await import("node:os"),{join:a}=await import("node:path"),l=n(a(s(),"clawdi-skill-")),c=a(l,e);i(c,{recursive:!0}),r(a(c,"SKILL.md"),t);let u=[];await eO({gzip:!0,cwd:l},[e]).on("data",(p)=>u.push(p)).promise();let d=Buffer.concat(u);return o(l,{recursive:!0,force:!0}),d}var cO,GS;var Kr=b(()=>{nO();$o();cO=new Set(["node_modules",".git",".turbo",".cache","dist","build","out","target","__pycache__",".venv","venv",".pytest_cache",".mypy_cache",".ruff_cache",".tox","coverage",".agents",".cursor",".factory",".openclaw",".hermes",".gbrain",".claude",".codex"]),GS=Object.freeze({entryCount:1024,entryBytes:16777216,totalEntryBytes:33554432,expandedTarBytes:37748736})});import{createHash as U9}from"node:crypto";import{lstatSync as F9,readdirSync as Dke,readFileSync as Tke}from"node:fs";import{join as jke}from"node:path";function Al(e,t){let n=t.resourceLabel??"file tree",r=F9(e);if(!r.isDirectory()||r.isSymbolicLink())throw Error(`${n} root is not a trusted directory`);let i=[],o=new Set,s=0,a=0,l=(c,u)=>{for(let d of Dke(c).sort((p,m)=>Buffer.compare(Buffer.from(p,"utf8"),Buffer.from(m,"utf8")))){let p=u?`${u}/${d}`:d;if(t.exclude?.(p))continue;t.validatePath?.(p);let m=t.collisionKey?.(p);if(m!==void 0){if(o.has(m))throw Error(t.collisionError??`${n} contains a path collision`);o.add(m)}if(s+=1,s>t.limits.entries)throw Error(`${n} exceeds ${t.limits.entries} entries`);let f=jke(c,d),g=F9(f);if(g.isDirectory()&&!g.isSymbolicLink()){l(f,p);continue}if(!g.isFile()||g.isSymbolicLink())throw Error(`${n} contains a non-regular entry`);if(i.length>=t.limits.files)throw Error(`${n} exceeds ${t.limits.files} files`);if(g.size>t.limits.fileBytes)throw Error(`${n} file exceeds ${t.limits.fileBytes} bytes`);if(a+=g.size,a>t.limits.totalBytes)throw Error(`${n} exceeds ${t.limits.totalBytes} total file bytes`);let v=Tke(f);if(v.length!==g.size)throw Error(`${n} changed while reading`);i.push({path:p,mode:(g.mode&73)!==0?33261:33188,bytes:v})}};return l(e,""),i}function xp(e){let t=U9("sha256");for(let n of[...e].sort((r,i)=>Buffer.compare(Buffer.from(r.path,"utf8"),Buffer.from(i.path,"utf8")))){let r=U9("sha256").update(n.bytes).digest("hex");t.update(`${n.mode.toString(8)}\x00${n.path}\x00${n.bytes.length}\x00${r}
7
- `,"utf8")}return`sha256-tree-v1:${t.digest("hex")}`}var jh=()=>{};function H9(e){return xp(Al(e,{limits:Nh,resourceLabel:"managed Skill tree"})).slice(15)}function on(e){return H9(e)}function pO(){return[...z9.keys()]}function Mh(e,t){let n=z9.get(e);if(!n)throw Error(`no bundled hosted skill is registered for ${e}`);let r=n.get(t);if(!r)throw Error(`no bundled hosted skill ${e} version ${t} is registered`);return r}function B9(e,t){if(H9(t)!==e.digest)throw Error(`bundled hosted skill catalog digest mismatch for ${e.id} version ${e.version}`)}var z9,Nh;var Io=b(()=>{jh();z9=new Map([["clawdi",new Map([[1,Object.freeze({id:"clawdi",version:1,assetDirectory:"hosted-versions/1/clawdi",digest:"f74f31286fc1338693ae01676733e870b026d3042445e8d7f13c7884be7a134d"})]])]]),Nh=Object.freeze({entries:1024,files:1024,fileBytes:16777216,totalBytes:33554432})});function V9(e,t){if(typeof e!=="string"||e.length>2048)throw Error(`${t} must be a valid absolute http:// or https:// URL.`);let n=e.trim(),r;try{r=new URL(n)}catch{throw Error(`${t} must be a valid absolute http:// or https:// URL.`)}if(r.protocol!=="http:"&&r.protocol!=="https:")throw Error(`${t} must use http:// or https://.`);let i=n.indexOf("://")+3,o=n.slice(i).search(/[/?#]/),s=o===-1?n.slice(i):n.slice(i,i+o);if(r.username||r.password||s.includes("@"))throw Error(`${t} must not contain credentials.`);if(!r.hostname||!r.hostname.startsWith("[")&&!r.hostname.split(".").every((c)=>/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(c)))throw Error(`${t} must contain a canonical hostname.`);if(n.includes("?")||n.includes("#"))throw Error(`${t} must not contain a query or fragment.`);let a=n.indexOf("/",i),l=a===-1?"":n.slice(a);return{url:r,rawPath:l}}function Nke(e){return e==="localhost"||e==="127.0.0.1"||e==="[::1]"}function q9(e,t){if(e.protocol==="http:"&&!Nke(e.hostname))throw Error(`${t} must use HTTPS except on loopback localhost.`)}function At(e){let{url:n,rawPath:r}=V9(e,"Clawdi Cloud API URL");if(q9(n,"Clawdi Cloud API URL"),r!==""&&r!=="/"||n.pathname!=="/")throw Error("Clawdi Cloud API URL must not contain a non-root path.");return n.origin}function ya(e){let{url:n,rawPath:r}=V9(e,"Hosted deploy API URL");if(q9(n,"Hosted deploy API URL"),!["","/","/v2","/v2/"].includes(r))throw Error("Hosted deploy API URL must use the origin root or the compatible /v2 base.");if(n.pathname!=="/"&&n.pathname!=="/v2"&&n.pathname!=="/v2/")throw Error("Hosted deploy API URL must use the origin root or the compatible /v2 base.");return n.origin}function Ft(e){return new URL(e).origin}function mO(e){return e==="https://cloud-api.clawdi.ai"}import{chmodSync as Mke,lstatSync as K9,mkdirSync as Lke}from"node:fs";import{isAbsolute as Uke,join as Fke,relative as zke,resolve as W9}from"node:path";function G9(e){return e instanceof Error&&"code"in e&&e.code==="ENOENT"}function fu(e,t="trusted directory"){let n;try{n=K9(e)}catch(r){if(G9(r))throw Error(`${t} is missing: ${e}`);throw r}if(!n.isDirectory()||n.isSymbolicLink())throw Error(`${t} is not a real directory: ${e}`)}function Rr(e,t,n={}){let r=W9(e),i=W9(t),o=zke(r,i);if(o.startsWith("..")||Uke(o))throw Error(`directory is outside trusted root ${e}: ${t}`);if(fu(r),!o)return;let s=r;for(let a of o.split("/")){s=Fke(s,a);try{let l=K9(s);if(!l.isDirectory()||l.isSymbolicLink())throw Error(`trusted directory path contains a non-directory: ${s}`)}catch(l){if(!G9(l))throw l;if(Lke(s,n.mode===void 0?void 0:{mode:n.mode}),n.mode!==void 0)Mke(s,n.mode)}}}var Ip=()=>{};import{chmodSync as Hke,closeSync as Bke,existsSync as Vke,fsyncSync as qke,mkdirSync as Wke,openSync as Kke,renameSync as Gke,rmSync as Jke,writeFileSync as Zke}from"node:fs";import{basename as Yke,dirname as Xke,join as Qke}from"node:path";function ie(e,t,n={}){let r=n.mode??at,i=Xke(e);if(n.trustedRoot)Rr(n.trustedRoot,i,{...n.dirMode===void 0?{}:{mode:n.dirMode}});else{let s=Vke(i);if(Wke(i,{recursive:!0,...n.dirMode===void 0?{}:{mode:n.dirMode}}),!s&&n.dirMode!==void 0)Op(i,n.dirMode)}let o=Qke(i,`.${Yke(e)}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`);try{if(Zke(o,t,{mode:r}),Op(o,r),n.durable)J9(o);if(Gke(o,e),Op(e,r),n.durable)J9(i)}catch(s){throw Jke(o,{force:!0}),s}}function J9(e){let t=Kke(e,"r");try{qke(t)}finally{Bke(t)}}function Op(e,t){try{Hke(e,t)}catch{}}var at=384,Ge=448;var _t=b(()=>{Ip()});var Q9={};ae(Q9,{CONFIG_KEYS:()=>XS,clearAuth:()=>Fh,clearPendingAuth:()=>Dp,getAuth:()=>we,getClawdiDir:()=>ge,getConfig:()=>Se,getPendingAuth:()=>Es,getStoredAuth:()=>ks,getStoredConfig:()=>Oo,isLoggedIn:()=>Ve,readRecoverablePrivateJson:()=>Rl,setAuth:()=>Uh,setConfig:()=>iEe,setConfigKey:()=>vO,setPendingAuth:()=>_O,unsetConfigKey:()=>wO});import{existsSync as gO,readFileSync as eEe,unlinkSync as Z9}from"node:fs";import{homedir as tEe}from"node:os";import{join as JS}from"node:path";function ZS(){let e=process.env.CLAWDI_HOME;if(e)return e;return JS(process.env.HOME||tEe(),".clawdi")}function YS(){return JS(ZS(),"config.json")}function hO(){return JS(ZS(),"auth.json")}function yO(){return JS(ZS(),"pending-auth.json")}function Y9(e){if(!gO(e))return null;return JSON.parse(eEe(e,"utf-8"))}function X9(){let e=Y9(YS());if(typeof e!=="object"||e===null||Array.isArray(e))return{};let t={...e};if(t.autoUpdate==="true")t.autoUpdate=!0;else if(t.autoUpdate==="false")t.autoUpdate=!1;else if(typeof t.autoUpdate!=="boolean")delete t.autoUpdate;if(typeof t.apiUrl!=="string")delete t.apiUrl;if(typeof t.deployApiUrl!=="string")delete t.deployApiUrl;return t}function Lh(e,t){ie(e,`${JSON.stringify(t,null,2)}
7
+ `,"utf8")}return`sha256-tree-v1:${t.digest("hex")}`}var jh=()=>{};function H9(e){return xp(Al(e,{limits:Nh,resourceLabel:"managed Skill tree"})).slice(15)}function on(e){return H9(e)}function pO(){return[...z9.keys()]}function Mh(e,t){let n=z9.get(e);if(!n)throw Error(`no bundled hosted skill is registered for ${e}`);let r=n.get(t);if(!r)throw Error(`no bundled hosted skill ${e} version ${t} is registered`);return r}function B9(e,t){if(H9(t)!==e.digest)throw Error(`bundled hosted skill catalog digest mismatch for ${e.id} version ${e.version}`)}var z9,Nh;var Io=b(()=>{jh();z9=new Map([["clawdi",new Map([[1,Object.freeze({id:"clawdi",version:1,assetDirectory:"hosted-versions/1/clawdi",digest:"ab41317bcca444e80162cc6eeae59fca059587e0a1cd35cc048422033c03fc33"})]])]]),Nh=Object.freeze({entries:1024,files:1024,fileBytes:16777216,totalBytes:33554432})});function V9(e,t){if(typeof e!=="string"||e.length>2048)throw Error(`${t} must be a valid absolute http:// or https:// URL.`);let n=e.trim(),r;try{r=new URL(n)}catch{throw Error(`${t} must be a valid absolute http:// or https:// URL.`)}if(r.protocol!=="http:"&&r.protocol!=="https:")throw Error(`${t} must use http:// or https://.`);let i=n.indexOf("://")+3,o=n.slice(i).search(/[/?#]/),s=o===-1?n.slice(i):n.slice(i,i+o);if(r.username||r.password||s.includes("@"))throw Error(`${t} must not contain credentials.`);if(!r.hostname||!r.hostname.startsWith("[")&&!r.hostname.split(".").every((c)=>/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(c)))throw Error(`${t} must contain a canonical hostname.`);if(n.includes("?")||n.includes("#"))throw Error(`${t} must not contain a query or fragment.`);let a=n.indexOf("/",i),l=a===-1?"":n.slice(a);return{url:r,rawPath:l}}function Nke(e){return e==="localhost"||e==="127.0.0.1"||e==="[::1]"}function q9(e,t){if(e.protocol==="http:"&&!Nke(e.hostname))throw Error(`${t} must use HTTPS except on loopback localhost.`)}function At(e){let{url:n,rawPath:r}=V9(e,"Clawdi Cloud API URL");if(q9(n,"Clawdi Cloud API URL"),r!==""&&r!=="/"||n.pathname!=="/")throw Error("Clawdi Cloud API URL must not contain a non-root path.");return n.origin}function ya(e){let{url:n,rawPath:r}=V9(e,"Hosted deploy API URL");if(q9(n,"Hosted deploy API URL"),!["","/","/v2","/v2/"].includes(r))throw Error("Hosted deploy API URL must use the origin root or the compatible /v2 base.");if(n.pathname!=="/"&&n.pathname!=="/v2"&&n.pathname!=="/v2/")throw Error("Hosted deploy API URL must use the origin root or the compatible /v2 base.");return n.origin}function Ft(e){return new URL(e).origin}function mO(e){return e==="https://cloud-api.clawdi.ai"}import{chmodSync as Mke,lstatSync as K9,mkdirSync as Lke}from"node:fs";import{isAbsolute as Uke,join as Fke,relative as zke,resolve as W9}from"node:path";function G9(e){return e instanceof Error&&"code"in e&&e.code==="ENOENT"}function fu(e,t="trusted directory"){let n;try{n=K9(e)}catch(r){if(G9(r))throw Error(`${t} is missing: ${e}`);throw r}if(!n.isDirectory()||n.isSymbolicLink())throw Error(`${t} is not a real directory: ${e}`)}function Rr(e,t,n={}){let r=W9(e),i=W9(t),o=zke(r,i);if(o.startsWith("..")||Uke(o))throw Error(`directory is outside trusted root ${e}: ${t}`);if(fu(r),!o)return;let s=r;for(let a of o.split("/")){s=Fke(s,a);try{let l=K9(s);if(!l.isDirectory()||l.isSymbolicLink())throw Error(`trusted directory path contains a non-directory: ${s}`)}catch(l){if(!G9(l))throw l;if(Lke(s,n.mode===void 0?void 0:{mode:n.mode}),n.mode!==void 0)Mke(s,n.mode)}}}var Ip=()=>{};import{chmodSync as Hke,closeSync as Bke,existsSync as Vke,fsyncSync as qke,mkdirSync as Wke,openSync as Kke,renameSync as Gke,rmSync as Jke,writeFileSync as Zke}from"node:fs";import{basename as Yke,dirname as Xke,join as Qke}from"node:path";function ie(e,t,n={}){let r=n.mode??at,i=Xke(e);if(n.trustedRoot)Rr(n.trustedRoot,i,{...n.dirMode===void 0?{}:{mode:n.dirMode}});else{let s=Vke(i);if(Wke(i,{recursive:!0,...n.dirMode===void 0?{}:{mode:n.dirMode}}),!s&&n.dirMode!==void 0)Op(i,n.dirMode)}let o=Qke(i,`.${Yke(e)}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`);try{if(Zke(o,t,{mode:r}),Op(o,r),n.durable)J9(o);if(Gke(o,e),Op(e,r),n.durable)J9(i)}catch(s){throw Jke(o,{force:!0}),s}}function J9(e){let t=Kke(e,"r");try{qke(t)}finally{Bke(t)}}function Op(e,t){try{Hke(e,t)}catch{}}var at=384,Ge=448;var _t=b(()=>{Ip()});var Q9={};ae(Q9,{CONFIG_KEYS:()=>XS,clearAuth:()=>Fh,clearPendingAuth:()=>Dp,getAuth:()=>we,getClawdiDir:()=>ge,getConfig:()=>Se,getPendingAuth:()=>Es,getStoredAuth:()=>ks,getStoredConfig:()=>Oo,isLoggedIn:()=>Ve,readRecoverablePrivateJson:()=>Rl,setAuth:()=>Uh,setConfig:()=>iEe,setConfigKey:()=>vO,setPendingAuth:()=>_O,unsetConfigKey:()=>wO});import{existsSync as gO,readFileSync as eEe,unlinkSync as Z9}from"node:fs";import{homedir as tEe}from"node:os";import{join as JS}from"node:path";function ZS(){let e=process.env.CLAWDI_HOME;if(e)return e;return JS(process.env.HOME||tEe(),".clawdi")}function YS(){return JS(ZS(),"config.json")}function hO(){return JS(ZS(),"auth.json")}function yO(){return JS(ZS(),"pending-auth.json")}function Y9(e){if(!gO(e))return null;return JSON.parse(eEe(e,"utf-8"))}function X9(){let e=Y9(YS());if(typeof e!=="object"||e===null||Array.isArray(e))return{};let t={...e};if(t.autoUpdate==="true")t.autoUpdate=!0;else if(t.autoUpdate==="false")t.autoUpdate=!1;else if(typeof t.autoUpdate!=="boolean")delete t.autoUpdate;if(typeof t.apiUrl!=="string")delete t.apiUrl;if(typeof t.deployApiUrl!=="string")delete t.deployApiUrl;return t}function Lh(e,t){ie(e,`${JSON.stringify(t,null,2)}
8
8
  `,{mode:at,dirMode:Ge})}function Se(){let e=X9();return{apiUrl:process.env.CLAWDI_API_URL||e.apiUrl||nEe,deployApiUrl:process.env.CLAWDI_DEPLOY_API_URL||e.deployApiUrl||rEe,autoUpdate:e.autoUpdate}}function Oo(){return X9()}function iEe(e){let t={...e,apiUrl:fO("apiUrl",e.apiUrl)};if(e.deployApiUrl!==void 0)t.deployApiUrl=fO("deployApiUrl",e.deployApiUrl);if(e.autoUpdate!==void 0&&typeof e.autoUpdate!=="boolean")throw Error("autoUpdate must be true or false.");Lh(YS(),t)}function vO(e,t){let n=oEe(e,t),r=Oo();Lh(YS(),{...r,[e]:n})}function oEe(e,t){if(e==="autoUpdate"){if(t==="true")return!0;if(t==="false")return!1;throw Error("autoUpdate must be true or false.")}return fO(e,t)}function fO(e,t){return e==="apiUrl"?At(t):ya(t)}function wO(e){let t=Oo();delete t[e],Lh(YS(),t)}function we(){let e=process.env.CLAWDI_AUTH_TOKEN;if(e)return{apiKey:e};return ks()}function ks(){return Rl(hO())}function Uh(e){Lh(hO(),e)}function Fh(){let e=hO();if(gO(e))Z9(e)}function Ve(){return we()!==null}function Es(){return Rl(yO())}function _O(e){Lh(yO(),e)}function Dp(){let e=yO();if(gO(e))Z9(e)}function Rl(e,t=Y9){try{return t(e)}catch{return null}}function ge(){return ZS()}var XS,nEe="https://cloud-api.clawdi.ai",rEe="https://api.clawdi.ai";var Pe=b(()=>{_t();XS=["apiUrl","deployApiUrl","autoUpdate"]});var u5={};ae(u5,{PrivateDirectoryLockTimeoutError:()=>zh,withPrivateDirectoryLock:()=>mr,withPrivateDirectoryLockSync:()=>Rn});import{randomUUID as bO}from"node:crypto";import{chmodSync as t5,mkdirSync as QS,readFileSync as sEe,renameSync as e5,rmSync as ek,statSync as n5}from"node:fs";import{dirname as r5,join as aEe}from"node:path";function Tp(e,t){return e instanceof Error&&"code"in e&&e.code===t}function SO(e){return aEe(e,"owner.json")}function jp(e){try{let t=JSON.parse(sEe(SO(e),"utf8"));if(!t||typeof t!=="object"||Array.isArray(t))return null;let n=t;if(n.schemaVersion!=="clawdi.privateDirectoryLockOwner.v1"||typeof n.pid!=="number"||!Number.isInteger(n.pid)||n.pid<=0||typeof n.acquiredAt!=="string"||!Number.isFinite(Date.parse(n.acquiredAt))||typeof n.token!=="string"||!n.token)return null;return n}catch{return null}}function a5(e){try{return process.kill(e,0),!0}catch(t){return!Tp(t,"ESRCH")}}function lEe(e,t){let n=jp(e);if(n)return t.isProcessAlive(n.pid)?null:{kind:"owner",owner:n};try{let r=n5(e).mtimeMs;return t.now()-r>t.staleMs?{kind:"ownerless",mtimeMs:r}:null}catch(r){if(Tp(r,"ENOENT"))return{kind:"ownerless",mtimeMs:0};throw r}}function cEe(e,t){if(t.kind==="owner"){let n=jp(e);return n?.token===t.owner.token&&n.pid===t.owner.pid&&n.acquiredAt===t.owner.acquiredAt}if(jp(e)!==null)return!1;try{return n5(e).mtimeMs===t.mtimeMs}catch{return!1}}function l5(e,t){let n=lEe(e,t);if(!n)return!1;t.beforeReclaimRename?.();let r=`${e}.stale.${process.pid}.${t.now()}.${bO()}`;try{e5(e,r)}catch(i){if(Tp(i,"ENOENT"))return!0;throw i}if(!cEe(r,n)){try{e5(r,e)}catch(i){if(!Tp(i,"EEXIST"))throw i}return!1}return ek(r,{recursive:!0,force:!0}),!0}function c5(e,t){if(jp(e)?.token!==t)return;ek(e,{recursive:!0,force:!0})}function uEe(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}function Rn(e,t,n={}){let r=n.timeoutMs??i5,i=n.staleMs??o5,o=n.retryMs??s5,s=n.now??Date.now,a=n.isProcessAlive??a5,l=r5(e);QS(l,{recursive:!0,mode:Ge});try{t5(l,Ge)}catch{}let c=s(),u=bO();for(;;)try{QS(e,{mode:Ge});try{ie(SO(e),`${JSON.stringify({schemaVersion:"clawdi.privateDirectoryLockOwner.v1",pid:process.pid,acquiredAt:new Date(s()).toISOString(),token:u})}
9
9
  `,{mode:at,dirMode:Ge})}catch(p){throw ek(e,{recursive:!0,force:!0}),p}break}catch(p){if(!Tp(p,"EEXIST"))throw p;if(l5(e,{staleMs:i,now:s,isProcessAlive:a,beforeReclaimRename:n.beforeReclaimRename}))continue;if(s()-c>=r)throw Error(`timed out waiting for private lock at ${e}`);uEe(o)}let d={token:u,assertOwned(){if(jp(e)?.token!==u)throw Error(`lost ownership of private lock at ${e}`)}};try{return d.assertOwned(),t(d)}finally{c5(e,u)}}async function mr(e,t,n={}){let r=n.timeoutMs??i5,i=n.staleMs??o5,o=n.retryMs??s5,s=n.now??Date.now,a=n.isProcessAlive??a5,l=r5(e);QS(l,{recursive:!0,mode:Ge});try{t5(l,Ge)}catch{}let c=s(),u=bO();for(;;)try{QS(e,{mode:Ge});try{let p={schemaVersion:"clawdi.privateDirectoryLockOwner.v1",pid:process.pid,acquiredAt:new Date(s()).toISOString(),token:u};ie(SO(e),`${JSON.stringify(p)}
10
10
  `,{mode:at,dirMode:Ge})}catch(p){throw ek(e,{recursive:!0,force:!0}),p}break}catch(p){if(!Tp(p,"EEXIST"))throw p;if(l5(e,{staleMs:i,now:s,isProcessAlive:a,beforeReclaimRename:n.beforeReclaimRename}))continue;if(s()-c>=r)throw new zh(e);await new Promise((m)=>setTimeout(m,o))}let d={token:u,assertOwned(){if(jp(e)?.token!==u)throw Error(`lost ownership of private lock at ${e}`)}};try{return d.assertOwned(),await t(d)}finally{c5(e,u)}}var i5=30000,o5=60000,s5=50,zh;var Do=b(()=>{_t();zh=class zh extends Error{lockDir;constructor(e){super(`timed out waiting for private lock at ${e}`);this.name="PrivateDirectoryLockTimeoutError",this.lockDir=e}}});import{mkdirSync as dEe,readFileSync as pEe,renameSync as d5,rmSync as Hh,statSync as mEe,writeFileSync as fEe}from"node:fs";import{basename as gEe,dirname as p5,join as m5}from"node:path";function f5(e){return m5(e,"owner.json")}function hEe(e,t,n){let r=m5(p5(e),`.${gEe(e)}.${process.pid}.${Date.now()}.tmp`),i=!1;try{fEe(r,t,{mode:n}),d5(r,e),i=!0}finally{if(!i)Hh(r,{force:!0})}}function yEe(e){hEe(f5(e),`${JSON.stringify({schemaVersion:"clawdi.runtimeConvergeLockOwner.v1",pid:process.pid,acquiredAt:new Date().toISOString()})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawdi",
3
- "version": "0.14.73",
3
+ "version": "0.14.75",
4
4
  "description": "The best home for all your AI agents. Run them in the cloud or connect your own—with their context and tools in one place.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: clawdi
3
- description: "Use Clawdi Cloud for missing user memory, past sessions, Project or Vault context, Clawdi share URLs, and connected-service fallback such as Gmail, GitHub, Notion, Drive, or Calendar. Prefer an authenticated official service CLI; otherwise choose a trusted direct MCP, safely installable official CLI, official API or SDK, or the Clawdi connector as fallback. Do not invoke solely because a project, person, repo, or tool is named."
3
+ description: "API keys, tokens, memory, sessions, Projects, integrations. Use Clawdi Cloud when a task needs passwords or safe credential storage/provision, missing user memory or Project/Vault context, past conversations, Clawdi share URLs, or connected-service fallback such as Gmail, GitHub, Notion, Drive, or Calendar. Do not invoke solely because a project, person, repo, or tool is named."
4
4
  ---
5
5
 
6
6
  # Clawdi Cloud
@@ -44,6 +44,10 @@ It preserves metadata; find the exact ID before changing it.
44
44
  - Use `session_list` to browse recent sessions or filter by time, Agent, or Project.
45
45
  - Use `session_search` to find past agent conversations by keyword and obtain session UUIDs.
46
46
  - Use `session_get` to read a session by UUID or Clawdi share URL.
47
+ - Use `session_share_create` to publish an immutable snapshot only when the user explicitly asks
48
+ to share a Session, part of it, or one Assistant response.
49
+ - Use `session_share_list` to inspect active links and obtain their exact IDs and kinds.
50
+ - Use `session_share_revoke` to stop sharing one exact link only when the user asks.
47
51
 
48
52
  Call `session_get` when the user provides a Clawdi share URL or session UUID and wants its
49
53
  contents. For a request to open a specific unnamed past conversation, use `session_search`
@@ -51,6 +55,13 @@ to find the UUID and then read the selected match.
51
55
 
52
56
  Do NOT call WebFetch on `cloud.clawdi.ai/s/...` URLs — `session_get` is the right tool and avoids the WebFetch permission prompt.
53
57
 
58
+ For `session_share_create`, omit `position` for the full `session` scope. For `through` or
59
+ `response`, use the stable message `position` returned by `session_get` or `session_search`,
60
+ never a filtered array index; `response` must target an Assistant message. Public snapshots
61
+ include only the existing safe user/Assistant projection, never reasoning, system/developer
62
+ messages, hidden events, or tool activity. Before revoking, use `session_share_list` unless the
63
+ user already supplied the exact `share_id` and `kind`; never infer a link ID or kind.
64
+
54
65
  CLI fallback: `clawdi session search "query" --json`, then `clawdi session read <cloud-session-id> --json`.
55
66
  `session list` is local; `session export <cloud-session-id>` exports owner Markdown without
56
67
  publishing. Publish only with user authorization: `session share <cloud-session-id> --yes`.
@@ -80,6 +91,11 @@ an access boundary as well as a possible unknown UUID; never bypass it with anot
80
91
 
81
92
  ## Vault
82
93
 
94
+ Vault stores credentials for authorized tools and services; it is not a universal service
95
+ alternative. Reuse ready, authorized mechanisms before requesting missing credentials. An
96
+ already-connected, capable Composio integration does not require duplicate credentials in Vault
97
+ or account migration. Request credentials only when the chosen task path actually needs them.
98
+
83
99
  Vault read tools expose metadata and exact references:
84
100
 
85
101
  - `vault_list` — List Vault attachments and key counts for visible Projects.
@@ -179,7 +195,10 @@ already exposed by the runtime, and authorized API or SDK credentials. If an ins
179
195
  authenticated official CLI can perform the task, use it directly. Check availability and
180
196
  authentication non-destructively and prefer structured output.
181
197
 
182
- Otherwise choose the lowest-setup reliable option for the task. Consult the service's official
198
+ Otherwise reuse a ready, authorized direct integration when it can perform the task. If none
199
+ is usable and Composio is already connected and capable, use it without demanding a new key,
200
+ login, installation, or account migration merely to avoid the connector. For remaining setup
201
+ choices, choose the lowest-setup reliable option for the task. Consult the service's official
183
202
  documentation when installation, authentication, commands, or schemas are uncertain or likely
184
203
  to have changed:
185
204
 
@@ -189,7 +208,7 @@ to have changed:
189
208
  official, and no elevation or persistent host change is required.
190
209
  - Use the official API or SDK with a verified contract and credentials already authorized for
191
210
  the runtime, including through an exact Vault reference.
192
- - Use the Clawdi connector when no direct option can perform the operation.
211
+ - Use the Clawdi connector when no direct option is usable for the operation.
193
212
 
194
213
  Before a side effect, establish the exact service account and organization, Project, or tenant.
195
214
  Use connection details from Composio discovery, or explicitly list accounts with
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: clawdi
3
- description: "Use Clawdi Cloud for missing user memory, past sessions, Project or Vault context, Clawdi share URLs, and connected-service fallback such as Gmail, GitHub, Notion, Drive, or Calendar. Prefer an authenticated official service CLI; otherwise choose a trusted direct MCP, safely installable official CLI, official API or SDK, or the Clawdi connector as fallback. Do not invoke solely because a project, person, repo, or tool is named."
3
+ description: "API keys, tokens, memory, sessions, Projects, integrations. Use Clawdi Cloud when a task needs passwords or safe credential storage/provision, missing user memory or Project/Vault context, past conversations, Clawdi share URLs, or connected-service fallback such as Gmail, GitHub, Notion, Drive, or Calendar. Do not invoke solely because a project, person, repo, or tool is named."
4
4
  ---
5
5
 
6
6
  # Clawdi Cloud
@@ -11,7 +11,8 @@ Use Clawdi Cloud tools through the `clawdi` MCP server. Treat the live tool sche
11
11
 
12
12
  Third-party tool routing below applies unchanged in Hosted. Do not inspect, run, or suggest
13
13
  Clawdi host-management commands such as `clawdi setup`, `clawdi wallet`, `clawdi vault`, or
14
- `clawdi ai-provider`.
14
+ `clawdi ai-provider`. Do not use any `clawdi` CLI command as a Cloud capability fallback;
15
+ use the Clawdi MCP tools exposed to the Hosted runtime.
15
16
 
16
17
  ## Context Routing
17
18
 
@@ -46,11 +47,23 @@ already supplied the exact memory ID; never infer which stored item to mutate.
46
47
  - Use `session_list` to browse recent sessions or filter by time, Agent, or Project.
47
48
  - Use `session_search` to find past agent conversations by keyword and obtain session UUIDs.
48
49
  - Use `session_get` to read a session by UUID or Clawdi share URL.
50
+ - Use `session_share_create` to publish an immutable snapshot only when the user explicitly asks
51
+ to share a Session, part of it, or one Assistant response.
52
+ - Use `session_share_list` to inspect active links and obtain their exact IDs and kinds.
53
+ - Use `session_share_revoke` to stop sharing one exact link only when the user asks.
49
54
 
50
55
  Call `session_get` when the user provides a Clawdi share URL or session UUID and wants its
51
56
  contents. Use `session_search` to locate a requested unnamed conversation. Do not use a
52
57
  generic web fetcher for Clawdi share URLs.
53
58
 
59
+ For `session_share_create`, omit `position` for the full `session` scope. For `through` or
60
+ `response`, use the stable message `position` returned by `session_get` or `session_search`,
61
+ never a filtered array index; `response` must target an Assistant message. Public snapshots
62
+ include only the existing safe user/Assistant projection, never reasoning, system/developer
63
+ messages, hidden events, or tool activity. Before revoking, use `session_share_list` unless the
64
+ user already supplied the exact `share_id` and `kind`; never infer a link ID or kind. Hosted
65
+ Session sharing uses these MCP tools only, not CLI commands.
66
+
54
67
  ## Projects
55
68
 
56
69
  - `project_current_get` — Read the runtime-bound Project.
@@ -65,6 +78,11 @@ as a possible unknown UUID; do not bypass it through another tool.
65
78
 
66
79
  ## Vault
67
80
 
81
+ Vault stores credentials for authorized tools and services; it is not a universal service
82
+ alternative. Reuse ready, authorized mechanisms before requesting missing credentials. An
83
+ already-connected, capable Composio integration does not require duplicate credentials in Vault
84
+ or account migration. Request credentials only when the chosen task path actually needs them.
85
+
68
86
  - `vault_list` — List attached Vaults and key counts for visible Projects.
69
87
  - `vault_get` — List key names, provenance, and exact references for an attached Vault.
70
88
 
@@ -140,7 +158,10 @@ already exposed by the runtime, and authorized API or SDK credentials. If an ins
140
158
  authenticated official CLI can perform the task, use it directly. Check availability and
141
159
  authentication non-destructively and prefer structured output.
142
160
 
143
- Otherwise choose the lowest-setup reliable option for the task. Consult the service's official
161
+ Otherwise reuse a ready, authorized direct integration when it can perform the task. If none
162
+ is usable and Composio is already connected and capable, use it without demanding a new key,
163
+ login, installation, or account migration merely to avoid the connector. For remaining setup
164
+ choices, choose the lowest-setup reliable option for the task. Consult the service's official
144
165
  documentation when installation, authentication, commands, or schemas are uncertain or likely
145
166
  to have changed:
146
167
 
@@ -150,7 +171,7 @@ to have changed:
150
171
  official, and no elevation or persistent host change is required.
151
172
  - Use the official API or SDK with a verified contract and credentials already authorized for
152
173
  the runtime, including through an exact Vault reference.
153
- - Use the Clawdi connector when no direct option can perform the operation.
174
+ - Use the Clawdi connector when no direct option is usable for the operation.
154
175
 
155
176
  Before a side effect, establish the exact service account and organization, Project, or tenant.
156
177
  Use connection details from Composio discovery, or explicitly list accounts with