@netlify/agent-runner-cli 1.138.0-pty.1 → 1.138.0-pty.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +206 -204
- package/dist/index.js +1 -1
- package/dist/pty-client.js +6 -5
- package/package.json +1 -1
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},Dye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},kye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Dye};import{Buffer as Uye}from"buffer";var M4=(t,e)=>t?void 0:Fye.bind(void 0,e),Fye=function*(t,e){if(typeof e!="string"&&!gt(e)&&!Uye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},L4=(t,e)=>t?Bye.bind(void 0,e):$ye.bind(void 0,e),Bye=function*(t,e){D4(t,e),yield e},$ye=function*(t,e){if(D4(t,e),typeof e!="string"&&!gt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},D4=(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 Gye}from"buffer";import{StringDecoder as qye}from"string_decoder";var JT=(t,e,r)=>{if(r)return;if(t)return{transform:Hye.bind(void 0,new TextEncoder)};let n=new qye(e);return{transform:Vye.bind(void 0,n),final:jye.bind(void 0,n)}},Hye=function*(t,e){Gye.isBuffer(e)?yield Ti(e):typeof e=="string"?yield t.encode(e):yield e},Vye=function*(t,e){yield gt(e)?t.write(e):e},jye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as k4}from"util";var gI=k4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),ZT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=zye}=e[r];for await(let s of n(t))yield*ZT(s,e,r+1)},U4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wye(r,Number(e),t)},Wye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*ZT(n,r,e+1)},F4=k4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),zye=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)}},B4=(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=Kye}=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*Yye(r,Number(e),t)},Yye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*gc(n,r,e+1)},Kye=function*(t){yield t};var SI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=G4(t,o,i),l=mc(e),u=mc(r),d=l?gI.bind(void 0,ZT,a):_I.bind(void 0,gc),f=l||u?gI.bind(void 0,U4,a):_I.bind(void 0,dm),h=l||u?F4.bind(void 0,a):void 0;return{stream:new Xye({writableObjectMode:n,writableHighWaterMark:$4(n),readableObjectMode:s,readableHighWaterMark:$4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},eb=(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=G4(o,r,a);t=B4(c,t)}return t},G4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:M4(n,a)},JT(r,o,n),QT(r,i,n,c),{transform:t,final:e},{transform:L4(s,a)},N4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var q4=(t,e)=>{for(let r of Qye(t))Jye(t,r,e)},Qye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Jye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Lo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Zye(a,n));r.input=tm(o)},Zye=(t,e)=>{let r=eb(t,e,"utf8",!0);return eTe(r),tm(r)},eTe=t=>{let e=t.find(r=>typeof r!="string"&&!gt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as sTe,appendFileSync as iTe}from"fs";var tb=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ru(r,n)&&!Fr.has(e)&&tTe(n)&&(t.some(({type:s,value:i})=>s==="native"&&rTe.has(i))||t.every(({type:s})=>pn.has(s))),tTe=t=>t===1||t===2,rTe=new Set(["pipe","overlapped"]),H4=async(t,e,r,n)=>{for await(let s of t)nTe(e)||j4(s,r,n)},V4=(t,e,r)=>{for(let n of t)j4(n,e,r)},nTe=t=>t._readableState.pipes.length>0,j4=(t,e,r)=>{let n=mT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var W4=({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)=>oTe({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},oTe=({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=zY(t,i,d),h=Ti(f),{stdioItems:p,objectMode:m}=e[r],E=aTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=cTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});lTe({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&&uTe(S,p,s),v}catch(T){return n.error=T,v}},aTe=(t,e,r,n)=>{try{return eb(t,e,r,!1)}catch(s){return n.error=s,t}},cTe=({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=aW(t,r);return n[i]?{serializedResult:o,finalResult:mI(o,!s[i],e)}:{serializedResult:o}},lTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!tb({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=mI(t,!1,o);try{V4(a,e,n)}catch(c){r.error??=c}},uTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>KT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?iTe(n,t):(r.add(i),sTe(n,t))}};var z4=([,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]:gt(t)&>(e)?vO([t,e]):`${t}${e}`};import{once as EI}from"events";var Y4=async(t,e)=>{let[r,n]=await dTe(t);return e.isForcefullyTerminated??=!1,[r,n]},dTe=async t=>{let[e,r]=await Promise.allSettled([EI(t,"spawn"),EI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?K4(t):r.value},K4=async t=>{try{return await EI(t,"exit")}catch{return K4(t)}},X4=async t=>{let[e,r]=await t;if(!fTe(e,r)&&yI(e,r))throw new jn;return[e,r]},fTe=(t,e)=>t===void 0&&e===void 0,yI=(t,e)=>t!==0||e!==null;var Q4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=hTe(t,e,r),o=i?.code==="ETIMEDOUT",a=WY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hTe=(t,e,r)=>t!==void 0?t:yI(e,r)?new jn:void 0;var J4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=mTe(t,e,r),d=STe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return ku(d,c,l)},mTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=_T(t,e,r),a=gTe(r),{file:c,commandArguments:l,options:u}=UT(t,e,a);_Te(u);let d=x4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},gTe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,_Te=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rb("ipcInput"),t&&rb("ipc: true"),r&&rb("detached: true"),n&&rb("cancelSignal")},rb=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},STe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=ETe({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}=Q4(c,r),{output:p,error:m=l}=W4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,v)=>vi(A,r,v)),S=vi(z4(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})},ETe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{q4(i,r);let a=yTe(r);return pTe(...FT(t,e,a))}catch(a){return Du({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},yTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:jT(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?WT({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 cAe}from"events";import{spawn as lAe}from"child_process";import n6 from"process";import{once as TI,on as bTe}from"events";var Z4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Pu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:IT(t)}),ATe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),ATe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{CT(e,s);let i=Mo(t,e,r),o=new AbortController;try{return await Promise.race([vTe(i,n,o),wTe(i,r,o),RTe(i,r,o)])}catch(a){throw Ou(t),a}finally{o.abort(),xT(e,s)}},vTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TI(t,"message",{signal:r});return n}for await(let[n]of bTe(t,"message",{signal:r}))if(e(n))return n},wTe=async(t,e,{signal:r})=>{await TI(t,"disconnect",{signal:r}),Bz(e)},RTe=async(t,e,{signal:r})=>{let[n]=await TI(t,"strict:error",{signal:r});throw vT(n,e)};import{once as t6,on as CTe}from"events";var r6=({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})=>{Pu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:IT(t)}),CT(e,i);let o=Mo(t,e,r),a=new AbortController,c={};return xTe(t,o,a),PTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),OTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},xTe=async(t,e,r)=>{try{await t6(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},PTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await t6(t,"strict:error",{signal:r.signal});n.error=vT(s,e),r.abort()}catch{}},OTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of CTe(r,"message",{signal:i.signal}))e6(o),yield c}catch{e6(o)}finally{i.abort(),xT(e,a),n||Ou(t),s&&await t}},e6=({error:t})=>{if(t)throw t};var s6=(t,{ipc:e})=>{Object.assign(t,o6(t,!1,e))},i6=()=>{let t=n6,e=!0,r=n6.channel!==void 0;return{...o6(t,e,r),getCancelSignal:fY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},o6=(t,e,r)=>({sendMessage:DT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Z4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:r6.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ITe}from"child_process";import{PassThrough as NTe,Readable as MTe,Writable as LTe,Duplex as DTe}from"stream";var a6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{fI(n);let a=new ITe;kTe(a,n),Object.assign(a,{readable:UTe,writable:FTe,duplex:BTe});let c=Du({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=$Te(c,o,s);return{subprocess:a,promise:l}},kTe=(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 NTe;return t.end(),t},UTe=()=>new MTe({read(){}}),FTe=()=>new LTe({write(){}}),BTe=()=>new DTe({read(){},write(){}}),$Te=async(t,e,r)=>ku(t,e,r);import{createReadStream as c6,createWriteStream as l6}from"fs";import{Buffer as GTe}from"buffer";import{Readable as hm,Writable as qTe,Duplex as HTe}from"stream";var d6=(t,e)=>XT(VTe,t,e,!1),pm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lo[t]}.`)},u6={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:HTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},VTe={input:{...u6,fileUrl:({value:t})=>({stream:c6(t)}),filePath:({value:{file:t}})=>({stream:c6(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(GTe.from(t))})},output:{...u6,fileUrl:({value:t})=>({stream:l6(t)}),filePath:({value:{file:t,append:e}})=>({stream:l6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:qTe.fromWeb(t)}),iterable:pm,asyncIterable:pm,string:pm,uint8Array:pm}};import{on as jTe,once as f6}from"events";import{PassThrough as WTe,getDefaultHighWaterMark as zTe}from"stream";import{finished as m6}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=YTe(t,e),n=new AI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var YTe=(t,e)=>{if(t.length===0)return zTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AI=class extends WTe{#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??=KTe(this,this.#e,this.#i);let r=JTe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(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)}},KTe=async(t,e,r)=>{nb(t,h6);let n=new AbortController;try{await Promise.race([XTe(t,n),QTe(t,e,r,n)])}finally{n.abort(),nb(t,-h6)}},XTe=async(t,{signal:e})=>{try{await m6(t,{signal:e,cleanup:!0})}catch(r){throw g6(t,r),r}},QTe=async(t,e,r,{signal:n})=>{for await(let[s]of jTe(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}\`.`)},JTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{nb(t,p6);let a=new AbortController;try{await Promise.race([ZTe(i,e,a),ebe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),tbe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),nb(t,-p6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?wI(t):rbe(t))},ZTe=async(t,e,{signal:r})=>{try{await t,r.aborted||wI(e)}catch(n){r.aborted||g6(e,n)}},ebe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await m6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;_6(o)?s.add(e):S6(t,o)}},tbe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await f6(t,s,{signal:i}),!t.readable)return f6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},rbe=t=>{t.writable&&t.end()},g6=(t,e)=>{_6(e)?wI(t):S6(t,e)},_6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wI=t=>{(t.readable||t.writable)&&t.destroy()},S6=(t,e)=>{t.destroyed||(t.once("error",nbe),t.destroy(e))},nbe=()=>{},nb=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},h6=2,p6=1;import{finished as E6}from"stream/promises";var Fu=(t,e)=>{t.pipe(e),sbe(t,e),ibe(t,e)},sbe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await E6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RI(e)}},RI=t=>{t.writable&&t.end()},ibe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await E6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}CI(t)}},CI=t=>{t.readable&&t.destroy()};var y6=(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)))obe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!pn.has(c)))cbe({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);Fu(o,s)}},obe=(t,e,r,n)=>{r==="output"?Fu(t.stdio[n],e):Fu(e,t.stdio[n]);let s=abe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},abe=["stdin","stdout","stderr"],cbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;lbe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},lbe=(t,{signal:e})=>{Vn(t)&&hc(t,ube,e)},ube=2;import{addAbortListener as hbe}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 sb=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,dbe=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];dbe(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}},ib=class{},fbe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),II=class extends ib{onExit(){return()=>{}}load(){}unload(){}},NI=class extends ib{#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(!sb(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 sb(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"&&sb(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:T6,load:RJe,unload:CJe}=fbe(sb(MI)?new NI(MI):new II);var b6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=T6(()=>{t.kill()});hbe(n,()=>{s()})};var v6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=gT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=pbe(r,n,s),{sourceStream:d,sourceError:f}=gbe(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}},pbe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=mbe(t,e,...r),a=RT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},mbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(A6,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]=oT(r,...n);return{destination:e(A6)(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}`)},A6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),gbe=(t,e)=>{try{return{sourceStream:Iu(t,e)}}catch(r){return{sourceError:r}}};var R6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=_be({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw LI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},_be=({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})=>Du({error:t,command:w6,escapedCommand:w6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),w6="source.pipe(destination)";var C6=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 Sbe}from"stream/promises";var x6=(t,e,r)=>{let n=ob.has(e)?ybe(t,e):Ebe(t,e);return hc(t,bbe,r.signal),hc(e,Abe,r.signal),Tbe(e),n},Ebe=(t,e)=>{let r=_c([t]);return Fu(r,e),ob.set(e,r),r},ybe=(t,e)=>{let r=ob.get(e);return r.add(t),r},Tbe=async t=>{try{await Sbe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ob.delete(t)},ob=new WeakMap,bbe=2,Abe=1;import{aborted as vbe}from"util";var P6=(t,e)=>t===void 0?[]:[wbe(t,e)],wbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await vbe(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 ab=(t,...e)=>{if(ot(e[0]))return ab.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=v6(t,...e),s=Rbe({...n,destination:r});return s.pipe=ab.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Rbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Cbe(t,s);R6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=x6(e,i,d);return await Promise.race([C6(u),...P6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Cbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Lbe}from"timers/promises";import{on as xbe}from"events";import{getDefaultHighWaterMark as Pbe}from"stream";var cb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Obe(e,o),I6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Obe=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;Ibe(e,o,t);let a=t.readableObjectMode&&!i;return I6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Ibe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},I6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=xbe(t,"data",{signal:e.signal,highWaterMark:O6,highWatermark:O6});return Nbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},kI=Pbe(!0),O6=kI,Nbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Mbe({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)}},Mbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[JT(t,r,!e),QT(t,s,!n,{})].filter(Boolean);var N6=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=Dbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([kbe(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([Ube({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},Dbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!tb({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 H4(a,t,r,i)},kbe=async t=>{await Lbe(),t.readableFlowing===null&&t.resume()},Ube=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await qT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await HT(r,{maxBuffer:i})):await Lu(r,{maxBuffer:i})}catch(a){return M6(HY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},UI=async t=>{try{return await t}catch(e){return M6(e)}},M6=({bufferedData:t})=>iW(t)?new Uint8Array(t):t;import{finished as Fbe}from"stream/promises";var mm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Bbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Fbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||qbe(a,e,r,n)}finally{o.abort()}},Bbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&$be(t,r,n),n},$be=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Gbe(e,r),n.call(t,...s)}},Gbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},qbe=(t,e,r,n)=>{if(!Hbe(t,e,r,n))throw t},Hbe=(t,e,r,n=!0)=>r.propagating?L6(t)||lb(t):(r.propagating=!0,FI(r,e)===n?L6(t):lb(t)),FI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lb=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",L6=t=>t?.code==="EPIPE";var D6=({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([N6({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 k6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?_c([t,e].filter(Boolean)):void 0,U6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>BI({...Vbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:jbe(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}},jbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Wbe}from"events";var F6=t=>Ru(t,"ipc"),B6=(t,e)=>{let r=mT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var $6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=F6(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&&(VY(t,s,c),s.push(l)),o&&B6(l,i);return s},G6=async(t,e)=>(await Promise.allSettled([t]),e);var q6=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=Y4(t,f),v={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=D6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),U=U6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),x=[],N=$6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),O=zbe(m,t,v),C=Ybe(p,v);try{return await Promise.race([Promise.all([{},X4(A),Promise.all(T),U,N,bY(t,d),...O,...C]),E,Kbe(t,S),..._Y(t,i,f,S),...Fz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...mY({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(U),G6(N,x),Promise.allSettled(O),Promise.allSettled(C)])}},zbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:mm(n,s,r)),Ybe=(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"}))),Kbe=async(t,{signal:e})=>{let[r]=await Wbe(t,"error",{signal:e});throw r};var H6=()=>({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}},Bu=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 Xbe}from"stream";import{callbackify as Qbe}from"util";import{finished as V6}from"stream/promises";var $I=async t=>{if(t!==void 0)try{await GI(t)}catch{}},j6=async t=>{if(t!==void 0)try{await qI(t)}catch{}},GI=async t=>{await V6(t,{cleanup:!0,readable:!1,writable:!0})},qI=async t=>{await V6(t,{cleanup:!0,readable:!0,writable:!1})},ub=async(t,e)=>{if(await t,e)throw e},db=(t,e,r)=>{r&&!lb(r)?t.destroy(r):e&&t.destroy()};var W6=({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 Xbe({read:f,destroy:Qbe(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=Iu(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=cb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Jbe(this,o,i)},onStdoutDataDone:i}},Jbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},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),z6(r,i)}},zI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bu(r,e)&&(z6(t,n),await ub(e,n))},z6=(t,e)=>{db(t,t.readable,e)};import{Writable as Zbe}from"stream";import{callbackify as Y6}from"util";var K6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=YI(t,r,e),o=new Zbe({...KI(n,t,s),destroy:Y6(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=RT(t,e),s=gm(r,n,"writableFinal"),i=gm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},KI=(t,e,r)=>({write:eAe.bind(void 0,t),final:Y6(tAe.bind(void 0,t,e,r))}),eAe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},tAe=async(t,e,r)=>{await Bu(r,e)&&(t.writable&&t.end(),await e)},XI=async(t,e,r)=>{try{await GI(t),e.writable&&e.end()}catch(n){await j6(r),X6(e,n)}},QI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Bu(r,e),await Bu(n,e)&&(X6(t,s),await ub(e,s))},X6=(t,e)=>{db(t,t.writable,e)};import{Duplex as rAe}from"stream";import{callbackify as nAe}from"util";var Q6=({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 rAe({read:E,...KI(u,t,d),destroy:nAe(sAe.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},sAe=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=Iu(t,r),a=cb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return iAe(a,o,t)},iAe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var J6=(t,{encoding:e})=>{let r=H6();t.readable=W6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=K6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Q6.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 Z6=(t,e)=>{for(let[r,n]of aAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},oAe=(async()=>{})().constructor.prototype,aAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(oAe,t)]);var e8=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=uAe(t,e,r),{subprocess:f,promise:h}=fAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ab.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),Z6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},uAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=_T(t,e,r),{file:a,commandArguments:c,options:l}=UT(t,e,r),u=dAe(l),d=d6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},dAe=({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}},fAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=lAe(...FT(t,e,r))}catch(p){return a6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;cAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];y6(c,a,l),b6(c,r,l);let d={},f=xs();c.kill=kz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=k6(c,r),J6(c,r),s6(c,r);let h=hAe({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}},hAe=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 q6({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,U)=>vi(T,e,U)),A=vi(m,e,"all"),v=pAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return ku(v,n,e)},pAe=({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}):WT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var fb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,mAe(n,t[n],s)]));return{...t,...r}},mAe=(t,e,r)=>gAe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,gAe=new Set(["env",...xO]);var Do=(t,e,r,n)=>{let s=(o,a,c)=>Do(o,a,r,c),i=(...o)=>_Ae({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},_Ae=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,fb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?J4(a,c,l):e8(a,c,l,s)},SAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=dW(e)?fW(e,r):[e,...r],[o,a,c]=oT(...i),l=fb(fb(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 t8=({file:t,commandArguments:e})=>n8(t,e),r8=({file:t,commandArguments:e})=>({...n8(t,e),isSync:!0}),n8=(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]=EAe(t);return{file:r,commandArguments:n}},EAe=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(yAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},yAe=/ +/g;var s8=(t,e,r)=>{t.sync=e(TAe,r),t.s=t.sync},i8=({options:t})=>o8(t),TAe=({options:t})=>({...o8(t),isSync:!0}),o8=t=>({options:{...bAe(t),...t}}),bAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},a8={preferLocal:!0};var c8=Do(()=>({})),_et=Do(()=>({isSync:!0})),l8=Do(t8),Eet=Do(r8),yet=Do(EY),Tet=Do(i8,{},a8,s8),{sendMessage:bet,getOneMessage:Aet,getEachMessage:vet,getCancelSignal:wet}=i6();var AAe=!1;var Ns=()=>AAe;var _m=null,u8=t=>(_m&&_m.destroy(),_m=new wi({totalAllowedTime:t}),_m),d8=()=>_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 eT({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 f8={name:"@netlify/agent-runner-cli",type:"module",version:"1.138.0-pty.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","agent-runner-pty":"./dist/pty-client.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","@types/ws":"^8.5.12","@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","node-pty":"1.1.0",openai:"6.34.0",ws:"8.21.0"}};var CAe=wAe(import.meta.url),xAe=Ri.dirname(CAe),PAe=RAe(import.meta.url),$u=me("shell"),ZI=new Set,h8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=OAe(e,r),i={...h8,...s},o=c8(t,n,i);m8(o,i),S8(o);let a=r?.idleTimeout;return a&&a>0&&_8(o,a),o},p8=(t,e)=>{let r={...h8,...e},n=l8(t,r);return m8(n,r),S8(n),e?.idleTimeout&&e.idleTimeout>0&&_8(n,e.idleTimeout),n},OAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},m8=(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),$u.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return $u.error("Error killing process:",r),!1}},g8=t=>eN(t,"SIGKILL"),_8=(t,e)=>{let r=null,n=()=>{$u.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($u.log(`Force killing idle process ${t.pid}`),g8(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=>{ZI.add(t);let e=d8();if(e){let r=e.onTimesUp(()=>{$u.log(`Global timer expired, killing process ${t.pid}`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($u.log(`Force killing process ${t.pid} after timeout`),g8(t))},5e3)});t.on("exit",()=>{ZI.delete(t),r()}),t.on("error",()=>{ZI.delete(t),r()})}};function pb(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=PAe.resolve(f8.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(hb.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(hb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(hb.existsSync(r))return r;let n=Ri.join(xAe,"..","node_modules",".bin",e);if(hb.existsSync(n))return n}var IAe=me("utils"),NAe=t=>new Promise(e=>{setTimeout(e,t)});var mb=(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 NAe(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},Gu=(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},E8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):IAe.error("Could not parse JSON",n))}},MAe=t=>t.charAt(0).toUpperCase()+t.slice(1),ko=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():MAe(e)).join(" ");function Ec(t,e){e&&t.log(`Skill invoked: ${e}`)}var y8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),T8=(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}},LAe=1e4,rN=(t,e=LAe)=>{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 b8}from"buffer";import DAe from"path";var A8=me("repo"),yr=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),w8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{A8.info("Getting runner diffs");let n=await UAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=BAe(i);await $Ae(m,r)}A8.info("Changes after processing"),await sN(r);let o=await iN(i,r);if(await nN(o,r),s=await FAe(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 v8(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=b8.from(S).toString("base64"))}await v8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=b8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},v8=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??"")},R8=/.. (.+)?\.log$/,kAe=[R8],UAe=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 Gye}from"buffer";import{StringDecoder as qye}from"string_decoder";var JT=(t,e,r)=>{if(r)return;if(t)return{transform:Hye.bind(void 0,new TextEncoder)};let n=new qye(e);return{transform:Vye.bind(void 0,n),final:jye.bind(void 0,n)}},Hye=function*(t,e){Gye.isBuffer(e)?yield Ti(e):typeof e=="string"?yield t.encode(e):yield e},Vye=function*(t,e){yield gt(e)?t.write(e):e},jye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as k4}from"util";var gI=k4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),ZT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=zye}=e[r];for await(let s of n(t))yield*ZT(s,e,r+1)},U4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wye(r,Number(e),t)},Wye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*ZT(n,r,e+1)},F4=k4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),zye=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)}},B4=(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=Kye}=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*Yye(r,Number(e),t)},Yye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*gc(n,r,e+1)},Kye=function*(t){yield t};var SI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=G4(t,o,i),l=mc(e),u=mc(r),d=l?gI.bind(void 0,ZT,a):_I.bind(void 0,gc),f=l||u?gI.bind(void 0,U4,a):_I.bind(void 0,dm),h=l||u?F4.bind(void 0,a):void 0;return{stream:new Xye({writableObjectMode:n,writableHighWaterMark:$4(n),readableObjectMode:s,readableHighWaterMark:$4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},eb=(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=G4(o,r,a);t=B4(c,t)}return t},G4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:M4(n,a)},JT(r,o,n),QT(r,i,n,c),{transform:t,final:e},{transform:L4(s,a)},N4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var q4=(t,e)=>{for(let r of Qye(t))Jye(t,r,e)},Qye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Jye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Lo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Zye(a,n));r.input=tm(o)},Zye=(t,e)=>{let r=eb(t,e,"utf8",!0);return eTe(r),tm(r)},eTe=t=>{let e=t.find(r=>typeof r!="string"&&!gt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as sTe,appendFileSync as iTe}from"fs";var tb=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ru(r,n)&&!Fr.has(e)&&tTe(n)&&(t.some(({type:s,value:i})=>s==="native"&&rTe.has(i))||t.every(({type:s})=>pn.has(s))),tTe=t=>t===1||t===2,rTe=new Set(["pipe","overlapped"]),H4=async(t,e,r,n)=>{for await(let s of t)nTe(e)||j4(s,r,n)},V4=(t,e,r)=>{for(let n of t)j4(n,e,r)},nTe=t=>t._readableState.pipes.length>0,j4=(t,e,r)=>{let n=mT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var W4=({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)=>oTe({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},oTe=({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=zY(t,i,d),h=Ti(f),{stdioItems:p,objectMode:m}=e[r],E=aTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=cTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});lTe({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&&uTe(S,p,s),v}catch(T){return n.error=T,v}},aTe=(t,e,r,n)=>{try{return eb(t,e,r,!1)}catch(s){return n.error=s,t}},cTe=({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=aW(t,r);return n[i]?{serializedResult:o,finalResult:mI(o,!s[i],e)}:{serializedResult:o}},lTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!tb({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=mI(t,!1,o);try{V4(a,e,n)}catch(c){r.error??=c}},uTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>KT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?iTe(n,t):(r.add(i),sTe(n,t))}};var z4=([,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]:gt(t)&>(e)?vO([t,e]):`${t}${e}`};import{once as EI}from"events";var Y4=async(t,e)=>{let[r,n]=await dTe(t);return e.isForcefullyTerminated??=!1,[r,n]},dTe=async t=>{let[e,r]=await Promise.allSettled([EI(t,"spawn"),EI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?K4(t):r.value},K4=async t=>{try{return await EI(t,"exit")}catch{return K4(t)}},X4=async t=>{let[e,r]=await t;if(!fTe(e,r)&&yI(e,r))throw new jn;return[e,r]},fTe=(t,e)=>t===void 0&&e===void 0,yI=(t,e)=>t!==0||e!==null;var Q4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=hTe(t,e,r),o=i?.code==="ETIMEDOUT",a=WY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hTe=(t,e,r)=>t!==void 0?t:yI(e,r)?new jn:void 0;var J4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=mTe(t,e,r),d=STe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return ku(d,c,l)},mTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=_T(t,e,r),a=gTe(r),{file:c,commandArguments:l,options:u}=UT(t,e,a);_Te(u);let d=x4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},gTe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,_Te=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rb("ipcInput"),t&&rb("ipc: true"),r&&rb("detached: true"),n&&rb("cancelSignal")},rb=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},STe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=ETe({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}=Q4(c,r),{output:p,error:m=l}=W4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,v)=>vi(A,r,v)),S=vi(z4(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})},ETe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{q4(i,r);let a=yTe(r);return pTe(...FT(t,e,a))}catch(a){return Du({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},yTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:jT(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?WT({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 cAe}from"events";import{spawn as lAe}from"child_process";import n6 from"process";import{once as TI,on as bTe}from"events";var Z4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Pu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:IT(t)}),ATe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),ATe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{CT(e,s);let i=Mo(t,e,r),o=new AbortController;try{return await Promise.race([vTe(i,n,o),wTe(i,r,o),RTe(i,r,o)])}catch(a){throw Ou(t),a}finally{o.abort(),xT(e,s)}},vTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TI(t,"message",{signal:r});return n}for await(let[n]of bTe(t,"message",{signal:r}))if(e(n))return n},wTe=async(t,e,{signal:r})=>{await TI(t,"disconnect",{signal:r}),Bz(e)},RTe=async(t,e,{signal:r})=>{let[n]=await TI(t,"strict:error",{signal:r});throw vT(n,e)};import{once as t6,on as CTe}from"events";var r6=({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})=>{Pu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:IT(t)}),CT(e,i);let o=Mo(t,e,r),a=new AbortController,c={};return xTe(t,o,a),PTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),OTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},xTe=async(t,e,r)=>{try{await t6(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},PTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await t6(t,"strict:error",{signal:r.signal});n.error=vT(s,e),r.abort()}catch{}},OTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of CTe(r,"message",{signal:i.signal}))e6(o),yield c}catch{e6(o)}finally{i.abort(),xT(e,a),n||Ou(t),s&&await t}},e6=({error:t})=>{if(t)throw t};var s6=(t,{ipc:e})=>{Object.assign(t,o6(t,!1,e))},i6=()=>{let t=n6,e=!0,r=n6.channel!==void 0;return{...o6(t,e,r),getCancelSignal:fY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},o6=(t,e,r)=>({sendMessage:DT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Z4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:r6.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ITe}from"child_process";import{PassThrough as NTe,Readable as MTe,Writable as LTe,Duplex as DTe}from"stream";var a6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{fI(n);let a=new ITe;kTe(a,n),Object.assign(a,{readable:UTe,writable:FTe,duplex:BTe});let c=Du({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=$Te(c,o,s);return{subprocess:a,promise:l}},kTe=(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 NTe;return t.end(),t},UTe=()=>new MTe({read(){}}),FTe=()=>new LTe({write(){}}),BTe=()=>new DTe({read(){},write(){}}),$Te=async(t,e,r)=>ku(t,e,r);import{createReadStream as c6,createWriteStream as l6}from"fs";import{Buffer as GTe}from"buffer";import{Readable as hm,Writable as qTe,Duplex as HTe}from"stream";var d6=(t,e)=>XT(VTe,t,e,!1),pm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lo[t]}.`)},u6={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:HTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},VTe={input:{...u6,fileUrl:({value:t})=>({stream:c6(t)}),filePath:({value:{file:t}})=>({stream:c6(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(GTe.from(t))})},output:{...u6,fileUrl:({value:t})=>({stream:l6(t)}),filePath:({value:{file:t,append:e}})=>({stream:l6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:qTe.fromWeb(t)}),iterable:pm,asyncIterable:pm,string:pm,uint8Array:pm}};import{on as jTe,once as f6}from"events";import{PassThrough as WTe,getDefaultHighWaterMark as zTe}from"stream";import{finished as m6}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=YTe(t,e),n=new AI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var YTe=(t,e)=>{if(t.length===0)return zTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AI=class extends WTe{#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??=KTe(this,this.#e,this.#i);let r=JTe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(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)}},KTe=async(t,e,r)=>{nb(t,h6);let n=new AbortController;try{await Promise.race([XTe(t,n),QTe(t,e,r,n)])}finally{n.abort(),nb(t,-h6)}},XTe=async(t,{signal:e})=>{try{await m6(t,{signal:e,cleanup:!0})}catch(r){throw g6(t,r),r}},QTe=async(t,e,r,{signal:n})=>{for await(let[s]of jTe(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}\`.`)},JTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{nb(t,p6);let a=new AbortController;try{await Promise.race([ZTe(i,e,a),ebe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),tbe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),nb(t,-p6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?wI(t):rbe(t))},ZTe=async(t,e,{signal:r})=>{try{await t,r.aborted||wI(e)}catch(n){r.aborted||g6(e,n)}},ebe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await m6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;_6(o)?s.add(e):S6(t,o)}},tbe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await f6(t,s,{signal:i}),!t.readable)return f6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},rbe=t=>{t.writable&&t.end()},g6=(t,e)=>{_6(e)?wI(t):S6(t,e)},_6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wI=t=>{(t.readable||t.writable)&&t.destroy()},S6=(t,e)=>{t.destroyed||(t.once("error",nbe),t.destroy(e))},nbe=()=>{},nb=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},h6=2,p6=1;import{finished as E6}from"stream/promises";var Fu=(t,e)=>{t.pipe(e),sbe(t,e),ibe(t,e)},sbe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await E6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RI(e)}},RI=t=>{t.writable&&t.end()},ibe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await E6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}CI(t)}},CI=t=>{t.readable&&t.destroy()};var y6=(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)))obe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!pn.has(c)))cbe({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);Fu(o,s)}},obe=(t,e,r,n)=>{r==="output"?Fu(t.stdio[n],e):Fu(e,t.stdio[n]);let s=abe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},abe=["stdin","stdout","stderr"],cbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;lbe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},lbe=(t,{signal:e})=>{Vn(t)&&hc(t,ube,e)},ube=2;import{addAbortListener as hbe}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 sb=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,dbe=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];dbe(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}},ib=class{},fbe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),II=class extends ib{onExit(){return()=>{}}load(){}unload(){}},NI=class extends ib{#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(!sb(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 sb(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"&&sb(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:T6,load:RJe,unload:CJe}=fbe(sb(MI)?new NI(MI):new II);var b6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=T6(()=>{t.kill()});hbe(n,()=>{s()})};var v6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=gT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=pbe(r,n,s),{sourceStream:d,sourceError:f}=gbe(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}},pbe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=mbe(t,e,...r),a=RT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},mbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(A6,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]=oT(r,...n);return{destination:e(A6)(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}`)},A6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),gbe=(t,e)=>{try{return{sourceStream:Iu(t,e)}}catch(r){return{sourceError:r}}};var R6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=_be({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw LI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},_be=({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})=>Du({error:t,command:w6,escapedCommand:w6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),w6="source.pipe(destination)";var C6=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 Sbe}from"stream/promises";var x6=(t,e,r)=>{let n=ob.has(e)?ybe(t,e):Ebe(t,e);return hc(t,bbe,r.signal),hc(e,Abe,r.signal),Tbe(e),n},Ebe=(t,e)=>{let r=_c([t]);return Fu(r,e),ob.set(e,r),r},ybe=(t,e)=>{let r=ob.get(e);return r.add(t),r},Tbe=async t=>{try{await Sbe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ob.delete(t)},ob=new WeakMap,bbe=2,Abe=1;import{aborted as vbe}from"util";var P6=(t,e)=>t===void 0?[]:[wbe(t,e)],wbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await vbe(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 ab=(t,...e)=>{if(ot(e[0]))return ab.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=v6(t,...e),s=Rbe({...n,destination:r});return s.pipe=ab.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Rbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Cbe(t,s);R6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=x6(e,i,d);return await Promise.race([C6(u),...P6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Cbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Lbe}from"timers/promises";import{on as xbe}from"events";import{getDefaultHighWaterMark as Pbe}from"stream";var cb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Obe(e,o),I6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Obe=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;Ibe(e,o,t);let a=t.readableObjectMode&&!i;return I6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Ibe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},I6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=xbe(t,"data",{signal:e.signal,highWaterMark:O6,highWatermark:O6});return Nbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},kI=Pbe(!0),O6=kI,Nbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Mbe({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)}},Mbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[JT(t,r,!e),QT(t,s,!n,{})].filter(Boolean);var N6=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=Dbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([kbe(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([Ube({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},Dbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!tb({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 H4(a,t,r,i)},kbe=async t=>{await Lbe(),t.readableFlowing===null&&t.resume()},Ube=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await qT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await HT(r,{maxBuffer:i})):await Lu(r,{maxBuffer:i})}catch(a){return M6(HY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},UI=async t=>{try{return await t}catch(e){return M6(e)}},M6=({bufferedData:t})=>iW(t)?new Uint8Array(t):t;import{finished as Fbe}from"stream/promises";var mm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Bbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Fbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||qbe(a,e,r,n)}finally{o.abort()}},Bbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&$be(t,r,n),n},$be=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Gbe(e,r),n.call(t,...s)}},Gbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},qbe=(t,e,r,n)=>{if(!Hbe(t,e,r,n))throw t},Hbe=(t,e,r,n=!0)=>r.propagating?L6(t)||lb(t):(r.propagating=!0,FI(r,e)===n?L6(t):lb(t)),FI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lb=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",L6=t=>t?.code==="EPIPE";var D6=({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([N6({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 k6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?_c([t,e].filter(Boolean)):void 0,U6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>BI({...Vbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:jbe(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}},jbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Wbe}from"events";var F6=t=>Ru(t,"ipc"),B6=(t,e)=>{let r=mT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var $6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=F6(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&&(VY(t,s,c),s.push(l)),o&&B6(l,i);return s},G6=async(t,e)=>(await Promise.allSettled([t]),e);var q6=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=Y4(t,f),v={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=D6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),U=U6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),x=[],N=$6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),O=zbe(m,t,v),C=Ybe(p,v);try{return await Promise.race([Promise.all([{},X4(A),Promise.all(T),U,N,bY(t,d),...O,...C]),E,Kbe(t,S),..._Y(t,i,f,S),...Fz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...mY({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(U),G6(N,x),Promise.allSettled(O),Promise.allSettled(C)])}},zbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:mm(n,s,r)),Ybe=(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"}))),Kbe=async(t,{signal:e})=>{let[r]=await Wbe(t,"error",{signal:e});throw r};var H6=()=>({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}},Bu=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 Xbe}from"stream";import{callbackify as Qbe}from"util";import{finished as V6}from"stream/promises";var $I=async t=>{if(t!==void 0)try{await GI(t)}catch{}},j6=async t=>{if(t!==void 0)try{await qI(t)}catch{}},GI=async t=>{await V6(t,{cleanup:!0,readable:!1,writable:!0})},qI=async t=>{await V6(t,{cleanup:!0,readable:!0,writable:!1})},ub=async(t,e)=>{if(await t,e)throw e},db=(t,e,r)=>{r&&!lb(r)?t.destroy(r):e&&t.destroy()};var W6=({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 Xbe({read:f,destroy:Qbe(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=Iu(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=cb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Jbe(this,o,i)},onStdoutDataDone:i}},Jbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},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),z6(r,i)}},zI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bu(r,e)&&(z6(t,n),await ub(e,n))},z6=(t,e)=>{db(t,t.readable,e)};import{Writable as Zbe}from"stream";import{callbackify as Y6}from"util";var K6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=YI(t,r,e),o=new Zbe({...KI(n,t,s),destroy:Y6(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=RT(t,e),s=gm(r,n,"writableFinal"),i=gm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},KI=(t,e,r)=>({write:eAe.bind(void 0,t),final:Y6(tAe.bind(void 0,t,e,r))}),eAe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},tAe=async(t,e,r)=>{await Bu(r,e)&&(t.writable&&t.end(),await e)},XI=async(t,e,r)=>{try{await GI(t),e.writable&&e.end()}catch(n){await j6(r),X6(e,n)}},QI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Bu(r,e),await Bu(n,e)&&(X6(t,s),await ub(e,s))},X6=(t,e)=>{db(t,t.writable,e)};import{Duplex as rAe}from"stream";import{callbackify as nAe}from"util";var Q6=({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 rAe({read:E,...KI(u,t,d),destroy:nAe(sAe.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},sAe=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=Iu(t,r),a=cb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return iAe(a,o,t)},iAe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var J6=(t,{encoding:e})=>{let r=H6();t.readable=W6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=K6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Q6.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 Z6=(t,e)=>{for(let[r,n]of aAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},oAe=(async()=>{})().constructor.prototype,aAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(oAe,t)]);var e8=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=uAe(t,e,r),{subprocess:f,promise:h}=fAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ab.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),Z6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},uAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=_T(t,e,r),{file:a,commandArguments:c,options:l}=UT(t,e,r),u=dAe(l),d=d6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},dAe=({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}},fAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=lAe(...FT(t,e,r))}catch(p){return a6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;cAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];y6(c,a,l),b6(c,r,l);let d={},f=xs();c.kill=kz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=k6(c,r),J6(c,r),s6(c,r);let h=hAe({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}},hAe=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 q6({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,U)=>vi(T,e,U)),A=vi(m,e,"all"),v=pAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return ku(v,n,e)},pAe=({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}):WT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var fb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,mAe(n,t[n],s)]));return{...t,...r}},mAe=(t,e,r)=>gAe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,gAe=new Set(["env",...xO]);var Do=(t,e,r,n)=>{let s=(o,a,c)=>Do(o,a,r,c),i=(...o)=>_Ae({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},_Ae=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,fb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?J4(a,c,l):e8(a,c,l,s)},SAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=dW(e)?fW(e,r):[e,...r],[o,a,c]=oT(...i),l=fb(fb(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 t8=({file:t,commandArguments:e})=>n8(t,e),r8=({file:t,commandArguments:e})=>({...n8(t,e),isSync:!0}),n8=(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]=EAe(t);return{file:r,commandArguments:n}},EAe=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(yAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},yAe=/ +/g;var s8=(t,e,r)=>{t.sync=e(TAe,r),t.s=t.sync},i8=({options:t})=>o8(t),TAe=({options:t})=>({...o8(t),isSync:!0}),o8=t=>({options:{...bAe(t),...t}}),bAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},a8={preferLocal:!0};var c8=Do(()=>({})),_et=Do(()=>({isSync:!0})),l8=Do(t8),Eet=Do(r8),yet=Do(EY),Tet=Do(i8,{},a8,s8),{sendMessage:bet,getOneMessage:Aet,getEachMessage:vet,getCancelSignal:wet}=i6();var AAe=!1;var Ns=()=>AAe;var _m=null,u8=t=>(_m&&_m.destroy(),_m=new wi({totalAllowedTime:t}),_m),d8=()=>_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 eT({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 f8={name:"@netlify/agent-runner-cli",type:"module",version:"1.138.0-pty.3",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","agent-runner-pty":"./dist/pty-client.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","@types/ws":"^8.5.12","@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","node-pty":"1.1.0",openai:"6.34.0",ws:"8.21.0"}};var CAe=wAe(import.meta.url),xAe=Ri.dirname(CAe),PAe=RAe(import.meta.url),$u=me("shell"),ZI=new Set,h8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=OAe(e,r),i={...h8,...s},o=c8(t,n,i);m8(o,i),S8(o);let a=r?.idleTimeout;return a&&a>0&&_8(o,a),o},p8=(t,e)=>{let r={...h8,...e},n=l8(t,r);return m8(n,r),S8(n),e?.idleTimeout&&e.idleTimeout>0&&_8(n,e.idleTimeout),n},OAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},m8=(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),$u.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return $u.error("Error killing process:",r),!1}},g8=t=>eN(t,"SIGKILL"),_8=(t,e)=>{let r=null,n=()=>{$u.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($u.log(`Force killing idle process ${t.pid}`),g8(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=>{ZI.add(t);let e=d8();if(e){let r=e.onTimesUp(()=>{$u.log(`Global timer expired, killing process ${t.pid}`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($u.log(`Force killing process ${t.pid} after timeout`),g8(t))},5e3)});t.on("exit",()=>{ZI.delete(t),r()}),t.on("error",()=>{ZI.delete(t),r()})}};function pb(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=PAe.resolve(f8.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(hb.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(hb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(hb.existsSync(r))return r;let n=Ri.join(xAe,"..","node_modules",".bin",e);if(hb.existsSync(n))return n}var IAe=me("utils"),NAe=t=>new Promise(e=>{setTimeout(e,t)});var mb=(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 NAe(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},Gu=(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},E8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):IAe.error("Could not parse JSON",n))}},MAe=t=>t.charAt(0).toUpperCase()+t.slice(1),ko=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():MAe(e)).join(" ");function Ec(t,e){e&&t.log(`Skill invoked: ${e}`)}var y8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),T8=(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}},LAe=1e4,rN=(t,e=LAe)=>{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 b8}from"buffer";import DAe from"path";var A8=me("repo"),yr=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),w8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{A8.info("Getting runner diffs");let n=await UAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=BAe(i);await $Ae(m,r)}A8.info("Changes after processing"),await sN(r);let o=await iN(i,r);if(await nN(o,r),s=await FAe(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 v8(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=b8.from(S).toString("base64"))}await v8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=b8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},v8=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??"")},R8=/.. (.+)?\.log$/,kAe=[R8],UAe=async(t=process.cwd())=>{let e=await sN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
90
90
|
`).filter(s=>kAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},FAe=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()},C8=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}${DAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(R8)?.[1];i&&n.push(`:!${i}.log`)}),n},oN=async(t=process.cwd())=>{await yr(["reset","--hard","HEAD"],{cwd:t})},x8=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))},BAe=t=>{let e=t.split(`
|