@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/bin-local.js CHANGED
@@ -86,7 +86,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
86
86
  `,LF:`
87
87
  `,concatBytes:uI},xye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Pye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:xye};import{Buffer as Oye}from"buffer";var xY=(t,e)=>t?void 0:Iye.bind(void 0,e),Iye=function*(t,e){if(typeof e!="string"&&!gt(e)&&!Oye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},PY=(t,e)=>t?Nye.bind(void 0,e):Mye.bind(void 0,e),Nye=function*(t,e){OY(t,e),yield e},Mye=function*(t,e){if(OY(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},OY=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
88
88
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
89
- if (condition) { yield value; }`)};import{Buffer as Lye}from"buffer";import{StringDecoder as Dye}from"string_decoder";var YT=(t,e,r)=>{if(r)return;if(t)return{transform:kye.bind(void 0,new TextEncoder)};let n=new Dye(e);return{transform:Uye.bind(void 0,n),final:Fye.bind(void 0,n)}},kye=function*(t,e){Lye.isBuffer(e)?yield yi(e):typeof e=="string"?yield t.encode(e):yield e},Uye=function*(t,e){yield gt(e)?t.write(e):e},Fye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as IY}from"util";var fI=IY(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),KT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=$ye}=e[r];for await(let s of n(t))yield*KT(s,e,r+1)},NY=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Bye(r,Number(e),t)},Bye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KT(n,r,e+1)},MY=IY(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),$ye=function*(t){yield t};var hI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},LY=(t,e)=>[...e.flatMap(r=>[...fc(r,t,0)]),...cm(t)],fc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qye}=e[r];for(let s of n(t))yield*fc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Gye(r,Number(e),t)},Gye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*fc(n,r,e+1)},qye=function*(t){yield t};var pI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=kY(t,o,i),l=dc(e),u=dc(r),d=l?fI.bind(void 0,KT,a):hI.bind(void 0,fc),f=l||u?fI.bind(void 0,NY,a):hI.bind(void 0,cm),h=l||u?MY.bind(void 0,a):void 0;return{stream:new Hye({writableObjectMode:n,writableHighWaterMark:DY(n),readableObjectMode:s,readableHighWaterMark:DY(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},XT=(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=kY(o,r,a);t=LY(c,t)}return t},kY=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:xY(n,a)},YT(r,o,n),zT(r,i,n,c),{transform:t,final:e},{transform:PY(s,a)},CY({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var UY=(t,e)=>{for(let r of Vye(t))jye(t,r,e)},Vye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),jye=(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 ${Mo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Wye(a,n));r.input=Jp(o)},Wye=(t,e)=>{let r=XT(t,e,"utf8",!0);return zye(r),Jp(r)},zye=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 Qye,appendFileSync as Jye}from"fs";var QT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&wu(r,n)&&!Fr.has(e)&&Yye(n)&&(t.some(({type:s,value:i})=>s==="native"&&Kye.has(i))||t.every(({type:s})=>mn.has(s))),Yye=t=>t===1||t===2,Kye=new Set(["pipe","overlapped"]),FY=async(t,e,r,n)=>{for await(let s of t)Xye(e)||$Y(s,r,n)},BY=(t,e,r)=>{for(let n of t)$Y(n,e,r)},Xye=t=>t._readableState.pipes.length>0,$Y=(t,e,r)=>{let n=dT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var GY=({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)=>Zye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},Zye=({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=q4(t,i,d),h=yi(f),{stdioItems:p,objectMode:m}=e[r],E=eTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=tTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});rTe({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let w=a[r]?A:void 0;try{return n.error===void 0&&nTe(S,p,s),w}catch(T){return n.error=T,w}},eTe=(t,e,r,n)=>{try{return XT(t,e,r,!1)}catch(s){return n.error=s,t}},tTe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Jp(t)};let o=rW(t,r);return n[i]?{serializedResult:o,finalResult:dI(o,!s[i],e)}:{serializedResult:o}},rTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!QT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=dI(t,!1,o);try{BY(a,e,n)}catch(c){r.error??=c}},nTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>jT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?Jye(n,t):(r.add(i),Qye(n,t))}};var qY=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ai(e,r,"all")]:Array.isArray(e)?[Ai(t,r,"all"),...e]:gt(t)&&gt(e)?yO([t,e]):`${t}${e}`};import{once as mI}from"events";var HY=async(t,e)=>{let[r,n]=await sTe(t);return e.isForcefullyTerminated??=!1,[r,n]},sTe=async t=>{let[e,r]=await Promise.allSettled([mI(t,"spawn"),mI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?VY(t):r.value},VY=async t=>{try{return await mI(t,"exit")}catch{return VY(t)}},jY=async t=>{let[e,r]=await t;if(!iTe(e,r)&&gI(e,r))throw new jn;return[e,r]},iTe=(t,e)=>t===void 0&&e===void 0,gI=(t,e)=>t!==0||e!==null;var WY=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=oTe(t,e,r),o=i?.code==="ETIMEDOUT",a=G4(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},oTe=(t,e,r)=>t!==void 0?t:gI(e,r)?new jn:void 0;var zY=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=cTe(t,e,r),d=dTe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Du(d,c,l)},cTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),a=lTe(r),{file:c,commandArguments:l,options:u}=MT(t,e,a);uTe(u);let d=AY(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},lTe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,uTe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&JT("ipcInput"),t&&JT("ipc: true"),r&&JT("detached: true"),n&&JT("cancelSignal")},JT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},dTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=fTe({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}=WY(c,r),{output:p,error:m=l}=GY({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,w)=>Ai(A,r,w)),S=Ai(qY(p,r),r,"all");return pTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},fTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{UY(i,r);let a=hTe(r);return aTe(...LT(t,e,a))}catch(a){return Lu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},hTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GT(e)}),pTe=({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?qT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):am({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 tAe}from"events";import{spawn as rAe}from"child_process";import JY from"process";import{once as _I,on as mTe}from"events";var YY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(xu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),gTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),gTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{AT(e,s);let i=No(t,e,r),o=new AbortController;try{return await Promise.race([_Te(i,n,o),STe(i,r,o),ETe(i,r,o)])}catch(a){throw Pu(t),a}finally{o.abort(),vT(e,s)}},_Te=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await _I(t,"message",{signal:r});return n}for await(let[n]of mTe(t,"message",{signal:r}))if(e(n))return n},STe=async(t,e,{signal:r})=>{await _I(t,"disconnect",{signal:r}),Lz(e)},ETe=async(t,e,{signal:r})=>{let[n]=await _I(t,"strict:error",{signal:r});throw yT(n,e)};import{once as XY,on as yTe}from"events";var QY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>SI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),SI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{xu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),AT(e,i);let o=No(t,e,r),a=new AbortController,c={};return TTe(t,o,a),bTe({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})},TTe=async(t,e,r)=>{try{await XY(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},bTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await XY(t,"strict:error",{signal:r.signal});n.error=yT(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 yTe(r,"message",{signal:i.signal}))KY(o),yield c}catch{KY(o)}finally{i.abort(),vT(e,a),n||Pu(t),s&&await t}},KY=({error:t})=>{if(t)throw t};var ZY=(t,{ipc:e})=>{Object.assign(t,t6(t,!1,e))},e6=()=>{let t=JY,e=!0,r=JY.channel!==void 0;return{...t6(t,e,r),getCancelSignal:a4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},t6=(t,e,r)=>({sendMessage:IT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:YY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:QY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as vTe}from"child_process";import{PassThrough as wTe,Readable as RTe,Writable as CTe,Duplex as xTe}from"stream";var r6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{cI(n);let a=new vTe;PTe(a,n),Object.assign(a,{readable:OTe,writable:ITe,duplex:NTe});let c=Lu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=MTe(c,o,s);return{subprocess:a,promise:l}},PTe=(t,e)=>{let r=lm(),n=lm(),s=lm(),i=Array.from({length:e.length-3},lm),o=lm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},lm=()=>{let t=new wTe;return t.end(),t},OTe=()=>new RTe({read(){}}),ITe=()=>new CTe({write(){}}),NTe=()=>new xTe({read(){},write(){}}),MTe=async(t,e,r)=>Du(t,e,r);import{createReadStream as n6,createWriteStream as s6}from"fs";import{Buffer as LTe}from"buffer";import{Readable as um,Writable as DTe,Duplex as kTe}from"stream";var o6=(t,e)=>WT(UTe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Mo[t]}.`)},i6={fileNumber:dm,generator:pI,asyncGenerator:pI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:kTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},UTe={input:{...i6,fileUrl:({value:t})=>({stream:n6(t)}),filePath:({value:{file:t}})=>({stream:n6(t)}),webStream:({value:t})=>({stream:um.fromWeb(t)}),iterable:({value:t})=>({stream:um.from(t)}),asyncIterable:({value:t})=>({stream:um.from(t)}),string:({value:t})=>({stream:um.from(t)}),uint8Array:({value:t})=>({stream:um.from(LTe.from(t))})},output:{...i6,fileUrl:({value:t})=>({stream:s6(t)}),filePath:({value:{file:t,append:e}})=>({stream:s6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:DTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as FTe,once as a6}from"events";import{PassThrough as BTe,getDefaultHighWaterMark as $Te}from"stream";import{finished as u6}from"stream/promises";function hc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)yI(s);let e=t.some(({readableObjectMode:s})=>s),r=GTe(t,e),n=new EI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var GTe=(t,e)=>{if(t.length===0)return $Te(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},EI=class extends BTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(yI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=qTe(this,this.#e,this.#i);let r=jTe({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(yI(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)}},qTe=async(t,e,r)=>{ZT(t,c6);let n=new AbortController;try{await Promise.race([HTe(t,n),VTe(t,e,r,n)])}finally{n.abort(),ZT(t,-c6)}},HTe=async(t,{signal:e})=>{try{await u6(t,{signal:e,cleanup:!0})}catch(r){throw d6(t,r),r}},VTe=async(t,e,r,{signal:n})=>{for await(let[s]of FTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},yI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},jTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{ZT(t,l6);let a=new AbortController;try{await Promise.race([WTe(i,e,a),zTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),YTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),ZT(t,-l6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?TI(t):KTe(t))},WTe=async(t,e,{signal:r})=>{try{await t,r.aborted||TI(e)}catch(n){r.aborted||d6(e,n)}},zTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await u6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;f6(o)?s.add(e):h6(t,o)}},YTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await a6(t,s,{signal:i}),!t.readable)return a6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},KTe=t=>{t.writable&&t.end()},d6=(t,e)=>{f6(e)?TI(t):h6(t,e)},f6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",TI=t=>{(t.readable||t.writable)&&t.destroy()},h6=(t,e)=>{t.destroyed||(t.once("error",XTe),t.destroy(e))},XTe=()=>{},ZT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},c6=2,l6=1;import{finished as p6}from"stream/promises";var Uu=(t,e)=>{t.pipe(e),QTe(t,e),JTe(t,e)},QTe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await p6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}bI(e)}},bI=t=>{t.writable&&t.end()},JTe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await p6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}AI(t)}},AI=t=>{t.readable&&t.destroy()};var m6=(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})=>mn.has(c)))ZTe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!mn.has(c)))tbe({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]:hc(i);Uu(o,s)}},ZTe=(t,e,r,n)=>{r==="output"?Uu(t.stdio[n],e):Uu(e,t.stdio[n]);let s=ebe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},ebe=["stdin","stdout","stderr"],tbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;rbe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},rbe=(t,{signal:e})=>{Vn(t)&&lc(t,nbe,e)},nbe=2;import{addAbortListener as obe}from"events";var pc=[];pc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&pc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&pc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eb=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",vI=Symbol.for("signal-exit emitter"),wI=globalThis,sbe=Object.defineProperty.bind(Object),RI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(wI[vI])return wI[vI];sbe(wI,vI,{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}},tb=class{},ibe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),CI=class extends tb{onExit(){return()=>{}}load(){}unload(){}},xI=class extends tb{#e=PI.platform==="win32"?"SIGINT":"SIGHUP";#r=new RI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of pc)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(!eb(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 pc)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,pc.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 eb(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"&&eb(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)}},PI=globalThis.process,{onExit:g6,load:gJe,unload:_Je}=ibe(eb(PI)?new xI(PI):new CI);var _6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=g6(()=>{t.kill()});obe(n,()=>{s()})};var E6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=fT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=abe(r,n,s),{sourceStream:d,sourceError:f}=lbe(t,l),{options:h,fileDescriptors:p}=Ps.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},abe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=cbe(t,e,...r),a=bT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},cbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(S6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||SO(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]=rT(r,...n);return{destination:e(S6)(s,i,o),pipeOptions:o}}if(Ps.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}`)},S6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),lbe=(t,e)=>{try{return{sourceStream:Ou(t,e)}}catch(r){return{sourceError:r}}};var T6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=ube({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw OI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},ube=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return AI(t),n;if(e!==void 0)return bI(r),e},OI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Lu({error:t,command:y6,escapedCommand:y6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),y6="source.pipe(destination)";var b6=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 dbe}from"stream/promises";var A6=(t,e,r)=>{let n=rb.has(e)?hbe(t,e):fbe(t,e);return lc(t,mbe,r.signal),lc(e,gbe,r.signal),pbe(e),n},fbe=(t,e)=>{let r=hc([t]);return Uu(r,e),rb.set(e,r),r},hbe=(t,e)=>{let r=rb.get(e);return r.add(t),r},pbe=async t=>{try{await dbe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rb.delete(t)},rb=new WeakMap,mbe=2,gbe=1;import{aborted as _be}from"util";var v6=(t,e)=>t===void 0?[]:[Sbe(t,e)],Sbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await _be(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw OI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var nb=(t,...e)=>{if(ot(e[0]))return nb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=E6(t,...e),s=Ebe({...n,destination:r});return s.pipe=nb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Ebe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ybe(t,s);T6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=A6(e,i,d);return await Promise.race([b6(u),...v6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ybe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Cbe}from"timers/promises";import{on as Tbe}from"events";import{getDefaultHighWaterMark as bbe}from"stream";var sb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Abe(e,o),R6({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()}},II=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;vbe(e,o,t);let a=t.readableObjectMode&&!i;return R6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},vbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},R6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Tbe(t,"data",{signal:e.signal,highWaterMark:w6,highWatermark:w6});return wbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},NI=bbe(!0),w6=NI,wbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Rbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*fc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},Rbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[YT(t,r,!e),zT(t,s,!n,{})].filter(Boolean);var C6=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=xbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Pbe(t),d]);return}let f=lI(c,r),h=II({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([Obe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},xbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!QT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=II({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await FY(a,t,r,i)},Pbe=async t=>{await Cbe(),t.readableFlowing===null&&t.resume()},Obe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await FT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await BT(r,{maxBuffer:i})):await Mu(r,{maxBuffer:i})}catch(a){return x6(F4({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},MI=async t=>{try{return await t}catch(e){return x6(e)}},x6=({bufferedData:t})=>eW(t)?new Uint8Array(t):t;import{finished as Ibe}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Nbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ibe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Dbe(a,e,r,n)}finally{o.abort()}},Nbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Mbe(t,r,n),n},Mbe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Lbe(e,r),n.call(t,...s)}},Lbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Dbe=(t,e,r,n)=>{if(!kbe(t,e,r,n))throw t},kbe=(t,e,r,n=!0)=>r.propagating?P6(t)||ib(t):(r.propagating=!0,LI(r,e)===n?P6(t):ib(t)),LI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ib=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",P6=t=>t?.code==="EPIPE";var O6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>DI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),DI=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=fm(t,e,l);if(LI(l,e)){await u;return}let[d]=await Promise.all([C6({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 I6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?hc([t,e].filter(Boolean)):void 0,N6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>DI({...Ube(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Fbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),Ube=({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}},Fbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Bbe}from"events";var M6=t=>wu(t,"ipc"),L6=(t,e)=>{let r=dT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var D6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=M6(i),a=Ti(e,"ipc"),c=Ti(r,"ipc");for await(let l of SI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(B4(t,s,c),s.push(l)),o&&L6(l,i);return s},k6=async(t,e)=>(await Promise.allSettled([t]),e);var U6=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 A=HY(t,f),w={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=O6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),k=N6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),R=[],O=D6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:h}),I=$be(m,t,w),x=Gbe(p,w);try{return await Promise.race([Promise.all([{},jY(A),Promise.all(T),k,O,_4(t,d),...I,...x]),E,qbe(t,S),...f4(t,i,f,S),...Mz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...u4({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(M){return f.terminationReason??="other",Promise.all([{error:M},A,Promise.all(T.map(_=>MI(_))),MI(k),k6(O,R),Promise.allSettled(I),Promise.allSettled(x)])}},$be=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),Gbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>zn(i,{checkOpen:!1})&&!Vn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:mn.has(s),stopOnExit:s==="native"}))),qbe=async(t,{signal:e})=>{let[r]=await Bbe(t,"error",{signal:e});throw r};var F6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=xs();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Fu=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 Hbe}from"stream";import{callbackify as Vbe}from"util";import{finished as B6}from"stream/promises";var kI=async t=>{if(t!==void 0)try{await UI(t)}catch{}},$6=async t=>{if(t!==void 0)try{await FI(t)}catch{}},UI=async t=>{await B6(t,{cleanup:!0,readable:!1,writable:!0})},FI=async t=>{await B6(t,{cleanup:!0,readable:!0,writable:!1})},ob=async(t,e)=>{if(await t,e)throw e},ab=(t,e,r)=>{r&&!ib(r)?t.destroy(r):e&&t.destroy()};var G6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Fr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=BI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=$I(a,o),{read:f,onStdoutDataDone:h}=GI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Hbe({read:f,destroy:Vbe(HI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return qI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},BI=(t,e,r)=>{let n=Ou(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},$I=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:NI},GI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=xs(),o=sb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){jbe(this,o,i)},onStdoutDataDone:i}},jbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},qI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await FI(t),await n,await kI(s),await e,r.readable&&r.push(null)}catch(i){await kI(s),q6(r,i)}},HI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Fu(r,e)&&(q6(t,n),await ob(e,n))},q6=(t,e)=>{ab(t,t.readable,e)};import{Writable as Wbe}from"stream";import{callbackify as H6}from"util";var V6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=VI(t,r,e),o=new Wbe({...jI(n,t,s),destroy:H6(zI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return WI(n,o),o},VI=(t,e,r)=>{let n=bT(t,e),s=hm(r,n,"writableFinal"),i=hm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},jI=(t,e,r)=>({write:zbe.bind(void 0,t),final:H6(Ybe.bind(void 0,t,e,r))}),zbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Ybe=async(t,e,r)=>{await Fu(r,e)&&(t.writable&&t.end(),await e)},WI=async(t,e,r)=>{try{await UI(t),e.writable&&e.end()}catch(n){await $6(r),j6(e,n)}},zI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Fu(r,e),await Fu(n,e)&&(j6(t,s),await ob(e,s))},j6=(t,e)=>{ab(t,t.writable,e)};import{Duplex as Kbe}from"stream";import{callbackify as Xbe}from"util";var W6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Fr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=BI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=VI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=$I(c,a),{read:E,onStdoutDataDone:S}=GI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),A=new Kbe({read:E,...jI(u,t,d),destroy:Xbe(Qbe.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 qI({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),WI(u,A,c),A},Qbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([HI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),zI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var YI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Fr.has(e),o=Ou(t,r),a=sb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Jbe(a,o,t)},Jbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var z6=(t,{encoding:e})=>{let r=F6();t.readable=G6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=V6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=W6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=YI.bind(void 0,t,e),t[Symbol.asyncIterator]=YI.bind(void 0,t,e,{})};var Y6=(t,e)=>{for(let[r,n]of eAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},Zbe=(async()=>{})().constructor.prototype,eAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Zbe,t)]);var K6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=nAe(t,e,r),{subprocess:f,promise:h}=iAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),Y6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},nAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),{file:a,commandArguments:c,options:l}=MT(t,e,r),u=sAe(l),d=o6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},sAe=({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}},iAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=rAe(...LT(t,e,r))}catch(p){return r6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;tAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];m6(c,a,l),_6(c,r,l);let d={},f=xs();c.kill=Iz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=I6(c,r),z6(c,r),ZY(c,r);let h=oAe({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}},oAe=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 U6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((T,k)=>Ai(T,e,k)),A=Ai(m,e,"all"),w=aAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Du(w,n,e)},aAe=({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?am({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 Os,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):qT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var cb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,cAe(n,t[n],s)]));return{...t,...r}},cAe=(t,e,r)=>lAe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,lAe=new Set(["env",...vO]);var Lo=(t,e,r,n)=>{let s=(o,a,c)=>Lo(o,a,r,c),i=(...o)=>uAe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},uAe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,cb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=dAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?zY(a,c,l):K6(a,c,l,s)},dAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=oW(e)?aW(e,r):[e,...r],[o,a,c]=rT(...i),l=cb(cb(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 X6=({file:t,commandArguments:e})=>J6(t,e),Q6=({file:t,commandArguments:e})=>({...J6(t,e),isSync:!0}),J6=(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]=fAe(t);return{file:r,commandArguments:n}},fAe=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(hAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},hAe=/ +/g;var Z6=(t,e,r)=>{t.sync=e(pAe,r),t.s=t.sync},e8=({options:t})=>t8(t),pAe=({options:t})=>({...t8(t),isSync:!0}),t8=t=>({options:{...mAe(t),...t}}),mAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},r8={preferLocal:!0};var n8=Lo(()=>({})),oet=Lo(()=>({isSync:!0})),s8=Lo(X6),aet=Lo(Q6),cet=Lo(p4),uet=Lo(e8,{},r8,Z6),{sendMessage:det,getOneMessage:fet,getEachMessage:het,getCancelSignal:pet}=e6();var gAe=!1;var vi=()=>gAe;var pm=null,i8=t=>(pm&&pm.destroy(),pm=new wi({totalAllowedTime:t}),pm),o8=()=>pm;var wi=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&&vi())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 Xy({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 a8={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 yAe=SAe(import.meta.url),TAe=Ri.dirname(yAe),bAe=EAe(import.meta.url),Bu=de("shell"),KI=new Set,c8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=AAe(e,r),i={...c8,...s},o=n8(t,n,i);u8(o,i),h8(o);let a=r?.idleTimeout;return a&&a>0&&f8(o,a),o},l8=(t,e)=>{let r={...c8,...e},n=s8(t,r);return u8(n,r),h8(n),e?.idleTimeout&&e.idleTimeout>0&&f8(n,e.idleTimeout),n},AAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},u8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ci.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(Ci.stdout),t.stderr?.pipe(new jp).pipe(Ci.stderr);return}t.stdout?.pipe(Ci.stdout),t.stderr?.pipe(Ci.stderr)},XI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ci.kill(-t.pid,e),Bu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bu.error("Error killing process:",r),!1}},d8=t=>XI(t,"SIGKILL"),f8=(t,e)=>{let r=null,n=()=>{Bu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),XI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bu.log(`Force killing idle process ${t.pid}`),d8(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)},h8=t=>{KI.add(t);let e=o8();if(e){let r=e.onTimesUp(()=>{Bu.log(`Global timer expired, killing process ${t.pid}`),XI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bu.log(`Force killing process ${t.pid} after timeout`),d8(t))},5e3)});t.on("exit",()=>{KI.delete(t),r()}),t.on("error",()=>{KI.delete(t),r()})}};function ub(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=bAe.resolve(a8.name),i=Ri.dirname(s);for(;i!==Ri.dirname(i);){let o=Ri.dirname(i);if(Ri.basename(o)==="node_modules"){let a=Ri.join(o,".bin",e);if(lb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(Ci.env.NODE_PATH){let s=Ri.join(Ci.env.NODE_PATH,".bin",e);if(lb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(lb.existsSync(r))return r;let n=Ri.join(TAe,"..","node_modules",".bin",e);if(lb.existsSync(n))return n}var vAe=de("utils"),wAe=t=>new Promise(e=>{setTimeout(e,t)});var db=(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 wAe(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},$u=(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},p8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):vAe.error("Could not parse JSON",n))}},RAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Do=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():RAe(e)).join(" ");function mc(t,e){e&&t.log(`Skill invoked: ${e}`)}var m8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),g8=(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 QI=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}},CAe=1e4,JI=(t,e=CAe)=>{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 _8}from"buffer";import xAe from"path";var S8=de("repo"),Er=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),y8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{S8.info("Getting runner diffs");let n=await OAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=NAe(i);await MAe(m,r)}S8.info("Changes after processing"),await eN(r);let o=await tN(i,r);if(await ZI(o,r),s=await IAe(r),!s)return{hasChanges:!1,ignored:o};await Er(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Er(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await E8(r),{hasChanges:!1,ignored:o};let u=await Er(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await Er(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await Er(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=_8.from(S).toString("base64"))}await E8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=_8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},E8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Er(["reset","--soft","HEAD~1"],{cwd:t})},ZI=async(t=[],e=process.cwd())=>{await Er(["add",".",...t],{cwd:e})},eN=async(t=process.cwd())=>{let e=await Er(["status","-s"],{cwd:t});return String(e.stdout??"")},T8=/.. (.+)?\.log$/,PAe=[T8],OAe=async(t=process.cwd())=>{let e=await eN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
89
+ if (condition) { yield value; }`)};import{Buffer as Lye}from"buffer";import{StringDecoder as Dye}from"string_decoder";var YT=(t,e,r)=>{if(r)return;if(t)return{transform:kye.bind(void 0,new TextEncoder)};let n=new Dye(e);return{transform:Uye.bind(void 0,n),final:Fye.bind(void 0,n)}},kye=function*(t,e){Lye.isBuffer(e)?yield yi(e):typeof e=="string"?yield t.encode(e):yield e},Uye=function*(t,e){yield gt(e)?t.write(e):e},Fye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as IY}from"util";var fI=IY(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),KT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=$ye}=e[r];for await(let s of n(t))yield*KT(s,e,r+1)},NY=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Bye(r,Number(e),t)},Bye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KT(n,r,e+1)},MY=IY(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),$ye=function*(t){yield t};var hI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},LY=(t,e)=>[...e.flatMap(r=>[...fc(r,t,0)]),...cm(t)],fc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qye}=e[r];for(let s of n(t))yield*fc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Gye(r,Number(e),t)},Gye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*fc(n,r,e+1)},qye=function*(t){yield t};var pI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=kY(t,o,i),l=dc(e),u=dc(r),d=l?fI.bind(void 0,KT,a):hI.bind(void 0,fc),f=l||u?fI.bind(void 0,NY,a):hI.bind(void 0,cm),h=l||u?MY.bind(void 0,a):void 0;return{stream:new Hye({writableObjectMode:n,writableHighWaterMark:DY(n),readableObjectMode:s,readableHighWaterMark:DY(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},XT=(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=kY(o,r,a);t=LY(c,t)}return t},kY=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:xY(n,a)},YT(r,o,n),zT(r,i,n,c),{transform:t,final:e},{transform:PY(s,a)},CY({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var UY=(t,e)=>{for(let r of Vye(t))jye(t,r,e)},Vye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),jye=(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 ${Mo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Wye(a,n));r.input=Jp(o)},Wye=(t,e)=>{let r=XT(t,e,"utf8",!0);return zye(r),Jp(r)},zye=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 Qye,appendFileSync as Jye}from"fs";var QT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&wu(r,n)&&!Fr.has(e)&&Yye(n)&&(t.some(({type:s,value:i})=>s==="native"&&Kye.has(i))||t.every(({type:s})=>mn.has(s))),Yye=t=>t===1||t===2,Kye=new Set(["pipe","overlapped"]),FY=async(t,e,r,n)=>{for await(let s of t)Xye(e)||$Y(s,r,n)},BY=(t,e,r)=>{for(let n of t)$Y(n,e,r)},Xye=t=>t._readableState.pipes.length>0,$Y=(t,e,r)=>{let n=dT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var GY=({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)=>Zye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},Zye=({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=q4(t,i,d),h=yi(f),{stdioItems:p,objectMode:m}=e[r],E=eTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=tTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});rTe({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let w=a[r]?A:void 0;try{return n.error===void 0&&nTe(S,p,s),w}catch(T){return n.error=T,w}},eTe=(t,e,r,n)=>{try{return XT(t,e,r,!1)}catch(s){return n.error=s,t}},tTe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Jp(t)};let o=rW(t,r);return n[i]?{serializedResult:o,finalResult:dI(o,!s[i],e)}:{serializedResult:o}},rTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!QT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=dI(t,!1,o);try{BY(a,e,n)}catch(c){r.error??=c}},nTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>jT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?Jye(n,t):(r.add(i),Qye(n,t))}};var qY=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ai(e,r,"all")]:Array.isArray(e)?[Ai(t,r,"all"),...e]:gt(t)&&gt(e)?yO([t,e]):`${t}${e}`};import{once as mI}from"events";var HY=async(t,e)=>{let[r,n]=await sTe(t);return e.isForcefullyTerminated??=!1,[r,n]},sTe=async t=>{let[e,r]=await Promise.allSettled([mI(t,"spawn"),mI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?VY(t):r.value},VY=async t=>{try{return await mI(t,"exit")}catch{return VY(t)}},jY=async t=>{let[e,r]=await t;if(!iTe(e,r)&&gI(e,r))throw new jn;return[e,r]},iTe=(t,e)=>t===void 0&&e===void 0,gI=(t,e)=>t!==0||e!==null;var WY=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=oTe(t,e,r),o=i?.code==="ETIMEDOUT",a=G4(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},oTe=(t,e,r)=>t!==void 0?t:gI(e,r)?new jn:void 0;var zY=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=cTe(t,e,r),d=dTe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Du(d,c,l)},cTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),a=lTe(r),{file:c,commandArguments:l,options:u}=MT(t,e,a);uTe(u);let d=AY(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},lTe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,uTe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&JT("ipcInput"),t&&JT("ipc: true"),r&&JT("detached: true"),n&&JT("cancelSignal")},JT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},dTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=fTe({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}=WY(c,r),{output:p,error:m=l}=GY({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,w)=>Ai(A,r,w)),S=Ai(qY(p,r),r,"all");return pTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},fTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{UY(i,r);let a=hTe(r);return aTe(...LT(t,e,a))}catch(a){return Lu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},hTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GT(e)}),pTe=({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?qT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):am({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 tAe}from"events";import{spawn as rAe}from"child_process";import JY from"process";import{once as _I,on as mTe}from"events";var YY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(xu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),gTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),gTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{AT(e,s);let i=No(t,e,r),o=new AbortController;try{return await Promise.race([_Te(i,n,o),STe(i,r,o),ETe(i,r,o)])}catch(a){throw Pu(t),a}finally{o.abort(),vT(e,s)}},_Te=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await _I(t,"message",{signal:r});return n}for await(let[n]of mTe(t,"message",{signal:r}))if(e(n))return n},STe=async(t,e,{signal:r})=>{await _I(t,"disconnect",{signal:r}),Lz(e)},ETe=async(t,e,{signal:r})=>{let[n]=await _I(t,"strict:error",{signal:r});throw yT(n,e)};import{once as XY,on as yTe}from"events";var QY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>SI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),SI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{xu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),AT(e,i);let o=No(t,e,r),a=new AbortController,c={};return TTe(t,o,a),bTe({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})},TTe=async(t,e,r)=>{try{await XY(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},bTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await XY(t,"strict:error",{signal:r.signal});n.error=yT(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 yTe(r,"message",{signal:i.signal}))KY(o),yield c}catch{KY(o)}finally{i.abort(),vT(e,a),n||Pu(t),s&&await t}},KY=({error:t})=>{if(t)throw t};var ZY=(t,{ipc:e})=>{Object.assign(t,t6(t,!1,e))},e6=()=>{let t=JY,e=!0,r=JY.channel!==void 0;return{...t6(t,e,r),getCancelSignal:a4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},t6=(t,e,r)=>({sendMessage:IT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:YY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:QY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as vTe}from"child_process";import{PassThrough as wTe,Readable as RTe,Writable as CTe,Duplex as xTe}from"stream";var r6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{cI(n);let a=new vTe;PTe(a,n),Object.assign(a,{readable:OTe,writable:ITe,duplex:NTe});let c=Lu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=MTe(c,o,s);return{subprocess:a,promise:l}},PTe=(t,e)=>{let r=lm(),n=lm(),s=lm(),i=Array.from({length:e.length-3},lm),o=lm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},lm=()=>{let t=new wTe;return t.end(),t},OTe=()=>new RTe({read(){}}),ITe=()=>new CTe({write(){}}),NTe=()=>new xTe({read(){},write(){}}),MTe=async(t,e,r)=>Du(t,e,r);import{createReadStream as n6,createWriteStream as s6}from"fs";import{Buffer as LTe}from"buffer";import{Readable as um,Writable as DTe,Duplex as kTe}from"stream";var o6=(t,e)=>WT(UTe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Mo[t]}.`)},i6={fileNumber:dm,generator:pI,asyncGenerator:pI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:kTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},UTe={input:{...i6,fileUrl:({value:t})=>({stream:n6(t)}),filePath:({value:{file:t}})=>({stream:n6(t)}),webStream:({value:t})=>({stream:um.fromWeb(t)}),iterable:({value:t})=>({stream:um.from(t)}),asyncIterable:({value:t})=>({stream:um.from(t)}),string:({value:t})=>({stream:um.from(t)}),uint8Array:({value:t})=>({stream:um.from(LTe.from(t))})},output:{...i6,fileUrl:({value:t})=>({stream:s6(t)}),filePath:({value:{file:t,append:e}})=>({stream:s6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:DTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as FTe,once as a6}from"events";import{PassThrough as BTe,getDefaultHighWaterMark as $Te}from"stream";import{finished as u6}from"stream/promises";function hc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)yI(s);let e=t.some(({readableObjectMode:s})=>s),r=GTe(t,e),n=new EI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var GTe=(t,e)=>{if(t.length===0)return $Te(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},EI=class extends BTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(yI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=qTe(this,this.#e,this.#i);let r=jTe({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(yI(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)}},qTe=async(t,e,r)=>{ZT(t,c6);let n=new AbortController;try{await Promise.race([HTe(t,n),VTe(t,e,r,n)])}finally{n.abort(),ZT(t,-c6)}},HTe=async(t,{signal:e})=>{try{await u6(t,{signal:e,cleanup:!0})}catch(r){throw d6(t,r),r}},VTe=async(t,e,r,{signal:n})=>{for await(let[s]of FTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},yI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},jTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{ZT(t,l6);let a=new AbortController;try{await Promise.race([WTe(i,e,a),zTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),YTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),ZT(t,-l6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?TI(t):KTe(t))},WTe=async(t,e,{signal:r})=>{try{await t,r.aborted||TI(e)}catch(n){r.aborted||d6(e,n)}},zTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await u6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;f6(o)?s.add(e):h6(t,o)}},YTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await a6(t,s,{signal:i}),!t.readable)return a6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},KTe=t=>{t.writable&&t.end()},d6=(t,e)=>{f6(e)?TI(t):h6(t,e)},f6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",TI=t=>{(t.readable||t.writable)&&t.destroy()},h6=(t,e)=>{t.destroyed||(t.once("error",XTe),t.destroy(e))},XTe=()=>{},ZT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},c6=2,l6=1;import{finished as p6}from"stream/promises";var Uu=(t,e)=>{t.pipe(e),QTe(t,e),JTe(t,e)},QTe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await p6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}bI(e)}},bI=t=>{t.writable&&t.end()},JTe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await p6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}AI(t)}},AI=t=>{t.readable&&t.destroy()};var m6=(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})=>mn.has(c)))ZTe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!mn.has(c)))tbe({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]:hc(i);Uu(o,s)}},ZTe=(t,e,r,n)=>{r==="output"?Uu(t.stdio[n],e):Uu(e,t.stdio[n]);let s=ebe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},ebe=["stdin","stdout","stderr"],tbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;rbe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},rbe=(t,{signal:e})=>{Vn(t)&&lc(t,nbe,e)},nbe=2;import{addAbortListener as obe}from"events";var pc=[];pc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&pc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&pc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eb=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",vI=Symbol.for("signal-exit emitter"),wI=globalThis,sbe=Object.defineProperty.bind(Object),RI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(wI[vI])return wI[vI];sbe(wI,vI,{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}},tb=class{},ibe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),CI=class extends tb{onExit(){return()=>{}}load(){}unload(){}},xI=class extends tb{#e=PI.platform==="win32"?"SIGINT":"SIGHUP";#r=new RI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of pc)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(!eb(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 pc)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,pc.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 eb(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"&&eb(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)}},PI=globalThis.process,{onExit:g6,load:gJe,unload:_Je}=ibe(eb(PI)?new xI(PI):new CI);var _6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=g6(()=>{t.kill()});obe(n,()=>{s()})};var E6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=fT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=abe(r,n,s),{sourceStream:d,sourceError:f}=lbe(t,l),{options:h,fileDescriptors:p}=Ps.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},abe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=cbe(t,e,...r),a=bT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},cbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(S6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||SO(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]=rT(r,...n);return{destination:e(S6)(s,i,o),pipeOptions:o}}if(Ps.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}`)},S6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),lbe=(t,e)=>{try{return{sourceStream:Ou(t,e)}}catch(r){return{sourceError:r}}};var T6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=ube({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw OI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},ube=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return AI(t),n;if(e!==void 0)return bI(r),e},OI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Lu({error:t,command:y6,escapedCommand:y6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),y6="source.pipe(destination)";var b6=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 dbe}from"stream/promises";var A6=(t,e,r)=>{let n=rb.has(e)?hbe(t,e):fbe(t,e);return lc(t,mbe,r.signal),lc(e,gbe,r.signal),pbe(e),n},fbe=(t,e)=>{let r=hc([t]);return Uu(r,e),rb.set(e,r),r},hbe=(t,e)=>{let r=rb.get(e);return r.add(t),r},pbe=async t=>{try{await dbe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rb.delete(t)},rb=new WeakMap,mbe=2,gbe=1;import{aborted as _be}from"util";var v6=(t,e)=>t===void 0?[]:[Sbe(t,e)],Sbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await _be(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw OI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var nb=(t,...e)=>{if(ot(e[0]))return nb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=E6(t,...e),s=Ebe({...n,destination:r});return s.pipe=nb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Ebe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ybe(t,s);T6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=A6(e,i,d);return await Promise.race([b6(u),...v6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ybe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Cbe}from"timers/promises";import{on as Tbe}from"events";import{getDefaultHighWaterMark as bbe}from"stream";var sb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Abe(e,o),R6({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()}},II=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;vbe(e,o,t);let a=t.readableObjectMode&&!i;return R6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},vbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},R6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Tbe(t,"data",{signal:e.signal,highWaterMark:w6,highWatermark:w6});return wbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},NI=bbe(!0),w6=NI,wbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Rbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*fc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},Rbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[YT(t,r,!e),zT(t,s,!n,{})].filter(Boolean);var C6=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=xbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Pbe(t),d]);return}let f=lI(c,r),h=II({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([Obe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},xbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!QT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=II({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await FY(a,t,r,i)},Pbe=async t=>{await Cbe(),t.readableFlowing===null&&t.resume()},Obe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await FT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await BT(r,{maxBuffer:i})):await Mu(r,{maxBuffer:i})}catch(a){return x6(F4({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},MI=async t=>{try{return await t}catch(e){return x6(e)}},x6=({bufferedData:t})=>eW(t)?new Uint8Array(t):t;import{finished as Ibe}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Nbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ibe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Dbe(a,e,r,n)}finally{o.abort()}},Nbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Mbe(t,r,n),n},Mbe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Lbe(e,r),n.call(t,...s)}},Lbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Dbe=(t,e,r,n)=>{if(!kbe(t,e,r,n))throw t},kbe=(t,e,r,n=!0)=>r.propagating?P6(t)||ib(t):(r.propagating=!0,LI(r,e)===n?P6(t):ib(t)),LI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ib=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",P6=t=>t?.code==="EPIPE";var O6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>DI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),DI=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=fm(t,e,l);if(LI(l,e)){await u;return}let[d]=await Promise.all([C6({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 I6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?hc([t,e].filter(Boolean)):void 0,N6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>DI({...Ube(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Fbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),Ube=({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}},Fbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Bbe}from"events";var M6=t=>wu(t,"ipc"),L6=(t,e)=>{let r=dT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var D6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=M6(i),a=Ti(e,"ipc"),c=Ti(r,"ipc");for await(let l of SI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(B4(t,s,c),s.push(l)),o&&L6(l,i);return s},k6=async(t,e)=>(await Promise.allSettled([t]),e);var U6=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 A=HY(t,f),w={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=O6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),k=N6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:w}),R=[],O=D6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:h}),I=$be(m,t,w),x=Gbe(p,w);try{return await Promise.race([Promise.all([{},jY(A),Promise.all(T),k,O,_4(t,d),...I,...x]),E,qbe(t,S),...f4(t,i,f,S),...Mz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...u4({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(M){return f.terminationReason??="other",Promise.all([{error:M},A,Promise.all(T.map(_=>MI(_))),MI(k),k6(O,R),Promise.allSettled(I),Promise.allSettled(x)])}},$be=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),Gbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>zn(i,{checkOpen:!1})&&!Vn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:mn.has(s),stopOnExit:s==="native"}))),qbe=async(t,{signal:e})=>{let[r]=await Bbe(t,"error",{signal:e});throw r};var F6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=xs();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Fu=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 Hbe}from"stream";import{callbackify as Vbe}from"util";import{finished as B6}from"stream/promises";var kI=async t=>{if(t!==void 0)try{await UI(t)}catch{}},$6=async t=>{if(t!==void 0)try{await FI(t)}catch{}},UI=async t=>{await B6(t,{cleanup:!0,readable:!1,writable:!0})},FI=async t=>{await B6(t,{cleanup:!0,readable:!0,writable:!1})},ob=async(t,e)=>{if(await t,e)throw e},ab=(t,e,r)=>{r&&!ib(r)?t.destroy(r):e&&t.destroy()};var G6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Fr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=BI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=$I(a,o),{read:f,onStdoutDataDone:h}=GI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Hbe({read:f,destroy:Vbe(HI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return qI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},BI=(t,e,r)=>{let n=Ou(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},$I=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:NI},GI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=xs(),o=sb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){jbe(this,o,i)},onStdoutDataDone:i}},jbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},qI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await FI(t),await n,await kI(s),await e,r.readable&&r.push(null)}catch(i){await kI(s),q6(r,i)}},HI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Fu(r,e)&&(q6(t,n),await ob(e,n))},q6=(t,e)=>{ab(t,t.readable,e)};import{Writable as Wbe}from"stream";import{callbackify as H6}from"util";var V6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=VI(t,r,e),o=new Wbe({...jI(n,t,s),destroy:H6(zI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return WI(n,o),o},VI=(t,e,r)=>{let n=bT(t,e),s=hm(r,n,"writableFinal"),i=hm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},jI=(t,e,r)=>({write:zbe.bind(void 0,t),final:H6(Ybe.bind(void 0,t,e,r))}),zbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Ybe=async(t,e,r)=>{await Fu(r,e)&&(t.writable&&t.end(),await e)},WI=async(t,e,r)=>{try{await UI(t),e.writable&&e.end()}catch(n){await $6(r),j6(e,n)}},zI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Fu(r,e),await Fu(n,e)&&(j6(t,s),await ob(e,s))},j6=(t,e)=>{ab(t,t.writable,e)};import{Duplex as Kbe}from"stream";import{callbackify as Xbe}from"util";var W6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Fr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=BI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=VI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=$I(c,a),{read:E,onStdoutDataDone:S}=GI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),A=new Kbe({read:E,...jI(u,t,d),destroy:Xbe(Qbe.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 qI({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),WI(u,A,c),A},Qbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([HI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),zI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var YI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Fr.has(e),o=Ou(t,r),a=sb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Jbe(a,o,t)},Jbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var z6=(t,{encoding:e})=>{let r=F6();t.readable=G6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=V6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=W6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=YI.bind(void 0,t,e),t[Symbol.asyncIterator]=YI.bind(void 0,t,e,{})};var Y6=(t,e)=>{for(let[r,n]of eAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},Zbe=(async()=>{})().constructor.prototype,eAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Zbe,t)]);var K6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=nAe(t,e,r),{subprocess:f,promise:h}=iAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),Y6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},nAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),{file:a,commandArguments:c,options:l}=MT(t,e,r),u=sAe(l),d=o6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},sAe=({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}},iAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=rAe(...LT(t,e,r))}catch(p){return r6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;tAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];m6(c,a,l),_6(c,r,l);let d={},f=xs();c.kill=Iz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=I6(c,r),z6(c,r),ZY(c,r);let h=oAe({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}},oAe=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 U6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((T,k)=>Ai(T,e,k)),A=Ai(m,e,"all"),w=aAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Du(w,n,e)},aAe=({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?am({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 Os,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):qT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var cb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,cAe(n,t[n],s)]));return{...t,...r}},cAe=(t,e,r)=>lAe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,lAe=new Set(["env",...vO]);var Lo=(t,e,r,n)=>{let s=(o,a,c)=>Lo(o,a,r,c),i=(...o)=>uAe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},uAe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,cb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=dAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?zY(a,c,l):K6(a,c,l,s)},dAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=oW(e)?aW(e,r):[e,...r],[o,a,c]=rT(...i),l=cb(cb(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 X6=({file:t,commandArguments:e})=>J6(t,e),Q6=({file:t,commandArguments:e})=>({...J6(t,e),isSync:!0}),J6=(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]=fAe(t);return{file:r,commandArguments:n}},fAe=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(hAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},hAe=/ +/g;var Z6=(t,e,r)=>{t.sync=e(pAe,r),t.s=t.sync},e8=({options:t})=>t8(t),pAe=({options:t})=>({...t8(t),isSync:!0}),t8=t=>({options:{...mAe(t),...t}}),mAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},r8={preferLocal:!0};var n8=Lo(()=>({})),oet=Lo(()=>({isSync:!0})),s8=Lo(X6),aet=Lo(Q6),cet=Lo(p4),uet=Lo(e8,{},r8,Z6),{sendMessage:det,getOneMessage:fet,getEachMessage:het,getCancelSignal:pet}=e6();var gAe=!1;var vi=()=>gAe;var pm=null,i8=t=>(pm&&pm.destroy(),pm=new wi({totalAllowedTime:t}),pm),o8=()=>pm;var wi=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&&vi())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 Xy({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 a8={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 yAe=SAe(import.meta.url),TAe=Ri.dirname(yAe),bAe=EAe(import.meta.url),Bu=de("shell"),KI=new Set,c8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=AAe(e,r),i={...c8,...s},o=n8(t,n,i);u8(o,i),h8(o);let a=r?.idleTimeout;return a&&a>0&&f8(o,a),o},l8=(t,e)=>{let r={...c8,...e},n=s8(t,r);return u8(n,r),h8(n),e?.idleTimeout&&e.idleTimeout>0&&f8(n,e.idleTimeout),n},AAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},u8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ci.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(Ci.stdout),t.stderr?.pipe(new jp).pipe(Ci.stderr);return}t.stdout?.pipe(Ci.stdout),t.stderr?.pipe(Ci.stderr)},XI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ci.kill(-t.pid,e),Bu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bu.error("Error killing process:",r),!1}},d8=t=>XI(t,"SIGKILL"),f8=(t,e)=>{let r=null,n=()=>{Bu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),XI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bu.log(`Force killing idle process ${t.pid}`),d8(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)},h8=t=>{KI.add(t);let e=o8();if(e){let r=e.onTimesUp(()=>{Bu.log(`Global timer expired, killing process ${t.pid}`),XI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bu.log(`Force killing process ${t.pid} after timeout`),d8(t))},5e3)});t.on("exit",()=>{KI.delete(t),r()}),t.on("error",()=>{KI.delete(t),r()})}};function ub(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=bAe.resolve(a8.name),i=Ri.dirname(s);for(;i!==Ri.dirname(i);){let o=Ri.dirname(i);if(Ri.basename(o)==="node_modules"){let a=Ri.join(o,".bin",e);if(lb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(Ci.env.NODE_PATH){let s=Ri.join(Ci.env.NODE_PATH,".bin",e);if(lb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(lb.existsSync(r))return r;let n=Ri.join(TAe,"..","node_modules",".bin",e);if(lb.existsSync(n))return n}var vAe=de("utils"),wAe=t=>new Promise(e=>{setTimeout(e,t)});var db=(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 wAe(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},$u=(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},p8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):vAe.error("Could not parse JSON",n))}},RAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Do=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():RAe(e)).join(" ");function mc(t,e){e&&t.log(`Skill invoked: ${e}`)}var m8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),g8=(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 QI=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}},CAe=1e4,JI=(t,e=CAe)=>{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 _8}from"buffer";import xAe from"path";var S8=de("repo"),Er=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),y8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{S8.info("Getting runner diffs");let n=await OAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=NAe(i);await MAe(m,r)}S8.info("Changes after processing"),await eN(r);let o=await tN(i,r);if(await ZI(o,r),s=await IAe(r),!s)return{hasChanges:!1,ignored:o};await Er(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Er(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await E8(r),{hasChanges:!1,ignored:o};let u=await Er(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await Er(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await Er(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=_8.from(S).toString("base64"))}await E8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=_8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},E8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Er(["reset","--soft","HEAD~1"],{cwd:t})},ZI=async(t=[],e=process.cwd())=>{await Er(["add",".",...t],{cwd:e})},eN=async(t=process.cwd())=>{let e=await Er(["status","-s"],{cwd:t});return String(e.stdout??"")},T8=/.. (.+)?\.log$/,PAe=[T8],OAe=async(t=process.cwd())=>{let e=await eN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
90
90
  `).filter(s=>PAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},IAe=async(t=process.cwd())=>{try{return await Er(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},mm=async(t=process.cwd())=>{let{stdout:e}=await Er(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},b8=async(t=process.cwd())=>{let{stdout:e}=await Er(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},tN=async(t,e=process.cwd())=>{t||=await eN(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(`
91
91
  `).forEach(s=>{r.forEach(o=>{let a=s===`?? ${o}`,c=s.startsWith(`?? ${o}/`)||s.startsWith(`?? ${o}${xAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(T8)?.[1];i&&n.push(`:!${i}.log`)}),n},rN=async(t=process.cwd())=>{await Er(["reset","--hard","HEAD"],{cwd:t})},A8=async(t=process.cwd())=>{let e=await Er(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
92
92
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},NAe=t=>{let e=t.split(`
@@ -362,7 +362,7 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
362
362
 
363
363
  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.
364
364
  `),w};var sCe=de("prompt"),V5=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:s,resumePrompt:i})=>{let o=await H5({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:s,resumePrompt:i});return process.env.AGENT_RUNNER_DEBUG&&sCe.log("Contextful Prompt:",o),{prompt:o}};var iCe,MM;var LM=()=>iCe,j5=de("session_manager"),DM=async(t,e)=>{if(!jt().idleTimeoutEnabled||!t||t===e)return;let r=Sf[t];if(r)try{await r.clean(),j5.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){j5.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{MM=void 0}},kM=t=>{MM=t};var W5=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===MM};var z5=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 Yi from"fs/promises";import X7 from"os";import Ki from"path";import{rm as _1}from"fs/promises";import{resolve as oCe}from"path";var aCe=".netlify/cache/",tl=function({cacheDir:t=aCe,cwd:e="."}={}){return oCe(e,t)};import{promises as gNe}from"fs";import{basename as v7,dirname as w7,join as _Ne}from"path";import NIe from"process";import MIe from"events";import De from"path";import LIe from"os";async function gg(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)},A=k=>{i(k),S()},w=k=>{u=!0,d=!0,o(k),S()};s&&(s.aborted&&w(s.reason),s.addEventListener("abort",E,{once:!0}));let T=async()=>{if(d)return;let k=await m.next(),R=p;if(p++,k.done){if(f=!0,h===0&&!d){if(!n&&c.length>0){w(new AggregateError(c));return}if(d=!0,l.size===0){A(a);return}let O=[];for(let[I,x]of a.entries())l.get(I)!==Y5&&O.push(x);A(O)}return}h++,(async()=>{try{let O=await k.value;if(d)return;let I=await e(O,R);I===Y5&&l.set(R,I),a[R]=I,h--,await T()}catch(O){if(n)w(O);else{c.push(O),h--;try{await T()}catch(I){w(I)}}}})()};(async()=>{for(let k=0;k<r;k++){try{await T()}catch(R){w(R);break}if(f||u)break}})()})}var Y5=Symbol("skip");import nl from"path";import agt,{constants as WM}from"fs";import zM from"fs/promises";var FM=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},BM=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},K5=t=>globalThis.DOMException===void 0?new BM(t):new DOMException(t),X5=t=>{let e=t.reason===void 0?K5("This operation was aborted."):t.reason;return e instanceof Error?e:K5(e)};function $M(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(X5(h)),a=()=>{d(X5(h))},h.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new FM;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 cCe=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 lCe(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}=cCe(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=$M(s,{milliseconds:r.timeout});return i.cancel=n,i}return s}function CA(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=lCe(t,e,r),s=n.then(i=>i[0]);return s.cancel=n.cancel,s}var lr=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Jn=fr(a9(),1);import{promisify as _g}from"util";var egt=_g(Jn.default.stat),yCe=_g(Jn.default.lstat),TCe=_g(Jn.default.utimes),bCe=_g(Jn.default.chmod),ACe=_g(Jn.default.mkdir),tgt=Jn.default.closeSync.bind(Jn.default),c9=Jn.default.createWriteStream.bind(Jn.default);async function l9(t,e){let r=Jn.default.createReadStream(t,e);try{await CA(r,["readable","end"])}catch(n){throw new lr(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var jM=t=>yCe(t).catch(e=>{throw new lr(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),u9=(t,e,r)=>TCe(t,e,r).catch(n=>{throw new lr(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),d9=(t,e)=>bCe(t,e).catch(r=>{throw new lr(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var f9=(t,e)=>ACe(t,{...e,recursive:!0}).catch(r=>{throw new lr(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var wCe=(t,e,r)=>({sourcePath:nl.resolve(t,e),destinationPath:nl.resolve(t,r)}),RCe=(t,e)=>{if(!t.isFile())throw Object.assign(new lr(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function h9(t,e,r={}){if(!t||!e)throw new lr("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=wCe(r.cwd,t,e)),r={overwrite:!0,...r};let n=await jM(t),{size:s}=n;RCe(n,t);let i=nl.dirname(e);if(nl.parse(i).root===i||await f9(nl.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await l9(t),c=c9(e,{flags:r.overwrite?"w":"wx"}),l=h=>{r.onProgress({sourcePath:nl.resolve(t),destinationPath:nl.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 lr(`Cannot read from \`${t}\`: ${h.message}`,{cause:h})});let f=!1;try{let h=CA(c,"close");a.pipe(c),await h,l(s),f=!0}catch(h){throw new lr(`Cannot write to \`${e}\`: ${h.message}`,{cause:h})}if(d)throw d;if(f){let h=await jM(t);return Promise.all([u9(e,h.atime,h.mtime).catch(p=>{if(p.code!=="EPERM")throw p}),d9(e,h.mode)])}}else{let a=r.overwrite?WM.COPYFILE_FICLONE:WM.COPYFILE_FICLONE|WM.COPYFILE_EXCL;try{await zM.copyFile(t,e,a),await Promise.all([zM.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),zM.chmod(e,n.mode)])}catch(c){throw new lr(c.message,{cause:c})}}}async function YM(t,e,r){return(await gg(t,(s,i)=>Promise.all([e(s,i),s]),r)).filter(s=>!!s[0]).map(s=>s[1])}import OJ from"process";import wIe from"fs";import Nf from"path";import{on as CCe,once as xCe}from"events";import{PassThrough as PCe}from"stream";import{finished as g9}from"stream/promises";function JM(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)XM(s);let e=t.some(({readableObjectMode:s})=>s),r=OCe(t,e),n=new KM({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return t.length===0&&E9(n),n}var OCe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},KM=class extends PCe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){XM(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=ICe(this,this.#e),LCe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return XM(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},ICe=async(t,e)=>{NA(t,p9);let r=new AbortController;try{await Promise.race([NCe(t,r),MCe(t,e,r)])}finally{r.abort(),NA(t,-p9)}},NCe=async(t,{signal:e})=>{await g9(t,{signal:e,cleanup:!0})},MCe=async(t,e,{signal:r})=>{for await(let[n]of CCe(t,"unpipe",{signal:r}))e.has(n)&&n.emit(S9)},XM=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},LCe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i})=>{NA(t,m9);let o=new AbortController;try{await Promise.race([DCe(i,e),kCe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:o}),UCe({stream:e,streams:r,ended:n,aborted:s,controller:o})])}finally{o.abort(),NA(t,-m9)}r.size===n.size+s.size&&(n.size===0&&s.size>0?QM(t):E9(t))},_9=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DCe=async(t,e)=>{try{await t,QM(e)}catch(r){_9(r)?QM(e):y9(e,r)}},kCe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await g9(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;_9(o)?s.add(e):y9(t,o)}},UCe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:s}})=>{await xCe(t,S9,{signal:s}),e.delete(t),r.delete(t),n.delete(t)},S9=Symbol("unpipe"),E9=t=>{t.writable&&t.end()},QM=t=>{(t.readable||t.writable)&&t.destroy()},y9=(t,e)=>{t.destroyed||(t.once("error",FCe),t.destroy(e))},FCe=()=>{},NA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},p9=2,m9=1;var Mf=fr(vg(),1);import XOe from"fs";import QOe from"fs/promises";async function FD(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await QOe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function BD(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return XOe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var $_t=FD.bind(void 0,"stat","isFile"),dJ=FD.bind(void 0,"stat","isDirectory"),G_t=FD.bind(void 0,"lstat","isSymbolicLink"),q_t=BD.bind(void 0,"statSync","isFile"),fJ=BD.bind(void 0,"statSync","isDirectory"),H_t=BD.bind(void 0,"lstatSync","isSymbolicLink");var zD=fr(vg(),1),TJ=fr(WD(),1);import SIe from"process";import EIe from"fs";import yIe from"fs/promises";import If from"path";function Of(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Rg=t=>t[0]==="!";var TIe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],bJ={absolute:!0,dot:!0},AJ="**/.gitignore",bIe=(t,e)=>Rg(t)?"!"+If.posix.join(e,t.slice(1)):If.posix.join(e,t),AIe=(t,e)=>{let r=Of(If.relative(e,If.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>bIe(n,r))},vIe=(t,e)=>{if(e=Of(e),If.isAbsolute(t)){if(Of(t).startsWith(e))return If.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},vJ=(t,e)=>{let r=t.flatMap(s=>AIe(s,e)),n=(0,TJ.default)().add(r);return s=>(s=Sr(s),s=vIe(s,e),s?n.ignores(Of(s)):!1)},wJ=(t={})=>({cwd:Sr(t.cwd)??SIe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...TIe]}),RJ=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=wJ(e),o=await(0,zD.default)(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...bJ}),a=await Promise.all(o.map(async c=>({filePath:c,content:await yIe.readFile(c,"utf8")})));return vJ(a,r)},CJ=(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=wJ(e),a=zD.default.sync(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...bJ}).map(c=>({filePath:c,content:EIe.readFileSync(c,"utf8")}));return vJ(a,r)};var RIe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},IJ=(t,e)=>{let r=Rg(t)?t.slice(1):t;return Nf.isAbsolute(r)?r:Nf.join(e,r)},NJ=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(s=>Nf.posix.join(t,`**/${Nf.extname(s)?s:`${s}${n}`}`)):[Nf.posix.join(t,`**${n?`/*${n}`:""}`)]},xJ=async(t,{cwd:e=OJ.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async i=>await dJ(IJ(i,e))?NJ({directoryPath:i,files:r,extensions:n}):i))).flat(),PJ=(t,{cwd:e=OJ.cwd(),files:r,extensions:n}={})=>t.flatMap(s=>fJ(IJ(s,e))?NJ({directoryPath:s,files:r,extensions:n}):s),YD=t=>(t=[...new Set([t].flat())],RIe(t),t),CIe=t=>{if(!t)return;let e;try{e=wIe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},MJ=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Sr(t.cwd)},CIe(t.cwd),t),LJ=t=>async(e,r)=>t(YD(e),MJ(r)),uv=t=>(e,r)=>t(YD(e),MJ(r)),DJ=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?YD(e):[];return r&&n.push(AJ),n},xIe=async t=>{let e=DJ(t);return UJ(e.length>0&&await RJ(e,t))},kJ=t=>{let e=DJ(t);return UJ(e.length>0&&CJ(e,t))},UJ=t=>{let e=new Set;return r=>{let n=Nf.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},FJ=(t,e)=>t.flat().filter(r=>e(r)),BJ=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(i=>Rg(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},$J=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),GJ=async(t,e)=>{let r=BJ(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=$J(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}}))},KD=(t,e)=>{let r=BJ(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=$J(s,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=PJ(a,i),c.ignore=PJ(c.ignore,{cwd:n}),{patterns:a,options:c}})},uSt=LJ(async(t,e)=>{let[r,n]=await Promise.all([GJ(t,e),xIe(e)]),s=await Promise.all(r.map(i=>(0,Mf.default)(i.patterns,i.options)));return FJ(s,n)}),qJ=uv((t,e)=>{let r=KD(t,e),n=kJ(e),s=r.map(i=>Mf.default.sync(i.patterns,i.options));return FJ(s,n)}),dSt=uv((t,e)=>{let r=KD(t,e),n=kJ(e),s=r.map(o=>Mf.default.stream(o.patterns,o.options));return JM(s).filter(o=>n(o))}),al=uv((t,e)=>t.some(r=>Mf.default.isDynamicPattern(r,e))),fSt=LJ(GJ),hSt=uv(KD),{convertPathToPattern:pSt}=Mf.default;var VJ=fr(yL(),1);var _a=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import fv from"path";import HJ 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$"],OIe=new RegExp(PIe.join("|"));function IIe(t){return OIe.test(t)}function dv(t){return!IIe(t)}var Cg=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!al(e)&&HJ.existsSync(e)&&HJ.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return fv.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(s=>s?al(s):!1),n=e.slice(0,r).join("/");return n?fv.isAbsolute(n)?n:fv.join(this.options.cwd,n):this.destination}hasMagic(){return al(this.options.flat?this.path:this.originalPath)}getMatches(){let e=qJ(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>dv(fv.basename(r)))),e}};var DIe={ignoreJunk:!0,flat:!1,cwd:NIe.cwd()},XD=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)}},kIe=t=>t.flatMap(e=>VJ.default.braces(e,{expand:!0,nodupes:!0})),UIe=({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)),FIe=(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 QD(t,e,{concurrency:r=LIe.availableParallelism(),...n}={}){let s=new Map,i=new MIe;n={...DIe,...n};let o=(async()=>{let a=[],c=0,l=0,u=kIe([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 _a("`source` and `destination` required");u=u.map(p=>new Cg(p,e,{...n,ignore:f}));for(let p of u){let m=[];try{m=p.getMatches()}catch(E){throw new _a(`Cannot glob \`${p.originalPath}\`: ${E.message}`,{cause:E})}if(m.length===0&&!al(p.originalPath)&&!al(f))throw new _a(`Cannot copy \`${p.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(E=>new XD(E,De.relative(n.cwd,E),p))]}n.filter!==void 0&&(a=await YM(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 gg(a,async p=>{let m=FIe(UIe({entry:p,destination:e,options:n}),n.rename);try{await h9(p.path,m,{...n,onProgress:h})}catch(E){throw new _a(`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 l7 from"process";import oNe from"fs";import kf from"path";import{on as BIe,once as $Ie}from"events";import{PassThrough as GIe}from"stream";import{finished as zJ}from"stream/promises";function t1(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)ZD(s);let e=t.some(({readableObjectMode:s})=>s),r=qIe(t,e),n=new JD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return t.length===0&&XJ(n),n}var qIe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},JD=class extends GIe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){ZD(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=HIe(this,this.#e),WIe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return ZD(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},HIe=async(t,e)=>{hv(t,jJ);let r=new AbortController;try{await Promise.race([VIe(t,r),jIe(t,e,r)])}finally{r.abort(),hv(t,-jJ)}},VIe=async(t,{signal:e})=>{await zJ(t,{signal:e,cleanup:!0})},jIe=async(t,e,{signal:r})=>{for await(let[n]of BIe(t,"unpipe",{signal:r}))e.has(n)&&n.emit(KJ)},ZD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},WIe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i})=>{hv(t,WJ);let o=new AbortController;try{await Promise.race([zIe(i,e),YIe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:o}),KIe({stream:e,streams:r,ended:n,aborted:s,controller:o})])}finally{o.abort(),hv(t,-WJ)}r.size===n.size+s.size&&(n.size===0&&s.size>0?e1(t):XJ(t))},YJ=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zIe=async(t,e)=>{try{await t,e1(e)}catch(r){YJ(r)?e1(e):QJ(e,r)}},YIe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await zJ(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;YJ(o)?s.add(e):QJ(t,o)}},KIe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:s}})=>{await $Ie(t,KJ,{signal:s}),e.delete(t),r.delete(t),n.delete(t)},KJ=Symbol("unpipe"),XJ=t=>{t.writable&&t.end()},e1=t=>{(t.readable||t.writable)&&t.destroy()},QJ=(t,e)=>{t.destroyed||(t.once("error",XIe),t.destroy(e))},XIe=()=>{},hv=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},jJ=2,WJ=1;var Uf=fr(vg(),1);import QIe from"fs";import JIe from"fs/promises";async function r1(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await JIe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function n1(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return QIe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var $St=r1.bind(void 0,"stat","isFile"),JJ=r1.bind(void 0,"stat","isDirectory"),GSt=r1.bind(void 0,"lstat","isSymbolicLink"),qSt=n1.bind(void 0,"statSync","isFile"),ZJ=n1.bind(void 0,"statSync","isDirectory"),HSt=n1.bind(void 0,"lstatSync","isSymbolicLink");var s1=fr(vg(),1),e7=fr(WD(),1);import ZIe from"process";import eNe from"fs";import tNe from"fs/promises";import Df from"path";function Lf(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var xg=t=>t[0]==="!";var rNe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],t7={absolute:!0,dot:!0},r7="**/.gitignore",nNe=(t,e)=>xg(t)?"!"+Df.posix.join(e,t.slice(1)):Df.posix.join(e,t),sNe=(t,e)=>{let r=Lf(Df.relative(e,Df.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>nNe(n,r))},iNe=(t,e)=>{if(e=Lf(e),Df.isAbsolute(t)){if(Lf(t).startsWith(e))return Df.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},n7=(t,e)=>{let r=t.flatMap(s=>sNe(s,e)),n=(0,e7.default)().add(r);return s=>(s=Sr(s),s=iNe(s,e),s?n.ignores(Lf(s)):!1)},s7=(t={})=>({cwd:Sr(t.cwd)??ZIe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...rNe]}),i7=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=s7(e),o=await(0,s1.default)(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...t7}),a=await Promise.all(o.map(async c=>({filePath:c,content:await tNe.readFile(c,"utf8")})));return n7(a,r)},o7=(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=s7(e),a=s1.default.sync(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...t7}).map(c=>({filePath:c,content:eNe.readFileSync(c,"utf8")}));return n7(a,r)};var aNe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},u7=(t,e)=>{let r=xg(t)?t.slice(1):t;return kf.isAbsolute(r)?r:kf.join(e,r)},d7=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(s=>kf.posix.join(t,`**/${kf.extname(s)?s:`${s}${n}`}`)):[kf.posix.join(t,`**${n?`/*${n}`:""}`)]},a7=async(t,{cwd:e=l7.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async i=>await JJ(u7(i,e))?d7({directoryPath:i,files:r,extensions:n}):i))).flat(),c7=(t,{cwd:e=l7.cwd(),files:r,extensions:n}={})=>t.flatMap(s=>ZJ(u7(s,e))?d7({directoryPath:s,files:r,extensions:n}):s),i1=t=>(t=[...new Set([t].flat())],aNe(t),t),cNe=t=>{if(!t)return;let e;try{e=oNe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},f7=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Sr(t.cwd)},cNe(t.cwd),t),h7=t=>async(e,r)=>t(i1(e),f7(r)),pv=t=>(e,r)=>t(i1(e),f7(r)),p7=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?i1(e):[];return r&&n.push(r7),n},lNe=async t=>{let e=p7(t);return g7(e.length>0&&await i7(e,t))},m7=t=>{let e=p7(t);return g7(e.length>0&&o7(e,t))},g7=t=>{let e=new Set;return r=>{let n=kf.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},_7=(t,e)=>t.flat().filter(r=>e(r)),S7=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(i=>xg(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},E7=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),y7=async(t,e)=>{let r=S7(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=E7(s,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([a7(a,i),a7(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},o1=(t,e)=>{let r=S7(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=E7(s,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=c7(a,i),c.ignore=c7(c.ignore,{cwd:n}),{patterns:a,options:c}})},T7=h7(async(t,e)=>{let[r,n]=await Promise.all([y7(t,e),lNe(e)]),s=await Promise.all(r.map(i=>(0,Uf.default)(i.patterns,i.options)));return _7(s,n)}),lEt=pv((t,e)=>{let r=o1(t,e),n=m7(e),s=r.map(i=>Uf.default.sync(i.patterns,i.options));return _7(s,n)}),uEt=pv((t,e)=>{let r=o1(t,e),n=m7(e),s=r.map(o=>Uf.default.stream(o.patterns,o.options));return t1(s).filter(o=>n(o))}),dEt=pv((t,e)=>t.some(r=>Uf.default.isDynamicPattern(r,e))),fEt=h7(y7),hEt=pv(o1),{convertPathToPattern:pEt}=Uf.default;import dNe from"process";import Pg from"path";import bEt,{promises as mv}from"fs";import _Et,{promises as uNe}from"fs";async function b7(t){try{return await uNe.access(t),!0}catch{return!1}}var fNe=(t,e,r)=>(e=Pg.resolve(t,e),r=Pg.resolve(t,r),{sourcePath:e,destinationPath:r}),hNe=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},pNe=(t,e)=>{if(Pg.dirname(t)!==Pg.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},mNe=async(t,e,{overwrite:r=!0,cwd:n=dNe.cwd(),directoryMode:s,validateDirectory:i=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=fNe(n,t,e)),i&&pNe(t,e),!r&&await b7(e))throw new Error(`The destination file exists: ${e}`);await mv.mkdir(Pg.dirname(e),{recursive:!0,mode:s});try{await mv.rename(t,e)}catch(o){if(o.code==="EXDEV")await mv.copyFile(t,e),await mv.unlink(t);else throw o}};async function A7(t,e,r){return hNe(t,e),mNe(t,e,r)}var a1=async function(t,e,r=!1){if(r)return A7(t,e,{overwrite:!1});let{srcGlob:n,dest:s,...i}=await R7(t,w7(e));if(n&&s)return QD(n,s,{...i,overwrite:!1})},Og=async function(t){let{srcGlob:e,isDir:r,dest:n,...s}=await R7(t,"");return e!==void 0&&!await SNe(e,r,s)},SNe=async function(t,e,r){return e?(await T7(t,r)).filter(i=>dv(v7(i))).length===0:!1},R7=async function(t,e){let r=await ENe(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),s=v7(t),i=w7(t),o={srcGlob:s,dest:e,isDir:n,cwd:i,dot:!0};return n?{...o,srcGlob:`${s}/**`,dest:_Ne(e,s)}:o},ENe=async t=>{try{return await gNe.stat(t)}catch{return}};import{join as pMe}from"path";import{stat as yNe,lstat as C7,readdir as TNe,realpath as bNe}from"fs/promises";import{Readable as ANe}from"stream";import{resolve as x7,relative as vNe,join as wNe,sep as RNe}from"path";var Yr={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},c1={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Yr.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(c1);var N7="READDIRP_RECURSIVE_ERROR",CNe=new Set(["ENOENT","EPERM","EACCES","ELOOP",N7]),P7=[Yr.DIR_TYPE,Yr.EVERYTHING_TYPE,Yr.FILE_DIR_TYPE,Yr.FILE_TYPE],xNe=new Set([Yr.DIR_TYPE,Yr.EVERYTHING_TYPE,Yr.FILE_DIR_TYPE]),PNe=new Set([Yr.EVERYTHING_TYPE,Yr.FILE_DIR_TYPE,Yr.FILE_TYPE]),ONe=t=>CNe.has(t.code),INe=process.platform==="win32",O7=t=>!0,I7=t=>{if(t===void 0)return O7;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 O7},l1=class extends ANe{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...c1,...e},{root:n,type:s}=r;this._fileFilter=I7(r.fileFilter),this._directoryFilter=I7(r.directoryFilter);let i=r.lstat?C7:yNe;INe?this._stat=o=>i(o,{bigint:!0}):this._stat=i,this._maxDepth=r.depth??c1.depth,this._wantsDir=s?xNe.has(s):!1,this._wantsFile=s?PNe.has(s):!1,this._wantsEverything=s===Yr.EVERYTHING_TYPE,this._root=x7(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 TNe(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=x7(wNe(r,s));n={path:vNe(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){ONe(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 bNe(n),i=await C7(s);if(i.isFile())return"file";if(i.isDirectory()){let o=s.length;if(n.startsWith(s)&&n.substr(o,1)===RNe){let a=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return a.code=N7,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 NNe(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Yr.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&&!P7.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${P7.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new l1(e)}function M7(t,e={}){return new Promise((r,n)=>{let s=[];NNe(t,e).on("data",i=>s.push(i)).on("end",()=>r(s)).on("error",i=>n(i))})}import{mkdir as jNe,readFile as $7,rm as WNe,writeFile as zNe}from"fs/promises";import{existsSync as G7}from"fs";import{dirname as YNe}from"path";var L7=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},D7=t=>t!==void 0&&Date.now()>t;import{createHash as GNe}from"crypto";import{createReadStream as qNe}from"fs";import DNe from"process";import kNe from"path";import jEt,{promises as k7}from"fs";import{fileURLToPath as UNe}from"url";var u1=class{value;next;constructor(e){this.value=e}},Ig=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new u1(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 gv(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 Ig,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 _v=class extends Error{constructor(e){super(),this.value=e}},MNe=async(t,e)=>e(await t),LNe=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new _v(e[0]);return!1};async function d1(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let s=gv(r),i=[...t].map(a=>[a,s(MNe,a,e)]),o=gv(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(i.map(a=>o(LNe,a)))}catch(a){if(a instanceof _v)return a.value;throw a}}var U7={directory:"isDirectory",file:"isFile"};function FNe(t){if(!Object.hasOwnProperty.call(U7,t))throw new Error(`Invalid type specified: ${t}`)}var BNe=(t,e)=>e[U7[t]](),$Ne=t=>t instanceof URL?UNe(t):t;async function F7(t,{cwd:e=DNe.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:s,preserveOrder:i}={}){FNe(r),e=$Ne(e);let o=n?k7.stat:k7.lstat;return d1(t,async a=>{try{let c=await o(kNe.resolve(e,a));return BNe(r,c)}catch{return!1}},{concurrency:s,preserveOrder:i})}var HNe="sha1",B7=async function(t,e){if(e||t.length===0)return;let r=await F7(t);return r===void 0?void 0:await VNe(r)},VNe=async function(t){let e=qNe(t,"utf8"),r=GNe(HNe,{encoding:"hex"});return e.pipe(r),await Mu(r)};var q7=async function({cachePath:t,move:e,ttl:r,digests:n}){let s=Sv(t),i=L7(r),o=await B7(n,e),c=`${JSON.stringify({expires:i,hash:o},null,2)}
365
- `,l=await KNe({hash:o,manifestPath:s,manifestString:c});return{manifestInfo:{manifestPath:s,manifestString:c},identical:l}},KNe=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!G7(e)?!1:await $7(e,"utf8")===r},H7=async function({manifestPath:t,manifestString:e}){await jNe(YNe(t),{recursive:!0}),await zNe(t,e)},V7=async function(t){let e=Sv(t);await WNe(e,{force:!0,recursive:!0,maxRetries:3})},Sv=function(t){return`${t}${W7}`},j7=function(t){return t.endsWith(W7)},W7=".netlify.cache.json",f1=async function(t){let e=Sv(t);if(!G7(e))return!1;let{expires:r}=await XNe(t);return D7(r)},XNe=async function(t){let e=Sv(t),r=await $7(e,"utf-8");return JSON.parse(r)};import{homedir as tMe}from"os";import{resolve as z7,isAbsolute as rMe,join as nMe,sep as p1}from"path";import{normalize as QNe}from"path";import{existsSync as JNe}from"fs";import ZNe from"process";var h1=function(t){try{let e=eMe(t);return JNe(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},eMe=function(t=ZNe.cwd()){return QNe(t)};var Ng=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await sMe(t,r),s=await cMe({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:s}},sMe=async function(t,e){let r=await h1(e),n=iMe(t,r);return oMe(n,r),n},iMe=function(t,e){if(rMe(t))return z7(t);if(e!=="")return z7(e,t);throw new Error(`Current directory does not exist: ${e}`)},oMe=function(t,e){if(e!==""&&aMe(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},aMe=function(t,e){return`${e}${p1}`.startsWith(`${t}${p1}`)},cMe=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=tl({cacheDir:e,cwd:r}),{name:s,relPath:i}=await lMe(t,r);return nMe(n,s,i)},lMe=async function(t,e){let r=await m1(e),n=uMe(t);return r.map(({name:s,base:i})=>fMe(s,i,n)).find(Boolean)},uMe=function(t){return t.replace(dMe,"\\")},dMe=/^[a-zA-Z]:\\/,fMe=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},m1=async function(t){return[...await hMe(t),{name:"home",base:tMe()},{name:"root",base:p1}]},hMe=async function(t){let e=await h1(t);return e===""?[]:[{name:"cwd",base:e}]};var mMe=1,g1=async function({cacheDir:t,cwd:e,depth:r=mMe}={}){let n=await m1(e),s=tl({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>gMe({name:a,base:c,cacheDir:s,depth:r})))).flat()},gMe=async function({name:t,base:e,cacheDir:r,depth:n}){return(await M7(`${r}/${t}`,{fileFilter:_Me,depth:n,type:"files_directories"})).map(({path:o})=>pMe(e,o))},_Me=function({basename:t}){return!j7(t)};var SMe=async function(t,{move:e=Y7,ttl:r=bMe,digests:n=[],cacheDir:s,cwd:i}={}){let{srcPath:o,cachePath:a}=await Ng({path:t,cacheDir:s,cwdOpt:i});if(!await Og(o))return!1;let{manifestInfo:c,identical:l}=await q7({cachePath:a,move:e,ttl:r,digests:n});return l||(await _1(a,{force:!0,recursive:!0,maxRetries:3}),await a1(o,a,e),await H7(c)),!0},EMe=async function(t,{move:e=Y7,cacheDir:r,cwd:n}={}){let{srcPath:s,cachePath:i}=await Ng({path:t,cacheDir:r,cwdOpt:n});return!await Og(i)||await f1(i)?!1:(await _1(s,{force:!0,recursive:!0,maxRetries:3}),await a1(i,s,e),!0)},yMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Ng({path:t,cacheDir:e,cwdOpt:r});return await Og(n)?(await _1(n,{force:!0,recursive:!0,maxRetries:3}),await V7(n),!0):!1},TMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Ng({path:t,cacheDir:e,cwdOpt:r});return await Og(n)&&!await f1(n)},Y7=!1,bMe=void 0,Ev=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(s=>t(s,...r)))).some(Boolean):t(e,...r)},AMe=Ev.bind(null,SMe),vMe=Ev.bind(null,EMe),wMe=Ev.bind(null,yMe),RMe=Ev.bind(null,TMe),K7=function(t){return{save:(e,r)=>AMe(e,{...t,...r}),restore:(e,r)=>vMe(e,{...t,...r}),remove:(e,r)=>wMe(e,{...t,...r}),has:(e,r)=>RMe(e,{...t,...r}),list:e=>g1({...t,...e}),getCacheDir:e=>tl({...t,...e})}};var Gt=de("native_session"),S1=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Yi.stat(Ki.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),yv=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 Yi.stat(n)).isDirectory()}catch{}if(!i)return Gt.log(`Native session base dir ${n} not found, skipping`),null;let o=await S1(n,s);if(o.length===0)return Gt.log(`No native session history found under ${n}, skipping`),null;let a=Ki.join(X7.tmpdir(),`native-session-${e}.zip`);try{await ar("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await Yi.readFile(a);Gt.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await F3(t,e);return await Xp(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 Yi.rm(a,{force:!0}).catch(()=>{})}},Q7=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await S1(e,r);for(let s of n)if((await Yi.readdir(Ki.join(e,s)).catch(()=>[])).length>0)return!0;return!1},CMe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J7=async(t,e)=>{let r=await Yi.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await J7(Ki.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Z7=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${CMe(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:s}=t,i=await S1(n,s);for(let o of i)if(await J7(Ki.join(n,o),r))return!0;return!1},eZ=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=Ki.join(X7.tmpdir(),`native-session-restore-${e}.zip`);try{let i=await B3(t,e);if(!i?.download_url)return Gt.log("No native session available to restore, skipping"),!1;let o=await W3(i.download_url);return await Yi.writeFile(s,o),Gt.log(`Downloaded native session (${o.length} bytes) to ${s}`),await Yi.mkdir(n,{recursive:!0}),await ar("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 Yi.rm(s,{force:!0}).catch(()=>{})}},xMe="native-sessions",tZ=(t,e)=>K7({cacheDir:Ki.join(e.dir,xMe),cwd:t}),rZ=async({archive:t,cache:e})=>{if(!e?.enabled||!t)return!1;let{baseDir:r,include:n}=t;try{return await tZ(r,e).restore(n.map(i=>Ki.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}},Tv=async({archive:t,cache:e})=>{if(!e?.enabled||!t)return!1;let{baseDir:r,include:n}=t;try{return await tZ(r,e).save(n.map(i=>Ki.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 bv=de("inference_stage"),nZ=5,cl=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(vi())throw new Error("Shutdown in progress, aborting inference stage");bv.log(`Running inference stage, attempt ${l} of ${nZ}`);let h=!1,p=await Ge(Pe(),"inference-stage",async m=>{m?.setAttributes({"inference.attempt":l||1}),E3();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:A}=await Ge(Pe(),"compose-prompt",async()=>await V5({cliPath:r,config:n,buildErrorContext:OMe(i),netlify:s,additionalContext:e,resumePrompt:S.viable})),w=`
365
+ `,l=await KNe({hash:o,manifestPath:s,manifestString:c});return{manifestInfo:{manifestPath:s,manifestString:c},identical:l}},KNe=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!G7(e)?!1:await $7(e,"utf8")===r},H7=async function({manifestPath:t,manifestString:e}){await jNe(YNe(t),{recursive:!0}),await zNe(t,e)},V7=async function(t){let e=Sv(t);await WNe(e,{force:!0,recursive:!0,maxRetries:3})},Sv=function(t){return`${t}${W7}`},j7=function(t){return t.endsWith(W7)},W7=".netlify.cache.json",f1=async function(t){let e=Sv(t);if(!G7(e))return!1;let{expires:r}=await XNe(t);return D7(r)},XNe=async function(t){let e=Sv(t),r=await $7(e,"utf-8");return JSON.parse(r)};import{homedir as tMe}from"os";import{resolve as z7,isAbsolute as rMe,join as nMe,sep as p1}from"path";import{normalize as QNe}from"path";import{existsSync as JNe}from"fs";import ZNe from"process";var h1=function(t){try{let e=eMe(t);return JNe(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},eMe=function(t=ZNe.cwd()){return QNe(t)};var Ng=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await sMe(t,r),s=await cMe({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:s}},sMe=async function(t,e){let r=await h1(e),n=iMe(t,r);return oMe(n,r),n},iMe=function(t,e){if(rMe(t))return z7(t);if(e!=="")return z7(e,t);throw new Error(`Current directory does not exist: ${e}`)},oMe=function(t,e){if(e!==""&&aMe(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},aMe=function(t,e){return`${e}${p1}`.startsWith(`${t}${p1}`)},cMe=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=tl({cacheDir:e,cwd:r}),{name:s,relPath:i}=await lMe(t,r);return nMe(n,s,i)},lMe=async function(t,e){let r=await m1(e),n=uMe(t);return r.map(({name:s,base:i})=>fMe(s,i,n)).find(Boolean)},uMe=function(t){return t.replace(dMe,"\\")},dMe=/^[a-zA-Z]:\\/,fMe=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},m1=async function(t){return[...await hMe(t),{name:"home",base:tMe()},{name:"root",base:p1}]},hMe=async function(t){let e=await h1(t);return e===""?[]:[{name:"cwd",base:e}]};var mMe=1,g1=async function({cacheDir:t,cwd:e,depth:r=mMe}={}){let n=await m1(e),s=tl({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>gMe({name:a,base:c,cacheDir:s,depth:r})))).flat()},gMe=async function({name:t,base:e,cacheDir:r,depth:n}){return(await M7(`${r}/${t}`,{fileFilter:_Me,depth:n,type:"files_directories"})).map(({path:o})=>pMe(e,o))},_Me=function({basename:t}){return!j7(t)};var SMe=async function(t,{move:e=Y7,ttl:r=bMe,digests:n=[],cacheDir:s,cwd:i}={}){let{srcPath:o,cachePath:a}=await Ng({path:t,cacheDir:s,cwdOpt:i});if(!await Og(o))return!1;let{manifestInfo:c,identical:l}=await q7({cachePath:a,move:e,ttl:r,digests:n});return l||(await _1(a,{force:!0,recursive:!0,maxRetries:3}),await a1(o,a,e),await H7(c)),!0},EMe=async function(t,{move:e=Y7,cacheDir:r,cwd:n}={}){let{srcPath:s,cachePath:i}=await Ng({path:t,cacheDir:r,cwdOpt:n});return!await Og(i)||await f1(i)?!1:(await _1(s,{force:!0,recursive:!0,maxRetries:3}),await a1(i,s,e),!0)},yMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Ng({path:t,cacheDir:e,cwdOpt:r});return await Og(n)?(await _1(n,{force:!0,recursive:!0,maxRetries:3}),await V7(n),!0):!1},TMe=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Ng({path:t,cacheDir:e,cwdOpt:r});return await Og(n)&&!await f1(n)},Y7=!1,bMe=void 0,Ev=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(s=>t(s,...r)))).some(Boolean):t(e,...r)},AMe=Ev.bind(null,SMe),vMe=Ev.bind(null,EMe),wMe=Ev.bind(null,yMe),RMe=Ev.bind(null,TMe),K7=function(t){return{save:(e,r)=>AMe(e,{...t,...r}),restore:(e,r)=>vMe(e,{...t,...r}),remove:(e,r)=>wMe(e,{...t,...r}),has:(e,r)=>RMe(e,{...t,...r}),list:e=>g1({...t,...e}),getCacheDir:e=>tl({...t,...e})}};var Gt=de("native_session"),S1=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Yi.stat(Ki.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),yv=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 Yi.stat(n)).isDirectory()}catch{}if(!i)return Gt.log(`Native session base dir ${n} not found, skipping`),null;let o=await S1(n,s);if(o.length===0)return Gt.log(`No native session history found under ${n}, skipping`),null;let a=Ki.join(X7.tmpdir(),`native-session-${e}.zip`);try{await ar("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await Yi.readFile(a);Gt.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await F3(t,e);return await Xp(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 Yi.rm(a,{force:!0}).catch(()=>{})}},Q7=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await S1(e,r);for(let s of n)if((await Yi.readdir(Ki.join(e,s)).catch(()=>[])).length>0)return!0;return!1},CMe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J7=async(t,e)=>{let r=await Yi.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await J7(Ki.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Z7=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${CMe(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:s}=t,i=await S1(n,s);for(let o of i)if(await J7(Ki.join(n,o),r))return!0;return!1},eZ=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=Ki.join(X7.tmpdir(),`native-session-restore-${e}.zip`);try{let i=await B3(t,e);if(!i?.download_url)return Gt.log("No native session available to restore, skipping"),!1;let o=await W3(i.download_url);return await Yi.writeFile(s,o),Gt.log(`Downloaded native session (${o.length} bytes) to ${s}`),await Yi.mkdir(n,{recursive:!0}),await ar("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 Yi.rm(s,{force:!0}).catch(()=>{})}},xMe="native-sessions",tZ=(t,e)=>K7({cacheDir:Ki.join(e.dir,xMe),cwd:t}),rZ=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await tZ(r,e).restore(n.map(i=>Ki.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}},Tv=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await tZ(r,e).save(n.map(i=>Ki.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 bv=de("inference_stage"),nZ=5,cl=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(vi())throw new Error("Shutdown in progress, aborting inference stage");bv.log(`Running inference stage, attempt ${l} of ${nZ}`);let h=!1,p=await Ge(Pe(),"inference-stage",async m=>{m?.setAttributes({"inference.attempt":l||1}),E3();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:A}=await Ge(Pe(),"compose-prompt",async()=>await V5({cliPath:r,config:n,buildErrorContext:OMe(i),netlify:s,additionalContext:e,resumePrompt:S.viable})),w=`
366
366
  ${u||""}
367
367
  ${A}
368
368
  `.trim(),T={...n,prompt:w},k=d??(S.viable?S.sessionId:void 0),R=await Ge(Pe(),`run-${n.runner}`,async O=>{let I=lO();O?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":A3(n.runner),"gen_ai.system":n.runner,...I?{"gen_ai.input.messages":Yy("user",w)}:{}});let x=Date.now(),M=await o({aiGateway:c,config:T,netlify:s,persistSteps:a,continueSession:E||S.viable,priorAgentSessionId:k,cwd:f}),_=Date.now(),Q=M.resolvedModel||n.model||"unknown",P=M.error?"error":"stop";return O?.setAttributes({...I?{"gen_ai.output.messages":Yy("assistant",M.result??M.error??"",P)}:{},"gen_ai.response.finish_reasons":[P],"gen_ai.request.model":Q,"gen_ai.response.model":Q,...M.effort?{"gen_ai.request.effort":M.effort}:{},...M.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":M.usage.input_tokens}:{},...M.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":M.usage.output_tokens}:{},...M.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":M.usage.cache_creation_input_tokens}:{},...M.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":M.usage.cache_read_input_tokens}:{}}),v3(M.steps??[],n.mode,x,_),M});return R.result&&(R.result=fn(R.result)),R.error&&(R.error=fn(R.error)),await a.flush(),R});if(p.error){if(vi()){let m=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(m,{agentSessionId:p.agentSessionId}),m}if(bv.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<nZ))return bv.log("Retrying inference stage"),await new Promise(E=>setTimeout(E,5e3)),{runnerResult:(await cl({...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(bv.log("Do not retry inference stage"),p.error.toLowerCase().includes("usage exceeded"))throw new Hn(p.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);let m=p.isRetryableError||p.isProviderUnavailableError?new Eu(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}=z5(t);if(!n)return{viable:n,outcome:s};let i=r?.nativeSessionId,o=_f(t.runner),a=async()=>i?t.runner==="gemini"?!!await RM(i):Z7(o,i):!1,c;if(W5(t)&&await Q7(o))c="local";else if(t.fastInit&&jt().warmNativeResumeEnabled&&await rZ({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 eZ({runnerId:t.id,sessionId:t.sessionId,archive:o}))return{viable:!1,outcome:"fetch_failed",source:c}}return t.runner==="gemini"&&i&&!await AA(i)?{viable:!1,outcome:"sanitize_failed",source:c}:{viable:!0,sessionId:i,outcome:"resumed",source:c}},OMe=t=>!t||t.length===0?"":`