@netlify/agent-runner-cli 2.9.0-nb7266f6744f08.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -385,7 +385,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
385
385
|
`,LF:`
|
|
386
386
|
`,concatBytes:zY},nlt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},ilt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:nlt};import{Buffer as slt}from"buffer";var fwe=(t,e)=>t?void 0:olt.bind(void 0,e),olt=function*(t,e){if(typeof e!="string"&&!zr(e)&&!slt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},pwe=(t,e)=>t?alt.bind(void 0,e):clt.bind(void 0,e),alt=function*(t,e){hwe(t,e),yield e},clt=function*(t,e){if(hwe(t,e),typeof e!="string"&&!zr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},hwe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
387
387
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
388
|
-
if (condition) { yield value; }`)};import{Buffer as ult}from"buffer";import{StringDecoder as llt}from"string_decoder";var nM=(t,e,r)=>{if(r)return;if(t)return{transform:dlt.bind(void 0,new TextEncoder)};let n=new llt(e);return{transform:flt.bind(void 0,n),final:plt.bind(void 0,n)}},dlt=function*(t,e){ult.isBuffer(e)?yield su(e):typeof e=="string"?yield t.encode(e):yield e},flt=function*(t,e){yield zr(e)?t.write(e):e},plt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as mwe}from"util";var qY=mwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),iM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=mlt}=e[r];for await(let i of n(t))yield*iM(i,e,r+1)},gwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hlt(r,Number(e),t)},hlt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*iM(n,r,e+1)},_we=mwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),mlt=function*(t){yield t};var BY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},ywe=(t,e)=>[...e.flatMap(r=>[...xp(r,t,0)]),...tA(t)],xp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_lt}=e[r];for(let i of n(t))yield*xp(i,e,r+1)},tA=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*glt(r,Number(e),t)},glt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xp(n,r,e+1)},_lt=function*(t){yield t};var GY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=vwe(t,o,s),u=Rp(e),l=Rp(r),d=u?qY.bind(void 0,iM,a):BY.bind(void 0,xp),f=u||l?qY.bind(void 0,gwe,a):BY.bind(void 0,tA),p=u||l?_we.bind(void 0,a):void 0;return{stream:new ylt({writableObjectMode:n,writableHighWaterMark:Swe(n),readableObjectMode:i,readableHighWaterMark:Swe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},sM=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=vwe(o,r,a);t=ywe(c,t)}return t},vwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:fwe(n,a)},nM(r,o,n),rM(r,s,n,c),{transform:t,final:e},{transform:pwe(i,a)},dwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Ewe=(t,e)=>{for(let r of Slt(t))vlt(t,r,e)},Slt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),vlt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Wl[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Elt(a,n));r.input=Vw(o)},Elt=(t,e)=>{let r=sM(t,e,"utf8",!0);return blt(r),Vw(r)},blt=t=>{let e=t.find(r=>typeof r!="string"&&!zr(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 Rlt,appendFileSync as xlt}from"fs";var oM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&N_(r,n)&&!ns.has(e)&&Tlt(n)&&(t.some(({type:i,value:s})=>i==="native"&&wlt.has(s))||t.every(({type:i})=>Us.has(i))),Tlt=t=>t===1||t===2,wlt=new Set(["pipe","overlapped"]),bwe=async(t,e,r,n)=>{for await(let i of t)Alt(e)||wwe(i,r,n)},Twe=(t,e,r)=>{for(let n of t)wwe(n,e,r)},Alt=t=>t._readableState.pipes.length>0,wwe=(t,e,r)=>{let n=vD(t);Va({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Awe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>Olt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Olt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=RTe(t,s,d),p=su(f),{stdioItems:h,objectMode:m}=e[r],_=Ilt([p],h,c,n),{serializedResult:S,finalResult:w=S}=Plt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Clt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?w:void 0;try{return n.error===void 0&&klt(S,h,i),x}catch(y){return n.error=y,x}},Ilt=(t,e,r,n)=>{try{return sM(t,e,r,!1)}catch(i){return n.error=i,t}},Plt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Vw(t)};let o=zve(t,r);return n[s]?{serializedResult:o,finalResult:jY(o,!i[s],e)}:{serializedResult:o}},Clt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!oM({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=jY(t,!1,o);try{Twe(a,e,n)}catch(c){r.error??=c}},klt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>eM.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?xlt(n,t):(r.add(s),Rlt(n,t))}};var Rwe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,cu(e,r,"all")]:Array.isArray(e)?[cu(t,r,"all"),...e]:zr(t)&&zr(e)?ZK([t,e]):`${t}${e}`};import{once as VY}from"events";var xwe=async(t,e)=>{let[r,n]=await Nlt(t);return e.isForcefullyTerminated??=!1,[r,n]},Nlt=async t=>{let[e,r]=await Promise.allSettled([VY(t,"spawn"),VY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Owe(t):r.value},Owe=async t=>{try{return await VY(t,"exit")}catch{return Owe(t)}},Iwe=async t=>{let[e,r]=await t;if(!Dlt(e,r)&&HY(e,r))throw new Ko;return[e,r]},Dlt=(t,e)=>t===void 0&&e===void 0,HY=(t,e)=>t!==0||e!==null;var Pwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Mlt(t,e,r),o=s?.code==="ETIMEDOUT",a=ATe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Mlt=(t,e,r)=>t!==void 0?t:HY(e,r)?new Ko:void 0;var Cwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Llt(t,e,r),d=zlt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return B_(d,c,u)},Llt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=bD(t,e,r),a=Ult(r),{file:c,commandArguments:u,options:l}=qD(t,e,a);Flt(l);let d=awe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Ult=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Flt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&aM("ipcInput"),t&&aM("ipc: true"),r&&aM("detached: true"),n&&aM("cancelSignal")},aM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},zlt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=jlt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=Pwe(c,r),{output:h,error:m=u}=Awe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((w,x)=>cu(w,r,x)),S=cu(Rwe(h,r),r,"all");return Blt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},jlt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Ewe(s,r);let a=qlt(r);return $lt(...BD(t,e,a))}catch(a){return q_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},qlt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ZD(e)}),Blt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?QD({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):eA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as Pft}from"events";import{spawn as Cft}from"child_process";import $we from"process";import{once as WY,on as Glt}from"events";var kwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>($_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:$D(t)}),Vlt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Vlt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{kD(e,i);let s=Hl(t,e,r),o=new AbortController;try{return await Promise.race([Hlt(s,n,o),Wlt(s,r,o),Klt(s,r,o)])}catch(a){throw L_(t),a}finally{o.abort(),ND(e,i)}},Hlt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await WY(t,"message",{signal:r});return n}for await(let[n]of Glt(t,"message",{signal:r}))if(e(n))return n},Wlt=async(t,e,{signal:r})=>{await WY(t,"disconnect",{signal:r}),ybe(e)},Klt=async(t,e,{signal:r})=>{let[n]=await WY(t,"strict:error",{signal:r});throw ID(n,e)};import{once as Dwe,on as Ylt}from"events";var Mwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>KY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),KY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{$_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:$D(t)}),kD(e,s);let o=Hl(t,e,r),a=new AbortController,c={};return Zlt(t,o,a),Qlt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Jlt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Zlt=async(t,e,r)=>{try{await Dwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Qlt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Dwe(t,"strict:error",{signal:r.signal});n.error=ID(i,e),r.abort()}catch{}},Jlt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Ylt(r,"message",{signal:s.signal}))Nwe(o),yield c}catch{Nwe(o)}finally{s.abort(),ND(e,a),n||L_(t),i&&await t}},Nwe=({error:t})=>{if(t)throw t};var Lwe=(t,{ipc:e})=>{Object.assign(t,Fwe(t,!1,e))},Uwe=()=>{let t=$we,e=!0,r=$we.channel!==void 0;return{...Fwe(t,e,r),getCancelSignal:Vbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Fwe=(t,e,r)=>({sendMessage:zD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:kwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Mwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Xlt}from"child_process";import{PassThrough as edt,Readable as tdt,Writable as rdt,Duplex as ndt}from"stream";var zwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{UY(n);let a=new Xlt;idt(a,n),Object.assign(a,{readable:sdt,writable:odt,duplex:adt});let c=q_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=cdt(c,o,i);return{subprocess:a,promise:u}},idt=(t,e)=>{let r=rA(),n=rA(),i=rA(),s=Array.from({length:e.length-3},rA),o=rA(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},rA=()=>{let t=new edt;return t.end(),t},sdt=()=>new tdt({read(){}}),odt=()=>new rdt({write(){}}),adt=()=>new ndt({read(){},write(){}}),cdt=async(t,e,r)=>B_(t,e,r);import{createReadStream as jwe,createWriteStream as qwe}from"fs";import{Buffer as udt}from"buffer";import{Readable as nA,Writable as ldt,Duplex as ddt}from"stream";var Gwe=(t,e)=>tM(fdt,t,e,!1),iA=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Wl[t]}.`)},Bwe={fileNumber:iA,generator:GY,asyncGenerator:GY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ddt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},fdt={input:{...Bwe,fileUrl:({value:t})=>({stream:jwe(t)}),filePath:({value:{file:t}})=>({stream:jwe(t)}),webStream:({value:t})=>({stream:nA.fromWeb(t)}),iterable:({value:t})=>({stream:nA.from(t)}),asyncIterable:({value:t})=>({stream:nA.from(t)}),string:({value:t})=>({stream:nA.from(t)}),uint8Array:({value:t})=>({stream:nA.from(udt.from(t))})},output:{...Bwe,fileUrl:({value:t})=>({stream:qwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:qwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ldt.fromWeb(t)}),iterable:iA,asyncIterable:iA,string:iA,uint8Array:iA}};import{on as pdt,once as Vwe}from"events";import{PassThrough as hdt,getDefaultHighWaterMark as mdt}from"stream";import{finished as Kwe}from"stream/promises";function Op(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)ZY(i);let e=t.some(({readableObjectMode:i})=>i),r=gdt(t,e),n=new YY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var gdt=(t,e)=>{if(t.length===0)return mdt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},YY=class extends hdt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(ZY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=_dt(this,this.#e,this.#s);let r=vdt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(ZY(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},_dt=async(t,e,r)=>{cM(t,Hwe);let n=new AbortController;try{await Promise.race([ydt(t,n),Sdt(t,e,r,n)])}finally{n.abort(),cM(t,-Hwe)}},ydt=async(t,{signal:e})=>{try{await Kwe(t,{signal:e,cleanup:!0})}catch(r){throw Ywe(t,r),r}},Sdt=async(t,e,r,{signal:n})=>{for await(let[i]of pdt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},ZY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},vdt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{cM(t,Wwe);let a=new AbortController;try{await Promise.race([Edt(s,e,a),bdt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Tdt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),cM(t,-Wwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?QY(t):wdt(t))},Edt=async(t,e,{signal:r})=>{try{await t,r.aborted||QY(e)}catch(n){r.aborted||Ywe(e,n)}},bdt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Kwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Zwe(o)?i.add(e):Qwe(t,o)}},Tdt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Vwe(t,i,{signal:s}),!t.readable)return Vwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},wdt=t=>{t.writable&&t.end()},Ywe=(t,e)=>{Zwe(e)?QY(t):Qwe(t,e)},Zwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",QY=t=>{(t.readable||t.writable)&&t.destroy()},Qwe=(t,e)=>{t.destroyed||(t.once("error",Adt),t.destroy(e))},Adt=()=>{},cM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Hwe=2,Wwe=1;import{finished as Jwe}from"stream/promises";var V_=(t,e)=>{t.pipe(e),Rdt(t,e),xdt(t,e)},Rdt=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Jwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}JY(e)}},JY=t=>{t.writable&&t.end()},xdt=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Jwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}XY(t)}},XY=t=>{t.readable&&t.destroy()};var Xwe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Us.has(c)))Odt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Us.has(c)))Pdt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Op(s);V_(o,i)}},Odt=(t,e,r,n)=>{r==="output"?V_(t.stdio[n],e):V_(e,t.stdio[n]);let i=Idt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Idt=["stdin","stdout","stderr"],Pdt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Cdt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Cdt=(t,{signal:e})=>{Wo(t)&&wp(t,kdt,e)},kdt=2;import{addAbortListener as Mdt}from"events";var Ip=[];Ip.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ip.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ip.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var uM=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",e9=Symbol.for("signal-exit emitter"),t9=globalThis,Ndt=Object.defineProperty.bind(Object),r9=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(t9[e9])return t9[e9];Ndt(t9,e9,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},lM=class{},Ddt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),n9=class extends lM{onExit(){return()=>{}}load(){}unload(){}},i9=class extends lM{#e=s9.platform==="win32"?"SIGINT":"SIGHUP";#r=new r9;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ip)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!uM(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 Ip)try{let r=this.#i[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,Ip.forEach(e=>{let r=this.#i[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.#s,this.#r.count-=1)}#a(e){return uM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&uM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},s9=globalThis.process,{onExit:eAe,load:Vor,unload:Hor}=Ddt(uM(s9)?new i9(s9):new n9);var tAe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=eAe(()=>{t.kill()});Mdt(n,()=>{i()})};var nAe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ED(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=$dt(r,n,i),{sourceStream:d,sourceError:f}=Udt(t,u),{options:p,fileDescriptors:h}=Wa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},$dt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Ldt(t,e,...r),a=CD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Ldt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(rAe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||KK(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[i,s,o]=dD(r,...n);return{destination:e(rAe)(i,s,o),pipeOptions:o}}if(Wa.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}`)},rAe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Udt=(t,e)=>{try{return{sourceStream:U_(t,e)}}catch(r){return{sourceError:r}}};var sAe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Fdt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw o9({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Fdt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return XY(t),n;if(e!==void 0)return JY(r),e},o9=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>q_({error:t,command:iAe,escapedCommand:iAe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),iAe="source.pipe(destination)";var oAe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as zdt}from"stream/promises";var aAe=(t,e,r)=>{let n=dM.has(e)?qdt(t,e):jdt(t,e);return wp(t,Gdt,r.signal),wp(e,Vdt,r.signal),Bdt(e),n},jdt=(t,e)=>{let r=Op([t]);return V_(r,e),dM.set(e,r),r},qdt=(t,e)=>{let r=dM.get(e);return r.add(t),r},Bdt=async t=>{try{await zdt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}dM.delete(t)},dM=new WeakMap,Gdt=2,Vdt=1;import{aborted as Hdt}from"util";var cAe=(t,e)=>t===void 0?[]:[Wdt(t,e)],Wdt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Hdt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw o9({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var fM=(t,...e)=>{if(Sr(e[0]))return fM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=nAe(t,...e),i=Kdt({...n,destination:r});return i.pipe=fM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Kdt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Ydt(t,i);sAe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=aAe(e,s,d);return await Promise.race([oAe(l),...cAe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Ydt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as rft}from"timers/promises";import{on as Zdt}from"events";import{getDefaultHighWaterMark as Qdt}from"stream";var pM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Jdt(e,o),lAe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Jdt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},a9=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Xdt(e,o,t);let a=t.readableObjectMode&&!s;return lAe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Xdt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},lAe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Zdt(t,"data",{signal:e.signal,highWaterMark:uAe,highWatermark:uAe});return eft({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},c9=Qdt(!0),uAe=c9,eft=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=tft({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*xp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*tA(a)}},tft=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[nM(t,r,!e),rM(t,i,!n,{})].filter(Boolean);var dAe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=nft({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([ift(t),d]);return}let f=FY(c,r),p=a9({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([sft({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},nft=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!oM({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=a9({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bwe(a,t,r,s)},ift=async t=>{await rft(),t.readableFlowing===null&&t.resume()},sft=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await WD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await KD(r,{maxBuffer:s})):await j_(r,{maxBuffer:s})}catch(a){return fAe(bTe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},u9=async t=>{try{return await t}catch(e){return fAe(e)}},fAe=({bufferedData:t})=>Uve(t)?new Uint8Array(t):t;import{finished as oft}from"stream/promises";var sA=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=aft(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],oft(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||lft(a,e,r,n)}finally{o.abort()}},aft=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&cft(t,r,n),n},cft=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{uft(e,r),n.call(t,...i)}},uft=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},lft=(t,e,r,n)=>{if(!dft(t,e,r,n))throw t},dft=(t,e,r,n=!0)=>r.propagating?pAe(t)||hM(t):(r.propagating=!0,l9(r,e)===n?pAe(t):hM(t)),l9=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",hM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pAe=t=>t?.code==="EPIPE";var hAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>d9({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),d9=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=sA(t,e,u);if(l9(u,e)){await l;return}let[d]=await Promise.all([dAe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var mAe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Op([t,e].filter(Boolean)):void 0,gAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>d9({...fft(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:pft(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),fft=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},pft=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as hft}from"events";var _Ae=t=>N_(t,"ipc"),yAe=(t,e)=>{let r=vD(t);Va({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var SAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=_Ae(s),a=ou(e,"ipc"),c=ou(r,"ipc");for await(let u of KY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(TTe(t,i,c),i.push(u)),o&&yAe(u,s);return i},vAe=async(t,e)=>(await Promise.allSettled([t]),e);var EAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let w=xwe(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:w,propagating:!1},y=hAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),v=gAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),E=[],R=SAe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=mft(m,t,x),I=gft(h,x);try{return await Promise.race([Promise.all([{},Iwe(w),Promise.all(y),v,R,tTe(t,d),...C,...I]),_,_ft(t,S),...Zbe(t,s,f,S),..._be({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Kbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},w,Promise.all(y.map(T=>u9(T))),u9(v),vAe(R,E),Promise.allSettled(C),Promise.allSettled(I)])}},mft=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:sA(n,i,r)),gft=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Zo(s,{checkOpen:!1})&&!Wo(s)).map(({type:i,value:s,stream:o=s})=>sA(o,n,e,{isSameDirection:Us.has(i),stopOnExit:i==="native"}))),_ft=async(t,{signal:e})=>{let[r]=await hft(t,"error",{signal:e});throw r};var bAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oA=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ha();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},H_=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 yft}from"stream";import{callbackify as Sft}from"util";import{finished as TAe}from"stream/promises";var f9=async t=>{if(t!==void 0)try{await p9(t)}catch{}},wAe=async t=>{if(t!==void 0)try{await h9(t)}catch{}},p9=async t=>{await TAe(t,{cleanup:!0,readable:!1,writable:!0})},h9=async t=>{await TAe(t,{cleanup:!0,readable:!0,writable:!1})},mM=async(t,e)=>{if(await t,e)throw e},gM=(t,e,r)=>{r&&!hM(r)?t.destroy(r):e&&t.destroy()};var AAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ns.has(r),{subprocessStdout:a,waitReadableDestroy:c}=m9(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=g9(a,o),{read:f,onStdoutDataDone:p}=_9({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new yft({read:f,destroy:Sft(S9.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return y9({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},m9=(t,e,r)=>{let n=U_(t,e),i=oA(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},g9=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:c9},_9=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ha(),o=pM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){vft(this,o,s)},onStdoutDataDone:s}},vft=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},y9=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await h9(t),await n,await f9(i),await e,r.readable&&r.push(null)}catch(s){await f9(i),RAe(r,s)}},S9=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await H_(r,e)&&(RAe(t,n),await mM(e,n))},RAe=(t,e)=>{gM(t,t.readable,e)};import{Writable as Eft}from"stream";import{callbackify as xAe}from"util";var OAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=v9(t,r,e),o=new Eft({...E9(n,t,i),destroy:xAe(T9.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return b9(n,o),o},v9=(t,e,r)=>{let n=CD(t,e),i=oA(r,n,"writableFinal"),s=oA(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},E9=(t,e,r)=>({write:bft.bind(void 0,t),final:xAe(Tft.bind(void 0,t,e,r))}),bft=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Tft=async(t,e,r)=>{await H_(r,e)&&(t.writable&&t.end(),await e)},b9=async(t,e,r)=>{try{await p9(t),e.writable&&e.end()}catch(n){await wAe(r),IAe(e,n)}},T9=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await H_(r,e),await H_(n,e)&&(IAe(t,i),await mM(e,i))},IAe=(t,e)=>{gM(t,t.writable,e)};import{Duplex as wft}from"stream";import{callbackify as Aft}from"util";var PAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ns.has(r),{subprocessStdout:c,waitReadableDestroy:u}=m9(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=v9(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=g9(c,a),{read:_,onStdoutDataDone:S}=_9({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),w=new wft({read:_,...E9(l,t,d),destroy:Aft(Rft.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return y9({subprocessStdout:c,onStdoutDataDone:S,readable:w,subprocess:t,subprocessStdin:l}),b9(l,w,c),w},Rft=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([S9({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),T9({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var w9=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ns.has(e),o=U_(t,r),a=pM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return xft(a,o,t)},xft=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var CAe=(t,{encoding:e})=>{let r=bAe();t.readable=AAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=OAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=PAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=w9.bind(void 0,t,e),t[Symbol.asyncIterator]=w9.bind(void 0,t,e,{})};var kAe=(t,e)=>{for(let[r,n]of Ift){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Oft=(async()=>{})().constructor.prototype,Ift=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Oft,t)]);var NAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=kft(t,e,r),{subprocess:f,promise:p}=Dft({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=fM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),kAe(f,p),Wa.set(f,{options:l,fileDescriptors:d}),f},kft=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=bD(t,e,r),{file:a,commandArguments:c,options:u}=qD(t,e,r),l=Nft(u),d=Gwe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Nft=({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}},Dft=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Cft(...BD(t,e,r))}catch(h){return zwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;Pft(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Xwe(c,a,u),tAe(c,r,u);let d={},f=Ha();c.kill=mbe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=mAe(c,r),CAe(c,r),Lwe(c,r);let p=Mft({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},Mft=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await EAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let S=h.map((y,v)=>cu(y,e,v)),w=cu(m,e,"all"),x=$ft({errorInfo:d,exitCode:f,signal:p,stdio:S,all:w,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return B_(x,n,e)},$ft=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?eA({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):QD({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var _M=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Lft(n,t[n],i)]));return{...t,...r}},Lft=(t,e,r)=>Uft.has(t)&&Sr(e)&&Sr(r)?{...e,...r}:r,Uft=new Set(["env",...eY]);var Kl=(t,e,r,n)=>{let i=(o,a,c)=>Kl(o,a,r,c),s=(...o)=>Fft({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Fft=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Sr(s))return i(t,_M(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=zft({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?Cwe(a,c,u):NAe(a,c,u,i)},zft=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Gve(e)?Vve(e,r):[e,...r],[o,a,c]=dD(...s),u=_M(_M(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var DAe=({file:t,commandArguments:e})=>$Ae(t,e),MAe=({file:t,commandArguments:e})=>({...$Ae(t,e),isSync:!0}),$Ae=(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]=jft(t);return{file:r,commandArguments:n}},jft=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(qft)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},qft=/ +/g;var LAe=(t,e,r)=>{t.sync=e(Bft,r),t.s=t.sync},UAe=({options:t})=>FAe(t),Bft=({options:t})=>({...FAe(t),isSync:!0}),FAe=t=>({options:{...Gft(t),...t}}),Gft=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},zAe={preferLocal:!0};var jAe=Kl(()=>({})),$ur=Kl(()=>({isSync:!0})),qAe=Kl(DAe),Lur=Kl(MAe),Uur=Kl(Jbe),Fur=Kl(UAe,{},zAe,LAe),{sendMessage:zur,getOneMessage:jur,getEachMessage:qur,getCancelSignal:Bur}=Uwe();var BAe=!1,GAe,Vft=t=>{GAe??=t},VAe=t=>{BAe=!0,Vft(t)},$n=()=>BAe,uu=()=>GAe,HAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var aA=null,WAe=t=>(aA&&aA.destroy(),aA=new Fs({totalAllowedTime:t}),aA),KAe=()=>aA;var Fs=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&$n())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await t0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{W.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),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 YAe={name:"@netlify/agent-runner-cli",type:"module",version:"2.9.0-nb7266f6744f08.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.5","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var Yft=Wft(import.meta.url),Zft=lu.dirname(Yft),Qft=Kft(import.meta.url),W_=re("shell"),A9=new Set,ZAe={preferLocal:!0},_t=(t,e,r)=>{let[n,i]=Jft(e,r),s={...ZAe,...i},o=jAe(t,n,s);JAe(o,s),tRe(o);let a=r?.idleTimeout;return a&&a>0&&eRe(o,a),o},QAe=(t,e)=>{let r={...ZAe,...e},n=qAe(t,r);return JAe(n,r),tRe(n),e?.idleTimeout&&e.idleTimeout>0&&eRe(n,e.idleTimeout),n},Jft=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},JAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Za.env.NETLIFY_LOCAL_QUIET==="true")return;if(Za.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Wb).pipe(Za.stdout),t.stderr?.pipe(new Wb).pipe(Za.stderr);return}t.stdout?.pipe(Za.stdout),t.stderr?.pipe(Za.stderr)},R9=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Za.kill(-t.pid,e),W_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return W_.error("Error killing process:",r),!1}},XAe=t=>R9(t,"SIGKILL"),eRe=(t,e)=>{let r=null,n=()=>{W_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),R9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(W_.log(`Force killing idle process ${t.pid}`),XAe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},tRe=t=>{A9.add(t);let e=KAe();if(e){let r=e.onTimesUp(()=>{W_.log(`Global timer expired, killing process ${t.pid}`),R9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(W_.log(`Force killing process ${t.pid} after timeout`),XAe(t))},5e3)});t.on("exit",()=>{A9.delete(t),r()}),t.on("error",()=>{A9.delete(t),r()})}};function SM(t,e){return!!Qo(t,e)}function Qo(t,e){if(!Za.env.NETLIFY_LOCAL_MODE)try{let i=Qft.resolve(YAe.name),s=lu.dirname(i);for(;s!==lu.dirname(s);){let o=lu.dirname(s);if(lu.basename(o)==="node_modules"){let a=lu.join(o,".bin",e);if(yM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Za.env.NODE_PATH){let i=lu.join(Za.env.NODE_PATH,".bin",e);if(yM.existsSync(i))return i}let r=lu.join(t,"node_modules",".bin",e);if(yM.existsSync(r))return r;let n=lu.join(Zft,"..","node_modules",".bin",e);if(yM.existsSync(n))return n}var K_=re("repo"),cRe="runner-diffs-",x9=t=>`${cRe}${t}-`,uRe=async t=>{let e=EM.tmpdir(),r;try{r=await ai.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(cRe)&&!n.startsWith(x9(t))).map(n=>ai.rm(zs.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},rRe=async t=>{let e=Xft("sha256");for await(let r of ept(t))e.update(r);return e.digest("hex")},nRe=async(t,e)=>t.size===e.size&&await rRe(t.path)===await rRe(e.path),lRe=/.. (.+)?\.log$/,tpt=[lRe],rpt=1,iRe=t=>{let e=t.split(`
|
|
388
|
+
if (condition) { yield value; }`)};import{Buffer as ult}from"buffer";import{StringDecoder as llt}from"string_decoder";var nM=(t,e,r)=>{if(r)return;if(t)return{transform:dlt.bind(void 0,new TextEncoder)};let n=new llt(e);return{transform:flt.bind(void 0,n),final:plt.bind(void 0,n)}},dlt=function*(t,e){ult.isBuffer(e)?yield su(e):typeof e=="string"?yield t.encode(e):yield e},flt=function*(t,e){yield zr(e)?t.write(e):e},plt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as mwe}from"util";var qY=mwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),iM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=mlt}=e[r];for await(let i of n(t))yield*iM(i,e,r+1)},gwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hlt(r,Number(e),t)},hlt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*iM(n,r,e+1)},_we=mwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),mlt=function*(t){yield t};var BY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},ywe=(t,e)=>[...e.flatMap(r=>[...xp(r,t,0)]),...tA(t)],xp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_lt}=e[r];for(let i of n(t))yield*xp(i,e,r+1)},tA=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*glt(r,Number(e),t)},glt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xp(n,r,e+1)},_lt=function*(t){yield t};var GY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=vwe(t,o,s),u=Rp(e),l=Rp(r),d=u?qY.bind(void 0,iM,a):BY.bind(void 0,xp),f=u||l?qY.bind(void 0,gwe,a):BY.bind(void 0,tA),p=u||l?_we.bind(void 0,a):void 0;return{stream:new ylt({writableObjectMode:n,writableHighWaterMark:Swe(n),readableObjectMode:i,readableHighWaterMark:Swe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},sM=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=vwe(o,r,a);t=ywe(c,t)}return t},vwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:fwe(n,a)},nM(r,o,n),rM(r,s,n,c),{transform:t,final:e},{transform:pwe(i,a)},dwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Ewe=(t,e)=>{for(let r of Slt(t))vlt(t,r,e)},Slt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),vlt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Wl[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Elt(a,n));r.input=Vw(o)},Elt=(t,e)=>{let r=sM(t,e,"utf8",!0);return blt(r),Vw(r)},blt=t=>{let e=t.find(r=>typeof r!="string"&&!zr(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 Rlt,appendFileSync as xlt}from"fs";var oM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&N_(r,n)&&!ns.has(e)&&Tlt(n)&&(t.some(({type:i,value:s})=>i==="native"&&wlt.has(s))||t.every(({type:i})=>Us.has(i))),Tlt=t=>t===1||t===2,wlt=new Set(["pipe","overlapped"]),bwe=async(t,e,r,n)=>{for await(let i of t)Alt(e)||wwe(i,r,n)},Twe=(t,e,r)=>{for(let n of t)wwe(n,e,r)},Alt=t=>t._readableState.pipes.length>0,wwe=(t,e,r)=>{let n=vD(t);Va({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Awe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>Olt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Olt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=RTe(t,s,d),p=su(f),{stdioItems:h,objectMode:m}=e[r],_=Ilt([p],h,c,n),{serializedResult:S,finalResult:w=S}=Plt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Clt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?w:void 0;try{return n.error===void 0&&klt(S,h,i),x}catch(y){return n.error=y,x}},Ilt=(t,e,r,n)=>{try{return sM(t,e,r,!1)}catch(i){return n.error=i,t}},Plt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Vw(t)};let o=zve(t,r);return n[s]?{serializedResult:o,finalResult:jY(o,!i[s],e)}:{serializedResult:o}},Clt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!oM({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=jY(t,!1,o);try{Twe(a,e,n)}catch(c){r.error??=c}},klt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>eM.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?xlt(n,t):(r.add(s),Rlt(n,t))}};var Rwe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,cu(e,r,"all")]:Array.isArray(e)?[cu(t,r,"all"),...e]:zr(t)&&zr(e)?ZK([t,e]):`${t}${e}`};import{once as VY}from"events";var xwe=async(t,e)=>{let[r,n]=await Nlt(t);return e.isForcefullyTerminated??=!1,[r,n]},Nlt=async t=>{let[e,r]=await Promise.allSettled([VY(t,"spawn"),VY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Owe(t):r.value},Owe=async t=>{try{return await VY(t,"exit")}catch{return Owe(t)}},Iwe=async t=>{let[e,r]=await t;if(!Dlt(e,r)&&HY(e,r))throw new Ko;return[e,r]},Dlt=(t,e)=>t===void 0&&e===void 0,HY=(t,e)=>t!==0||e!==null;var Pwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Mlt(t,e,r),o=s?.code==="ETIMEDOUT",a=ATe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Mlt=(t,e,r)=>t!==void 0?t:HY(e,r)?new Ko:void 0;var Cwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Llt(t,e,r),d=zlt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return B_(d,c,u)},Llt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=bD(t,e,r),a=Ult(r),{file:c,commandArguments:u,options:l}=qD(t,e,a);Flt(l);let d=awe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Ult=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Flt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&aM("ipcInput"),t&&aM("ipc: true"),r&&aM("detached: true"),n&&aM("cancelSignal")},aM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},zlt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=jlt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=Pwe(c,r),{output:h,error:m=u}=Awe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((w,x)=>cu(w,r,x)),S=cu(Rwe(h,r),r,"all");return Blt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},jlt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Ewe(s,r);let a=qlt(r);return $lt(...BD(t,e,a))}catch(a){return q_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},qlt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ZD(e)}),Blt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?QD({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):eA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as Pft}from"events";import{spawn as Cft}from"child_process";import $we from"process";import{once as WY,on as Glt}from"events";var kwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>($_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:$D(t)}),Vlt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Vlt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{kD(e,i);let s=Hl(t,e,r),o=new AbortController;try{return await Promise.race([Hlt(s,n,o),Wlt(s,r,o),Klt(s,r,o)])}catch(a){throw L_(t),a}finally{o.abort(),ND(e,i)}},Hlt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await WY(t,"message",{signal:r});return n}for await(let[n]of Glt(t,"message",{signal:r}))if(e(n))return n},Wlt=async(t,e,{signal:r})=>{await WY(t,"disconnect",{signal:r}),ybe(e)},Klt=async(t,e,{signal:r})=>{let[n]=await WY(t,"strict:error",{signal:r});throw ID(n,e)};import{once as Dwe,on as Ylt}from"events";var Mwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>KY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),KY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{$_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:$D(t)}),kD(e,s);let o=Hl(t,e,r),a=new AbortController,c={};return Zlt(t,o,a),Qlt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Jlt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Zlt=async(t,e,r)=>{try{await Dwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Qlt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Dwe(t,"strict:error",{signal:r.signal});n.error=ID(i,e),r.abort()}catch{}},Jlt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Ylt(r,"message",{signal:s.signal}))Nwe(o),yield c}catch{Nwe(o)}finally{s.abort(),ND(e,a),n||L_(t),i&&await t}},Nwe=({error:t})=>{if(t)throw t};var Lwe=(t,{ipc:e})=>{Object.assign(t,Fwe(t,!1,e))},Uwe=()=>{let t=$we,e=!0,r=$we.channel!==void 0;return{...Fwe(t,e,r),getCancelSignal:Vbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Fwe=(t,e,r)=>({sendMessage:zD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:kwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Mwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Xlt}from"child_process";import{PassThrough as edt,Readable as tdt,Writable as rdt,Duplex as ndt}from"stream";var zwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{UY(n);let a=new Xlt;idt(a,n),Object.assign(a,{readable:sdt,writable:odt,duplex:adt});let c=q_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=cdt(c,o,i);return{subprocess:a,promise:u}},idt=(t,e)=>{let r=rA(),n=rA(),i=rA(),s=Array.from({length:e.length-3},rA),o=rA(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},rA=()=>{let t=new edt;return t.end(),t},sdt=()=>new tdt({read(){}}),odt=()=>new rdt({write(){}}),adt=()=>new ndt({read(){},write(){}}),cdt=async(t,e,r)=>B_(t,e,r);import{createReadStream as jwe,createWriteStream as qwe}from"fs";import{Buffer as udt}from"buffer";import{Readable as nA,Writable as ldt,Duplex as ddt}from"stream";var Gwe=(t,e)=>tM(fdt,t,e,!1),iA=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Wl[t]}.`)},Bwe={fileNumber:iA,generator:GY,asyncGenerator:GY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ddt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},fdt={input:{...Bwe,fileUrl:({value:t})=>({stream:jwe(t)}),filePath:({value:{file:t}})=>({stream:jwe(t)}),webStream:({value:t})=>({stream:nA.fromWeb(t)}),iterable:({value:t})=>({stream:nA.from(t)}),asyncIterable:({value:t})=>({stream:nA.from(t)}),string:({value:t})=>({stream:nA.from(t)}),uint8Array:({value:t})=>({stream:nA.from(udt.from(t))})},output:{...Bwe,fileUrl:({value:t})=>({stream:qwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:qwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ldt.fromWeb(t)}),iterable:iA,asyncIterable:iA,string:iA,uint8Array:iA}};import{on as pdt,once as Vwe}from"events";import{PassThrough as hdt,getDefaultHighWaterMark as mdt}from"stream";import{finished as Kwe}from"stream/promises";function Op(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)ZY(i);let e=t.some(({readableObjectMode:i})=>i),r=gdt(t,e),n=new YY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var gdt=(t,e)=>{if(t.length===0)return mdt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},YY=class extends hdt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(ZY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=_dt(this,this.#e,this.#s);let r=vdt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(ZY(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},_dt=async(t,e,r)=>{cM(t,Hwe);let n=new AbortController;try{await Promise.race([ydt(t,n),Sdt(t,e,r,n)])}finally{n.abort(),cM(t,-Hwe)}},ydt=async(t,{signal:e})=>{try{await Kwe(t,{signal:e,cleanup:!0})}catch(r){throw Ywe(t,r),r}},Sdt=async(t,e,r,{signal:n})=>{for await(let[i]of pdt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},ZY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},vdt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{cM(t,Wwe);let a=new AbortController;try{await Promise.race([Edt(s,e,a),bdt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Tdt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),cM(t,-Wwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?QY(t):wdt(t))},Edt=async(t,e,{signal:r})=>{try{await t,r.aborted||QY(e)}catch(n){r.aborted||Ywe(e,n)}},bdt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Kwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Zwe(o)?i.add(e):Qwe(t,o)}},Tdt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Vwe(t,i,{signal:s}),!t.readable)return Vwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},wdt=t=>{t.writable&&t.end()},Ywe=(t,e)=>{Zwe(e)?QY(t):Qwe(t,e)},Zwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",QY=t=>{(t.readable||t.writable)&&t.destroy()},Qwe=(t,e)=>{t.destroyed||(t.once("error",Adt),t.destroy(e))},Adt=()=>{},cM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Hwe=2,Wwe=1;import{finished as Jwe}from"stream/promises";var V_=(t,e)=>{t.pipe(e),Rdt(t,e),xdt(t,e)},Rdt=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Jwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}JY(e)}},JY=t=>{t.writable&&t.end()},xdt=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Jwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}XY(t)}},XY=t=>{t.readable&&t.destroy()};var Xwe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Us.has(c)))Odt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Us.has(c)))Pdt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Op(s);V_(o,i)}},Odt=(t,e,r,n)=>{r==="output"?V_(t.stdio[n],e):V_(e,t.stdio[n]);let i=Idt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Idt=["stdin","stdout","stderr"],Pdt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Cdt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Cdt=(t,{signal:e})=>{Wo(t)&&wp(t,kdt,e)},kdt=2;import{addAbortListener as Mdt}from"events";var Ip=[];Ip.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ip.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ip.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var uM=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",e9=Symbol.for("signal-exit emitter"),t9=globalThis,Ndt=Object.defineProperty.bind(Object),r9=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(t9[e9])return t9[e9];Ndt(t9,e9,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},lM=class{},Ddt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),n9=class extends lM{onExit(){return()=>{}}load(){}unload(){}},i9=class extends lM{#e=s9.platform==="win32"?"SIGINT":"SIGHUP";#r=new r9;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ip)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!uM(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 Ip)try{let r=this.#i[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,Ip.forEach(e=>{let r=this.#i[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.#s,this.#r.count-=1)}#a(e){return uM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&uM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},s9=globalThis.process,{onExit:eAe,load:Vor,unload:Hor}=Ddt(uM(s9)?new i9(s9):new n9);var tAe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=eAe(()=>{t.kill()});Mdt(n,()=>{i()})};var nAe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ED(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=$dt(r,n,i),{sourceStream:d,sourceError:f}=Udt(t,u),{options:p,fileDescriptors:h}=Wa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},$dt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Ldt(t,e,...r),a=CD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Ldt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(rAe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||KK(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[i,s,o]=dD(r,...n);return{destination:e(rAe)(i,s,o),pipeOptions:o}}if(Wa.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}`)},rAe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Udt=(t,e)=>{try{return{sourceStream:U_(t,e)}}catch(r){return{sourceError:r}}};var sAe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Fdt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw o9({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Fdt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return XY(t),n;if(e!==void 0)return JY(r),e},o9=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>q_({error:t,command:iAe,escapedCommand:iAe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),iAe="source.pipe(destination)";var oAe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as zdt}from"stream/promises";var aAe=(t,e,r)=>{let n=dM.has(e)?qdt(t,e):jdt(t,e);return wp(t,Gdt,r.signal),wp(e,Vdt,r.signal),Bdt(e),n},jdt=(t,e)=>{let r=Op([t]);return V_(r,e),dM.set(e,r),r},qdt=(t,e)=>{let r=dM.get(e);return r.add(t),r},Bdt=async t=>{try{await zdt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}dM.delete(t)},dM=new WeakMap,Gdt=2,Vdt=1;import{aborted as Hdt}from"util";var cAe=(t,e)=>t===void 0?[]:[Wdt(t,e)],Wdt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Hdt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw o9({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var fM=(t,...e)=>{if(Sr(e[0]))return fM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=nAe(t,...e),i=Kdt({...n,destination:r});return i.pipe=fM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Kdt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Ydt(t,i);sAe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=aAe(e,s,d);return await Promise.race([oAe(l),...cAe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Ydt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as rft}from"timers/promises";import{on as Zdt}from"events";import{getDefaultHighWaterMark as Qdt}from"stream";var pM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Jdt(e,o),lAe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Jdt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},a9=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Xdt(e,o,t);let a=t.readableObjectMode&&!s;return lAe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Xdt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},lAe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Zdt(t,"data",{signal:e.signal,highWaterMark:uAe,highWatermark:uAe});return eft({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},c9=Qdt(!0),uAe=c9,eft=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=tft({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*xp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*tA(a)}},tft=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[nM(t,r,!e),rM(t,i,!n,{})].filter(Boolean);var dAe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=nft({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([ift(t),d]);return}let f=FY(c,r),p=a9({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([sft({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},nft=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!oM({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=a9({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bwe(a,t,r,s)},ift=async t=>{await rft(),t.readableFlowing===null&&t.resume()},sft=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await WD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await KD(r,{maxBuffer:s})):await j_(r,{maxBuffer:s})}catch(a){return fAe(bTe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},u9=async t=>{try{return await t}catch(e){return fAe(e)}},fAe=({bufferedData:t})=>Uve(t)?new Uint8Array(t):t;import{finished as oft}from"stream/promises";var sA=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=aft(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],oft(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||lft(a,e,r,n)}finally{o.abort()}},aft=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&cft(t,r,n),n},cft=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{uft(e,r),n.call(t,...i)}},uft=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},lft=(t,e,r,n)=>{if(!dft(t,e,r,n))throw t},dft=(t,e,r,n=!0)=>r.propagating?pAe(t)||hM(t):(r.propagating=!0,l9(r,e)===n?pAe(t):hM(t)),l9=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",hM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pAe=t=>t?.code==="EPIPE";var hAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>d9({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),d9=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=sA(t,e,u);if(l9(u,e)){await l;return}let[d]=await Promise.all([dAe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var mAe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Op([t,e].filter(Boolean)):void 0,gAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>d9({...fft(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:pft(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),fft=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},pft=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as hft}from"events";var _Ae=t=>N_(t,"ipc"),yAe=(t,e)=>{let r=vD(t);Va({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var SAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=_Ae(s),a=ou(e,"ipc"),c=ou(r,"ipc");for await(let u of KY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(TTe(t,i,c),i.push(u)),o&&yAe(u,s);return i},vAe=async(t,e)=>(await Promise.allSettled([t]),e);var EAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let w=xwe(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:w,propagating:!1},y=hAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),v=gAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),E=[],R=SAe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=mft(m,t,x),I=gft(h,x);try{return await Promise.race([Promise.all([{},Iwe(w),Promise.all(y),v,R,tTe(t,d),...C,...I]),_,_ft(t,S),...Zbe(t,s,f,S),..._be({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Kbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},w,Promise.all(y.map(T=>u9(T))),u9(v),vAe(R,E),Promise.allSettled(C),Promise.allSettled(I)])}},mft=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:sA(n,i,r)),gft=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Zo(s,{checkOpen:!1})&&!Wo(s)).map(({type:i,value:s,stream:o=s})=>sA(o,n,e,{isSameDirection:Us.has(i),stopOnExit:i==="native"}))),_ft=async(t,{signal:e})=>{let[r]=await hft(t,"error",{signal:e});throw r};var bAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oA=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ha();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},H_=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 yft}from"stream";import{callbackify as Sft}from"util";import{finished as TAe}from"stream/promises";var f9=async t=>{if(t!==void 0)try{await p9(t)}catch{}},wAe=async t=>{if(t!==void 0)try{await h9(t)}catch{}},p9=async t=>{await TAe(t,{cleanup:!0,readable:!1,writable:!0})},h9=async t=>{await TAe(t,{cleanup:!0,readable:!0,writable:!1})},mM=async(t,e)=>{if(await t,e)throw e},gM=(t,e,r)=>{r&&!hM(r)?t.destroy(r):e&&t.destroy()};var AAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ns.has(r),{subprocessStdout:a,waitReadableDestroy:c}=m9(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=g9(a,o),{read:f,onStdoutDataDone:p}=_9({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new yft({read:f,destroy:Sft(S9.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return y9({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},m9=(t,e,r)=>{let n=U_(t,e),i=oA(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},g9=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:c9},_9=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ha(),o=pM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){vft(this,o,s)},onStdoutDataDone:s}},vft=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},y9=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await h9(t),await n,await f9(i),await e,r.readable&&r.push(null)}catch(s){await f9(i),RAe(r,s)}},S9=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await H_(r,e)&&(RAe(t,n),await mM(e,n))},RAe=(t,e)=>{gM(t,t.readable,e)};import{Writable as Eft}from"stream";import{callbackify as xAe}from"util";var OAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=v9(t,r,e),o=new Eft({...E9(n,t,i),destroy:xAe(T9.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return b9(n,o),o},v9=(t,e,r)=>{let n=CD(t,e),i=oA(r,n,"writableFinal"),s=oA(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},E9=(t,e,r)=>({write:bft.bind(void 0,t),final:xAe(Tft.bind(void 0,t,e,r))}),bft=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Tft=async(t,e,r)=>{await H_(r,e)&&(t.writable&&t.end(),await e)},b9=async(t,e,r)=>{try{await p9(t),e.writable&&e.end()}catch(n){await wAe(r),IAe(e,n)}},T9=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await H_(r,e),await H_(n,e)&&(IAe(t,i),await mM(e,i))},IAe=(t,e)=>{gM(t,t.writable,e)};import{Duplex as wft}from"stream";import{callbackify as Aft}from"util";var PAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ns.has(r),{subprocessStdout:c,waitReadableDestroy:u}=m9(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=v9(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=g9(c,a),{read:_,onStdoutDataDone:S}=_9({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),w=new wft({read:_,...E9(l,t,d),destroy:Aft(Rft.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return y9({subprocessStdout:c,onStdoutDataDone:S,readable:w,subprocess:t,subprocessStdin:l}),b9(l,w,c),w},Rft=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([S9({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),T9({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var w9=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ns.has(e),o=U_(t,r),a=pM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return xft(a,o,t)},xft=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var CAe=(t,{encoding:e})=>{let r=bAe();t.readable=AAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=OAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=PAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=w9.bind(void 0,t,e),t[Symbol.asyncIterator]=w9.bind(void 0,t,e,{})};var kAe=(t,e)=>{for(let[r,n]of Ift){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Oft=(async()=>{})().constructor.prototype,Ift=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Oft,t)]);var NAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=kft(t,e,r),{subprocess:f,promise:p}=Dft({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=fM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),kAe(f,p),Wa.set(f,{options:l,fileDescriptors:d}),f},kft=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=bD(t,e,r),{file:a,commandArguments:c,options:u}=qD(t,e,r),l=Nft(u),d=Gwe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Nft=({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}},Dft=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Cft(...BD(t,e,r))}catch(h){return zwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;Pft(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Xwe(c,a,u),tAe(c,r,u);let d={},f=Ha();c.kill=mbe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=mAe(c,r),CAe(c,r),Lwe(c,r);let p=Mft({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},Mft=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await EAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let S=h.map((y,v)=>cu(y,e,v)),w=cu(m,e,"all"),x=$ft({errorInfo:d,exitCode:f,signal:p,stdio:S,all:w,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return B_(x,n,e)},$ft=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?eA({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):QD({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var _M=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Lft(n,t[n],i)]));return{...t,...r}},Lft=(t,e,r)=>Uft.has(t)&&Sr(e)&&Sr(r)?{...e,...r}:r,Uft=new Set(["env",...eY]);var Kl=(t,e,r,n)=>{let i=(o,a,c)=>Kl(o,a,r,c),s=(...o)=>Fft({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Fft=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Sr(s))return i(t,_M(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=zft({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?Cwe(a,c,u):NAe(a,c,u,i)},zft=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Gve(e)?Vve(e,r):[e,...r],[o,a,c]=dD(...s),u=_M(_M(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var DAe=({file:t,commandArguments:e})=>$Ae(t,e),MAe=({file:t,commandArguments:e})=>({...$Ae(t,e),isSync:!0}),$Ae=(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]=jft(t);return{file:r,commandArguments:n}},jft=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(qft)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},qft=/ +/g;var LAe=(t,e,r)=>{t.sync=e(Bft,r),t.s=t.sync},UAe=({options:t})=>FAe(t),Bft=({options:t})=>({...FAe(t),isSync:!0}),FAe=t=>({options:{...Gft(t),...t}}),Gft=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},zAe={preferLocal:!0};var jAe=Kl(()=>({})),$ur=Kl(()=>({isSync:!0})),qAe=Kl(DAe),Lur=Kl(MAe),Uur=Kl(Jbe),Fur=Kl(UAe,{},zAe,LAe),{sendMessage:zur,getOneMessage:jur,getEachMessage:qur,getCancelSignal:Bur}=Uwe();var BAe=!1,GAe,Vft=t=>{GAe??=t},VAe=t=>{BAe=!0,Vft(t)},$n=()=>BAe,uu=()=>GAe,HAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var aA=null,WAe=t=>(aA&&aA.destroy(),aA=new Fs({totalAllowedTime:t}),aA),KAe=()=>aA;var Fs=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&$n())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await t0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{W.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),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 YAe={name:"@netlify/agent-runner-cli",type:"module",version:"2.9.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.5","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var Yft=Wft(import.meta.url),Zft=lu.dirname(Yft),Qft=Kft(import.meta.url),W_=re("shell"),A9=new Set,ZAe={preferLocal:!0},_t=(t,e,r)=>{let[n,i]=Jft(e,r),s={...ZAe,...i},o=jAe(t,n,s);JAe(o,s),tRe(o);let a=r?.idleTimeout;return a&&a>0&&eRe(o,a),o},QAe=(t,e)=>{let r={...ZAe,...e},n=qAe(t,r);return JAe(n,r),tRe(n),e?.idleTimeout&&e.idleTimeout>0&&eRe(n,e.idleTimeout),n},Jft=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},JAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Za.env.NETLIFY_LOCAL_QUIET==="true")return;if(Za.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Wb).pipe(Za.stdout),t.stderr?.pipe(new Wb).pipe(Za.stderr);return}t.stdout?.pipe(Za.stdout),t.stderr?.pipe(Za.stderr)},R9=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Za.kill(-t.pid,e),W_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return W_.error("Error killing process:",r),!1}},XAe=t=>R9(t,"SIGKILL"),eRe=(t,e)=>{let r=null,n=()=>{W_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),R9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(W_.log(`Force killing idle process ${t.pid}`),XAe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},tRe=t=>{A9.add(t);let e=KAe();if(e){let r=e.onTimesUp(()=>{W_.log(`Global timer expired, killing process ${t.pid}`),R9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(W_.log(`Force killing process ${t.pid} after timeout`),XAe(t))},5e3)});t.on("exit",()=>{A9.delete(t),r()}),t.on("error",()=>{A9.delete(t),r()})}};function SM(t,e){return!!Qo(t,e)}function Qo(t,e){if(!Za.env.NETLIFY_LOCAL_MODE)try{let i=Qft.resolve(YAe.name),s=lu.dirname(i);for(;s!==lu.dirname(s);){let o=lu.dirname(s);if(lu.basename(o)==="node_modules"){let a=lu.join(o,".bin",e);if(yM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Za.env.NODE_PATH){let i=lu.join(Za.env.NODE_PATH,".bin",e);if(yM.existsSync(i))return i}let r=lu.join(t,"node_modules",".bin",e);if(yM.existsSync(r))return r;let n=lu.join(Zft,"..","node_modules",".bin",e);if(yM.existsSync(n))return n}var K_=re("repo"),cRe="runner-diffs-",x9=t=>`${cRe}${t}-`,uRe=async t=>{let e=EM.tmpdir(),r;try{r=await ai.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(cRe)&&!n.startsWith(x9(t))).map(n=>ai.rm(zs.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},rRe=async t=>{let e=Xft("sha256");for await(let r of ept(t))e.update(r);return e.digest("hex")},nRe=async(t,e)=>t.size===e.size&&await rRe(t.path)===await rRe(e.path),lRe=/.. (.+)?\.log$/,tpt=[lRe],rpt=1,iRe=t=>{let e=t.split(`
|
|
389
389
|
`).reduce((r,n)=>{if(!n)return r;let[i,s,,...o]=n,a=o.join(""),c=i.trim(),u=s.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},npt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),sRe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return yn(r?`${e}: ${r}`:e)},ipt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),oRe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),spt=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&oRe(n)===oRe(r)&&n.password!==""}catch{return!1}},aRe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},vM=500,cA=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Ln=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),s=new Set(n.changedFiles),o=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!s.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),o.length>0&&await ai.writeFile(await this.getSetupMetadataPath(),JSON.stringify(o)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new cA(r,n)}}run(e,r={}){return _t("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){K_.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!r){let u=iRe(s);await this.discardSetupOnlyChanges(u)}K_.info("Changes after processing"),await this.getStatus();let o=await this.getIgnoredPathspecs(s);if(await this.stageFiles(o),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:o};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await ai.mkdtemp(zs.join(EM.tmpdir(),x9(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:o});return await this.rollbackIfLocal(),c.hasChanges&&W.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
390
390
|
`).filter(i=>tpt.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await ai.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
391
391
|
`)})}async stageBuildSetup(){await ai.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return zs.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=vM){let s=e.slice(i,i+vM).map(a=>`:(literal)${a}`),{stdout:o}=await this.run(["ls-files","--stage","-z","--",...s],{...aRe,...r});for(let a of String(o??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await ai.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},s=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),o=r.filter(({filePath:a,entry:c})=>s.get(a)===c);o.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:o.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();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 e.split(`
|
package/dist/bin.js
CHANGED
|
@@ -597,7 +597,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
597
597
|
`,LF:`
|
|
598
598
|
`,concatBytes:VZ},UMt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},FMt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:UMt};import{Buffer as jMt}from"buffer";var Vke=(t,e)=>t?void 0:zMt.bind(void 0,e),zMt=function*(t,e){if(typeof e!="string"&&!Sn(e)&&!jMt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Gke=(t,e)=>t?qMt.bind(void 0,e):BMt.bind(void 0,e),qMt=function*(t,e){Wke(t,e),yield e},BMt=function*(t,e){if(Wke(t,e),typeof e!="string"&&!Sn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Wke=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
599
599
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
600
|
-
if (condition) { yield value; }`)};import{Buffer as HMt}from"buffer";import{StringDecoder as VMt}from"string_decoder";var CM=(t,e,r)=>{if(r)return;if(t)return{transform:GMt.bind(void 0,new TextEncoder)};let n=new VMt(e);return{transform:WMt.bind(void 0,n),final:KMt.bind(void 0,n)}},GMt=function*(t,e){HMt.isBuffer(e)?yield ul(e):typeof e=="string"?yield t.encode(e):yield e},WMt=function*(t,e){yield Sn(e)?t.write(e):e},KMt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Kke}from"util";var WZ=Kke(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),NM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JMt}=e[r];for await(let i of n(t))yield*NM(i,e,r+1)},Yke=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*YMt(r,Number(e),t)},YMt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*NM(n,r,e+1)},Jke=Kke(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),JMt=function*(t){yield t};var KZ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zke=(t,e)=>[...e.flatMap(r=>[...om(r,t,0)]),...h0(t)],om=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XMt}=e[r];for(let i of n(t))yield*om(i,e,r+1)},h0=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZMt(r,Number(e),t)},ZMt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*om(n,r,e+1)},XMt=function*(t){yield t};var YZ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Qke(t,o,s),u=sm(e),l=sm(r),d=u?WZ.bind(void 0,NM,a):KZ.bind(void 0,om),f=u||l?WZ.bind(void 0,Yke,a):KZ.bind(void 0,h0),p=u||l?Jke.bind(void 0,a):void 0;return{stream:new QMt({writableObjectMode:n,writableHighWaterMark:Xke(n),readableObjectMode:i,readableHighWaterMark:Xke(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},kM=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Qke(o,r,a);t=Zke(c,t)}return t},Qke=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Vke(n,a)},CM(r,o,n),IM(r,s,n,c),{transform:t,final:e},{transform:Gke(i,a)},Hke({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var eDe=(t,e)=>{for(let r of e1t(t))t1t(t,r,e)},e1t=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),t1t=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${hf[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>r1t(a,n));r.input=i0(o)},r1t=(t,e)=>{let r=kM(t,e,"utf8",!0);return n1t(r),i0(r)},n1t=t=>{let e=t.find(r=>typeof r!="string"&&!Sn(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 a1t,appendFileSync as c1t}from"fs";var DM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&ES(r,n)&&!Hs.has(e)&&i1t(n)&&(t.some(({type:i,value:s})=>i==="native"&&s1t.has(s))||t.every(({type:i})=>Mo.has(i))),i1t=t=>t===1||t===2,s1t=new Set(["pipe","overlapped"]),tDe=async(t,e,r,n)=>{for await(let i of t)o1t(e)||nDe(i,r,n)},rDe=(t,e,r)=>{for(let n of t)nDe(n,e,r)},o1t=t=>t._readableState.pipes.length>0,nDe=(t,e,r)=>{let n=K$(t);qc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var iDe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>u1t({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},u1t=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=ske(t,s,d),p=ul(f),{stdioItems:h,objectMode:m}=e[r],g=l1t([p],h,c,n),{serializedResult:y,finalResult:v=y}=d1t({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});f1t({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&p1t(y,h,i),S}catch(_){return n.error=_,S}},l1t=(t,e,r,n)=>{try{return kM(t,e,r,!1)}catch(i){return n.error=i,t}},d1t=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:i0(t)};let o=SIe(t,r);return n[s]?{serializedResult:o,finalResult:GZ(o,!i[s],e)}:{serializedResult:o}},f1t=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DM({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GZ(t,!1,o);try{rDe(a,e,n)}catch(c){r.error??=c}},p1t=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OM.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?c1t(n,t):(r.add(s),a1t(n,t))}};var sDe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,fl(e,r,"all")]:Array.isArray(e)?[fl(t,r,"all"),...e]:Sn(t)&&Sn(e)?tZ([t,e]):`${t}${e}`};import{once as JZ}from"events";var oDe=async(t,e)=>{let[r,n]=await h1t(t);return e.isForcefullyTerminated??=!1,[r,n]},h1t=async t=>{let[e,r]=await Promise.allSettled([JZ(t,"spawn"),JZ(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?aDe(t):r.value},aDe=async t=>{try{return await JZ(t,"exit")}catch{return aDe(t)}},cDe=async t=>{let[e,r]=await t;if(!m1t(e,r)&&ZZ(e,r))throw new Da;return[e,r]},m1t=(t,e)=>t===void 0&&e===void 0,ZZ=(t,e)=>t!==0||e!==null;var uDe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=g1t(t,e,r),o=s?.code==="ETIMEDOUT",a=ike(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},g1t=(t,e,r)=>t!==void 0?t:ZZ(e,r)?new Da:void 0;var lDe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=y1t(t,e,r),d=v1t({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return IS(d,c,u)},y1t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=J$(t,e,r),a=S1t(r),{file:c,commandArguments:u,options:l}=gM(t,e,a);E1t(l);let d=jke(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},S1t=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,E1t=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},v1t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=b1t({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=uDe(c,r),{output:h,error:m=u}=iDe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((v,S)=>fl(v,r,S)),y=fl(sDe(h,r),r,"all");return T1t({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},b1t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{eDe(s,r);let a=w1t(r);return _1t(..._M(t,e,a))}catch(a){return PS({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},w1t=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:TM(e)}),T1t=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?RM({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):p0({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as dFt}from"events";import{spawn as fFt}from"child_process";import mDe from"process";import{once as XZ,on as R1t}from"events";var dDe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(wS({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:lM(t)}),A1t({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),A1t=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{oM(e,i);let s=pf(t,e,r),o=new AbortController;try{return await Promise.race([x1t(s,n,o),O1t(s,r,o),P1t(s,r,o)])}catch(a){throw TS(t),a}finally{o.abort(),aM(e,i)}},x1t=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await XZ(t,"message",{signal:r});return n}for await(let[n]of R1t(t,"message",{signal:r}))if(e(n))return n},O1t=async(t,e,{signal:r})=>{await XZ(t,"disconnect",{signal:r}),ZCe(e)},P1t=async(t,e,{signal:r})=>{let[n]=await XZ(t,"strict:error",{signal:r});throw nM(n,e)};import{once as pDe,on as I1t}from"events";var hDe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>QZ({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),QZ=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{wS({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:lM(t)}),oM(e,s);let o=pf(t,e,r),a=new AbortController,c={};return C1t(t,o,a),N1t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),k1t({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},C1t=async(t,e,r)=>{try{await pDe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},N1t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await pDe(t,"strict:error",{signal:r.signal});n.error=nM(i,e),r.abort()}catch{}},k1t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of I1t(r,"message",{signal:s.signal}))fDe(o),yield c}catch{fDe(o)}finally{s.abort(),aM(e,a),n||TS(t),i&&await t}},fDe=({error:t})=>{if(t)throw t};var gDe=(t,{ipc:e})=>{Object.assign(t,yDe(t,!1,e))},_De=()=>{let t=mDe,e=!0,r=mDe.channel!==void 0;return{...yDe(t,e,r),getCancelSignal:TNe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},yDe=(t,e,r)=>({sendMessage:hM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:dDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:hDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as D1t}from"child_process";import{PassThrough as L1t,Readable as $1t,Writable as M1t,Duplex as U1t}from"stream";var SDe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{BZ(n);let a=new D1t;F1t(a,n),Object.assign(a,{readable:j1t,writable:z1t,duplex:q1t});let c=PS({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=B1t(c,o,i);return{subprocess:a,promise:u}},F1t=(t,e)=>{let r=m0(),n=m0(),i=m0(),s=Array.from({length:e.length-3},m0),o=m0(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},m0=()=>{let t=new L1t;return t.end(),t},j1t=()=>new $1t({read(){}}),z1t=()=>new M1t({write(){}}),q1t=()=>new U1t({read(){},write(){}}),B1t=async(t,e,r)=>IS(t,e,r);import{createReadStream as EDe,createWriteStream as vDe}from"fs";import{Buffer as H1t}from"buffer";import{Readable as g0,Writable as V1t,Duplex as G1t}from"stream";var wDe=(t,e)=>PM(W1t,t,e,!1),_0=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${hf[t]}.`)},bDe={fileNumber:_0,generator:YZ,asyncGenerator:YZ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:G1t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},W1t={input:{...bDe,fileUrl:({value:t})=>({stream:EDe(t)}),filePath:({value:{file:t}})=>({stream:EDe(t)}),webStream:({value:t})=>({stream:g0.fromWeb(t)}),iterable:({value:t})=>({stream:g0.from(t)}),asyncIterable:({value:t})=>({stream:g0.from(t)}),string:({value:t})=>({stream:g0.from(t)}),uint8Array:({value:t})=>({stream:g0.from(H1t.from(t))})},output:{...bDe,fileUrl:({value:t})=>({stream:vDe(t)}),filePath:({value:{file:t,append:e}})=>({stream:vDe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:V1t.fromWeb(t)}),iterable:_0,asyncIterable:_0,string:_0,uint8Array:_0}};import{on as K1t,once as TDe}from"events";import{PassThrough as Y1t,getDefaultHighWaterMark as J1t}from"stream";import{finished as xDe}from"stream/promises";function am(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)tX(i);let e=t.some(({readableObjectMode:i})=>i),r=Z1t(t,e),n=new eX({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Z1t=(t,e)=>{if(t.length===0)return J1t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},eX=class extends Y1t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(tX(e),this.#e.has(e))return;this.#e.add(e),this.#n??=X1t(this,this.#e,this.#s);let r=tUt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(tX(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},X1t=async(t,e,r)=>{$M(t,RDe);let n=new AbortController;try{await Promise.race([Q1t(t,n),eUt(t,e,r,n)])}finally{n.abort(),$M(t,-RDe)}},Q1t=async(t,{signal:e})=>{try{await xDe(t,{signal:e,cleanup:!0})}catch(r){throw ODe(t,r),r}},eUt=async(t,e,r,{signal:n})=>{for await(let[i]of K1t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},tX=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},tUt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{$M(t,ADe);let a=new AbortController;try{await Promise.race([rUt(s,e,a),nUt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),iUt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),$M(t,-ADe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?rX(t):sUt(t))},rUt=async(t,e,{signal:r})=>{try{await t,r.aborted||rX(e)}catch(n){r.aborted||ODe(e,n)}},nUt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await xDe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;PDe(o)?i.add(e):IDe(t,o)}},iUt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await TDe(t,i,{signal:s}),!t.readable)return TDe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},sUt=t=>{t.writable&&t.end()},ODe=(t,e)=>{PDe(e)?rX(t):IDe(t,e)},PDe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",rX=t=>{(t.readable||t.writable)&&t.destroy()},IDe=(t,e)=>{t.destroyed||(t.once("error",oUt),t.destroy(e))},oUt=()=>{},$M=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},RDe=2,ADe=1;import{finished as CDe}from"stream/promises";var NS=(t,e)=>{t.pipe(e),aUt(t,e),cUt(t,e)},aUt=async(t,e)=>{if(!(ka(t)||ka(e))){try{await CDe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}nX(e)}},nX=t=>{t.writable&&t.end()},cUt=async(t,e)=>{if(!(ka(t)||ka(e))){try{await CDe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}iX(t)}},iX=t=>{t.readable&&t.destroy()};var NDe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Mo.has(c)))uUt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Mo.has(c)))dUt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:am(s);NS(o,i)}},uUt=(t,e,r,n)=>{r==="output"?NS(t.stdio[n],e):NS(e,t.stdio[n]);let i=lUt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lUt=["stdin","stdout","stderr"],dUt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;fUt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},fUt=(t,{signal:e})=>{ka(t)&&nm(t,pUt,e)},pUt=2;import{addAbortListener as gUt}from"events";var cm=[];cm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&cm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&cm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var MM=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",sX=Symbol.for("signal-exit emitter"),oX=globalThis,hUt=Object.defineProperty.bind(Object),aX=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(oX[sX])return oX[sX];hUt(oX,sX,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},UM=class{},mUt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),cX=class extends UM{onExit(){return()=>{}}load(){}unload(){}},uX=class extends UM{#e=lX.platform==="win32"?"SIGINT":"SIGHUP";#r=new aX;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of cm)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!MM(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 cm)try{let r=this.#i[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,cm.forEach(e=>{let r=this.#i[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.#s,this.#r.count-=1)}#a(e){return MM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&MM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},lX=globalThis.process,{onExit:kDe,load:yUr,unload:SUr}=mUt(MM(lX)?new uX(lX):new cX);var DDe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=kDe(()=>{t.kill()});gUt(n,()=>{i()})};var $De=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=Y$(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=_Ut(r,n,i),{sourceStream:d,sourceError:f}=SUt(t,u),{options:p,fileDescriptors:h}=Hc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},_Ut=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=yUt(t,e,...r),a=sM(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},yUt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(LDe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||QJ(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[i,s,o]=F$(r,...n);return{destination:e(LDe)(i,s,o),pipeOptions:o}}if(Hc.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}`)},LDe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),SUt=(t,e)=>{try{return{sourceStream:RS(t,e)}}catch(r){return{sourceError:r}}};var UDe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=EUt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw dX({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},EUt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return iX(t),n;if(e!==void 0)return nX(r),e},dX=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>PS({error:t,command:MDe,escapedCommand:MDe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),MDe="source.pipe(destination)";var FDe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as vUt}from"stream/promises";var jDe=(t,e,r)=>{let n=FM.has(e)?wUt(t,e):bUt(t,e);return nm(t,RUt,r.signal),nm(e,AUt,r.signal),TUt(e),n},bUt=(t,e)=>{let r=am([t]);return NS(r,e),FM.set(e,r),r},wUt=(t,e)=>{let r=FM.get(e);return r.add(t),r},TUt=async t=>{try{await vUt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}FM.delete(t)},FM=new WeakMap,RUt=2,AUt=1;import{aborted as xUt}from"util";var zDe=(t,e)=>t===void 0?[]:[OUt(t,e)],OUt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await xUt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw dX({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var jM=(t,...e)=>{if(Kr(e[0]))return jM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$De(t,...e),i=PUt({...n,destination:r});return i.pipe=jM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},PUt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=IUt(t,i);UDe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=jDe(e,s,d);return await Promise.race([FDe(l),...zDe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},IUt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as MUt}from"timers/promises";import{on as CUt}from"events";import{getDefaultHighWaterMark as NUt}from"stream";var zM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return kUt(e,o),BDe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},kUt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},fX=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;DUt(e,o,t);let a=t.readableObjectMode&&!s;return BDe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},DUt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},BDe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=CUt(t,"data",{signal:e.signal,highWaterMark:qDe,highWatermark:qDe});return LUt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},pX=NUt(!0),qDe=pX,LUt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Ut({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*om(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*h0(a)}},$Ut=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[CM(t,r,!e),IM(t,i,!n,{})].filter(Boolean);var HDe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=UUt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([FUt(t),d]);return}let f=HZ(c,r),p=fX({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([jUt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},UUt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DM({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=fX({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await tDe(a,t,r,s)},FUt=async t=>{await MUt(),t.readableFlowing===null&&t.resume()},jUt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await vM(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await bM(r,{maxBuffer:s})):await OS(r,{maxBuffer:s})}catch(a){return VDe(tke({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},hX=async t=>{try{return await t}catch(e){return VDe(e)}},VDe=({bufferedData:t})=>_Ie(t)?new Uint8Array(t):t;import{finished as zUt}from"stream/promises";var y0=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=qUt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],zUt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||VUt(a,e,r,n)}finally{o.abort()}},qUt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&BUt(t,r,n),n},BUt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{HUt(e,r),n.call(t,...i)}},HUt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},VUt=(t,e,r,n)=>{if(!GUt(t,e,r,n))throw t},GUt=(t,e,r,n=!0)=>r.propagating?GDe(t)||qM(t):(r.propagating=!0,mX(r,e)===n?GDe(t):qM(t)),mX=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",qM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",GDe=t=>t?.code==="EPIPE";var WDe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>gX({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),gX=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=y0(t,e,u);if(mX(u,e)){await l;return}let[d]=await Promise.all([HDe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var KDe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?am([t,e].filter(Boolean)):void 0,YDe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>gX({...WUt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:KUt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),WUt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},KUt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as YUt}from"events";var JDe=t=>ES(t,"ipc"),ZDe=(t,e)=>{let r=K$(t);qc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var XDe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=JDe(s),a=ll(e,"ipc"),c=ll(r,"ipc");for await(let u of QZ({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(rke(t,i,c),i.push(u)),o&&ZDe(u,s);return i},QDe=async(t,e)=>(await Promise.allSettled([t]),e);var eLe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let v=oDe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},_=WDe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=YDe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=[],A=XDe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:w,verboseInfo:p}),R=JUt(m,t,S),P=ZUt(h,S);try{return await Promise.race([Promise.all([{},cDe(v),Promise.all(_),b,A,DNe(t,d),...R,...P]),g,XUt(t,y),...PNe(t,s,f,y),...JCe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...xNe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(C){return f.terminationReason??="other",Promise.all([{error:C},v,Promise.all(_.map(O=>hX(O))),hX(b),QDe(A,w),Promise.allSettled(R),Promise.allSettled(P)])}},JUt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:y0(n,i,r)),ZUt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>$a(s,{checkOpen:!1})&&!ka(s)).map(({type:i,value:s,stream:o=s})=>y0(o,n,e,{isSameDirection:Mo.has(i),stopOnExit:i==="native"}))),XUt=async(t,{signal:e})=>{let[r]=await YUt(t,"error",{signal:e});throw r};var tLe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),S0=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Bc();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},kS=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 QUt}from"stream";import{callbackify as eFt}from"util";import{finished as rLe}from"stream/promises";var _X=async t=>{if(t!==void 0)try{await yX(t)}catch{}},nLe=async t=>{if(t!==void 0)try{await SX(t)}catch{}},yX=async t=>{await rLe(t,{cleanup:!0,readable:!1,writable:!0})},SX=async t=>{await rLe(t,{cleanup:!0,readable:!0,writable:!1})},BM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!qM(r)?t.destroy(r):e&&t.destroy()};var iLe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Hs.has(r),{subprocessStdout:a,waitReadableDestroy:c}=EX(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=vX(a,o),{read:f,onStdoutDataDone:p}=bX({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new QUt({read:f,destroy:eFt(TX.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return wX({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},EX=(t,e,r)=>{let n=RS(t,e),i=S0(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},vX=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:pX},bX=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Bc(),o=zM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){tFt(this,o,s)},onStdoutDataDone:s}},tFt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},wX=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await SX(t),await n,await _X(i),await e,r.readable&&r.push(null)}catch(s){await _X(i),sLe(r,s)}},TX=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kS(r,e)&&(sLe(t,n),await BM(e,n))},sLe=(t,e)=>{HM(t,t.readable,e)};import{Writable as rFt}from"stream";import{callbackify as oLe}from"util";var aLe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=RX(t,r,e),o=new rFt({...AX(n,t,i),destroy:oLe(OX.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return xX(n,o),o},RX=(t,e,r)=>{let n=sM(t,e),i=S0(r,n,"writableFinal"),s=S0(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},AX=(t,e,r)=>({write:nFt.bind(void 0,t),final:oLe(iFt.bind(void 0,t,e,r))}),nFt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iFt=async(t,e,r)=>{await kS(r,e)&&(t.writable&&t.end(),await e)},xX=async(t,e,r)=>{try{await yX(t),e.writable&&e.end()}catch(n){await nLe(r),cLe(e,n)}},OX=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kS(r,e),await kS(n,e)&&(cLe(t,i),await BM(e,i))},cLe=(t,e)=>{HM(t,t.writable,e)};import{Duplex as sFt}from"stream";import{callbackify as oFt}from"util";var uLe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Hs.has(r),{subprocessStdout:c,waitReadableDestroy:u}=EX(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=RX(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=vX(c,a),{read:g,onStdoutDataDone:y}=bX({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new sFt({read:g,...AX(l,t,d),destroy:oFt(aFt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return wX({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),xX(l,v,c),v},aFt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([TX({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),OX({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var PX=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Hs.has(e),o=RS(t,r),a=zM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return cFt(a,o,t)},cFt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lLe=(t,{encoding:e})=>{let r=tLe();t.readable=iLe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=aLe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=uLe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=PX.bind(void 0,t,e),t[Symbol.asyncIterator]=PX.bind(void 0,t,e,{})};var dLe=(t,e)=>{for(let[r,n]of lFt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uFt=(async()=>{})().constructor.prototype,lFt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uFt,t)]);var fLe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=pFt(t,e,r),{subprocess:f,promise:p}=mFt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=jM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),dLe(f,p),Hc.set(f,{options:l,fileDescriptors:d}),f},pFt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=J$(t,e,r),{file:a,commandArguments:c,options:u}=gM(t,e,r),l=hFt(u),d=wDe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},hFt=({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}},mFt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=fFt(..._M(t,e,r))}catch(h){return SDe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;dFt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];NDe(c,a,u),DDe(c,r,u);let d={},f=Bc();c.kill=KCe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=KDe(c,r),lLe(c,r),gDe(c,r);let p=gFt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},gFt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await eLe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,b)=>fl(_,e,b)),v=fl(m,e,"all"),S=_Ft({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return IS(S,n,e)},_Ft=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?p0({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Vc,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):RM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var VM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,yFt(n,t[n],i)]));return{...t,...r}},yFt=(t,e,r)=>SFt.has(t)&&Kr(e)&&Kr(r)?{...e,...r}:r,SFt=new Set(["env",...sZ]);var mf=(t,e,r,n)=>{let i=(o,a,c)=>mf(o,a,r,c),s=(...o)=>EFt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},EFt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Kr(s))return i(t,VM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=vFt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?lDe(a,c,u):fLe(a,c,u,i)},vFt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=wIe(e)?TIe(e,r):[e,...r],[o,a,c]=F$(...s),u=VM(VM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var pLe=({file:t,commandArguments:e})=>mLe(t,e),hLe=({file:t,commandArguments:e})=>({...mLe(t,e),isSync:!0}),mLe=(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]=bFt(t);return{file:r,commandArguments:n}},bFt=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(wFt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wFt=/ +/g;var gLe=(t,e,r)=>{t.sync=e(TFt,r),t.s=t.sync},_Le=({options:t})=>yLe(t),TFt=({options:t})=>({...yLe(t),isSync:!0}),yLe=t=>({options:{...RFt(t),...t}}),RFt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},SLe={preferLocal:!0};var ELe=mf(()=>({})),czr=mf(()=>({isSync:!0})),vLe=mf(pLe),uzr=mf(hLe),lzr=mf(CNe),dzr=mf(_Le,{},SLe,gLe),{sendMessage:fzr,getOneMessage:pzr,getEachMessage:hzr,getCancelSignal:mzr}=_De();import{Transform as AFt}from"stream";var xFt=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function OFt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...xFt])]}function PFt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function IFt(){let e=OFt().map(r=>process.env[r]).filter(r=>!(!r||PFt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function di(t){if(typeof t!="string")return t;let e=IFt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(CFt(n),"g");r=r.replace(i,"******")}),r}function CFt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var E0=class extends AFt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=di(i);n(null,s)}},GM=Symbol("maskedWrite");function bLe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[GM]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?di(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[GM]=!0,process.stdout.write=r}if(!process.stderr.write[GM]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?di(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[GM]=!0,process.stderr.write=r}}}var wLe=!1,TLe,IX=t=>{TLe??=t},RLe=t=>{wLe=!0,IX(t)},Yr=()=>wLe,Uo=()=>TLe,ALe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var v0=null,xLe=t=>(v0&&v0.destroy(),v0=new Fo({totalAllowedTime:t}),v0),OLe=()=>v0;var Fo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Yr())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await pD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Q.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),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 PLe={name:"@netlify/agent-runner-cli",type:"module",version:"2.9.0-nb7266f6744f08.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.5","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var LFt=kFt(import.meta.url),$Ft=pl.dirname(LFt),MFt=DFt(import.meta.url),DS=de("shell"),CX=new Set,ILe={preferLocal:!0},Lt=(t,e,r)=>{let[n,i]=UFt(e,r),s={...ILe,...i},o=ELe(t,n,s);NLe(o,s),LLe(o);let a=r?.idleTimeout;return a&&a>0&&DLe(o,a),o},CLe=(t,e)=>{let r={...ILe,...e},n=vLe(t,r);return NLe(n,r),LLe(n),e?.idleTimeout&&e.idleTimeout>0&&DLe(n,e.idleTimeout),n},UFt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},NLe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Wc.env.NETLIFY_LOCAL_QUIET==="true")return;if(Wc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new E0).pipe(Wc.stdout),t.stderr?.pipe(new E0).pipe(Wc.stderr);return}t.stdout?.pipe(Wc.stdout),t.stderr?.pipe(Wc.stderr)},NX=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Wc.kill(-t.pid,e),DS.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return DS.error("Error killing process:",r),!1}},kLe=t=>NX(t,"SIGKILL"),DLe=(t,e)=>{let r=null,n=()=>{DS.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),NX(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(DS.log(`Force killing idle process ${t.pid}`),kLe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},LLe=t=>{CX.add(t);let e=OLe();if(e){let r=e.onTimesUp(()=>{DS.log(`Global timer expired, killing process ${t.pid}`),NX(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(DS.log(`Force killing process ${t.pid} after timeout`),kLe(t))},5e3)});t.on("exit",()=>{CX.delete(t),r()}),t.on("error",()=>{CX.delete(t),r()})}};function Kc(t,e){if(!Wc.env.NETLIFY_LOCAL_MODE)try{let i=MFt.resolve(PLe.name),s=pl.dirname(i);for(;s!==pl.dirname(s);){let o=pl.dirname(s);if(pl.basename(o)==="node_modules"){let a=pl.join(o,".bin",e);if(WM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Wc.env.NODE_PATH){let i=pl.join(Wc.env.NODE_PATH,".bin",e);if(WM.existsSync(i))return i}let r=pl.join(t,"node_modules",".bin",e);if(WM.existsSync(r))return r;let n=pl.join($Ft,"..","node_modules",".bin",e);if(WM.existsSync(n))return n}import Xj from"process";import{fileURLToPath as QYt}from"url";import{createRequire as e5t}from"module";import _O from"path";import{readFileSync as t5t}from"fs";var FFt="__netlify__getTracer",jFt="__netlify__shutdownTracers",Ct=(t,e)=>globalThis[FFt]?.(t,e),$Le=async()=>globalThis[jFt]?.();function b0(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as HYt}from"timers/promises";Ue();import Dzt from"process";Ue();var zFt=(t,e)=>{e.recordException(t),e.setStatus({code:Ln.ERROR})};var hl=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=MLe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>ULe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=MLe(r,n,i),c=this._tracer.startSpan(e,s,o);return ULe(c,s,a)}};function MLe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??ir.active(),{opts:n,ctx:i,fn:s}}function ULe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:zFt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ue();var $S=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var DX=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=KLe(e),n._asyncAttributesPending=e.filter(([i,s])=>$S(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>($S(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=KLe(this._rawAttributes),this._schemaUrl=qFt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,$S(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&fe.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if($S(n)){fe.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=BFt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function LX(t,e){return DX.FromAttributeList(Object.entries(t),e)}function KLe(t){return t.map(([e,r])=>$S(r)?[e,r.catch(n=>{fe.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function qFt(t){if(typeof t=="string"||t===void 0)return t;fe.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function BFt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;fe.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var w0=class{emit(e){}enabled(){return!1}},YLe=new w0;var T0=Symbol.for("io.opentelemetry.js.api.logs"),MS=globalThis;function JLe(t,e,r){return n=>n===t?e:r}var $X=1;var MX=class{getLogger(e,r,n){return new w0}},JM=new MX;var ZM=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):YLe}};var R0=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new ZM(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:JM}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var XM=class t{constructor(){this._proxyLoggerProvider=new R0}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return MS[T0]?this.getLoggerProvider():(MS[T0]=JLe($X,e,JM),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=MS[T0])===null||e===void 0?void 0:e.call(MS,$X))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete MS[T0],this._proxyLoggerProvider=new R0}};var ZLe=XM.getInstance();function XLe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function QLe(t){t.forEach(e=>e.disable())}function UX(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||jR.getMeterProvider(),n=t.loggerProvider||ZLe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return XLe(i,e,r,n),()=>{QLe(i)}}Ue();var HFt=Dn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function e$e(t){return t.getValue(HFt)===!0}var US;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(US||(US={}));Ue();var FX="[_0-9a-z-*/]",VFt=`[a-z]${FX}{0,255}`,GFt=`[a-z0-9]${FX}{0,240}@[a-z]${FX}{0,13}`,WFt=new RegExp(`^(?:${VFt}|${GFt})$`),KFt=/^[ -~]{0,255}[!-~]$/,YFt=/,|=/;function jX(t){return WFt.test(t)}function zX(t){return KFt.test(t)&&!YFt.test(t)}var JFt=32,t$e=512,r$e=",",n$e="=",QM=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!jX(e)||!zX(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>t$e)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=r$e+e),e=`${n[0]}${n$e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(r$e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(n$e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!jX(a)||!zX(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>t$e)&&(r.set(a,c),n=u,r.size>=JFt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var e1="traceparent",t1="tracestate",ZFt="00",XFt="(?!ff)[\\da-f]{2}",QFt="(?![0]{32})[\\da-f]{32}",ejt="(?![0]{16})[\\da-f]{16}",tjt="[\\da-f]{2}",rjt=new RegExp(`^\\s?(${XFt})-(${QFt})-(${ejt})-(${tjt})(-.*)?\\s?$`);function i$e(t){let e=rjt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var gf=class{inject(e,r,n){let i=zt.getSpanContext(e);if(!i||e$e(e)||!ms(i))return;let s=`${ZFt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||$r.NONE).toString(16)}`;n.set(r,e1,s),i.traceState&&n.set(r,t1,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,e1);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=i$e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,t1);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new QM(typeof c=="string"?c:void 0)}return zt.setSpanContext(e,o)}fields(){return[e1,t1]}};var r1=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var A0=class{_isCalled=!1;_deferred=new r1;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var Y1=mn(PQ(),1);Ue();var rUe=t=>{throw TypeError(t)},kQ=(t,e,r)=>e.has(t)||rUe("Cannot "+r),K1=(t,e,r)=>(kQ(t,e,"read from private field"),r?r.call(t):e.get(t)),IQ=(t,e,r)=>e.has(t)?rUe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Q1e=(t,e,r,n)=>(kQ(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),kzt=(t,e,r)=>(kQ(t,e,"access private method"),r),eUe="__netlify__getTracer",Lzt="__netlify__shutdownTracers",$zt="__nfOTLPTrace",V0,G0,NQ,nUe,Mzt=class{constructor(){IQ(this,NQ),IQ(this,V0),IQ(this,G0),Q1e(this,V0,new A0(kzt(this,NQ,nUe),this)),Q1e(this,G0,fe.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(K1(this,G0).debug(`export ${t.length.toString()} spans`),K1(this,V0).isCalled){e({code:US.FAILED,error:new Error("Exporter has been shutdown")});return}console.log($zt,JSON.stringify(Uzt(t))),e({code:US.SUCCESS})}shutdown(){return K1(this,V0).call()}};V0=new WeakMap;G0=new WeakMap;NQ=new WeakSet;nUe=function(){return K1(this,G0).debug("Shutting down"),Promise.resolve()};function Uzt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:W1(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Oa.SERVER,startTimeUnixNano:CQ(e.startTime),endTimeUnixNano:CQ(e.endTime),attributes:W1(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:CQ(n.time),attributes:W1(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:W1(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function W1(t){return Object.keys(t).map(e=>iUe(e,t[e]))}function iUe(t,e){return{key:t,value:sUe(e)}}function sUe(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(sUe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>iUe(r,n))}}:{}}function CQ(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var tUe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},oUe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,eUe))return;let e=Dzt.version.slice(1),r=LX({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Fzt()],i=new Y1.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new gf});let s=t.instrumentations??[];UX({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,eUe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new hl(zt.getTracer(a,c)):new hl(zt.getTracer(tUe.name,tUe.version))}}),Object.defineProperty(globalThis,Lzt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Fzt=()=>new Y1.SimpleSpanProcessor(new Mzt);Ue();var JS=mn(PQ(),1);Ue();import*as J1 from"diagnostics_channel";var aUe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Ln.ERROR:Ln.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof hl?t:new hl(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){J1.subscribe(t,e);let r=()=>J1.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Oa.CLIENT},ir.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Ln.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var HVe=mn(jVe(),1);Cne();var zVe=0;var qYt=3*1024*1024,BYt=t=>dO.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Jj=class{constructor(e,r=qYt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=BYt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:zVe});return}this.inner.export(n[c],u=>{u.code!==zVe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var YE=de("tracing"),qVe=8e3,VYt=5e3,BVe=t=>t.length>qVe?`${t.slice(0,qVe)}\u2026`:t,hO={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},GYt=Math.ceil(hO.maxQueueSize/hO.maxExportBatchSize)+1,WYt=t=>new JS.BatchSpanProcessor(new Jj(new HVe.OTLPTraceExporter({url:t,concurrencyLimit:GYt})),hO),Bm=async(t=VYt)=>{try{let e=Symbol("timed out");await Promise.race([$Le(),HYt(t,e)])===e&&YE.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){YE.warn("Failed to flush tracers on shutdown",e)}},VVe=async(t,e,r)=>{if(!Ct()){let n=[new JS.SimpleSpanProcessor(new kne),WYt(r.exporterUrl)];await oUe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new aUe({skipHeaders:!0})]})}return r.traceparent?(qi.setGlobalPropagator(new gf),qi.extract(ir.active(),{traceparent:r.traceparent,isRemote:!0})):ir.active()};function ur(t,e,r){return YE.log(`\u23F3 TRACE: ${e} starting...`),b0(t,e,r)}var kne=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";YE.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&YE.log(` \u274C Error: ${e.status.message}`)}};function Dne(){return Ye().captureLlmContentEnabled}function GVe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Zj(t,e,r){let n={role:t,parts:[{type:"text",content:di(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var KYt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]);function WVe(t,e,r,n){if(!t.length)return;let i=Ct();if(!i)return;t.length>hO.maxQueueSize&&YE.warn(`${t.length} step spans exceed the span queue of ${hO.maxQueueSize}; spans may be dropped`);let s=Dne(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&KYt.has(a.category)||a.category===X.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=BVe(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?BVe(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":di(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":di(g)}:{"gen_ai.output.messages":Zj("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:Ln.ERROR}))),y.end(l)})}import{readdir as YYt,rm as JYt}from"fs/promises";import{join as ZYt}from"path";async function KVe(t,e=[]){let n=(await YYt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>JYt(ZYt(t,i),{recursive:!0,force:!0})))}var XYt=300,mO=t=>Ye().budgetCreditThresholds[t.mode]?.[t.runner]??XYt,gO=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Lne=t=>{let e=mO(t);if(!gO(t,e))return"default";let r=Ye();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},YVe=t=>{let e=Lne(t),r=mO(t);return{budget_eligible:gO(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var r5t=_O.dirname(QYt(import.meta.url)),JVe=e5t(import.meta.url),n5t=_O.resolve(r5t,"scripts/scaffold.js"),i5t="scripts/scaffold.js",s5t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,$ne=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},o5t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),a5t=t=>{let e=$ne(t);return e==="node"||e.endsWith("/node")},Xs=t=>{if(typeof t!="string")return!1;let e=t.match(s5t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&o5t($ne(e[r]));)r+=1;if(r>=e.length||!a5t(e[r]))return!1;let n=e[r+1];return n?$ne(n).includes(i5t):!1},Hm=de("create_stage"),Mne="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",c5t=`${Mne}
|
|
600
|
+
if (condition) { yield value; }`)};import{Buffer as HMt}from"buffer";import{StringDecoder as VMt}from"string_decoder";var CM=(t,e,r)=>{if(r)return;if(t)return{transform:GMt.bind(void 0,new TextEncoder)};let n=new VMt(e);return{transform:WMt.bind(void 0,n),final:KMt.bind(void 0,n)}},GMt=function*(t,e){HMt.isBuffer(e)?yield ul(e):typeof e=="string"?yield t.encode(e):yield e},WMt=function*(t,e){yield Sn(e)?t.write(e):e},KMt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Kke}from"util";var WZ=Kke(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),NM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JMt}=e[r];for await(let i of n(t))yield*NM(i,e,r+1)},Yke=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*YMt(r,Number(e),t)},YMt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*NM(n,r,e+1)},Jke=Kke(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),JMt=function*(t){yield t};var KZ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zke=(t,e)=>[...e.flatMap(r=>[...om(r,t,0)]),...h0(t)],om=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XMt}=e[r];for(let i of n(t))yield*om(i,e,r+1)},h0=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZMt(r,Number(e),t)},ZMt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*om(n,r,e+1)},XMt=function*(t){yield t};var YZ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Qke(t,o,s),u=sm(e),l=sm(r),d=u?WZ.bind(void 0,NM,a):KZ.bind(void 0,om),f=u||l?WZ.bind(void 0,Yke,a):KZ.bind(void 0,h0),p=u||l?Jke.bind(void 0,a):void 0;return{stream:new QMt({writableObjectMode:n,writableHighWaterMark:Xke(n),readableObjectMode:i,readableHighWaterMark:Xke(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},kM=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Qke(o,r,a);t=Zke(c,t)}return t},Qke=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Vke(n,a)},CM(r,o,n),IM(r,s,n,c),{transform:t,final:e},{transform:Gke(i,a)},Hke({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var eDe=(t,e)=>{for(let r of e1t(t))t1t(t,r,e)},e1t=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),t1t=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${hf[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>r1t(a,n));r.input=i0(o)},r1t=(t,e)=>{let r=kM(t,e,"utf8",!0);return n1t(r),i0(r)},n1t=t=>{let e=t.find(r=>typeof r!="string"&&!Sn(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 a1t,appendFileSync as c1t}from"fs";var DM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&ES(r,n)&&!Hs.has(e)&&i1t(n)&&(t.some(({type:i,value:s})=>i==="native"&&s1t.has(s))||t.every(({type:i})=>Mo.has(i))),i1t=t=>t===1||t===2,s1t=new Set(["pipe","overlapped"]),tDe=async(t,e,r,n)=>{for await(let i of t)o1t(e)||nDe(i,r,n)},rDe=(t,e,r)=>{for(let n of t)nDe(n,e,r)},o1t=t=>t._readableState.pipes.length>0,nDe=(t,e,r)=>{let n=K$(t);qc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var iDe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>u1t({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},u1t=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=ske(t,s,d),p=ul(f),{stdioItems:h,objectMode:m}=e[r],g=l1t([p],h,c,n),{serializedResult:y,finalResult:v=y}=d1t({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});f1t({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&p1t(y,h,i),S}catch(_){return n.error=_,S}},l1t=(t,e,r,n)=>{try{return kM(t,e,r,!1)}catch(i){return n.error=i,t}},d1t=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:i0(t)};let o=SIe(t,r);return n[s]?{serializedResult:o,finalResult:GZ(o,!i[s],e)}:{serializedResult:o}},f1t=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DM({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GZ(t,!1,o);try{rDe(a,e,n)}catch(c){r.error??=c}},p1t=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OM.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?c1t(n,t):(r.add(s),a1t(n,t))}};var sDe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,fl(e,r,"all")]:Array.isArray(e)?[fl(t,r,"all"),...e]:Sn(t)&&Sn(e)?tZ([t,e]):`${t}${e}`};import{once as JZ}from"events";var oDe=async(t,e)=>{let[r,n]=await h1t(t);return e.isForcefullyTerminated??=!1,[r,n]},h1t=async t=>{let[e,r]=await Promise.allSettled([JZ(t,"spawn"),JZ(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?aDe(t):r.value},aDe=async t=>{try{return await JZ(t,"exit")}catch{return aDe(t)}},cDe=async t=>{let[e,r]=await t;if(!m1t(e,r)&&ZZ(e,r))throw new Da;return[e,r]},m1t=(t,e)=>t===void 0&&e===void 0,ZZ=(t,e)=>t!==0||e!==null;var uDe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=g1t(t,e,r),o=s?.code==="ETIMEDOUT",a=ike(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},g1t=(t,e,r)=>t!==void 0?t:ZZ(e,r)?new Da:void 0;var lDe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=y1t(t,e,r),d=v1t({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return IS(d,c,u)},y1t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=J$(t,e,r),a=S1t(r),{file:c,commandArguments:u,options:l}=gM(t,e,a);E1t(l);let d=jke(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},S1t=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,E1t=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},v1t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=b1t({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=uDe(c,r),{output:h,error:m=u}=iDe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((v,S)=>fl(v,r,S)),y=fl(sDe(h,r),r,"all");return T1t({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},b1t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{eDe(s,r);let a=w1t(r);return _1t(..._M(t,e,a))}catch(a){return PS({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},w1t=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:TM(e)}),T1t=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?RM({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):p0({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as dFt}from"events";import{spawn as fFt}from"child_process";import mDe from"process";import{once as XZ,on as R1t}from"events";var dDe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(wS({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:lM(t)}),A1t({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),A1t=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{oM(e,i);let s=pf(t,e,r),o=new AbortController;try{return await Promise.race([x1t(s,n,o),O1t(s,r,o),P1t(s,r,o)])}catch(a){throw TS(t),a}finally{o.abort(),aM(e,i)}},x1t=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await XZ(t,"message",{signal:r});return n}for await(let[n]of R1t(t,"message",{signal:r}))if(e(n))return n},O1t=async(t,e,{signal:r})=>{await XZ(t,"disconnect",{signal:r}),ZCe(e)},P1t=async(t,e,{signal:r})=>{let[n]=await XZ(t,"strict:error",{signal:r});throw nM(n,e)};import{once as pDe,on as I1t}from"events";var hDe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>QZ({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),QZ=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{wS({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:lM(t)}),oM(e,s);let o=pf(t,e,r),a=new AbortController,c={};return C1t(t,o,a),N1t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),k1t({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},C1t=async(t,e,r)=>{try{await pDe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},N1t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await pDe(t,"strict:error",{signal:r.signal});n.error=nM(i,e),r.abort()}catch{}},k1t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of I1t(r,"message",{signal:s.signal}))fDe(o),yield c}catch{fDe(o)}finally{s.abort(),aM(e,a),n||TS(t),i&&await t}},fDe=({error:t})=>{if(t)throw t};var gDe=(t,{ipc:e})=>{Object.assign(t,yDe(t,!1,e))},_De=()=>{let t=mDe,e=!0,r=mDe.channel!==void 0;return{...yDe(t,e,r),getCancelSignal:TNe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},yDe=(t,e,r)=>({sendMessage:hM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:dDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:hDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as D1t}from"child_process";import{PassThrough as L1t,Readable as $1t,Writable as M1t,Duplex as U1t}from"stream";var SDe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{BZ(n);let a=new D1t;F1t(a,n),Object.assign(a,{readable:j1t,writable:z1t,duplex:q1t});let c=PS({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=B1t(c,o,i);return{subprocess:a,promise:u}},F1t=(t,e)=>{let r=m0(),n=m0(),i=m0(),s=Array.from({length:e.length-3},m0),o=m0(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},m0=()=>{let t=new L1t;return t.end(),t},j1t=()=>new $1t({read(){}}),z1t=()=>new M1t({write(){}}),q1t=()=>new U1t({read(){},write(){}}),B1t=async(t,e,r)=>IS(t,e,r);import{createReadStream as EDe,createWriteStream as vDe}from"fs";import{Buffer as H1t}from"buffer";import{Readable as g0,Writable as V1t,Duplex as G1t}from"stream";var wDe=(t,e)=>PM(W1t,t,e,!1),_0=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${hf[t]}.`)},bDe={fileNumber:_0,generator:YZ,asyncGenerator:YZ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:G1t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},W1t={input:{...bDe,fileUrl:({value:t})=>({stream:EDe(t)}),filePath:({value:{file:t}})=>({stream:EDe(t)}),webStream:({value:t})=>({stream:g0.fromWeb(t)}),iterable:({value:t})=>({stream:g0.from(t)}),asyncIterable:({value:t})=>({stream:g0.from(t)}),string:({value:t})=>({stream:g0.from(t)}),uint8Array:({value:t})=>({stream:g0.from(H1t.from(t))})},output:{...bDe,fileUrl:({value:t})=>({stream:vDe(t)}),filePath:({value:{file:t,append:e}})=>({stream:vDe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:V1t.fromWeb(t)}),iterable:_0,asyncIterable:_0,string:_0,uint8Array:_0}};import{on as K1t,once as TDe}from"events";import{PassThrough as Y1t,getDefaultHighWaterMark as J1t}from"stream";import{finished as xDe}from"stream/promises";function am(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)tX(i);let e=t.some(({readableObjectMode:i})=>i),r=Z1t(t,e),n=new eX({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Z1t=(t,e)=>{if(t.length===0)return J1t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},eX=class extends Y1t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(tX(e),this.#e.has(e))return;this.#e.add(e),this.#n??=X1t(this,this.#e,this.#s);let r=tUt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(tX(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},X1t=async(t,e,r)=>{$M(t,RDe);let n=new AbortController;try{await Promise.race([Q1t(t,n),eUt(t,e,r,n)])}finally{n.abort(),$M(t,-RDe)}},Q1t=async(t,{signal:e})=>{try{await xDe(t,{signal:e,cleanup:!0})}catch(r){throw ODe(t,r),r}},eUt=async(t,e,r,{signal:n})=>{for await(let[i]of K1t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},tX=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},tUt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{$M(t,ADe);let a=new AbortController;try{await Promise.race([rUt(s,e,a),nUt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),iUt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),$M(t,-ADe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?rX(t):sUt(t))},rUt=async(t,e,{signal:r})=>{try{await t,r.aborted||rX(e)}catch(n){r.aborted||ODe(e,n)}},nUt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await xDe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;PDe(o)?i.add(e):IDe(t,o)}},iUt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await TDe(t,i,{signal:s}),!t.readable)return TDe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},sUt=t=>{t.writable&&t.end()},ODe=(t,e)=>{PDe(e)?rX(t):IDe(t,e)},PDe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",rX=t=>{(t.readable||t.writable)&&t.destroy()},IDe=(t,e)=>{t.destroyed||(t.once("error",oUt),t.destroy(e))},oUt=()=>{},$M=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},RDe=2,ADe=1;import{finished as CDe}from"stream/promises";var NS=(t,e)=>{t.pipe(e),aUt(t,e),cUt(t,e)},aUt=async(t,e)=>{if(!(ka(t)||ka(e))){try{await CDe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}nX(e)}},nX=t=>{t.writable&&t.end()},cUt=async(t,e)=>{if(!(ka(t)||ka(e))){try{await CDe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}iX(t)}},iX=t=>{t.readable&&t.destroy()};var NDe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Mo.has(c)))uUt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Mo.has(c)))dUt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:am(s);NS(o,i)}},uUt=(t,e,r,n)=>{r==="output"?NS(t.stdio[n],e):NS(e,t.stdio[n]);let i=lUt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lUt=["stdin","stdout","stderr"],dUt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;fUt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},fUt=(t,{signal:e})=>{ka(t)&&nm(t,pUt,e)},pUt=2;import{addAbortListener as gUt}from"events";var cm=[];cm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&cm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&cm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var MM=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",sX=Symbol.for("signal-exit emitter"),oX=globalThis,hUt=Object.defineProperty.bind(Object),aX=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(oX[sX])return oX[sX];hUt(oX,sX,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},UM=class{},mUt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),cX=class extends UM{onExit(){return()=>{}}load(){}unload(){}},uX=class extends UM{#e=lX.platform==="win32"?"SIGINT":"SIGHUP";#r=new aX;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of cm)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!MM(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 cm)try{let r=this.#i[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,cm.forEach(e=>{let r=this.#i[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.#s,this.#r.count-=1)}#a(e){return MM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&MM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},lX=globalThis.process,{onExit:kDe,load:yUr,unload:SUr}=mUt(MM(lX)?new uX(lX):new cX);var DDe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=kDe(()=>{t.kill()});gUt(n,()=>{i()})};var $De=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=Y$(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=_Ut(r,n,i),{sourceStream:d,sourceError:f}=SUt(t,u),{options:p,fileDescriptors:h}=Hc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},_Ut=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=yUt(t,e,...r),a=sM(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},yUt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(LDe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||QJ(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[i,s,o]=F$(r,...n);return{destination:e(LDe)(i,s,o),pipeOptions:o}}if(Hc.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}`)},LDe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),SUt=(t,e)=>{try{return{sourceStream:RS(t,e)}}catch(r){return{sourceError:r}}};var UDe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=EUt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw dX({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},EUt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return iX(t),n;if(e!==void 0)return nX(r),e},dX=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>PS({error:t,command:MDe,escapedCommand:MDe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),MDe="source.pipe(destination)";var FDe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as vUt}from"stream/promises";var jDe=(t,e,r)=>{let n=FM.has(e)?wUt(t,e):bUt(t,e);return nm(t,RUt,r.signal),nm(e,AUt,r.signal),TUt(e),n},bUt=(t,e)=>{let r=am([t]);return NS(r,e),FM.set(e,r),r},wUt=(t,e)=>{let r=FM.get(e);return r.add(t),r},TUt=async t=>{try{await vUt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}FM.delete(t)},FM=new WeakMap,RUt=2,AUt=1;import{aborted as xUt}from"util";var zDe=(t,e)=>t===void 0?[]:[OUt(t,e)],OUt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await xUt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw dX({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var jM=(t,...e)=>{if(Kr(e[0]))return jM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$De(t,...e),i=PUt({...n,destination:r});return i.pipe=jM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},PUt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=IUt(t,i);UDe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=jDe(e,s,d);return await Promise.race([FDe(l),...zDe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},IUt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as MUt}from"timers/promises";import{on as CUt}from"events";import{getDefaultHighWaterMark as NUt}from"stream";var zM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return kUt(e,o),BDe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},kUt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},fX=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;DUt(e,o,t);let a=t.readableObjectMode&&!s;return BDe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},DUt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},BDe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=CUt(t,"data",{signal:e.signal,highWaterMark:qDe,highWatermark:qDe});return LUt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},pX=NUt(!0),qDe=pX,LUt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Ut({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*om(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*h0(a)}},$Ut=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[CM(t,r,!e),IM(t,i,!n,{})].filter(Boolean);var HDe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=UUt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([FUt(t),d]);return}let f=HZ(c,r),p=fX({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([jUt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},UUt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DM({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=fX({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await tDe(a,t,r,s)},FUt=async t=>{await MUt(),t.readableFlowing===null&&t.resume()},jUt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await vM(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await bM(r,{maxBuffer:s})):await OS(r,{maxBuffer:s})}catch(a){return VDe(tke({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},hX=async t=>{try{return await t}catch(e){return VDe(e)}},VDe=({bufferedData:t})=>_Ie(t)?new Uint8Array(t):t;import{finished as zUt}from"stream/promises";var y0=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=qUt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],zUt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||VUt(a,e,r,n)}finally{o.abort()}},qUt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&BUt(t,r,n),n},BUt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{HUt(e,r),n.call(t,...i)}},HUt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},VUt=(t,e,r,n)=>{if(!GUt(t,e,r,n))throw t},GUt=(t,e,r,n=!0)=>r.propagating?GDe(t)||qM(t):(r.propagating=!0,mX(r,e)===n?GDe(t):qM(t)),mX=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",qM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",GDe=t=>t?.code==="EPIPE";var WDe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>gX({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),gX=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=y0(t,e,u);if(mX(u,e)){await l;return}let[d]=await Promise.all([HDe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var KDe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?am([t,e].filter(Boolean)):void 0,YDe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>gX({...WUt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:KUt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),WUt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},KUt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as YUt}from"events";var JDe=t=>ES(t,"ipc"),ZDe=(t,e)=>{let r=K$(t);qc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var XDe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=JDe(s),a=ll(e,"ipc"),c=ll(r,"ipc");for await(let u of QZ({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(rke(t,i,c),i.push(u)),o&&ZDe(u,s);return i},QDe=async(t,e)=>(await Promise.allSettled([t]),e);var eLe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let v=oDe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},_=WDe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=YDe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=[],A=XDe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:w,verboseInfo:p}),R=JUt(m,t,S),P=ZUt(h,S);try{return await Promise.race([Promise.all([{},cDe(v),Promise.all(_),b,A,DNe(t,d),...R,...P]),g,XUt(t,y),...PNe(t,s,f,y),...JCe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...xNe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(C){return f.terminationReason??="other",Promise.all([{error:C},v,Promise.all(_.map(O=>hX(O))),hX(b),QDe(A,w),Promise.allSettled(R),Promise.allSettled(P)])}},JUt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:y0(n,i,r)),ZUt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>$a(s,{checkOpen:!1})&&!ka(s)).map(({type:i,value:s,stream:o=s})=>y0(o,n,e,{isSameDirection:Mo.has(i),stopOnExit:i==="native"}))),XUt=async(t,{signal:e})=>{let[r]=await YUt(t,"error",{signal:e});throw r};var tLe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),S0=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Bc();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},kS=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 QUt}from"stream";import{callbackify as eFt}from"util";import{finished as rLe}from"stream/promises";var _X=async t=>{if(t!==void 0)try{await yX(t)}catch{}},nLe=async t=>{if(t!==void 0)try{await SX(t)}catch{}},yX=async t=>{await rLe(t,{cleanup:!0,readable:!1,writable:!0})},SX=async t=>{await rLe(t,{cleanup:!0,readable:!0,writable:!1})},BM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!qM(r)?t.destroy(r):e&&t.destroy()};var iLe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Hs.has(r),{subprocessStdout:a,waitReadableDestroy:c}=EX(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=vX(a,o),{read:f,onStdoutDataDone:p}=bX({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new QUt({read:f,destroy:eFt(TX.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return wX({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},EX=(t,e,r)=>{let n=RS(t,e),i=S0(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},vX=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:pX},bX=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Bc(),o=zM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){tFt(this,o,s)},onStdoutDataDone:s}},tFt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},wX=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await SX(t),await n,await _X(i),await e,r.readable&&r.push(null)}catch(s){await _X(i),sLe(r,s)}},TX=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kS(r,e)&&(sLe(t,n),await BM(e,n))},sLe=(t,e)=>{HM(t,t.readable,e)};import{Writable as rFt}from"stream";import{callbackify as oLe}from"util";var aLe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=RX(t,r,e),o=new rFt({...AX(n,t,i),destroy:oLe(OX.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return xX(n,o),o},RX=(t,e,r)=>{let n=sM(t,e),i=S0(r,n,"writableFinal"),s=S0(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},AX=(t,e,r)=>({write:nFt.bind(void 0,t),final:oLe(iFt.bind(void 0,t,e,r))}),nFt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iFt=async(t,e,r)=>{await kS(r,e)&&(t.writable&&t.end(),await e)},xX=async(t,e,r)=>{try{await yX(t),e.writable&&e.end()}catch(n){await nLe(r),cLe(e,n)}},OX=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kS(r,e),await kS(n,e)&&(cLe(t,i),await BM(e,i))},cLe=(t,e)=>{HM(t,t.writable,e)};import{Duplex as sFt}from"stream";import{callbackify as oFt}from"util";var uLe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Hs.has(r),{subprocessStdout:c,waitReadableDestroy:u}=EX(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=RX(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=vX(c,a),{read:g,onStdoutDataDone:y}=bX({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new sFt({read:g,...AX(l,t,d),destroy:oFt(aFt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return wX({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),xX(l,v,c),v},aFt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([TX({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),OX({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var PX=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Hs.has(e),o=RS(t,r),a=zM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return cFt(a,o,t)},cFt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lLe=(t,{encoding:e})=>{let r=tLe();t.readable=iLe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=aLe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=uLe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=PX.bind(void 0,t,e),t[Symbol.asyncIterator]=PX.bind(void 0,t,e,{})};var dLe=(t,e)=>{for(let[r,n]of lFt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uFt=(async()=>{})().constructor.prototype,lFt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uFt,t)]);var fLe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=pFt(t,e,r),{subprocess:f,promise:p}=mFt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=jM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),dLe(f,p),Hc.set(f,{options:l,fileDescriptors:d}),f},pFt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=J$(t,e,r),{file:a,commandArguments:c,options:u}=gM(t,e,r),l=hFt(u),d=wDe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},hFt=({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}},mFt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=fFt(..._M(t,e,r))}catch(h){return SDe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;dFt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];NDe(c,a,u),DDe(c,r,u);let d={},f=Bc();c.kill=KCe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=KDe(c,r),lLe(c,r),gDe(c,r);let p=gFt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},gFt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await eLe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,b)=>fl(_,e,b)),v=fl(m,e,"all"),S=_Ft({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return IS(S,n,e)},_Ft=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?p0({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Vc,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):RM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var VM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,yFt(n,t[n],i)]));return{...t,...r}},yFt=(t,e,r)=>SFt.has(t)&&Kr(e)&&Kr(r)?{...e,...r}:r,SFt=new Set(["env",...sZ]);var mf=(t,e,r,n)=>{let i=(o,a,c)=>mf(o,a,r,c),s=(...o)=>EFt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},EFt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Kr(s))return i(t,VM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=vFt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?lDe(a,c,u):fLe(a,c,u,i)},vFt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=wIe(e)?TIe(e,r):[e,...r],[o,a,c]=F$(...s),u=VM(VM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var pLe=({file:t,commandArguments:e})=>mLe(t,e),hLe=({file:t,commandArguments:e})=>({...mLe(t,e),isSync:!0}),mLe=(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]=bFt(t);return{file:r,commandArguments:n}},bFt=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(wFt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wFt=/ +/g;var gLe=(t,e,r)=>{t.sync=e(TFt,r),t.s=t.sync},_Le=({options:t})=>yLe(t),TFt=({options:t})=>({...yLe(t),isSync:!0}),yLe=t=>({options:{...RFt(t),...t}}),RFt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},SLe={preferLocal:!0};var ELe=mf(()=>({})),czr=mf(()=>({isSync:!0})),vLe=mf(pLe),uzr=mf(hLe),lzr=mf(CNe),dzr=mf(_Le,{},SLe,gLe),{sendMessage:fzr,getOneMessage:pzr,getEachMessage:hzr,getCancelSignal:mzr}=_De();import{Transform as AFt}from"stream";var xFt=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function OFt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...xFt])]}function PFt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function IFt(){let e=OFt().map(r=>process.env[r]).filter(r=>!(!r||PFt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function di(t){if(typeof t!="string")return t;let e=IFt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(CFt(n),"g");r=r.replace(i,"******")}),r}function CFt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var E0=class extends AFt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=di(i);n(null,s)}},GM=Symbol("maskedWrite");function bLe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[GM]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?di(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[GM]=!0,process.stdout.write=r}if(!process.stderr.write[GM]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?di(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[GM]=!0,process.stderr.write=r}}}var wLe=!1,TLe,IX=t=>{TLe??=t},RLe=t=>{wLe=!0,IX(t)},Yr=()=>wLe,Uo=()=>TLe,ALe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var v0=null,xLe=t=>(v0&&v0.destroy(),v0=new Fo({totalAllowedTime:t}),v0),OLe=()=>v0;var Fo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Yr())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await pD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Q.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),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 PLe={name:"@netlify/agent-runner-cli",type:"module",version:"2.9.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.5","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var LFt=kFt(import.meta.url),$Ft=pl.dirname(LFt),MFt=DFt(import.meta.url),DS=de("shell"),CX=new Set,ILe={preferLocal:!0},Lt=(t,e,r)=>{let[n,i]=UFt(e,r),s={...ILe,...i},o=ELe(t,n,s);NLe(o,s),LLe(o);let a=r?.idleTimeout;return a&&a>0&&DLe(o,a),o},CLe=(t,e)=>{let r={...ILe,...e},n=vLe(t,r);return NLe(n,r),LLe(n),e?.idleTimeout&&e.idleTimeout>0&&DLe(n,e.idleTimeout),n},UFt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},NLe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Wc.env.NETLIFY_LOCAL_QUIET==="true")return;if(Wc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new E0).pipe(Wc.stdout),t.stderr?.pipe(new E0).pipe(Wc.stderr);return}t.stdout?.pipe(Wc.stdout),t.stderr?.pipe(Wc.stderr)},NX=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Wc.kill(-t.pid,e),DS.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return DS.error("Error killing process:",r),!1}},kLe=t=>NX(t,"SIGKILL"),DLe=(t,e)=>{let r=null,n=()=>{DS.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),NX(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(DS.log(`Force killing idle process ${t.pid}`),kLe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},LLe=t=>{CX.add(t);let e=OLe();if(e){let r=e.onTimesUp(()=>{DS.log(`Global timer expired, killing process ${t.pid}`),NX(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(DS.log(`Force killing process ${t.pid} after timeout`),kLe(t))},5e3)});t.on("exit",()=>{CX.delete(t),r()}),t.on("error",()=>{CX.delete(t),r()})}};function Kc(t,e){if(!Wc.env.NETLIFY_LOCAL_MODE)try{let i=MFt.resolve(PLe.name),s=pl.dirname(i);for(;s!==pl.dirname(s);){let o=pl.dirname(s);if(pl.basename(o)==="node_modules"){let a=pl.join(o,".bin",e);if(WM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Wc.env.NODE_PATH){let i=pl.join(Wc.env.NODE_PATH,".bin",e);if(WM.existsSync(i))return i}let r=pl.join(t,"node_modules",".bin",e);if(WM.existsSync(r))return r;let n=pl.join($Ft,"..","node_modules",".bin",e);if(WM.existsSync(n))return n}import Xj from"process";import{fileURLToPath as QYt}from"url";import{createRequire as e5t}from"module";import _O from"path";import{readFileSync as t5t}from"fs";var FFt="__netlify__getTracer",jFt="__netlify__shutdownTracers",Ct=(t,e)=>globalThis[FFt]?.(t,e),$Le=async()=>globalThis[jFt]?.();function b0(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as HYt}from"timers/promises";Ue();import Dzt from"process";Ue();var zFt=(t,e)=>{e.recordException(t),e.setStatus({code:Ln.ERROR})};var hl=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=MLe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>ULe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=MLe(r,n,i),c=this._tracer.startSpan(e,s,o);return ULe(c,s,a)}};function MLe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??ir.active(),{opts:n,ctx:i,fn:s}}function ULe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:zFt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ue();var $S=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var DX=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=KLe(e),n._asyncAttributesPending=e.filter(([i,s])=>$S(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>($S(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=KLe(this._rawAttributes),this._schemaUrl=qFt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,$S(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&fe.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if($S(n)){fe.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=BFt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function LX(t,e){return DX.FromAttributeList(Object.entries(t),e)}function KLe(t){return t.map(([e,r])=>$S(r)?[e,r.catch(n=>{fe.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function qFt(t){if(typeof t=="string"||t===void 0)return t;fe.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function BFt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;fe.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var w0=class{emit(e){}enabled(){return!1}},YLe=new w0;var T0=Symbol.for("io.opentelemetry.js.api.logs"),MS=globalThis;function JLe(t,e,r){return n=>n===t?e:r}var $X=1;var MX=class{getLogger(e,r,n){return new w0}},JM=new MX;var ZM=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):YLe}};var R0=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new ZM(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:JM}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var XM=class t{constructor(){this._proxyLoggerProvider=new R0}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return MS[T0]?this.getLoggerProvider():(MS[T0]=JLe($X,e,JM),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=MS[T0])===null||e===void 0?void 0:e.call(MS,$X))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete MS[T0],this._proxyLoggerProvider=new R0}};var ZLe=XM.getInstance();function XLe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function QLe(t){t.forEach(e=>e.disable())}function UX(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||jR.getMeterProvider(),n=t.loggerProvider||ZLe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return XLe(i,e,r,n),()=>{QLe(i)}}Ue();var HFt=Dn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function e$e(t){return t.getValue(HFt)===!0}var US;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(US||(US={}));Ue();var FX="[_0-9a-z-*/]",VFt=`[a-z]${FX}{0,255}`,GFt=`[a-z0-9]${FX}{0,240}@[a-z]${FX}{0,13}`,WFt=new RegExp(`^(?:${VFt}|${GFt})$`),KFt=/^[ -~]{0,255}[!-~]$/,YFt=/,|=/;function jX(t){return WFt.test(t)}function zX(t){return KFt.test(t)&&!YFt.test(t)}var JFt=32,t$e=512,r$e=",",n$e="=",QM=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!jX(e)||!zX(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>t$e)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=r$e+e),e=`${n[0]}${n$e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(r$e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(n$e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!jX(a)||!zX(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>t$e)&&(r.set(a,c),n=u,r.size>=JFt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var e1="traceparent",t1="tracestate",ZFt="00",XFt="(?!ff)[\\da-f]{2}",QFt="(?![0]{32})[\\da-f]{32}",ejt="(?![0]{16})[\\da-f]{16}",tjt="[\\da-f]{2}",rjt=new RegExp(`^\\s?(${XFt})-(${QFt})-(${ejt})-(${tjt})(-.*)?\\s?$`);function i$e(t){let e=rjt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var gf=class{inject(e,r,n){let i=zt.getSpanContext(e);if(!i||e$e(e)||!ms(i))return;let s=`${ZFt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||$r.NONE).toString(16)}`;n.set(r,e1,s),i.traceState&&n.set(r,t1,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,e1);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=i$e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,t1);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new QM(typeof c=="string"?c:void 0)}return zt.setSpanContext(e,o)}fields(){return[e1,t1]}};var r1=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var A0=class{_isCalled=!1;_deferred=new r1;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var Y1=mn(PQ(),1);Ue();var rUe=t=>{throw TypeError(t)},kQ=(t,e,r)=>e.has(t)||rUe("Cannot "+r),K1=(t,e,r)=>(kQ(t,e,"read from private field"),r?r.call(t):e.get(t)),IQ=(t,e,r)=>e.has(t)?rUe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Q1e=(t,e,r,n)=>(kQ(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),kzt=(t,e,r)=>(kQ(t,e,"access private method"),r),eUe="__netlify__getTracer",Lzt="__netlify__shutdownTracers",$zt="__nfOTLPTrace",V0,G0,NQ,nUe,Mzt=class{constructor(){IQ(this,NQ),IQ(this,V0),IQ(this,G0),Q1e(this,V0,new A0(kzt(this,NQ,nUe),this)),Q1e(this,G0,fe.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(K1(this,G0).debug(`export ${t.length.toString()} spans`),K1(this,V0).isCalled){e({code:US.FAILED,error:new Error("Exporter has been shutdown")});return}console.log($zt,JSON.stringify(Uzt(t))),e({code:US.SUCCESS})}shutdown(){return K1(this,V0).call()}};V0=new WeakMap;G0=new WeakMap;NQ=new WeakSet;nUe=function(){return K1(this,G0).debug("Shutting down"),Promise.resolve()};function Uzt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:W1(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Oa.SERVER,startTimeUnixNano:CQ(e.startTime),endTimeUnixNano:CQ(e.endTime),attributes:W1(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:CQ(n.time),attributes:W1(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:W1(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function W1(t){return Object.keys(t).map(e=>iUe(e,t[e]))}function iUe(t,e){return{key:t,value:sUe(e)}}function sUe(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(sUe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>iUe(r,n))}}:{}}function CQ(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var tUe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},oUe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,eUe))return;let e=Dzt.version.slice(1),r=LX({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Fzt()],i=new Y1.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new gf});let s=t.instrumentations??[];UX({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,eUe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new hl(zt.getTracer(a,c)):new hl(zt.getTracer(tUe.name,tUe.version))}}),Object.defineProperty(globalThis,Lzt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Fzt=()=>new Y1.SimpleSpanProcessor(new Mzt);Ue();var JS=mn(PQ(),1);Ue();import*as J1 from"diagnostics_channel";var aUe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Ln.ERROR:Ln.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof hl?t:new hl(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){J1.subscribe(t,e);let r=()=>J1.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Oa.CLIENT},ir.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Ln.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var HVe=mn(jVe(),1);Cne();var zVe=0;var qYt=3*1024*1024,BYt=t=>dO.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Jj=class{constructor(e,r=qYt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=BYt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:zVe});return}this.inner.export(n[c],u=>{u.code!==zVe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var YE=de("tracing"),qVe=8e3,VYt=5e3,BVe=t=>t.length>qVe?`${t.slice(0,qVe)}\u2026`:t,hO={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},GYt=Math.ceil(hO.maxQueueSize/hO.maxExportBatchSize)+1,WYt=t=>new JS.BatchSpanProcessor(new Jj(new HVe.OTLPTraceExporter({url:t,concurrencyLimit:GYt})),hO),Bm=async(t=VYt)=>{try{let e=Symbol("timed out");await Promise.race([$Le(),HYt(t,e)])===e&&YE.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){YE.warn("Failed to flush tracers on shutdown",e)}},VVe=async(t,e,r)=>{if(!Ct()){let n=[new JS.SimpleSpanProcessor(new kne),WYt(r.exporterUrl)];await oUe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new aUe({skipHeaders:!0})]})}return r.traceparent?(qi.setGlobalPropagator(new gf),qi.extract(ir.active(),{traceparent:r.traceparent,isRemote:!0})):ir.active()};function ur(t,e,r){return YE.log(`\u23F3 TRACE: ${e} starting...`),b0(t,e,r)}var kne=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";YE.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&YE.log(` \u274C Error: ${e.status.message}`)}};function Dne(){return Ye().captureLlmContentEnabled}function GVe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Zj(t,e,r){let n={role:t,parts:[{type:"text",content:di(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var KYt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]);function WVe(t,e,r,n){if(!t.length)return;let i=Ct();if(!i)return;t.length>hO.maxQueueSize&&YE.warn(`${t.length} step spans exceed the span queue of ${hO.maxQueueSize}; spans may be dropped`);let s=Dne(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&KYt.has(a.category)||a.category===X.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=BVe(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?BVe(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":di(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":di(g)}:{"gen_ai.output.messages":Zj("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:Ln.ERROR}))),y.end(l)})}import{readdir as YYt,rm as JYt}from"fs/promises";import{join as ZYt}from"path";async function KVe(t,e=[]){let n=(await YYt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>JYt(ZYt(t,i),{recursive:!0,force:!0})))}var XYt=300,mO=t=>Ye().budgetCreditThresholds[t.mode]?.[t.runner]??XYt,gO=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Lne=t=>{let e=mO(t);if(!gO(t,e))return"default";let r=Ye();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},YVe=t=>{let e=Lne(t),r=mO(t);return{budget_eligible:gO(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var r5t=_O.dirname(QYt(import.meta.url)),JVe=e5t(import.meta.url),n5t=_O.resolve(r5t,"scripts/scaffold.js"),i5t="scripts/scaffold.js",s5t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,$ne=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},o5t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),a5t=t=>{let e=$ne(t);return e==="node"||e.endsWith("/node")},Xs=t=>{if(typeof t!="string")return!1;let e=t.match(s5t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&o5t($ne(e[r]));)r+=1;if(r>=e.length||!a5t(e[r]))return!1;let n=e[r+1];return n?$ne(n).includes(i5t):!1},Hm=de("create_stage"),Mne="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",c5t=`${Mne}
|
|
601
601
|
|
|
602
602
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,u5t=`${Mne}
|
|
603
603
|
|
package/dist/index.js
CHANGED
|
@@ -384,7 +384,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
384
384
|
`,LF:`
|
|
385
385
|
`,concatBytes:RY},Put=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Cut={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Put};import{Buffer as kut}from"buffer";var VTe=(t,e)=>t?void 0:Nut.bind(void 0,e),Nut=function*(t,e){if(typeof e!="string"&&!Fr(e)&&!kut.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},HTe=(t,e)=>t?Dut.bind(void 0,e):Mut.bind(void 0,e),Dut=function*(t,e){WTe(t,e),yield e},Mut=function*(t,e){if(WTe(t,e),typeof e!="string"&&!Fr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},WTe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
386
386
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
387
|
-
if (condition) { yield value; }`)};import{Buffer as $ut}from"buffer";import{StringDecoder as Lut}from"string_decoder";var KD=(t,e,r)=>{if(r)return;if(t)return{transform:Uut.bind(void 0,new TextEncoder)};let n=new Lut(e);return{transform:Fut.bind(void 0,n),final:zut.bind(void 0,n)}},Uut=function*(t,e){$ut.isBuffer(e)?yield eu(e):typeof e=="string"?yield t.encode(e):yield e},Fut=function*(t,e){yield Fr(e)?t.write(e):e},zut=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as KTe}from"util";var OY=KTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),YD=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qut}=e[r];for await(let i of n(t))yield*YD(i,e,r+1)},YTe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*jut(r,Number(e),t)},jut=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*YD(n,r,e+1)},ZTe=KTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),qut=function*(t){yield t};var IY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QTe=(t,e)=>[...e.flatMap(r=>[...bp(r,t,0)]),...Ww(t)],bp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Gut}=e[r];for(let i of n(t))yield*bp(i,e,r+1)},Ww=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*But(r,Number(e),t)},But=function*(t,e,r){if(t!==void 0)for(let n of t())yield*bp(n,r,e+1)},Gut=function*(t){yield t};var PY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=XTe(t,o,s),u=Ep(e),l=Ep(r),d=u?OY.bind(void 0,YD,a):IY.bind(void 0,bp),f=u||l?OY.bind(void 0,YTe,a):IY.bind(void 0,Ww),p=u||l?ZTe.bind(void 0,a):void 0;return{stream:new Vut({writableObjectMode:n,writableHighWaterMark:JTe(n),readableObjectMode:i,readableHighWaterMark:JTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ZD=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=XTe(o,r,a);t=QTe(c,t)}return t},XTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:VTe(n,a)},KD(r,o,n),WD(r,s,n,c),{transform:t,final:e},{transform:HTe(i,a)},GTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var ewe=(t,e)=>{for(let r of Hut(t))Wut(t,r,e)},Hut=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Wut=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ql[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Kut(a,n));r.input=Lw(o)},Kut=(t,e)=>{let r=ZD(t,e,"utf8",!0);return Yut(r),Lw(r)},Yut=t=>{let e=t.find(r=>typeof r!="string"&&!Fr(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 Xut,appendFileSync as elt}from"fs";var QD=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&R_(r,n)&&!es.has(e)&&Zut(n)&&(t.some(({type:i,value:s})=>i==="native"&&Qut.has(s))||t.every(({type:i})=>Ms.has(i))),Zut=t=>t===1||t===2,Qut=new Set(["pipe","overlapped"]),twe=async(t,e,r,n)=>{for await(let i of t)Jut(e)||nwe(i,r,n)},rwe=(t,e,r)=>{for(let n of t)nwe(n,e,r)},Jut=t=>t._readableState.pipes.length>0,nwe=(t,e,r)=>{let n=dD(t);za({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var iwe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>tlt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},tlt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=sTe(t,s,d),p=eu(f),{stdioItems:h,objectMode:m}=e[r],_=rlt([p],h,c,n),{serializedResult:y,finalResult:w=y}=nlt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});ilt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?w:void 0;try{return n.error===void 0&&slt(y,h,i),x}catch(S){return n.error=S,x}},rlt=(t,e,r,n)=>{try{return ZD(t,e,r,!1)}catch(i){return n.error=i,t}},nlt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Lw(t)};let o=Sve(t,r);return n[s]?{serializedResult:o,finalResult:xY(o,!i[s],e)}:{serializedResult:o}},ilt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!QD({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=xY(t,!1,o);try{rwe(a,e,n)}catch(c){r.error??=c}},slt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>VD.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?elt(n,t):(r.add(s),Xut(n,t))}};var swe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,nu(e,r,"all")]:Array.isArray(e)?[nu(t,r,"all"),...e]:Fr(t)&&Fr(e)?$K([t,e]):`${t}${e}`};import{once as CY}from"events";var owe=async(t,e)=>{let[r,n]=await olt(t);return e.isForcefullyTerminated??=!1,[r,n]},olt=async t=>{let[e,r]=await Promise.allSettled([CY(t,"spawn"),CY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?awe(t):r.value},awe=async t=>{try{return await CY(t,"exit")}catch{return awe(t)}},cwe=async t=>{let[e,r]=await t;if(!alt(e,r)&&kY(e,r))throw new Go;return[e,r]},alt=(t,e)=>t===void 0&&e===void 0,kY=(t,e)=>t!==0||e!==null;var uwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=clt(t,e,r),o=s?.code==="ETIMEDOUT",a=iTe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},clt=(t,e,r)=>t!==void 0?t:kY(e,r)?new Go:void 0;var lwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=llt(t,e,r),d=plt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return $_(d,c,u)},llt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pD(t,e,r),a=dlt(r),{file:c,commandArguments:u,options:l}=ND(t,e,a);flt(l);let d=zTe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},dlt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,flt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&JD("ipcInput"),t&&JD("ipc: true"),r&&JD("detached: true"),n&&JD("cancelSignal")},JD=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},plt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=hlt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=uwe(c,r),{output:h,error:m=u}=iwe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((w,x)=>nu(w,r,x)),y=nu(swe(h,r),r,"all");return glt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},hlt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{ewe(s,r);let a=mlt(r);return ult(...DD(t,e,a))}catch(a){return M_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},mlt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:jD(e)}),glt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?qD({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):Hw({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as nft}from"events";import{spawn as ift}from"child_process";import mwe from"process";import{once as NY,on as _lt}from"events";var dwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(I_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:xD(t)}),ylt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),ylt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{TD(e,i);let s=jl(t,e,r),o=new AbortController;try{return await Promise.race([Slt(s,n,o),vlt(s,r,o),Elt(s,r,o)])}catch(a){throw P_(t),a}finally{o.abort(),wD(e,i)}},Slt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await NY(t,"message",{signal:r});return n}for await(let[n]of _lt(t,"message",{signal:r}))if(e(n))return n},vlt=async(t,e,{signal:r})=>{await NY(t,"disconnect",{signal:r}),QEe(e)},Elt=async(t,e,{signal:r})=>{let[n]=await NY(t,"strict:error",{signal:r});throw vD(n,e)};import{once as pwe,on as blt}from"events";var hwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>DY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),DY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{I_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:xD(t)}),TD(e,s);let o=jl(t,e,r),a=new AbortController,c={};return Tlt(t,o,a),wlt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Alt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Tlt=async(t,e,r)=>{try{await pwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},wlt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await pwe(t,"strict:error",{signal:r.signal});n.error=vD(i,e),r.abort()}catch{}},Alt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of blt(r,"message",{signal:s.signal}))fwe(o),yield c}catch{fwe(o)}finally{s.abort(),wD(e,a),n||P_(t),i&&await t}},fwe=({error:t})=>{if(t)throw t};var gwe=(t,{ipc:e})=>{Object.assign(t,ywe(t,!1,e))},_we=()=>{let t=mwe,e=!0,r=mwe.channel!==void 0;return{...ywe(t,e,r),getCancelSignal:wbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ywe=(t,e,r)=>({sendMessage:CD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:dwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:hwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Rlt}from"child_process";import{PassThrough as xlt,Readable as Olt,Writable as Ilt,Duplex as Plt}from"stream";var Swe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{wY(n);let a=new Rlt;Clt(a,n),Object.assign(a,{readable:klt,writable:Nlt,duplex:Dlt});let c=M_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Mlt(c,o,i);return{subprocess:a,promise:u}},Clt=(t,e)=>{let r=Kw(),n=Kw(),i=Kw(),s=Array.from({length:e.length-3},Kw),o=Kw(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Kw=()=>{let t=new xlt;return t.end(),t},klt=()=>new Olt({read(){}}),Nlt=()=>new Ilt({write(){}}),Dlt=()=>new Plt({read(){},write(){}}),Mlt=async(t,e,r)=>$_(t,e,r);import{createReadStream as vwe,createWriteStream as Ewe}from"fs";import{Buffer as $lt}from"buffer";import{Readable as Yw,Writable as Llt,Duplex as Ult}from"stream";var Twe=(t,e)=>HD(Flt,t,e,!1),Zw=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ql[t]}.`)},bwe={fileNumber:Zw,generator:PY,asyncGenerator:PY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Ult.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Flt={input:{...bwe,fileUrl:({value:t})=>({stream:vwe(t)}),filePath:({value:{file:t}})=>({stream:vwe(t)}),webStream:({value:t})=>({stream:Yw.fromWeb(t)}),iterable:({value:t})=>({stream:Yw.from(t)}),asyncIterable:({value:t})=>({stream:Yw.from(t)}),string:({value:t})=>({stream:Yw.from(t)}),uint8Array:({value:t})=>({stream:Yw.from($lt.from(t))})},output:{...bwe,fileUrl:({value:t})=>({stream:Ewe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Ewe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Llt.fromWeb(t)}),iterable:Zw,asyncIterable:Zw,string:Zw,uint8Array:Zw}};import{on as zlt,once as wwe}from"events";import{PassThrough as jlt,getDefaultHighWaterMark as qlt}from"stream";import{finished as xwe}from"stream/promises";function Tp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)$Y(i);let e=t.some(({readableObjectMode:i})=>i),r=Blt(t,e),n=new MY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Blt=(t,e)=>{if(t.length===0)return qlt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},MY=class extends jlt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if($Y(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Glt(this,this.#e,this.#s);let r=Wlt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if($Y(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Glt=async(t,e,r)=>{XD(t,Awe);let n=new AbortController;try{await Promise.race([Vlt(t,n),Hlt(t,e,r,n)])}finally{n.abort(),XD(t,-Awe)}},Vlt=async(t,{signal:e})=>{try{await xwe(t,{signal:e,cleanup:!0})}catch(r){throw Owe(t,r),r}},Hlt=async(t,e,r,{signal:n})=>{for await(let[i]of zlt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},$Y=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Wlt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{XD(t,Rwe);let a=new AbortController;try{await Promise.race([Klt(s,e,a),Ylt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Zlt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),XD(t,-Rwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?LY(t):Qlt(t))},Klt=async(t,e,{signal:r})=>{try{await t,r.aborted||LY(e)}catch(n){r.aborted||Owe(e,n)}},Ylt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await xwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Iwe(o)?i.add(e):Pwe(t,o)}},Zlt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await wwe(t,i,{signal:s}),!t.readable)return wwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Qlt=t=>{t.writable&&t.end()},Owe=(t,e)=>{Iwe(e)?LY(t):Pwe(t,e)},Iwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",LY=t=>{(t.readable||t.writable)&&t.destroy()},Pwe=(t,e)=>{t.destroyed||(t.once("error",Jlt),t.destroy(e))},Jlt=()=>{},XD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Awe=2,Rwe=1;import{finished as Cwe}from"stream/promises";var U_=(t,e)=>{t.pipe(e),Xlt(t,e),edt(t,e)},Xlt=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await Cwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}UY(e)}},UY=t=>{t.writable&&t.end()},edt=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await Cwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}FY(t)}},FY=t=>{t.readable&&t.destroy()};var kwe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Ms.has(c)))tdt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ms.has(c)))ndt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Tp(s);U_(o,i)}},tdt=(t,e,r,n)=>{r==="output"?U_(t.stdio[n],e):U_(e,t.stdio[n]);let i=rdt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},rdt=["stdin","stdout","stderr"],ndt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;idt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},idt=(t,{signal:e})=>{Bo(t)&&Sp(t,sdt,e)},sdt=2;import{addAbortListener as cdt}from"events";var wp=[];wp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&wp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&wp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eM=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",zY=Symbol.for("signal-exit emitter"),jY=globalThis,odt=Object.defineProperty.bind(Object),qY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(jY[zY])return jY[zY];odt(jY,zY,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},tM=class{},adt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),BY=class extends tM{onExit(){return()=>{}}load(){}unload(){}},GY=class extends tM{#e=VY.platform==="win32"?"SIGINT":"SIGHUP";#r=new qY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of wp)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!eM(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 wp)try{let r=this.#i[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,wp.forEach(e=>{let r=this.#i[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.#s,this.#r.count-=1)}#a(e){return eM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&eM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},VY=globalThis.process,{onExit:Nwe,load:bor,unload:Tor}=adt(eM(VY)?new GY(VY):new BY);var Dwe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Nwe(()=>{t.kill()});cdt(n,()=>{i()})};var $we=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=fD(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=udt(r,n,i),{sourceStream:d,sourceError:f}=ddt(t,u),{options:p,fileDescriptors:h}=qa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},udt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=ldt(t,e,...r),a=bD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},ldt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Mwe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||DK(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[i,s,o]=rD(r,...n);return{destination:e(Mwe)(i,s,o),pipeOptions:o}}if(qa.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}`)},Mwe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ddt=(t,e)=>{try{return{sourceStream:C_(t,e)}}catch(r){return{sourceError:r}}};var Uwe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=fdt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw HY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},fdt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return FY(t),n;if(e!==void 0)return UY(r),e},HY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>M_({error:t,command:Lwe,escapedCommand:Lwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Lwe="source.pipe(destination)";var Fwe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as pdt}from"stream/promises";var zwe=(t,e,r)=>{let n=rM.has(e)?mdt(t,e):hdt(t,e);return Sp(t,_dt,r.signal),Sp(e,ydt,r.signal),gdt(e),n},hdt=(t,e)=>{let r=Tp([t]);return U_(r,e),rM.set(e,r),r},mdt=(t,e)=>{let r=rM.get(e);return r.add(t),r},gdt=async t=>{try{await pdt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rM.delete(t)},rM=new WeakMap,_dt=2,ydt=1;import{aborted as Sdt}from"util";var jwe=(t,e)=>t===void 0?[]:[vdt(t,e)],vdt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Sdt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw HY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var nM=(t,...e)=>{if(yr(e[0]))return nM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$we(t,...e),i=Edt({...n,destination:r});return i.pipe=nM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Edt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=bdt(t,i);Uwe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=zwe(e,s,d);return await Promise.race([Fwe(l),...jwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},bdt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Idt}from"timers/promises";import{on as Tdt}from"events";import{getDefaultHighWaterMark as wdt}from"stream";var iM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Adt(e,o),Bwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Adt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},WY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Rdt(e,o,t);let a=t.readableObjectMode&&!s;return Bwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Rdt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Bwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Tdt(t,"data",{signal:e.signal,highWaterMark:qwe,highWatermark:qwe});return xdt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},KY=wdt(!0),qwe=KY,xdt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Odt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*bp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ww(a)}},Odt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[KD(t,r,!e),WD(t,i,!n,{})].filter(Boolean);var Gwe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Pdt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Cdt(t),d]);return}let f=AY(c,r),p=WY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([kdt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Pdt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!QD({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=WY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await twe(a,t,r,s)},Cdt=async t=>{await Idt(),t.readableFlowing===null&&t.resume()},kdt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await UD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await FD(r,{maxBuffer:s})):await D_(r,{maxBuffer:s})}catch(a){return Vwe(tTe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},YY=async t=>{try{return await t}catch(e){return Vwe(e)}},Vwe=({bufferedData:t})=>_ve(t)?new Uint8Array(t):t;import{finished as Ndt}from"stream/promises";var Qw=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Ddt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Ndt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Ldt(a,e,r,n)}finally{o.abort()}},Ddt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Mdt(t,r,n),n},Mdt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{$dt(e,r),n.call(t,...i)}},$dt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ldt=(t,e,r,n)=>{if(!Udt(t,e,r,n))throw t},Udt=(t,e,r,n=!0)=>r.propagating?Hwe(t)||sM(t):(r.propagating=!0,ZY(r,e)===n?Hwe(t):sM(t)),ZY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Hwe=t=>t?.code==="EPIPE";var Wwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>QY({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),QY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Qw(t,e,u);if(ZY(u,e)){await l;return}let[d]=await Promise.all([Gwe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Kwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Tp([t,e].filter(Boolean)):void 0,Ywe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>QY({...Fdt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:zdt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Fdt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},zdt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as jdt}from"events";var Zwe=t=>R_(t,"ipc"),Qwe=(t,e)=>{let r=dD(t);za({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Jwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Zwe(s),a=tu(e,"ipc"),c=tu(r,"ipc");for await(let u of DY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(rTe(t,i,c),i.push(u)),o&&Qwe(u,s);return i},Xwe=async(t,e)=>(await Promise.allSettled([t]),e);var eAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let w=owe(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:w,propagating:!1},S=Wwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),v=Ywe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),E=[],I=Jwe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=qdt(m,t,x),P=Bdt(h,x);try{return await Promise.race([Promise.all([{},cwe(w),Promise.all(S),v,I,Dbe(t,d),...C,...P]),_,Gdt(t,y),...Ibe(t,s,f,y),...ZEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...xbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},w,Promise.all(S.map(T=>YY(T))),YY(v),Xwe(I,E),Promise.allSettled(C),Promise.allSettled(P)])}},qdt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Qw(n,i,r)),Bdt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ho(s,{checkOpen:!1})&&!Bo(s)).map(({type:i,value:s,stream:o=s})=>Qw(o,n,e,{isSameDirection:Ms.has(i),stopOnExit:i==="native"}))),Gdt=async(t,{signal:e})=>{let[r]=await jdt(t,"error",{signal:e});throw r};var tAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Jw=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ja();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},F_=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 Vdt}from"stream";import{callbackify as Hdt}from"util";import{finished as rAe}from"stream/promises";var JY=async t=>{if(t!==void 0)try{await XY(t)}catch{}},nAe=async t=>{if(t!==void 0)try{await e9(t)}catch{}},XY=async t=>{await rAe(t,{cleanup:!0,readable:!1,writable:!0})},e9=async t=>{await rAe(t,{cleanup:!0,readable:!0,writable:!1})},oM=async(t,e)=>{if(await t,e)throw e},aM=(t,e,r)=>{r&&!sM(r)?t.destroy(r):e&&t.destroy()};var iAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||es.has(r),{subprocessStdout:a,waitReadableDestroy:c}=t9(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=r9(a,o),{read:f,onStdoutDataDone:p}=n9({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new Vdt({read:f,destroy:Hdt(s9.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return i9({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},t9=(t,e,r)=>{let n=C_(t,e),i=Jw(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},r9=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:KY},n9=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ja(),o=iM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Wdt(this,o,s)},onStdoutDataDone:s}},Wdt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},i9=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await e9(t),await n,await JY(i),await e,r.readable&&r.push(null)}catch(s){await JY(i),sAe(r,s)}},s9=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await F_(r,e)&&(sAe(t,n),await oM(e,n))},sAe=(t,e)=>{aM(t,t.readable,e)};import{Writable as Kdt}from"stream";import{callbackify as oAe}from"util";var aAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=o9(t,r,e),o=new Kdt({...a9(n,t,i),destroy:oAe(u9.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return c9(n,o),o},o9=(t,e,r)=>{let n=bD(t,e),i=Jw(r,n,"writableFinal"),s=Jw(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},a9=(t,e,r)=>({write:Ydt.bind(void 0,t),final:oAe(Zdt.bind(void 0,t,e,r))}),Ydt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Zdt=async(t,e,r)=>{await F_(r,e)&&(t.writable&&t.end(),await e)},c9=async(t,e,r)=>{try{await XY(t),e.writable&&e.end()}catch(n){await nAe(r),cAe(e,n)}},u9=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await F_(r,e),await F_(n,e)&&(cAe(t,i),await oM(e,i))},cAe=(t,e)=>{aM(t,t.writable,e)};import{Duplex as Qdt}from"stream";import{callbackify as Jdt}from"util";var uAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||es.has(r),{subprocessStdout:c,waitReadableDestroy:u}=t9(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=o9(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=r9(c,a),{read:_,onStdoutDataDone:y}=n9({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),w=new Qdt({read:_,...a9(l,t,d),destroy:Jdt(Xdt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return i9({subprocessStdout:c,onStdoutDataDone:y,readable:w,subprocess:t,subprocessStdin:l}),c9(l,w,c),w},Xdt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([s9({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),u9({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var l9=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||es.has(e),o=C_(t,r),a=iM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return eft(a,o,t)},eft=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lAe=(t,{encoding:e})=>{let r=tAe();t.readable=iAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=aAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=uAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=l9.bind(void 0,t,e),t[Symbol.asyncIterator]=l9.bind(void 0,t,e,{})};var dAe=(t,e)=>{for(let[r,n]of rft){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},tft=(async()=>{})().constructor.prototype,rft=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(tft,t)]);var fAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=sft(t,e,r),{subprocess:f,promise:p}=aft({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),dAe(f,p),qa.set(f,{options:l,fileDescriptors:d}),f},sft=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pD(t,e,r),{file:a,commandArguments:c,options:u}=ND(t,e,r),l=oft(u),d=Twe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},oft=({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}},aft=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=ift(...DD(t,e,r))}catch(h){return Swe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;nft(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];kwe(c,a,u),Dwe(c,r,u);let d={},f=ja();c.kill=KEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Kwe(c,r),lAe(c,r),gwe(c,r);let p=cft({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},cft=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await eAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,v)=>nu(S,e,v)),w=nu(m,e,"all"),x=uft({errorInfo:d,exitCode:f,signal:p,stdio:y,all:w,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return $_(x,n,e)},uft=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?Hw({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ba,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):qD({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var cM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,lft(n,t[n],i)]));return{...t,...r}},lft=(t,e,r)=>dft.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,dft=new Set(["env",...zK]);var Bl=(t,e,r,n)=>{let i=(o,a,c)=>Bl(o,a,r,c),s=(...o)=>fft({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},fft=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,cM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=pft({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?lwe(a,c,u):fAe(a,c,u,i)},pft=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Tve(e)?wve(e,r):[e,...r],[o,a,c]=rD(...s),u=cM(cM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var pAe=({file:t,commandArguments:e})=>mAe(t,e),hAe=({file:t,commandArguments:e})=>({...mAe(t,e),isSync:!0}),mAe=(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]=hft(t);return{file:r,commandArguments:n}},hft=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(mft)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},mft=/ +/g;var gAe=(t,e,r)=>{t.sync=e(gft,r),t.s=t.sync},_Ae=({options:t})=>yAe(t),gft=({options:t})=>({...yAe(t),isSync:!0}),yAe=t=>({options:{..._ft(t),...t}}),_ft=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},SAe={preferLocal:!0};var vAe=Bl(()=>({})),pur=Bl(()=>({isSync:!0})),EAe=Bl(pAe),hur=Bl(hAe),mur=Bl(Cbe),gur=Bl(_Ae,{},SAe,gAe),{sendMessage:_ur,getOneMessage:yur,getEachMessage:Sur,getCancelSignal:vur}=_we();var bAe=!1,TAe,yft=t=>{TAe??=t},wAe=t=>{bAe=!0,yft(t)},Nn=()=>bAe,iu=()=>TAe,AAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Xw=null,RAe=t=>(Xw&&Xw.destroy(),Xw=new $s({totalAllowedTime:t}),Xw),xAe=()=>Xw;var $s=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Nn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await WC({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{W.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),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 OAe={name:"@netlify/agent-runner-cli",type:"module",version:"2.9.0-nb7266f6744f08.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.5","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var bft=vft(import.meta.url),Tft=su.dirname(bft),wft=Eft(import.meta.url),z_=re("shell"),d9=new Set,IAe={preferLocal:!0},yt=(t,e,r)=>{let[n,i]=Aft(e,r),s={...IAe,...i},o=vAe(t,n,s);CAe(o,s),DAe(o);let a=r?.idleTimeout;return a&&a>0&&NAe(o,a),o},PAe=(t,e)=>{let r={...IAe,...e},n=EAe(t,r);return CAe(n,r),DAe(n),e?.idleTimeout&&e.idleTimeout>0&&NAe(n,e.idleTimeout),n},Aft=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},CAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Va.env.NETLIFY_LOCAL_QUIET==="true")return;if(Va.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Fb).pipe(Va.stdout),t.stderr?.pipe(new Fb).pipe(Va.stderr);return}t.stdout?.pipe(Va.stdout),t.stderr?.pipe(Va.stderr)},f9=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Va.kill(-t.pid,e),z_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return z_.error("Error killing process:",r),!1}},kAe=t=>f9(t,"SIGKILL"),NAe=(t,e)=>{let r=null,n=()=>{z_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),f9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing idle process ${t.pid}`),kAe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},DAe=t=>{d9.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{z_.log(`Global timer expired, killing process ${t.pid}`),f9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing process ${t.pid} after timeout`),kAe(t))},5e3)});t.on("exit",()=>{d9.delete(t),r()}),t.on("error",()=>{d9.delete(t),r()})}};function Ha(t,e){if(!Va.env.NETLIFY_LOCAL_MODE)try{let i=wft.resolve(OAe.name),s=su.dirname(i);for(;s!==su.dirname(s);){let o=su.dirname(s);if(su.basename(o)==="node_modules"){let a=su.join(o,".bin",e);if(uM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Va.env.NODE_PATH){let i=su.join(Va.env.NODE_PATH,".bin",e);if(uM.existsSync(i))return i}let r=su.join(t,"node_modules",".bin",e);if(uM.existsSync(r))return r;let n=su.join(Tft,"..","node_modules",".bin",e);if(uM.existsSync(n))return n}var j_=re("repo"),jAe="runner-diffs-",p9=t=>`${jAe}${t}-`,qAe=async t=>{let e=dM.tmpdir(),r;try{r=await ni.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(jAe)&&!n.startsWith(p9(t))).map(n=>ni.rm(Ls.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},MAe=async t=>{let e=Rft("sha256");for await(let r of xft(t))e.update(r);return e.digest("hex")},$Ae=async(t,e)=>t.size===e.size&&await MAe(t.path)===await MAe(e.path),BAe=/.. (.+)?\.log$/,Oft=[BAe],Ift=1,LAe=t=>{let e=t.split(`
|
|
387
|
+
if (condition) { yield value; }`)};import{Buffer as $ut}from"buffer";import{StringDecoder as Lut}from"string_decoder";var KD=(t,e,r)=>{if(r)return;if(t)return{transform:Uut.bind(void 0,new TextEncoder)};let n=new Lut(e);return{transform:Fut.bind(void 0,n),final:zut.bind(void 0,n)}},Uut=function*(t,e){$ut.isBuffer(e)?yield eu(e):typeof e=="string"?yield t.encode(e):yield e},Fut=function*(t,e){yield Fr(e)?t.write(e):e},zut=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as KTe}from"util";var OY=KTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),YD=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qut}=e[r];for await(let i of n(t))yield*YD(i,e,r+1)},YTe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*jut(r,Number(e),t)},jut=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*YD(n,r,e+1)},ZTe=KTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),qut=function*(t){yield t};var IY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QTe=(t,e)=>[...e.flatMap(r=>[...bp(r,t,0)]),...Ww(t)],bp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Gut}=e[r];for(let i of n(t))yield*bp(i,e,r+1)},Ww=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*But(r,Number(e),t)},But=function*(t,e,r){if(t!==void 0)for(let n of t())yield*bp(n,r,e+1)},Gut=function*(t){yield t};var PY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=XTe(t,o,s),u=Ep(e),l=Ep(r),d=u?OY.bind(void 0,YD,a):IY.bind(void 0,bp),f=u||l?OY.bind(void 0,YTe,a):IY.bind(void 0,Ww),p=u||l?ZTe.bind(void 0,a):void 0;return{stream:new Vut({writableObjectMode:n,writableHighWaterMark:JTe(n),readableObjectMode:i,readableHighWaterMark:JTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ZD=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=XTe(o,r,a);t=QTe(c,t)}return t},XTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:VTe(n,a)},KD(r,o,n),WD(r,s,n,c),{transform:t,final:e},{transform:HTe(i,a)},GTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var ewe=(t,e)=>{for(let r of Hut(t))Wut(t,r,e)},Hut=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Wut=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ql[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Kut(a,n));r.input=Lw(o)},Kut=(t,e)=>{let r=ZD(t,e,"utf8",!0);return Yut(r),Lw(r)},Yut=t=>{let e=t.find(r=>typeof r!="string"&&!Fr(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 Xut,appendFileSync as elt}from"fs";var QD=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&R_(r,n)&&!es.has(e)&&Zut(n)&&(t.some(({type:i,value:s})=>i==="native"&&Qut.has(s))||t.every(({type:i})=>Ms.has(i))),Zut=t=>t===1||t===2,Qut=new Set(["pipe","overlapped"]),twe=async(t,e,r,n)=>{for await(let i of t)Jut(e)||nwe(i,r,n)},rwe=(t,e,r)=>{for(let n of t)nwe(n,e,r)},Jut=t=>t._readableState.pipes.length>0,nwe=(t,e,r)=>{let n=dD(t);za({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var iwe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>tlt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},tlt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=sTe(t,s,d),p=eu(f),{stdioItems:h,objectMode:m}=e[r],_=rlt([p],h,c,n),{serializedResult:y,finalResult:w=y}=nlt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});ilt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?w:void 0;try{return n.error===void 0&&slt(y,h,i),x}catch(S){return n.error=S,x}},rlt=(t,e,r,n)=>{try{return ZD(t,e,r,!1)}catch(i){return n.error=i,t}},nlt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Lw(t)};let o=Sve(t,r);return n[s]?{serializedResult:o,finalResult:xY(o,!i[s],e)}:{serializedResult:o}},ilt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!QD({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=xY(t,!1,o);try{rwe(a,e,n)}catch(c){r.error??=c}},slt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>VD.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?elt(n,t):(r.add(s),Xut(n,t))}};var swe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,nu(e,r,"all")]:Array.isArray(e)?[nu(t,r,"all"),...e]:Fr(t)&&Fr(e)?$K([t,e]):`${t}${e}`};import{once as CY}from"events";var owe=async(t,e)=>{let[r,n]=await olt(t);return e.isForcefullyTerminated??=!1,[r,n]},olt=async t=>{let[e,r]=await Promise.allSettled([CY(t,"spawn"),CY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?awe(t):r.value},awe=async t=>{try{return await CY(t,"exit")}catch{return awe(t)}},cwe=async t=>{let[e,r]=await t;if(!alt(e,r)&&kY(e,r))throw new Go;return[e,r]},alt=(t,e)=>t===void 0&&e===void 0,kY=(t,e)=>t!==0||e!==null;var uwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=clt(t,e,r),o=s?.code==="ETIMEDOUT",a=iTe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},clt=(t,e,r)=>t!==void 0?t:kY(e,r)?new Go:void 0;var lwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=llt(t,e,r),d=plt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return $_(d,c,u)},llt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pD(t,e,r),a=dlt(r),{file:c,commandArguments:u,options:l}=ND(t,e,a);flt(l);let d=zTe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},dlt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,flt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&JD("ipcInput"),t&&JD("ipc: true"),r&&JD("detached: true"),n&&JD("cancelSignal")},JD=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},plt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=hlt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=uwe(c,r),{output:h,error:m=u}=iwe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((w,x)=>nu(w,r,x)),y=nu(swe(h,r),r,"all");return glt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},hlt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{ewe(s,r);let a=mlt(r);return ult(...DD(t,e,a))}catch(a){return M_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},mlt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:jD(e)}),glt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?qD({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):Hw({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as nft}from"events";import{spawn as ift}from"child_process";import mwe from"process";import{once as NY,on as _lt}from"events";var dwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(I_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:xD(t)}),ylt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),ylt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{TD(e,i);let s=jl(t,e,r),o=new AbortController;try{return await Promise.race([Slt(s,n,o),vlt(s,r,o),Elt(s,r,o)])}catch(a){throw P_(t),a}finally{o.abort(),wD(e,i)}},Slt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await NY(t,"message",{signal:r});return n}for await(let[n]of _lt(t,"message",{signal:r}))if(e(n))return n},vlt=async(t,e,{signal:r})=>{await NY(t,"disconnect",{signal:r}),QEe(e)},Elt=async(t,e,{signal:r})=>{let[n]=await NY(t,"strict:error",{signal:r});throw vD(n,e)};import{once as pwe,on as blt}from"events";var hwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>DY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),DY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{I_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:xD(t)}),TD(e,s);let o=jl(t,e,r),a=new AbortController,c={};return Tlt(t,o,a),wlt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Alt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Tlt=async(t,e,r)=>{try{await pwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},wlt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await pwe(t,"strict:error",{signal:r.signal});n.error=vD(i,e),r.abort()}catch{}},Alt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of blt(r,"message",{signal:s.signal}))fwe(o),yield c}catch{fwe(o)}finally{s.abort(),wD(e,a),n||P_(t),i&&await t}},fwe=({error:t})=>{if(t)throw t};var gwe=(t,{ipc:e})=>{Object.assign(t,ywe(t,!1,e))},_we=()=>{let t=mwe,e=!0,r=mwe.channel!==void 0;return{...ywe(t,e,r),getCancelSignal:wbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ywe=(t,e,r)=>({sendMessage:CD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:dwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:hwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Rlt}from"child_process";import{PassThrough as xlt,Readable as Olt,Writable as Ilt,Duplex as Plt}from"stream";var Swe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{wY(n);let a=new Rlt;Clt(a,n),Object.assign(a,{readable:klt,writable:Nlt,duplex:Dlt});let c=M_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Mlt(c,o,i);return{subprocess:a,promise:u}},Clt=(t,e)=>{let r=Kw(),n=Kw(),i=Kw(),s=Array.from({length:e.length-3},Kw),o=Kw(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Kw=()=>{let t=new xlt;return t.end(),t},klt=()=>new Olt({read(){}}),Nlt=()=>new Ilt({write(){}}),Dlt=()=>new Plt({read(){},write(){}}),Mlt=async(t,e,r)=>$_(t,e,r);import{createReadStream as vwe,createWriteStream as Ewe}from"fs";import{Buffer as $lt}from"buffer";import{Readable as Yw,Writable as Llt,Duplex as Ult}from"stream";var Twe=(t,e)=>HD(Flt,t,e,!1),Zw=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ql[t]}.`)},bwe={fileNumber:Zw,generator:PY,asyncGenerator:PY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Ult.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Flt={input:{...bwe,fileUrl:({value:t})=>({stream:vwe(t)}),filePath:({value:{file:t}})=>({stream:vwe(t)}),webStream:({value:t})=>({stream:Yw.fromWeb(t)}),iterable:({value:t})=>({stream:Yw.from(t)}),asyncIterable:({value:t})=>({stream:Yw.from(t)}),string:({value:t})=>({stream:Yw.from(t)}),uint8Array:({value:t})=>({stream:Yw.from($lt.from(t))})},output:{...bwe,fileUrl:({value:t})=>({stream:Ewe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Ewe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Llt.fromWeb(t)}),iterable:Zw,asyncIterable:Zw,string:Zw,uint8Array:Zw}};import{on as zlt,once as wwe}from"events";import{PassThrough as jlt,getDefaultHighWaterMark as qlt}from"stream";import{finished as xwe}from"stream/promises";function Tp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)$Y(i);let e=t.some(({readableObjectMode:i})=>i),r=Blt(t,e),n=new MY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Blt=(t,e)=>{if(t.length===0)return qlt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},MY=class extends jlt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if($Y(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Glt(this,this.#e,this.#s);let r=Wlt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if($Y(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Glt=async(t,e,r)=>{XD(t,Awe);let n=new AbortController;try{await Promise.race([Vlt(t,n),Hlt(t,e,r,n)])}finally{n.abort(),XD(t,-Awe)}},Vlt=async(t,{signal:e})=>{try{await xwe(t,{signal:e,cleanup:!0})}catch(r){throw Owe(t,r),r}},Hlt=async(t,e,r,{signal:n})=>{for await(let[i]of zlt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},$Y=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Wlt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{XD(t,Rwe);let a=new AbortController;try{await Promise.race([Klt(s,e,a),Ylt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Zlt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),XD(t,-Rwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?LY(t):Qlt(t))},Klt=async(t,e,{signal:r})=>{try{await t,r.aborted||LY(e)}catch(n){r.aborted||Owe(e,n)}},Ylt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await xwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Iwe(o)?i.add(e):Pwe(t,o)}},Zlt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await wwe(t,i,{signal:s}),!t.readable)return wwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Qlt=t=>{t.writable&&t.end()},Owe=(t,e)=>{Iwe(e)?LY(t):Pwe(t,e)},Iwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",LY=t=>{(t.readable||t.writable)&&t.destroy()},Pwe=(t,e)=>{t.destroyed||(t.once("error",Jlt),t.destroy(e))},Jlt=()=>{},XD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Awe=2,Rwe=1;import{finished as Cwe}from"stream/promises";var U_=(t,e)=>{t.pipe(e),Xlt(t,e),edt(t,e)},Xlt=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await Cwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}UY(e)}},UY=t=>{t.writable&&t.end()},edt=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await Cwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}FY(t)}},FY=t=>{t.readable&&t.destroy()};var kwe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Ms.has(c)))tdt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ms.has(c)))ndt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Tp(s);U_(o,i)}},tdt=(t,e,r,n)=>{r==="output"?U_(t.stdio[n],e):U_(e,t.stdio[n]);let i=rdt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},rdt=["stdin","stdout","stderr"],ndt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;idt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},idt=(t,{signal:e})=>{Bo(t)&&Sp(t,sdt,e)},sdt=2;import{addAbortListener as cdt}from"events";var wp=[];wp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&wp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&wp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eM=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",zY=Symbol.for("signal-exit emitter"),jY=globalThis,odt=Object.defineProperty.bind(Object),qY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(jY[zY])return jY[zY];odt(jY,zY,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},tM=class{},adt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),BY=class extends tM{onExit(){return()=>{}}load(){}unload(){}},GY=class extends tM{#e=VY.platform==="win32"?"SIGINT":"SIGHUP";#r=new qY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of wp)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!eM(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 wp)try{let r=this.#i[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,wp.forEach(e=>{let r=this.#i[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.#s,this.#r.count-=1)}#a(e){return eM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&eM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},VY=globalThis.process,{onExit:Nwe,load:bor,unload:Tor}=adt(eM(VY)?new GY(VY):new BY);var Dwe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Nwe(()=>{t.kill()});cdt(n,()=>{i()})};var $we=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=fD(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=udt(r,n,i),{sourceStream:d,sourceError:f}=ddt(t,u),{options:p,fileDescriptors:h}=qa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},udt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=ldt(t,e,...r),a=bD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},ldt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Mwe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||DK(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[i,s,o]=rD(r,...n);return{destination:e(Mwe)(i,s,o),pipeOptions:o}}if(qa.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}`)},Mwe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ddt=(t,e)=>{try{return{sourceStream:C_(t,e)}}catch(r){return{sourceError:r}}};var Uwe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=fdt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw HY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},fdt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return FY(t),n;if(e!==void 0)return UY(r),e},HY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>M_({error:t,command:Lwe,escapedCommand:Lwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Lwe="source.pipe(destination)";var Fwe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as pdt}from"stream/promises";var zwe=(t,e,r)=>{let n=rM.has(e)?mdt(t,e):hdt(t,e);return Sp(t,_dt,r.signal),Sp(e,ydt,r.signal),gdt(e),n},hdt=(t,e)=>{let r=Tp([t]);return U_(r,e),rM.set(e,r),r},mdt=(t,e)=>{let r=rM.get(e);return r.add(t),r},gdt=async t=>{try{await pdt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rM.delete(t)},rM=new WeakMap,_dt=2,ydt=1;import{aborted as Sdt}from"util";var jwe=(t,e)=>t===void 0?[]:[vdt(t,e)],vdt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Sdt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw HY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var nM=(t,...e)=>{if(yr(e[0]))return nM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$we(t,...e),i=Edt({...n,destination:r});return i.pipe=nM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Edt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=bdt(t,i);Uwe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=zwe(e,s,d);return await Promise.race([Fwe(l),...jwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},bdt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Idt}from"timers/promises";import{on as Tdt}from"events";import{getDefaultHighWaterMark as wdt}from"stream";var iM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Adt(e,o),Bwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Adt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},WY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Rdt(e,o,t);let a=t.readableObjectMode&&!s;return Bwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Rdt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Bwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Tdt(t,"data",{signal:e.signal,highWaterMark:qwe,highWatermark:qwe});return xdt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},KY=wdt(!0),qwe=KY,xdt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Odt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*bp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ww(a)}},Odt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[KD(t,r,!e),WD(t,i,!n,{})].filter(Boolean);var Gwe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Pdt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Cdt(t),d]);return}let f=AY(c,r),p=WY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([kdt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Pdt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!QD({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=WY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await twe(a,t,r,s)},Cdt=async t=>{await Idt(),t.readableFlowing===null&&t.resume()},kdt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await UD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await FD(r,{maxBuffer:s})):await D_(r,{maxBuffer:s})}catch(a){return Vwe(tTe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},YY=async t=>{try{return await t}catch(e){return Vwe(e)}},Vwe=({bufferedData:t})=>_ve(t)?new Uint8Array(t):t;import{finished as Ndt}from"stream/promises";var Qw=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Ddt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Ndt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Ldt(a,e,r,n)}finally{o.abort()}},Ddt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Mdt(t,r,n),n},Mdt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{$dt(e,r),n.call(t,...i)}},$dt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ldt=(t,e,r,n)=>{if(!Udt(t,e,r,n))throw t},Udt=(t,e,r,n=!0)=>r.propagating?Hwe(t)||sM(t):(r.propagating=!0,ZY(r,e)===n?Hwe(t):sM(t)),ZY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Hwe=t=>t?.code==="EPIPE";var Wwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>QY({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),QY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Qw(t,e,u);if(ZY(u,e)){await l;return}let[d]=await Promise.all([Gwe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Kwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Tp([t,e].filter(Boolean)):void 0,Ywe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>QY({...Fdt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:zdt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Fdt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},zdt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as jdt}from"events";var Zwe=t=>R_(t,"ipc"),Qwe=(t,e)=>{let r=dD(t);za({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Jwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Zwe(s),a=tu(e,"ipc"),c=tu(r,"ipc");for await(let u of DY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(rTe(t,i,c),i.push(u)),o&&Qwe(u,s);return i},Xwe=async(t,e)=>(await Promise.allSettled([t]),e);var eAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let w=owe(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:w,propagating:!1},S=Wwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),v=Ywe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),E=[],I=Jwe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=qdt(m,t,x),P=Bdt(h,x);try{return await Promise.race([Promise.all([{},cwe(w),Promise.all(S),v,I,Dbe(t,d),...C,...P]),_,Gdt(t,y),...Ibe(t,s,f,y),...ZEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...xbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},w,Promise.all(S.map(T=>YY(T))),YY(v),Xwe(I,E),Promise.allSettled(C),Promise.allSettled(P)])}},qdt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Qw(n,i,r)),Bdt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ho(s,{checkOpen:!1})&&!Bo(s)).map(({type:i,value:s,stream:o=s})=>Qw(o,n,e,{isSameDirection:Ms.has(i),stopOnExit:i==="native"}))),Gdt=async(t,{signal:e})=>{let[r]=await jdt(t,"error",{signal:e});throw r};var tAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Jw=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ja();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},F_=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 Vdt}from"stream";import{callbackify as Hdt}from"util";import{finished as rAe}from"stream/promises";var JY=async t=>{if(t!==void 0)try{await XY(t)}catch{}},nAe=async t=>{if(t!==void 0)try{await e9(t)}catch{}},XY=async t=>{await rAe(t,{cleanup:!0,readable:!1,writable:!0})},e9=async t=>{await rAe(t,{cleanup:!0,readable:!0,writable:!1})},oM=async(t,e)=>{if(await t,e)throw e},aM=(t,e,r)=>{r&&!sM(r)?t.destroy(r):e&&t.destroy()};var iAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||es.has(r),{subprocessStdout:a,waitReadableDestroy:c}=t9(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=r9(a,o),{read:f,onStdoutDataDone:p}=n9({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new Vdt({read:f,destroy:Hdt(s9.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return i9({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},t9=(t,e,r)=>{let n=C_(t,e),i=Jw(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},r9=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:KY},n9=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ja(),o=iM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Wdt(this,o,s)},onStdoutDataDone:s}},Wdt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},i9=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await e9(t),await n,await JY(i),await e,r.readable&&r.push(null)}catch(s){await JY(i),sAe(r,s)}},s9=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await F_(r,e)&&(sAe(t,n),await oM(e,n))},sAe=(t,e)=>{aM(t,t.readable,e)};import{Writable as Kdt}from"stream";import{callbackify as oAe}from"util";var aAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=o9(t,r,e),o=new Kdt({...a9(n,t,i),destroy:oAe(u9.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return c9(n,o),o},o9=(t,e,r)=>{let n=bD(t,e),i=Jw(r,n,"writableFinal"),s=Jw(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},a9=(t,e,r)=>({write:Ydt.bind(void 0,t),final:oAe(Zdt.bind(void 0,t,e,r))}),Ydt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Zdt=async(t,e,r)=>{await F_(r,e)&&(t.writable&&t.end(),await e)},c9=async(t,e,r)=>{try{await XY(t),e.writable&&e.end()}catch(n){await nAe(r),cAe(e,n)}},u9=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await F_(r,e),await F_(n,e)&&(cAe(t,i),await oM(e,i))},cAe=(t,e)=>{aM(t,t.writable,e)};import{Duplex as Qdt}from"stream";import{callbackify as Jdt}from"util";var uAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||es.has(r),{subprocessStdout:c,waitReadableDestroy:u}=t9(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=o9(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=r9(c,a),{read:_,onStdoutDataDone:y}=n9({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),w=new Qdt({read:_,...a9(l,t,d),destroy:Jdt(Xdt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return i9({subprocessStdout:c,onStdoutDataDone:y,readable:w,subprocess:t,subprocessStdin:l}),c9(l,w,c),w},Xdt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([s9({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),u9({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var l9=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||es.has(e),o=C_(t,r),a=iM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return eft(a,o,t)},eft=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lAe=(t,{encoding:e})=>{let r=tAe();t.readable=iAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=aAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=uAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=l9.bind(void 0,t,e),t[Symbol.asyncIterator]=l9.bind(void 0,t,e,{})};var dAe=(t,e)=>{for(let[r,n]of rft){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},tft=(async()=>{})().constructor.prototype,rft=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(tft,t)]);var fAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=sft(t,e,r),{subprocess:f,promise:p}=aft({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),dAe(f,p),qa.set(f,{options:l,fileDescriptors:d}),f},sft=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pD(t,e,r),{file:a,commandArguments:c,options:u}=ND(t,e,r),l=oft(u),d=Twe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},oft=({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}},aft=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=ift(...DD(t,e,r))}catch(h){return Swe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;nft(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];kwe(c,a,u),Dwe(c,r,u);let d={},f=ja();c.kill=KEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Kwe(c,r),lAe(c,r),gwe(c,r);let p=cft({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},cft=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await eAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,v)=>nu(S,e,v)),w=nu(m,e,"all"),x=uft({errorInfo:d,exitCode:f,signal:p,stdio:y,all:w,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return $_(x,n,e)},uft=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?Hw({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ba,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):qD({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var cM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,lft(n,t[n],i)]));return{...t,...r}},lft=(t,e,r)=>dft.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,dft=new Set(["env",...zK]);var Bl=(t,e,r,n)=>{let i=(o,a,c)=>Bl(o,a,r,c),s=(...o)=>fft({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},fft=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,cM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=pft({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?lwe(a,c,u):fAe(a,c,u,i)},pft=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Tve(e)?wve(e,r):[e,...r],[o,a,c]=rD(...s),u=cM(cM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var pAe=({file:t,commandArguments:e})=>mAe(t,e),hAe=({file:t,commandArguments:e})=>({...mAe(t,e),isSync:!0}),mAe=(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]=hft(t);return{file:r,commandArguments:n}},hft=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(mft)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},mft=/ +/g;var gAe=(t,e,r)=>{t.sync=e(gft,r),t.s=t.sync},_Ae=({options:t})=>yAe(t),gft=({options:t})=>({...yAe(t),isSync:!0}),yAe=t=>({options:{..._ft(t),...t}}),_ft=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},SAe={preferLocal:!0};var vAe=Bl(()=>({})),pur=Bl(()=>({isSync:!0})),EAe=Bl(pAe),hur=Bl(hAe),mur=Bl(Cbe),gur=Bl(_Ae,{},SAe,gAe),{sendMessage:_ur,getOneMessage:yur,getEachMessage:Sur,getCancelSignal:vur}=_we();var bAe=!1,TAe,yft=t=>{TAe??=t},wAe=t=>{bAe=!0,yft(t)},Nn=()=>bAe,iu=()=>TAe,AAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Xw=null,RAe=t=>(Xw&&Xw.destroy(),Xw=new $s({totalAllowedTime:t}),Xw),xAe=()=>Xw;var $s=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Nn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await WC({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{W.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),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 OAe={name:"@netlify/agent-runner-cli",type:"module",version:"2.9.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.5","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var bft=vft(import.meta.url),Tft=su.dirname(bft),wft=Eft(import.meta.url),z_=re("shell"),d9=new Set,IAe={preferLocal:!0},yt=(t,e,r)=>{let[n,i]=Aft(e,r),s={...IAe,...i},o=vAe(t,n,s);CAe(o,s),DAe(o);let a=r?.idleTimeout;return a&&a>0&&NAe(o,a),o},PAe=(t,e)=>{let r={...IAe,...e},n=EAe(t,r);return CAe(n,r),DAe(n),e?.idleTimeout&&e.idleTimeout>0&&NAe(n,e.idleTimeout),n},Aft=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},CAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Va.env.NETLIFY_LOCAL_QUIET==="true")return;if(Va.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Fb).pipe(Va.stdout),t.stderr?.pipe(new Fb).pipe(Va.stderr);return}t.stdout?.pipe(Va.stdout),t.stderr?.pipe(Va.stderr)},f9=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Va.kill(-t.pid,e),z_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return z_.error("Error killing process:",r),!1}},kAe=t=>f9(t,"SIGKILL"),NAe=(t,e)=>{let r=null,n=()=>{z_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),f9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing idle process ${t.pid}`),kAe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},DAe=t=>{d9.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{z_.log(`Global timer expired, killing process ${t.pid}`),f9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing process ${t.pid} after timeout`),kAe(t))},5e3)});t.on("exit",()=>{d9.delete(t),r()}),t.on("error",()=>{d9.delete(t),r()})}};function Ha(t,e){if(!Va.env.NETLIFY_LOCAL_MODE)try{let i=wft.resolve(OAe.name),s=su.dirname(i);for(;s!==su.dirname(s);){let o=su.dirname(s);if(su.basename(o)==="node_modules"){let a=su.join(o,".bin",e);if(uM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Va.env.NODE_PATH){let i=su.join(Va.env.NODE_PATH,".bin",e);if(uM.existsSync(i))return i}let r=su.join(t,"node_modules",".bin",e);if(uM.existsSync(r))return r;let n=su.join(Tft,"..","node_modules",".bin",e);if(uM.existsSync(n))return n}var j_=re("repo"),jAe="runner-diffs-",p9=t=>`${jAe}${t}-`,qAe=async t=>{let e=dM.tmpdir(),r;try{r=await ni.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(jAe)&&!n.startsWith(p9(t))).map(n=>ni.rm(Ls.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},MAe=async t=>{let e=Rft("sha256");for await(let r of xft(t))e.update(r);return e.digest("hex")},$Ae=async(t,e)=>t.size===e.size&&await MAe(t.path)===await MAe(e.path),BAe=/.. (.+)?\.log$/,Oft=[BAe],Ift=1,LAe=t=>{let e=t.split(`
|
|
388
388
|
`).reduce((r,n)=>{if(!n)return r;let[i,s,,...o]=n,a=o.join(""),c=i.trim(),u=s.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},Pft=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),UAe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return _n(r?`${e}: ${r}`:e)},Cft=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),FAe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),kft=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&FAe(n)===FAe(r)&&n.password!==""}catch{return!1}},zAe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},lM=500,eA=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Ii=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),s=new Set(n.changedFiles),o=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!s.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),o.length>0&&await ni.writeFile(await this.getSetupMetadataPath(),JSON.stringify(o)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new eA(r,n)}}run(e,r={}){return yt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){j_.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!r){let u=LAe(s);await this.discardSetupOnlyChanges(u)}j_.info("Changes after processing"),await this.getStatus();let o=await this.getIgnoredPathspecs(s);if(await this.stageFiles(o),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:o};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await ni.mkdtemp(Ls.join(dM.tmpdir(),p9(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:o});return await this.rollbackIfLocal(),c.hasChanges&&W.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
389
389
|
`).filter(i=>Oft.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await ni.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
390
390
|
`)})}async stageBuildSetup(){await ni.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return Ls.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=lM){let s=e.slice(i,i+lM).map(a=>`:(literal)${a}`),{stdout:o}=await this.run(["ls-files","--stage","-z","--",...s],{...zAe,...r});for(let a of String(o??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await ni.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},s=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),o=r.filter(({filePath:a,entry:c})=>s.get(a)===c);o.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:o.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();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 e.split(`
|
package/package.json
CHANGED