@netlify/agent-runner-cli 1.136.0-ex-2324.1 → 1.136.0-ex-2324.2

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
@@ -85,7 +85,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
85
85
  `,LF:`
86
86
  `,concatBytes:iI},fye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},hye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:fye};import{Buffer as pye}from"buffer";var _Y=(t,e)=>t?void 0:mye.bind(void 0,e),mye=function*(t,e){if(typeof e!="string"&&!gt(e)&&!pye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},SY=(t,e)=>t?gye.bind(void 0,e):_ye.bind(void 0,e),gye=function*(t,e){EY(t,e),yield e},_ye=function*(t,e){if(EY(t,e),typeof e!="string"&&!gt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},EY=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
87
87
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
88
- if (condition) { yield value; }`)};import{Buffer as Sye}from"buffer";import{StringDecoder as Eye}from"string_decoder";var VT=(t,e,r)=>{if(r)return;if(t)return{transform:yye.bind(void 0,new TextEncoder)};let n=new Eye(e);return{transform:Tye.bind(void 0,n),final:bye.bind(void 0,n)}},yye=function*(t,e){Sye.isBuffer(e)?yield _i(e):typeof e=="string"?yield t.encode(e):yield e},Tye=function*(t,e){yield gt(e)?t.write(e):e},bye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yY}from"util";var aI=yY(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),jT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vye}=e[r];for await(let s of n(t))yield*jT(s,e,r+1)},TY=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Aye(r,Number(e),t)},Aye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*jT(n,r,e+1)},bY=yY(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),vye=function*(t){yield t};var cI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},AY=(t,e)=>[...e.flatMap(r=>[...lc(r,t,0)]),...im(t)],lc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Rye}=e[r];for(let s of n(t))yield*lc(s,e,r+1)},im=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wye(r,Number(e),t)},wye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*lc(n,r,e+1)},Rye=function*(t){yield t};var lI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=wY(t,o,i),l=cc(e),u=cc(r),d=l?aI.bind(void 0,jT,a):cI.bind(void 0,lc),f=l||u?aI.bind(void 0,TY,a):cI.bind(void 0,im),h=l||u?bY.bind(void 0,a):void 0;return{stream:new Cye({writableObjectMode:n,writableHighWaterMark:vY(n),readableObjectMode:s,readableHighWaterMark:vY(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},WT=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=wY(o,r,a);t=AY(c,t)}return t},wY=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:_Y(n,a)},VT(r,o,n),HT(r,i,n,c),{transform:t,final:e},{transform:SY(s,a)},gY({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var RY=(t,e)=>{for(let r of xye(t))Pye(t,r,e)},xye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Pye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Po[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Oye(a,n));r.input=Kp(o)},Oye=(t,e)=>{let r=WT(t,e,"utf8",!0);return Iye(r),Kp(r)},Iye=t=>{let e=t.find(r=>typeof r!="string"&&!gt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as Dye,appendFileSync as kye}from"fs";var zT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&bu(r,n)&&!Dr.has(e)&&Nye(n)&&(t.some(({type:s,value:i})=>s==="native"&&Mye.has(i))||t.every(({type:s})=>fn.has(s))),Nye=t=>t===1||t===2,Mye=new Set(["pipe","overlapped"]),CY=async(t,e,r,n)=>{for await(let s of t)Lye(e)||PY(s,r,n)},xY=(t,e,r)=>{for(let n of t)PY(n,e,r)},Lye=t=>t._readableState.pipes.length>0,PY=(t,e,r)=>{let n=aT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var OY=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>Uye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},Uye=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=I4(t,i,d),h=_i(f),{stdioItems:p,objectMode:m}=e[r],E=Fye([h],p,c,n),{serializedResult:S,finalResult:b=S}=Bye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});$ye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let w=a[r]?b:void 0;try{return n.error===void 0&&Gye(S,p,s),w}catch(A){return n.error=A,w}},Fye=(t,e,r,n)=>{try{return WT(t,e,r,!1)}catch(s){return n.error=s,t}},Bye=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Kp(t)};let o=j3(t,r);return n[i]?{serializedResult:o,finalResult:oI(o,!s[i],e)}:{serializedResult:o}},$ye=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!zT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=oI(t,!1,o);try{xY(a,e,n)}catch(c){r.error??=c}},Gye=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>GT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?kye(n,t):(r.add(i),Dye(n,t))}};var IY=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,yi(e,r,"all")]:Array.isArray(e)?[yi(t,r,"all"),...e]:gt(t)&&gt(e)?mO([t,e]):`${t}${e}`};import{once as uI}from"events";var NY=async(t,e)=>{let[r,n]=await qye(t);return e.isForcefullyTerminated??=!1,[r,n]},qye=async t=>{let[e,r]=await Promise.allSettled([uI(t,"spawn"),uI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?MY(t):r.value},MY=async t=>{try{return await uI(t,"exit")}catch{return MY(t)}},LY=async t=>{let[e,r]=await t;if(!Hye(e,r)&&dI(e,r))throw new qn;return[e,r]},Hye=(t,e)=>t===void 0&&e===void 0,dI=(t,e)=>t!==0||e!==null;var DY=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=Vye(t,e,r),o=i?.code==="ETIMEDOUT",a=O4(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Vye=(t,e,r)=>t!==void 0?t:dI(e,r)?new qn:void 0;var kY=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Wye(t,e,r),d=Kye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Nu(d,c,l)},Wye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=lT(t,e,r),a=zye(r),{file:c,commandArguments:l,options:u}=PT(t,e,a);Yye(u);let d=fY(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},zye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Yye=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&YT("ipcInput"),t&&YT("ipc: true"),r&&YT("detached: true"),n&&YT("cancelSignal")},YT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Kye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Xye({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h}=DY(c,r),{output:p,error:m=l}=OY({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,w)=>yi(b,r,w)),S=yi(IY(p,r),r,"all");return Jye({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Xye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{RY(i,r);let a=Qye(r);return jye(...OT(t,e,a))}catch(a){return Iu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},Qye=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:UT(e)}),Jye=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?FT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):sm({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as Bbe}from"events";import{spawn as $be}from"child_process";import GY from"process";import{once as fI,on as Zye}from"events";var UY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(wu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:AT(t)}),eTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),eTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{ET(e,s);let i=xo(t,e,r),o=new AbortController;try{return await Promise.race([tTe(i,n,o),rTe(i,r,o),nTe(i,r,o)])}catch(a){throw Ru(t),a}finally{o.abort(),yT(e,s)}},tTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await fI(t,"message",{signal:r});return n}for await(let[n]of Zye(t,"message",{signal:r}))if(e(n))return n},rTe=async(t,e,{signal:r})=>{await fI(t,"disconnect",{signal:r}),Az(e)},nTe=async(t,e,{signal:r})=>{let[n]=await fI(t,"strict:error",{signal:r});throw gT(n,e)};import{once as BY,on as sTe}from"events";var $Y=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>hI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),hI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{wu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:AT(t)}),ET(e,i);let o=xo(t,e,r),a=new AbortController,c={};return iTe(t,o,a),oTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),aTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},iTe=async(t,e,r)=>{try{await BY(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},oTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await BY(t,"strict:error",{signal:r.signal});n.error=gT(s,e),r.abort()}catch{}},aTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of sTe(r,"message",{signal:i.signal}))FY(o),yield c}catch{FY(o)}finally{i.abort(),yT(e,a),n||Ru(t),s&&await t}},FY=({error:t})=>{if(t)throw t};var qY=(t,{ipc:e})=>{Object.assign(t,VY(t,!1,e))},HY=()=>{let t=GY,e=!0,r=GY.channel!==void 0;return{...VY(t,e,r),getCancelSignal:Xz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},VY=(t,e,r)=>({sendMessage:CT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:UY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:$Y.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as cTe}from"child_process";import{PassThrough as lTe,Readable as uTe,Writable as dTe,Duplex as fTe}from"stream";var jY=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{nI(n);let a=new cTe;hTe(a,n),Object.assign(a,{readable:pTe,writable:mTe,duplex:gTe});let c=Iu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=_Te(c,o,s);return{subprocess:a,promise:l}},hTe=(t,e)=>{let r=om(),n=om(),s=om(),i=Array.from({length:e.length-3},om),o=om(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},om=()=>{let t=new lTe;return t.end(),t},pTe=()=>new uTe({read(){}}),mTe=()=>new dTe({write(){}}),gTe=()=>new fTe({read(){},write(){}}),_Te=async(t,e,r)=>Nu(t,e,r);import{createReadStream as WY,createWriteStream as zY}from"fs";import{Buffer as STe}from"buffer";import{Readable as am,Writable as ETe,Duplex as yTe}from"stream";var KY=(t,e)=>qT(TTe,t,e,!1),cm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Po[t]}.`)},YY={fileNumber:cm,generator:lI,asyncGenerator:lI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:yTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},TTe={input:{...YY,fileUrl:({value:t})=>({stream:WY(t)}),filePath:({value:{file:t}})=>({stream:WY(t)}),webStream:({value:t})=>({stream:am.fromWeb(t)}),iterable:({value:t})=>({stream:am.from(t)}),asyncIterable:({value:t})=>({stream:am.from(t)}),string:({value:t})=>({stream:am.from(t)}),uint8Array:({value:t})=>({stream:am.from(STe.from(t))})},output:{...YY,fileUrl:({value:t})=>({stream:zY(t)}),filePath:({value:{file:t,append:e}})=>({stream:zY(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ETe.fromWeb(t)}),iterable:cm,asyncIterable:cm,string:cm,uint8Array:cm}};import{on as bTe,once as XY}from"events";import{PassThrough as ATe,getDefaultHighWaterMark as vTe}from"stream";import{finished as ZY}from"stream/promises";function uc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)mI(s);let e=t.some(({readableObjectMode:s})=>s),r=wTe(t,e),n=new pI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var wTe=(t,e)=>{if(t.length===0)return vTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},pI=class extends ATe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(mI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=RTe(this,this.#e,this.#i);let r=PTe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(mI(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},RTe=async(t,e,r)=>{KT(t,QY);let n=new AbortController;try{await Promise.race([CTe(t,n),xTe(t,e,r,n)])}finally{n.abort(),KT(t,-QY)}},CTe=async(t,{signal:e})=>{try{await ZY(t,{signal:e,cleanup:!0})}catch(r){throw e6(t,r),r}},xTe=async(t,e,r,{signal:n})=>{for await(let[s]of bTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},mI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},PTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{KT(t,JY);let a=new AbortController;try{await Promise.race([OTe(i,e,a),ITe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),NTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),KT(t,-JY)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?gI(t):MTe(t))},OTe=async(t,e,{signal:r})=>{try{await t,r.aborted||gI(e)}catch(n){r.aborted||e6(e,n)}},ITe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await ZY(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;t6(o)?s.add(e):r6(t,o)}},NTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await XY(t,s,{signal:i}),!t.readable)return XY(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},MTe=t=>{t.writable&&t.end()},e6=(t,e)=>{t6(e)?gI(t):r6(t,e)},t6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gI=t=>{(t.readable||t.writable)&&t.destroy()},r6=(t,e)=>{t.destroyed||(t.once("error",LTe),t.destroy(e))},LTe=()=>{},KT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},QY=2,JY=1;import{finished as n6}from"stream/promises";var Lu=(t,e)=>{t.pipe(e),DTe(t,e),kTe(t,e)},DTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await n6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}_I(e)}},_I=t=>{t.writable&&t.end()},kTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await n6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}SI(t)}},SI=t=>{t.readable&&t.destroy()};var s6=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>fn.has(c)))UTe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!fn.has(c)))BTe({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:uc(i);Lu(o,s)}},UTe=(t,e,r,n)=>{r==="output"?Lu(t.stdio[n],e):Lu(e,t.stdio[n]);let s=FTe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},FTe=["stdin","stdout","stderr"],BTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;$Te(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},$Te=(t,{signal:e})=>{Gn(t)&&oc(t,GTe,e)},GTe=2;import{addAbortListener as VTe}from"events";var dc=[];dc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&dc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&dc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var XT=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",EI=Symbol.for("signal-exit emitter"),yI=globalThis,qTe=Object.defineProperty.bind(Object),TI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(yI[EI])return yI[EI];qTe(yI,EI,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},QT=class{},HTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),bI=class extends QT{onExit(){return()=>{}}load(){}unload(){}},AI=class extends QT{#e=vI.platform==="win32"?"SIGINT":"SIGHUP";#r=new TI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of dc)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!XT(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of dc)try{let r=this.#s[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,dc.forEach(e=>{let r=this.#s[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#i,this.#r.count-=1)}#a(e){return XT(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&XT(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},vI=globalThis.process,{onExit:i6,load:ZQe,unload:eJe}=HTe(XT(vI)?new AI(vI):new bI);var o6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=i6(()=>{t.kill()});VTe(n,()=>{s()})};var c6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=cT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=jTe(r,n,s),{sourceStream:d,sourceError:f}=zTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},jTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=WTe(t,e,...r),a=ST(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},WTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(a6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hO(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[s,i,o]=Jy(r,...n);return{destination:e(a6)(s,i,o),pipeOptions:o}}if(Rs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},a6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),zTe=(t,e)=>{try{return{sourceStream:Cu(t,e)}}catch(r){return{sourceError:r}}};var u6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=YTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw wI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},YTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return SI(t),n;if(e!==void 0)return _I(r),e},wI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iu({error:t,command:l6,escapedCommand:l6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),l6="source.pipe(destination)";var d6=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as KTe}from"stream/promises";var f6=(t,e,r)=>{let n=JT.has(e)?QTe(t,e):XTe(t,e);return oc(t,ZTe,r.signal),oc(e,ebe,r.signal),JTe(e),n},XTe=(t,e)=>{let r=uc([t]);return Lu(r,e),JT.set(e,r),r},QTe=(t,e)=>{let r=JT.get(e);return r.add(t),r},JTe=async t=>{try{await KTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}JT.delete(t)},JT=new WeakMap,ZTe=2,ebe=1;import{aborted as tbe}from"util";var h6=(t,e)=>t===void 0?[]:[rbe(t,e)],rbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await tbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw wI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var ZT=(t,...e)=>{if(ot(e[0]))return ZT.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=c6(t,...e),s=nbe({...n,destination:r});return s.pipe=ZT.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},nbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=sbe(t,s);u6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=f6(e,i,d);return await Promise.race([d6(u),...h6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},sbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dbe}from"timers/promises";import{on as ibe}from"events";import{getDefaultHighWaterMark as obe}from"stream";var eb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return abe(e,o),m6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},abe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},RI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;cbe(e,o,t);let a=t.readableObjectMode&&!i;return m6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},cbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},m6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=ibe(t,"data",{signal:e.signal,highWaterMark:p6,highWatermark:p6});return lbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},CI=obe(!0),p6=CI,lbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=ube({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*lc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*im(a)}},ube=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[VT(t,r,!e),HT(t,s,!n,{})].filter(Boolean);var g6=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=fbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([hbe(t),d]);return}let f=sI(c,r),h=RI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([pbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},fbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!zT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=RI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await CY(a,t,r,i)},hbe=async t=>{await dbe(),t.readableFlowing===null&&t.resume()},pbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await LT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await DT(r,{maxBuffer:i})):await Ou(r,{maxBuffer:i})}catch(a){return _6(C4({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},xI=async t=>{try{return await t}catch(e){return _6(e)}},_6=({bufferedData:t})=>H3(t)?new Uint8Array(t):t;import{finished as mbe}from"stream/promises";var lm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=gbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],mbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Ebe(a,e,r,n)}finally{o.abort()}},gbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_be(t,r,n),n},_be=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Sbe(e,r),n.call(t,...s)}},Sbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ebe=(t,e,r,n)=>{if(!ybe(t,e,r,n))throw t},ybe=(t,e,r,n=!0)=>r.propagating?S6(t)||tb(t):(r.propagating=!0,PI(r,e)===n?S6(t):tb(t)),PI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",tb=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",S6=t=>t?.code==="EPIPE";var E6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>OI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),OI=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=lm(t,e,l);if(PI(l,e)){await u;return}let[d]=await Promise.all([g6({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var y6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?uc([t,e].filter(Boolean)):void 0,T6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>OI({...Tbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:bbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),Tbe=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},bbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Abe}from"events";var b6=t=>bu(t,"ipc"),A6=(t,e)=>{let r=aT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var v6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=b6(i),a=Si(e,"ipc"),c=Si(r,"ipc");for await(let l of hI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(x4(t,s,c),s.push(l)),o&&A6(l,i);return s},w6=async(t,e)=>(await Promise.allSettled([t]),e);var R6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let b=NY(t,f),w={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=E6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),G=T6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),x=[],F=v6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),O=vbe(m,t,w),P=wbe(p,w);try{return await Promise.race([Promise.all([{},LY(b),Promise.all(A),G,F,o4(t,d),...O,...P]),E,Rbe(t,S),...t4(t,i,f,S),...bz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Zz({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},b,Promise.all(A.map(_=>xI(_))),xI(G),w6(F,x),Promise.allSettled(O),Promise.allSettled(P)])}},vbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:lm(n,s,r)),wbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>lm(o,n,e,{isSameDirection:fn.has(s),stopOnExit:s==="native"}))),Rbe=async(t,{signal:e})=>{let[r]=await Abe(t,"error",{signal:e});throw r};var C6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),um=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Du=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as Cbe}from"stream";import{callbackify as xbe}from"util";import{finished as x6}from"stream/promises";var II=async t=>{if(t!==void 0)try{await NI(t)}catch{}},P6=async t=>{if(t!==void 0)try{await MI(t)}catch{}},NI=async t=>{await x6(t,{cleanup:!0,readable:!1,writable:!0})},MI=async t=>{await x6(t,{cleanup:!0,readable:!0,writable:!1})},rb=async(t,e)=>{if(await t,e)throw e},nb=(t,e,r)=>{r&&!tb(r)?t.destroy(r):e&&t.destroy()};var O6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=LI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=DI(a,o),{read:f,onStdoutDataDone:h}=kI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Cbe({read:f,destroy:xbe(FI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return UI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},LI=(t,e,r)=>{let n=Cu(t,e),s=um(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},DI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:CI},kI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=eb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Pbe(this,o,i)},onStdoutDataDone:i}},Pbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},UI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await MI(t),await n,await II(s),await e,r.readable&&r.push(null)}catch(i){await II(s),I6(r,i)}},FI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Du(r,e)&&(I6(t,n),await rb(e,n))},I6=(t,e)=>{nb(t,t.readable,e)};import{Writable as Obe}from"stream";import{callbackify as N6}from"util";var M6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=BI(t,r,e),o=new Obe({...$I(n,t,s),destroy:N6(qI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return GI(n,o),o},BI=(t,e,r)=>{let n=ST(t,e),s=um(r,n,"writableFinal"),i=um(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},$I=(t,e,r)=>({write:Ibe.bind(void 0,t),final:N6(Nbe.bind(void 0,t,e,r))}),Ibe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Nbe=async(t,e,r)=>{await Du(r,e)&&(t.writable&&t.end(),await e)},GI=async(t,e,r)=>{try{await NI(t),e.writable&&e.end()}catch(n){await P6(r),L6(e,n)}},qI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Du(r,e),await Du(n,e)&&(L6(t,s),await rb(e,s))},L6=(t,e)=>{nb(t,t.writable,e)};import{Duplex as Mbe}from"stream";import{callbackify as Lbe}from"util";var D6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=LI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=BI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=DI(c,a),{read:E,onStdoutDataDone:S}=kI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new Mbe({read:E,...$I(u,t,d),destroy:Lbe(Dbe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return UI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),GI(u,b,c),b},Dbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([FI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),qI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var HI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=Cu(t,r),a=eb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return kbe(a,o,t)},kbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var k6=(t,{encoding:e})=>{let r=C6();t.readable=O6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=M6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=D6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HI.bind(void 0,t,e),t[Symbol.asyncIterator]=HI.bind(void 0,t,e,{})};var U6=(t,e)=>{for(let[r,n]of Fbe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},Ube=(async()=>{})().constructor.prototype,Fbe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Ube,t)]);var F6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Gbe(t,e,r),{subprocess:f,promise:h}=Hbe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ZT.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),U6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Gbe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=lT(t,e,r),{file:a,commandArguments:c,options:l}=PT(t,e,r),u=qbe(l),d=KY(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},qbe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},Hbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=$be(...OT(t,e,r))}catch(p){return jY({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;Bbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];s6(c,a,l),o6(c,r,l);let d={},f=ws();c.kill=yz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=y6(c,r),k6(c,r),qY(c,r);let h=Vbe({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:h}},Vbe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,h],p,m,E]=await R6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,G)=>yi(A,e,G)),b=yi(m,e,"all"),w=jbe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Nu(w,n,e)},jbe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?sm({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):FT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var sb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Wbe(n,t[n],s)]));return{...t,...r}},Wbe=(t,e,r)=>zbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,zbe=new Set(["env",...EO]);var Oo=(t,e,r,n)=>{let s=(o,a,c)=>Oo(o,a,r,c),i=(...o)=>Ybe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Ybe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,sb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Kbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?kY(a,c,l):F6(a,c,l,s)},Kbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=K3(e)?X3(e,r):[e,...r],[o,a,c]=Jy(...i),l=sb(sb(n,s),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:h}};var B6=({file:t,commandArguments:e})=>G6(t,e),$6=({file:t,commandArguments:e})=>({...G6(t,e),isSync:!0}),G6=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=Xbe(t);return{file:r,commandArguments:n}},Xbe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(Qbe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},Qbe=/ +/g;var q6=(t,e,r)=>{t.sync=e(Jbe,r),t.s=t.sync},H6=({options:t})=>V6(t),Jbe=({options:t})=>({...V6(t),isSync:!0}),V6=t=>({options:{...Zbe(t),...t}}),Zbe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},j6={preferLocal:!0};var W6=Oo(()=>({})),HZe=Oo(()=>({isSync:!0})),z6=Oo(B6),VZe=Oo($6),jZe=Oo(n4),WZe=Oo(H6,{},j6,q6),{sendMessage:zZe,getOneMessage:YZe,getEachMessage:KZe,getCancelSignal:XZe}=HY();var eAe=!1;var Ti=()=>eAe;var dm=null,Y6=t=>(dm&&dm.destroy(),dm=new bi({totalAllowedTime:t}),dm),K6=()=>dm;var bi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ti())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Wy({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ge.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var X6={name:"@netlify/agent-runner-cli",type:"module",version:"1.136.0-ex-2324.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var sAe=rAe(import.meta.url),iAe=Ai.dirname(sAe),oAe=nAe(import.meta.url),ku=de("shell"),VI=new Set,Q6={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=aAe(e,r),i={...Q6,...s},o=W6(t,n,i);Z6(o,i),r8(o);let a=r?.idleTimeout;return a&&a>0&&t8(o,a),o},J6=(t,e)=>{let r={...Q6,...e},n=z6(t,r);return Z6(n,r),r8(n),e?.idleTimeout&&e.idleTimeout>0&&t8(n,e.idleTimeout),n},aAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Z6=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new qp).pipe(vi.stdout),t.stderr?.pipe(new qp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},jI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),ku.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ku.error("Error killing process:",r),!1}},e8=t=>jI(t,"SIGKILL"),t8=(t,e)=>{let r=null,n=()=>{ku.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),jI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ku.log(`Force killing idle process ${t.pid}`),e8(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},r8=t=>{VI.add(t);let e=K6();if(e){let r=e.onTimesUp(()=>{ku.log(`Global timer expired, killing process ${t.pid}`),jI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ku.log(`Force killing process ${t.pid} after timeout`),e8(t))},5e3)});t.on("exit",()=>{VI.delete(t),r()}),t.on("error",()=>{VI.delete(t),r()})}};function Io(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=oAe.resolve(X6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(ib.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(ib.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(ib.existsSync(r))return r;let n=Ai.join(iAe,"..","node_modules",".bin",e);if(ib.existsSync(n))return n}var cAe=de("utils"),lAe=t=>new Promise(e=>{setTimeout(e,t)});var ob=(t,e=3e3)=>{let r=!1,n=null,s=[],i=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{s.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return i=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await lAe(e),!n)return r=!1,i=null,u;let d=n,f=s;n=null,s=[],u=await t(...d),f.forEach(h=>{h(u)})}})(),l};return o.flush=async()=>{if((r||n)&&i)return await i,o.flush()},o.cancel=()=>{n=null,s.forEach(a=>a(void 0)),s=[]},o},Uu=(t,e,r=!1)=>{let n=null,s=null,i=null,o=function(...a){s=a,i=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(i,s),s=null,i=null)},e),c&&(t.apply(i,s),s=null,i=null)};return o.cancel=()=>{clearTimeout(n),n=null,s=null,i=null},o.flush=()=>{if(n){clearTimeout(n);let a=s,c=i;n=null,s=null,i=null,t.apply(c,a)}},o},n8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):cAe.error("Could not parse JSON",n))}},uAe=t=>t.charAt(0).toUpperCase()+t.slice(1),No=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():uAe(e)).join(" ");function fc(t,e){e&&t.log(`Skill invoked: ${e}`)}var s8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),i8=(t,e,r=!1)=>{if(r)return;let n=60,s=55,i=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${i}`;if(c.length>s)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var WI=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},dAe=1e4,zI=(t,e=dAe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as o8}from"buffer";import fAe from"path";var a8=de("repo"),mr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),l8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{a8.info("Getting runner diffs");let n=await pAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=gAe(i);await _Ae(m,r)}a8.info("Changes after processing"),await KI(r);let o=await QI(i,r);if(await YI(o,r),s=await mAe(r),!s)return{hasChanges:!1,ignored:o};await mr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await mr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await c8(r),{hasChanges:!1,ignored:o};let u=await mr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await mr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await mr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=o8.from(S).toString("base64"))}await c8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=o8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},c8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await mr(["reset","--soft","HEAD~1"],{cwd:t})},YI=async(t=[],e=process.cwd())=>{await mr(["add",".",...t],{cwd:e})},KI=async(t=process.cwd())=>{let e=await mr(["status","-s"],{cwd:t});return String(e.stdout??"")},u8=/.. (.+)?\.log$/,hAe=[u8],pAe=async(t=process.cwd())=>{let e=await KI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
88
+ if (condition) { yield value; }`)};import{Buffer as Sye}from"buffer";import{StringDecoder as Eye}from"string_decoder";var VT=(t,e,r)=>{if(r)return;if(t)return{transform:yye.bind(void 0,new TextEncoder)};let n=new Eye(e);return{transform:Tye.bind(void 0,n),final:bye.bind(void 0,n)}},yye=function*(t,e){Sye.isBuffer(e)?yield _i(e):typeof e=="string"?yield t.encode(e):yield e},Tye=function*(t,e){yield gt(e)?t.write(e):e},bye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yY}from"util";var aI=yY(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),jT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vye}=e[r];for await(let s of n(t))yield*jT(s,e,r+1)},TY=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Aye(r,Number(e),t)},Aye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*jT(n,r,e+1)},bY=yY(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),vye=function*(t){yield t};var cI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},AY=(t,e)=>[...e.flatMap(r=>[...lc(r,t,0)]),...im(t)],lc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Rye}=e[r];for(let s of n(t))yield*lc(s,e,r+1)},im=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wye(r,Number(e),t)},wye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*lc(n,r,e+1)},Rye=function*(t){yield t};var lI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=wY(t,o,i),l=cc(e),u=cc(r),d=l?aI.bind(void 0,jT,a):cI.bind(void 0,lc),f=l||u?aI.bind(void 0,TY,a):cI.bind(void 0,im),h=l||u?bY.bind(void 0,a):void 0;return{stream:new Cye({writableObjectMode:n,writableHighWaterMark:vY(n),readableObjectMode:s,readableHighWaterMark:vY(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},WT=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=wY(o,r,a);t=AY(c,t)}return t},wY=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:_Y(n,a)},VT(r,o,n),HT(r,i,n,c),{transform:t,final:e},{transform:SY(s,a)},gY({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var RY=(t,e)=>{for(let r of xye(t))Pye(t,r,e)},xye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Pye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Po[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Oye(a,n));r.input=Kp(o)},Oye=(t,e)=>{let r=WT(t,e,"utf8",!0);return Iye(r),Kp(r)},Iye=t=>{let e=t.find(r=>typeof r!="string"&&!gt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as Dye,appendFileSync as kye}from"fs";var zT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&bu(r,n)&&!Dr.has(e)&&Nye(n)&&(t.some(({type:s,value:i})=>s==="native"&&Mye.has(i))||t.every(({type:s})=>fn.has(s))),Nye=t=>t===1||t===2,Mye=new Set(["pipe","overlapped"]),CY=async(t,e,r,n)=>{for await(let s of t)Lye(e)||PY(s,r,n)},xY=(t,e,r)=>{for(let n of t)PY(n,e,r)},Lye=t=>t._readableState.pipes.length>0,PY=(t,e,r)=>{let n=aT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var OY=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>Uye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},Uye=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=I4(t,i,d),h=_i(f),{stdioItems:p,objectMode:m}=e[r],E=Fye([h],p,c,n),{serializedResult:S,finalResult:b=S}=Bye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});$ye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let w=a[r]?b:void 0;try{return n.error===void 0&&Gye(S,p,s),w}catch(A){return n.error=A,w}},Fye=(t,e,r,n)=>{try{return WT(t,e,r,!1)}catch(s){return n.error=s,t}},Bye=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Kp(t)};let o=j3(t,r);return n[i]?{serializedResult:o,finalResult:oI(o,!s[i],e)}:{serializedResult:o}},$ye=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!zT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=oI(t,!1,o);try{xY(a,e,n)}catch(c){r.error??=c}},Gye=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>GT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?kye(n,t):(r.add(i),Dye(n,t))}};var IY=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,yi(e,r,"all")]:Array.isArray(e)?[yi(t,r,"all"),...e]:gt(t)&&gt(e)?mO([t,e]):`${t}${e}`};import{once as uI}from"events";var NY=async(t,e)=>{let[r,n]=await qye(t);return e.isForcefullyTerminated??=!1,[r,n]},qye=async t=>{let[e,r]=await Promise.allSettled([uI(t,"spawn"),uI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?MY(t):r.value},MY=async t=>{try{return await uI(t,"exit")}catch{return MY(t)}},LY=async t=>{let[e,r]=await t;if(!Hye(e,r)&&dI(e,r))throw new qn;return[e,r]},Hye=(t,e)=>t===void 0&&e===void 0,dI=(t,e)=>t!==0||e!==null;var DY=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=Vye(t,e,r),o=i?.code==="ETIMEDOUT",a=O4(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Vye=(t,e,r)=>t!==void 0?t:dI(e,r)?new qn:void 0;var kY=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Wye(t,e,r),d=Kye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Nu(d,c,l)},Wye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=lT(t,e,r),a=zye(r),{file:c,commandArguments:l,options:u}=PT(t,e,a);Yye(u);let d=fY(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},zye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Yye=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&YT("ipcInput"),t&&YT("ipc: true"),r&&YT("detached: true"),n&&YT("cancelSignal")},YT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Kye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Xye({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h}=DY(c,r),{output:p,error:m=l}=OY({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,w)=>yi(b,r,w)),S=yi(IY(p,r),r,"all");return Jye({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Xye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{RY(i,r);let a=Qye(r);return jye(...OT(t,e,a))}catch(a){return Iu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},Qye=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:UT(e)}),Jye=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?FT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):sm({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as Bbe}from"events";import{spawn as $be}from"child_process";import GY from"process";import{once as fI,on as Zye}from"events";var UY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(wu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:AT(t)}),eTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),eTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{ET(e,s);let i=xo(t,e,r),o=new AbortController;try{return await Promise.race([tTe(i,n,o),rTe(i,r,o),nTe(i,r,o)])}catch(a){throw Ru(t),a}finally{o.abort(),yT(e,s)}},tTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await fI(t,"message",{signal:r});return n}for await(let[n]of Zye(t,"message",{signal:r}))if(e(n))return n},rTe=async(t,e,{signal:r})=>{await fI(t,"disconnect",{signal:r}),Az(e)},nTe=async(t,e,{signal:r})=>{let[n]=await fI(t,"strict:error",{signal:r});throw gT(n,e)};import{once as BY,on as sTe}from"events";var $Y=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>hI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),hI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{wu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:AT(t)}),ET(e,i);let o=xo(t,e,r),a=new AbortController,c={};return iTe(t,o,a),oTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),aTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},iTe=async(t,e,r)=>{try{await BY(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},oTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await BY(t,"strict:error",{signal:r.signal});n.error=gT(s,e),r.abort()}catch{}},aTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of sTe(r,"message",{signal:i.signal}))FY(o),yield c}catch{FY(o)}finally{i.abort(),yT(e,a),n||Ru(t),s&&await t}},FY=({error:t})=>{if(t)throw t};var qY=(t,{ipc:e})=>{Object.assign(t,VY(t,!1,e))},HY=()=>{let t=GY,e=!0,r=GY.channel!==void 0;return{...VY(t,e,r),getCancelSignal:Xz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},VY=(t,e,r)=>({sendMessage:CT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:UY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:$Y.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as cTe}from"child_process";import{PassThrough as lTe,Readable as uTe,Writable as dTe,Duplex as fTe}from"stream";var jY=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{nI(n);let a=new cTe;hTe(a,n),Object.assign(a,{readable:pTe,writable:mTe,duplex:gTe});let c=Iu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=_Te(c,o,s);return{subprocess:a,promise:l}},hTe=(t,e)=>{let r=om(),n=om(),s=om(),i=Array.from({length:e.length-3},om),o=om(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},om=()=>{let t=new lTe;return t.end(),t},pTe=()=>new uTe({read(){}}),mTe=()=>new dTe({write(){}}),gTe=()=>new fTe({read(){},write(){}}),_Te=async(t,e,r)=>Nu(t,e,r);import{createReadStream as WY,createWriteStream as zY}from"fs";import{Buffer as STe}from"buffer";import{Readable as am,Writable as ETe,Duplex as yTe}from"stream";var KY=(t,e)=>qT(TTe,t,e,!1),cm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Po[t]}.`)},YY={fileNumber:cm,generator:lI,asyncGenerator:lI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:yTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},TTe={input:{...YY,fileUrl:({value:t})=>({stream:WY(t)}),filePath:({value:{file:t}})=>({stream:WY(t)}),webStream:({value:t})=>({stream:am.fromWeb(t)}),iterable:({value:t})=>({stream:am.from(t)}),asyncIterable:({value:t})=>({stream:am.from(t)}),string:({value:t})=>({stream:am.from(t)}),uint8Array:({value:t})=>({stream:am.from(STe.from(t))})},output:{...YY,fileUrl:({value:t})=>({stream:zY(t)}),filePath:({value:{file:t,append:e}})=>({stream:zY(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ETe.fromWeb(t)}),iterable:cm,asyncIterable:cm,string:cm,uint8Array:cm}};import{on as bTe,once as XY}from"events";import{PassThrough as ATe,getDefaultHighWaterMark as vTe}from"stream";import{finished as ZY}from"stream/promises";function uc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)mI(s);let e=t.some(({readableObjectMode:s})=>s),r=wTe(t,e),n=new pI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var wTe=(t,e)=>{if(t.length===0)return vTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},pI=class extends ATe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(mI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=RTe(this,this.#e,this.#i);let r=PTe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(mI(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},RTe=async(t,e,r)=>{KT(t,QY);let n=new AbortController;try{await Promise.race([CTe(t,n),xTe(t,e,r,n)])}finally{n.abort(),KT(t,-QY)}},CTe=async(t,{signal:e})=>{try{await ZY(t,{signal:e,cleanup:!0})}catch(r){throw e6(t,r),r}},xTe=async(t,e,r,{signal:n})=>{for await(let[s]of bTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},mI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},PTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{KT(t,JY);let a=new AbortController;try{await Promise.race([OTe(i,e,a),ITe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),NTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),KT(t,-JY)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?gI(t):MTe(t))},OTe=async(t,e,{signal:r})=>{try{await t,r.aborted||gI(e)}catch(n){r.aborted||e6(e,n)}},ITe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await ZY(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;t6(o)?s.add(e):r6(t,o)}},NTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await XY(t,s,{signal:i}),!t.readable)return XY(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},MTe=t=>{t.writable&&t.end()},e6=(t,e)=>{t6(e)?gI(t):r6(t,e)},t6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gI=t=>{(t.readable||t.writable)&&t.destroy()},r6=(t,e)=>{t.destroyed||(t.once("error",LTe),t.destroy(e))},LTe=()=>{},KT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},QY=2,JY=1;import{finished as n6}from"stream/promises";var Lu=(t,e)=>{t.pipe(e),DTe(t,e),kTe(t,e)},DTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await n6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}_I(e)}},_I=t=>{t.writable&&t.end()},kTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await n6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}SI(t)}},SI=t=>{t.readable&&t.destroy()};var s6=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>fn.has(c)))UTe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!fn.has(c)))BTe({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:uc(i);Lu(o,s)}},UTe=(t,e,r,n)=>{r==="output"?Lu(t.stdio[n],e):Lu(e,t.stdio[n]);let s=FTe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},FTe=["stdin","stdout","stderr"],BTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;$Te(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},$Te=(t,{signal:e})=>{Gn(t)&&oc(t,GTe,e)},GTe=2;import{addAbortListener as VTe}from"events";var dc=[];dc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&dc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&dc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var XT=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",EI=Symbol.for("signal-exit emitter"),yI=globalThis,qTe=Object.defineProperty.bind(Object),TI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(yI[EI])return yI[EI];qTe(yI,EI,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},QT=class{},HTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),bI=class extends QT{onExit(){return()=>{}}load(){}unload(){}},AI=class extends QT{#e=vI.platform==="win32"?"SIGINT":"SIGHUP";#r=new TI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of dc)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!XT(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of dc)try{let r=this.#s[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,dc.forEach(e=>{let r=this.#s[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#i,this.#r.count-=1)}#a(e){return XT(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&XT(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},vI=globalThis.process,{onExit:i6,load:ZQe,unload:eJe}=HTe(XT(vI)?new AI(vI):new bI);var o6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=i6(()=>{t.kill()});VTe(n,()=>{s()})};var c6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=cT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=jTe(r,n,s),{sourceStream:d,sourceError:f}=zTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},jTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=WTe(t,e,...r),a=ST(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},WTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(a6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hO(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[s,i,o]=Jy(r,...n);return{destination:e(a6)(s,i,o),pipeOptions:o}}if(Rs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},a6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),zTe=(t,e)=>{try{return{sourceStream:Cu(t,e)}}catch(r){return{sourceError:r}}};var u6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=YTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw wI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},YTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return SI(t),n;if(e!==void 0)return _I(r),e},wI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iu({error:t,command:l6,escapedCommand:l6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),l6="source.pipe(destination)";var d6=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as KTe}from"stream/promises";var f6=(t,e,r)=>{let n=JT.has(e)?QTe(t,e):XTe(t,e);return oc(t,ZTe,r.signal),oc(e,ebe,r.signal),JTe(e),n},XTe=(t,e)=>{let r=uc([t]);return Lu(r,e),JT.set(e,r),r},QTe=(t,e)=>{let r=JT.get(e);return r.add(t),r},JTe=async t=>{try{await KTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}JT.delete(t)},JT=new WeakMap,ZTe=2,ebe=1;import{aborted as tbe}from"util";var h6=(t,e)=>t===void 0?[]:[rbe(t,e)],rbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await tbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw wI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var ZT=(t,...e)=>{if(ot(e[0]))return ZT.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=c6(t,...e),s=nbe({...n,destination:r});return s.pipe=ZT.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},nbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=sbe(t,s);u6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=f6(e,i,d);return await Promise.race([d6(u),...h6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},sbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dbe}from"timers/promises";import{on as ibe}from"events";import{getDefaultHighWaterMark as obe}from"stream";var eb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return abe(e,o),m6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},abe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},RI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;cbe(e,o,t);let a=t.readableObjectMode&&!i;return m6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},cbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},m6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=ibe(t,"data",{signal:e.signal,highWaterMark:p6,highWatermark:p6});return lbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},CI=obe(!0),p6=CI,lbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=ube({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*lc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*im(a)}},ube=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[VT(t,r,!e),HT(t,s,!n,{})].filter(Boolean);var g6=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=fbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([hbe(t),d]);return}let f=sI(c,r),h=RI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([pbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},fbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!zT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=RI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await CY(a,t,r,i)},hbe=async t=>{await dbe(),t.readableFlowing===null&&t.resume()},pbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await LT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await DT(r,{maxBuffer:i})):await Ou(r,{maxBuffer:i})}catch(a){return _6(C4({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},xI=async t=>{try{return await t}catch(e){return _6(e)}},_6=({bufferedData:t})=>H3(t)?new Uint8Array(t):t;import{finished as mbe}from"stream/promises";var lm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=gbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],mbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Ebe(a,e,r,n)}finally{o.abort()}},gbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_be(t,r,n),n},_be=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Sbe(e,r),n.call(t,...s)}},Sbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ebe=(t,e,r,n)=>{if(!ybe(t,e,r,n))throw t},ybe=(t,e,r,n=!0)=>r.propagating?S6(t)||tb(t):(r.propagating=!0,PI(r,e)===n?S6(t):tb(t)),PI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",tb=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",S6=t=>t?.code==="EPIPE";var E6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>OI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),OI=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=lm(t,e,l);if(PI(l,e)){await u;return}let[d]=await Promise.all([g6({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var y6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?uc([t,e].filter(Boolean)):void 0,T6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>OI({...Tbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:bbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),Tbe=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},bbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Abe}from"events";var b6=t=>bu(t,"ipc"),A6=(t,e)=>{let r=aT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var v6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=b6(i),a=Si(e,"ipc"),c=Si(r,"ipc");for await(let l of hI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(x4(t,s,c),s.push(l)),o&&A6(l,i);return s},w6=async(t,e)=>(await Promise.allSettled([t]),e);var R6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let b=NY(t,f),w={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=E6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),G=T6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),x=[],F=v6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),O=vbe(m,t,w),P=wbe(p,w);try{return await Promise.race([Promise.all([{},LY(b),Promise.all(A),G,F,o4(t,d),...O,...P]),E,Rbe(t,S),...t4(t,i,f,S),...bz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Zz({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},b,Promise.all(A.map(_=>xI(_))),xI(G),w6(F,x),Promise.allSettled(O),Promise.allSettled(P)])}},vbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:lm(n,s,r)),wbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>lm(o,n,e,{isSameDirection:fn.has(s),stopOnExit:s==="native"}))),Rbe=async(t,{signal:e})=>{let[r]=await Abe(t,"error",{signal:e});throw r};var C6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),um=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Du=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as Cbe}from"stream";import{callbackify as xbe}from"util";import{finished as x6}from"stream/promises";var II=async t=>{if(t!==void 0)try{await NI(t)}catch{}},P6=async t=>{if(t!==void 0)try{await MI(t)}catch{}},NI=async t=>{await x6(t,{cleanup:!0,readable:!1,writable:!0})},MI=async t=>{await x6(t,{cleanup:!0,readable:!0,writable:!1})},rb=async(t,e)=>{if(await t,e)throw e},nb=(t,e,r)=>{r&&!tb(r)?t.destroy(r):e&&t.destroy()};var O6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=LI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=DI(a,o),{read:f,onStdoutDataDone:h}=kI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Cbe({read:f,destroy:xbe(FI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return UI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},LI=(t,e,r)=>{let n=Cu(t,e),s=um(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},DI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:CI},kI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=eb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Pbe(this,o,i)},onStdoutDataDone:i}},Pbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},UI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await MI(t),await n,await II(s),await e,r.readable&&r.push(null)}catch(i){await II(s),I6(r,i)}},FI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Du(r,e)&&(I6(t,n),await rb(e,n))},I6=(t,e)=>{nb(t,t.readable,e)};import{Writable as Obe}from"stream";import{callbackify as N6}from"util";var M6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=BI(t,r,e),o=new Obe({...$I(n,t,s),destroy:N6(qI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return GI(n,o),o},BI=(t,e,r)=>{let n=ST(t,e),s=um(r,n,"writableFinal"),i=um(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},$I=(t,e,r)=>({write:Ibe.bind(void 0,t),final:N6(Nbe.bind(void 0,t,e,r))}),Ibe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Nbe=async(t,e,r)=>{await Du(r,e)&&(t.writable&&t.end(),await e)},GI=async(t,e,r)=>{try{await NI(t),e.writable&&e.end()}catch(n){await P6(r),L6(e,n)}},qI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Du(r,e),await Du(n,e)&&(L6(t,s),await rb(e,s))},L6=(t,e)=>{nb(t,t.writable,e)};import{Duplex as Mbe}from"stream";import{callbackify as Lbe}from"util";var D6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=LI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=BI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=DI(c,a),{read:E,onStdoutDataDone:S}=kI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new Mbe({read:E,...$I(u,t,d),destroy:Lbe(Dbe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return UI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),GI(u,b,c),b},Dbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([FI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),qI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var HI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=Cu(t,r),a=eb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return kbe(a,o,t)},kbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var k6=(t,{encoding:e})=>{let r=C6();t.readable=O6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=M6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=D6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HI.bind(void 0,t,e),t[Symbol.asyncIterator]=HI.bind(void 0,t,e,{})};var U6=(t,e)=>{for(let[r,n]of Fbe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},Ube=(async()=>{})().constructor.prototype,Fbe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Ube,t)]);var F6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Gbe(t,e,r),{subprocess:f,promise:h}=Hbe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ZT.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),U6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Gbe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=lT(t,e,r),{file:a,commandArguments:c,options:l}=PT(t,e,r),u=qbe(l),d=KY(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},qbe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},Hbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=$be(...OT(t,e,r))}catch(p){return jY({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;Bbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];s6(c,a,l),o6(c,r,l);let d={},f=ws();c.kill=yz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=y6(c,r),k6(c,r),qY(c,r);let h=Vbe({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:h}},Vbe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,h],p,m,E]=await R6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,G)=>yi(A,e,G)),b=yi(m,e,"all"),w=jbe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Nu(w,n,e)},jbe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?sm({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):FT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var sb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Wbe(n,t[n],s)]));return{...t,...r}},Wbe=(t,e,r)=>zbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,zbe=new Set(["env",...EO]);var Oo=(t,e,r,n)=>{let s=(o,a,c)=>Oo(o,a,r,c),i=(...o)=>Ybe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Ybe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,sb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Kbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?kY(a,c,l):F6(a,c,l,s)},Kbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=K3(e)?X3(e,r):[e,...r],[o,a,c]=Jy(...i),l=sb(sb(n,s),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:h}};var B6=({file:t,commandArguments:e})=>G6(t,e),$6=({file:t,commandArguments:e})=>({...G6(t,e),isSync:!0}),G6=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=Xbe(t);return{file:r,commandArguments:n}},Xbe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(Qbe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},Qbe=/ +/g;var q6=(t,e,r)=>{t.sync=e(Jbe,r),t.s=t.sync},H6=({options:t})=>V6(t),Jbe=({options:t})=>({...V6(t),isSync:!0}),V6=t=>({options:{...Zbe(t),...t}}),Zbe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},j6={preferLocal:!0};var W6=Oo(()=>({})),HZe=Oo(()=>({isSync:!0})),z6=Oo(B6),VZe=Oo($6),jZe=Oo(n4),WZe=Oo(H6,{},j6,q6),{sendMessage:zZe,getOneMessage:YZe,getEachMessage:KZe,getCancelSignal:XZe}=HY();var eAe=!1;var Ti=()=>eAe;var dm=null,Y6=t=>(dm&&dm.destroy(),dm=new bi({totalAllowedTime:t}),dm),K6=()=>dm;var bi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ti())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Wy({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ge.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var X6={name:"@netlify/agent-runner-cli",type:"module",version:"1.136.0-ex-2324.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var sAe=rAe(import.meta.url),iAe=Ai.dirname(sAe),oAe=nAe(import.meta.url),ku=de("shell"),VI=new Set,Q6={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=aAe(e,r),i={...Q6,...s},o=W6(t,n,i);Z6(o,i),r8(o);let a=r?.idleTimeout;return a&&a>0&&t8(o,a),o},J6=(t,e)=>{let r={...Q6,...e},n=z6(t,r);return Z6(n,r),r8(n),e?.idleTimeout&&e.idleTimeout>0&&t8(n,e.idleTimeout),n},aAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Z6=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new qp).pipe(vi.stdout),t.stderr?.pipe(new qp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},jI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),ku.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ku.error("Error killing process:",r),!1}},e8=t=>jI(t,"SIGKILL"),t8=(t,e)=>{let r=null,n=()=>{ku.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),jI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ku.log(`Force killing idle process ${t.pid}`),e8(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},r8=t=>{VI.add(t);let e=K6();if(e){let r=e.onTimesUp(()=>{ku.log(`Global timer expired, killing process ${t.pid}`),jI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ku.log(`Force killing process ${t.pid} after timeout`),e8(t))},5e3)});t.on("exit",()=>{VI.delete(t),r()}),t.on("error",()=>{VI.delete(t),r()})}};function Io(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=oAe.resolve(X6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(ib.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(ib.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(ib.existsSync(r))return r;let n=Ai.join(iAe,"..","node_modules",".bin",e);if(ib.existsSync(n))return n}var cAe=de("utils"),lAe=t=>new Promise(e=>{setTimeout(e,t)});var ob=(t,e=3e3)=>{let r=!1,n=null,s=[],i=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{s.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return i=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await lAe(e),!n)return r=!1,i=null,u;let d=n,f=s;n=null,s=[],u=await t(...d),f.forEach(h=>{h(u)})}})(),l};return o.flush=async()=>{if((r||n)&&i)return await i,o.flush()},o.cancel=()=>{n=null,s.forEach(a=>a(void 0)),s=[]},o},Uu=(t,e,r=!1)=>{let n=null,s=null,i=null,o=function(...a){s=a,i=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(i,s),s=null,i=null)},e),c&&(t.apply(i,s),s=null,i=null)};return o.cancel=()=>{clearTimeout(n),n=null,s=null,i=null},o.flush=()=>{if(n){clearTimeout(n);let a=s,c=i;n=null,s=null,i=null,t.apply(c,a)}},o},n8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):cAe.error("Could not parse JSON",n))}},uAe=t=>t.charAt(0).toUpperCase()+t.slice(1),No=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():uAe(e)).join(" ");function fc(t,e){e&&t.log(`Skill invoked: ${e}`)}var s8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),i8=(t,e,r=!1)=>{if(r)return;let n=60,s=55,i=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${i}`;if(c.length>s)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var WI=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},dAe=1e4,zI=(t,e=dAe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as o8}from"buffer";import fAe from"path";var a8=de("repo"),mr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),l8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{a8.info("Getting runner diffs");let n=await pAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=gAe(i);await _Ae(m,r)}a8.info("Changes after processing"),await KI(r);let o=await QI(i,r);if(await YI(o,r),s=await mAe(r),!s)return{hasChanges:!1,ignored:o};await mr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await mr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await c8(r),{hasChanges:!1,ignored:o};let u=await mr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await mr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await mr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=o8.from(S).toString("base64"))}await c8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=o8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},c8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await mr(["reset","--soft","HEAD~1"],{cwd:t})},YI=async(t=[],e=process.cwd())=>{await mr(["add",".",...t],{cwd:e})},KI=async(t=process.cwd())=>{let e=await mr(["status","-s"],{cwd:t});return String(e.stdout??"")},u8=/.. (.+)?\.log$/,hAe=[u8],pAe=async(t=process.cwd())=>{let e=await KI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
89
89
  `).filter(s=>hAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},mAe=async(t=process.cwd())=>{try{return await mr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},XI=async(t=process.cwd())=>{let{stdout:e}=await mr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},d8=async(t=process.cwd())=>{let{stdout:e}=await mr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},QI=async(t,e=process.cwd())=>{t||=await KI(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
90
90
  `).forEach(s=>{r.forEach(o=>{let a=s===`?? ${o}`,c=s.startsWith(`?? ${o}/`)||s.startsWith(`?? ${o}${fAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(u8)?.[1];i&&n.push(`:!${i}.log`)}),n},JI=async(t=process.cwd())=>{await mr(["reset","--hard","HEAD"],{cwd:t})},f8=async(t=process.cwd())=>{let e=await mr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
91
91
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},gAe=t=>{let e=t.split(`
@@ -361,7 +361,7 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
361
361
 
362
362
  Use the following file for the complete context of the ask, the environment, and what's available. ${u} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
363
363
  `),w};var qRe=de("prompt"),M5=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:s,resumePrompt:i})=>{let o=await N5({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:s,resumePrompt:i});return process.env.AGENT_RUNNER_DEBUG&&qRe.log("Contextful Prompt:",o),{prompt:o}};var HRe,PM;var OM=()=>HRe,L5=de("session_manager"),IM=async(t,e)=>{if(!jt().idleTimeoutEnabled||!t||t===e)return;let r=mf[t];if(r)try{await r.clean(),L5.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){L5.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{PM=void 0}},NM=t=>{PM=t};var D5=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===PM};var k5=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import Vi from"fs/promises";import B7 from"os";import ji from"path";import{rm as fk}from"fs/promises";import{resolve as jRe}from"path";var WRe=".netlify/cache/",Jc=function({cacheDir:t=WRe,cwd:e="."}={}){return jRe(e,t)};import{promises as tNe}from"fs";import{basename as h7,dirname as p7,join as rNe}from"path";import _Ie from"process";import SIe from"events";import De from"path";import EIe from"os";async function fg(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:s}={}){return new Promise((i,o)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,h=0,p=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),E=()=>{w(s.reason)},S=()=>{s?.removeEventListener("abort",E)},b=G=>{i(G),S()},w=G=>{u=!0,d=!0,o(G),S()};s&&(s.aborted&&w(s.reason),s.addEventListener("abort",E,{once:!0}));let A=async()=>{if(d)return;let G=await m.next(),x=p;if(p++,G.done){if(f=!0,h===0&&!d){if(!n&&c.length>0){w(new AggregateError(c));return}if(d=!0,l.size===0){b(a);return}let F=[];for(let[O,P]of a.entries())l.get(O)!==U5&&F.push(P);b(F)}return}h++,(async()=>{try{let F=await G.value;if(d)return;let O=await e(F,x);O===U5&&l.set(x,O),a[x]=O,h--,await A()}catch(F){if(n)w(F);else{c.push(F),h--;try{await A()}catch(O){w(O)}}}})()};(async()=>{for(let G=0;G<r;G++){try{await A()}catch(x){w(x);break}if(f||u)break}})()})}var U5=Symbol("skip");import el from"path";import Vmt,{constants as GM}from"fs";import qM from"fs/promises";var MM=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},LM=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},F5=t=>globalThis.DOMException===void 0?new LM(t):new DOMException(t),B5=t=>{let e=t.reason===void 0?F5("This operation was aborted."):t.reason;return e instanceof Error?e:F5(e)};function DM(t,e){let{milliseconds:r,fallback:n,message:s,customTimers:i={setTimeout,clearTimeout}}=e,o,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:h}=e;h.aborted&&d(B5(h)),a=()=>{d(B5(h))},h.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new MM;o=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(h){d(h)}return}typeof t.cancel=="function"&&t.cancel(),s===!1?u():s instanceof Error?d(s):(f.message=s??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(h){d(h)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,o),o=void 0},l}var zRe=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function YRe(t,e,r){let n,s=new Promise((i,o)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=zRe(t),d=(...h)=>{let p=r.multiArgs?h:h[0];r.filter&&!r.filter(p)||(c.push(p),r.count===c.length&&(n(),i(c)))},f=h=>{n(),o(h)};n=()=>{for(let h of a)u(h,d);for(let h of r.rejectionEvents)u(h,f)};for(let h of a)l(h,d);for(let h of r.rejectionEvents)l(h,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(s.cancel=n,typeof r.timeout=="number"){let i=DM(s,{milliseconds:r.timeout});return i.cancel=n,i}return s}function bA(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=YRe(t,e,r),s=n.then(i=>i[0]);return s.cancel=n.cancel,s}var ar=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Kn=Ar(X5(),1);import{promisify as hg}from"util";var Umt=hg(Kn.default.stat),iCe=hg(Kn.default.lstat),oCe=hg(Kn.default.utimes),aCe=hg(Kn.default.chmod),cCe=hg(Kn.default.mkdir),Fmt=Kn.default.closeSync.bind(Kn.default),Q5=Kn.default.createWriteStream.bind(Kn.default);async function J5(t,e){let r=Kn.default.createReadStream(t,e);try{await bA(r,["readable","end"])}catch(n){throw new ar(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var $M=t=>iCe(t).catch(e=>{throw new ar(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),Z5=(t,e,r)=>oCe(t,e,r).catch(n=>{throw new ar(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),e9=(t,e)=>aCe(t,e).catch(r=>{throw new ar(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var t9=(t,e)=>cCe(t,{...e,recursive:!0}).catch(r=>{throw new ar(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var uCe=(t,e,r)=>({sourcePath:el.resolve(t,e),destinationPath:el.resolve(t,r)}),dCe=(t,e)=>{if(!t.isFile())throw Object.assign(new ar(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function r9(t,e,r={}){if(!t||!e)throw new ar("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=uCe(r.cwd,t,e)),r={overwrite:!0,...r};let n=await $M(t),{size:s}=n;dCe(n,t);let i=el.dirname(e);if(el.parse(i).root===i||await t9(el.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await J5(t),c=Q5(e,{flags:r.overwrite?"w":"wx"}),l=h=>{r.onProgress({sourcePath:el.resolve(t),destinationPath:el.resolve(e),size:s,writtenBytes:h,percent:h===s?1:h/s})},u=-1;a.on("data",()=>{let h=c.bytesWritten,p=h===s?1:h/s;(p===1||p-u>=.01)&&(u=p,l(h))});let d;a.once("error",h=>{d=new ar(`Cannot read from \`${t}\`: ${h.message}`,{cause:h})});let f=!1;try{let h=bA(c,"close");a.pipe(c),await h,l(s),f=!0}catch(h){throw new ar(`Cannot write to \`${e}\`: ${h.message}`,{cause:h})}if(d)throw d;if(f){let h=await $M(t);return Promise.all([Z5(e,h.atime,h.mtime).catch(p=>{if(p.code!=="EPERM")throw p}),e9(e,h.mode)])}}else{let a=r.overwrite?GM.COPYFILE_FICLONE:GM.COPYFILE_FICLONE|GM.COPYFILE_EXCL;try{await qM.copyFile(t,e,a),await Promise.all([qM.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),qM.chmod(e,n.mode)])}catch(c){throw new ar(c.message,{cause:c})}}}async function HM(t,e,r){return(await fg(t,(s,i)=>Promise.all([e(s,i),s]),r)).filter(s=>!!s[0]).map(s=>s[1])}import EJ from"process";import uIe from"fs";import Pf from"path";import{on as fCe,once as hCe}from"events";import{PassThrough as pCe}from"stream";import{finished as i9}from"stream/promises";function zM(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)jM(s);let e=t.some(({readableObjectMode:s})=>s),r=mCe(t,e),n=new VM({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return t.length===0&&c9(n),n}var mCe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},VM=class extends pCe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){jM(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=gCe(this,this.#e),ECe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return jM(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},gCe=async(t,e)=>{CA(t,n9);let r=new AbortController;try{await Promise.race([_Ce(t,r),SCe(t,e,r)])}finally{r.abort(),CA(t,-n9)}},_Ce=async(t,{signal:e})=>{await i9(t,{signal:e,cleanup:!0})},SCe=async(t,e,{signal:r})=>{for await(let[n]of fCe(t,"unpipe",{signal:r}))e.has(n)&&n.emit(a9)},jM=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ECe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i})=>{CA(t,s9);let o=new AbortController;try{await Promise.race([yCe(i,e),TCe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:o}),bCe({stream:e,streams:r,ended:n,aborted:s,controller:o})])}finally{o.abort(),CA(t,-s9)}r.size===n.size+s.size&&(n.size===0&&s.size>0?WM(t):c9(t))},o9=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yCe=async(t,e)=>{try{await t,WM(e)}catch(r){o9(r)?WM(e):l9(e,r)}},TCe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await i9(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;o9(o)?s.add(e):l9(t,o)}},bCe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:s}})=>{await hCe(t,a9,{signal:s}),e.delete(t),r.delete(t),n.delete(t)},a9=Symbol("unpipe"),c9=t=>{t.writable&&t.end()},WM=t=>{(t.readable||t.writable)&&t.destroy()},l9=(t,e)=>{t.destroyed||(t.once("error",ACe),t.destroy(e))},ACe=()=>{},CA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},n9=2,s9=1;var Of=Ar(yg(),1);import DOe from"fs";import kOe from"fs/promises";async function MD(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await kOe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function LD(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return DOe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var A_t=MD.bind(void 0,"stat","isFile"),eJ=MD.bind(void 0,"stat","isDirectory"),v_t=MD.bind(void 0,"lstat","isSymbolicLink"),w_t=LD.bind(void 0,"statSync","isFile"),tJ=LD.bind(void 0,"statSync","isDirectory"),R_t=LD.bind(void 0,"lstatSync","isSymbolicLink");var qD=Ar(yg(),1),uJ=Ar(GD(),1);import nIe from"process";import sIe from"fs";import iIe from"fs/promises";import xf from"path";function Cf(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var bg=t=>t[0]==="!";var oIe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],dJ={absolute:!0,dot:!0},fJ="**/.gitignore",aIe=(t,e)=>bg(t)?"!"+xf.posix.join(e,t.slice(1)):xf.posix.join(e,t),cIe=(t,e)=>{let r=Cf(xf.relative(e,xf.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>aIe(n,r))},lIe=(t,e)=>{if(e=Cf(e),xf.isAbsolute(t)){if(Cf(t).startsWith(e))return xf.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},hJ=(t,e)=>{let r=t.flatMap(s=>cIe(s,e)),n=(0,uJ.default)().add(r);return s=>(s=pr(s),s=lIe(s,e),s?n.ignores(Cf(s)):!1)},pJ=(t={})=>({cwd:pr(t.cwd)??nIe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...oIe]}),mJ=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=pJ(e),o=await(0,qD.default)(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...dJ}),a=await Promise.all(o.map(async c=>({filePath:c,content:await iIe.readFile(c,"utf8")})));return hJ(a,r)},gJ=(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=pJ(e),a=qD.default.sync(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...dJ}).map(c=>({filePath:c,content:sIe.readFileSync(c,"utf8")}));return hJ(a,r)};var dIe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},yJ=(t,e)=>{let r=bg(t)?t.slice(1):t;return Pf.isAbsolute(r)?r:Pf.join(e,r)},TJ=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(s=>Pf.posix.join(t,`**/${Pf.extname(s)?s:`${s}${n}`}`)):[Pf.posix.join(t,`**${n?`/*${n}`:""}`)]},_J=async(t,{cwd:e=EJ.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async i=>await eJ(yJ(i,e))?TJ({directoryPath:i,files:r,extensions:n}):i))).flat(),SJ=(t,{cwd:e=EJ.cwd(),files:r,extensions:n}={})=>t.flatMap(s=>tJ(yJ(s,e))?TJ({directoryPath:s,files:r,extensions:n}):s),HD=t=>(t=[...new Set([t].flat())],dIe(t),t),fIe=t=>{if(!t)return;let e;try{e=uIe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},bJ=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:pr(t.cwd)},fIe(t.cwd),t),AJ=t=>async(e,r)=>t(HD(e),bJ(r)),iv=t=>(e,r)=>t(HD(e),bJ(r)),vJ=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?HD(e):[];return r&&n.push(fJ),n},hIe=async t=>{let e=vJ(t);return RJ(e.length>0&&await mJ(e,t))},wJ=t=>{let e=vJ(t);return RJ(e.length>0&&gJ(e,t))},RJ=t=>{let e=new Set;return r=>{let n=Pf.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},CJ=(t,e)=>t.flat().filter(r=>e(r)),xJ=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(i=>bg(i));if(n===-1){r.push({patterns:t,options:e});break}let s=t[n].slice(1);for(let i of r)i.options.ignore.push(s);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,s]}}),t=t.slice(n+1)}return r},PJ=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),OJ=async(t,e)=>{let r=xJ(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=PJ(s,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([_J(a,i),_J(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},VD=(t,e)=>{let r=xJ(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=PJ(s,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=SJ(a,i),c.ignore=SJ(c.ignore,{cwd:n}),{patterns:a,options:c}})},z_t=AJ(async(t,e)=>{let[r,n]=await Promise.all([OJ(t,e),hIe(e)]),s=await Promise.all(r.map(i=>(0,Of.default)(i.patterns,i.options)));return CJ(s,n)}),IJ=iv((t,e)=>{let r=VD(t,e),n=wJ(e),s=r.map(i=>Of.default.sync(i.patterns,i.options));return CJ(s,n)}),Y_t=iv((t,e)=>{let r=VD(t,e),n=wJ(e),s=r.map(o=>Of.default.stream(o.patterns,o.options));return zM(s).filter(o=>n(o))}),sl=iv((t,e)=>t.some(r=>Of.default.isDynamicPattern(r,e))),K_t=AJ(OJ),X_t=iv(VD),{convertPathToPattern:Q_t}=Of.default;var MJ=Ar(mL(),1);var pa=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import av from"path";import NJ from"fs";var pIe=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],mIe=new RegExp(pIe.join("|"));function gIe(t){return mIe.test(t)}function ov(t){return!gIe(t)}var Ag=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!sl(e)&&NJ.existsSync(e)&&NJ.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return av.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(s=>s?sl(s):!1),n=e.slice(0,r).join("/");return n?av.isAbsolute(n)?n:av.join(this.options.cwd,n):this.destination}hasMagic(){return sl(this.options.flat?this.path:this.originalPath)}getMatches(){let e=IJ(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>ov(av.basename(r)))),e}};var yIe={ignoreJunk:!0,flat:!1,cwd:_Ie.cwd()},jD=class{constructor(e,r,n){this.path=e.split("/").join(De.sep),this.relativePath=r.split("/").join(De.sep),this.pattern=n,Object.freeze(this)}get name(){return De.basename(this.path)}get nameWithoutExtension(){return De.basename(this.path,De.extname(this.path))}get extension(){return De.extname(this.path).slice(1)}},TIe=t=>t.flatMap(e=>MJ.default.braces(e,{expand:!0,nodupes:!0})),bIe=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?De.isAbsolute(e)?De.join(e,t.name):De.join(r.cwd,e,t.name):De.join(e,De.relative(t.pattern.normalizedPath,t.path)):De.isAbsolute(e)?De.join(e,t.name):t.pattern.isDirectory&&De.relative(r.cwd,t.path).startsWith("..")?De.join(r.cwd,e,De.basename(t.pattern.originalPath),De.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?De.join(r.cwd,e,De.basename(t.pattern.originalPath),De.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?De.join(r.cwd,e,De.basename(t.pattern.originalPath)):De.join(r.cwd,e,De.relative(r.cwd,t.path)),AIe=(t,e)=>{let r=De.dirname(t);if(typeof e=="string")return De.join(r,e);if(typeof e=="function"){let n=De.basename(t);return De.join(r,e(n))}return t};function WD(t,e,{concurrency:r=EIe.availableParallelism(),...n}={}){let s=new Map,i=new SIe;n={...yIe,...n};let o=(async()=>{let a=[],c=0,l=0,u=TIe([t??[]].flat()).map(p=>p.replaceAll("\\","/")),d=u.filter(p=>!p.startsWith("!")),f=u.filter(p=>p.startsWith("!"));if(d.length===0||!e)throw new pa("`source` and `destination` required");u=u.map(p=>new Ag(p,e,{...n,ignore:f}));for(let p of u){let m=[];try{m=p.getMatches()}catch(E){throw new pa(`Cannot glob \`${p.originalPath}\`: ${E.message}`,{cause:E})}if(m.length===0&&!sl(p.originalPath)&&!sl(f))throw new pa(`Cannot copy \`${p.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(E=>new jD(E,De.relative(n.cwd,E),p))]}n.filter!==void 0&&(a=await HM(a,n.filter,{concurrency:1024})),a.length===0&&i.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let h=p=>{let m=s.get(p.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==p.writtenBytes||m.percent!==p.percent)&&(l-=m.writtenBytes,l+=p.writtenBytes,p.percent===1&&m.percent!==1&&c++,s.set(p.sourcePath,{writtenBytes:p.writtenBytes,percent:p.percent}),i.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:p.sourcePath,destinationPath:p.destinationPath}))};return fg(a,async p=>{let m=AIe(bIe({entry:p,destination:e,options:n}),n.rename);try{await r9(p.path,m,{...n,onProgress:h})}catch(E){throw new pa(`Cannot copy from \`${p.relativePath}\` to \`${m}\`: ${E.message}`,{cause:E})}return m},{concurrency:r})})();return o.on=(...a)=>(i.on(...a),o),o}import JJ from"process";import jIe from"fs";import Mf from"path";import{on as vIe,once as wIe}from"events";import{PassThrough as RIe}from"stream";import{finished as kJ}from"stream/promises";function XD(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)YD(s);let e=t.some(({readableObjectMode:s})=>s),r=CIe(t,e),n=new zD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return t.length===0&&BJ(n),n}var CIe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},zD=class extends RIe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){YD(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=xIe(this,this.#e),IIe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return YD(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},xIe=async(t,e)=>{cv(t,LJ);let r=new AbortController;try{await Promise.race([PIe(t,r),OIe(t,e,r)])}finally{r.abort(),cv(t,-LJ)}},PIe=async(t,{signal:e})=>{await kJ(t,{signal:e,cleanup:!0})},OIe=async(t,e,{signal:r})=>{for await(let[n]of vIe(t,"unpipe",{signal:r}))e.has(n)&&n.emit(FJ)},YD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},IIe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i})=>{cv(t,DJ);let o=new AbortController;try{await Promise.race([NIe(i,e),MIe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:o}),LIe({stream:e,streams:r,ended:n,aborted:s,controller:o})])}finally{o.abort(),cv(t,-DJ)}r.size===n.size+s.size&&(n.size===0&&s.size>0?KD(t):BJ(t))},UJ=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",NIe=async(t,e)=>{try{await t,KD(e)}catch(r){UJ(r)?KD(e):$J(e,r)}},MIe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await kJ(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;UJ(o)?s.add(e):$J(t,o)}},LIe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:s}})=>{await wIe(t,FJ,{signal:s}),e.delete(t),r.delete(t),n.delete(t)},FJ=Symbol("unpipe"),BJ=t=>{t.writable&&t.end()},KD=t=>{(t.readable||t.writable)&&t.destroy()},$J=(t,e)=>{t.destroyed||(t.once("error",DIe),t.destroy(e))},DIe=()=>{},cv=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},LJ=2,DJ=1;var Lf=Ar(yg(),1);import kIe from"fs";import UIe from"fs/promises";async function QD(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await UIe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function JD(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return kIe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var ASt=QD.bind(void 0,"stat","isFile"),GJ=QD.bind(void 0,"stat","isDirectory"),vSt=QD.bind(void 0,"lstat","isSymbolicLink"),wSt=JD.bind(void 0,"statSync","isFile"),qJ=JD.bind(void 0,"statSync","isDirectory"),RSt=JD.bind(void 0,"lstatSync","isSymbolicLink");var ZD=Ar(yg(),1),HJ=Ar(GD(),1);import FIe from"process";import BIe from"fs";import $Ie from"fs/promises";import Nf from"path";function If(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var vg=t=>t[0]==="!";var GIe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],VJ={absolute:!0,dot:!0},jJ="**/.gitignore",qIe=(t,e)=>vg(t)?"!"+Nf.posix.join(e,t.slice(1)):Nf.posix.join(e,t),HIe=(t,e)=>{let r=If(Nf.relative(e,Nf.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>qIe(n,r))},VIe=(t,e)=>{if(e=If(e),Nf.isAbsolute(t)){if(If(t).startsWith(e))return Nf.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},WJ=(t,e)=>{let r=t.flatMap(s=>HIe(s,e)),n=(0,HJ.default)().add(r);return s=>(s=pr(s),s=VIe(s,e),s?n.ignores(If(s)):!1)},zJ=(t={})=>({cwd:pr(t.cwd)??FIe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...GIe]}),YJ=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=zJ(e),o=await(0,ZD.default)(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...VJ}),a=await Promise.all(o.map(async c=>({filePath:c,content:await $Ie.readFile(c,"utf8")})));return WJ(a,r)},KJ=(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=zJ(e),a=ZD.default.sync(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...VJ}).map(c=>({filePath:c,content:BIe.readFileSync(c,"utf8")}));return WJ(a,r)};var WIe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},ZJ=(t,e)=>{let r=vg(t)?t.slice(1):t;return Mf.isAbsolute(r)?r:Mf.join(e,r)},e7=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(s=>Mf.posix.join(t,`**/${Mf.extname(s)?s:`${s}${n}`}`)):[Mf.posix.join(t,`**${n?`/*${n}`:""}`)]},XJ=async(t,{cwd:e=JJ.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async i=>await GJ(ZJ(i,e))?e7({directoryPath:i,files:r,extensions:n}):i))).flat(),QJ=(t,{cwd:e=JJ.cwd(),files:r,extensions:n}={})=>t.flatMap(s=>qJ(ZJ(s,e))?e7({directoryPath:s,files:r,extensions:n}):s),ek=t=>(t=[...new Set([t].flat())],WIe(t),t),zIe=t=>{if(!t)return;let e;try{e=jIe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},t7=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:pr(t.cwd)},zIe(t.cwd),t),r7=t=>async(e,r)=>t(ek(e),t7(r)),lv=t=>(e,r)=>t(ek(e),t7(r)),n7=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?ek(e):[];return r&&n.push(jJ),n},YIe=async t=>{let e=n7(t);return i7(e.length>0&&await YJ(e,t))},s7=t=>{let e=n7(t);return i7(e.length>0&&KJ(e,t))},i7=t=>{let e=new Set;return r=>{let n=Mf.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},o7=(t,e)=>t.flat().filter(r=>e(r)),a7=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(i=>vg(i));if(n===-1){r.push({patterns:t,options:e});break}let s=t[n].slice(1);for(let i of r)i.options.ignore.push(s);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,s]}}),t=t.slice(n+1)}return r},c7=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),l7=async(t,e)=>{let r=a7(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=c7(s,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([XJ(a,i),XJ(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},tk=(t,e)=>{let r=a7(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=c7(s,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=QJ(a,i),c.ignore=QJ(c.ignore,{cwd:n}),{patterns:a,options:c}})},u7=r7(async(t,e)=>{let[r,n]=await Promise.all([l7(t,e),YIe(e)]),s=await Promise.all(r.map(i=>(0,Lf.default)(i.patterns,i.options)));return o7(s,n)}),WSt=lv((t,e)=>{let r=tk(t,e),n=s7(e),s=r.map(i=>Lf.default.sync(i.patterns,i.options));return o7(s,n)}),zSt=lv((t,e)=>{let r=tk(t,e),n=s7(e),s=r.map(o=>Lf.default.stream(o.patterns,o.options));return XD(s).filter(o=>n(o))}),YSt=lv((t,e)=>t.some(r=>Lf.default.isDynamicPattern(r,e))),KSt=r7(l7),XSt=lv(tk),{convertPathToPattern:QSt}=Lf.default;import XIe from"process";import wg from"path";import iEt,{promises as uv}from"fs";import eEt,{promises as KIe}from"fs";async function d7(t){try{return await KIe.access(t),!0}catch{return!1}}var QIe=(t,e,r)=>(e=wg.resolve(t,e),r=wg.resolve(t,r),{sourcePath:e,destinationPath:r}),JIe=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},ZIe=(t,e)=>{if(wg.dirname(t)!==wg.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},eNe=async(t,e,{overwrite:r=!0,cwd:n=XIe.cwd(),directoryMode:s,validateDirectory:i=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=QIe(n,t,e)),i&&ZIe(t,e),!r&&await d7(e))throw new Error(`The destination file exists: ${e}`);await uv.mkdir(wg.dirname(e),{recursive:!0,mode:s});try{await uv.rename(t,e)}catch(o){if(o.code==="EXDEV")await uv.copyFile(t,e),await uv.unlink(t);else throw o}};async function f7(t,e,r){return JIe(t,e),eNe(t,e,r)}var rk=async function(t,e,r=!1){if(r)return f7(t,e,{overwrite:!1});let{srcGlob:n,dest:s,...i}=await m7(t,p7(e));if(n&&s)return WD(n,s,{...i,overwrite:!1})},Rg=async function(t){let{srcGlob:e,isDir:r,dest:n,...s}=await m7(t,"");return e!==void 0&&!await nNe(e,r,s)},nNe=async function(t,e,r){return e?(await u7(t,r)).filter(i=>ov(h7(i))).length===0:!1},m7=async function(t,e){let r=await sNe(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),s=h7(t),i=p7(t),o={srcGlob:s,dest:e,isDir:n,cwd:i,dot:!0};return n?{...o,srcGlob:`${s}/**`,dest:rNe(e,s)}:o},sNe=async t=>{try{return await tNe.stat(t)}catch{return}};import{join as ZNe}from"path";import{stat as iNe,lstat as g7,readdir as oNe,realpath as aNe}from"fs/promises";import{Readable as cNe}from"stream";import{resolve as _7,relative as lNe,join as uNe,sep as dNe}from"path";var Wr={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},nk={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Wr.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(nk);var T7="READDIRP_RECURSIVE_ERROR",fNe=new Set(["ENOENT","EPERM","EACCES","ELOOP",T7]),S7=[Wr.DIR_TYPE,Wr.EVERYTHING_TYPE,Wr.FILE_DIR_TYPE,Wr.FILE_TYPE],hNe=new Set([Wr.DIR_TYPE,Wr.EVERYTHING_TYPE,Wr.FILE_DIR_TYPE]),pNe=new Set([Wr.EVERYTHING_TYPE,Wr.FILE_DIR_TYPE,Wr.FILE_TYPE]),mNe=t=>fNe.has(t.code),gNe=process.platform==="win32",E7=t=>!0,y7=t=>{if(t===void 0)return E7;if(typeof t=="function")return t;if(typeof t=="string"){let e=t.trim();return r=>r.basename===e}if(Array.isArray(t)){let e=t.map(r=>r.trim());return r=>e.some(n=>r.basename===n)}return E7},sk=class extends cNe{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...nk,...e},{root:n,type:s}=r;this._fileFilter=y7(r.fileFilter),this._directoryFilter=y7(r.directoryFilter);let i=r.lstat?g7:iNe;gNe?this._stat=o=>i(o,{bigint:!0}):this._stat=i,this._maxDepth=r.depth??nk.depth,this._wantsDir=s?hNe.has(s):!1,this._wantsFile=s?pNe.has(s):!1,this._wantsEverything=s===Wr.EVERYTHING_TYPE,this._root=_7(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:s,depth:i}=r,o=n.splice(0,e).map(c=>this._formatEntry(c,s)),a=await Promise.all(o);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await oNe(e,this._rdOptions)}catch(s){this._onError(s)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,s=this._isDirent?e.name:e;try{let i=_7(uNe(r,s));n={path:lNe(this._root,i),fullPath:i,basename:s},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(e){mNe(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let s=await aNe(n),i=await g7(s);if(i.isFile())return"file";if(i.isDirectory()){let o=s.length;if(n.startsWith(s)&&n.substr(o,1)===dNe){let a=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return a.code=T7,this._onError(a)}return"directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function _Ne(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Wr.FILE_DIR_TYPE),r&&(e.type=r),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(r&&!S7.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${S7.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new sk(e)}function b7(t,e={}){return new Promise((r,n)=>{let s=[];_Ne(t,e).on("data",i=>s.push(i)).on("end",()=>r(s)).on("error",i=>n(i))})}import{mkdir as ONe,readFile as P7,rm as INe,writeFile as NNe}from"fs/promises";import{existsSync as O7}from"fs";import{dirname as MNe}from"path";var A7=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},v7=t=>t!==void 0&&Date.now()>t;import{createHash as RNe}from"crypto";import{createReadStream as CNe}from"fs";import yNe from"process";import TNe from"path";import xEt,{promises as w7}from"fs";import{fileURLToPath as bNe}from"url";var ik=class{value;next;constructor(e){this.value=e}},Cg=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new ik(e);this.#e?(this.#r.next=r,this.#r=r):(this.#e=r,this.#r=r),this.#t++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#t--,this.#e||(this.#r=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#r=void 0,this.#t=0}get size(){return this.#t}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function dv(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new Cg,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},s=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},i=(a,c,l)=>{e.enqueue(s.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},o=(a,...c)=>new Promise(l=>{i(a,l,c)});return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}var fv=class extends Error{constructor(e){super(),this.value=e}},SNe=async(t,e)=>e(await t),ENe=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new fv(e[0]);return!1};async function ok(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let s=dv(r),i=[...t].map(a=>[a,s(SNe,a,e)]),o=dv(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(i.map(a=>o(ENe,a)))}catch(a){if(a instanceof fv)return a.value;throw a}}var R7={directory:"isDirectory",file:"isFile"};function ANe(t){if(!Object.hasOwnProperty.call(R7,t))throw new Error(`Invalid type specified: ${t}`)}var vNe=(t,e)=>e[R7[t]](),wNe=t=>t instanceof URL?bNe(t):t;async function C7(t,{cwd:e=yNe.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:s,preserveOrder:i}={}){ANe(r),e=wNe(e);let o=n?w7.stat:w7.lstat;return ok(t,async a=>{try{let c=await o(TNe.resolve(e,a));return vNe(r,c)}catch{return!1}},{concurrency:s,preserveOrder:i})}var xNe="sha1",x7=async function(t,e){if(e||t.length===0)return;let r=await C7(t);return r===void 0?void 0:await PNe(r)},PNe=async function(t){let e=CNe(t,"utf8"),r=RNe(xNe,{encoding:"hex"});return e.pipe(r),await Ou(r)};var I7=async function({cachePath:t,move:e,ttl:r,digests:n}){let s=hv(t),i=A7(r),o=await x7(n,e),c=`${JSON.stringify({expires:i,hash:o},null,2)}
364
- `,l=await LNe({hash:o,manifestPath:s,manifestString:c});return{manifestInfo:{manifestPath:s,manifestString:c},identical:l}},LNe=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!O7(e)?!1:await P7(e,"utf8")===r},N7=async function({manifestPath:t,manifestString:e}){await ONe(MNe(t),{recursive:!0}),await NNe(t,e)},M7=async function(t){let e=hv(t);await INe(e,{force:!0,recursive:!0,maxRetries:3})},hv=function(t){return`${t}${D7}`},L7=function(t){return t.endsWith(D7)},D7=".netlify.cache.json",ak=async function(t){let e=hv(t);if(!O7(e))return!1;let{expires:r}=await DNe(t);return v7(r)},DNe=async function(t){let e=hv(t),r=await P7(e,"utf-8");return JSON.parse(r)};import{homedir as $Ne}from"os";import{resolve as k7,isAbsolute as GNe,join as qNe,sep as lk}from"path";import{normalize as kNe}from"path";import{existsSync as UNe}from"fs";import FNe from"process";var ck=function(t){try{let e=BNe(t);return UNe(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},BNe=function(t=FNe.cwd()){return kNe(t)};var xg=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await HNe(t,r),s=await zNe({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:s}},HNe=async function(t,e){let r=await ck(e),n=VNe(t,r);return jNe(n,r),n},VNe=function(t,e){if(GNe(t))return k7(t);if(e!=="")return k7(e,t);throw new Error(`Current directory does not exist: ${e}`)},jNe=function(t,e){if(e!==""&&WNe(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},WNe=function(t,e){return`${e}${lk}`.startsWith(`${t}${lk}`)},zNe=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Jc({cacheDir:e,cwd:r}),{name:s,relPath:i}=await YNe(t,r);return qNe(n,s,i)},YNe=async function(t,e){let r=await uk(e),n=KNe(t);return r.map(({name:s,base:i})=>QNe(s,i,n)).find(Boolean)},KNe=function(t){return t.replace(XNe,"\\")},XNe=/^[a-zA-Z]:\\/,QNe=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},uk=async function(t){return[...await JNe(t),{name:"home",base:$Ne()},{name:"root",base:lk}]},JNe=async function(t){let e=await ck(t);return e===""?[]:[{name:"cwd",base:e}]};var eMe=1,dk=async function({cacheDir:t,cwd:e,depth:r=eMe}={}){let n=await uk(e),s=Jc({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>tMe({name:a,base:c,cacheDir:s,depth:r})))).flat()},tMe=async function({name:t,base:e,cacheDir:r,depth:n}){return(await b7(`${r}/${t}`,{fileFilter:rMe,depth:n,type:"files_directories"})).map(({path:o})=>ZNe(e,o))},rMe=function({basename:t}){return!L7(t)};var nMe=async function(t,{move:e=U7,ttl:r=aMe,digests:n=[],cacheDir:s,cwd:i}={}){let{srcPath:o,cachePath:a}=await xg({path:t,cacheDir:s,cwdOpt:i});if(!await Rg(o))return!1;let{manifestInfo:c,identical:l}=await I7({cachePath:a,move:e,ttl:r,digests:n});return l||(await fk(a,{force:!0,recursive:!0,maxRetries:3}),await rk(o,a,e),await N7(c)),!0},sMe=async function(t,{move:e=U7,cacheDir:r,cwd:n}={}){let{srcPath:s,cachePath:i}=await xg({path:t,cacheDir:r,cwdOpt:n});return!await Rg(i)||await ak(i)?!1:(await fk(s,{force:!0,recursive:!0,maxRetries:3}),await rk(i,s,e),!0)},iMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await xg({path:t,cacheDir:e,cwdOpt:r});return await Rg(n)?(await fk(n,{force:!0,recursive:!0,maxRetries:3}),await M7(n),!0):!1},oMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await xg({path:t,cacheDir:e,cwdOpt:r});return await Rg(n)&&!await ak(n)},U7=!1,aMe=void 0,pv=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(s=>t(s,...r)))).some(Boolean):t(e,...r)},cMe=pv.bind(null,nMe),lMe=pv.bind(null,sMe),uMe=pv.bind(null,iMe),dMe=pv.bind(null,oMe),F7=function(t){return{save:(e,r)=>cMe(e,{...t,...r}),restore:(e,r)=>lMe(e,{...t,...r}),remove:(e,r)=>uMe(e,{...t,...r}),has:(e,r)=>dMe(e,{...t,...r}),list:e=>dk({...t,...e}),getCacheDir:e=>Jc({...t,...e})}};var Gt=de("native_session"),hk=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Vi.stat(ji.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),mv=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Gt.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:n,include:s}=r,i=!1;try{i=(await Vi.stat(n)).isDirectory()}catch{}if(!i)return Gt.log(`Native session base dir ${n} not found, skipping`),null;let o=await hk(n,s);if(o.length===0)return Gt.log(`No native session history found under ${n}, skipping`),null;let a=ji.join(B7.tmpdir(),`native-session-${e}.zip`);try{await kr("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await Vi.readFile(a);Gt.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await C3(t,e);return await zp(l,c,{contentType:"application/zip"}),Gt.log("Successfully uploaded native session to S3"),u}catch(c){return Gt.error("Failed to archive/upload native session, continuing without it:",c),null}finally{await Vi.rm(a,{force:!0}).catch(()=>{})}},$7=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await hk(e,r);for(let s of n)if((await Vi.readdir(ji.join(e,s)).catch(()=>[])).length>0)return!0;return!1},fMe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),G7=async(t,e)=>{let r=await Vi.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await G7(ji.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},q7=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${fMe(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:s}=t,i=await hk(n,s);for(let o of i)if(await G7(ji.join(n,o),r))return!0;return!1},H7=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Gt.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,s=ji.join(B7.tmpdir(),`native-session-restore-${e}.zip`);try{let i=await x3(t,e);if(!i?.download_url)return Gt.log("No native session available to restore, skipping"),!1;let o=await D3(i.download_url);return await Vi.writeFile(s,o),Gt.log(`Downloaded native session (${o.length} bytes) to ${s}`),await Vi.mkdir(n,{recursive:!0}),await kr("unzip",["-o","-q",s,"-d",n]),Gt.log(`Restored native session into ${n}`),!0}catch(i){return Gt.error("Failed to fetch/restore native session, continuing without it:",i),!1}finally{await Vi.rm(s,{force:!0}).catch(()=>{})}},hMe="native-sessions",V7=(t,e)=>F7({cacheDir:ji.join(e.dir,hMe),cwd:t}),j7=async({archive:t,cache:e})=>{if(!e?.enabled||!t)return!1;let{baseDir:r,include:n}=t;try{return await V7(r,e).restore(n.map(i=>ji.join(r,i)),{})?(Gt.log(`Restored native session from buildbot cache into ${r}`),!0):(Gt.log("No native session in buildbot cache, skipping restore"),!1)}catch(s){return Gt.error("Failed to restore native session from buildbot cache, continuing without it:",s),!1}},gv=async({archive:t,cache:e})=>{if(!e?.enabled||!t)return!1;let{baseDir:r,include:n}=t;try{return await V7(r,e).save(n.map(i=>ji.join(r,i)),{})?(Gt.log(`Saved native session to buildbot cache under ${e.dir}`),!0):(Gt.log("No native session history to save to buildbot cache, skipping"),!1)}catch(s){return Gt.error("Failed to save native session to buildbot cache, continuing:",s),!1}};var _v=de("inference_stage"),W7=5,il=async t=>{let{additionalContext:e,cliPath:r,config:n,context:s,buildErrors:i,runner:o,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f}=t;if(Ti())throw new Error("Shutdown in progress, aborting inference stage");_v.log(`Running inference stage, attempt ${l} of ${W7}`);let h=!1,p=await Ge(Pe(),"inference-stage",async m=>{m?.setAttributes({"inference.attempt":l||1}),c3();let E=!!(l&&l>1),S=await pMe(n,E);h=S.viable,S.outcome!=="not_eligible"&&ge.inc("inference.native_resume",1,{outcome:S.outcome,...S.source?{source:S.source}:{}});let{prompt:b}=await Ge(Pe(),"compose-prompt",async()=>await M5({cliPath:r,config:n,buildErrorContext:mMe(i),netlify:s,additionalContext:e,resumePrompt:S.viable})),w=`
364
+ `,l=await LNe({hash:o,manifestPath:s,manifestString:c});return{manifestInfo:{manifestPath:s,manifestString:c},identical:l}},LNe=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!O7(e)?!1:await P7(e,"utf8")===r},N7=async function({manifestPath:t,manifestString:e}){await ONe(MNe(t),{recursive:!0}),await NNe(t,e)},M7=async function(t){let e=hv(t);await INe(e,{force:!0,recursive:!0,maxRetries:3})},hv=function(t){return`${t}${D7}`},L7=function(t){return t.endsWith(D7)},D7=".netlify.cache.json",ak=async function(t){let e=hv(t);if(!O7(e))return!1;let{expires:r}=await DNe(t);return v7(r)},DNe=async function(t){let e=hv(t),r=await P7(e,"utf-8");return JSON.parse(r)};import{homedir as $Ne}from"os";import{resolve as k7,isAbsolute as GNe,join as qNe,sep as lk}from"path";import{normalize as kNe}from"path";import{existsSync as UNe}from"fs";import FNe from"process";var ck=function(t){try{let e=BNe(t);return UNe(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},BNe=function(t=FNe.cwd()){return kNe(t)};var xg=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await HNe(t,r),s=await zNe({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:s}},HNe=async function(t,e){let r=await ck(e),n=VNe(t,r);return jNe(n,r),n},VNe=function(t,e){if(GNe(t))return k7(t);if(e!=="")return k7(e,t);throw new Error(`Current directory does not exist: ${e}`)},jNe=function(t,e){if(e!==""&&WNe(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},WNe=function(t,e){return`${e}${lk}`.startsWith(`${t}${lk}`)},zNe=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Jc({cacheDir:e,cwd:r}),{name:s,relPath:i}=await YNe(t,r);return qNe(n,s,i)},YNe=async function(t,e){let r=await uk(e),n=KNe(t);return r.map(({name:s,base:i})=>QNe(s,i,n)).find(Boolean)},KNe=function(t){return t.replace(XNe,"\\")},XNe=/^[a-zA-Z]:\\/,QNe=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},uk=async function(t){return[...await JNe(t),{name:"home",base:$Ne()},{name:"root",base:lk}]},JNe=async function(t){let e=await ck(t);return e===""?[]:[{name:"cwd",base:e}]};var eMe=1,dk=async function({cacheDir:t,cwd:e,depth:r=eMe}={}){let n=await uk(e),s=Jc({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>tMe({name:a,base:c,cacheDir:s,depth:r})))).flat()},tMe=async function({name:t,base:e,cacheDir:r,depth:n}){return(await b7(`${r}/${t}`,{fileFilter:rMe,depth:n,type:"files_directories"})).map(({path:o})=>ZNe(e,o))},rMe=function({basename:t}){return!L7(t)};var nMe=async function(t,{move:e=U7,ttl:r=aMe,digests:n=[],cacheDir:s,cwd:i}={}){let{srcPath:o,cachePath:a}=await xg({path:t,cacheDir:s,cwdOpt:i});if(!await Rg(o))return!1;let{manifestInfo:c,identical:l}=await I7({cachePath:a,move:e,ttl:r,digests:n});return l||(await fk(a,{force:!0,recursive:!0,maxRetries:3}),await rk(o,a,e),await N7(c)),!0},sMe=async function(t,{move:e=U7,cacheDir:r,cwd:n}={}){let{srcPath:s,cachePath:i}=await xg({path:t,cacheDir:r,cwdOpt:n});return!await Rg(i)||await ak(i)?!1:(await fk(s,{force:!0,recursive:!0,maxRetries:3}),await rk(i,s,e),!0)},iMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await xg({path:t,cacheDir:e,cwdOpt:r});return await Rg(n)?(await fk(n,{force:!0,recursive:!0,maxRetries:3}),await M7(n),!0):!1},oMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await xg({path:t,cacheDir:e,cwdOpt:r});return await Rg(n)&&!await ak(n)},U7=!1,aMe=void 0,pv=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(s=>t(s,...r)))).some(Boolean):t(e,...r)},cMe=pv.bind(null,nMe),lMe=pv.bind(null,sMe),uMe=pv.bind(null,iMe),dMe=pv.bind(null,oMe),F7=function(t){return{save:(e,r)=>cMe(e,{...t,...r}),restore:(e,r)=>lMe(e,{...t,...r}),remove:(e,r)=>uMe(e,{...t,...r}),has:(e,r)=>dMe(e,{...t,...r}),list:e=>dk({...t,...e}),getCacheDir:e=>Jc({...t,...e})}};var Gt=de("native_session"),hk=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Vi.stat(ji.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),mv=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Gt.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:n,include:s}=r,i=!1;try{i=(await Vi.stat(n)).isDirectory()}catch{}if(!i)return Gt.log(`Native session base dir ${n} not found, skipping`),null;let o=await hk(n,s);if(o.length===0)return Gt.log(`No native session history found under ${n}, skipping`),null;let a=ji.join(B7.tmpdir(),`native-session-${e}.zip`);try{await kr("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await Vi.readFile(a);Gt.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await C3(t,e);return await zp(l,c,{contentType:"application/zip"}),Gt.log("Successfully uploaded native session to S3"),u}catch(c){return Gt.error("Failed to archive/upload native session, continuing without it:",c),null}finally{await Vi.rm(a,{force:!0}).catch(()=>{})}},$7=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await hk(e,r);for(let s of n)if((await Vi.readdir(ji.join(e,s)).catch(()=>[])).length>0)return!0;return!1},fMe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),G7=async(t,e)=>{let r=await Vi.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await G7(ji.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},q7=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${fMe(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:s}=t,i=await hk(n,s);for(let o of i)if(await G7(ji.join(n,o),r))return!0;return!1},H7=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Gt.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,s=ji.join(B7.tmpdir(),`native-session-restore-${e}.zip`);try{let i=await x3(t,e);if(!i?.download_url)return Gt.log("No native session available to restore, skipping"),!1;let o=await D3(i.download_url);return await Vi.writeFile(s,o),Gt.log(`Downloaded native session (${o.length} bytes) to ${s}`),await Vi.mkdir(n,{recursive:!0}),await kr("unzip",["-o","-q",s,"-d",n]),Gt.log(`Restored native session into ${n}`),!0}catch(i){return Gt.error("Failed to fetch/restore native session, continuing without it:",i),!1}finally{await Vi.rm(s,{force:!0}).catch(()=>{})}},hMe="native-sessions",V7=(t,e)=>F7({cacheDir:ji.join(e.dir,hMe),cwd:t}),j7=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await V7(r,e).restore(n.map(i=>ji.join(r,i)),{})?(Gt.log(`Restored native session from buildbot cache into ${r}`),!0):(Gt.log("No native session in buildbot cache, skipping restore"),!1)}catch(s){return Gt.error("Failed to restore native session from buildbot cache, continuing without it:",s),!1}},gv=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await V7(r,e).save(n.map(i=>ji.join(r,i)),{})?(Gt.log(`Saved native session to buildbot cache under ${e.dir}`),!0):(Gt.log("No native session history to save to buildbot cache, skipping"),!1)}catch(s){return Gt.error("Failed to save native session to buildbot cache, continuing:",s),!1}};var _v=de("inference_stage"),W7=5,il=async t=>{let{additionalContext:e,cliPath:r,config:n,context:s,buildErrors:i,runner:o,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f}=t;if(Ti())throw new Error("Shutdown in progress, aborting inference stage");_v.log(`Running inference stage, attempt ${l} of ${W7}`);let h=!1,p=await Ge(Pe(),"inference-stage",async m=>{m?.setAttributes({"inference.attempt":l||1}),c3();let E=!!(l&&l>1),S=await pMe(n,E);h=S.viable,S.outcome!=="not_eligible"&&ge.inc("inference.native_resume",1,{outcome:S.outcome,...S.source?{source:S.source}:{}});let{prompt:b}=await Ge(Pe(),"compose-prompt",async()=>await M5({cliPath:r,config:n,buildErrorContext:mMe(i),netlify:s,additionalContext:e,resumePrompt:S.viable})),w=`
365
365
  ${u||""}
366
366
  ${b}
367
367
  `.trim(),A={...n,prompt:w},G=d??(S.viable?S.sessionId:void 0),x=await Ge(Pe(),`run-${n.runner}`,async F=>{let O=sO();F?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":f3(n.runner),"gen_ai.system":n.runner,...O?{"gen_ai.input.messages":Vy("user",w)}:{}});let P=Date.now(),L=await o({aiGateway:c,config:A,netlify:s,persistSteps:a,continueSession:E||S.viable,priorAgentSessionId:G,cwd:f}),_=Date.now(),Q=L.resolvedModel||n.model||"unknown",C=L.error?"error":"stop";return F?.setAttributes({...O?{"gen_ai.output.messages":Vy("assistant",L.result??L.error??"",C)}:{},"gen_ai.response.finish_reasons":[C],"gen_ai.request.model":Q,"gen_ai.response.model":Q,...L.effort?{"gen_ai.request.effort":L.effort}:{},...L.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":L.usage.input_tokens}:{},...L.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":L.usage.output_tokens}:{},...L.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":L.usage.cache_creation_input_tokens}:{},...L.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":L.usage.cache_read_input_tokens}:{}}),h3(L.steps??[],n.mode,P,_),L});return x.result&&(x.result=ln(x.result)),x.error&&(x.error=ln(x.error)),await a.flush(),x});if(p.error){if(Ti()){let m=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(m,{agentSessionId:p.agentSessionId}),m}if(_v.error("Runner failed",{stepsCount:p.steps.length,duration:p.duration,error:p.error,isRetryableError:p.isRetryableError,attempt:l||1,agentSessionId:p.agentSessionId}),ge.inc("inference.failed",1,{attempt:l||1,is_retryable:!!p.isRetryableError,is_provider_unavailable:!!p.isProviderUnavailableError}),p.isRetryableError&&(!l||l<W7))return _v.log("Retrying inference stage"),await new Promise(E=>setTimeout(E,5e3)),{runnerResult:(await il({...t,attempt:(l||1)+1,priorAgentSessionId:p.agentSessionId,contextPrefix:p.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:h};{if(_v.log("Do not retry inference stage"),p.error.toLowerCase().includes("usage exceeded"))throw new $n(p.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);let m=p.isRetryableError||p.isProviderUnavailableError?new gu(p.error):new Error(p.error);throw Object.assign(m,{agentSessionId:p.agentSessionId}),m}}return{runnerResult:p,nativeResume:h}},pMe=async(t,e)=>{if(e)return{viable:!1,outcome:"not_eligible"};let r=t.previousSession,{viable:n,outcome:s}=k5(t);if(!n)return{viable:n,outcome:s};let i=r?.nativeSessionId,o=pf(t.runner),a=async()=>i?t.runner==="gemini"?!!await bM(i):q7(o,i):!1,c;if(D5(t)&&await $7(o))c="local";else if(t.fastInit&&jt().warmNativeResumeEnabled&&await j7({archive:o,cache:t.cache})&&await a())c="cache_restore";else{if(c="fetch",!jt().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:c};if(!await H7({runnerId:t.id,sessionId:t.sessionId,archive:o}))return{viable:!1,outcome:"fetch_failed",source:c}}return t.runner==="gemini"&&i&&!await SA(i)?{viable:!1,outcome:"sanitize_failed",source:c}:{viable:!0,sessionId:i,outcome:"resumed",source:c}},mMe=t=>!t||t.length===0?"":`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.136.0-ex-2324.1",
4
+ "version": "1.136.0-ex-2324.2",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",