@netlify/agent-runner-cli 1.140.1-next.0 → 1.140.1

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:pI},kye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Uye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:kye};import{Buffer as Fye}from"buffer";var N4=(t,e)=>t?void 0:Bye.bind(void 0,e),Bye=function*(t,e){if(typeof e!="string"&&!_t(e)&&!Fye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},M4=(t,e)=>t?$ye.bind(void 0,e):Gye.bind(void 0,e),$ye=function*(t,e){L4(t,e),yield e},Gye=function*(t,e){if(L4(t,e),typeof e!="string"&&!_t(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},L4=(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 qye}from"buffer";import{StringDecoder as Hye}from"string_decoder";var ZT=(t,e,r)=>{if(r)return;if(t)return{transform:Vye.bind(void 0,new TextEncoder)};let n=new Hye(e);return{transform:jye.bind(void 0,n),final:Wye.bind(void 0,n)}},Vye=function*(t,e){qye.isBuffer(e)?yield Ti(e):typeof e=="string"?yield t.encode(e):yield e},jye=function*(t,e){yield _t(e)?t.write(e):e},Wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as D4}from"util";var gI=D4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),eb=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Yye}=e[r];for await(let s of n(t))yield*eb(s,e,r+1)},k4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zye(r,Number(e),t)},zye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*eb(n,r,e+1)},U4=D4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Yye=function*(t){yield t};var _I=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},F4=(t,e)=>[...e.flatMap(r=>[...gc(r,t,0)]),...dm(t)],gc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xye}=e[r];for(let s of n(t))yield*gc(s,e,r+1)},dm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kye(r,Number(e),t)},Kye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*gc(n,r,e+1)},Xye=function*(t){yield t};var SI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=$4(t,o,i),l=mc(e),u=mc(r),d=l?gI.bind(void 0,eb,a):_I.bind(void 0,gc),f=l||u?gI.bind(void 0,k4,a):_I.bind(void 0,dm),h=l||u?U4.bind(void 0,a):void 0;return{stream:new Qye({writableObjectMode:n,writableHighWaterMark:B4(n),readableObjectMode:s,readableHighWaterMark:B4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},tb=(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=$4(o,r,a);t=F4(c,t)}return t},$4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:N4(n,a)},ZT(r,o,n),JT(r,i,n,c),{transform:t,final:e},{transform:M4(s,a)},I4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var G4=(t,e)=>{for(let r of Jye(t))Zye(t,r,e)},Jye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Zye=(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=>eTe(a,n));r.input=tm(o)},eTe=(t,e)=>{let r=tb(t,e,"utf8",!0);return tTe(r),tm(r)},tTe=t=>{let e=t.find(r=>typeof r!="string"&&!_t(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 iTe,appendFileSync as oTe}from"fs";var rb=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cu(r,n)&&!Fr.has(e)&&rTe(n)&&(t.some(({type:s,value:i})=>s==="native"&&nTe.has(i))||t.every(({type:s})=>pn.has(s))),rTe=t=>t===1||t===2,nTe=new Set(["pipe","overlapped"]),q4=async(t,e,r,n)=>{for await(let s of t)sTe(e)||V4(s,r,n)},H4=(t,e,r)=>{for(let n of t)V4(n,e,r)},sTe=t=>t._readableState.pipes.length>0,V4=(t,e,r)=>{let n=gT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var j4=({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)=>aTe({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},aTe=({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=WY(t,i,d),h=Ti(f),{stdioItems:p,objectMode:m}=e[r],E=cTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=lTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uTe({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let v=a[r]?A:void 0;try{return n.error===void 0&&dTe(S,p,s),v}catch(T){return n.error=T,v}},cTe=(t,e,r,n)=>{try{return tb(t,e,r,!1)}catch(s){return n.error=s,t}},lTe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:tm(t)};let o=oW(t,r);return n[i]?{serializedResult:o,finalResult:mI(o,!s[i],e)}:{serializedResult:o}},uTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!rb({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=mI(t,!1,o);try{H4(a,e,n)}catch(c){r.error??=c}},dTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>XT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?oTe(n,t):(r.add(i),iTe(n,t))}};var W4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vi(e,r,"all")]:Array.isArray(e)?[vi(t,r,"all"),...e]:_t(t)&&_t(e)?vO([t,e]):`${t}${e}`};import{once as EI}from"events";var z4=async(t,e)=>{let[r,n]=await fTe(t);return e.isForcefullyTerminated??=!1,[r,n]},fTe=async t=>{let[e,r]=await Promise.allSettled([EI(t,"spawn"),EI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Y4(t):r.value},Y4=async t=>{try{return await EI(t,"exit")}catch{return Y4(t)}},K4=async t=>{let[e,r]=await t;if(!hTe(e,r)&&yI(e,r))throw new jn;return[e,r]},hTe=(t,e)=>t===void 0&&e===void 0,yI=(t,e)=>t!==0||e!==null;var X4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=pTe(t,e,r),o=i?.code==="ETIMEDOUT",a=jY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},pTe=(t,e,r)=>t!==void 0?t:yI(e,r)?new jn:void 0;var Q4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gTe(t,e,r),d=ETe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Uu(d,c,l)},gTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),a=_Te(r),{file:c,commandArguments:l,options:u}=FT(t,e,a);STe(u);let d=C4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},_Te=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,STe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&nb("ipcInput"),t&&nb("ipc: true"),r&&nb("detached: true"),n&&nb("cancelSignal")},nb=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ETe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=yTe({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}=X4(c,r),{output:p,error:m=l}=j4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,v)=>vi(A,r,v)),S=vi(W4(p,r),r,"all");return bTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},yTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{G4(i,r);let a=TTe(r);return mTe(...BT(t,e,a))}catch(a){return ku({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},TTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:WT(e)}),bTe=({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?zT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):um({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 lAe}from"events";import{spawn as uAe}from"child_process";import r6 from"process";import{once as TI,on as ATe}from"events";var J4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Ou({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),vTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),vTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{xT(e,s);let i=No(t,e,r),o=new AbortController;try{return await Promise.race([wTe(i,n,o),RTe(i,r,o),CTe(i,r,o)])}catch(a){throw Iu(t),a}finally{o.abort(),PT(e,s)}},wTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TI(t,"message",{signal:r});return n}for await(let[n]of ATe(t,"message",{signal:r}))if(e(n))return n},RTe=async(t,e,{signal:r})=>{await TI(t,"disconnect",{signal:r}),Fz(e)},CTe=async(t,e,{signal:r})=>{let[n]=await TI(t,"strict:error",{signal:r});throw wT(n,e)};import{once as e6,on as xTe}from"events";var t6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>bI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),bI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Ou({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),xT(e,i);let o=No(t,e,r),a=new AbortController,c={};return PTe(t,o,a),OTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),ITe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},PTe=async(t,e,r)=>{try{await e6(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},OTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await e6(t,"strict:error",{signal:r.signal});n.error=wT(s,e),r.abort()}catch{}},ITe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of xTe(r,"message",{signal:i.signal}))Z4(o),yield c}catch{Z4(o)}finally{i.abort(),PT(e,a),n||Iu(t),s&&await t}},Z4=({error:t})=>{if(t)throw t};var n6=(t,{ipc:e})=>{Object.assign(t,i6(t,!1,e))},s6=()=>{let t=r6,e=!0,r=r6.channel!==void 0;return{...i6(t,e,r),getCancelSignal:dY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},i6=(t,e,r)=>({sendMessage:kT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:J4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:t6.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as NTe}from"child_process";import{PassThrough as MTe,Readable as LTe,Writable as DTe,Duplex as kTe}from"stream";var o6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{fI(n);let a=new NTe;UTe(a,n),Object.assign(a,{readable:FTe,writable:BTe,duplex:$Te});let c=ku({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=GTe(c,o,s);return{subprocess:a,promise:l}},UTe=(t,e)=>{let r=fm(),n=fm(),s=fm(),i=Array.from({length:e.length-3},fm),o=fm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},fm=()=>{let t=new MTe;return t.end(),t},FTe=()=>new LTe({read(){}}),BTe=()=>new DTe({write(){}}),$Te=()=>new kTe({read(){},write(){}}),GTe=async(t,e,r)=>Uu(t,e,r);import{createReadStream as a6,createWriteStream as c6}from"fs";import{Buffer as qTe}from"buffer";import{Readable as hm,Writable as HTe,Duplex as VTe}from"stream";var u6=(t,e)=>QT(jTe,t,e,!1),pm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Mo[t]}.`)},l6={fileNumber:pm,generator:SI,asyncGenerator:SI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:VTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},jTe={input:{...l6,fileUrl:({value:t})=>({stream:a6(t)}),filePath:({value:{file:t}})=>({stream:a6(t)}),webStream:({value:t})=>({stream:hm.fromWeb(t)}),iterable:({value:t})=>({stream:hm.from(t)}),asyncIterable:({value:t})=>({stream:hm.from(t)}),string:({value:t})=>({stream:hm.from(t)}),uint8Array:({value:t})=>({stream:hm.from(qTe.from(t))})},output:{...l6,fileUrl:({value:t})=>({stream:c6(t)}),filePath:({value:{file:t,append:e}})=>({stream:c6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HTe.fromWeb(t)}),iterable:pm,asyncIterable:pm,string:pm,uint8Array:pm}};import{on as WTe,once as d6}from"events";import{PassThrough as zTe,getDefaultHighWaterMark as YTe}from"stream";import{finished as p6}from"stream/promises";function _c(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)vI(s);let e=t.some(({readableObjectMode:s})=>s),r=KTe(t,e),n=new AI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var KTe=(t,e)=>{if(t.length===0)return YTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AI=class extends zTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(vI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=XTe(this,this.#e,this.#i);let r=ZTe({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(vI(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)}},XTe=async(t,e,r)=>{sb(t,f6);let n=new AbortController;try{await Promise.race([QTe(t,n),JTe(t,e,r,n)])}finally{n.abort(),sb(t,-f6)}},QTe=async(t,{signal:e})=>{try{await p6(t,{signal:e,cleanup:!0})}catch(r){throw m6(t,r),r}},JTe=async(t,e,r,{signal:n})=>{for await(let[s]of WTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},vI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ZTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{sb(t,h6);let a=new AbortController;try{await Promise.race([ebe(i,e,a),tbe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),rbe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),sb(t,-h6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?wI(t):nbe(t))},ebe=async(t,e,{signal:r})=>{try{await t,r.aborted||wI(e)}catch(n){r.aborted||m6(e,n)}},tbe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await p6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;g6(o)?s.add(e):_6(t,o)}},rbe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await d6(t,s,{signal:i}),!t.readable)return d6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},nbe=t=>{t.writable&&t.end()},m6=(t,e)=>{g6(e)?wI(t):_6(t,e)},g6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wI=t=>{(t.readable||t.writable)&&t.destroy()},_6=(t,e)=>{t.destroyed||(t.once("error",sbe),t.destroy(e))},sbe=()=>{},sb=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},f6=2,h6=1;import{finished as S6}from"stream/promises";var Bu=(t,e)=>{t.pipe(e),ibe(t,e),obe(t,e)},ibe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RI(e)}},RI=t=>{t.writable&&t.end()},obe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}CI(t)}},CI=t=>{t.readable&&t.destroy()};var E6=(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})=>pn.has(c)))abe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!pn.has(c)))lbe({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]:_c(i);Bu(o,s)}},abe=(t,e,r,n)=>{r==="output"?Bu(t.stdio[n],e):Bu(e,t.stdio[n]);let s=cbe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},cbe=["stdin","stdout","stderr"],lbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;ube(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},ube=(t,{signal:e})=>{Vn(t)&&hc(t,dbe,e)},dbe=2;import{addAbortListener as pbe}from"events";var Sc=[];Sc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Sc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Sc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ib=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",xI=Symbol.for("signal-exit emitter"),PI=globalThis,fbe=Object.defineProperty.bind(Object),OI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PI[xI])return PI[xI];fbe(PI,xI,{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}},ob=class{},hbe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),II=class extends ob{onExit(){return()=>{}}load(){}unload(){}},NI=class extends ob{#e=MI.platform==="win32"?"SIGINT":"SIGHUP";#r=new OI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of Sc)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(!ib(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 Sc)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,Sc.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 ib(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"&&ib(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)}},MI=globalThis.process,{onExit:y6,load:RJe,unload:CJe}=hbe(ib(MI)?new NI(MI):new II);var T6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=y6(()=>{t.kill()});pbe(n,()=>{s()})};var A6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=_T(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mbe(r,n,s),{sourceStream:d,sourceError:f}=_be(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}},mbe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=gbe(t,e,...r),a=CT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},gbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(b6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||bO(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]=aT(r,...n);return{destination:e(b6)(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}`)},b6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_be=(t,e)=>{try{return{sourceStream:Nu(t,e)}}catch(r){return{sourceError:r}}};var w6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Sbe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw LI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Sbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return CI(t),n;if(e!==void 0)return RI(r),e},LI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>ku({error:t,command:v6,escapedCommand:v6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),v6="source.pipe(destination)";var R6=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 Ebe}from"stream/promises";var C6=(t,e,r)=>{let n=ab.has(e)?Tbe(t,e):ybe(t,e);return hc(t,Abe,r.signal),hc(e,vbe,r.signal),bbe(e),n},ybe=(t,e)=>{let r=_c([t]);return Bu(r,e),ab.set(e,r),r},Tbe=(t,e)=>{let r=ab.get(e);return r.add(t),r},bbe=async t=>{try{await Ebe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ab.delete(t)},ab=new WeakMap,Abe=2,vbe=1;import{aborted as wbe}from"util";var x6=(t,e)=>t===void 0?[]:[Rbe(t,e)],Rbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await wbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw LI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var cb=(t,...e)=>{if(ot(e[0]))return cb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=A6(t,...e),s=Cbe({...n,destination:r});return s.pipe=cb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Cbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=xbe(t,s);w6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=C6(e,i,d);return await Promise.race([R6(u),...x6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},xbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Dbe}from"timers/promises";import{on as Pbe}from"events";import{getDefaultHighWaterMark as Obe}from"stream";var lb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Ibe(e,o),O6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Ibe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},DI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Nbe(e,o,t);let a=t.readableObjectMode&&!i;return O6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Nbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},O6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Pbe(t,"data",{signal:e.signal,highWaterMark:P6,highWatermark:P6});return Mbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},kI=Obe(!0),P6=kI,Mbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Lbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*gc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*dm(a)}},Lbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[ZT(t,r,!e),JT(t,s,!n,{})].filter(Boolean);var I6=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=kbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Ube(t),d]);return}let f=hI(c,r),h=DI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([Fbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},kbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!rb({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=DI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await q4(a,t,r,i)},Ube=async t=>{await Dbe(),t.readableFlowing===null&&t.resume()},Fbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await HT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await VT(r,{maxBuffer:i})):await Du(r,{maxBuffer:i})}catch(a){return N6(qY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},UI=async t=>{try{return await t}catch(e){return N6(e)}},N6=({bufferedData:t})=>sW(t)?new Uint8Array(t):t;import{finished as Bbe}from"stream/promises";var mm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=$be(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Bbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Hbe(a,e,r,n)}finally{o.abort()}},$be=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Gbe(t,r,n),n},Gbe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{qbe(e,r),n.call(t,...s)}},qbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Hbe=(t,e,r,n)=>{if(!Vbe(t,e,r,n))throw t},Vbe=(t,e,r,n=!0)=>r.propagating?M6(t)||ub(t):(r.propagating=!0,FI(r,e)===n?M6(t):ub(t)),FI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ub=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",M6=t=>t?.code==="EPIPE";var L6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>BI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),BI=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=mm(t,e,l);if(FI(l,e)){await u;return}let[d]=await Promise.all([I6({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 D6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?_c([t,e].filter(Boolean)):void 0,k6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>BI({...jbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Wbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),jbe=({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}},Wbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as zbe}from"events";var U6=t=>Cu(t,"ipc"),F6=(t,e)=>{let r=gT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var B6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=U6(i),a=bi(e,"ipc"),c=bi(r,"ipc");for await(let l of bI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(HY(t,s,c),s.push(l)),o&&F6(l,i);return s},$6=async(t,e)=>(await Promise.allSettled([t]),e);var G6=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=z4(t,f),v={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=L6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),k=k6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),x=[],N=B6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),P=Ybe(m,t,v),C=Kbe(p,v);try{return await Promise.race([Promise.all([{},K4(A),Promise.all(T),k,N,TY(t,d),...P,...C]),E,Xbe(t,S),...gY(t,i,f,S),...Uz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...pY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},A,Promise.all(T.map(_=>UI(_))),UI(k),$6(N,x),Promise.allSettled(P),Promise.allSettled(C)])}},Ybe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:mm(n,s,r)),Kbe=(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})=>mm(o,n,e,{isSameDirection:pn.has(s),stopOnExit:s==="native"}))),Xbe=async(t,{signal:e})=>{let[r]=await zbe(t,"error",{signal:e});throw r};var q6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),gm=(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}},$u=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 Qbe}from"stream";import{callbackify as Jbe}from"util";import{finished as H6}from"stream/promises";var $I=async t=>{if(t!==void 0)try{await GI(t)}catch{}},V6=async t=>{if(t!==void 0)try{await qI(t)}catch{}},GI=async t=>{await H6(t,{cleanup:!0,readable:!1,writable:!0})},qI=async t=>{await H6(t,{cleanup:!0,readable:!0,writable:!1})},db=async(t,e)=>{if(await t,e)throw e},fb=(t,e,r)=>{r&&!ub(r)?t.destroy(r):e&&t.destroy()};var j6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Fr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=HI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=VI(a,o),{read:f,onStdoutDataDone:h}=jI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Qbe({read:f,destroy:Jbe(zI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},HI=(t,e,r)=>{let n=Nu(t,e),s=gm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},VI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:kI},jI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=xs(),o=lb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Zbe(this,o,i)},onStdoutDataDone:i}},Zbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},WI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await qI(t),await n,await $I(s),await e,r.readable&&r.push(null)}catch(i){await $I(s),W6(r,i)}},zI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $u(r,e)&&(W6(t,n),await db(e,n))},W6=(t,e)=>{fb(t,t.readable,e)};import{Writable as eAe}from"stream";import{callbackify as z6}from"util";var Y6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=YI(t,r,e),o=new eAe({...KI(n,t,s),destroy:z6(QI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return XI(n,o),o},YI=(t,e,r)=>{let n=CT(t,e),s=gm(r,n,"writableFinal"),i=gm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},KI=(t,e,r)=>({write:tAe.bind(void 0,t),final:z6(rAe.bind(void 0,t,e,r))}),tAe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAe=async(t,e,r)=>{await $u(r,e)&&(t.writable&&t.end(),await e)},XI=async(t,e,r)=>{try{await GI(t),e.writable&&e.end()}catch(n){await V6(r),K6(e,n)}},QI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await $u(r,e),await $u(n,e)&&(K6(t,s),await db(e,s))},K6=(t,e)=>{fb(t,t.writable,e)};import{Duplex as nAe}from"stream";import{callbackify as sAe}from"util";var X6=({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}=HI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=YI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=VI(c,a),{read:E,onStdoutDataDone:S}=jI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),A=new nAe({read:E,...KI(u,t,d),destroy:sAe(iAe.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 WI({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),XI(u,A,c),A},iAe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([zI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),QI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var JI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Fr.has(e),o=Nu(t,r),a=lb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return oAe(a,o,t)},oAe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Q6=(t,{encoding:e})=>{let r=q6();t.readable=j6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Y6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=X6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=JI.bind(void 0,t,e),t[Symbol.asyncIterator]=JI.bind(void 0,t,e,{})};var J6=(t,e)=>{for(let[r,n]of cAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},aAe=(async()=>{})().constructor.prototype,cAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAe,t)]);var Z6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAe(t,e,r),{subprocess:f,promise:h}=hAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=cb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),J6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},dAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),{file:a,commandArguments:c,options:l}=FT(t,e,r),u=fAe(l),d=u6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},fAe=({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}},hAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAe(...BT(t,e,r))}catch(p){return o6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;lAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];E6(c,a,l),T6(c,r,l);let d={},f=xs();c.kill=Dz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=D6(c,r),Q6(c,r),n6(c,r);let h=pAe({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}},pAe=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 G6({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)=>vi(T,e,k)),A=vi(m,e,"all"),v=mAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Uu(v,n,e)},mAe=({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?um({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}):zT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var hb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,gAe(n,t[n],s)]));return{...t,...r}},gAe=(t,e,r)=>_Ae.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,_Ae=new Set(["env",...xO]);var Lo=(t,e,r,n)=>{let s=(o,a,c)=>Lo(o,a,r,c),i=(...o)=>SAe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},SAe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,hb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=EAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?Q4(a,c,l):Z6(a,c,l,s)},EAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=uW(e)?dW(e,r):[e,...r],[o,a,c]=aT(...i),l=hb(hb(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 e8=({file:t,commandArguments:e})=>r8(t,e),t8=({file:t,commandArguments:e})=>({...r8(t,e),isSync:!0}),r8=(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]=yAe(t);return{file:r,commandArguments:n}},yAe=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(TAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},TAe=/ +/g;var n8=(t,e,r)=>{t.sync=e(bAe,r),t.s=t.sync},s8=({options:t})=>i8(t),bAe=({options:t})=>({...i8(t),isSync:!0}),i8=t=>({options:{...AAe(t),...t}}),AAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},o8={preferLocal:!0};var a8=Lo(()=>({})),_et=Lo(()=>({isSync:!0})),c8=Lo(e8),Eet=Lo(t8),yet=Lo(SY),Tet=Lo(s8,{},o8,n8),{sendMessage:bet,getOneMessage:Aet,getEachMessage:vet,getCancelSignal:wet}=s6();var vAe=!1;var Ns=()=>vAe;var _m=null,l8=t=>(_m&&_m.destroy(),_m=new wi({totalAllowedTime:t}),_m),u8=()=>_m;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&&Ns())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 tT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ee.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 d8={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.1-next.0",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 xAe=RAe(import.meta.url),PAe=Ri.dirname(xAe),OAe=CAe(import.meta.url),Gu=me("shell"),ZI=new Set,f8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=IAe(e,r),i={...f8,...s},o=a8(t,n,i);p8(o,i),_8(o);let a=r?.idleTimeout;return a&&a>0&&g8(o,a),o},h8=(t,e)=>{let r={...f8,...e},n=c8(t,r);return p8(n,r),_8(n),e?.idleTimeout&&e.idleTimeout>0&&g8(n,e.idleTimeout),n},IAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},p8=(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 Yp).pipe(Ci.stdout),t.stderr?.pipe(new Yp).pipe(Ci.stderr);return}t.stdout?.pipe(Ci.stdout),t.stderr?.pipe(Ci.stderr)},eN=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ci.kill(-t.pid,e),Gu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Gu.error("Error killing process:",r),!1}},m8=t=>eN(t,"SIGKILL"),g8=(t,e)=>{let r=null,n=()=>{Gu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing idle process ${t.pid}`),m8(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)},_8=t=>{ZI.add(t);let e=u8();if(e){let r=e.onTimesUp(()=>{Gu.log(`Global timer expired, killing process ${t.pid}`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing process ${t.pid} after timeout`),m8(t))},5e3)});t.on("exit",()=>{ZI.delete(t),r()}),t.on("error",()=>{ZI.delete(t),r()})}};function mb(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=OAe.resolve(d8.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(pb.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(pb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(pb.existsSync(r))return r;let n=Ri.join(PAe,"..","node_modules",".bin",e);if(pb.existsSync(n))return n}var NAe=me("utils"),MAe=t=>new Promise(e=>{setTimeout(e,t)});var gb=(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 MAe(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},qu=(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},S8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):NAe.error("Could not parse JSON",n))}},LAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Do=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():LAe(e)).join(" ");function Ec(t,e){e&&t.log(`Skill invoked: ${e}`)}var E8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),y8=(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 tN=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},DAe=1e4,rN=(t,e=DAe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as T8}from"buffer";import kAe from"path";var b8=me("repo"),yr=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),v8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{b8.info("Getting runner diffs");let n=await FAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=$Ae(i);await GAe(m,r)}b8.info("Changes after processing"),await sN(r);let o=await iN(i,r);if(await nN(o,r),s=await BAe(r),!s)return{hasChanges:!1,ignored:o};await yr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await yr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await A8(r),{hasChanges:!1,ignored:o};let u=await yr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await yr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await yr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=T8.from(S).toString("base64"))}await A8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=T8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},A8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await yr(["reset","--soft","HEAD~1"],{cwd:t})},nN=async(t=[],e=process.cwd())=>{await yr(["add",".",...t],{cwd:e})},sN=async(t=process.cwd())=>{let e=await yr(["status","-s"],{cwd:t});return String(e.stdout??"")},w8=/.. (.+)?\.log$/,UAe=[w8],FAe=async(t=process.cwd())=>{let e=await sN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
89
+ if (condition) { yield value; }`)};import{Buffer as qye}from"buffer";import{StringDecoder as Hye}from"string_decoder";var ZT=(t,e,r)=>{if(r)return;if(t)return{transform:Vye.bind(void 0,new TextEncoder)};let n=new Hye(e);return{transform:jye.bind(void 0,n),final:Wye.bind(void 0,n)}},Vye=function*(t,e){qye.isBuffer(e)?yield Ti(e):typeof e=="string"?yield t.encode(e):yield e},jye=function*(t,e){yield _t(e)?t.write(e):e},Wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as D4}from"util";var gI=D4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),eb=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Yye}=e[r];for await(let s of n(t))yield*eb(s,e,r+1)},k4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zye(r,Number(e),t)},zye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*eb(n,r,e+1)},U4=D4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Yye=function*(t){yield t};var _I=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},F4=(t,e)=>[...e.flatMap(r=>[...gc(r,t,0)]),...dm(t)],gc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xye}=e[r];for(let s of n(t))yield*gc(s,e,r+1)},dm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kye(r,Number(e),t)},Kye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*gc(n,r,e+1)},Xye=function*(t){yield t};var SI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=$4(t,o,i),l=mc(e),u=mc(r),d=l?gI.bind(void 0,eb,a):_I.bind(void 0,gc),f=l||u?gI.bind(void 0,k4,a):_I.bind(void 0,dm),h=l||u?U4.bind(void 0,a):void 0;return{stream:new Qye({writableObjectMode:n,writableHighWaterMark:B4(n),readableObjectMode:s,readableHighWaterMark:B4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},tb=(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=$4(o,r,a);t=F4(c,t)}return t},$4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:N4(n,a)},ZT(r,o,n),JT(r,i,n,c),{transform:t,final:e},{transform:M4(s,a)},I4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var G4=(t,e)=>{for(let r of Jye(t))Zye(t,r,e)},Jye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Zye=(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=>eTe(a,n));r.input=tm(o)},eTe=(t,e)=>{let r=tb(t,e,"utf8",!0);return tTe(r),tm(r)},tTe=t=>{let e=t.find(r=>typeof r!="string"&&!_t(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 iTe,appendFileSync as oTe}from"fs";var rb=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cu(r,n)&&!Fr.has(e)&&rTe(n)&&(t.some(({type:s,value:i})=>s==="native"&&nTe.has(i))||t.every(({type:s})=>pn.has(s))),rTe=t=>t===1||t===2,nTe=new Set(["pipe","overlapped"]),q4=async(t,e,r,n)=>{for await(let s of t)sTe(e)||V4(s,r,n)},H4=(t,e,r)=>{for(let n of t)V4(n,e,r)},sTe=t=>t._readableState.pipes.length>0,V4=(t,e,r)=>{let n=gT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var j4=({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)=>aTe({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},aTe=({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=WY(t,i,d),h=Ti(f),{stdioItems:p,objectMode:m}=e[r],E=cTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=lTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uTe({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let v=a[r]?A:void 0;try{return n.error===void 0&&dTe(S,p,s),v}catch(T){return n.error=T,v}},cTe=(t,e,r,n)=>{try{return tb(t,e,r,!1)}catch(s){return n.error=s,t}},lTe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:tm(t)};let o=oW(t,r);return n[i]?{serializedResult:o,finalResult:mI(o,!s[i],e)}:{serializedResult:o}},uTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!rb({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=mI(t,!1,o);try{H4(a,e,n)}catch(c){r.error??=c}},dTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>XT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?oTe(n,t):(r.add(i),iTe(n,t))}};var W4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vi(e,r,"all")]:Array.isArray(e)?[vi(t,r,"all"),...e]:_t(t)&&_t(e)?vO([t,e]):`${t}${e}`};import{once as EI}from"events";var z4=async(t,e)=>{let[r,n]=await fTe(t);return e.isForcefullyTerminated??=!1,[r,n]},fTe=async t=>{let[e,r]=await Promise.allSettled([EI(t,"spawn"),EI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Y4(t):r.value},Y4=async t=>{try{return await EI(t,"exit")}catch{return Y4(t)}},K4=async t=>{let[e,r]=await t;if(!hTe(e,r)&&yI(e,r))throw new jn;return[e,r]},hTe=(t,e)=>t===void 0&&e===void 0,yI=(t,e)=>t!==0||e!==null;var X4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=pTe(t,e,r),o=i?.code==="ETIMEDOUT",a=jY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},pTe=(t,e,r)=>t!==void 0?t:yI(e,r)?new jn:void 0;var Q4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gTe(t,e,r),d=ETe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Uu(d,c,l)},gTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),a=_Te(r),{file:c,commandArguments:l,options:u}=FT(t,e,a);STe(u);let d=C4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},_Te=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,STe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&nb("ipcInput"),t&&nb("ipc: true"),r&&nb("detached: true"),n&&nb("cancelSignal")},nb=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ETe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=yTe({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}=X4(c,r),{output:p,error:m=l}=j4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,v)=>vi(A,r,v)),S=vi(W4(p,r),r,"all");return bTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},yTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{G4(i,r);let a=TTe(r);return mTe(...BT(t,e,a))}catch(a){return ku({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},TTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:WT(e)}),bTe=({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?zT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):um({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 lAe}from"events";import{spawn as uAe}from"child_process";import r6 from"process";import{once as TI,on as ATe}from"events";var J4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Ou({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),vTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),vTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{xT(e,s);let i=No(t,e,r),o=new AbortController;try{return await Promise.race([wTe(i,n,o),RTe(i,r,o),CTe(i,r,o)])}catch(a){throw Iu(t),a}finally{o.abort(),PT(e,s)}},wTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TI(t,"message",{signal:r});return n}for await(let[n]of ATe(t,"message",{signal:r}))if(e(n))return n},RTe=async(t,e,{signal:r})=>{await TI(t,"disconnect",{signal:r}),Fz(e)},CTe=async(t,e,{signal:r})=>{let[n]=await TI(t,"strict:error",{signal:r});throw wT(n,e)};import{once as e6,on as xTe}from"events";var t6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>bI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),bI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Ou({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),xT(e,i);let o=No(t,e,r),a=new AbortController,c={};return PTe(t,o,a),OTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),ITe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},PTe=async(t,e,r)=>{try{await e6(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},OTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await e6(t,"strict:error",{signal:r.signal});n.error=wT(s,e),r.abort()}catch{}},ITe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of xTe(r,"message",{signal:i.signal}))Z4(o),yield c}catch{Z4(o)}finally{i.abort(),PT(e,a),n||Iu(t),s&&await t}},Z4=({error:t})=>{if(t)throw t};var n6=(t,{ipc:e})=>{Object.assign(t,i6(t,!1,e))},s6=()=>{let t=r6,e=!0,r=r6.channel!==void 0;return{...i6(t,e,r),getCancelSignal:dY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},i6=(t,e,r)=>({sendMessage:kT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:J4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:t6.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as NTe}from"child_process";import{PassThrough as MTe,Readable as LTe,Writable as DTe,Duplex as kTe}from"stream";var o6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{fI(n);let a=new NTe;UTe(a,n),Object.assign(a,{readable:FTe,writable:BTe,duplex:$Te});let c=ku({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=GTe(c,o,s);return{subprocess:a,promise:l}},UTe=(t,e)=>{let r=fm(),n=fm(),s=fm(),i=Array.from({length:e.length-3},fm),o=fm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},fm=()=>{let t=new MTe;return t.end(),t},FTe=()=>new LTe({read(){}}),BTe=()=>new DTe({write(){}}),$Te=()=>new kTe({read(){},write(){}}),GTe=async(t,e,r)=>Uu(t,e,r);import{createReadStream as a6,createWriteStream as c6}from"fs";import{Buffer as qTe}from"buffer";import{Readable as hm,Writable as HTe,Duplex as VTe}from"stream";var u6=(t,e)=>QT(jTe,t,e,!1),pm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Mo[t]}.`)},l6={fileNumber:pm,generator:SI,asyncGenerator:SI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:VTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},jTe={input:{...l6,fileUrl:({value:t})=>({stream:a6(t)}),filePath:({value:{file:t}})=>({stream:a6(t)}),webStream:({value:t})=>({stream:hm.fromWeb(t)}),iterable:({value:t})=>({stream:hm.from(t)}),asyncIterable:({value:t})=>({stream:hm.from(t)}),string:({value:t})=>({stream:hm.from(t)}),uint8Array:({value:t})=>({stream:hm.from(qTe.from(t))})},output:{...l6,fileUrl:({value:t})=>({stream:c6(t)}),filePath:({value:{file:t,append:e}})=>({stream:c6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HTe.fromWeb(t)}),iterable:pm,asyncIterable:pm,string:pm,uint8Array:pm}};import{on as WTe,once as d6}from"events";import{PassThrough as zTe,getDefaultHighWaterMark as YTe}from"stream";import{finished as p6}from"stream/promises";function _c(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)vI(s);let e=t.some(({readableObjectMode:s})=>s),r=KTe(t,e),n=new AI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var KTe=(t,e)=>{if(t.length===0)return YTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AI=class extends zTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(vI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=XTe(this,this.#e,this.#i);let r=ZTe({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(vI(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)}},XTe=async(t,e,r)=>{sb(t,f6);let n=new AbortController;try{await Promise.race([QTe(t,n),JTe(t,e,r,n)])}finally{n.abort(),sb(t,-f6)}},QTe=async(t,{signal:e})=>{try{await p6(t,{signal:e,cleanup:!0})}catch(r){throw m6(t,r),r}},JTe=async(t,e,r,{signal:n})=>{for await(let[s]of WTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},vI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ZTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{sb(t,h6);let a=new AbortController;try{await Promise.race([ebe(i,e,a),tbe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),rbe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),sb(t,-h6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?wI(t):nbe(t))},ebe=async(t,e,{signal:r})=>{try{await t,r.aborted||wI(e)}catch(n){r.aborted||m6(e,n)}},tbe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await p6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;g6(o)?s.add(e):_6(t,o)}},rbe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await d6(t,s,{signal:i}),!t.readable)return d6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},nbe=t=>{t.writable&&t.end()},m6=(t,e)=>{g6(e)?wI(t):_6(t,e)},g6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wI=t=>{(t.readable||t.writable)&&t.destroy()},_6=(t,e)=>{t.destroyed||(t.once("error",sbe),t.destroy(e))},sbe=()=>{},sb=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},f6=2,h6=1;import{finished as S6}from"stream/promises";var Bu=(t,e)=>{t.pipe(e),ibe(t,e),obe(t,e)},ibe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RI(e)}},RI=t=>{t.writable&&t.end()},obe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}CI(t)}},CI=t=>{t.readable&&t.destroy()};var E6=(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})=>pn.has(c)))abe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!pn.has(c)))lbe({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]:_c(i);Bu(o,s)}},abe=(t,e,r,n)=>{r==="output"?Bu(t.stdio[n],e):Bu(e,t.stdio[n]);let s=cbe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},cbe=["stdin","stdout","stderr"],lbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;ube(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},ube=(t,{signal:e})=>{Vn(t)&&hc(t,dbe,e)},dbe=2;import{addAbortListener as pbe}from"events";var Sc=[];Sc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Sc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Sc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ib=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",xI=Symbol.for("signal-exit emitter"),PI=globalThis,fbe=Object.defineProperty.bind(Object),OI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PI[xI])return PI[xI];fbe(PI,xI,{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}},ob=class{},hbe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),II=class extends ob{onExit(){return()=>{}}load(){}unload(){}},NI=class extends ob{#e=MI.platform==="win32"?"SIGINT":"SIGHUP";#r=new OI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of Sc)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(!ib(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 Sc)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,Sc.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 ib(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"&&ib(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)}},MI=globalThis.process,{onExit:y6,load:RJe,unload:CJe}=hbe(ib(MI)?new NI(MI):new II);var T6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=y6(()=>{t.kill()});pbe(n,()=>{s()})};var A6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=_T(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mbe(r,n,s),{sourceStream:d,sourceError:f}=_be(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}},mbe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=gbe(t,e,...r),a=CT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},gbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(b6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||bO(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]=aT(r,...n);return{destination:e(b6)(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}`)},b6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_be=(t,e)=>{try{return{sourceStream:Nu(t,e)}}catch(r){return{sourceError:r}}};var w6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Sbe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw LI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Sbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return CI(t),n;if(e!==void 0)return RI(r),e},LI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>ku({error:t,command:v6,escapedCommand:v6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),v6="source.pipe(destination)";var R6=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 Ebe}from"stream/promises";var C6=(t,e,r)=>{let n=ab.has(e)?Tbe(t,e):ybe(t,e);return hc(t,Abe,r.signal),hc(e,vbe,r.signal),bbe(e),n},ybe=(t,e)=>{let r=_c([t]);return Bu(r,e),ab.set(e,r),r},Tbe=(t,e)=>{let r=ab.get(e);return r.add(t),r},bbe=async t=>{try{await Ebe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ab.delete(t)},ab=new WeakMap,Abe=2,vbe=1;import{aborted as wbe}from"util";var x6=(t,e)=>t===void 0?[]:[Rbe(t,e)],Rbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await wbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw LI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var cb=(t,...e)=>{if(ot(e[0]))return cb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=A6(t,...e),s=Cbe({...n,destination:r});return s.pipe=cb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Cbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=xbe(t,s);w6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=C6(e,i,d);return await Promise.race([R6(u),...x6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},xbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Dbe}from"timers/promises";import{on as Pbe}from"events";import{getDefaultHighWaterMark as Obe}from"stream";var lb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Ibe(e,o),O6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Ibe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},DI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Nbe(e,o,t);let a=t.readableObjectMode&&!i;return O6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Nbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},O6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Pbe(t,"data",{signal:e.signal,highWaterMark:P6,highWatermark:P6});return Mbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},kI=Obe(!0),P6=kI,Mbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Lbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*gc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*dm(a)}},Lbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[ZT(t,r,!e),JT(t,s,!n,{})].filter(Boolean);var I6=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=kbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Ube(t),d]);return}let f=hI(c,r),h=DI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([Fbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},kbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!rb({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=DI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await q4(a,t,r,i)},Ube=async t=>{await Dbe(),t.readableFlowing===null&&t.resume()},Fbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await HT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await VT(r,{maxBuffer:i})):await Du(r,{maxBuffer:i})}catch(a){return N6(qY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},UI=async t=>{try{return await t}catch(e){return N6(e)}},N6=({bufferedData:t})=>sW(t)?new Uint8Array(t):t;import{finished as Bbe}from"stream/promises";var mm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=$be(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Bbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Hbe(a,e,r,n)}finally{o.abort()}},$be=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Gbe(t,r,n),n},Gbe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{qbe(e,r),n.call(t,...s)}},qbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Hbe=(t,e,r,n)=>{if(!Vbe(t,e,r,n))throw t},Vbe=(t,e,r,n=!0)=>r.propagating?M6(t)||ub(t):(r.propagating=!0,FI(r,e)===n?M6(t):ub(t)),FI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ub=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",M6=t=>t?.code==="EPIPE";var L6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>BI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),BI=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=mm(t,e,l);if(FI(l,e)){await u;return}let[d]=await Promise.all([I6({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 D6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?_c([t,e].filter(Boolean)):void 0,k6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>BI({...jbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Wbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),jbe=({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}},Wbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as zbe}from"events";var U6=t=>Cu(t,"ipc"),F6=(t,e)=>{let r=gT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var B6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=U6(i),a=bi(e,"ipc"),c=bi(r,"ipc");for await(let l of bI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(HY(t,s,c),s.push(l)),o&&F6(l,i);return s},$6=async(t,e)=>(await Promise.allSettled([t]),e);var G6=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=z4(t,f),v={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=L6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),k=k6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),x=[],N=B6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),P=Ybe(m,t,v),C=Kbe(p,v);try{return await Promise.race([Promise.all([{},K4(A),Promise.all(T),k,N,TY(t,d),...P,...C]),E,Xbe(t,S),...gY(t,i,f,S),...Uz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...pY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},A,Promise.all(T.map(_=>UI(_))),UI(k),$6(N,x),Promise.allSettled(P),Promise.allSettled(C)])}},Ybe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:mm(n,s,r)),Kbe=(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})=>mm(o,n,e,{isSameDirection:pn.has(s),stopOnExit:s==="native"}))),Xbe=async(t,{signal:e})=>{let[r]=await zbe(t,"error",{signal:e});throw r};var q6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),gm=(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}},$u=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 Qbe}from"stream";import{callbackify as Jbe}from"util";import{finished as H6}from"stream/promises";var $I=async t=>{if(t!==void 0)try{await GI(t)}catch{}},V6=async t=>{if(t!==void 0)try{await qI(t)}catch{}},GI=async t=>{await H6(t,{cleanup:!0,readable:!1,writable:!0})},qI=async t=>{await H6(t,{cleanup:!0,readable:!0,writable:!1})},db=async(t,e)=>{if(await t,e)throw e},fb=(t,e,r)=>{r&&!ub(r)?t.destroy(r):e&&t.destroy()};var j6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Fr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=HI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=VI(a,o),{read:f,onStdoutDataDone:h}=jI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Qbe({read:f,destroy:Jbe(zI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},HI=(t,e,r)=>{let n=Nu(t,e),s=gm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},VI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:kI},jI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=xs(),o=lb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Zbe(this,o,i)},onStdoutDataDone:i}},Zbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},WI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await qI(t),await n,await $I(s),await e,r.readable&&r.push(null)}catch(i){await $I(s),W6(r,i)}},zI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $u(r,e)&&(W6(t,n),await db(e,n))},W6=(t,e)=>{fb(t,t.readable,e)};import{Writable as eAe}from"stream";import{callbackify as z6}from"util";var Y6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=YI(t,r,e),o=new eAe({...KI(n,t,s),destroy:z6(QI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return XI(n,o),o},YI=(t,e,r)=>{let n=CT(t,e),s=gm(r,n,"writableFinal"),i=gm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},KI=(t,e,r)=>({write:tAe.bind(void 0,t),final:z6(rAe.bind(void 0,t,e,r))}),tAe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAe=async(t,e,r)=>{await $u(r,e)&&(t.writable&&t.end(),await e)},XI=async(t,e,r)=>{try{await GI(t),e.writable&&e.end()}catch(n){await V6(r),K6(e,n)}},QI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await $u(r,e),await $u(n,e)&&(K6(t,s),await db(e,s))},K6=(t,e)=>{fb(t,t.writable,e)};import{Duplex as nAe}from"stream";import{callbackify as sAe}from"util";var X6=({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}=HI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=YI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=VI(c,a),{read:E,onStdoutDataDone:S}=jI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),A=new nAe({read:E,...KI(u,t,d),destroy:sAe(iAe.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 WI({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),XI(u,A,c),A},iAe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([zI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),QI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var JI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Fr.has(e),o=Nu(t,r),a=lb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return oAe(a,o,t)},oAe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Q6=(t,{encoding:e})=>{let r=q6();t.readable=j6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Y6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=X6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=JI.bind(void 0,t,e),t[Symbol.asyncIterator]=JI.bind(void 0,t,e,{})};var J6=(t,e)=>{for(let[r,n]of cAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},aAe=(async()=>{})().constructor.prototype,cAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAe,t)]);var Z6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAe(t,e,r),{subprocess:f,promise:h}=hAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=cb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),J6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},dAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),{file:a,commandArguments:c,options:l}=FT(t,e,r),u=fAe(l),d=u6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},fAe=({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}},hAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAe(...BT(t,e,r))}catch(p){return o6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;lAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];E6(c,a,l),T6(c,r,l);let d={},f=xs();c.kill=Dz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=D6(c,r),Q6(c,r),n6(c,r);let h=pAe({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}},pAe=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 G6({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)=>vi(T,e,k)),A=vi(m,e,"all"),v=mAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Uu(v,n,e)},mAe=({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?um({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}):zT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var hb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,gAe(n,t[n],s)]));return{...t,...r}},gAe=(t,e,r)=>_Ae.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,_Ae=new Set(["env",...xO]);var Lo=(t,e,r,n)=>{let s=(o,a,c)=>Lo(o,a,r,c),i=(...o)=>SAe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},SAe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,hb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=EAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?Q4(a,c,l):Z6(a,c,l,s)},EAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=uW(e)?dW(e,r):[e,...r],[o,a,c]=aT(...i),l=hb(hb(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 e8=({file:t,commandArguments:e})=>r8(t,e),t8=({file:t,commandArguments:e})=>({...r8(t,e),isSync:!0}),r8=(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]=yAe(t);return{file:r,commandArguments:n}},yAe=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(TAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},TAe=/ +/g;var n8=(t,e,r)=>{t.sync=e(bAe,r),t.s=t.sync},s8=({options:t})=>i8(t),bAe=({options:t})=>({...i8(t),isSync:!0}),i8=t=>({options:{...AAe(t),...t}}),AAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},o8={preferLocal:!0};var a8=Lo(()=>({})),_et=Lo(()=>({isSync:!0})),c8=Lo(e8),Eet=Lo(t8),yet=Lo(SY),Tet=Lo(s8,{},o8,n8),{sendMessage:bet,getOneMessage:Aet,getEachMessage:vet,getCancelSignal:wet}=s6();var vAe=!1;var Ns=()=>vAe;var _m=null,l8=t=>(_m&&_m.destroy(),_m=new wi({totalAllowedTime:t}),_m),u8=()=>_m;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&&Ns())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 tT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ee.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 d8={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.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 xAe=RAe(import.meta.url),PAe=Ri.dirname(xAe),OAe=CAe(import.meta.url),Gu=me("shell"),ZI=new Set,f8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=IAe(e,r),i={...f8,...s},o=a8(t,n,i);p8(o,i),_8(o);let a=r?.idleTimeout;return a&&a>0&&g8(o,a),o},h8=(t,e)=>{let r={...f8,...e},n=c8(t,r);return p8(n,r),_8(n),e?.idleTimeout&&e.idleTimeout>0&&g8(n,e.idleTimeout),n},IAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},p8=(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 Yp).pipe(Ci.stdout),t.stderr?.pipe(new Yp).pipe(Ci.stderr);return}t.stdout?.pipe(Ci.stdout),t.stderr?.pipe(Ci.stderr)},eN=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ci.kill(-t.pid,e),Gu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Gu.error("Error killing process:",r),!1}},m8=t=>eN(t,"SIGKILL"),g8=(t,e)=>{let r=null,n=()=>{Gu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing idle process ${t.pid}`),m8(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)},_8=t=>{ZI.add(t);let e=u8();if(e){let r=e.onTimesUp(()=>{Gu.log(`Global timer expired, killing process ${t.pid}`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing process ${t.pid} after timeout`),m8(t))},5e3)});t.on("exit",()=>{ZI.delete(t),r()}),t.on("error",()=>{ZI.delete(t),r()})}};function mb(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=OAe.resolve(d8.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(pb.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(pb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(pb.existsSync(r))return r;let n=Ri.join(PAe,"..","node_modules",".bin",e);if(pb.existsSync(n))return n}var NAe=me("utils"),MAe=t=>new Promise(e=>{setTimeout(e,t)});var gb=(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 MAe(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},qu=(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},S8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):NAe.error("Could not parse JSON",n))}},LAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Do=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():LAe(e)).join(" ");function Ec(t,e){e&&t.log(`Skill invoked: ${e}`)}var E8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),y8=(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 tN=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},DAe=1e4,rN=(t,e=DAe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as T8}from"buffer";import kAe from"path";var b8=me("repo"),yr=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),v8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{b8.info("Getting runner diffs");let n=await FAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=$Ae(i);await GAe(m,r)}b8.info("Changes after processing"),await sN(r);let o=await iN(i,r);if(await nN(o,r),s=await BAe(r),!s)return{hasChanges:!1,ignored:o};await yr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await yr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await A8(r),{hasChanges:!1,ignored:o};let u=await yr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await yr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await yr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=T8.from(S).toString("base64"))}await A8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=T8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},A8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await yr(["reset","--soft","HEAD~1"],{cwd:t})},nN=async(t=[],e=process.cwd())=>{await yr(["add",".",...t],{cwd:e})},sN=async(t=process.cwd())=>{let e=await yr(["status","-s"],{cwd:t});return String(e.stdout??"")},w8=/.. (.+)?\.log$/,UAe=[w8],FAe=async(t=process.cwd())=>{let e=await sN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
90
90
  `).filter(s=>UAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},BAe=async(t=process.cwd())=>{try{return await yr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},Sm=async(t=process.cwd())=>{let{stdout:e}=await yr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},R8=async(t=process.cwd())=>{let{stdout:e}=await yr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},iN=async(t,e=process.cwd())=>{t||=await sN(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}${kAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(w8)?.[1];i&&n.push(`:!${i}.log`)}),n},oN=async(t=process.cwd())=>{await yr(["reset","--hard","HEAD"],{cwd:t})},C8=async(t=process.cwd())=>{let e=await yr(["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))},$Ae=t=>{let e=t.split(`
package/dist/bin.js CHANGED
@@ -501,7 +501,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
501
501
  `,LF:`
502
502
  `,concatBytes:sq},HZe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},VZe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:HZe};import{Buffer as GZe}from"buffer";var Tle=(t,e)=>t?void 0:zZe.bind(void 0,e),zZe=function*(t,e){if(typeof e!="string"&&!cr(e)&&!GZe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},ble=(t,e)=>t?WZe.bind(void 0,e):YZe.bind(void 0,e),WZe=function*(t,e){vle(t,e),yield e},YZe=function*(t,e){if(vle(t,e),typeof e!="string"&&!cr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},vle=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
503
503
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
504
- if (condition) { yield value; }`)};import{Buffer as KZe}from"buffer";import{StringDecoder as JZe}from"string_decoder";var jA=(t,e,r)=>{if(r)return;if(t)return{transform:XZe.bind(void 0,new TextEncoder)};let n=new JZe(e);return{transform:QZe.bind(void 0,n),final:ZZe.bind(void 0,n)}},XZe=function*(t,e){KZe.isBuffer(e)?yield wa(e):typeof e=="string"?yield t.encode(e):yield e},QZe=function*(t,e){yield cr(e)?t.write(e):e},ZZe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as wle}from"util";var oq=wle(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),HA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tet}=e[r];for await(let s of n(t))yield*HA(s,e,r+1)},Rle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eet(r,Number(e),t)},eet=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HA(n,r,e+1)},Ale=wle(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),tet=function*(t){yield t};var aq=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},Cle=(t,e)=>[...e.flatMap(r=>[...Tf(r,t,0)]),...nE(t)],Tf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=net}=e[r];for(let s of n(t))yield*Tf(s,e,r+1)},nE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ret(r,Number(e),t)},ret=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tf(n,r,e+1)},net=function*(t){yield t};var cq=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=Ple(t,o,i),l=Ef(e),u=Ef(r),f=l?oq.bind(void 0,HA,a):aq.bind(void 0,Tf),d=l||u?oq.bind(void 0,Rle,a):aq.bind(void 0,nE),h=l||u?Ale.bind(void 0,a):void 0;return{stream:new set({writableObjectMode:n,writableHighWaterMark:Ole(n),readableObjectMode:s,readableHighWaterMark:Ole(s),transform(m,g,y){f([m,c,0],this,y)},flush(m){d([c],this,m)},destroy:h})}},VA=(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=Ple(o,r,a);t=Cle(c,t)}return t},Ple=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:Tle(n,a)},jA(r,o,n),BA(r,i,n,c),{transform:t,final:e},{transform:ble(s,a)},Ele({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var xle=(t,e)=>{for(let r of iet(t))oet(t,r,e)},iet=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oet=(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 ${ol[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>aet(a,n));r.input=WS(o)},aet=(t,e)=>{let r=VA(t,e,"utf8",!0);return cet(r),WS(r)},cet=t=>{let e=t.find(r=>typeof r!="string"&&!cr(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 het,appendFileSync as pet}from"fs";var GA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Up(r,n)&&!ts.has(e)&&uet(n)&&(t.some(({type:s,value:i})=>s==="native"&&fet.has(i))||t.every(({type:s})=>Bs.has(s))),uet=t=>t===1||t===2,fet=new Set(["pipe","overlapped"]),Ile=async(t,e,r,n)=>{for await(let s of t)det(e)||Mle(s,r,n)},Nle=(t,e,r)=>{for(let n of t)Mle(n,e,r)},det=t=>t._readableState.pipes.length>0,Mle=(t,e,r)=>{let n=iA(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Lle=({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)=>met({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},met=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:f})=>{if(t===null)return;let d=Dce(t,i,f),h=wa(d),{stdioItems:p,objectMode:m}=e[r],g=get([h],p,c,n),{serializedResult:y,finalResult:T=y}=_et({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});yet({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let S=a[r]?T:void 0;try{return n.error===void 0&&Eet(y,p,s),S}catch(_){return n.error=_,S}},get=(t,e,r,n)=>{try{return VA(t,e,r,!1)}catch(s){return n.error=s,t}},_et=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:WS(t)};let o=Kie(t,r);return n[i]?{serializedResult:o,finalResult:iq(o,!s[i],e)}:{serializedResult:o}},yet=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!GA({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=iq(t,!1,o);try{Nle(a,e,n)}catch(c){r.error??=c}},Eet=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>UA.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?pet(n,t):(r.add(i),het(n,t))}};var Dle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:cr(t)&&cr(e)?pU([t,e]):`${t}${e}`};import{once as lq}from"events";var kle=async(t,e)=>{let[r,n]=await Tet(t);return e.isForcefullyTerminated??=!1,[r,n]},Tet=async t=>{let[e,r]=await Promise.allSettled([lq(t,"spawn"),lq(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$le(t):r.value},$le=async t=>{try{return await lq(t,"exit")}catch{return $le(t)}},Fle=async t=>{let[e,r]=await t;if(!bet(e,r)&&uq(e,r))throw new gi;return[e,r]},bet=(t,e)=>t===void 0&&e===void 0,uq=(t,e)=>t!==0||e!==null;var Ule=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=vet(t,e,r),o=i?.code==="ETIMEDOUT",a=Lce(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vet=(t,e,r)=>t!==void 0?t:uq(e,r)?new gi:void 0;var qle=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ret(t,e,r),f=Oet({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Kp(f,c,l)},Ret=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),a=Aet(r),{file:c,commandArguments:l,options:u}=CA(t,e,a);Cet(u);let f=gle(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Aet=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Cet=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zA("ipcInput"),t&&zA("ipc: true"),r&&zA("detached: true"),n&&zA("cancelSignal")},zA=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Oet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Pet({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:f,timedOut:d,isMaxBuffer:h}=Ule(c,r),{output:p,error:m=l}=Lle({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),g=p.map((T,S)=>Ca(T,r,S)),y=Ca(Dle(p,r),r,"all");return Iet({error:m,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h,stdio:g,all:y,options:r,command:n,escapedCommand:s,startTime:a})},Pet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{xle(i,r);let a=xet(r);return wet(...OA(t,e,a))}catch(a){return Yp({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},xet=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:DA(e)}),Iet=({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?kA({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):rE({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 yrt}from"events";import{spawn as Srt}from"child_process";import Gle from"process";import{once as fq,on as Net}from"events";var Ble=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(jp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),Met({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),Met=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{_A(e,s);let i=il(t,e,r),o=new AbortController;try{return await Promise.race([Let(i,n,o),Det(i,r,o),ket(i,r,o)])}catch(a){throw Hp(t),a}finally{o.abort(),yA(e,s)}},Let=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await fq(t,"message",{signal:r});return n}for await(let[n]of Net(t,"message",{signal:r}))if(e(n))return n},Det=async(t,e,{signal:r})=>{await fq(t,"disconnect",{signal:r}),Cae(e)},ket=async(t,e,{signal:r})=>{let[n]=await fq(t,"strict:error",{signal:r});throw pA(n,e)};import{once as Hle,on as $et}from"events";var Vle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>dq({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),dq=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{jp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),_A(e,i);let o=il(t,e,r),a=new AbortController,c={};return Fet(t,o,a),Uet({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),qet({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},Fet=async(t,e,r)=>{try{await Hle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Uet=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await Hle(t,"strict:error",{signal:r.signal});n.error=pA(s,e),r.abort()}catch{}},qet=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of $et(r,"message",{signal:i.signal}))jle(o),yield c}catch{jle(o)}finally{i.abort(),yA(e,a),n||Hp(t),s&&await t}},jle=({error:t})=>{if(t)throw t};var zle=(t,{ipc:e})=>{Object.assign(t,Yle(t,!1,e))},Wle=()=>{let t=Gle,e=!0,r=Gle.channel!==void 0;return{...Yle(t,e,r),getCancelSignal:ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Yle=(t,e,r)=>({sendMessage:RA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Ble.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Vle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Bet}from"child_process";import{PassThrough as jet,Readable as Het,Writable as Vet,Duplex as Get}from"stream";var Kle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{rq(n);let a=new Bet;zet(a,n),Object.assign(a,{readable:Wet,writable:Yet,duplex:Ket});let c=Yp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=Jet(c,o,s);return{subprocess:a,promise:l}},zet=(t,e)=>{let r=sE(),n=sE(),s=sE(),i=Array.from({length:e.length-3},sE),o=sE(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},sE=()=>{let t=new jet;return t.end(),t},Wet=()=>new Het({read(){}}),Yet=()=>new Vet({write(){}}),Ket=()=>new Get({read(){},write(){}}),Jet=async(t,e,r)=>Kp(t,e,r);import{createReadStream as Jle,createWriteStream as Xle}from"fs";import{Buffer as Xet}from"buffer";import{Readable as iE,Writable as Qet,Duplex as Zet}from"stream";var Zle=(t,e)=>qA(ett,t,e,!1),oE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ol[t]}.`)},Qle={fileNumber:oE,generator:cq,asyncGenerator:cq,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zet.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ett={input:{...Qle,fileUrl:({value:t})=>({stream:Jle(t)}),filePath:({value:{file:t}})=>({stream:Jle(t)}),webStream:({value:t})=>({stream:iE.fromWeb(t)}),iterable:({value:t})=>({stream:iE.from(t)}),asyncIterable:({value:t})=>({stream:iE.from(t)}),string:({value:t})=>({stream:iE.from(t)}),uint8Array:({value:t})=>({stream:iE.from(Xet.from(t))})},output:{...Qle,fileUrl:({value:t})=>({stream:Xle(t)}),filePath:({value:{file:t,append:e}})=>({stream:Xle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Qet.fromWeb(t)}),iterable:oE,asyncIterable:oE,string:oE,uint8Array:oE}};import{on as ttt,once as eue}from"events";import{PassThrough as rtt,getDefaultHighWaterMark as ntt}from"stream";import{finished as nue}from"stream/promises";function bf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)pq(s);let e=t.some(({readableObjectMode:s})=>s),r=stt(t,e),n=new hq({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var stt=(t,e)=>{if(t.length===0)return ntt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},hq=class extends rtt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(pq(e),this.#e.has(e))return;this.#e.add(e),this.#n??=itt(this,this.#e,this.#i);let r=ctt({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(pq(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)}},itt=async(t,e,r)=>{WA(t,tue);let n=new AbortController;try{await Promise.race([ott(t,n),att(t,e,r,n)])}finally{n.abort(),WA(t,-tue)}},ott=async(t,{signal:e})=>{try{await nue(t,{signal:e,cleanup:!0})}catch(r){throw sue(t,r),r}},att=async(t,e,r,{signal:n})=>{for await(let[s]of ttt(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},pq=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ctt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{WA(t,rue);let a=new AbortController;try{await Promise.race([ltt(i,e,a),utt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),ftt({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),WA(t,-rue)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?mq(t):dtt(t))},ltt=async(t,e,{signal:r})=>{try{await t,r.aborted||mq(e)}catch(n){r.aborted||sue(e,n)}},utt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await nue(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;iue(o)?s.add(e):oue(t,o)}},ftt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await eue(t,s,{signal:i}),!t.readable)return eue(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},dtt=t=>{t.writable&&t.end()},sue=(t,e)=>{iue(e)?mq(t):oue(t,e)},iue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",mq=t=>{(t.readable||t.writable)&&t.destroy()},oue=(t,e)=>{t.destroyed||(t.once("error",htt),t.destroy(e))},htt=()=>{},WA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},tue=2,rue=1;import{finished as aue}from"stream/promises";var Xp=(t,e)=>{t.pipe(e),ptt(t,e),mtt(t,e)},ptt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(t,{cleanup:!0,readable:!0,writable:!1})}catch{}gq(e)}},gq=t=>{t.writable&&t.end()},mtt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(e,{cleanup:!0,readable:!1,writable:!0})}catch{}_q(t)}},_q=t=>{t.readable&&t.destroy()};var cue=(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})=>Bs.has(c)))gtt(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!Bs.has(c)))ytt({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]:bf(i);Xp(o,s)}},gtt=(t,e,r,n)=>{r==="output"?Xp(t.stdio[n],e):Xp(e,t.stdio[n]);let s=_tt[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},_tt=["stdin","stdout","stderr"],ytt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;Stt(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},Stt=(t,{signal:e})=>{mi(t)&&yf(t,Ett,e)},Ett=2;import{addAbortListener as vtt}from"events";var vf=[];vf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var YA=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",yq=Symbol.for("signal-exit emitter"),Sq=globalThis,Ttt=Object.defineProperty.bind(Object),Eq=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Sq[yq])return Sq[yq];Ttt(Sq,yq,{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}},KA=class{},btt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Tq=class extends KA{onExit(){return()=>{}}load(){}unload(){}},bq=class extends KA{#e=vq.platform==="win32"?"SIGINT":"SIGHUP";#r=new Eq;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of vf)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(!YA(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 vf)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,vf.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 YA(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"&&YA(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)}},vq=globalThis.process,{onExit:lue,load:gzt,unload:_zt}=btt(YA(vq)?new bq(vq):new Tq);var uue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=lue(()=>{t.kill()});vtt(n,()=>{s()})};var due=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=oA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=wtt(r,n,s),{sourceStream:f,sourceError:d}=Att(t,l),{options:h,fileDescriptors:p}=mo.get(t);return{sourcePromise:e,sourceStream:f,sourceOptions:h,sourceError:d,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},wtt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=Rtt(t,e,...r),a=gA(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},Rtt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(fue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||dU(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]=JR(r,...n);return{destination:e(fue)(s,i,o),pipeOptions:o}}if(mo.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}`)},fue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Att=(t,e)=>{try{return{sourceStream:Vp(t,e)}}catch(r){return{sourceError:r}}};var pue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Ctt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw wq({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Ctt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return _q(t),n;if(e!==void 0)return gq(r),e},wq=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yp({error:t,command:hue,escapedCommand:hue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),hue="source.pipe(destination)";var mue=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 Ott}from"stream/promises";var gue=(t,e,r)=>{let n=JA.has(e)?xtt(t,e):Ptt(t,e);return yf(t,Ntt,r.signal),yf(e,Mtt,r.signal),Itt(e),n},Ptt=(t,e)=>{let r=bf([t]);return Xp(r,e),JA.set(e,r),r},xtt=(t,e)=>{let r=JA.get(e);return r.add(t),r},Itt=async t=>{try{await Ott(t,{cleanup:!0,readable:!1,writable:!0})}catch{}JA.delete(t)},JA=new WeakMap,Ntt=2,Mtt=1;import{aborted as Ltt}from"util";var _ue=(t,e)=>t===void 0?[]:[Dtt(t,e)],Dtt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await Ltt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw wq({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var XA=(t,...e)=>{if(Jt(e[0]))return XA.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=due(t,...e),s=ktt({...n,destination:r});return s.pipe=XA.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},ktt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=$tt(t,s);pue({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let f=new AbortController;try{let d=gue(e,i,f);return await Promise.race([mue(u),..._ue(a,{sourceStream:e,mergedStream:d,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{f.abort()}},$tt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Vtt}from"timers/promises";import{on as Ftt}from"events";import{getDefaultHighWaterMark as Utt}from"stream";var QA=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return qtt(e,o),Sue({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},qtt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Rq=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Btt(e,o,t);let a=t.readableObjectMode&&!i;return Sue({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Btt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Sue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Ftt(t,"data",{signal:e.signal,highWaterMark:yue,highWatermark:yue});return jtt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},Aq=Utt(!0),yue=Aq,jtt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Htt({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*Tf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*nE(a)}},Htt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[jA(t,r,!e),BA(t,s,!n,{})].filter(Boolean);var Eue=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let f=Gtt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([ztt(t),f]);return}let d=nq(c,r),h=Rq({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:d,allMixed:a}),[p]=await Promise.all([Wtt({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),f]);return p},Gtt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!GA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=Rq({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await Ile(a,t,r,i)},ztt=async t=>{await Vtt(),t.readableFlowing===null&&t.resume()},Wtt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await NA(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await MA(r,{maxBuffer:i})):await Wp(r,{maxBuffer:i})}catch(a){return Tue(Ice({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},Cq=async t=>{try{return await t}catch(e){return Tue(e)}},Tue=({bufferedData:t})=>Wie(t)?new Uint8Array(t):t;import{finished as Ytt}from"stream/promises";var aE=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ktt(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ytt(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Qtt(a,e,r,n)}finally{o.abort()}},Ktt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Jtt(t,r,n),n},Jtt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Xtt(e,r),n.call(t,...s)}},Xtt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Qtt=(t,e,r,n)=>{if(!Ztt(t,e,r,n))throw t},Ztt=(t,e,r,n=!0)=>r.propagating?bue(t)||ZA(t):(r.propagating=!0,Oq(r,e)===n?bue(t):ZA(t)),Oq=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ZA=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",bue=t=>t?.code==="EPIPE";var vue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Pq({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),Pq=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=aE(t,e,l);if(Oq(l,e)){await u;return}let[f]=await Promise.all([Eue({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return f};var wue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bf([t,e].filter(Boolean)):void 0,Rue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>Pq({...ert(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:trt(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),ert=({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}},trt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as rrt}from"events";var Aue=t=>Up(t,"ipc"),Cue=(t,e)=>{let r=iA(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Oue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=Aue(i),a=Ra(e,"ipc"),c=Ra(r,"ipc");for await(let l of dq({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Nce(t,s,c),s.push(l)),o&&Cue(l,i);return s},Pue=async(t,e)=>(await Promise.allSettled([t]),e);var xue=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:f},context:d,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:g,controller:y})=>{let T=kle(t,d),S={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:T,propagating:!1},_=vue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),A=Rue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),P=[],C=Oue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:h}),R=nrt(m,t,S),O=srt(p,S);try{return await Promise.race([Promise.all([{},Fle(T),Promise.all(_),A,C,uce(t,f),...R,...O]),g,irt(t,y),...ice(t,i,d,y),...Aae({subprocess:t,cancelSignal:o,gracefulCancel:a,context:d,controller:y}),...nce({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:d,controller:y})])}catch(w){return d.terminationReason??="other",Promise.all([{error:w},T,Promise.all(_.map(b=>Cq(b))),Cq(A),Pue(C,P),Promise.allSettled(R),Promise.allSettled(O)])}},nrt=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:aE(n,s,r)),srt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>yi(i,{checkOpen:!1})&&!mi(i)).map(({type:s,value:i,stream:o=i})=>aE(o,n,e,{isSameDirection:Bs.has(s),stopOnExit:s==="native"}))),irt=async(t,{signal:e})=>{let[r]=await rrt(t,"error",{signal:e});throw r};var Iue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),cE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=po();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Qp=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 ort}from"stream";import{callbackify as art}from"util";import{finished as Nue}from"stream/promises";var xq=async t=>{if(t!==void 0)try{await Iq(t)}catch{}},Mue=async t=>{if(t!==void 0)try{await Nq(t)}catch{}},Iq=async t=>{await Nue(t,{cleanup:!0,readable:!1,writable:!0})},Nq=async t=>{await Nue(t,{cleanup:!0,readable:!0,writable:!1})},eC=async(t,e)=>{if(await t,e)throw e},tC=(t,e,r)=>{r&&!ZA(r)?t.destroy(r):e&&t.destroy()};var Lue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Mq(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:f}=Lq(a,o),{read:d,onStdoutDataDone:h}=Dq({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new ort({read:d,destroy:art($q.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:f,objectMode:u,encoding:l});return kq({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},Mq=(t,e,r)=>{let n=Vp(t,e),s=cE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},Lq=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Aq},Dq=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=po(),o=QA({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){crt(this,o,i)},onStdoutDataDone:i}},crt=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},kq=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await Nq(t),await n,await xq(s),await e,r.readable&&r.push(null)}catch(i){await xq(s),Due(r,i)}},$q=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qp(r,e)&&(Due(t,n),await eC(e,n))},Due=(t,e)=>{tC(t,t.readable,e)};import{Writable as lrt}from"stream";import{callbackify as kue}from"util";var $ue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=Fq(t,r,e),o=new lrt({...Uq(n,t,s),destroy:kue(Bq.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qq(n,o),o},Fq=(t,e,r)=>{let n=gA(t,e),s=cE(r,n,"writableFinal"),i=cE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},Uq=(t,e,r)=>({write:urt.bind(void 0,t),final:kue(frt.bind(void 0,t,e,r))}),urt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},frt=async(t,e,r)=>{await Qp(r,e)&&(t.writable&&t.end(),await e)},qq=async(t,e,r)=>{try{await Iq(t),e.writable&&e.end()}catch(n){await Mue(r),Fue(e,n)}},Bq=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Qp(r,e),await Qp(n,e)&&(Fue(t,s),await eC(e,s))},Fue=(t,e)=>{tC(t,t.writable,e)};import{Duplex as drt}from"stream";import{callbackify as hrt}from"util";var Uue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||ts.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Mq(t,n,e),{subprocessStdin:u,waitWritableFinal:f,waitWritableDestroy:d}=Fq(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=Lq(c,a),{read:g,onStdoutDataDone:y}=Dq({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),T=new drt({read:g,...Uq(u,t,f),destroy:hrt(prt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:f,waitWritableDestroy:d})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return kq({subprocessStdout:c,onStdoutDataDone:y,readable:T,subprocess:t,subprocessStdin:u}),qq(u,T,c),T},prt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([$q({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Bq({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var jq=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||ts.has(e),o=Vp(t,r),a=QA({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return mrt(a,o,t)},mrt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var que=(t,{encoding:e})=>{let r=Iue();t.readable=Lue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=jq.bind(void 0,t,e),t[Symbol.asyncIterator]=jq.bind(void 0,t,e,{})};var Bue=(t,e)=>{for(let[r,n]of _rt){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},grt=(async()=>{})().constructor.prototype,_rt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(grt,t)]);var jue=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:f}=Ert(t,e,r),{subprocess:d,promise:h}=brt({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:f});return d.pipe=XA.bind(void 0,{source:d,sourcePromise:h,boundOptions:{},createNested:n}),Bue(d,h),mo.set(d,{options:u,fileDescriptors:f}),d},Ert=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),{file:a,commandArguments:c,options:l}=CA(t,e,r),u=Trt(l),f=Zle(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Trt=({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}},brt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Srt(...OA(t,e,r))}catch(p){return Kle({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;yrt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];cue(c,a,l),uue(c,r,l);let f={},d=po();c.kill=wae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:d,context:f,controller:l}),c.all=wue(c,r),que(c,r),zle(c,r);let h=vrt({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:f,onInternalError:d,controller:l});return{subprocess:c,promise:h}},vrt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[f,[d,h],p,m,g]=await xue({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let y=p.map((_,A)=>Ca(_,e,A)),T=Ca(m,e,"all"),S=wrt({errorInfo:f,exitCode:d,signal:h,stdio:y,all:T,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Kp(S,n,e)},wrt=({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?rE({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 go,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):kA({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var rC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Rrt(n,t[n],s)]));return{...t,...r}},Rrt=(t,e,r)=>Art.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,Art=new Set(["env",...yU]);var al=(t,e,r,n)=>{let s=(o,a,c)=>al(o,a,r,c),i=(...o)=>Crt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Crt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(Jt(i))return s(t,rC(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Ort({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?qle(a,c,l):jue(a,c,l,s)},Ort=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Zie(e)?eoe(e,r):[e,...r],[o,a,c]=JR(...i),l=rC(rC(n,s),c),{file:u=o,commandArguments:f=a,options:d=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:f,options:d,isSync:h}};var Hue=({file:t,commandArguments:e})=>Gue(t,e),Vue=({file:t,commandArguments:e})=>({...Gue(t,e),isSync:!0}),Gue=(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]=Prt(t);return{file:r,commandArguments:n}},Prt=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(xrt)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},xrt=/ +/g;var zue=(t,e,r)=>{t.sync=e(Irt,r),t.s=t.sync},Wue=({options:t})=>Yue(t),Irt=({options:t})=>({...Yue(t),isSync:!0}),Yue=t=>({options:{...Nrt(t),...t}}),Nrt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Kue={preferLocal:!0};var Jue=al(()=>({})),oWt=al(()=>({isSync:!0})),Xue=al(Hue),aWt=al(Vue),cWt=al(ace),lWt=al(Wue,{},Kue,zue),{sendMessage:uWt,getOneMessage:fWt,getEachMessage:dWt,getCancelSignal:hWt}=Wle();import{Transform as Mrt}from"stream";var Lrt=["NETLIFY_AI_GATEWAY_KEY"];function Drt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Lrt])]}function krt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $rt(){let e=Drt().map(r=>process.env[r]).filter(r=>!(!r||krt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function js(t){if(typeof t!="string")return t;let e=$rt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let s=new RegExp(Frt(n),"g");r=r.replace(s,"******")}),r}function Frt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var lE=class extends Mrt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let s=e.toString(),i=js(s);n(null,i)}},nC=Symbol("maskedWrite");function Que(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[nC]){let e=process.stdout.write.bind(process.stdout),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stdout.write=r}if(!process.stderr.write[nC]){let e=process.stderr.write.bind(process.stderr),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stderr.write=r}}}var Zue=!1,efe=()=>{Zue=!0},Fn=()=>Zue;var uE=null,tfe=t=>(uE&&uE.destroy(),uE=new Oa({totalAllowedTime:t}),uE),rfe=()=>uE;var Oa=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&&Fn())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,f)=>{o=setTimeout(()=>{f(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await YR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Oe.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 nfe={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.1-next.0",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 jrt=qrt(import.meta.url),Hrt=Pa.dirname(jrt),Vrt=Brt(import.meta.url),Zp=Te("shell"),Hq=new Set,sfe={preferLocal:!0},rs=(t,e,r)=>{let[n,s]=Grt(e,r),i={...sfe,...s},o=Jue(t,n,i);ofe(o,i),lfe(o);let a=r?.idleTimeout;return a&&a>0&&cfe(o,a),o},ife=(t,e)=>{let r={...sfe,...e},n=Xue(t,r);return ofe(n,r),lfe(n),e?.idleTimeout&&e.idleTimeout>0&&cfe(n,e.idleTimeout),n},Grt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ofe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(xa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new lE).pipe(xa.stdout),t.stderr?.pipe(new lE).pipe(xa.stderr);return}t.stdout?.pipe(xa.stdout),t.stderr?.pipe(xa.stderr)},Vq=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xa.kill(-t.pid,e),Zp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zp.error("Error killing process:",r),!1}},afe=t=>Vq(t,"SIGKILL"),cfe=(t,e)=>{let r=null,n=()=>{Zp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing idle process ${t.pid}`),afe(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)},lfe=t=>{Hq.add(t);let e=rfe();if(e){let r=e.onTimesUp(()=>{Zp.log(`Global timer expired, killing process ${t.pid}`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing process ${t.pid} after timeout`),afe(t))},5e3)});t.on("exit",()=>{Hq.delete(t),r()}),t.on("error",()=>{Hq.delete(t),r()})}};function cl(t,e){if(!xa.env.NETLIFY_LOCAL_MODE)try{let s=Vrt.resolve(nfe.name),i=Pa.dirname(s);for(;i!==Pa.dirname(i);){let o=Pa.dirname(i);if(Pa.basename(o)==="node_modules"){let a=Pa.join(o,".bin",e);if(sC.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(xa.env.NODE_PATH){let s=Pa.join(xa.env.NODE_PATH,".bin",e);if(sC.existsSync(s))return s}let r=Pa.join(t,"node_modules",".bin",e);if(sC.existsSync(r))return r;let n=Pa.join(Hrt,"..","node_modules",".bin",e);if(sC.existsSync(n))return n}import cI from"process";import{fileURLToPath as Mgt}from"url";import{createRequire as Lgt}from"module";import lI from"path";var zrt="__netlify__getTracer",Wrt="__netlify__shutdownTracers",Ze=(t,e)=>globalThis[zrt]?.(t,e),ufe=async()=>globalThis[Wrt]?.();function wf(t,e,r,n,s){let i=typeof n=="function"?n:typeof r=="function"?r:s;if(!i)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,i):i()}import{setTimeout as Ogt}from"timers/promises";import Hst from"process";var ffe=typeof globalThis=="object"?globalThis:global;var Ia="1.9.0";var dfe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Yrt(t){var e=new Set([t]),r=new Set,n=t.match(dfe);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(dfe);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var hfe=Yrt(Ia);var Krt=Ia.split(".")[0],fE=Symbol.for("opentelemetry.js.api."+Krt),dE=ffe;function ll(t,e,r,n){var s;n===void 0&&(n=!1);var i=dE[fE]=(s=dE[fE])!==null&&s!==void 0?s:{version:Ia};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==Ia){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+Ia);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ia+"."),!0}function Si(t){var e,r,n=(e=dE[fE])===null||e===void 0?void 0:e.version;if(!(!n||!hfe(n)))return(r=dE[fE])===null||r===void 0?void 0:r[t]}function ul(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ia+".");var r=dE[fE];r&&delete r[t]}var Jrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Xrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},pfe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("verbose",this._namespace,e)},t})();function hE(t,e,r){var n=Si("diag");if(n)return r.unshift(e),n[t].apply(n,Xrt([],Jrt(r),!1))}var yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(yn||(yn={}));function mfe(t,e){t<yn.NONE?t=yn.NONE:t>yn.ALL&&(t=yn.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",yn.ERROR),warn:r("warn",yn.WARN),info:r("info",yn.INFO),debug:r("debug",yn.DEBUG),verbose:r("verbose",yn.VERBOSE)}}var Qrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Zrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},ent="diag",ns=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Si("diag");if(a)return a[s].apply(a,Zrt([],Qrt(i),!1))}}var r=this,n=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:yn.INFO}),s===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof i=="number"&&(i={logLevel:i});var u=Si("diag"),f=mfe((a=i.logLevel)!==null&&a!==void 0?a:yn.INFO,s);if(u&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ll("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ul(ent,r)},r.createComponentLogger=function(s){return new pfe(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var tnt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},rnt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},gfe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=tnt(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=rnt(n),a=o.next();!a.done;a=o.next()){var c=a.value;i._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();var rYt=ns.instance();function _fe(t){return t===void 0&&(t={}),new gfe(new Map(Object.entries(t)))}function iC(t){return Symbol.for(t)}var nnt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),yfe=new nnt;var Sfe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Efe={set:function(t,e,r){t!=null&&(t[e]=r)}};var snt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},int=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Tfe=(function(){function t(){}return t.prototype.active=function(){return yfe},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,int([n],snt(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var ont=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},ant=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Gq="context",cnt=new Tfe,fl=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ll(Gq,e,ns.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,ant([e,r,n],ont(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Si(Gq)||cnt},t.prototype.disable=function(){this._getContextManager().disable(),ul(Gq,ns.instance())},t})();var oC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(oC||(oC={}));var zq="0000000000000000",Wq="00000000000000000000000000000000",bfe={traceId:Wq,spanId:zq,traceFlags:oC.NONE};var dl=(function(){function t(e){e===void 0&&(e=bfe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var Yq=iC("OpenTelemetry Context Key SPAN");function aC(t){return t.getValue(Yq)||void 0}function vfe(){return aC(fl.getInstance().active())}function pE(t,e){return t.setValue(Yq,e)}function wfe(t){return t.deleteValue(Yq)}function Rfe(t,e){return pE(t,new dl(e))}function cC(t){var e;return(e=aC(t))===null||e===void 0?void 0:e.spanContext()}var lnt=/^([0-9a-f]{32})$/i,unt=/^[0-9a-f]{16}$/i;function fnt(t){return lnt.test(t)&&t!==Wq}function dnt(t){return unt.test(t)&&t!==zq}function lC(t){return fnt(t.traceId)&&dnt(t.spanId)}function Afe(t){return new dl(t)}var Kq=fl.getInstance(),uC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=Kq.active());var s=!!r?.root;if(s)return new dl;var i=n&&cC(n);return hnt(i)&&lC(i)?new dl(i):new dl},t.prototype.startActiveSpan=function(e,r,n,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(i=r,a=n):(i=r,o=n,a=s);var c=o??Kq.active(),l=this.startSpan(e,i,c),u=pE(c,l);return Kq.with(u,a,void 0,l)}},t})();function hnt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var pnt=new uC,Cfe=(function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):pnt},t})();var Ofe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new uC},t})();var mnt=new Ofe,Jq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new Cfe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:mnt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t})();var hl;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(hl||(hl={}));var yo;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(yo||(yo={}));var Na=fl.getInstance();var Xq=ns.instance();var Pfe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Qq=iC("OpenTelemetry Baggage Key");function Zq(t){return t.getValue(Qq)||void 0}function xfe(){return Zq(fl.getInstance().active())}function Ife(t,e){return t.setValue(Qq,e)}function Nfe(t){return t.deleteValue(Qq)}var eB="propagation",gnt=new Pfe,Mfe=(function(){function t(){this.createBaggage=_fe,this.getBaggage=Zq,this.getActiveBaggage=xfe,this.setBaggage=Ife,this.deleteBaggage=Nfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ll(eB,e,ns.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Efe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Sfe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ul(eB,ns.instance())},t.prototype._getGlobalPropagator=function(){return Si(eB)||gnt},t})();var mE=Mfe.getInstance();var tB="trace",Lfe=(function(){function t(){this._proxyTracerProvider=new Jq,this.wrapSpanContext=Afe,this.isSpanContextValid=lC,this.deleteSpan=wfe,this.getSpan=aC,this.getActiveSpan=vfe,this.getSpanContext=cC,this.setSpan=pE,this.setSpanContext=Rfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=ll(tB,this._proxyTracerProvider,ns.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return Si(tB)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){ul(tB,ns.instance()),this._proxyTracerProvider=new Jq},t})();var gE=Lfe.getInstance();var ynt=function(t,e){e.recordException(t),e.setStatus({code:yo.ERROR})};var Rf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return kfe(l,o,c)})},t.prototype.withSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn,l=this._tracer.startSpan(e,o,a);return kfe(l,o,c)},t})();function Dfe(t,e,r){var n,s,i;return!e&&!r?i=t:r?(n=t,s=e,i=r):(n=t,i=e),n=n??{},s=s??Na.active(),{opts:n,ctx:s,fn:i}}function kfe(t,e,r){var n,s=(n=e.onException)!==null&&n!==void 0?n:ynt,i=function(a){throw s(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},i):(t.end(),o)}catch(a){throw i(a)}}QB();He();var BE=class{emit(e){}enabled(){return!1}},Khe=new BE;var jE=Symbol.for("io.opentelemetry.js.api.logs"),lm=globalThis;function Jhe(t,e,r){return n=>n===t?e:r}var ZB=1;var ej=class{getLogger(e,r,n){return new BE}},tO=new ej;var rO=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Khe}};var HE=class{getLogger(e,r,n){var s;return(s=this._getDelegateLogger(e,r,n))!==null&&s!==void 0?s:new rO(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tO}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(e,r,n)}};var nO=class t{constructor(){this._proxyLoggerProvider=new HE}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return lm[jE]?this.getLoggerProvider():(lm[jE]=Jhe(ZB,e,tO),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=lm[jE])===null||e===void 0?void 0:e.call(lm,ZB))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete lm[jE],this._proxyLoggerProvider=new HE}};var Xhe=nO.getInstance();function Qhe(t,e,r,n){for(let s=0,i=t.length;s<i;s++){let o=t[s];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function Zhe(t){t.forEach(e=>e.disable())}function tj(t){let e=t.tracerProvider||lr.getTracerProvider(),r=t.meterProvider||CE.getMeterProvider(),n=t.loggerProvider||Xhe.getLoggerProvider(),s=t.instrumentations?.flat()??[];return Qhe(s,e,r,n),()=>{Zhe(s)}}Vt();var RO=fn(_j(),1);Vt();var Npe=t=>{throw TypeError(t)},Tj=(t,e,r)=>e.has(t)||Npe("Cannot "+r),wO=(t,e,r)=>(Tj(t,e,"read from private field"),r?r.call(t):e.get(t)),yj=(t,e,r)=>e.has(t)?Npe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Ppe=(t,e,r,n)=>(Tj(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),jst=(t,e,r)=>(Tj(t,e,"access private method"),r),xpe="__netlify__getTracer",Vst="__netlify__shutdownTracers",Gst="__nfOTLPTrace",GE,zE,Ej,Mpe,zst=class{constructor(){yj(this,Ej),yj(this,GE),yj(this,zE),Ppe(this,GE,new Ro(jst(this,Ej,Mpe),this)),Ppe(this,zE,Xq.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(wO(this,zE).debug(`export ${t.length.toString()} spans`),wO(this,GE).isCalled){e({code:It.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Gst,JSON.stringify(Wst(t))),e({code:It.SUCCESS})}shutdown(){return wO(this,GE).call()}};GE=new WeakMap;zE=new WeakMap;Ej=new WeakSet;Mpe=function(){return wO(this,zE).debug("Shutting down"),Promise.resolve()};function Wst(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:vO(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||hl.SERVER,startTimeUnixNano:Sj(e.startTime),endTimeUnixNano:Sj(e.endTime),attributes:vO(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Sj(n.time),attributes:vO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:vO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function vO(t){return Object.keys(t).map(e=>Lpe(e,t[e]))}function Lpe(t,e){return{key:t,value:Dpe(e)}}function Dpe(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Dpe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Lpe(r,n))}}:{}}function Sj(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Ipe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},kpe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,xpe))return;let e=Hst.version.slice(1),r=eO({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Yst()],s=new RO.NodeTracerProvider({resource:r,spanProcessors:n});s.register({propagator:new $a});let i=t.instrumentations??[];tj({instrumentations:i,tracerProvider:s}),Object.defineProperty(globalThis,xpe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Rf(gE.getTracer(a,c)):new Rf(gE.getTracer(Ipe.name,Ipe.version))}}),Object.defineProperty(globalThis,Vst,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await s.shutdown()})},Yst=()=>new RO.SimpleSpanProcessor(new zst);Vt();var WE=fn(_j(),1);import*as AO from"diagnostics_channel";var $pe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?yo.ERROR:yo.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],s=this.config.redactHeaders??[],i=n.some(a=>r.includes(a.toString())),o={};if(i)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(d=>typeof d=="string"?d==u:d.test(u)))continue;let f=`http.${t}.header.${u}`;s===!0||s.some(d=>typeof d=="string"?d==u:d.test(u))?o[f]="REDACTED":o[f]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Rf?t:new Rf(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){AO.subscribe(t,e);let r=()=>AO.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(s=>typeof s=="string"?r.href.startsWith(s):s.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:hl.CLIENT},Na.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:yo.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var KTe=fn(WTe(),1);var oI=Te("tracing"),YTe=8e3,Pgt=5e3,ob=async(t=Pgt)=>{try{await Promise.race([ufe(),Ogt(t)])}catch(e){oI.warn("Failed to flush tracers on shutdown",e)}},JTe=async(t,e,r)=>{if(!Ze()){let n=[new WE.SimpleSpanProcessor(new iz),new WE.SimpleSpanProcessor(new KTe.OTLPTraceExporter({url:r.exporterUrl}))];await kpe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new $pe({skipHeaders:!0})]})}return r.traceparent?(mE.setGlobalPropagator(new $a),mE.extract(Na.active(),{traceparent:r.traceparent,isRemote:!0})):Na.active()};function yt(t,e,r){return oI.log(`\u23F3 TRACE: ${e} starting...`),wf(t,e,r)}var iz=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,s=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?s.push(`${a}=${c.toFixed(2)}ms`):s.push(`${a}=${c}`);let i=e.status?.code===2?"\u274C":"\u2705",o=s.length>0?` [${s.join(", ")}]`:"";oI.log(`${i} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&oI.log(` \u274C Error: ${e.status.message}`)}};function oz(){return process.env.AGENT_RUNNER_CAPTURE_LLM_CONTENT!=="false"}function XTe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function aI(t,e,r){let n={role:t,parts:[{type:"text",content:js(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function QTe(t,e,r,n){if(!t.length)return;let s=Ze();if(!s)return;let i=oz(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),f=a.title||a.type||`step-${a.id??c}`,d=a.type==="tool_use"||a.type==="tool_result",h=a.message?a.message.length>YTe?`${a.message.slice(0,YTe)}\u2026`:a.message:void 0;s.startSpan(f,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":f,"gen_ai.operation.name":d?"execute_tool":"chat",...d?{"gen_ai.tool.name":f}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...i&&h?d?{"gen_ai.tool.call.result":js(h)}:{"gen_ai.output.messages":aI("assistant",h)}:{}}}).end(u)})}import{readdir as xgt,rm as Igt}from"fs/promises";import{join as Ngt}from"path";async function ZTe(t,e=[]){let n=(await xgt(t)).filter(s=>!e.includes(s));await Promise.all(n.map(s=>Igt(Ngt(t,s),{recursive:!0,force:!0})))}var Dgt=lI.dirname(Mgt(import.meta.url)),ebe=Lgt(import.meta.url),kgt=lI.resolve(Dgt,"scripts/scaffold.js"),$gt="scripts/scaffold.js",Fgt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,az=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},Ugt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),qgt=t=>{let e=az(t);return e==="node"||e.endsWith("/node")},cd=t=>{if(typeof t!="string")return!1;let e=t.match(Fgt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Ugt(az(e[r]));)r+=1;if(r>=e.length||!qgt(e[r]))return!1;let n=e[r+1];return n?az(n).includes($gt):!1},ab=Te("create_stage"),Bgt="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.\n\nCommands that generate or modify project files are fine to run when the task requires them \u2014 for example `drizzle-kit generate` to write a database migration after a schema change, or other code-generation utilities documented in the skills.",jgt="./.netlify-cache",Hgt=({cwd:t=cI.cwd()}={})=>{let e=cI.env.NVM_BIN?`${cI.env.NVM_BIN}/node`:"node",r;try{let n=ebe.resolve("@netlify/ts-cli/package.json"),s=lI.dirname(n),i=ebe("@netlify/ts-cli/package.json");r=lI.join(s,i.bin)}catch{r=cl(t,"ts-cli")}return{nodeCmd:e,tsCliPath:r}},Vgt=t=>{let e;try{if(!t)throw new Error("empty response");e=JSON.parse(t)}catch(r){return ab.error("Failed to parse template list from ts-cli",{raw:t,error:r.message}),Oe.inc("context.degraded",1,{component:"templates"}),[]}return e.filter(r=>r.type==="example").map(r=>{let{type:n,...s}=r;return s})},Ggt=({templates:t,nodeCmd:e,scaffoldScriptPath:r})=>{let n=JSON.stringify(t.map(({id:i,name:o,description:a})=>({id:i,name:o,description:a})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",t.length>0?`## Available Templates
504
+ if (condition) { yield value; }`)};import{Buffer as KZe}from"buffer";import{StringDecoder as JZe}from"string_decoder";var jA=(t,e,r)=>{if(r)return;if(t)return{transform:XZe.bind(void 0,new TextEncoder)};let n=new JZe(e);return{transform:QZe.bind(void 0,n),final:ZZe.bind(void 0,n)}},XZe=function*(t,e){KZe.isBuffer(e)?yield wa(e):typeof e=="string"?yield t.encode(e):yield e},QZe=function*(t,e){yield cr(e)?t.write(e):e},ZZe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as wle}from"util";var oq=wle(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),HA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tet}=e[r];for await(let s of n(t))yield*HA(s,e,r+1)},Rle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eet(r,Number(e),t)},eet=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HA(n,r,e+1)},Ale=wle(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),tet=function*(t){yield t};var aq=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},Cle=(t,e)=>[...e.flatMap(r=>[...Tf(r,t,0)]),...nE(t)],Tf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=net}=e[r];for(let s of n(t))yield*Tf(s,e,r+1)},nE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ret(r,Number(e),t)},ret=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tf(n,r,e+1)},net=function*(t){yield t};var cq=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=Ple(t,o,i),l=Ef(e),u=Ef(r),f=l?oq.bind(void 0,HA,a):aq.bind(void 0,Tf),d=l||u?oq.bind(void 0,Rle,a):aq.bind(void 0,nE),h=l||u?Ale.bind(void 0,a):void 0;return{stream:new set({writableObjectMode:n,writableHighWaterMark:Ole(n),readableObjectMode:s,readableHighWaterMark:Ole(s),transform(m,g,y){f([m,c,0],this,y)},flush(m){d([c],this,m)},destroy:h})}},VA=(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=Ple(o,r,a);t=Cle(c,t)}return t},Ple=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:Tle(n,a)},jA(r,o,n),BA(r,i,n,c),{transform:t,final:e},{transform:ble(s,a)},Ele({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var xle=(t,e)=>{for(let r of iet(t))oet(t,r,e)},iet=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oet=(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 ${ol[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>aet(a,n));r.input=WS(o)},aet=(t,e)=>{let r=VA(t,e,"utf8",!0);return cet(r),WS(r)},cet=t=>{let e=t.find(r=>typeof r!="string"&&!cr(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 het,appendFileSync as pet}from"fs";var GA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Up(r,n)&&!ts.has(e)&&uet(n)&&(t.some(({type:s,value:i})=>s==="native"&&fet.has(i))||t.every(({type:s})=>Bs.has(s))),uet=t=>t===1||t===2,fet=new Set(["pipe","overlapped"]),Ile=async(t,e,r,n)=>{for await(let s of t)det(e)||Mle(s,r,n)},Nle=(t,e,r)=>{for(let n of t)Mle(n,e,r)},det=t=>t._readableState.pipes.length>0,Mle=(t,e,r)=>{let n=iA(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Lle=({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)=>met({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},met=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:f})=>{if(t===null)return;let d=Dce(t,i,f),h=wa(d),{stdioItems:p,objectMode:m}=e[r],g=get([h],p,c,n),{serializedResult:y,finalResult:T=y}=_et({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});yet({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let S=a[r]?T:void 0;try{return n.error===void 0&&Eet(y,p,s),S}catch(_){return n.error=_,S}},get=(t,e,r,n)=>{try{return VA(t,e,r,!1)}catch(s){return n.error=s,t}},_et=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:WS(t)};let o=Kie(t,r);return n[i]?{serializedResult:o,finalResult:iq(o,!s[i],e)}:{serializedResult:o}},yet=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!GA({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=iq(t,!1,o);try{Nle(a,e,n)}catch(c){r.error??=c}},Eet=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>UA.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?pet(n,t):(r.add(i),het(n,t))}};var Dle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:cr(t)&&cr(e)?pU([t,e]):`${t}${e}`};import{once as lq}from"events";var kle=async(t,e)=>{let[r,n]=await Tet(t);return e.isForcefullyTerminated??=!1,[r,n]},Tet=async t=>{let[e,r]=await Promise.allSettled([lq(t,"spawn"),lq(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$le(t):r.value},$le=async t=>{try{return await lq(t,"exit")}catch{return $le(t)}},Fle=async t=>{let[e,r]=await t;if(!bet(e,r)&&uq(e,r))throw new gi;return[e,r]},bet=(t,e)=>t===void 0&&e===void 0,uq=(t,e)=>t!==0||e!==null;var Ule=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=vet(t,e,r),o=i?.code==="ETIMEDOUT",a=Lce(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vet=(t,e,r)=>t!==void 0?t:uq(e,r)?new gi:void 0;var qle=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ret(t,e,r),f=Oet({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Kp(f,c,l)},Ret=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),a=Aet(r),{file:c,commandArguments:l,options:u}=CA(t,e,a);Cet(u);let f=gle(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Aet=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Cet=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zA("ipcInput"),t&&zA("ipc: true"),r&&zA("detached: true"),n&&zA("cancelSignal")},zA=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Oet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Pet({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:f,timedOut:d,isMaxBuffer:h}=Ule(c,r),{output:p,error:m=l}=Lle({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),g=p.map((T,S)=>Ca(T,r,S)),y=Ca(Dle(p,r),r,"all");return Iet({error:m,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h,stdio:g,all:y,options:r,command:n,escapedCommand:s,startTime:a})},Pet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{xle(i,r);let a=xet(r);return wet(...OA(t,e,a))}catch(a){return Yp({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},xet=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:DA(e)}),Iet=({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?kA({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):rE({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 yrt}from"events";import{spawn as Srt}from"child_process";import Gle from"process";import{once as fq,on as Net}from"events";var Ble=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(jp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),Met({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),Met=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{_A(e,s);let i=il(t,e,r),o=new AbortController;try{return await Promise.race([Let(i,n,o),Det(i,r,o),ket(i,r,o)])}catch(a){throw Hp(t),a}finally{o.abort(),yA(e,s)}},Let=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await fq(t,"message",{signal:r});return n}for await(let[n]of Net(t,"message",{signal:r}))if(e(n))return n},Det=async(t,e,{signal:r})=>{await fq(t,"disconnect",{signal:r}),Cae(e)},ket=async(t,e,{signal:r})=>{let[n]=await fq(t,"strict:error",{signal:r});throw pA(n,e)};import{once as Hle,on as $et}from"events";var Vle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>dq({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),dq=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{jp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),_A(e,i);let o=il(t,e,r),a=new AbortController,c={};return Fet(t,o,a),Uet({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),qet({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},Fet=async(t,e,r)=>{try{await Hle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Uet=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await Hle(t,"strict:error",{signal:r.signal});n.error=pA(s,e),r.abort()}catch{}},qet=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of $et(r,"message",{signal:i.signal}))jle(o),yield c}catch{jle(o)}finally{i.abort(),yA(e,a),n||Hp(t),s&&await t}},jle=({error:t})=>{if(t)throw t};var zle=(t,{ipc:e})=>{Object.assign(t,Yle(t,!1,e))},Wle=()=>{let t=Gle,e=!0,r=Gle.channel!==void 0;return{...Yle(t,e,r),getCancelSignal:ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Yle=(t,e,r)=>({sendMessage:RA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Ble.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Vle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Bet}from"child_process";import{PassThrough as jet,Readable as Het,Writable as Vet,Duplex as Get}from"stream";var Kle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{rq(n);let a=new Bet;zet(a,n),Object.assign(a,{readable:Wet,writable:Yet,duplex:Ket});let c=Yp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=Jet(c,o,s);return{subprocess:a,promise:l}},zet=(t,e)=>{let r=sE(),n=sE(),s=sE(),i=Array.from({length:e.length-3},sE),o=sE(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},sE=()=>{let t=new jet;return t.end(),t},Wet=()=>new Het({read(){}}),Yet=()=>new Vet({write(){}}),Ket=()=>new Get({read(){},write(){}}),Jet=async(t,e,r)=>Kp(t,e,r);import{createReadStream as Jle,createWriteStream as Xle}from"fs";import{Buffer as Xet}from"buffer";import{Readable as iE,Writable as Qet,Duplex as Zet}from"stream";var Zle=(t,e)=>qA(ett,t,e,!1),oE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ol[t]}.`)},Qle={fileNumber:oE,generator:cq,asyncGenerator:cq,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zet.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ett={input:{...Qle,fileUrl:({value:t})=>({stream:Jle(t)}),filePath:({value:{file:t}})=>({stream:Jle(t)}),webStream:({value:t})=>({stream:iE.fromWeb(t)}),iterable:({value:t})=>({stream:iE.from(t)}),asyncIterable:({value:t})=>({stream:iE.from(t)}),string:({value:t})=>({stream:iE.from(t)}),uint8Array:({value:t})=>({stream:iE.from(Xet.from(t))})},output:{...Qle,fileUrl:({value:t})=>({stream:Xle(t)}),filePath:({value:{file:t,append:e}})=>({stream:Xle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Qet.fromWeb(t)}),iterable:oE,asyncIterable:oE,string:oE,uint8Array:oE}};import{on as ttt,once as eue}from"events";import{PassThrough as rtt,getDefaultHighWaterMark as ntt}from"stream";import{finished as nue}from"stream/promises";function bf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)pq(s);let e=t.some(({readableObjectMode:s})=>s),r=stt(t,e),n=new hq({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var stt=(t,e)=>{if(t.length===0)return ntt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},hq=class extends rtt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(pq(e),this.#e.has(e))return;this.#e.add(e),this.#n??=itt(this,this.#e,this.#i);let r=ctt({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(pq(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)}},itt=async(t,e,r)=>{WA(t,tue);let n=new AbortController;try{await Promise.race([ott(t,n),att(t,e,r,n)])}finally{n.abort(),WA(t,-tue)}},ott=async(t,{signal:e})=>{try{await nue(t,{signal:e,cleanup:!0})}catch(r){throw sue(t,r),r}},att=async(t,e,r,{signal:n})=>{for await(let[s]of ttt(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},pq=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ctt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{WA(t,rue);let a=new AbortController;try{await Promise.race([ltt(i,e,a),utt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),ftt({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),WA(t,-rue)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?mq(t):dtt(t))},ltt=async(t,e,{signal:r})=>{try{await t,r.aborted||mq(e)}catch(n){r.aborted||sue(e,n)}},utt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await nue(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;iue(o)?s.add(e):oue(t,o)}},ftt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await eue(t,s,{signal:i}),!t.readable)return eue(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},dtt=t=>{t.writable&&t.end()},sue=(t,e)=>{iue(e)?mq(t):oue(t,e)},iue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",mq=t=>{(t.readable||t.writable)&&t.destroy()},oue=(t,e)=>{t.destroyed||(t.once("error",htt),t.destroy(e))},htt=()=>{},WA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},tue=2,rue=1;import{finished as aue}from"stream/promises";var Xp=(t,e)=>{t.pipe(e),ptt(t,e),mtt(t,e)},ptt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(t,{cleanup:!0,readable:!0,writable:!1})}catch{}gq(e)}},gq=t=>{t.writable&&t.end()},mtt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(e,{cleanup:!0,readable:!1,writable:!0})}catch{}_q(t)}},_q=t=>{t.readable&&t.destroy()};var cue=(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})=>Bs.has(c)))gtt(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!Bs.has(c)))ytt({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]:bf(i);Xp(o,s)}},gtt=(t,e,r,n)=>{r==="output"?Xp(t.stdio[n],e):Xp(e,t.stdio[n]);let s=_tt[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},_tt=["stdin","stdout","stderr"],ytt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;Stt(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},Stt=(t,{signal:e})=>{mi(t)&&yf(t,Ett,e)},Ett=2;import{addAbortListener as vtt}from"events";var vf=[];vf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var YA=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",yq=Symbol.for("signal-exit emitter"),Sq=globalThis,Ttt=Object.defineProperty.bind(Object),Eq=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Sq[yq])return Sq[yq];Ttt(Sq,yq,{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}},KA=class{},btt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Tq=class extends KA{onExit(){return()=>{}}load(){}unload(){}},bq=class extends KA{#e=vq.platform==="win32"?"SIGINT":"SIGHUP";#r=new Eq;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of vf)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(!YA(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 vf)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,vf.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 YA(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"&&YA(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)}},vq=globalThis.process,{onExit:lue,load:gzt,unload:_zt}=btt(YA(vq)?new bq(vq):new Tq);var uue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=lue(()=>{t.kill()});vtt(n,()=>{s()})};var due=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=oA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=wtt(r,n,s),{sourceStream:f,sourceError:d}=Att(t,l),{options:h,fileDescriptors:p}=mo.get(t);return{sourcePromise:e,sourceStream:f,sourceOptions:h,sourceError:d,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},wtt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=Rtt(t,e,...r),a=gA(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},Rtt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(fue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||dU(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]=JR(r,...n);return{destination:e(fue)(s,i,o),pipeOptions:o}}if(mo.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}`)},fue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Att=(t,e)=>{try{return{sourceStream:Vp(t,e)}}catch(r){return{sourceError:r}}};var pue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Ctt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw wq({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Ctt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return _q(t),n;if(e!==void 0)return gq(r),e},wq=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yp({error:t,command:hue,escapedCommand:hue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),hue="source.pipe(destination)";var mue=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 Ott}from"stream/promises";var gue=(t,e,r)=>{let n=JA.has(e)?xtt(t,e):Ptt(t,e);return yf(t,Ntt,r.signal),yf(e,Mtt,r.signal),Itt(e),n},Ptt=(t,e)=>{let r=bf([t]);return Xp(r,e),JA.set(e,r),r},xtt=(t,e)=>{let r=JA.get(e);return r.add(t),r},Itt=async t=>{try{await Ott(t,{cleanup:!0,readable:!1,writable:!0})}catch{}JA.delete(t)},JA=new WeakMap,Ntt=2,Mtt=1;import{aborted as Ltt}from"util";var _ue=(t,e)=>t===void 0?[]:[Dtt(t,e)],Dtt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await Ltt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw wq({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var XA=(t,...e)=>{if(Jt(e[0]))return XA.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=due(t,...e),s=ktt({...n,destination:r});return s.pipe=XA.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},ktt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=$tt(t,s);pue({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let f=new AbortController;try{let d=gue(e,i,f);return await Promise.race([mue(u),..._ue(a,{sourceStream:e,mergedStream:d,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{f.abort()}},$tt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Vtt}from"timers/promises";import{on as Ftt}from"events";import{getDefaultHighWaterMark as Utt}from"stream";var QA=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return qtt(e,o),Sue({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},qtt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Rq=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Btt(e,o,t);let a=t.readableObjectMode&&!i;return Sue({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Btt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Sue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Ftt(t,"data",{signal:e.signal,highWaterMark:yue,highWatermark:yue});return jtt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},Aq=Utt(!0),yue=Aq,jtt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Htt({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*Tf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*nE(a)}},Htt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[jA(t,r,!e),BA(t,s,!n,{})].filter(Boolean);var Eue=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let f=Gtt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([ztt(t),f]);return}let d=nq(c,r),h=Rq({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:d,allMixed:a}),[p]=await Promise.all([Wtt({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),f]);return p},Gtt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!GA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=Rq({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await Ile(a,t,r,i)},ztt=async t=>{await Vtt(),t.readableFlowing===null&&t.resume()},Wtt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await NA(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await MA(r,{maxBuffer:i})):await Wp(r,{maxBuffer:i})}catch(a){return Tue(Ice({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},Cq=async t=>{try{return await t}catch(e){return Tue(e)}},Tue=({bufferedData:t})=>Wie(t)?new Uint8Array(t):t;import{finished as Ytt}from"stream/promises";var aE=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ktt(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ytt(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Qtt(a,e,r,n)}finally{o.abort()}},Ktt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Jtt(t,r,n),n},Jtt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Xtt(e,r),n.call(t,...s)}},Xtt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Qtt=(t,e,r,n)=>{if(!Ztt(t,e,r,n))throw t},Ztt=(t,e,r,n=!0)=>r.propagating?bue(t)||ZA(t):(r.propagating=!0,Oq(r,e)===n?bue(t):ZA(t)),Oq=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ZA=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",bue=t=>t?.code==="EPIPE";var vue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Pq({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),Pq=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=aE(t,e,l);if(Oq(l,e)){await u;return}let[f]=await Promise.all([Eue({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return f};var wue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bf([t,e].filter(Boolean)):void 0,Rue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>Pq({...ert(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:trt(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),ert=({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}},trt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as rrt}from"events";var Aue=t=>Up(t,"ipc"),Cue=(t,e)=>{let r=iA(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Oue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=Aue(i),a=Ra(e,"ipc"),c=Ra(r,"ipc");for await(let l of dq({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Nce(t,s,c),s.push(l)),o&&Cue(l,i);return s},Pue=async(t,e)=>(await Promise.allSettled([t]),e);var xue=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:f},context:d,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:g,controller:y})=>{let T=kle(t,d),S={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:T,propagating:!1},_=vue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),A=Rue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),P=[],C=Oue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:h}),R=nrt(m,t,S),O=srt(p,S);try{return await Promise.race([Promise.all([{},Fle(T),Promise.all(_),A,C,uce(t,f),...R,...O]),g,irt(t,y),...ice(t,i,d,y),...Aae({subprocess:t,cancelSignal:o,gracefulCancel:a,context:d,controller:y}),...nce({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:d,controller:y})])}catch(w){return d.terminationReason??="other",Promise.all([{error:w},T,Promise.all(_.map(b=>Cq(b))),Cq(A),Pue(C,P),Promise.allSettled(R),Promise.allSettled(O)])}},nrt=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:aE(n,s,r)),srt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>yi(i,{checkOpen:!1})&&!mi(i)).map(({type:s,value:i,stream:o=i})=>aE(o,n,e,{isSameDirection:Bs.has(s),stopOnExit:s==="native"}))),irt=async(t,{signal:e})=>{let[r]=await rrt(t,"error",{signal:e});throw r};var Iue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),cE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=po();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Qp=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 ort}from"stream";import{callbackify as art}from"util";import{finished as Nue}from"stream/promises";var xq=async t=>{if(t!==void 0)try{await Iq(t)}catch{}},Mue=async t=>{if(t!==void 0)try{await Nq(t)}catch{}},Iq=async t=>{await Nue(t,{cleanup:!0,readable:!1,writable:!0})},Nq=async t=>{await Nue(t,{cleanup:!0,readable:!0,writable:!1})},eC=async(t,e)=>{if(await t,e)throw e},tC=(t,e,r)=>{r&&!ZA(r)?t.destroy(r):e&&t.destroy()};var Lue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Mq(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:f}=Lq(a,o),{read:d,onStdoutDataDone:h}=Dq({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new ort({read:d,destroy:art($q.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:f,objectMode:u,encoding:l});return kq({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},Mq=(t,e,r)=>{let n=Vp(t,e),s=cE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},Lq=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Aq},Dq=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=po(),o=QA({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){crt(this,o,i)},onStdoutDataDone:i}},crt=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},kq=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await Nq(t),await n,await xq(s),await e,r.readable&&r.push(null)}catch(i){await xq(s),Due(r,i)}},$q=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qp(r,e)&&(Due(t,n),await eC(e,n))},Due=(t,e)=>{tC(t,t.readable,e)};import{Writable as lrt}from"stream";import{callbackify as kue}from"util";var $ue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=Fq(t,r,e),o=new lrt({...Uq(n,t,s),destroy:kue(Bq.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qq(n,o),o},Fq=(t,e,r)=>{let n=gA(t,e),s=cE(r,n,"writableFinal"),i=cE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},Uq=(t,e,r)=>({write:urt.bind(void 0,t),final:kue(frt.bind(void 0,t,e,r))}),urt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},frt=async(t,e,r)=>{await Qp(r,e)&&(t.writable&&t.end(),await e)},qq=async(t,e,r)=>{try{await Iq(t),e.writable&&e.end()}catch(n){await Mue(r),Fue(e,n)}},Bq=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Qp(r,e),await Qp(n,e)&&(Fue(t,s),await eC(e,s))},Fue=(t,e)=>{tC(t,t.writable,e)};import{Duplex as drt}from"stream";import{callbackify as hrt}from"util";var Uue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||ts.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Mq(t,n,e),{subprocessStdin:u,waitWritableFinal:f,waitWritableDestroy:d}=Fq(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=Lq(c,a),{read:g,onStdoutDataDone:y}=Dq({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),T=new drt({read:g,...Uq(u,t,f),destroy:hrt(prt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:f,waitWritableDestroy:d})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return kq({subprocessStdout:c,onStdoutDataDone:y,readable:T,subprocess:t,subprocessStdin:u}),qq(u,T,c),T},prt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([$q({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Bq({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var jq=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||ts.has(e),o=Vp(t,r),a=QA({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return mrt(a,o,t)},mrt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var que=(t,{encoding:e})=>{let r=Iue();t.readable=Lue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=jq.bind(void 0,t,e),t[Symbol.asyncIterator]=jq.bind(void 0,t,e,{})};var Bue=(t,e)=>{for(let[r,n]of _rt){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},grt=(async()=>{})().constructor.prototype,_rt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(grt,t)]);var jue=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:f}=Ert(t,e,r),{subprocess:d,promise:h}=brt({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:f});return d.pipe=XA.bind(void 0,{source:d,sourcePromise:h,boundOptions:{},createNested:n}),Bue(d,h),mo.set(d,{options:u,fileDescriptors:f}),d},Ert=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),{file:a,commandArguments:c,options:l}=CA(t,e,r),u=Trt(l),f=Zle(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Trt=({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}},brt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Srt(...OA(t,e,r))}catch(p){return Kle({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;yrt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];cue(c,a,l),uue(c,r,l);let f={},d=po();c.kill=wae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:d,context:f,controller:l}),c.all=wue(c,r),que(c,r),zle(c,r);let h=vrt({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:f,onInternalError:d,controller:l});return{subprocess:c,promise:h}},vrt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[f,[d,h],p,m,g]=await xue({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let y=p.map((_,A)=>Ca(_,e,A)),T=Ca(m,e,"all"),S=wrt({errorInfo:f,exitCode:d,signal:h,stdio:y,all:T,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Kp(S,n,e)},wrt=({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?rE({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 go,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):kA({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var rC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Rrt(n,t[n],s)]));return{...t,...r}},Rrt=(t,e,r)=>Art.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,Art=new Set(["env",...yU]);var al=(t,e,r,n)=>{let s=(o,a,c)=>al(o,a,r,c),i=(...o)=>Crt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Crt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(Jt(i))return s(t,rC(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Ort({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?qle(a,c,l):jue(a,c,l,s)},Ort=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Zie(e)?eoe(e,r):[e,...r],[o,a,c]=JR(...i),l=rC(rC(n,s),c),{file:u=o,commandArguments:f=a,options:d=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:f,options:d,isSync:h}};var Hue=({file:t,commandArguments:e})=>Gue(t,e),Vue=({file:t,commandArguments:e})=>({...Gue(t,e),isSync:!0}),Gue=(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]=Prt(t);return{file:r,commandArguments:n}},Prt=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(xrt)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},xrt=/ +/g;var zue=(t,e,r)=>{t.sync=e(Irt,r),t.s=t.sync},Wue=({options:t})=>Yue(t),Irt=({options:t})=>({...Yue(t),isSync:!0}),Yue=t=>({options:{...Nrt(t),...t}}),Nrt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Kue={preferLocal:!0};var Jue=al(()=>({})),oWt=al(()=>({isSync:!0})),Xue=al(Hue),aWt=al(Vue),cWt=al(ace),lWt=al(Wue,{},Kue,zue),{sendMessage:uWt,getOneMessage:fWt,getEachMessage:dWt,getCancelSignal:hWt}=Wle();import{Transform as Mrt}from"stream";var Lrt=["NETLIFY_AI_GATEWAY_KEY"];function Drt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Lrt])]}function krt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $rt(){let e=Drt().map(r=>process.env[r]).filter(r=>!(!r||krt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function js(t){if(typeof t!="string")return t;let e=$rt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let s=new RegExp(Frt(n),"g");r=r.replace(s,"******")}),r}function Frt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var lE=class extends Mrt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let s=e.toString(),i=js(s);n(null,i)}},nC=Symbol("maskedWrite");function Que(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[nC]){let e=process.stdout.write.bind(process.stdout),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stdout.write=r}if(!process.stderr.write[nC]){let e=process.stderr.write.bind(process.stderr),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stderr.write=r}}}var Zue=!1,efe=()=>{Zue=!0},Fn=()=>Zue;var uE=null,tfe=t=>(uE&&uE.destroy(),uE=new Oa({totalAllowedTime:t}),uE),rfe=()=>uE;var Oa=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&&Fn())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,f)=>{o=setTimeout(()=>{f(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await YR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Oe.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 nfe={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.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 jrt=qrt(import.meta.url),Hrt=Pa.dirname(jrt),Vrt=Brt(import.meta.url),Zp=Te("shell"),Hq=new Set,sfe={preferLocal:!0},rs=(t,e,r)=>{let[n,s]=Grt(e,r),i={...sfe,...s},o=Jue(t,n,i);ofe(o,i),lfe(o);let a=r?.idleTimeout;return a&&a>0&&cfe(o,a),o},ife=(t,e)=>{let r={...sfe,...e},n=Xue(t,r);return ofe(n,r),lfe(n),e?.idleTimeout&&e.idleTimeout>0&&cfe(n,e.idleTimeout),n},Grt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ofe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(xa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new lE).pipe(xa.stdout),t.stderr?.pipe(new lE).pipe(xa.stderr);return}t.stdout?.pipe(xa.stdout),t.stderr?.pipe(xa.stderr)},Vq=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xa.kill(-t.pid,e),Zp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zp.error("Error killing process:",r),!1}},afe=t=>Vq(t,"SIGKILL"),cfe=(t,e)=>{let r=null,n=()=>{Zp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing idle process ${t.pid}`),afe(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)},lfe=t=>{Hq.add(t);let e=rfe();if(e){let r=e.onTimesUp(()=>{Zp.log(`Global timer expired, killing process ${t.pid}`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing process ${t.pid} after timeout`),afe(t))},5e3)});t.on("exit",()=>{Hq.delete(t),r()}),t.on("error",()=>{Hq.delete(t),r()})}};function cl(t,e){if(!xa.env.NETLIFY_LOCAL_MODE)try{let s=Vrt.resolve(nfe.name),i=Pa.dirname(s);for(;i!==Pa.dirname(i);){let o=Pa.dirname(i);if(Pa.basename(o)==="node_modules"){let a=Pa.join(o,".bin",e);if(sC.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(xa.env.NODE_PATH){let s=Pa.join(xa.env.NODE_PATH,".bin",e);if(sC.existsSync(s))return s}let r=Pa.join(t,"node_modules",".bin",e);if(sC.existsSync(r))return r;let n=Pa.join(Hrt,"..","node_modules",".bin",e);if(sC.existsSync(n))return n}import cI from"process";import{fileURLToPath as Mgt}from"url";import{createRequire as Lgt}from"module";import lI from"path";var zrt="__netlify__getTracer",Wrt="__netlify__shutdownTracers",Ze=(t,e)=>globalThis[zrt]?.(t,e),ufe=async()=>globalThis[Wrt]?.();function wf(t,e,r,n,s){let i=typeof n=="function"?n:typeof r=="function"?r:s;if(!i)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,i):i()}import{setTimeout as Ogt}from"timers/promises";import Hst from"process";var ffe=typeof globalThis=="object"?globalThis:global;var Ia="1.9.0";var dfe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Yrt(t){var e=new Set([t]),r=new Set,n=t.match(dfe);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(dfe);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var hfe=Yrt(Ia);var Krt=Ia.split(".")[0],fE=Symbol.for("opentelemetry.js.api."+Krt),dE=ffe;function ll(t,e,r,n){var s;n===void 0&&(n=!1);var i=dE[fE]=(s=dE[fE])!==null&&s!==void 0?s:{version:Ia};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==Ia){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+Ia);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ia+"."),!0}function Si(t){var e,r,n=(e=dE[fE])===null||e===void 0?void 0:e.version;if(!(!n||!hfe(n)))return(r=dE[fE])===null||r===void 0?void 0:r[t]}function ul(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ia+".");var r=dE[fE];r&&delete r[t]}var Jrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Xrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},pfe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("verbose",this._namespace,e)},t})();function hE(t,e,r){var n=Si("diag");if(n)return r.unshift(e),n[t].apply(n,Xrt([],Jrt(r),!1))}var yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(yn||(yn={}));function mfe(t,e){t<yn.NONE?t=yn.NONE:t>yn.ALL&&(t=yn.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",yn.ERROR),warn:r("warn",yn.WARN),info:r("info",yn.INFO),debug:r("debug",yn.DEBUG),verbose:r("verbose",yn.VERBOSE)}}var Qrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Zrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},ent="diag",ns=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Si("diag");if(a)return a[s].apply(a,Zrt([],Qrt(i),!1))}}var r=this,n=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:yn.INFO}),s===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof i=="number"&&(i={logLevel:i});var u=Si("diag"),f=mfe((a=i.logLevel)!==null&&a!==void 0?a:yn.INFO,s);if(u&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ll("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ul(ent,r)},r.createComponentLogger=function(s){return new pfe(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var tnt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},rnt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},gfe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=tnt(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=rnt(n),a=o.next();!a.done;a=o.next()){var c=a.value;i._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();var rYt=ns.instance();function _fe(t){return t===void 0&&(t={}),new gfe(new Map(Object.entries(t)))}function iC(t){return Symbol.for(t)}var nnt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),yfe=new nnt;var Sfe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Efe={set:function(t,e,r){t!=null&&(t[e]=r)}};var snt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},int=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Tfe=(function(){function t(){}return t.prototype.active=function(){return yfe},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,int([n],snt(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var ont=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},ant=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Gq="context",cnt=new Tfe,fl=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ll(Gq,e,ns.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,ant([e,r,n],ont(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Si(Gq)||cnt},t.prototype.disable=function(){this._getContextManager().disable(),ul(Gq,ns.instance())},t})();var oC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(oC||(oC={}));var zq="0000000000000000",Wq="00000000000000000000000000000000",bfe={traceId:Wq,spanId:zq,traceFlags:oC.NONE};var dl=(function(){function t(e){e===void 0&&(e=bfe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var Yq=iC("OpenTelemetry Context Key SPAN");function aC(t){return t.getValue(Yq)||void 0}function vfe(){return aC(fl.getInstance().active())}function pE(t,e){return t.setValue(Yq,e)}function wfe(t){return t.deleteValue(Yq)}function Rfe(t,e){return pE(t,new dl(e))}function cC(t){var e;return(e=aC(t))===null||e===void 0?void 0:e.spanContext()}var lnt=/^([0-9a-f]{32})$/i,unt=/^[0-9a-f]{16}$/i;function fnt(t){return lnt.test(t)&&t!==Wq}function dnt(t){return unt.test(t)&&t!==zq}function lC(t){return fnt(t.traceId)&&dnt(t.spanId)}function Afe(t){return new dl(t)}var Kq=fl.getInstance(),uC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=Kq.active());var s=!!r?.root;if(s)return new dl;var i=n&&cC(n);return hnt(i)&&lC(i)?new dl(i):new dl},t.prototype.startActiveSpan=function(e,r,n,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(i=r,a=n):(i=r,o=n,a=s);var c=o??Kq.active(),l=this.startSpan(e,i,c),u=pE(c,l);return Kq.with(u,a,void 0,l)}},t})();function hnt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var pnt=new uC,Cfe=(function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):pnt},t})();var Ofe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new uC},t})();var mnt=new Ofe,Jq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new Cfe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:mnt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t})();var hl;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(hl||(hl={}));var yo;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(yo||(yo={}));var Na=fl.getInstance();var Xq=ns.instance();var Pfe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Qq=iC("OpenTelemetry Baggage Key");function Zq(t){return t.getValue(Qq)||void 0}function xfe(){return Zq(fl.getInstance().active())}function Ife(t,e){return t.setValue(Qq,e)}function Nfe(t){return t.deleteValue(Qq)}var eB="propagation",gnt=new Pfe,Mfe=(function(){function t(){this.createBaggage=_fe,this.getBaggage=Zq,this.getActiveBaggage=xfe,this.setBaggage=Ife,this.deleteBaggage=Nfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ll(eB,e,ns.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Efe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Sfe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ul(eB,ns.instance())},t.prototype._getGlobalPropagator=function(){return Si(eB)||gnt},t})();var mE=Mfe.getInstance();var tB="trace",Lfe=(function(){function t(){this._proxyTracerProvider=new Jq,this.wrapSpanContext=Afe,this.isSpanContextValid=lC,this.deleteSpan=wfe,this.getSpan=aC,this.getActiveSpan=vfe,this.getSpanContext=cC,this.setSpan=pE,this.setSpanContext=Rfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=ll(tB,this._proxyTracerProvider,ns.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return Si(tB)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){ul(tB,ns.instance()),this._proxyTracerProvider=new Jq},t})();var gE=Lfe.getInstance();var ynt=function(t,e){e.recordException(t),e.setStatus({code:yo.ERROR})};var Rf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return kfe(l,o,c)})},t.prototype.withSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn,l=this._tracer.startSpan(e,o,a);return kfe(l,o,c)},t})();function Dfe(t,e,r){var n,s,i;return!e&&!r?i=t:r?(n=t,s=e,i=r):(n=t,i=e),n=n??{},s=s??Na.active(),{opts:n,ctx:s,fn:i}}function kfe(t,e,r){var n,s=(n=e.onException)!==null&&n!==void 0?n:ynt,i=function(a){throw s(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},i):(t.end(),o)}catch(a){throw i(a)}}QB();He();var BE=class{emit(e){}enabled(){return!1}},Khe=new BE;var jE=Symbol.for("io.opentelemetry.js.api.logs"),lm=globalThis;function Jhe(t,e,r){return n=>n===t?e:r}var ZB=1;var ej=class{getLogger(e,r,n){return new BE}},tO=new ej;var rO=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Khe}};var HE=class{getLogger(e,r,n){var s;return(s=this._getDelegateLogger(e,r,n))!==null&&s!==void 0?s:new rO(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tO}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(e,r,n)}};var nO=class t{constructor(){this._proxyLoggerProvider=new HE}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return lm[jE]?this.getLoggerProvider():(lm[jE]=Jhe(ZB,e,tO),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=lm[jE])===null||e===void 0?void 0:e.call(lm,ZB))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete lm[jE],this._proxyLoggerProvider=new HE}};var Xhe=nO.getInstance();function Qhe(t,e,r,n){for(let s=0,i=t.length;s<i;s++){let o=t[s];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function Zhe(t){t.forEach(e=>e.disable())}function tj(t){let e=t.tracerProvider||lr.getTracerProvider(),r=t.meterProvider||CE.getMeterProvider(),n=t.loggerProvider||Xhe.getLoggerProvider(),s=t.instrumentations?.flat()??[];return Qhe(s,e,r,n),()=>{Zhe(s)}}Vt();var RO=fn(_j(),1);Vt();var Npe=t=>{throw TypeError(t)},Tj=(t,e,r)=>e.has(t)||Npe("Cannot "+r),wO=(t,e,r)=>(Tj(t,e,"read from private field"),r?r.call(t):e.get(t)),yj=(t,e,r)=>e.has(t)?Npe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Ppe=(t,e,r,n)=>(Tj(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),jst=(t,e,r)=>(Tj(t,e,"access private method"),r),xpe="__netlify__getTracer",Vst="__netlify__shutdownTracers",Gst="__nfOTLPTrace",GE,zE,Ej,Mpe,zst=class{constructor(){yj(this,Ej),yj(this,GE),yj(this,zE),Ppe(this,GE,new Ro(jst(this,Ej,Mpe),this)),Ppe(this,zE,Xq.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(wO(this,zE).debug(`export ${t.length.toString()} spans`),wO(this,GE).isCalled){e({code:It.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Gst,JSON.stringify(Wst(t))),e({code:It.SUCCESS})}shutdown(){return wO(this,GE).call()}};GE=new WeakMap;zE=new WeakMap;Ej=new WeakSet;Mpe=function(){return wO(this,zE).debug("Shutting down"),Promise.resolve()};function Wst(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:vO(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||hl.SERVER,startTimeUnixNano:Sj(e.startTime),endTimeUnixNano:Sj(e.endTime),attributes:vO(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Sj(n.time),attributes:vO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:vO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function vO(t){return Object.keys(t).map(e=>Lpe(e,t[e]))}function Lpe(t,e){return{key:t,value:Dpe(e)}}function Dpe(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Dpe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Lpe(r,n))}}:{}}function Sj(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Ipe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},kpe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,xpe))return;let e=Hst.version.slice(1),r=eO({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Yst()],s=new RO.NodeTracerProvider({resource:r,spanProcessors:n});s.register({propagator:new $a});let i=t.instrumentations??[];tj({instrumentations:i,tracerProvider:s}),Object.defineProperty(globalThis,xpe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Rf(gE.getTracer(a,c)):new Rf(gE.getTracer(Ipe.name,Ipe.version))}}),Object.defineProperty(globalThis,Vst,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await s.shutdown()})},Yst=()=>new RO.SimpleSpanProcessor(new zst);Vt();var WE=fn(_j(),1);import*as AO from"diagnostics_channel";var $pe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?yo.ERROR:yo.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],s=this.config.redactHeaders??[],i=n.some(a=>r.includes(a.toString())),o={};if(i)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(d=>typeof d=="string"?d==u:d.test(u)))continue;let f=`http.${t}.header.${u}`;s===!0||s.some(d=>typeof d=="string"?d==u:d.test(u))?o[f]="REDACTED":o[f]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Rf?t:new Rf(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){AO.subscribe(t,e);let r=()=>AO.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(s=>typeof s=="string"?r.href.startsWith(s):s.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:hl.CLIENT},Na.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:yo.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var KTe=fn(WTe(),1);var oI=Te("tracing"),YTe=8e3,Pgt=5e3,ob=async(t=Pgt)=>{try{await Promise.race([ufe(),Ogt(t)])}catch(e){oI.warn("Failed to flush tracers on shutdown",e)}},JTe=async(t,e,r)=>{if(!Ze()){let n=[new WE.SimpleSpanProcessor(new iz),new WE.SimpleSpanProcessor(new KTe.OTLPTraceExporter({url:r.exporterUrl}))];await kpe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new $pe({skipHeaders:!0})]})}return r.traceparent?(mE.setGlobalPropagator(new $a),mE.extract(Na.active(),{traceparent:r.traceparent,isRemote:!0})):Na.active()};function yt(t,e,r){return oI.log(`\u23F3 TRACE: ${e} starting...`),wf(t,e,r)}var iz=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,s=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?s.push(`${a}=${c.toFixed(2)}ms`):s.push(`${a}=${c}`);let i=e.status?.code===2?"\u274C":"\u2705",o=s.length>0?` [${s.join(", ")}]`:"";oI.log(`${i} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&oI.log(` \u274C Error: ${e.status.message}`)}};function oz(){return process.env.AGENT_RUNNER_CAPTURE_LLM_CONTENT!=="false"}function XTe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function aI(t,e,r){let n={role:t,parts:[{type:"text",content:js(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function QTe(t,e,r,n){if(!t.length)return;let s=Ze();if(!s)return;let i=oz(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),f=a.title||a.type||`step-${a.id??c}`,d=a.type==="tool_use"||a.type==="tool_result",h=a.message?a.message.length>YTe?`${a.message.slice(0,YTe)}\u2026`:a.message:void 0;s.startSpan(f,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":f,"gen_ai.operation.name":d?"execute_tool":"chat",...d?{"gen_ai.tool.name":f}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...i&&h?d?{"gen_ai.tool.call.result":js(h)}:{"gen_ai.output.messages":aI("assistant",h)}:{}}}).end(u)})}import{readdir as xgt,rm as Igt}from"fs/promises";import{join as Ngt}from"path";async function ZTe(t,e=[]){let n=(await xgt(t)).filter(s=>!e.includes(s));await Promise.all(n.map(s=>Igt(Ngt(t,s),{recursive:!0,force:!0})))}var Dgt=lI.dirname(Mgt(import.meta.url)),ebe=Lgt(import.meta.url),kgt=lI.resolve(Dgt,"scripts/scaffold.js"),$gt="scripts/scaffold.js",Fgt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,az=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},Ugt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),qgt=t=>{let e=az(t);return e==="node"||e.endsWith("/node")},cd=t=>{if(typeof t!="string")return!1;let e=t.match(Fgt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Ugt(az(e[r]));)r+=1;if(r>=e.length||!qgt(e[r]))return!1;let n=e[r+1];return n?az(n).includes($gt):!1},ab=Te("create_stage"),Bgt="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.\n\nCommands that generate or modify project files are fine to run when the task requires them \u2014 for example `drizzle-kit generate` to write a database migration after a schema change, or other code-generation utilities documented in the skills.",jgt="./.netlify-cache",Hgt=({cwd:t=cI.cwd()}={})=>{let e=cI.env.NVM_BIN?`${cI.env.NVM_BIN}/node`:"node",r;try{let n=ebe.resolve("@netlify/ts-cli/package.json"),s=lI.dirname(n),i=ebe("@netlify/ts-cli/package.json");r=lI.join(s,i.bin)}catch{r=cl(t,"ts-cli")}return{nodeCmd:e,tsCliPath:r}},Vgt=t=>{let e;try{if(!t)throw new Error("empty response");e=JSON.parse(t)}catch(r){return ab.error("Failed to parse template list from ts-cli",{raw:t,error:r.message}),Oe.inc("context.degraded",1,{component:"templates"}),[]}return e.filter(r=>r.type==="example").map(r=>{let{type:n,...s}=r;return s})},Ggt=({templates:t,nodeCmd:e,scaffoldScriptPath:r})=>{let n=JSON.stringify(t.map(({id:i,name:o,description:a})=>({id:i,name:o,description:a})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",t.length>0?`## Available Templates
505
505
 
506
506
  Start with one of the following templates by using the Bash command below, unless there's a strong reason to start from scratch based on the users prompt.
507
507
 
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
85
85
  `,LF:`
86
86
  `,concatBytes:lI},mye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},gye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:mye};import{Buffer as _ye}from"buffer";var E4=(t,e)=>t?void 0:Sye.bind(void 0,e),Sye=function*(t,e){if(typeof e!="string"&&!_t(e)&&!_ye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},y4=(t,e)=>t?Eye.bind(void 0,e):yye.bind(void 0,e),Eye=function*(t,e){T4(t,e),yield e},yye=function*(t,e){if(T4(t,e),typeof e!="string"&&!_t(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},T4=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
87
87
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
88
- if (condition) { yield value; }`)};import{Buffer as Tye}from"buffer";import{StringDecoder as bye}from"string_decoder";var YT=(t,e,r)=>{if(r)return;if(t)return{transform:Aye.bind(void 0,new TextEncoder)};let n=new bye(e);return{transform:vye.bind(void 0,n),final:wye.bind(void 0,n)}},Aye=function*(t,e){Tye.isBuffer(e)?yield Si(e):typeof e=="string"?yield t.encode(e):yield e},vye=function*(t,e){yield _t(e)?t.write(e):e},wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as b4}from"util";var dI=b4(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=Cye}=e[r];for await(let s of n(t))yield*KT(s,e,r+1)},A4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Rye(r,Number(e),t)},Rye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KT(n,r,e+1)},v4=b4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Cye=function*(t){yield t};var fI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},w4=(t,e)=>[...e.flatMap(r=>[...hc(r,t,0)]),...cm(t)],hc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Pye}=e[r];for(let s of n(t))yield*hc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*xye(r,Number(e),t)},xye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*hc(n,r,e+1)},Pye=function*(t){yield t};var hI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=C4(t,o,i),l=fc(e),u=fc(r),d=l?dI.bind(void 0,KT,a):fI.bind(void 0,hc),f=l||u?dI.bind(void 0,A4,a):fI.bind(void 0,cm),h=l||u?v4.bind(void 0,a):void 0;return{stream:new Oye({writableObjectMode:n,writableHighWaterMark:R4(n),readableObjectMode:s,readableHighWaterMark:R4(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=C4(o,r,a);t=w4(c,t)}return t},C4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:E4(n,a)},YT(r,o,n),zT(r,i,n,c),{transform:t,final:e},{transform:y4(s,a)},S4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var x4=(t,e)=>{for(let r of Iye(t))Nye(t,r,e)},Iye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Nye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Po[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Mye(a,n));r.input=Jp(o)},Mye=(t,e)=>{let r=XT(t,e,"utf8",!0);return Lye(r),Jp(r)},Lye=t=>{let e=t.find(r=>typeof r!="string"&&!_t(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 Fye,appendFileSync as Bye}from"fs";var QT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&vu(r,n)&&!Dr.has(e)&&Dye(n)&&(t.some(({type:s,value:i})=>s==="native"&&kye.has(i))||t.every(({type:s})=>dn.has(s))),Dye=t=>t===1||t===2,kye=new Set(["pipe","overlapped"]),P4=async(t,e,r,n)=>{for await(let s of t)Uye(e)||I4(s,r,n)},O4=(t,e,r)=>{for(let n of t)I4(n,e,r)},Uye=t=>t._readableState.pipes.length>0,I4=(t,e,r)=>{let n=dT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var N4=({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)=>$ye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},$ye=({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=MY(t,i,d),h=Si(f),{stdioItems:p,objectMode:m}=e[r],E=Gye([h],p,c,n),{serializedResult:S,finalResult:b=S}=qye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Hye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&Vye(S,p,s),R}catch(A){return n.error=A,R}},Gye=(t,e,r,n)=>{try{return XT(t,e,r,!1)}catch(s){return n.error=s,t}},qye=({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=z3(t,r);return n[i]?{serializedResult:o,finalResult:uI(o,!s[i],e)}:{serializedResult:o}},Hye=({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=uI(t,!1,o);try{O4(a,e,n)}catch(c){r.error??=c}},Vye=(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)?Bye(n,t):(r.add(i),Fye(n,t))}};var M4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ti(e,r,"all")]:Array.isArray(e)?[Ti(t,r,"all"),...e]:_t(t)&&_t(e)?EO([t,e]):`${t}${e}`};import{once as pI}from"events";var L4=async(t,e)=>{let[r,n]=await jye(t);return e.isForcefullyTerminated??=!1,[r,n]},jye=async t=>{let[e,r]=await Promise.allSettled([pI(t,"spawn"),pI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?D4(t):r.value},D4=async t=>{try{return await pI(t,"exit")}catch{return D4(t)}},k4=async t=>{let[e,r]=await t;if(!Wye(e,r)&&mI(e,r))throw new qn;return[e,r]},Wye=(t,e)=>t===void 0&&e===void 0,mI=(t,e)=>t!==0||e!==null;var U4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=zye(t,e,r),o=i?.code==="ETIMEDOUT",a=NY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},zye=(t,e,r)=>t!==void 0?t:mI(e,r)?new qn:void 0;var F4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Kye(t,e,r),d=Jye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Lu(d,c,l)},Kye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),a=Xye(r),{file:c,commandArguments:l,options:u}=MT(t,e,a);Qye(u);let d=p4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Xye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Qye=({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.`)},Jye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Zye({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}=U4(c,r),{output:p,error:m=l}=N4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,R)=>Ti(b,r,R)),S=Ti(M4(p,r),r,"all");return tTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Zye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{x4(i,r);let a=eTe(r);return Yye(...LT(t,e,a))}catch(a){return Mu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},eTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GT(e)}),tTe=({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 qbe}from"events";import{spawn as Hbe}from"child_process";import H4 from"process";import{once as gI,on as rTe}from"events";var B4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Cu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),nTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),nTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{AT(e,s);let i=xo(t,e,r),o=new AbortController;try{return await Promise.race([sTe(i,n,o),iTe(i,r,o),oTe(i,r,o)])}catch(a){throw xu(t),a}finally{o.abort(),vT(e,s)}},sTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gI(t,"message",{signal:r});return n}for await(let[n]of rTe(t,"message",{signal:r}))if(e(n))return n},iTe=async(t,e,{signal:r})=>{await gI(t,"disconnect",{signal:r}),wz(e)},oTe=async(t,e,{signal:r})=>{let[n]=await gI(t,"strict:error",{signal:r});throw yT(n,e)};import{once as G4,on as aTe}from"events";var q4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>_I({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),_I=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Cu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),AT(e,i);let o=xo(t,e,r),a=new AbortController,c={};return cTe(t,o,a),lTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),uTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},cTe=async(t,e,r)=>{try{await G4(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},lTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await G4(t,"strict:error",{signal:r.signal});n.error=yT(s,e),r.abort()}catch{}},uTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of aTe(r,"message",{signal:i.signal}))$4(o),yield c}catch{$4(o)}finally{i.abort(),vT(e,a),n||xu(t),s&&await t}},$4=({error:t})=>{if(t)throw t};var V4=(t,{ipc:e})=>{Object.assign(t,W4(t,!1,e))},j4=()=>{let t=H4,e=!0,r=H4.channel!==void 0;return{...W4(t,e,r),getCancelSignal:Jz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},W4=(t,e,r)=>({sendMessage:IT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:B4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:q4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as dTe}from"child_process";import{PassThrough as fTe,Readable as hTe,Writable as pTe,Duplex as mTe}from"stream";var z4=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{aI(n);let a=new dTe;gTe(a,n),Object.assign(a,{readable:_Te,writable:STe,duplex:ETe});let c=Mu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=yTe(c,o,s);return{subprocess:a,promise:l}},gTe=(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 fTe;return t.end(),t},_Te=()=>new hTe({read(){}}),STe=()=>new pTe({write(){}}),ETe=()=>new mTe({read(){},write(){}}),yTe=async(t,e,r)=>Lu(t,e,r);import{createReadStream as Y4,createWriteStream as K4}from"fs";import{Buffer as TTe}from"buffer";import{Readable as um,Writable as bTe,Duplex as ATe}from"stream";var Q4=(t,e)=>WT(vTe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Po[t]}.`)},X4={fileNumber:dm,generator:hI,asyncGenerator:hI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ATe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vTe={input:{...X4,fileUrl:({value:t})=>({stream:Y4(t)}),filePath:({value:{file:t}})=>({stream:Y4(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(TTe.from(t))})},output:{...X4,fileUrl:({value:t})=>({stream:K4(t)}),filePath:({value:{file:t,append:e}})=>({stream:K4(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:bTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as wTe,once as J4}from"events";import{PassThrough as RTe,getDefaultHighWaterMark as CTe}from"stream";import{finished as t6}from"stream/promises";function pc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)EI(s);let e=t.some(({readableObjectMode:s})=>s),r=xTe(t,e),n=new SI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var xTe=(t,e)=>{if(t.length===0)return CTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SI=class extends RTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(EI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=PTe(this,this.#e,this.#i);let r=NTe({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(EI(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)}},PTe=async(t,e,r)=>{ZT(t,Z4);let n=new AbortController;try{await Promise.race([OTe(t,n),ITe(t,e,r,n)])}finally{n.abort(),ZT(t,-Z4)}},OTe=async(t,{signal:e})=>{try{await t6(t,{signal:e,cleanup:!0})}catch(r){throw r6(t,r),r}},ITe=async(t,e,r,{signal:n})=>{for await(let[s]of wTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},EI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},NTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{ZT(t,e6);let a=new AbortController;try{await Promise.race([MTe(i,e,a),LTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),DTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),ZT(t,-e6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?yI(t):kTe(t))},MTe=async(t,e,{signal:r})=>{try{await t,r.aborted||yI(e)}catch(n){r.aborted||r6(e,n)}},LTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await t6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;n6(o)?s.add(e):s6(t,o)}},DTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await J4(t,s,{signal:i}),!t.readable)return J4(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},kTe=t=>{t.writable&&t.end()},r6=(t,e)=>{n6(e)?yI(t):s6(t,e)},n6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yI=t=>{(t.readable||t.writable)&&t.destroy()},s6=(t,e)=>{t.destroyed||(t.once("error",UTe),t.destroy(e))},UTe=()=>{},ZT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Z4=2,e6=1;import{finished as i6}from"stream/promises";var ku=(t,e)=>{t.pipe(e),FTe(t,e),BTe(t,e)},FTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}TI(e)}},TI=t=>{t.writable&&t.end()},BTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bI(t)}},bI=t=>{t.readable&&t.destroy()};var o6=(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})=>dn.has(c)))$Te(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!dn.has(c)))qTe({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]:pc(i);ku(o,s)}},$Te=(t,e,r,n)=>{r==="output"?ku(t.stdio[n],e):ku(e,t.stdio[n]);let s=GTe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},GTe=["stdin","stdout","stderr"],qTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;HTe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},HTe=(t,{signal:e})=>{Gn(t)&&uc(t,VTe,e)},VTe=2;import{addAbortListener as zTe}from"events";var mc=[];mc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&mc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&mc.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",AI=Symbol.for("signal-exit emitter"),vI=globalThis,jTe=Object.defineProperty.bind(Object),wI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vI[AI])return vI[AI];jTe(vI,AI,{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{},WTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RI=class extends tb{onExit(){return()=>{}}load(){}unload(){}},CI=class extends tb{#e=xI.platform==="win32"?"SIGINT":"SIGHUP";#r=new wI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of mc)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 mc)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,mc.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)}},xI=globalThis.process,{onExit:a6,load:oJe,unload:aJe}=WTe(eb(xI)?new CI(xI):new RI);var c6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=a6(()=>{t.kill()});zTe(n,()=>{s()})};var u6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=fT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=YTe(r,n,s),{sourceStream:d,sourceError:f}=XTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},YTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=KTe(t,e,...r),a=bT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},KTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(l6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_O(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(l6)(s,i,o),pipeOptions:o}}if(Rs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},l6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),XTe=(t,e)=>{try{return{sourceStream:Pu(t,e)}}catch(r){return{sourceError:r}}};var f6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=QTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},QTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bI(t),n;if(e!==void 0)return TI(r),e},PI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mu({error:t,command:d6,escapedCommand:d6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),d6="source.pipe(destination)";var h6=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 JTe}from"stream/promises";var p6=(t,e,r)=>{let n=rb.has(e)?ebe(t,e):ZTe(t,e);return uc(t,rbe,r.signal),uc(e,nbe,r.signal),tbe(e),n},ZTe=(t,e)=>{let r=pc([t]);return ku(r,e),rb.set(e,r),r},ebe=(t,e)=>{let r=rb.get(e);return r.add(t),r},tbe=async t=>{try{await JTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rb.delete(t)},rb=new WeakMap,rbe=2,nbe=1;import{aborted as sbe}from"util";var m6=(t,e)=>t===void 0?[]:[ibe(t,e)],ibe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await sbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PI({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}=u6(t,...e),s=obe({...n,destination:r});return s.pipe=nb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},obe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=abe(t,s);f6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=p6(e,i,d);return await Promise.race([h6(u),...m6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},abe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pbe}from"timers/promises";import{on as cbe}from"events";import{getDefaultHighWaterMark as lbe}from"stream";var sb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return ube(e,o),_6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},ube=async(t,e)=>{try{await t}catch{}finally{e.abort()}},OI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;dbe(e,o,t);let a=t.readableObjectMode&&!i;return _6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},dbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=cbe(t,"data",{signal:e.signal,highWaterMark:g6,highWatermark:g6});return fbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},II=lbe(!0),g6=II,fbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=hbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*hc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},hbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[YT(t,r,!e),zT(t,s,!n,{})].filter(Boolean);var S6=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=mbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([gbe(t),d]);return}let f=cI(c,r),h=OI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([_be({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},mbe=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=OI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await P4(a,t,r,i)},gbe=async t=>{await pbe(),t.readableFlowing===null&&t.resume()},_be=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 Nu(r,{maxBuffer:i})}catch(a){return E6(PY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},NI=async t=>{try{return await t}catch(e){return E6(e)}},E6=({bufferedData:t})=>j3(t)?new Uint8Array(t):t;import{finished as Sbe}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ebe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Sbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||bbe(a,e,r,n)}finally{o.abort()}},Ebe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&ybe(t,r,n),n},ybe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Tbe(e,r),n.call(t,...s)}},Tbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},bbe=(t,e,r,n)=>{if(!Abe(t,e,r,n))throw t},Abe=(t,e,r,n=!0)=>r.propagating?y6(t)||ib(t):(r.propagating=!0,MI(r,e)===n?y6(t):ib(t)),MI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ib=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",y6=t=>t?.code==="EPIPE";var T6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>LI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),LI=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(MI(l,e)){await u;return}let[d]=await Promise.all([S6({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 b6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?pc([t,e].filter(Boolean)):void 0,A6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>LI({...vbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:wbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),vbe=({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}},wbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Rbe}from"events";var v6=t=>vu(t,"ipc"),w6=(t,e)=>{let r=dT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var R6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=v6(i),a=Ei(e,"ipc"),c=Ei(r,"ipc");for await(let l of _I({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(OY(t,s,c),s.push(l)),o&&w6(l,i);return s},C6=async(t,e)=>(await Promise.allSettled([t]),e);var x6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let b=L4(t,f),R={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=T6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),B=A6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),O=[],U=R6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:h}),P=Cbe(m,t,R),I=xbe(p,R);try{return await Promise.race([Promise.all([{},k4(b),Promise.all(A),B,U,cY(t,d),...P,...I]),E,Pbe(t,S),...nY(t,i,f,S),...vz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...tY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(A.map(_=>NI(_))),NI(B),C6(U,O),Promise.allSettled(P),Promise.allSettled(I)])}},Cbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),xbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:dn.has(s),stopOnExit:s==="native"}))),Pbe=async(t,{signal:e})=>{let[r]=await Rbe(t,"error",{signal:e});throw r};var P6=()=>({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=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Uu=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 Obe}from"stream";import{callbackify as Ibe}from"util";import{finished as O6}from"stream/promises";var DI=async t=>{if(t!==void 0)try{await kI(t)}catch{}},I6=async t=>{if(t!==void 0)try{await UI(t)}catch{}},kI=async t=>{await O6(t,{cleanup:!0,readable:!1,writable:!0})},UI=async t=>{await O6(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 N6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=FI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=BI(a,o),{read:f,onStdoutDataDone:h}=$I({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Obe({read:f,destroy:Ibe(qI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return GI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},FI=(t,e,r)=>{let n=Pu(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},BI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:II},$I=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=sb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Nbe(this,o,i)},onStdoutDataDone:i}},Nbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},GI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await UI(t),await n,await DI(s),await e,r.readable&&r.push(null)}catch(i){await DI(s),M6(r,i)}},qI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Uu(r,e)&&(M6(t,n),await ob(e,n))},M6=(t,e)=>{ab(t,t.readable,e)};import{Writable as Mbe}from"stream";import{callbackify as L6}from"util";var D6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=HI(t,r,e),o=new Mbe({...VI(n,t,s),destroy:L6(WI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return jI(n,o),o},HI=(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}},VI=(t,e,r)=>({write:Lbe.bind(void 0,t),final:L6(Dbe.bind(void 0,t,e,r))}),Lbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Dbe=async(t,e,r)=>{await Uu(r,e)&&(t.writable&&t.end(),await e)},jI=async(t,e,r)=>{try{await kI(t),e.writable&&e.end()}catch(n){await I6(r),k6(e,n)}},WI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Uu(r,e),await Uu(n,e)&&(k6(t,s),await ob(e,s))},k6=(t,e)=>{ab(t,t.writable,e)};import{Duplex as kbe}from"stream";import{callbackify as Ube}from"util";var U6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=FI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=HI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=BI(c,a),{read:E,onStdoutDataDone:S}=$I({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new kbe({read:E,...VI(u,t,d),destroy:Ube(Fbe.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 GI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),jI(u,b,c),b},Fbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([qI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),WI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var zI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=Pu(t,r),a=sb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Bbe(a,o,t)},Bbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var F6=(t,{encoding:e})=>{let r=P6();t.readable=N6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=D6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=U6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zI.bind(void 0,t,e),t[Symbol.asyncIterator]=zI.bind(void 0,t,e,{})};var B6=(t,e)=>{for(let[r,n]of Gbe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},$be=(async()=>{})().constructor.prototype,Gbe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($be,t)]);var $6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Vbe(t,e,r),{subprocess:f,promise:h}=Wbe({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}),B6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Vbe=(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=jbe(l),d=Q4(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},jbe=({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}},Wbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Hbe(...LT(t,e,r))}catch(p){return z4({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;qbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];o6(c,a,l),c6(c,r,l);let d={},f=ws();c.kill=bz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=b6(c,r),F6(c,r),V4(c,r);let h=zbe({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}},zbe=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 x6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,B)=>Ti(A,e,B)),b=Ti(m,e,"all"),R=Ybe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Lu(R,n,e)},Ybe=({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 Cs,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,Kbe(n,t[n],s)]));return{...t,...r}},Kbe=(t,e,r)=>Xbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,Xbe=new Set(["env",...AO]);var Oo=(t,e,r,n)=>{let s=(o,a,c)=>Oo(o,a,r,c),i=(...o)=>Qbe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Qbe=({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}=Jbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?F4(a,c,l):$6(a,c,l,s)},Jbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Q3(e)?J3(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 G6=({file:t,commandArguments:e})=>H6(t,e),q6=({file:t,commandArguments:e})=>({...H6(t,e),isSync:!0}),H6=(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]=Zbe(t);return{file:r,commandArguments:n}},Zbe=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(eAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},eAe=/ +/g;var V6=(t,e,r)=>{t.sync=e(tAe,r),t.s=t.sync},j6=({options:t})=>W6(t),tAe=({options:t})=>({...W6(t),isSync:!0}),W6=t=>({options:{...rAe(t),...t}}),rAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},z6={preferLocal:!0};var Y6=Oo(()=>({})),XZe=Oo(()=>({isSync:!0})),K6=Oo(G6),QZe=Oo(q6),JZe=Oo(iY),ZZe=Oo(j6,{},z6,V6),{sendMessage:eet,getOneMessage:tet,getEachMessage:ret,getCancelSignal:net}=j4();var nAe=!1;var Ps=()=>nAe;var pm=null,X6=t=>(pm&&pm.destroy(),pm=new bi({totalAllowedTime:t}),pm),Q6=()=>pm;var bi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ps())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{Ee.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 J6={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.1-next.0",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 aAe=iAe(import.meta.url),cAe=Ai.dirname(aAe),lAe=oAe(import.meta.url),Fu=me("shell"),YI=new Set,Z6={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=uAe(e,r),i={...Z6,...s},o=Y6(t,n,i);t8(o,i),s8(o);let a=r?.idleTimeout;return a&&a>0&&n8(o,a),o},e8=(t,e)=>{let r={...Z6,...e},n=K6(t,r);return t8(n,r),s8(n),e?.idleTimeout&&e.idleTimeout>0&&n8(n,e.idleTimeout),n},uAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},t8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(vi.stdout),t.stderr?.pipe(new jp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},KI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),Fu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Fu.error("Error killing process:",r),!1}},r8=t=>KI(t,"SIGKILL"),n8=(t,e)=>{let r=null,n=()=>{Fu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing idle process ${t.pid}`),r8(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)},s8=t=>{YI.add(t);let e=Q6();if(e){let r=e.onTimesUp(()=>{Fu.log(`Global timer expired, killing process ${t.pid}`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing process ${t.pid} after timeout`),r8(t))},5e3)});t.on("exit",()=>{YI.delete(t),r()}),t.on("error",()=>{YI.delete(t),r()})}};function Io(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=lAe.resolve(J6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(lb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(lb.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(lb.existsSync(r))return r;let n=Ai.join(cAe,"..","node_modules",".bin",e);if(lb.existsSync(n))return n}var dAe=me("utils"),fAe=t=>new Promise(e=>{setTimeout(e,t)});var ub=(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 fAe(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},Bu=(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},i8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):dAe.error("Could not parse JSON",n))}},hAe=t=>t.charAt(0).toUpperCase()+t.slice(1),No=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():hAe(e)).join(" ");function gc(t,e){e&&t.log(`Skill invoked: ${e}`)}var o8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),a8=(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 XI=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}},pAe=1e4,QI=(t,e=pAe)=>{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 c8}from"buffer";import mAe from"path";var l8=me("repo"),gr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),d8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{l8.info("Getting runner diffs");let n=await _Ae(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=EAe(i);await yAe(m,r)}l8.info("Changes after processing"),await ZI(r);let o=await tN(i,r);if(await JI(o,r),s=await SAe(r),!s)return{hasChanges:!1,ignored:o};await gr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await u8(r),{hasChanges:!1,ignored:o};let u=await gr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await gr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await gr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=c8.from(S).toString("base64"))}await u8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=c8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},u8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gr(["reset","--soft","HEAD~1"],{cwd:t})},JI=async(t=[],e=process.cwd())=>{await gr(["add",".",...t],{cwd:e})},ZI=async(t=process.cwd())=>{let e=await gr(["status","-s"],{cwd:t});return String(e.stdout??"")},f8=/.. (.+)?\.log$/,gAe=[f8],_Ae=async(t=process.cwd())=>{let e=await ZI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
88
+ if (condition) { yield value; }`)};import{Buffer as Tye}from"buffer";import{StringDecoder as bye}from"string_decoder";var YT=(t,e,r)=>{if(r)return;if(t)return{transform:Aye.bind(void 0,new TextEncoder)};let n=new bye(e);return{transform:vye.bind(void 0,n),final:wye.bind(void 0,n)}},Aye=function*(t,e){Tye.isBuffer(e)?yield Si(e):typeof e=="string"?yield t.encode(e):yield e},vye=function*(t,e){yield _t(e)?t.write(e):e},wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as b4}from"util";var dI=b4(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=Cye}=e[r];for await(let s of n(t))yield*KT(s,e,r+1)},A4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Rye(r,Number(e),t)},Rye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KT(n,r,e+1)},v4=b4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Cye=function*(t){yield t};var fI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},w4=(t,e)=>[...e.flatMap(r=>[...hc(r,t,0)]),...cm(t)],hc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Pye}=e[r];for(let s of n(t))yield*hc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*xye(r,Number(e),t)},xye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*hc(n,r,e+1)},Pye=function*(t){yield t};var hI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=C4(t,o,i),l=fc(e),u=fc(r),d=l?dI.bind(void 0,KT,a):fI.bind(void 0,hc),f=l||u?dI.bind(void 0,A4,a):fI.bind(void 0,cm),h=l||u?v4.bind(void 0,a):void 0;return{stream:new Oye({writableObjectMode:n,writableHighWaterMark:R4(n),readableObjectMode:s,readableHighWaterMark:R4(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=C4(o,r,a);t=w4(c,t)}return t},C4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:E4(n,a)},YT(r,o,n),zT(r,i,n,c),{transform:t,final:e},{transform:y4(s,a)},S4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var x4=(t,e)=>{for(let r of Iye(t))Nye(t,r,e)},Iye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Nye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Po[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Mye(a,n));r.input=Jp(o)},Mye=(t,e)=>{let r=XT(t,e,"utf8",!0);return Lye(r),Jp(r)},Lye=t=>{let e=t.find(r=>typeof r!="string"&&!_t(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 Fye,appendFileSync as Bye}from"fs";var QT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&vu(r,n)&&!Dr.has(e)&&Dye(n)&&(t.some(({type:s,value:i})=>s==="native"&&kye.has(i))||t.every(({type:s})=>dn.has(s))),Dye=t=>t===1||t===2,kye=new Set(["pipe","overlapped"]),P4=async(t,e,r,n)=>{for await(let s of t)Uye(e)||I4(s,r,n)},O4=(t,e,r)=>{for(let n of t)I4(n,e,r)},Uye=t=>t._readableState.pipes.length>0,I4=(t,e,r)=>{let n=dT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var N4=({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)=>$ye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},$ye=({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=MY(t,i,d),h=Si(f),{stdioItems:p,objectMode:m}=e[r],E=Gye([h],p,c,n),{serializedResult:S,finalResult:b=S}=qye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Hye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&Vye(S,p,s),R}catch(A){return n.error=A,R}},Gye=(t,e,r,n)=>{try{return XT(t,e,r,!1)}catch(s){return n.error=s,t}},qye=({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=z3(t,r);return n[i]?{serializedResult:o,finalResult:uI(o,!s[i],e)}:{serializedResult:o}},Hye=({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=uI(t,!1,o);try{O4(a,e,n)}catch(c){r.error??=c}},Vye=(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)?Bye(n,t):(r.add(i),Fye(n,t))}};var M4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ti(e,r,"all")]:Array.isArray(e)?[Ti(t,r,"all"),...e]:_t(t)&&_t(e)?EO([t,e]):`${t}${e}`};import{once as pI}from"events";var L4=async(t,e)=>{let[r,n]=await jye(t);return e.isForcefullyTerminated??=!1,[r,n]},jye=async t=>{let[e,r]=await Promise.allSettled([pI(t,"spawn"),pI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?D4(t):r.value},D4=async t=>{try{return await pI(t,"exit")}catch{return D4(t)}},k4=async t=>{let[e,r]=await t;if(!Wye(e,r)&&mI(e,r))throw new qn;return[e,r]},Wye=(t,e)=>t===void 0&&e===void 0,mI=(t,e)=>t!==0||e!==null;var U4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=zye(t,e,r),o=i?.code==="ETIMEDOUT",a=NY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},zye=(t,e,r)=>t!==void 0?t:mI(e,r)?new qn:void 0;var F4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Kye(t,e,r),d=Jye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Lu(d,c,l)},Kye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),a=Xye(r),{file:c,commandArguments:l,options:u}=MT(t,e,a);Qye(u);let d=p4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Xye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Qye=({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.`)},Jye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Zye({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}=U4(c,r),{output:p,error:m=l}=N4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,R)=>Ti(b,r,R)),S=Ti(M4(p,r),r,"all");return tTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Zye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{x4(i,r);let a=eTe(r);return Yye(...LT(t,e,a))}catch(a){return Mu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},eTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GT(e)}),tTe=({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 qbe}from"events";import{spawn as Hbe}from"child_process";import H4 from"process";import{once as gI,on as rTe}from"events";var B4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Cu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),nTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),nTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{AT(e,s);let i=xo(t,e,r),o=new AbortController;try{return await Promise.race([sTe(i,n,o),iTe(i,r,o),oTe(i,r,o)])}catch(a){throw xu(t),a}finally{o.abort(),vT(e,s)}},sTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gI(t,"message",{signal:r});return n}for await(let[n]of rTe(t,"message",{signal:r}))if(e(n))return n},iTe=async(t,e,{signal:r})=>{await gI(t,"disconnect",{signal:r}),wz(e)},oTe=async(t,e,{signal:r})=>{let[n]=await gI(t,"strict:error",{signal:r});throw yT(n,e)};import{once as G4,on as aTe}from"events";var q4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>_I({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),_I=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Cu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),AT(e,i);let o=xo(t,e,r),a=new AbortController,c={};return cTe(t,o,a),lTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),uTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},cTe=async(t,e,r)=>{try{await G4(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},lTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await G4(t,"strict:error",{signal:r.signal});n.error=yT(s,e),r.abort()}catch{}},uTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of aTe(r,"message",{signal:i.signal}))$4(o),yield c}catch{$4(o)}finally{i.abort(),vT(e,a),n||xu(t),s&&await t}},$4=({error:t})=>{if(t)throw t};var V4=(t,{ipc:e})=>{Object.assign(t,W4(t,!1,e))},j4=()=>{let t=H4,e=!0,r=H4.channel!==void 0;return{...W4(t,e,r),getCancelSignal:Jz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},W4=(t,e,r)=>({sendMessage:IT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:B4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:q4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as dTe}from"child_process";import{PassThrough as fTe,Readable as hTe,Writable as pTe,Duplex as mTe}from"stream";var z4=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{aI(n);let a=new dTe;gTe(a,n),Object.assign(a,{readable:_Te,writable:STe,duplex:ETe});let c=Mu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=yTe(c,o,s);return{subprocess:a,promise:l}},gTe=(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 fTe;return t.end(),t},_Te=()=>new hTe({read(){}}),STe=()=>new pTe({write(){}}),ETe=()=>new mTe({read(){},write(){}}),yTe=async(t,e,r)=>Lu(t,e,r);import{createReadStream as Y4,createWriteStream as K4}from"fs";import{Buffer as TTe}from"buffer";import{Readable as um,Writable as bTe,Duplex as ATe}from"stream";var Q4=(t,e)=>WT(vTe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Po[t]}.`)},X4={fileNumber:dm,generator:hI,asyncGenerator:hI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ATe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vTe={input:{...X4,fileUrl:({value:t})=>({stream:Y4(t)}),filePath:({value:{file:t}})=>({stream:Y4(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(TTe.from(t))})},output:{...X4,fileUrl:({value:t})=>({stream:K4(t)}),filePath:({value:{file:t,append:e}})=>({stream:K4(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:bTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as wTe,once as J4}from"events";import{PassThrough as RTe,getDefaultHighWaterMark as CTe}from"stream";import{finished as t6}from"stream/promises";function pc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)EI(s);let e=t.some(({readableObjectMode:s})=>s),r=xTe(t,e),n=new SI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var xTe=(t,e)=>{if(t.length===0)return CTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SI=class extends RTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(EI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=PTe(this,this.#e,this.#i);let r=NTe({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(EI(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)}},PTe=async(t,e,r)=>{ZT(t,Z4);let n=new AbortController;try{await Promise.race([OTe(t,n),ITe(t,e,r,n)])}finally{n.abort(),ZT(t,-Z4)}},OTe=async(t,{signal:e})=>{try{await t6(t,{signal:e,cleanup:!0})}catch(r){throw r6(t,r),r}},ITe=async(t,e,r,{signal:n})=>{for await(let[s]of wTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},EI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},NTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{ZT(t,e6);let a=new AbortController;try{await Promise.race([MTe(i,e,a),LTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),DTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),ZT(t,-e6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?yI(t):kTe(t))},MTe=async(t,e,{signal:r})=>{try{await t,r.aborted||yI(e)}catch(n){r.aborted||r6(e,n)}},LTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await t6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;n6(o)?s.add(e):s6(t,o)}},DTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await J4(t,s,{signal:i}),!t.readable)return J4(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},kTe=t=>{t.writable&&t.end()},r6=(t,e)=>{n6(e)?yI(t):s6(t,e)},n6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yI=t=>{(t.readable||t.writable)&&t.destroy()},s6=(t,e)=>{t.destroyed||(t.once("error",UTe),t.destroy(e))},UTe=()=>{},ZT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Z4=2,e6=1;import{finished as i6}from"stream/promises";var ku=(t,e)=>{t.pipe(e),FTe(t,e),BTe(t,e)},FTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}TI(e)}},TI=t=>{t.writable&&t.end()},BTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bI(t)}},bI=t=>{t.readable&&t.destroy()};var o6=(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})=>dn.has(c)))$Te(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!dn.has(c)))qTe({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]:pc(i);ku(o,s)}},$Te=(t,e,r,n)=>{r==="output"?ku(t.stdio[n],e):ku(e,t.stdio[n]);let s=GTe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},GTe=["stdin","stdout","stderr"],qTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;HTe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},HTe=(t,{signal:e})=>{Gn(t)&&uc(t,VTe,e)},VTe=2;import{addAbortListener as zTe}from"events";var mc=[];mc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&mc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&mc.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",AI=Symbol.for("signal-exit emitter"),vI=globalThis,jTe=Object.defineProperty.bind(Object),wI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vI[AI])return vI[AI];jTe(vI,AI,{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{},WTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RI=class extends tb{onExit(){return()=>{}}load(){}unload(){}},CI=class extends tb{#e=xI.platform==="win32"?"SIGINT":"SIGHUP";#r=new wI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of mc)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 mc)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,mc.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)}},xI=globalThis.process,{onExit:a6,load:oJe,unload:aJe}=WTe(eb(xI)?new CI(xI):new RI);var c6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=a6(()=>{t.kill()});zTe(n,()=>{s()})};var u6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=fT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=YTe(r,n,s),{sourceStream:d,sourceError:f}=XTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},YTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=KTe(t,e,...r),a=bT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},KTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(l6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_O(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(l6)(s,i,o),pipeOptions:o}}if(Rs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},l6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),XTe=(t,e)=>{try{return{sourceStream:Pu(t,e)}}catch(r){return{sourceError:r}}};var f6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=QTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},QTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bI(t),n;if(e!==void 0)return TI(r),e},PI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mu({error:t,command:d6,escapedCommand:d6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),d6="source.pipe(destination)";var h6=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 JTe}from"stream/promises";var p6=(t,e,r)=>{let n=rb.has(e)?ebe(t,e):ZTe(t,e);return uc(t,rbe,r.signal),uc(e,nbe,r.signal),tbe(e),n},ZTe=(t,e)=>{let r=pc([t]);return ku(r,e),rb.set(e,r),r},ebe=(t,e)=>{let r=rb.get(e);return r.add(t),r},tbe=async t=>{try{await JTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rb.delete(t)},rb=new WeakMap,rbe=2,nbe=1;import{aborted as sbe}from"util";var m6=(t,e)=>t===void 0?[]:[ibe(t,e)],ibe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await sbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PI({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}=u6(t,...e),s=obe({...n,destination:r});return s.pipe=nb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},obe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=abe(t,s);f6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=p6(e,i,d);return await Promise.race([h6(u),...m6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},abe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pbe}from"timers/promises";import{on as cbe}from"events";import{getDefaultHighWaterMark as lbe}from"stream";var sb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return ube(e,o),_6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},ube=async(t,e)=>{try{await t}catch{}finally{e.abort()}},OI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;dbe(e,o,t);let a=t.readableObjectMode&&!i;return _6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},dbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=cbe(t,"data",{signal:e.signal,highWaterMark:g6,highWatermark:g6});return fbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},II=lbe(!0),g6=II,fbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=hbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*hc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},hbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[YT(t,r,!e),zT(t,s,!n,{})].filter(Boolean);var S6=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=mbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([gbe(t),d]);return}let f=cI(c,r),h=OI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([_be({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},mbe=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=OI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await P4(a,t,r,i)},gbe=async t=>{await pbe(),t.readableFlowing===null&&t.resume()},_be=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 Nu(r,{maxBuffer:i})}catch(a){return E6(PY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},NI=async t=>{try{return await t}catch(e){return E6(e)}},E6=({bufferedData:t})=>j3(t)?new Uint8Array(t):t;import{finished as Sbe}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ebe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Sbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||bbe(a,e,r,n)}finally{o.abort()}},Ebe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&ybe(t,r,n),n},ybe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Tbe(e,r),n.call(t,...s)}},Tbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},bbe=(t,e,r,n)=>{if(!Abe(t,e,r,n))throw t},Abe=(t,e,r,n=!0)=>r.propagating?y6(t)||ib(t):(r.propagating=!0,MI(r,e)===n?y6(t):ib(t)),MI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ib=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",y6=t=>t?.code==="EPIPE";var T6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>LI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),LI=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(MI(l,e)){await u;return}let[d]=await Promise.all([S6({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 b6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?pc([t,e].filter(Boolean)):void 0,A6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>LI({...vbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:wbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),vbe=({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}},wbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Rbe}from"events";var v6=t=>vu(t,"ipc"),w6=(t,e)=>{let r=dT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var R6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=v6(i),a=Ei(e,"ipc"),c=Ei(r,"ipc");for await(let l of _I({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(OY(t,s,c),s.push(l)),o&&w6(l,i);return s},C6=async(t,e)=>(await Promise.allSettled([t]),e);var x6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let b=L4(t,f),R={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=T6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),B=A6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),O=[],U=R6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:h}),P=Cbe(m,t,R),I=xbe(p,R);try{return await Promise.race([Promise.all([{},k4(b),Promise.all(A),B,U,cY(t,d),...P,...I]),E,Pbe(t,S),...nY(t,i,f,S),...vz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...tY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(A.map(_=>NI(_))),NI(B),C6(U,O),Promise.allSettled(P),Promise.allSettled(I)])}},Cbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),xbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:dn.has(s),stopOnExit:s==="native"}))),Pbe=async(t,{signal:e})=>{let[r]=await Rbe(t,"error",{signal:e});throw r};var P6=()=>({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=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Uu=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 Obe}from"stream";import{callbackify as Ibe}from"util";import{finished as O6}from"stream/promises";var DI=async t=>{if(t!==void 0)try{await kI(t)}catch{}},I6=async t=>{if(t!==void 0)try{await UI(t)}catch{}},kI=async t=>{await O6(t,{cleanup:!0,readable:!1,writable:!0})},UI=async t=>{await O6(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 N6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=FI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=BI(a,o),{read:f,onStdoutDataDone:h}=$I({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Obe({read:f,destroy:Ibe(qI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return GI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},FI=(t,e,r)=>{let n=Pu(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},BI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:II},$I=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=sb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Nbe(this,o,i)},onStdoutDataDone:i}},Nbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},GI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await UI(t),await n,await DI(s),await e,r.readable&&r.push(null)}catch(i){await DI(s),M6(r,i)}},qI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Uu(r,e)&&(M6(t,n),await ob(e,n))},M6=(t,e)=>{ab(t,t.readable,e)};import{Writable as Mbe}from"stream";import{callbackify as L6}from"util";var D6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=HI(t,r,e),o=new Mbe({...VI(n,t,s),destroy:L6(WI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return jI(n,o),o},HI=(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}},VI=(t,e,r)=>({write:Lbe.bind(void 0,t),final:L6(Dbe.bind(void 0,t,e,r))}),Lbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Dbe=async(t,e,r)=>{await Uu(r,e)&&(t.writable&&t.end(),await e)},jI=async(t,e,r)=>{try{await kI(t),e.writable&&e.end()}catch(n){await I6(r),k6(e,n)}},WI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Uu(r,e),await Uu(n,e)&&(k6(t,s),await ob(e,s))},k6=(t,e)=>{ab(t,t.writable,e)};import{Duplex as kbe}from"stream";import{callbackify as Ube}from"util";var U6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=FI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=HI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=BI(c,a),{read:E,onStdoutDataDone:S}=$I({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new kbe({read:E,...VI(u,t,d),destroy:Ube(Fbe.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 GI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),jI(u,b,c),b},Fbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([qI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),WI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var zI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=Pu(t,r),a=sb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Bbe(a,o,t)},Bbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var F6=(t,{encoding:e})=>{let r=P6();t.readable=N6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=D6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=U6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zI.bind(void 0,t,e),t[Symbol.asyncIterator]=zI.bind(void 0,t,e,{})};var B6=(t,e)=>{for(let[r,n]of Gbe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},$be=(async()=>{})().constructor.prototype,Gbe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($be,t)]);var $6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Vbe(t,e,r),{subprocess:f,promise:h}=Wbe({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}),B6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Vbe=(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=jbe(l),d=Q4(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},jbe=({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}},Wbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Hbe(...LT(t,e,r))}catch(p){return z4({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;qbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];o6(c,a,l),c6(c,r,l);let d={},f=ws();c.kill=bz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=b6(c,r),F6(c,r),V4(c,r);let h=zbe({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}},zbe=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 x6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,B)=>Ti(A,e,B)),b=Ti(m,e,"all"),R=Ybe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Lu(R,n,e)},Ybe=({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 Cs,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,Kbe(n,t[n],s)]));return{...t,...r}},Kbe=(t,e,r)=>Xbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,Xbe=new Set(["env",...AO]);var Oo=(t,e,r,n)=>{let s=(o,a,c)=>Oo(o,a,r,c),i=(...o)=>Qbe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Qbe=({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}=Jbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?F4(a,c,l):$6(a,c,l,s)},Jbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Q3(e)?J3(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 G6=({file:t,commandArguments:e})=>H6(t,e),q6=({file:t,commandArguments:e})=>({...H6(t,e),isSync:!0}),H6=(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]=Zbe(t);return{file:r,commandArguments:n}},Zbe=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(eAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},eAe=/ +/g;var V6=(t,e,r)=>{t.sync=e(tAe,r),t.s=t.sync},j6=({options:t})=>W6(t),tAe=({options:t})=>({...W6(t),isSync:!0}),W6=t=>({options:{...rAe(t),...t}}),rAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},z6={preferLocal:!0};var Y6=Oo(()=>({})),XZe=Oo(()=>({isSync:!0})),K6=Oo(G6),QZe=Oo(q6),JZe=Oo(iY),ZZe=Oo(j6,{},z6,V6),{sendMessage:eet,getOneMessage:tet,getEachMessage:ret,getCancelSignal:net}=j4();var nAe=!1;var Ps=()=>nAe;var pm=null,X6=t=>(pm&&pm.destroy(),pm=new bi({totalAllowedTime:t}),pm),Q6=()=>pm;var bi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ps())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{Ee.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 J6={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.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 aAe=iAe(import.meta.url),cAe=Ai.dirname(aAe),lAe=oAe(import.meta.url),Fu=me("shell"),YI=new Set,Z6={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=uAe(e,r),i={...Z6,...s},o=Y6(t,n,i);t8(o,i),s8(o);let a=r?.idleTimeout;return a&&a>0&&n8(o,a),o},e8=(t,e)=>{let r={...Z6,...e},n=K6(t,r);return t8(n,r),s8(n),e?.idleTimeout&&e.idleTimeout>0&&n8(n,e.idleTimeout),n},uAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},t8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(vi.stdout),t.stderr?.pipe(new jp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},KI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),Fu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Fu.error("Error killing process:",r),!1}},r8=t=>KI(t,"SIGKILL"),n8=(t,e)=>{let r=null,n=()=>{Fu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing idle process ${t.pid}`),r8(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)},s8=t=>{YI.add(t);let e=Q6();if(e){let r=e.onTimesUp(()=>{Fu.log(`Global timer expired, killing process ${t.pid}`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing process ${t.pid} after timeout`),r8(t))},5e3)});t.on("exit",()=>{YI.delete(t),r()}),t.on("error",()=>{YI.delete(t),r()})}};function Io(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=lAe.resolve(J6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(lb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(lb.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(lb.existsSync(r))return r;let n=Ai.join(cAe,"..","node_modules",".bin",e);if(lb.existsSync(n))return n}var dAe=me("utils"),fAe=t=>new Promise(e=>{setTimeout(e,t)});var ub=(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 fAe(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},Bu=(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},i8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):dAe.error("Could not parse JSON",n))}},hAe=t=>t.charAt(0).toUpperCase()+t.slice(1),No=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():hAe(e)).join(" ");function gc(t,e){e&&t.log(`Skill invoked: ${e}`)}var o8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),a8=(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 XI=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}},pAe=1e4,QI=(t,e=pAe)=>{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 c8}from"buffer";import mAe from"path";var l8=me("repo"),gr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),d8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{l8.info("Getting runner diffs");let n=await _Ae(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=EAe(i);await yAe(m,r)}l8.info("Changes after processing"),await ZI(r);let o=await tN(i,r);if(await JI(o,r),s=await SAe(r),!s)return{hasChanges:!1,ignored:o};await gr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await u8(r),{hasChanges:!1,ignored:o};let u=await gr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await gr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await gr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=c8.from(S).toString("base64"))}await u8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=c8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},u8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gr(["reset","--soft","HEAD~1"],{cwd:t})},JI=async(t=[],e=process.cwd())=>{await gr(["add",".",...t],{cwd:e})},ZI=async(t=process.cwd())=>{let e=await gr(["status","-s"],{cwd:t});return String(e.stdout??"")},f8=/.. (.+)?\.log$/,gAe=[f8],_Ae=async(t=process.cwd())=>{let e=await ZI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
89
89
  `).filter(s=>gAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},SAe=async(t=process.cwd())=>{try{return await gr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},eN=async(t=process.cwd())=>{let{stdout:e}=await gr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},h8=async(t=process.cwd())=>{let{stdout:e}=await gr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},tN=async(t,e=process.cwd())=>{t||=await ZI(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
90
90
  `).forEach(s=>{r.forEach(o=>{let a=s===`?? ${o}`,c=s.startsWith(`?? ${o}/`)||s.startsWith(`?? ${o}${mAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(f8)?.[1];i&&n.push(`:!${i}.log`)}),n},rN=async(t=process.cwd())=>{await gr(["reset","--hard","HEAD"],{cwd:t})},p8=async(t=process.cwd())=>{let e=await gr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
91
91
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},EAe=t=>{let e=t.split(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.140.1-next.0",
4
+ "version": "1.140.1",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",