@netlify/agent-runner-cli 1.194.1 → 1.194.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +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
|
@@ -143,7 +143,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
143
143
|
`,LF:`
|
|
144
144
|
`,concatBytes:ZU},jVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},BVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:jVe};import{Buffer as qVe}from"buffer";var ece=(t,e)=>t?void 0:GVe.bind(void 0,e),GVe=function*(t,e){if(typeof e!="string"&&!mr(e)&&!qVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},tce=(t,e)=>t?VVe.bind(void 0,e):HVe.bind(void 0,e),VVe=function*(t,e){rce(t,e),yield e},HVe=function*(t,e){if(rce(t,e),typeof e!="string"&&!mr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},rce=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
145
145
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
146
|
-
if (condition) { yield value; }`)};import{Buffer as WVe}from"buffer";import{StringDecoder as YVe}from"string_decoder";var FR=(t,e,r)=>{if(r)return;if(t)return{transform:KVe.bind(void 0,new TextEncoder)};let n=new YVe(e);return{transform:ZVe.bind(void 0,n),final:JVe.bind(void 0,n)}},KVe=function*(t,e){WVe.isBuffer(e)?yield Sa(e):typeof e=="string"?yield t.encode(e):yield e},ZVe=function*(t,e){yield mr(e)?t.write(e):e},JVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as nce}from"util";var XU=nce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),zR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QVe}=e[r];for await(let i of n(t))yield*zR(i,e,r+1)},ice=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XVe(r,Number(e),t)},XVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*zR(n,r,e+1)},oce=nce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QVe=function*(t){yield t};var QU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},sce=(t,e)=>[...e.flatMap(r=>[...Wu(r,t,0)]),...tS(t)],Wu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=t4e}=e[r];for(let i of n(t))yield*Wu(i,e,r+1)},tS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*e4e(r,Number(e),t)},e4e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Wu(n,r,e+1)},t4e=function*(t){yield t};var eF=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=cce(t,s,o),l=Hu(e),u=Hu(r),d=l?XU.bind(void 0,zR,a):QU.bind(void 0,Wu),f=l||u?XU.bind(void 0,ice,a):QU.bind(void 0,tS),p=l||u?oce.bind(void 0,a):void 0;return{stream:new r4e({writableObjectMode:n,writableHighWaterMark:ace(n),readableObjectMode:i,readableHighWaterMark:ace(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},jR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=cce(s,r,a);t=sce(c,t)}return t},cce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ece(n,a)},FR(r,s,n),UR(r,o,n,c),{transform:t,final:e},{transform:tce(i,a)},Qae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var lce=(t,e)=>{for(let r of n4e(t))i4e(t,r,e)},n4e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),i4e=(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 ${jc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>o4e(a,n));r.input=Vy(s)},o4e=(t,e)=>{let r=jR(t,e,"utf8",!0);return s4e(r),Vy(r)},s4e=t=>{let e=t.find(r=>typeof r!="string"&&!mr(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 u4e,appendFileSync as d4e}from"fs";var BR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Fp(r,n)&&!ai.has(e)&&a4e(n)&&(t.some(({type:i,value:o})=>i==="native"&&c4e.has(o))||t.every(({type:i})=>Fi.has(i))),a4e=t=>t===1||t===2,c4e=new Set(["pipe","overlapped"]),uce=async(t,e,r,n)=>{for await(let i of t)l4e(e)||fce(i,r,n)},dce=(t,e,r)=>{for(let n of t)fce(n,e,r)},l4e=t=>t._readableState.pipes.length>0,fce=(t,e,r)=>{let n=rR(t);ms({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var pce=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>f4e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},f4e=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=hae(t,o,d),p=Sa(f),{stdioItems:h,objectMode:m}=e[r],g=p4e([p],h,c,n),{serializedResult:_,finalResult:y=_}=h4e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});m4e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?y:void 0;try{return n.error===void 0&&g4e(_,h,i),w}catch(v){return n.error=v,w}},p4e=(t,e,r,n)=>{try{return jR(t,e,r,!1)}catch(i){return n.error=i,t}},h4e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Vy(t)};let s=Cie(t,r);return n[o]?{serializedResult:s,finalResult:JU(s,!i[o],e)}:{serializedResult:s}},m4e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!BR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JU(t,!1,s);try{dce(a,e,n)}catch(c){r.error??=c}},g4e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>$R.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?d4e(n,t):(r.add(o),u4e(n,t))}};var hce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ta(e,r,"all")]:Array.isArray(e)?[Ta(t,r,"all"),...e]:mr(t)&&mr(e)?sU([t,e]):`${t}${e}`};import{once as tF}from"events";var mce=async(t,e)=>{let[r,n]=await _4e(t);return e.isForcefullyTerminated??=!1,[r,n]},_4e=async t=>{let[e,r]=await Promise.allSettled([tF(t,"spawn"),tF(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?gce(t):r.value},gce=async t=>{try{return await tF(t,"exit")}catch{return gce(t)}},_ce=async t=>{let[e,r]=await t;if(!y4e(e,r)&&rF(e,r))throw new To;return[e,r]},y4e=(t,e)=>t===void 0&&e===void 0,rF=(t,e)=>t!==0||e!==null;var yce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=S4e(t,e,r),s=o?.code==="ETIMEDOUT",a=pae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},S4e=(t,e,r)=>t!==void 0?t:rF(e,r)?new To:void 0;var Sce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=v4e(t,e,r),d=w4e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Kp(d,c,l)},v4e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=iR(t,e,r),a=T4e(r),{file:c,commandArguments:l,options:u}=wR(t,e,a);b4e(u);let d=Kae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},T4e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,b4e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&qR("ipcInput"),t&&qR("ipc: true"),r&&qR("detached: true"),n&&qR("cancelSignal")},qR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},w4e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=A4e({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=yce(c,r),{output:h,error:m=l}=pce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((y,w)=>Ta(y,r,w)),_=Ta(hce(h,r),r,"all");return R4e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},A4e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{lce(o,r);let a=x4e(r);return E4e(...AR(t,e,a))}catch(a){return Yp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},x4e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:NR(e)}),R4e=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?kR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):eS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as h6e}from"events";import{spawn as m6e}from"child_process";import wce from"process";import{once as nF,on as C4e}from"events";var Ece=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Bp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:yR(t)}),I4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),I4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{hR(e,i);let o=zc(t,e,r),s=new AbortController;try{return await Promise.race([P4e(o,n,s),O4e(o,r,s),N4e(o,r,s)])}catch(a){throw qp(t),a}finally{s.abort(),mR(e,i)}},P4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await nF(t,"message",{signal:r});return n}for await(let[n]of C4e(t,"message",{signal:r}))if(e(n))return n},O4e=async(t,e,{signal:r})=>{await nF(t,"disconnect",{signal:r}),sse(e)},N4e=async(t,e,{signal:r})=>{let[n]=await nF(t,"strict:error",{signal:r});throw dR(n,e)};import{once as Tce,on as k4e}from"events";var bce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>iF({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),iF=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Bp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:yR(t)}),hR(e,o);let s=zc(t,e,r),a=new AbortController,c={};return M4e(t,s,a),D4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),$4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},M4e=async(t,e,r)=>{try{await Tce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},D4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Tce(t,"strict:error",{signal:r.signal});n.error=dR(i,e),r.abort()}catch{}},$4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of k4e(r,"message",{signal:o.signal}))vce(s),yield c}catch{vce(s)}finally{o.abort(),mR(e,a),n||qp(t),i&&await t}},vce=({error:t})=>{if(t)throw t};var Ace=(t,{ipc:e})=>{Object.assign(t,Rce(t,!1,e))},xce=()=>{let t=wce,e=!0,r=wce.channel!==void 0;return{...Rce(t,e,r),getCancelSignal:kse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Rce=(t,e,r)=>({sendMessage:TR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:bce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as L4e}from"child_process";import{PassThrough as U4e,Readable as F4e,Writable as z4e,Duplex as j4e}from"stream";var Cce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{YU(n);let a=new L4e;B4e(a,n),Object.assign(a,{readable:q4e,writable:G4e,duplex:V4e});let c=Yp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=H4e(c,s,i);return{subprocess:a,promise:l}},B4e=(t,e)=>{let r=rS(),n=rS(),i=rS(),o=Array.from({length:e.length-3},rS),s=rS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},rS=()=>{let t=new U4e;return t.end(),t},q4e=()=>new F4e({read(){}}),G4e=()=>new z4e({write(){}}),V4e=()=>new j4e({read(){},write(){}}),H4e=async(t,e,r)=>Kp(t,e,r);import{createReadStream as Ice,createWriteStream as Pce}from"fs";import{Buffer as W4e}from"buffer";import{Readable as nS,Writable as Y4e,Duplex as K4e}from"stream";var Nce=(t,e)=>LR(Z4e,t,e,!1),iS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${jc[t]}.`)},Oce={fileNumber:iS,generator:eF,asyncGenerator:eF,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:K4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Z4e={input:{...Oce,fileUrl:({value:t})=>({stream:Ice(t)}),filePath:({value:{file:t}})=>({stream:Ice(t)}),webStream:({value:t})=>({stream:nS.fromWeb(t)}),iterable:({value:t})=>({stream:nS.from(t)}),asyncIterable:({value:t})=>({stream:nS.from(t)}),string:({value:t})=>({stream:nS.from(t)}),uint8Array:({value:t})=>({stream:nS.from(W4e.from(t))})},output:{...Oce,fileUrl:({value:t})=>({stream:Pce(t)}),filePath:({value:{file:t,append:e}})=>({stream:Pce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Y4e.fromWeb(t)}),iterable:iS,asyncIterable:iS,string:iS,uint8Array:iS}};import{on as J4e,once as kce}from"events";import{PassThrough as X4e,getDefaultHighWaterMark as Q4e}from"stream";import{finished as $ce}from"stream/promises";function Yu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)sF(i);let e=t.some(({readableObjectMode:i})=>i),r=eHe(t,e),n=new oF({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var eHe=(t,e)=>{if(t.length===0)return Q4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},oF=class extends X4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(sF(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tHe(this,this.#e,this.#o);let r=iHe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(sF(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)}},tHe=async(t,e,r)=>{GR(t,Mce);let n=new AbortController;try{await Promise.race([rHe(t,n),nHe(t,e,r,n)])}finally{n.abort(),GR(t,-Mce)}},rHe=async(t,{signal:e})=>{try{await $ce(t,{signal:e,cleanup:!0})}catch(r){throw Lce(t,r),r}},nHe=async(t,e,r,{signal:n})=>{for await(let[i]of J4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},sF=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{GR(t,Dce);let a=new AbortController;try{await Promise.race([oHe(o,e,a),sHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),aHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),GR(t,-Dce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?aF(t):cHe(t))},oHe=async(t,e,{signal:r})=>{try{await t,r.aborted||aF(e)}catch(n){r.aborted||Lce(e,n)}},sHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await $ce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Uce(s)?i.add(e):Fce(t,s)}},aHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await kce(t,i,{signal:o}),!t.readable)return kce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},cHe=t=>{t.writable&&t.end()},Lce=(t,e)=>{Uce(e)?aF(t):Fce(t,e)},Uce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",aF=t=>{(t.readable||t.writable)&&t.destroy()},Fce=(t,e)=>{t.destroyed||(t.once("error",lHe),t.destroy(e))},lHe=()=>{},GR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Mce=2,Dce=1;import{finished as zce}from"stream/promises";var Jp=(t,e)=>{t.pipe(e),uHe(t,e),dHe(t,e)},uHe=async(t,e)=>{if(!(vo(t)||vo(e))){try{await zce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}cF(e)}},cF=t=>{t.writable&&t.end()},dHe=async(t,e)=>{if(!(vo(t)||vo(e))){try{await zce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}lF(t)}},lF=t=>{t.readable&&t.destroy()};var jce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Fi.has(c)))fHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Fi.has(c)))hHe({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Yu(o);Jp(s,i)}},fHe=(t,e,r,n)=>{r==="output"?Jp(t.stdio[n],e):Jp(e,t.stdio[n]);let i=pHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pHe=["stdin","stdout","stderr"],hHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;mHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},mHe=(t,{signal:e})=>{vo(t)&&Gu(t,gHe,e)},gHe=2;import{addAbortListener as SHe}from"events";var Ku=[];Ku.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ku.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ku.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var VR=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",uF=Symbol.for("signal-exit emitter"),dF=globalThis,_He=Object.defineProperty.bind(Object),fF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(dF[uF])return dF[uF];_He(dF,uF,{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 o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},HR=class{},yHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),pF=class extends HR{onExit(){return()=>{}}load(){}unload(){}},hF=class extends HR{#e=mF.platform==="win32"?"SIGINT":"SIGHUP";#r=new fF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ku)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!VR(this.#t))return()=>{};this.#s===!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.#s){this.#s=!0,this.#r.count+=1;for(let e of Ku)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.#s&&(this.#s=!1,Ku.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.#o,this.#r.count-=1)}#a(e){return VR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&VR(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)}},mF=globalThis.process,{onExit:Bce,load:EUt,unload:vUt}=yHe(VR(mF)?new hF(mF):new pF);var qce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Bce(()=>{t.kill()});SHe(n,()=>{i()})};var Vce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=nR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=EHe(r,n,i),{sourceStream:d,sourceError:f}=THe(t,l),{options:p,fileDescriptors:h}=_s.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},EHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=vHe(t,e,...r),a=pR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},vHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Gce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||iU(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,o,s]=Wx(r,...n);return{destination:e(Gce)(i,o,s),pipeOptions:s}}if(_s.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}`)},Gce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),THe=(t,e)=>{try{return{sourceStream:Gp(t,e)}}catch(r){return{sourceError:r}}};var Wce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=bHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw gF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},bHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return lF(t),n;if(e!==void 0)return cF(r),e},gF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yp({error:t,command:Hce,escapedCommand:Hce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Hce="source.pipe(destination)";var Yce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as wHe}from"stream/promises";var Kce=(t,e,r)=>{let n=WR.has(e)?xHe(t,e):AHe(t,e);return Gu(t,CHe,r.signal),Gu(e,IHe,r.signal),RHe(e),n},AHe=(t,e)=>{let r=Yu([t]);return Jp(r,e),WR.set(e,r),r},xHe=(t,e)=>{let r=WR.get(e);return r.add(t),r},RHe=async t=>{try{await wHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}WR.delete(t)},WR=new WeakMap,CHe=2,IHe=1;import{aborted as PHe}from"util";var Zce=(t,e)=>t===void 0?[]:[OHe(t,e)],OHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await PHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw gF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var YR=(t,...e)=>{if(Xt(e[0]))return YR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Vce(t,...e),i=NHe({...n,destination:r});return i.pipe=YR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=kHe(t,i);Wce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Kce(e,o,d);return await Promise.race([Yce(u),...Zce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},kHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as zHe}from"timers/promises";import{on as MHe}from"events";import{getDefaultHighWaterMark as DHe}from"stream";var KR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return $He(e,s),Xce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},$He=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_F=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;LHe(e,s,t);let a=t.readableObjectMode&&!o;return Xce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Xce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=MHe(t,"data",{signal:e.signal,highWaterMark:Jce,highWatermark:Jce});return UHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},yF=DHe(!0),Jce=yF,UHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=FHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Wu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*tS(a)}},FHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[FR(t,r,!e),UR(t,i,!n,{})].filter(Boolean);var Qce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=jHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([BHe(t),d]);return}let f=KU(c,r),p=_F({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([qHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},jHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!BR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=_F({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await uce(a,t,r,o)},BHe=async t=>{await zHe(),t.readableFlowing===null&&t.resume()},qHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await IR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await PR(r,{maxBuffer:o})):await Wp(r,{maxBuffer:o})}catch(a){return ele(uae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},SF=async t=>{try{return await t}catch(e){return ele(e)}},ele=({bufferedData:t})=>xie(t)?new Uint8Array(t):t;import{finished as GHe}from"stream/promises";var oS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=VHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||YHe(a,e,r,n)}finally{s.abort()}},VHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&HHe(t,r,n),n},HHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{WHe(e,r),n.call(t,...i)}},WHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YHe=(t,e,r,n)=>{if(!KHe(t,e,r,n))throw t},KHe=(t,e,r,n=!0)=>r.propagating?tle(t)||ZR(t):(r.propagating=!0,EF(r,e)===n?tle(t):ZR(t)),EF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ZR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",tle=t=>t?.code==="EPIPE";var rle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>vF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),vF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=oS(t,e,l);if(EF(l,e)){await u;return}let[d]=await Promise.all([Qce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var nle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Yu([t,e].filter(Boolean)):void 0,ile=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>vF({...ZHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:JHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),ZHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},JHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as XHe}from"events";var ole=t=>Fp(t,"ipc"),sle=(t,e)=>{let r=rR(t);ms({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ale=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=ole(o),a=Ea(e,"ipc"),c=Ea(r,"ipc");for await(let l of iF({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(dae(t,i,c),i.push(l)),s&&sle(l,o);return i},cle=async(t,e)=>(await Promise.allSettled([t]),e);var lle=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let y=mce(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:y,propagating:!1},v=rle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),S=ile({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],R=ale({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),O=QHe(m,t,w),I=e6e(h,w);try{return await Promise.race([Promise.all([{},_ce(y),Promise.all(v),S,R,qse(t,d),...O,...I]),g,t6e(t,_),...Use(t,o,f,_),...ose({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...$se({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},y,Promise.all(v.map(b=>SF(b))),SF(S),cle(R,A),Promise.allSettled(O),Promise.allSettled(I)])}},QHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:oS(n,i,r)),e6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>wo(o,{checkOpen:!1})&&!vo(o)).map(({type:i,value:o,stream:s=o})=>oS(s,n,e,{isSameDirection:Fi.has(i),stopOnExit:i==="native"}))),t6e=async(t,{signal:e})=>{let[r]=await XHe(t,"error",{signal:e});throw r};var ule=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),sS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=gs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Xp=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 r6e}from"stream";import{callbackify as n6e}from"util";import{finished as dle}from"stream/promises";var TF=async t=>{if(t!==void 0)try{await bF(t)}catch{}},fle=async t=>{if(t!==void 0)try{await wF(t)}catch{}},bF=async t=>{await dle(t,{cleanup:!0,readable:!1,writable:!0})},wF=async t=>{await dle(t,{cleanup:!0,readable:!0,writable:!1})},JR=async(t,e)=>{if(await t,e)throw e},XR=(t,e,r)=>{r&&!ZR(r)?t.destroy(r):e&&t.destroy()};var ple=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ai.has(r),{subprocessStdout:a,waitReadableDestroy:c}=AF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=xF(a,s),{read:f,onStdoutDataDone:p}=RF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new r6e({read:f,destroy:n6e(IF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return CF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},AF=(t,e,r)=>{let n=Gp(t,e),i=sS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},xF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:yF},RF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=gs(),s=KR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){i6e(this,s,o)},onStdoutDataDone:o}},i6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},CF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await wF(t),await n,await TF(i),await e,r.readable&&r.push(null)}catch(o){await TF(i),hle(r,o)}},IF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Xp(r,e)&&(hle(t,n),await JR(e,n))},hle=(t,e)=>{XR(t,t.readable,e)};import{Writable as o6e}from"stream";import{callbackify as mle}from"util";var gle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=PF(t,r,e),s=new o6e({...OF(n,t,i),destroy:mle(kF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return NF(n,s),s},PF=(t,e,r)=>{let n=pR(t,e),i=sS(r,n,"writableFinal"),o=sS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},OF=(t,e,r)=>({write:s6e.bind(void 0,t),final:mle(a6e.bind(void 0,t,e,r))}),s6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},a6e=async(t,e,r)=>{await Xp(r,e)&&(t.writable&&t.end(),await e)},NF=async(t,e,r)=>{try{await bF(t),e.writable&&e.end()}catch(n){await fle(r),_le(e,n)}},kF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Xp(r,e),await Xp(n,e)&&(_le(t,i),await JR(e,i))},_le=(t,e)=>{XR(t,t.writable,e)};import{Duplex as c6e}from"stream";import{callbackify as l6e}from"util";var yle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ai.has(r),{subprocessStdout:c,waitReadableDestroy:l}=AF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=PF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=xF(c,a),{read:g,onStdoutDataDone:_}=RF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),y=new c6e({read:g,...OF(u,t,d),destroy:l6e(u6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return CF({subprocessStdout:c,onStdoutDataDone:_,readable:y,subprocess:t,subprocessStdin:u}),NF(u,y,c),y},u6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([IF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),kF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var MF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ai.has(e),s=Gp(t,r),a=KR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return d6e(a,s,t)},d6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Sle=(t,{encoding:e})=>{let r=ule();t.readable=ple.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=gle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=yle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=MF.bind(void 0,t,e),t[Symbol.asyncIterator]=MF.bind(void 0,t,e,{})};var Ele=(t,e)=>{for(let[r,n]of p6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},f6e=(async()=>{})().constructor.prototype,p6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(f6e,t)]);var vle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=g6e(t,e,r),{subprocess:f,promise:p}=y6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=YR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Ele(f,p),_s.set(f,{options:u,fileDescriptors:d}),f},g6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=iR(t,e,r),{file:a,commandArguments:c,options:l}=wR(t,e,r),u=_6e(l),d=Nce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},_6e=({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}},y6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=m6e(...AR(t,e,r))}catch(h){return Cce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;h6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];jce(c,a,l),qce(c,r,l);let d={},f=gs();c.kill=nse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=nle(c,r),Sle(c,r),Ace(c,r);let p=S6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},S6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await lle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,S)=>Ta(v,e,S)),y=Ta(m,e,"all"),w=E6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:y,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Kp(w,n,e)},E6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?eS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ys,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):kR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var QR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,v6e(n,t[n],i)]));return{...t,...r}},v6e=(t,e,r)=>T6e.has(t)&&Xt(e)&&Xt(r)?{...e,...r}:r,T6e=new Set(["env",...uU]);var Bc=(t,e,r,n)=>{let i=(s,a,c)=>Bc(s,a,r,c),o=(...s)=>b6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},b6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Xt(o))return i(t,QR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=w6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Sce(a,c,l):vle(a,c,l,i)},w6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Nie(e)?kie(e,r):[e,...r],[s,a,c]=Wx(...o),l=QR(QR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Tle=({file:t,commandArguments:e})=>wle(t,e),ble=({file:t,commandArguments:e})=>({...wle(t,e),isSync:!0}),wle=(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]=A6e(t);return{file:r,commandArguments:n}},A6e=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(x6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},x6e=/ +/g;var Ale=(t,e,r)=>{t.sync=e(R6e,r),t.s=t.sync},xle=({options:t})=>Rle(t),R6e=({options:t})=>({...Rle(t),isSync:!0}),Rle=t=>({options:{...C6e(t),...t}}),C6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Cle={preferLocal:!0};var Ile=Bc(()=>({})),ujt=Bc(()=>({isSync:!0})),Ple=Bc(Tle),djt=Bc(ble),fjt=Bc(zse),pjt=Bc(xle,{},Cle,Ale),{sendMessage:hjt,getOneMessage:mjt,getEachMessage:gjt,getCancelSignal:_jt}=xce();var Ole=!1,Nle,I6e=t=>{Nle??=t},kle=t=>{Ole=!0,I6e(t)},ci=()=>Ole,qc=()=>Nle,Mle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var aS=null,Dle=t=>(aS&&aS.destroy(),aS=new zi({totalAllowedTime:t}),aS),$le=()=>aS;var zi=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&&ci())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await $x({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{G.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};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 Lle={name:"@netlify/agent-runner-cli",type:"module",version:"1.194.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"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.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.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var k6e=O6e(import.meta.url),M6e=ba.dirname(k6e),D6e=N6e(import.meta.url),Qp=ne("shell"),DF=new Set,Ule={preferLocal:!0},It=(t,e,r)=>{let[n,i]=$6e(e,r),o={...Ule,...i},s=Ile(t,n,o);zle(s,o),qle(s);let a=r?.idleTimeout;return a&&a>0&&Ble(s,a),s},Fle=(t,e)=>{let r={...Ule,...e},n=Ple(t,r);return zle(n,r),qle(n),e?.idleTimeout&&e.idleTimeout>0&&Ble(n,e.idleTimeout),n},$6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Es.env.NETLIFY_LOCAL_QUIET==="true")return;if(Es.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Dy).pipe(Es.stdout),t.stderr?.pipe(new Dy).pipe(Es.stderr);return}t.stdout?.pipe(Es.stdout),t.stderr?.pipe(Es.stderr)},$F=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Es.kill(-t.pid,e),Qp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Qp.error("Error killing process:",r),!1}},jle=t=>$F(t,"SIGKILL"),Ble=(t,e)=>{let r=null,n=()=>{Qp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),$F(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qp.log(`Force killing idle process ${t.pid}`),jle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},qle=t=>{DF.add(t);let e=$le();if(e){let r=e.onTimesUp(()=>{Qp.log(`Global timer expired, killing process ${t.pid}`),$F(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qp.log(`Force killing process ${t.pid} after timeout`),jle(t))},5e3)});t.on("exit",()=>{DF.delete(t),r()}),t.on("error",()=>{DF.delete(t),r()})}};function tC(t,e){return!!Ao(t,e)}function Ao(t,e){if(!Es.env.NETLIFY_LOCAL_MODE)try{let i=D6e.resolve(Lle.name),o=ba.dirname(i);for(;o!==ba.dirname(o);){let s=ba.dirname(o);if(ba.basename(s)==="node_modules"){let a=ba.join(s,".bin",e);if(eC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Es.env.NODE_PATH){let i=ba.join(Es.env.NODE_PATH,".bin",e);if(eC.existsSync(i))return i}let r=ba.join(t,"node_modules",".bin",e);if(eC.existsSync(r))return r;let n=ba.join(M6e,"..","node_modules",".bin",e);if(eC.existsSync(n))return n}var Gle=ne("repo"),Yle="runner-diffs-",iC=t=>`${Yle}${t}-`,Kle=async t=>{let e=Wle.tmpdir(),r;try{r=await rC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Yle)&&!n.startsWith(iC(t))).map(n=>rC.rm(nC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Qt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),oC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Gle.info("Getting runner diffs");let n=await zF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=jF(o);await G6e(l,r)}Gle.info("Changes after processing"),await FF(r);let s=await lS(o,r);if(await UF(s,r),i=await j6e(r),!i)return{hasChanges:!1,ignored:s};await Qt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await rC.mkdtemp(nC.join(Wle.tmpdir(),iC(t.sessionId))),c=await LF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await F6e(r),c.hasChanges&&G.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},LF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=nC.join(e,h);await Qt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:y}=await rC.stat(g);return{path:g,size:y}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Hle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Hle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Vle=async t=>{let e=L6e("sha256");for await(let r of U6e(t))e.update(r);return e.digest("hex")},Hle=async(t,e)=>t.size===e.size&&await Vle(t.path)===await Vle(e.path),F6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qt(["reset","--soft","HEAD~1"],{cwd:t})},UF=async(t=[],e=process.cwd())=>{await Qt(["add",".",...t],{cwd:e})},FF=async(t=process.cwd())=>{let e=await Qt(["status","-s"],{cwd:t});return String(e.stdout??"")},Zle=/.. (.+)?\.log$/,z6e=[Zle],zF=async(t=process.cwd())=>{let e=await FF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
|
+
if (condition) { yield value; }`)};import{Buffer as WVe}from"buffer";import{StringDecoder as YVe}from"string_decoder";var FR=(t,e,r)=>{if(r)return;if(t)return{transform:KVe.bind(void 0,new TextEncoder)};let n=new YVe(e);return{transform:ZVe.bind(void 0,n),final:JVe.bind(void 0,n)}},KVe=function*(t,e){WVe.isBuffer(e)?yield Sa(e):typeof e=="string"?yield t.encode(e):yield e},ZVe=function*(t,e){yield mr(e)?t.write(e):e},JVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as nce}from"util";var XU=nce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),zR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QVe}=e[r];for await(let i of n(t))yield*zR(i,e,r+1)},ice=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XVe(r,Number(e),t)},XVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*zR(n,r,e+1)},oce=nce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QVe=function*(t){yield t};var QU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},sce=(t,e)=>[...e.flatMap(r=>[...Wu(r,t,0)]),...tS(t)],Wu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=t4e}=e[r];for(let i of n(t))yield*Wu(i,e,r+1)},tS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*e4e(r,Number(e),t)},e4e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Wu(n,r,e+1)},t4e=function*(t){yield t};var eF=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=cce(t,s,o),l=Hu(e),u=Hu(r),d=l?XU.bind(void 0,zR,a):QU.bind(void 0,Wu),f=l||u?XU.bind(void 0,ice,a):QU.bind(void 0,tS),p=l||u?oce.bind(void 0,a):void 0;return{stream:new r4e({writableObjectMode:n,writableHighWaterMark:ace(n),readableObjectMode:i,readableHighWaterMark:ace(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},jR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=cce(s,r,a);t=sce(c,t)}return t},cce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ece(n,a)},FR(r,s,n),UR(r,o,n,c),{transform:t,final:e},{transform:tce(i,a)},Qae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var lce=(t,e)=>{for(let r of n4e(t))i4e(t,r,e)},n4e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),i4e=(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 ${jc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>o4e(a,n));r.input=Vy(s)},o4e=(t,e)=>{let r=jR(t,e,"utf8",!0);return s4e(r),Vy(r)},s4e=t=>{let e=t.find(r=>typeof r!="string"&&!mr(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 u4e,appendFileSync as d4e}from"fs";var BR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Fp(r,n)&&!ai.has(e)&&a4e(n)&&(t.some(({type:i,value:o})=>i==="native"&&c4e.has(o))||t.every(({type:i})=>Fi.has(i))),a4e=t=>t===1||t===2,c4e=new Set(["pipe","overlapped"]),uce=async(t,e,r,n)=>{for await(let i of t)l4e(e)||fce(i,r,n)},dce=(t,e,r)=>{for(let n of t)fce(n,e,r)},l4e=t=>t._readableState.pipes.length>0,fce=(t,e,r)=>{let n=rR(t);ms({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var pce=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>f4e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},f4e=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=hae(t,o,d),p=Sa(f),{stdioItems:h,objectMode:m}=e[r],g=p4e([p],h,c,n),{serializedResult:_,finalResult:y=_}=h4e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});m4e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?y:void 0;try{return n.error===void 0&&g4e(_,h,i),w}catch(v){return n.error=v,w}},p4e=(t,e,r,n)=>{try{return jR(t,e,r,!1)}catch(i){return n.error=i,t}},h4e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Vy(t)};let s=Cie(t,r);return n[o]?{serializedResult:s,finalResult:JU(s,!i[o],e)}:{serializedResult:s}},m4e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!BR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JU(t,!1,s);try{dce(a,e,n)}catch(c){r.error??=c}},g4e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>$R.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?d4e(n,t):(r.add(o),u4e(n,t))}};var hce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ta(e,r,"all")]:Array.isArray(e)?[Ta(t,r,"all"),...e]:mr(t)&&mr(e)?sU([t,e]):`${t}${e}`};import{once as tF}from"events";var mce=async(t,e)=>{let[r,n]=await _4e(t);return e.isForcefullyTerminated??=!1,[r,n]},_4e=async t=>{let[e,r]=await Promise.allSettled([tF(t,"spawn"),tF(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?gce(t):r.value},gce=async t=>{try{return await tF(t,"exit")}catch{return gce(t)}},_ce=async t=>{let[e,r]=await t;if(!y4e(e,r)&&rF(e,r))throw new To;return[e,r]},y4e=(t,e)=>t===void 0&&e===void 0,rF=(t,e)=>t!==0||e!==null;var yce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=S4e(t,e,r),s=o?.code==="ETIMEDOUT",a=pae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},S4e=(t,e,r)=>t!==void 0?t:rF(e,r)?new To:void 0;var Sce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=v4e(t,e,r),d=w4e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Kp(d,c,l)},v4e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=iR(t,e,r),a=T4e(r),{file:c,commandArguments:l,options:u}=wR(t,e,a);b4e(u);let d=Kae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},T4e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,b4e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&qR("ipcInput"),t&&qR("ipc: true"),r&&qR("detached: true"),n&&qR("cancelSignal")},qR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},w4e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=A4e({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=yce(c,r),{output:h,error:m=l}=pce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((y,w)=>Ta(y,r,w)),_=Ta(hce(h,r),r,"all");return R4e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},A4e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{lce(o,r);let a=x4e(r);return E4e(...AR(t,e,a))}catch(a){return Yp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},x4e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:NR(e)}),R4e=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?kR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):eS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as h6e}from"events";import{spawn as m6e}from"child_process";import wce from"process";import{once as nF,on as C4e}from"events";var Ece=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Bp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:yR(t)}),I4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),I4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{hR(e,i);let o=zc(t,e,r),s=new AbortController;try{return await Promise.race([P4e(o,n,s),O4e(o,r,s),N4e(o,r,s)])}catch(a){throw qp(t),a}finally{s.abort(),mR(e,i)}},P4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await nF(t,"message",{signal:r});return n}for await(let[n]of C4e(t,"message",{signal:r}))if(e(n))return n},O4e=async(t,e,{signal:r})=>{await nF(t,"disconnect",{signal:r}),sse(e)},N4e=async(t,e,{signal:r})=>{let[n]=await nF(t,"strict:error",{signal:r});throw dR(n,e)};import{once as Tce,on as k4e}from"events";var bce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>iF({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),iF=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Bp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:yR(t)}),hR(e,o);let s=zc(t,e,r),a=new AbortController,c={};return M4e(t,s,a),D4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),$4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},M4e=async(t,e,r)=>{try{await Tce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},D4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Tce(t,"strict:error",{signal:r.signal});n.error=dR(i,e),r.abort()}catch{}},$4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of k4e(r,"message",{signal:o.signal}))vce(s),yield c}catch{vce(s)}finally{o.abort(),mR(e,a),n||qp(t),i&&await t}},vce=({error:t})=>{if(t)throw t};var Ace=(t,{ipc:e})=>{Object.assign(t,Rce(t,!1,e))},xce=()=>{let t=wce,e=!0,r=wce.channel!==void 0;return{...Rce(t,e,r),getCancelSignal:kse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Rce=(t,e,r)=>({sendMessage:TR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:bce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as L4e}from"child_process";import{PassThrough as U4e,Readable as F4e,Writable as z4e,Duplex as j4e}from"stream";var Cce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{YU(n);let a=new L4e;B4e(a,n),Object.assign(a,{readable:q4e,writable:G4e,duplex:V4e});let c=Yp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=H4e(c,s,i);return{subprocess:a,promise:l}},B4e=(t,e)=>{let r=rS(),n=rS(),i=rS(),o=Array.from({length:e.length-3},rS),s=rS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},rS=()=>{let t=new U4e;return t.end(),t},q4e=()=>new F4e({read(){}}),G4e=()=>new z4e({write(){}}),V4e=()=>new j4e({read(){},write(){}}),H4e=async(t,e,r)=>Kp(t,e,r);import{createReadStream as Ice,createWriteStream as Pce}from"fs";import{Buffer as W4e}from"buffer";import{Readable as nS,Writable as Y4e,Duplex as K4e}from"stream";var Nce=(t,e)=>LR(Z4e,t,e,!1),iS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${jc[t]}.`)},Oce={fileNumber:iS,generator:eF,asyncGenerator:eF,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:K4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Z4e={input:{...Oce,fileUrl:({value:t})=>({stream:Ice(t)}),filePath:({value:{file:t}})=>({stream:Ice(t)}),webStream:({value:t})=>({stream:nS.fromWeb(t)}),iterable:({value:t})=>({stream:nS.from(t)}),asyncIterable:({value:t})=>({stream:nS.from(t)}),string:({value:t})=>({stream:nS.from(t)}),uint8Array:({value:t})=>({stream:nS.from(W4e.from(t))})},output:{...Oce,fileUrl:({value:t})=>({stream:Pce(t)}),filePath:({value:{file:t,append:e}})=>({stream:Pce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Y4e.fromWeb(t)}),iterable:iS,asyncIterable:iS,string:iS,uint8Array:iS}};import{on as J4e,once as kce}from"events";import{PassThrough as X4e,getDefaultHighWaterMark as Q4e}from"stream";import{finished as $ce}from"stream/promises";function Yu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)sF(i);let e=t.some(({readableObjectMode:i})=>i),r=eHe(t,e),n=new oF({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var eHe=(t,e)=>{if(t.length===0)return Q4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},oF=class extends X4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(sF(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tHe(this,this.#e,this.#o);let r=iHe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(sF(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)}},tHe=async(t,e,r)=>{GR(t,Mce);let n=new AbortController;try{await Promise.race([rHe(t,n),nHe(t,e,r,n)])}finally{n.abort(),GR(t,-Mce)}},rHe=async(t,{signal:e})=>{try{await $ce(t,{signal:e,cleanup:!0})}catch(r){throw Lce(t,r),r}},nHe=async(t,e,r,{signal:n})=>{for await(let[i]of J4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},sF=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{GR(t,Dce);let a=new AbortController;try{await Promise.race([oHe(o,e,a),sHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),aHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),GR(t,-Dce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?aF(t):cHe(t))},oHe=async(t,e,{signal:r})=>{try{await t,r.aborted||aF(e)}catch(n){r.aborted||Lce(e,n)}},sHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await $ce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Uce(s)?i.add(e):Fce(t,s)}},aHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await kce(t,i,{signal:o}),!t.readable)return kce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},cHe=t=>{t.writable&&t.end()},Lce=(t,e)=>{Uce(e)?aF(t):Fce(t,e)},Uce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",aF=t=>{(t.readable||t.writable)&&t.destroy()},Fce=(t,e)=>{t.destroyed||(t.once("error",lHe),t.destroy(e))},lHe=()=>{},GR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Mce=2,Dce=1;import{finished as zce}from"stream/promises";var Jp=(t,e)=>{t.pipe(e),uHe(t,e),dHe(t,e)},uHe=async(t,e)=>{if(!(vo(t)||vo(e))){try{await zce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}cF(e)}},cF=t=>{t.writable&&t.end()},dHe=async(t,e)=>{if(!(vo(t)||vo(e))){try{await zce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}lF(t)}},lF=t=>{t.readable&&t.destroy()};var jce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Fi.has(c)))fHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Fi.has(c)))hHe({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Yu(o);Jp(s,i)}},fHe=(t,e,r,n)=>{r==="output"?Jp(t.stdio[n],e):Jp(e,t.stdio[n]);let i=pHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pHe=["stdin","stdout","stderr"],hHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;mHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},mHe=(t,{signal:e})=>{vo(t)&&Gu(t,gHe,e)},gHe=2;import{addAbortListener as SHe}from"events";var Ku=[];Ku.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ku.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ku.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var VR=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",uF=Symbol.for("signal-exit emitter"),dF=globalThis,_He=Object.defineProperty.bind(Object),fF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(dF[uF])return dF[uF];_He(dF,uF,{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 o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},HR=class{},yHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),pF=class extends HR{onExit(){return()=>{}}load(){}unload(){}},hF=class extends HR{#e=mF.platform==="win32"?"SIGINT":"SIGHUP";#r=new fF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ku)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!VR(this.#t))return()=>{};this.#s===!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.#s){this.#s=!0,this.#r.count+=1;for(let e of Ku)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.#s&&(this.#s=!1,Ku.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.#o,this.#r.count-=1)}#a(e){return VR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&VR(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)}},mF=globalThis.process,{onExit:Bce,load:EUt,unload:vUt}=yHe(VR(mF)?new hF(mF):new pF);var qce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Bce(()=>{t.kill()});SHe(n,()=>{i()})};var Vce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=nR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=EHe(r,n,i),{sourceStream:d,sourceError:f}=THe(t,l),{options:p,fileDescriptors:h}=_s.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},EHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=vHe(t,e,...r),a=pR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},vHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Gce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||iU(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,o,s]=Wx(r,...n);return{destination:e(Gce)(i,o,s),pipeOptions:s}}if(_s.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}`)},Gce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),THe=(t,e)=>{try{return{sourceStream:Gp(t,e)}}catch(r){return{sourceError:r}}};var Wce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=bHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw gF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},bHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return lF(t),n;if(e!==void 0)return cF(r),e},gF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yp({error:t,command:Hce,escapedCommand:Hce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Hce="source.pipe(destination)";var Yce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as wHe}from"stream/promises";var Kce=(t,e,r)=>{let n=WR.has(e)?xHe(t,e):AHe(t,e);return Gu(t,CHe,r.signal),Gu(e,IHe,r.signal),RHe(e),n},AHe=(t,e)=>{let r=Yu([t]);return Jp(r,e),WR.set(e,r),r},xHe=(t,e)=>{let r=WR.get(e);return r.add(t),r},RHe=async t=>{try{await wHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}WR.delete(t)},WR=new WeakMap,CHe=2,IHe=1;import{aborted as PHe}from"util";var Zce=(t,e)=>t===void 0?[]:[OHe(t,e)],OHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await PHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw gF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var YR=(t,...e)=>{if(Xt(e[0]))return YR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Vce(t,...e),i=NHe({...n,destination:r});return i.pipe=YR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=kHe(t,i);Wce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Kce(e,o,d);return await Promise.race([Yce(u),...Zce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},kHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as zHe}from"timers/promises";import{on as MHe}from"events";import{getDefaultHighWaterMark as DHe}from"stream";var KR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return $He(e,s),Xce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},$He=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_F=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;LHe(e,s,t);let a=t.readableObjectMode&&!o;return Xce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Xce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=MHe(t,"data",{signal:e.signal,highWaterMark:Jce,highWatermark:Jce});return UHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},yF=DHe(!0),Jce=yF,UHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=FHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Wu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*tS(a)}},FHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[FR(t,r,!e),UR(t,i,!n,{})].filter(Boolean);var Qce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=jHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([BHe(t),d]);return}let f=KU(c,r),p=_F({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([qHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},jHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!BR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=_F({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await uce(a,t,r,o)},BHe=async t=>{await zHe(),t.readableFlowing===null&&t.resume()},qHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await IR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await PR(r,{maxBuffer:o})):await Wp(r,{maxBuffer:o})}catch(a){return ele(uae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},SF=async t=>{try{return await t}catch(e){return ele(e)}},ele=({bufferedData:t})=>xie(t)?new Uint8Array(t):t;import{finished as GHe}from"stream/promises";var oS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=VHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||YHe(a,e,r,n)}finally{s.abort()}},VHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&HHe(t,r,n),n},HHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{WHe(e,r),n.call(t,...i)}},WHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YHe=(t,e,r,n)=>{if(!KHe(t,e,r,n))throw t},KHe=(t,e,r,n=!0)=>r.propagating?tle(t)||ZR(t):(r.propagating=!0,EF(r,e)===n?tle(t):ZR(t)),EF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ZR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",tle=t=>t?.code==="EPIPE";var rle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>vF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),vF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=oS(t,e,l);if(EF(l,e)){await u;return}let[d]=await Promise.all([Qce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var nle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Yu([t,e].filter(Boolean)):void 0,ile=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>vF({...ZHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:JHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),ZHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},JHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as XHe}from"events";var ole=t=>Fp(t,"ipc"),sle=(t,e)=>{let r=rR(t);ms({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ale=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=ole(o),a=Ea(e,"ipc"),c=Ea(r,"ipc");for await(let l of iF({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(dae(t,i,c),i.push(l)),s&&sle(l,o);return i},cle=async(t,e)=>(await Promise.allSettled([t]),e);var lle=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let y=mce(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:y,propagating:!1},v=rle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),S=ile({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],R=ale({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),O=QHe(m,t,w),I=e6e(h,w);try{return await Promise.race([Promise.all([{},_ce(y),Promise.all(v),S,R,qse(t,d),...O,...I]),g,t6e(t,_),...Use(t,o,f,_),...ose({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...$se({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},y,Promise.all(v.map(b=>SF(b))),SF(S),cle(R,A),Promise.allSettled(O),Promise.allSettled(I)])}},QHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:oS(n,i,r)),e6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>wo(o,{checkOpen:!1})&&!vo(o)).map(({type:i,value:o,stream:s=o})=>oS(s,n,e,{isSameDirection:Fi.has(i),stopOnExit:i==="native"}))),t6e=async(t,{signal:e})=>{let[r]=await XHe(t,"error",{signal:e});throw r};var ule=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),sS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=gs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Xp=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 r6e}from"stream";import{callbackify as n6e}from"util";import{finished as dle}from"stream/promises";var TF=async t=>{if(t!==void 0)try{await bF(t)}catch{}},fle=async t=>{if(t!==void 0)try{await wF(t)}catch{}},bF=async t=>{await dle(t,{cleanup:!0,readable:!1,writable:!0})},wF=async t=>{await dle(t,{cleanup:!0,readable:!0,writable:!1})},JR=async(t,e)=>{if(await t,e)throw e},XR=(t,e,r)=>{r&&!ZR(r)?t.destroy(r):e&&t.destroy()};var ple=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ai.has(r),{subprocessStdout:a,waitReadableDestroy:c}=AF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=xF(a,s),{read:f,onStdoutDataDone:p}=RF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new r6e({read:f,destroy:n6e(IF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return CF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},AF=(t,e,r)=>{let n=Gp(t,e),i=sS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},xF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:yF},RF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=gs(),s=KR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){i6e(this,s,o)},onStdoutDataDone:o}},i6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},CF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await wF(t),await n,await TF(i),await e,r.readable&&r.push(null)}catch(o){await TF(i),hle(r,o)}},IF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Xp(r,e)&&(hle(t,n),await JR(e,n))},hle=(t,e)=>{XR(t,t.readable,e)};import{Writable as o6e}from"stream";import{callbackify as mle}from"util";var gle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=PF(t,r,e),s=new o6e({...OF(n,t,i),destroy:mle(kF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return NF(n,s),s},PF=(t,e,r)=>{let n=pR(t,e),i=sS(r,n,"writableFinal"),o=sS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},OF=(t,e,r)=>({write:s6e.bind(void 0,t),final:mle(a6e.bind(void 0,t,e,r))}),s6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},a6e=async(t,e,r)=>{await Xp(r,e)&&(t.writable&&t.end(),await e)},NF=async(t,e,r)=>{try{await bF(t),e.writable&&e.end()}catch(n){await fle(r),_le(e,n)}},kF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Xp(r,e),await Xp(n,e)&&(_le(t,i),await JR(e,i))},_le=(t,e)=>{XR(t,t.writable,e)};import{Duplex as c6e}from"stream";import{callbackify as l6e}from"util";var yle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ai.has(r),{subprocessStdout:c,waitReadableDestroy:l}=AF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=PF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=xF(c,a),{read:g,onStdoutDataDone:_}=RF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),y=new c6e({read:g,...OF(u,t,d),destroy:l6e(u6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return CF({subprocessStdout:c,onStdoutDataDone:_,readable:y,subprocess:t,subprocessStdin:u}),NF(u,y,c),y},u6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([IF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),kF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var MF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ai.has(e),s=Gp(t,r),a=KR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return d6e(a,s,t)},d6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Sle=(t,{encoding:e})=>{let r=ule();t.readable=ple.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=gle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=yle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=MF.bind(void 0,t,e),t[Symbol.asyncIterator]=MF.bind(void 0,t,e,{})};var Ele=(t,e)=>{for(let[r,n]of p6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},f6e=(async()=>{})().constructor.prototype,p6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(f6e,t)]);var vle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=g6e(t,e,r),{subprocess:f,promise:p}=y6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=YR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Ele(f,p),_s.set(f,{options:u,fileDescriptors:d}),f},g6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=iR(t,e,r),{file:a,commandArguments:c,options:l}=wR(t,e,r),u=_6e(l),d=Nce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},_6e=({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}},y6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=m6e(...AR(t,e,r))}catch(h){return Cce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;h6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];jce(c,a,l),qce(c,r,l);let d={},f=gs();c.kill=nse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=nle(c,r),Sle(c,r),Ace(c,r);let p=S6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},S6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await lle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,S)=>Ta(v,e,S)),y=Ta(m,e,"all"),w=E6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:y,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Kp(w,n,e)},E6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?eS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ys,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):kR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var QR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,v6e(n,t[n],i)]));return{...t,...r}},v6e=(t,e,r)=>T6e.has(t)&&Xt(e)&&Xt(r)?{...e,...r}:r,T6e=new Set(["env",...uU]);var Bc=(t,e,r,n)=>{let i=(s,a,c)=>Bc(s,a,r,c),o=(...s)=>b6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},b6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Xt(o))return i(t,QR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=w6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Sce(a,c,l):vle(a,c,l,i)},w6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Nie(e)?kie(e,r):[e,...r],[s,a,c]=Wx(...o),l=QR(QR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Tle=({file:t,commandArguments:e})=>wle(t,e),ble=({file:t,commandArguments:e})=>({...wle(t,e),isSync:!0}),wle=(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]=A6e(t);return{file:r,commandArguments:n}},A6e=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(x6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},x6e=/ +/g;var Ale=(t,e,r)=>{t.sync=e(R6e,r),t.s=t.sync},xle=({options:t})=>Rle(t),R6e=({options:t})=>({...Rle(t),isSync:!0}),Rle=t=>({options:{...C6e(t),...t}}),C6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Cle={preferLocal:!0};var Ile=Bc(()=>({})),ujt=Bc(()=>({isSync:!0})),Ple=Bc(Tle),djt=Bc(ble),fjt=Bc(zse),pjt=Bc(xle,{},Cle,Ale),{sendMessage:hjt,getOneMessage:mjt,getEachMessage:gjt,getCancelSignal:_jt}=xce();var Ole=!1,Nle,I6e=t=>{Nle??=t},kle=t=>{Ole=!0,I6e(t)},ci=()=>Ole,qc=()=>Nle,Mle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var aS=null,Dle=t=>(aS&&aS.destroy(),aS=new zi({totalAllowedTime:t}),aS),$le=()=>aS;var zi=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&&ci())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await $x({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{G.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};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 Lle={name:"@netlify/agent-runner-cli",type:"module",version:"1.194.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.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.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var k6e=O6e(import.meta.url),M6e=ba.dirname(k6e),D6e=N6e(import.meta.url),Qp=ne("shell"),DF=new Set,Ule={preferLocal:!0},It=(t,e,r)=>{let[n,i]=$6e(e,r),o={...Ule,...i},s=Ile(t,n,o);zle(s,o),qle(s);let a=r?.idleTimeout;return a&&a>0&&Ble(s,a),s},Fle=(t,e)=>{let r={...Ule,...e},n=Ple(t,r);return zle(n,r),qle(n),e?.idleTimeout&&e.idleTimeout>0&&Ble(n,e.idleTimeout),n},$6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Es.env.NETLIFY_LOCAL_QUIET==="true")return;if(Es.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Dy).pipe(Es.stdout),t.stderr?.pipe(new Dy).pipe(Es.stderr);return}t.stdout?.pipe(Es.stdout),t.stderr?.pipe(Es.stderr)},$F=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Es.kill(-t.pid,e),Qp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Qp.error("Error killing process:",r),!1}},jle=t=>$F(t,"SIGKILL"),Ble=(t,e)=>{let r=null,n=()=>{Qp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),$F(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qp.log(`Force killing idle process ${t.pid}`),jle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},qle=t=>{DF.add(t);let e=$le();if(e){let r=e.onTimesUp(()=>{Qp.log(`Global timer expired, killing process ${t.pid}`),$F(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qp.log(`Force killing process ${t.pid} after timeout`),jle(t))},5e3)});t.on("exit",()=>{DF.delete(t),r()}),t.on("error",()=>{DF.delete(t),r()})}};function tC(t,e){return!!Ao(t,e)}function Ao(t,e){if(!Es.env.NETLIFY_LOCAL_MODE)try{let i=D6e.resolve(Lle.name),o=ba.dirname(i);for(;o!==ba.dirname(o);){let s=ba.dirname(o);if(ba.basename(s)==="node_modules"){let a=ba.join(s,".bin",e);if(eC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Es.env.NODE_PATH){let i=ba.join(Es.env.NODE_PATH,".bin",e);if(eC.existsSync(i))return i}let r=ba.join(t,"node_modules",".bin",e);if(eC.existsSync(r))return r;let n=ba.join(M6e,"..","node_modules",".bin",e);if(eC.existsSync(n))return n}var Gle=ne("repo"),Yle="runner-diffs-",iC=t=>`${Yle}${t}-`,Kle=async t=>{let e=Wle.tmpdir(),r;try{r=await rC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Yle)&&!n.startsWith(iC(t))).map(n=>rC.rm(nC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Qt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),oC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Gle.info("Getting runner diffs");let n=await zF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=jF(o);await G6e(l,r)}Gle.info("Changes after processing"),await FF(r);let s=await lS(o,r);if(await UF(s,r),i=await j6e(r),!i)return{hasChanges:!1,ignored:s};await Qt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await rC.mkdtemp(nC.join(Wle.tmpdir(),iC(t.sessionId))),c=await LF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await F6e(r),c.hasChanges&&G.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},LF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=nC.join(e,h);await Qt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:y}=await rC.stat(g);return{path:g,size:y}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Hle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Hle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Vle=async t=>{let e=L6e("sha256");for await(let r of U6e(t))e.update(r);return e.digest("hex")},Hle=async(t,e)=>t.size===e.size&&await Vle(t.path)===await Vle(e.path),F6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qt(["reset","--soft","HEAD~1"],{cwd:t})},UF=async(t=[],e=process.cwd())=>{await Qt(["add",".",...t],{cwd:e})},FF=async(t=process.cwd())=>{let e=await Qt(["status","-s"],{cwd:t});return String(e.stdout??"")},Zle=/.. (.+)?\.log$/,z6e=[Zle],zF=async(t=process.cwd())=>{let e=await FF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
147
147
|
`).filter(i=>z6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},j6e=async(t=process.cwd())=>{try{return await Qt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},cS=async(t=process.cwd())=>{let{stdout:e}=await Qt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},B6e=1,q6e=async t=>{try{return await Qt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===B6e)return!1;throw e}},Jle=async(t=process.cwd())=>{if(!await q6e(t))return!0;let{stdout:e}=await Qt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Xle=async(t=process.cwd())=>{let{stdout:e}=await Qt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},lS=async(t,e=process.cwd())=>{t||=await FF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
148
148
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${nC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Zle)?.[1];o&&n.push(`:!${o}.log`)}),n},Qle=async(t=process.cwd())=>{await Qt(["reset","--hard","HEAD"],{cwd:t})},eue=async(t=process.cwd())=>{let e=await Qt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
149
149
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},jF=t=>{let e=t.split(`
|
package/dist/bin.js
CHANGED
|
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
594
594
|
`,LF:`
|
|
595
595
|
`,concatBytes:cW},vwt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Twt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:vwt};import{Buffer as bwt}from"buffer";var lRe=(t,e)=>t?void 0:wwt.bind(void 0,e),wwt=function*(t,e){if(typeof e!="string"&&!Wr(e)&&!bwt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},uRe=(t,e)=>t?Rwt.bind(void 0,e):Awt.bind(void 0,e),Rwt=function*(t,e){dRe(t,e),yield e},Awt=function*(t,e){if(dRe(t,e),typeof e!="string"&&!Wr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},dRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
596
596
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
597
|
-
if (condition) { yield value; }`)};import{Buffer as xwt}from"buffer";import{StringDecoder as Cwt}from"string_decoder";var DP=(t,e,r)=>{if(r)return;if(t)return{transform:Iwt.bind(void 0,new TextEncoder)};let n=new Cwt(e);return{transform:Owt.bind(void 0,n),final:Pwt.bind(void 0,n)}},Iwt=function*(t,e){xwt.isBuffer(e)?yield Dc(e):typeof e=="string"?yield t.encode(e):yield e},Owt=function*(t,e){yield Wr(e)?t.write(e):e},Pwt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as fRe}from"util";var uW=fRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LP=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kwt}=e[r];for await(let i of n(t))yield*LP(i,e,r+1)},pRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Nwt(r,Number(e),t)},Nwt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LP(n,r,e+1)},hRe=fRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),kwt=function*(t){yield t};var dW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},mRe=(t,e)=>[...e.flatMap(r=>[...Qf(r,t,0)]),...KT(t)],Qf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Dwt}=e[r];for(let i of n(t))yield*Qf(i,e,r+1)},KT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$wt(r,Number(e),t)},$wt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Qf(n,r,e+1)},Dwt=function*(t){yield t};var fW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=_Re(t,o,s),l=Xf(e),u=Xf(r),d=l?uW.bind(void 0,LP,a):dW.bind(void 0,Qf),f=l||u?uW.bind(void 0,pRe,a):dW.bind(void 0,KT),p=l||u?hRe.bind(void 0,a):void 0;return{stream:new Lwt({writableObjectMode:n,writableHighWaterMark:gRe(n),readableObjectMode:i,readableHighWaterMark:gRe(i),transform(m,g,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},MP=(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=_Re(o,r,a);t=mRe(c,t)}return t},_Re=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:lRe(n,a)},DP(r,o,n),$P(r,s,n,c),{transform:t,final:e},{transform:uRe(i,a)},cRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var yRe=(t,e)=>{for(let r of Mwt(t))Uwt(t,r,e)},Mwt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Uwt=(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 ${$u[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Fwt(a,n));r.input=FT(o)},Fwt=(t,e)=>{let r=MP(t,e,"utf8",!0);return jwt(r),FT(r)},jwt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(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 Vwt,appendFileSync as Hwt}from"fs";var UP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Og(r,n)&&!Qi.has(e)&&zwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&qwt.has(s))||t.every(({type:i})=>Ls.has(i))),zwt=t=>t===1||t===2,qwt=new Set(["pipe","overlapped"]),SRe=async(t,e,r,n)=>{for await(let i of t)Bwt(e)||vRe(i,r,n)},ERe=(t,e,r)=>{for(let n of t)vRe(n,e,r)},Bwt=t=>t._readableState.pipes.length>0,vRe=(t,e,r)=>{let n=XO(t);ga({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var TRe=({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,l)=>Gwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Gwt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=bwe(t,s,d),p=Dc(f),{stdioItems:h,objectMode:m}=e[r],g=Wwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=Ywt({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Kwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&Zwt(S,h,i),y}catch(_){return n.error=_,y}},Wwt=(t,e,r,n)=>{try{return MP(t,e,r,!1)}catch(i){return n.error=i,t}},Ywt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:FT(t)};let o=Mve(t,r);return n[s]?{serializedResult:o,finalResult:lW(o,!i[s],e)}:{serializedResult:o}},Kwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!UP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=lW(t,!1,o);try{ERe(a,e,n)}catch(c){r.error??=c}},Zwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>NP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Hwt(n,t):(r.add(s),Vwt(n,t))}};var bRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Uc(e,r,"all")]:Array.isArray(e)?[Uc(t,r,"all"),...e]:Wr(t)&&Wr(e)?y3([t,e]):`${t}${e}`};import{once as pW}from"events";var wRe=async(t,e)=>{let[r,n]=await Jwt(t);return e.isForcefullyTerminated??=!1,[r,n]},Jwt=async t=>{let[e,r]=await Promise.allSettled([pW(t,"spawn"),pW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?RRe(t):r.value},RRe=async t=>{try{return await pW(t,"exit")}catch{return RRe(t)}},ARe=async t=>{let[e,r]=await t;if(!Xwt(e,r)&&hW(e,r))throw new go;return[e,r]},Xwt=(t,e)=>t===void 0&&e===void 0,hW=(t,e)=>t!==0||e!==null;var xRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Qwt(t,e,r),o=s?.code==="ETIMEDOUT",a=Twe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Qwt=(t,e,r)=>t!==void 0?t:hW(e,r)?new go:void 0;var CRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=tRt(t,e,r),d=iRt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return jg(d,c,l)},tRt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=eP(t,e,r),a=rRt(r),{file:c,commandArguments:l,options:u}=EP(t,e,a);nRt(u);let d=iRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},rRt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,nRt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&FP("ipcInput"),t&&FP("ipc: true"),r&&FP("detached: true"),n&&FP("cancelSignal")},FP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},iRt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=sRt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=xRe(c,r),{output:h,error:m=l}=TRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,y)=>Uc(E,r,y)),S=Uc(bRe(h,r),r,"all");return aRt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},sRt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{yRe(s,r);let a=oRt(r);return eRt(...vP(t,e,a))}catch(a){return Fg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},oRt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:CP(e)}),aRt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?IP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):YT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as YAt}from"events";import{spawn as KAt}from"child_process";import kRe from"process";import{once as mW,on as cRt}from"events";var IRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(kg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:hP(t)}),lRt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),lRt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{uP(e,i);let s=ku(t,e,r),o=new AbortController;try{return await Promise.race([uRt(s,n,o),dRt(s,r,o),fRt(s,r,o)])}catch(a){throw $g(t),a}finally{o.abort(),dP(e,i)}},uRt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await mW(t,"message",{signal:r});return n}for await(let[n]of cRt(t,"message",{signal:r}))if(e(n))return n},dRt=async(t,e,{signal:r})=>{await mW(t,"disconnect",{signal:r}),mbe(e)},fRt=async(t,e,{signal:r})=>{let[n]=await mW(t,"strict:error",{signal:r});throw aP(n,e)};import{once as PRe,on as pRt}from"events";var NRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>gW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),gW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{kg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:hP(t)}),uP(e,s);let o=ku(t,e,r),a=new AbortController,c={};return hRt(t,o,a),mRt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),gRt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},hRt=async(t,e,r)=>{try{await PRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},mRt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await PRe(t,"strict:error",{signal:r.signal});n.error=aP(i,e),r.abort()}catch{}},gRt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of pRt(r,"message",{signal:s.signal}))ORe(o),yield c}catch{ORe(o)}finally{s.abort(),dP(e,a),n||$g(t),i&&await t}},ORe=({error:t})=>{if(t)throw t};var $Re=(t,{ipc:e})=>{Object.assign(t,LRe(t,!1,e))},DRe=()=>{let t=kRe,e=!0,r=kRe.channel!==void 0;return{...LRe(t,e,r),getCancelSignal:qbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},LRe=(t,e,r)=>({sendMessage:yP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:IRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:NRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as _Rt}from"child_process";import{PassThrough as yRt,Readable as SRt,Writable as ERt,Duplex as vRt}from"stream";var MRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{oW(n);let a=new _Rt;TRt(a,n),Object.assign(a,{readable:bRt,writable:wRt,duplex:RRt});let c=Fg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=ARt(c,o,i);return{subprocess:a,promise:l}},TRt=(t,e)=>{let r=ZT(),n=ZT(),i=ZT(),s=Array.from({length:e.length-3},ZT),o=ZT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},ZT=()=>{let t=new yRt;return t.end(),t},bRt=()=>new SRt({read(){}}),wRt=()=>new ERt({write(){}}),RRt=()=>new vRt({read(){},write(){}}),ARt=async(t,e,r)=>jg(t,e,r);import{createReadStream as URe,createWriteStream as FRe}from"fs";import{Buffer as xRt}from"buffer";import{Readable as JT,Writable as CRt,Duplex as IRt}from"stream";var zRe=(t,e)=>kP(ORt,t,e,!1),XT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$u[t]}.`)},jRe={fileNumber:XT,generator:fW,asyncGenerator:fW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:IRt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ORt={input:{...jRe,fileUrl:({value:t})=>({stream:URe(t)}),filePath:({value:{file:t}})=>({stream:URe(t)}),webStream:({value:t})=>({stream:JT.fromWeb(t)}),iterable:({value:t})=>({stream:JT.from(t)}),asyncIterable:({value:t})=>({stream:JT.from(t)}),string:({value:t})=>({stream:JT.from(t)}),uint8Array:({value:t})=>({stream:JT.from(xRt.from(t))})},output:{...jRe,fileUrl:({value:t})=>({stream:FRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:FRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:CRt.fromWeb(t)}),iterable:XT,asyncIterable:XT,string:XT,uint8Array:XT}};import{on as PRt,once as qRe}from"events";import{PassThrough as NRt,getDefaultHighWaterMark as kRt}from"stream";import{finished as HRe}from"stream/promises";function ep(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)yW(i);let e=t.some(({readableObjectMode:i})=>i),r=$Rt(t,e),n=new _W({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var $Rt=(t,e)=>{if(t.length===0)return kRt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},_W=class extends NRt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(yW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=DRt(this,this.#e,this.#s);let r=URt({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(yW(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)}},DRt=async(t,e,r)=>{jP(t,BRe);let n=new AbortController;try{await Promise.race([LRt(t,n),MRt(t,e,r,n)])}finally{n.abort(),jP(t,-BRe)}},LRt=async(t,{signal:e})=>{try{await HRe(t,{signal:e,cleanup:!0})}catch(r){throw GRe(t,r),r}},MRt=async(t,e,r,{signal:n})=>{for await(let[i]of PRt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},yW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},URt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{jP(t,VRe);let a=new AbortController;try{await Promise.race([FRt(s,e,a),jRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),zRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),jP(t,-VRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?SW(t):qRt(t))},FRt=async(t,e,{signal:r})=>{try{await t,r.aborted||SW(e)}catch(n){r.aborted||GRe(e,n)}},jRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await HRe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;WRe(o)?i.add(e):YRe(t,o)}},zRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await qRe(t,i,{signal:s}),!t.readable)return qRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},qRt=t=>{t.writable&&t.end()},GRe=(t,e)=>{WRe(e)?SW(t):YRe(t,e)},WRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",SW=t=>{(t.readable||t.writable)&&t.destroy()},YRe=(t,e)=>{t.destroyed||(t.once("error",BRt),t.destroy(e))},BRt=()=>{},jP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},BRe=2,VRe=1;import{finished as KRe}from"stream/promises";var qg=(t,e)=>{t.pipe(e),VRt(t,e),HRt(t,e)},VRt=async(t,e)=>{if(!(mo(t)||mo(e))){try{await KRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}EW(e)}},EW=t=>{t.writable&&t.end()},HRt=async(t,e)=>{if(!(mo(t)||mo(e))){try{await KRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}vW(t)}},vW=t=>{t.readable&&t.destroy()};var ZRe=(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})=>Ls.has(c)))GRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ls.has(c)))YRt({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]:ep(s);qg(o,i)}},GRt=(t,e,r,n)=>{r==="output"?qg(t.stdio[n],e):qg(e,t.stdio[n]);let i=WRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},WRt=["stdin","stdout","stderr"],YRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;KRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},KRt=(t,{signal:e})=>{mo(t)&&Zf(t,ZRt,e)},ZRt=2;import{addAbortListener as QRt}from"events";var tp=[];tp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&tp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&tp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var zP=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",TW=Symbol.for("signal-exit emitter"),bW=globalThis,JRt=Object.defineProperty.bind(Object),wW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bW[TW])return bW[TW];JRt(bW,TW,{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}},qP=class{},XRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RW=class extends qP{onExit(){return()=>{}}load(){}unload(){}},AW=class extends qP{#e=xW.platform==="win32"?"SIGINT":"SIGHUP";#r=new wW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of tp)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(!zP(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 tp)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,tp.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 zP(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"&&zP(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)}},xW=globalThis.process,{onExit:JRe,load:jgr,unload:zgr}=XRt(zP(xW)?new AW(xW):new RW);var XRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=JRe(()=>{t.kill()});QRt(n,()=>{i()})};var eAe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=QO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=eAt(r,n,i),{sourceStream:d,sourceError:f}=rAt(t,l),{options:p,fileDescriptors:h}=ya.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},eAt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=tAt(t,e,...r),a=lP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},tAt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(QRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||g3(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]=BO(r,...n);return{destination:e(QRe)(i,s,o),pipeOptions:o}}if(ya.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}`)},QRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),rAt=(t,e)=>{try{return{sourceStream:Dg(t,e)}}catch(r){return{sourceError:r}}};var rAe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=nAt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw CW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},nAt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return vW(t),n;if(e!==void 0)return EW(r),e},CW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Fg({error:t,command:tAe,escapedCommand:tAe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),tAe="source.pipe(destination)";var nAe=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 iAt}from"stream/promises";var iAe=(t,e,r)=>{let n=BP.has(e)?oAt(t,e):sAt(t,e);return Zf(t,cAt,r.signal),Zf(e,lAt,r.signal),aAt(e),n},sAt=(t,e)=>{let r=ep([t]);return qg(r,e),BP.set(e,r),r},oAt=(t,e)=>{let r=BP.get(e);return r.add(t),r},aAt=async t=>{try{await iAt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}BP.delete(t)},BP=new WeakMap,cAt=2,lAt=1;import{aborted as uAt}from"util";var sAe=(t,e)=>t===void 0?[]:[dAt(t,e)],dAt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await uAt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw CW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var VP=(t,...e)=>{if(Nr(e[0]))return VP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=eAe(t,...e),i=fAt({...n,destination:r});return i.pipe=VP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},fAt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=pAt(t,i);rAe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=iAe(e,s,d);return await Promise.race([nAe(u),...sAe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},pAt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as EAt}from"timers/promises";import{on as hAt}from"events";import{getDefaultHighWaterMark as mAt}from"stream";var HP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return gAt(e,o),aAe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},gAt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},IW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;_At(e,o,t);let a=t.readableObjectMode&&!s;return aAe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},_At=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},aAe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=hAt(t,"data",{signal:e.signal,highWaterMark:oAe,highWatermark:oAe});return yAt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},OW=mAt(!0),oAe=OW,yAt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=SAt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Qf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*KT(a)}},SAt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[DP(t,r,!e),$P(t,i,!n,{})].filter(Boolean);var cAe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=vAt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([TAt(t),d]);return}let f=aW(c,r),p=IW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([bAt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},vAt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!UP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=IW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await SRe(a,t,r,s)},TAt=async t=>{await EAt(),t.readableFlowing===null&&t.resume()},bAt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await RP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await AP(r,{maxBuffer:s})):await Ug(r,{maxBuffer:s})}catch(a){return lAe(Swe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},PW=async t=>{try{return await t}catch(e){return lAe(e)}},lAe=({bufferedData:t})=>Dve(t)?new Uint8Array(t):t;import{finished as wAt}from"stream/promises";var QT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=RAt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],wAt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||CAt(a,e,r,n)}finally{o.abort()}},RAt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&AAt(t,r,n),n},AAt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{xAt(e,r),n.call(t,...i)}},xAt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},CAt=(t,e,r,n)=>{if(!IAt(t,e,r,n))throw t},IAt=(t,e,r,n=!0)=>r.propagating?uAe(t)||GP(t):(r.propagating=!0,NW(r,e)===n?uAe(t):GP(t)),NW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",GP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",uAe=t=>t?.code==="EPIPE";var dAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>kW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),kW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=QT(t,e,l);if(NW(l,e)){await u;return}let[d]=await Promise.all([cAe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var fAe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?ep([t,e].filter(Boolean)):void 0,pAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>kW({...OAt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:PAt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),OAt=({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}},PAt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as NAt}from"events";var hAe=t=>Og(t,"ipc"),mAe=(t,e)=>{let r=XO(t);ga({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var gAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=hAe(s),a=Lc(e,"ipc"),c=Lc(r,"ipc");for await(let l of gW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ewe(t,i,c),i.push(l)),o&&mAe(l,s);return i},_Ae=async(t,e)=>(await Promise.allSettled([t]),e);var yAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:S})=>{let E=wRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=dAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=pAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],R=gAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=kAt(m,t,y),C=$At(h,y);try{return await Promise.race([Promise.all([{},ARe(E),Promise.all(_),T,R,Xbe(t,d),...b,...C]),g,DAt(t,S),...Wbe(t,s,f,S),...hbe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Hbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(x=>PW(x))),PW(T),_Ae(R,w),Promise.allSettled(b),Promise.allSettled(C)])}},kAt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:QT(n,i,r)),$At=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>yo(s,{checkOpen:!1})&&!mo(s)).map(({type:i,value:s,stream:o=s})=>QT(o,n,e,{isSameDirection:Ls.has(i),stopOnExit:i==="native"}))),DAt=async(t,{signal:e})=>{let[r]=await NAt(t,"error",{signal:e});throw r};var SAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=_a();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Bg=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 LAt}from"stream";import{callbackify as MAt}from"util";import{finished as EAe}from"stream/promises";var $W=async t=>{if(t!==void 0)try{await DW(t)}catch{}},vAe=async t=>{if(t!==void 0)try{await LW(t)}catch{}},DW=async t=>{await EAe(t,{cleanup:!0,readable:!1,writable:!0})},LW=async t=>{await EAe(t,{cleanup:!0,readable:!0,writable:!1})},WP=async(t,e)=>{if(await t,e)throw e},YP=(t,e,r)=>{r&&!GP(r)?t.destroy(r):e&&t.destroy()};var TAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Qi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=MW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=UW(a,o),{read:f,onStdoutDataDone:p}=FW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new LAt({read:f,destroy:MAt(zW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return jW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},MW=(t,e,r)=>{let n=Dg(t,e),i=eb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},UW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:OW},FW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=_a(),o=HP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){UAt(this,o,s)},onStdoutDataDone:s}},UAt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},jW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LW(t),await n,await $W(i),await e,r.readable&&r.push(null)}catch(s){await $W(i),bAe(r,s)}},zW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bg(r,e)&&(bAe(t,n),await WP(e,n))},bAe=(t,e)=>{YP(t,t.readable,e)};import{Writable as FAt}from"stream";import{callbackify as wAe}from"util";var RAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=qW(t,r,e),o=new FAt({...BW(n,t,i),destroy:wAe(HW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return VW(n,o),o},qW=(t,e,r)=>{let n=lP(t,e),i=eb(r,n,"writableFinal"),s=eb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},BW=(t,e,r)=>({write:jAt.bind(void 0,t),final:wAe(zAt.bind(void 0,t,e,r))}),jAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},zAt=async(t,e,r)=>{await Bg(r,e)&&(t.writable&&t.end(),await e)},VW=async(t,e,r)=>{try{await DW(t),e.writable&&e.end()}catch(n){await vAe(r),AAe(e,n)}},HW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bg(r,e),await Bg(n,e)&&(AAe(t,i),await WP(e,i))},AAe=(t,e)=>{YP(t,t.writable,e)};import{Duplex as qAt}from"stream";import{callbackify as BAt}from"util";var xAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Qi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=MW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=qW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=UW(c,a),{read:g,onStdoutDataDone:S}=FW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new qAt({read:g,...BW(u,t,d),destroy:BAt(VAt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return jW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),VW(u,E,c),E},VAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([zW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var GW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Qi.has(e),o=Dg(t,r),a=HP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return HAt(a,o,t)},HAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var CAe=(t,{encoding:e})=>{let r=SAe();t.readable=TAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=RAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=xAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=GW.bind(void 0,t,e),t[Symbol.asyncIterator]=GW.bind(void 0,t,e,{})};var IAe=(t,e)=>{for(let[r,n]of WAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},GAt=(async()=>{})().constructor.prototype,WAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(GAt,t)]);var OAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ZAt(t,e,r),{subprocess:f,promise:p}=XAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=VP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),IAe(f,p),ya.set(f,{options:u,fileDescriptors:d}),f},ZAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=eP(t,e,r),{file:a,commandArguments:c,options:l}=EP(t,e,r),u=JAt(l),d=zRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},JAt=({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}},XAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=KAt(...vP(t,e,r))}catch(h){return MRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;YAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ZRe(c,a,l),XRe(c,r,l);let d={},f=_a();c.kill=fbe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=fAe(c,r),CAe(c,r),$Re(c,r);let p=QAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},QAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await yAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((_,T)=>Uc(_,e,T)),E=Uc(m,e,"all"),y=e0t({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return jg(y,n,e)},e0t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?YT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Sa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):IP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var KP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,t0t(n,t[n],i)]));return{...t,...r}},t0t=(t,e,r)=>r0t.has(t)&&Nr(e)&&Nr(r)?{...e,...r}:r,r0t=new Set(["env",...T3]);var Du=(t,e,r,n)=>{let i=(o,a,c)=>Du(o,a,r,c),s=(...o)=>n0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},n0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Nr(s))return i(t,KP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=i0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?CRe(a,c,l):OAe(a,c,l,i)},i0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=zve(e)?qve(e,r):[e,...r],[o,a,c]=BO(...s),l=KP(KP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var PAe=({file:t,commandArguments:e})=>kAe(t,e),NAe=({file:t,commandArguments:e})=>({...kAe(t,e),isSync:!0}),kAe=(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]=s0t(t);return{file:r,commandArguments:n}},s0t=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(o0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},o0t=/ +/g;var $Ae=(t,e,r)=>{t.sync=e(a0t,r),t.s=t.sync},DAe=({options:t})=>LAe(t),a0t=({options:t})=>({...LAe(t),isSync:!0}),LAe=t=>({options:{...c0t(t),...t}}),c0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},MAe={preferLocal:!0};var UAe=Du(()=>({})),OSr=Du(()=>({isSync:!0})),FAe=Du(PAe),PSr=Du(NAe),NSr=Du(Kbe),kSr=Du(DAe,{},MAe,$Ae),{sendMessage:$Sr,getOneMessage:DSr,getEachMessage:LSr,getCancelSignal:MSr}=DRe();import{Transform as l0t}from"stream";var u0t=["NETLIFY_AI_GATEWAY_KEY"];function d0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...u0t])]}function f0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function p0t(){let e=d0t().map(r=>process.env[r]).filter(r=>!(!r||f0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Li(t){if(typeof t!="string")return t;let e=p0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(h0t(n),"g");r=r.replace(i,"******")}),r}function h0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tb=class extends l0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Li(i);n(null,s)}},ZP=Symbol("maskedWrite");function jAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[ZP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Li(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[ZP]=!0,process.stdout.write=r}if(!process.stderr.write[ZP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Li(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[ZP]=!0,process.stderr.write=r}}}var zAe=!1,qAe,WW=t=>{qAe??=t},BAe=t=>{zAe=!0,WW(t)},kn=()=>zAe,va=()=>qAe,VAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var rb=null,HAe=t=>(rb&&rb.destroy(),rb=new Ms({totalAllowedTime:t}),rb),GAe=()=>rb;var Ms=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&&kn())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((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await FO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{X.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 WAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.194.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"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.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.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var y0t=g0t(import.meta.url),S0t=Fc.dirname(y0t),E0t=_0t(import.meta.url),Vg=fe("shell"),YW=new Set,YAe={preferLocal:!0},ar=(t,e,r)=>{let[n,i]=v0t(e,r),s={...YAe,...i},o=UAe(t,n,s);ZAe(o,s),QAe(o);let a=r?.idleTimeout;return a&&a>0&&XAe(o,a),o},KAe=(t,e)=>{let r={...YAe,...e},n=FAe(t,r);return ZAe(n,r),QAe(n),e?.idleTimeout&&e.idleTimeout>0&&XAe(n,e.idleTimeout),n},v0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ZAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ta.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ta.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tb).pipe(Ta.stdout),t.stderr?.pipe(new tb).pipe(Ta.stderr);return}t.stdout?.pipe(Ta.stdout),t.stderr?.pipe(Ta.stderr)},KW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ta.kill(-t.pid,e),Vg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Vg.error("Error killing process:",r),!1}},JAe=t=>KW(t,"SIGKILL"),XAe=(t,e)=>{let r=null,n=()=>{Vg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing idle process ${t.pid}`),JAe(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)},QAe=t=>{YW.add(t);let e=GAe();if(e){let r=e.onTimesUp(()=>{Vg.log(`Global timer expired, killing process ${t.pid}`),KW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing process ${t.pid} after timeout`),JAe(t))},5e3)});t.on("exit",()=>{YW.delete(t),r()}),t.on("error",()=>{YW.delete(t),r()})}};function ba(t,e){if(!Ta.env.NETLIFY_LOCAL_MODE)try{let i=E0t.resolve(WAe.name),s=Fc.dirname(i);for(;s!==Fc.dirname(s);){let o=Fc.dirname(s);if(Fc.basename(o)==="node_modules"){let a=Fc.join(o,".bin",e);if(JP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ta.env.NODE_PATH){let i=Fc.join(Ta.env.NODE_PATH,".bin",e);if(JP.existsSync(i))return i}let r=Fc.join(t,"node_modules",".bin",e);if(JP.existsSync(r))return r;let n=Fc.join(S0t,"..","node_modules",".bin",e);if(JP.existsSync(n))return n}import EL from"process";import{fileURLToPath as ZFt}from"url";import{createRequire as JFt}from"module";import rR from"path";import{readFileSync as XFt}from"fs";var T0t="__netlify__getTracer",b0t="__netlify__shutdownTracers",Et=(t,e)=>globalThis[T0t]?.(t,e),e0e=async()=>globalThis[b0t]?.();function nb(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 BFt}from"timers/promises";Oe();import wCt from"process";Oe();var W0t=(t,e)=>{e.recordException(t),e.setStatus({code:Xn.ERROR})};var qc=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}=W0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Y0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=W0e(r,n,i),c=this._tracer.startSpan(e,s,o);return Y0e(c,s,a)}};function W0e(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??Kt.active(),{opts:n,ctx:i,fn:s}}function Y0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:W0t,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)}}Oe();var Jg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var IY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=ixe(e),n._asyncAttributesPending=e.filter(([i,s])=>Jg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Jg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=ixe(this._rawAttributes),this._schemaUrl=Y0t(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,Jg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ce.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Jg(n)){ce.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=K0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function OY(t,e){return IY.FromAttributeList(Object.entries(t),e)}function ixe(t){return t.map(([e,r])=>Jg(r)?[e,r.catch(n=>{ce.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Y0t(t){if(typeof t=="string"||t===void 0)return t;ce.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function K0t(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;ce.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Oe();var mb=class{emit(e){}enabled(){return!1}},sxe=new mb;var gb=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function oxe(t,e,r){return n=>n===t?e:r}var PY=1;var NY=class{getLogger(e,r,n){return new mb}},EN=new NY;var vN=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):sxe}};var _b=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new vN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:EN}_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 TN=class t{constructor(){this._proxyLoggerProvider=new _b}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[gb]?this.getLoggerProvider():(Xg[gb]=oxe(PY,e,EN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[gb])===null||e===void 0?void 0:e.call(Xg,PY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[gb],this._proxyLoggerProvider=new _b}};var axe=TN.getInstance();function cxe(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 lxe(t){t.forEach(e=>e.disable())}function kY(t){let e=t.tracerProvider||Pt.getTracerProvider(),r=t.meterProvider||hb.getMeterProvider(),n=t.loggerProvider||axe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return cxe(i,e,r,n),()=>{lxe(i)}}Oe();var Z0t=on("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function uxe(t){return t.getValue(Z0t)===!0}var Qg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Qg||(Qg={}));Oe();var $Y="[_0-9a-z-*/]",J0t=`[a-z]${$Y}{0,255}`,X0t=`[a-z0-9]${$Y}{0,240}@[a-z]${$Y}{0,13}`,Q0t=new RegExp(`^(?:${J0t}|${X0t})$`),ext=/^[ -~]{0,255}[!-~]$/,txt=/,|=/;function DY(t){return Q0t.test(t)}function LY(t){return ext.test(t)&&!txt.test(t)}var rxt=32,dxe=512,fxe=",",pxe="=",bN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!DY(e)||!LY(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>dxe)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=fxe+e),e=`${n[0]}${pxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(fxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(pxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!DY(a)||!LY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>dxe)&&(r.set(a,c),n=l,r.size>=rxt))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 wN="traceparent",RN="tracestate",nxt="00",ixt="(?!ff)[\\da-f]{2}",sxt="(?![0]{32})[\\da-f]{32}",oxt="(?![0]{16})[\\da-f]{16}",axt="[\\da-f]{2}",cxt=new RegExp(`^\\s?(${ixt})-(${sxt})-(${oxt})-(${axt})(-.*)?\\s?$`);function hxe(t){let e=cxt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Uu=class{inject(e,r,n){let i=Pt.getSpanContext(e);if(!i||uxe(e)||!Mi(i))return;let s=`${nxt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||wr.NONE).toString(16)}`;n.set(r,wN,s),i.traceState&&n.set(r,RN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,wN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=hxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,RN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new bN(typeof c=="string"?c:void 0)}return Pt.setSpanContext(e,o)}fields(){return[wN,RN]}};var AN=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 yb=class{_isCalled=!1;_deferred=new AN;_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 _k=en(vK(),1);Oe();var ZIe=t=>{throw TypeError(t)},RK=(t,e,r)=>e.has(t)||ZIe("Cannot "+r),gk=(t,e,r)=>(RK(t,e,"read from private field"),r?r.call(t):e.get(t)),TK=(t,e,r)=>e.has(t)?ZIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),WIe=(t,e,r,n)=>(RK(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),bCt=(t,e,r)=>(RK(t,e,"access private method"),r),YIe="__netlify__getTracer",RCt="__netlify__shutdownTracers",ACt="__nfOTLPTrace",kb,$b,wK,JIe,xCt=class{constructor(){TK(this,wK),TK(this,kb),TK(this,$b),WIe(this,kb,new yb(bCt(this,wK,JIe),this)),WIe(this,$b,ce.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(gk(this,$b).debug(`export ${t.length.toString()} spans`),gk(this,kb).isCalled){e({code:Qg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(ACt,JSON.stringify(CCt(t))),e({code:Qg.SUCCESS})}shutdown(){return gk(this,kb).call()}};kb=new WeakMap;$b=new WeakMap;wK=new WeakSet;JIe=function(){return gk(this,$b).debug("Shutting down"),Promise.resolve()};function CCt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:mk(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||So.SERVER,startTimeUnixNano:bK(e.startTime),endTimeUnixNano:bK(e.endTime),attributes:mk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:bK(n.time),attributes:mk(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:mk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function mk(t){return Object.keys(t).map(e=>XIe(e,t[e]))}function XIe(t,e){return{key:t,value:QIe(e)}}function QIe(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(QIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>XIe(r,n))}}:{}}function bK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var KIe={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"}},eOe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,YIe))return;let e=wCt.version.slice(1),r=OY({"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??[ICt()],i=new _k.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Uu});let s=t.instrumentations??[];kY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,YIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new qc(Pt.getTracer(a,c)):new qc(Pt.getTracer(KIe.name,KIe.version))}}),Object.defineProperty(globalThis,RCt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},ICt=()=>new _k.SimpleSpanProcessor(new xCt);Oe();var Db=en(vK(),1);Oe();import*as yk from"diagnostics_channel";var tOe=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?Xn.ERROR:Xn.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],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof qc?t:new qc(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){yk.subscribe(t,e);let r=()=>yk.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:So.CLIENT},Kt.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:Xn.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 R1e=en(b1e(),1);var yL=fe("tracing"),w1e=8e3,VFt=5e3,Qw=async(t=VFt)=>{try{await Promise.race([e0e(),BFt(t)])}catch(e){yL.warn("Failed to flush tracers on shutdown",e)}},A1e=async(t,e,r)=>{if(!Et()){let n=[new Db.SimpleSpanProcessor(new AJ),new Db.SimpleSpanProcessor(new R1e.OTLPTraceExporter({url:r.exporterUrl}))];await eOe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new tOe({skipHeaders:!0})]})}return r.traceparent?(mi.setGlobalPropagator(new Uu),mi.extract(Kt.active(),{traceparent:r.traceparent,isRemote:!0})):Kt.active()};function Xt(t,e,r){return yL.log(`\u23F3 TRACE: ${e} starting...`),nb(t,e,r)}var AJ=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(", ")}]`:"";yL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&yL.log(` \u274C Error: ${e.status.message}`)}};function xJ(){return Ze().captureLlmContentEnabled}function x1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function SL(t,e,r){let n={role:t,parts:[{type:"text",content:Li(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var HFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function C1e(t,e,r,n){if(!t.length)return;let i=Et();if(!i)return;let s=xJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&HFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?a.message.length>w1e?`${a.message.slice(0,w1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":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":Li(g)}:{"gen_ai.output.messages":SL("assistant",g)}:{}}}).end(u)})}import{readdir as GFt,rm as WFt}from"fs/promises";import{join as YFt}from"path";async function I1e(t,e=[]){let n=(await GFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>WFt(YFt(t,i),{recursive:!0,force:!0})))}var KFt=300,eR=t=>Ze().budgetCreditThresholds[t.mode]?.[t.runner]??KFt,tR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var CJ=t=>{let e=eR(t);if(!tR(t,e))return"default";let r=Ze();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},O1e=t=>{let e=CJ(t),r=eR(t);return{budget_eligible:tR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var QFt=rR.dirname(ZFt(import.meta.url)),P1e=JFt(import.meta.url),ejt=rR.resolve(QFt,"scripts/scaffold.js"),tjt="scripts/scaffold.js",rjt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,IJ=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},njt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),ijt=t=>{let e=IJ(t);return e==="node"||e.endsWith("/node")},fl=t=>{if(typeof t!="string")return!1;let e=t.match(rjt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&njt(IJ(e[r]));)r+=1;if(r>=e.length||!ijt(e[r]))return!1;let n=e[r+1];return n?IJ(n).includes(tjt):!1},zp=fe("create_stage"),OJ="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.",sjt=`${OJ}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as xwt}from"buffer";import{StringDecoder as Cwt}from"string_decoder";var DP=(t,e,r)=>{if(r)return;if(t)return{transform:Iwt.bind(void 0,new TextEncoder)};let n=new Cwt(e);return{transform:Owt.bind(void 0,n),final:Pwt.bind(void 0,n)}},Iwt=function*(t,e){xwt.isBuffer(e)?yield Dc(e):typeof e=="string"?yield t.encode(e):yield e},Owt=function*(t,e){yield Wr(e)?t.write(e):e},Pwt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as fRe}from"util";var uW=fRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LP=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kwt}=e[r];for await(let i of n(t))yield*LP(i,e,r+1)},pRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Nwt(r,Number(e),t)},Nwt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LP(n,r,e+1)},hRe=fRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),kwt=function*(t){yield t};var dW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},mRe=(t,e)=>[...e.flatMap(r=>[...Qf(r,t,0)]),...KT(t)],Qf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Dwt}=e[r];for(let i of n(t))yield*Qf(i,e,r+1)},KT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$wt(r,Number(e),t)},$wt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Qf(n,r,e+1)},Dwt=function*(t){yield t};var fW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=_Re(t,o,s),l=Xf(e),u=Xf(r),d=l?uW.bind(void 0,LP,a):dW.bind(void 0,Qf),f=l||u?uW.bind(void 0,pRe,a):dW.bind(void 0,KT),p=l||u?hRe.bind(void 0,a):void 0;return{stream:new Lwt({writableObjectMode:n,writableHighWaterMark:gRe(n),readableObjectMode:i,readableHighWaterMark:gRe(i),transform(m,g,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},MP=(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=_Re(o,r,a);t=mRe(c,t)}return t},_Re=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:lRe(n,a)},DP(r,o,n),$P(r,s,n,c),{transform:t,final:e},{transform:uRe(i,a)},cRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var yRe=(t,e)=>{for(let r of Mwt(t))Uwt(t,r,e)},Mwt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Uwt=(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 ${$u[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Fwt(a,n));r.input=FT(o)},Fwt=(t,e)=>{let r=MP(t,e,"utf8",!0);return jwt(r),FT(r)},jwt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(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 Vwt,appendFileSync as Hwt}from"fs";var UP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Og(r,n)&&!Qi.has(e)&&zwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&qwt.has(s))||t.every(({type:i})=>Ls.has(i))),zwt=t=>t===1||t===2,qwt=new Set(["pipe","overlapped"]),SRe=async(t,e,r,n)=>{for await(let i of t)Bwt(e)||vRe(i,r,n)},ERe=(t,e,r)=>{for(let n of t)vRe(n,e,r)},Bwt=t=>t._readableState.pipes.length>0,vRe=(t,e,r)=>{let n=XO(t);ga({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var TRe=({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,l)=>Gwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Gwt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=bwe(t,s,d),p=Dc(f),{stdioItems:h,objectMode:m}=e[r],g=Wwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=Ywt({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Kwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&Zwt(S,h,i),y}catch(_){return n.error=_,y}},Wwt=(t,e,r,n)=>{try{return MP(t,e,r,!1)}catch(i){return n.error=i,t}},Ywt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:FT(t)};let o=Mve(t,r);return n[s]?{serializedResult:o,finalResult:lW(o,!i[s],e)}:{serializedResult:o}},Kwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!UP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=lW(t,!1,o);try{ERe(a,e,n)}catch(c){r.error??=c}},Zwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>NP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Hwt(n,t):(r.add(s),Vwt(n,t))}};var bRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Uc(e,r,"all")]:Array.isArray(e)?[Uc(t,r,"all"),...e]:Wr(t)&&Wr(e)?y3([t,e]):`${t}${e}`};import{once as pW}from"events";var wRe=async(t,e)=>{let[r,n]=await Jwt(t);return e.isForcefullyTerminated??=!1,[r,n]},Jwt=async t=>{let[e,r]=await Promise.allSettled([pW(t,"spawn"),pW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?RRe(t):r.value},RRe=async t=>{try{return await pW(t,"exit")}catch{return RRe(t)}},ARe=async t=>{let[e,r]=await t;if(!Xwt(e,r)&&hW(e,r))throw new go;return[e,r]},Xwt=(t,e)=>t===void 0&&e===void 0,hW=(t,e)=>t!==0||e!==null;var xRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Qwt(t,e,r),o=s?.code==="ETIMEDOUT",a=Twe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Qwt=(t,e,r)=>t!==void 0?t:hW(e,r)?new go:void 0;var CRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=tRt(t,e,r),d=iRt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return jg(d,c,l)},tRt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=eP(t,e,r),a=rRt(r),{file:c,commandArguments:l,options:u}=EP(t,e,a);nRt(u);let d=iRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},rRt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,nRt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&FP("ipcInput"),t&&FP("ipc: true"),r&&FP("detached: true"),n&&FP("cancelSignal")},FP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},iRt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=sRt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=xRe(c,r),{output:h,error:m=l}=TRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,y)=>Uc(E,r,y)),S=Uc(bRe(h,r),r,"all");return aRt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},sRt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{yRe(s,r);let a=oRt(r);return eRt(...vP(t,e,a))}catch(a){return Fg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},oRt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:CP(e)}),aRt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?IP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):YT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as YAt}from"events";import{spawn as KAt}from"child_process";import kRe from"process";import{once as mW,on as cRt}from"events";var IRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(kg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:hP(t)}),lRt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),lRt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{uP(e,i);let s=ku(t,e,r),o=new AbortController;try{return await Promise.race([uRt(s,n,o),dRt(s,r,o),fRt(s,r,o)])}catch(a){throw $g(t),a}finally{o.abort(),dP(e,i)}},uRt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await mW(t,"message",{signal:r});return n}for await(let[n]of cRt(t,"message",{signal:r}))if(e(n))return n},dRt=async(t,e,{signal:r})=>{await mW(t,"disconnect",{signal:r}),mbe(e)},fRt=async(t,e,{signal:r})=>{let[n]=await mW(t,"strict:error",{signal:r});throw aP(n,e)};import{once as PRe,on as pRt}from"events";var NRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>gW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),gW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{kg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:hP(t)}),uP(e,s);let o=ku(t,e,r),a=new AbortController,c={};return hRt(t,o,a),mRt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),gRt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},hRt=async(t,e,r)=>{try{await PRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},mRt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await PRe(t,"strict:error",{signal:r.signal});n.error=aP(i,e),r.abort()}catch{}},gRt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of pRt(r,"message",{signal:s.signal}))ORe(o),yield c}catch{ORe(o)}finally{s.abort(),dP(e,a),n||$g(t),i&&await t}},ORe=({error:t})=>{if(t)throw t};var $Re=(t,{ipc:e})=>{Object.assign(t,LRe(t,!1,e))},DRe=()=>{let t=kRe,e=!0,r=kRe.channel!==void 0;return{...LRe(t,e,r),getCancelSignal:qbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},LRe=(t,e,r)=>({sendMessage:yP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:IRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:NRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as _Rt}from"child_process";import{PassThrough as yRt,Readable as SRt,Writable as ERt,Duplex as vRt}from"stream";var MRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{oW(n);let a=new _Rt;TRt(a,n),Object.assign(a,{readable:bRt,writable:wRt,duplex:RRt});let c=Fg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=ARt(c,o,i);return{subprocess:a,promise:l}},TRt=(t,e)=>{let r=ZT(),n=ZT(),i=ZT(),s=Array.from({length:e.length-3},ZT),o=ZT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},ZT=()=>{let t=new yRt;return t.end(),t},bRt=()=>new SRt({read(){}}),wRt=()=>new ERt({write(){}}),RRt=()=>new vRt({read(){},write(){}}),ARt=async(t,e,r)=>jg(t,e,r);import{createReadStream as URe,createWriteStream as FRe}from"fs";import{Buffer as xRt}from"buffer";import{Readable as JT,Writable as CRt,Duplex as IRt}from"stream";var zRe=(t,e)=>kP(ORt,t,e,!1),XT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$u[t]}.`)},jRe={fileNumber:XT,generator:fW,asyncGenerator:fW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:IRt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ORt={input:{...jRe,fileUrl:({value:t})=>({stream:URe(t)}),filePath:({value:{file:t}})=>({stream:URe(t)}),webStream:({value:t})=>({stream:JT.fromWeb(t)}),iterable:({value:t})=>({stream:JT.from(t)}),asyncIterable:({value:t})=>({stream:JT.from(t)}),string:({value:t})=>({stream:JT.from(t)}),uint8Array:({value:t})=>({stream:JT.from(xRt.from(t))})},output:{...jRe,fileUrl:({value:t})=>({stream:FRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:FRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:CRt.fromWeb(t)}),iterable:XT,asyncIterable:XT,string:XT,uint8Array:XT}};import{on as PRt,once as qRe}from"events";import{PassThrough as NRt,getDefaultHighWaterMark as kRt}from"stream";import{finished as HRe}from"stream/promises";function ep(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)yW(i);let e=t.some(({readableObjectMode:i})=>i),r=$Rt(t,e),n=new _W({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var $Rt=(t,e)=>{if(t.length===0)return kRt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},_W=class extends NRt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(yW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=DRt(this,this.#e,this.#s);let r=URt({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(yW(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)}},DRt=async(t,e,r)=>{jP(t,BRe);let n=new AbortController;try{await Promise.race([LRt(t,n),MRt(t,e,r,n)])}finally{n.abort(),jP(t,-BRe)}},LRt=async(t,{signal:e})=>{try{await HRe(t,{signal:e,cleanup:!0})}catch(r){throw GRe(t,r),r}},MRt=async(t,e,r,{signal:n})=>{for await(let[i]of PRt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},yW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},URt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{jP(t,VRe);let a=new AbortController;try{await Promise.race([FRt(s,e,a),jRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),zRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),jP(t,-VRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?SW(t):qRt(t))},FRt=async(t,e,{signal:r})=>{try{await t,r.aborted||SW(e)}catch(n){r.aborted||GRe(e,n)}},jRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await HRe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;WRe(o)?i.add(e):YRe(t,o)}},zRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await qRe(t,i,{signal:s}),!t.readable)return qRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},qRt=t=>{t.writable&&t.end()},GRe=(t,e)=>{WRe(e)?SW(t):YRe(t,e)},WRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",SW=t=>{(t.readable||t.writable)&&t.destroy()},YRe=(t,e)=>{t.destroyed||(t.once("error",BRt),t.destroy(e))},BRt=()=>{},jP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},BRe=2,VRe=1;import{finished as KRe}from"stream/promises";var qg=(t,e)=>{t.pipe(e),VRt(t,e),HRt(t,e)},VRt=async(t,e)=>{if(!(mo(t)||mo(e))){try{await KRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}EW(e)}},EW=t=>{t.writable&&t.end()},HRt=async(t,e)=>{if(!(mo(t)||mo(e))){try{await KRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}vW(t)}},vW=t=>{t.readable&&t.destroy()};var ZRe=(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})=>Ls.has(c)))GRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ls.has(c)))YRt({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]:ep(s);qg(o,i)}},GRt=(t,e,r,n)=>{r==="output"?qg(t.stdio[n],e):qg(e,t.stdio[n]);let i=WRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},WRt=["stdin","stdout","stderr"],YRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;KRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},KRt=(t,{signal:e})=>{mo(t)&&Zf(t,ZRt,e)},ZRt=2;import{addAbortListener as QRt}from"events";var tp=[];tp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&tp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&tp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var zP=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",TW=Symbol.for("signal-exit emitter"),bW=globalThis,JRt=Object.defineProperty.bind(Object),wW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bW[TW])return bW[TW];JRt(bW,TW,{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}},qP=class{},XRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RW=class extends qP{onExit(){return()=>{}}load(){}unload(){}},AW=class extends qP{#e=xW.platform==="win32"?"SIGINT":"SIGHUP";#r=new wW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of tp)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(!zP(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 tp)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,tp.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 zP(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"&&zP(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)}},xW=globalThis.process,{onExit:JRe,load:jgr,unload:zgr}=XRt(zP(xW)?new AW(xW):new RW);var XRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=JRe(()=>{t.kill()});QRt(n,()=>{i()})};var eAe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=QO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=eAt(r,n,i),{sourceStream:d,sourceError:f}=rAt(t,l),{options:p,fileDescriptors:h}=ya.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},eAt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=tAt(t,e,...r),a=lP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},tAt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(QRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||g3(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]=BO(r,...n);return{destination:e(QRe)(i,s,o),pipeOptions:o}}if(ya.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}`)},QRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),rAt=(t,e)=>{try{return{sourceStream:Dg(t,e)}}catch(r){return{sourceError:r}}};var rAe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=nAt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw CW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},nAt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return vW(t),n;if(e!==void 0)return EW(r),e},CW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Fg({error:t,command:tAe,escapedCommand:tAe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),tAe="source.pipe(destination)";var nAe=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 iAt}from"stream/promises";var iAe=(t,e,r)=>{let n=BP.has(e)?oAt(t,e):sAt(t,e);return Zf(t,cAt,r.signal),Zf(e,lAt,r.signal),aAt(e),n},sAt=(t,e)=>{let r=ep([t]);return qg(r,e),BP.set(e,r),r},oAt=(t,e)=>{let r=BP.get(e);return r.add(t),r},aAt=async t=>{try{await iAt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}BP.delete(t)},BP=new WeakMap,cAt=2,lAt=1;import{aborted as uAt}from"util";var sAe=(t,e)=>t===void 0?[]:[dAt(t,e)],dAt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await uAt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw CW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var VP=(t,...e)=>{if(Nr(e[0]))return VP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=eAe(t,...e),i=fAt({...n,destination:r});return i.pipe=VP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},fAt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=pAt(t,i);rAe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=iAe(e,s,d);return await Promise.race([nAe(u),...sAe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},pAt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as EAt}from"timers/promises";import{on as hAt}from"events";import{getDefaultHighWaterMark as mAt}from"stream";var HP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return gAt(e,o),aAe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},gAt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},IW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;_At(e,o,t);let a=t.readableObjectMode&&!s;return aAe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},_At=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},aAe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=hAt(t,"data",{signal:e.signal,highWaterMark:oAe,highWatermark:oAe});return yAt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},OW=mAt(!0),oAe=OW,yAt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=SAt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Qf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*KT(a)}},SAt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[DP(t,r,!e),$P(t,i,!n,{})].filter(Boolean);var cAe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=vAt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([TAt(t),d]);return}let f=aW(c,r),p=IW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([bAt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},vAt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!UP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=IW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await SRe(a,t,r,s)},TAt=async t=>{await EAt(),t.readableFlowing===null&&t.resume()},bAt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await RP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await AP(r,{maxBuffer:s})):await Ug(r,{maxBuffer:s})}catch(a){return lAe(Swe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},PW=async t=>{try{return await t}catch(e){return lAe(e)}},lAe=({bufferedData:t})=>Dve(t)?new Uint8Array(t):t;import{finished as wAt}from"stream/promises";var QT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=RAt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],wAt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||CAt(a,e,r,n)}finally{o.abort()}},RAt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&AAt(t,r,n),n},AAt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{xAt(e,r),n.call(t,...i)}},xAt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},CAt=(t,e,r,n)=>{if(!IAt(t,e,r,n))throw t},IAt=(t,e,r,n=!0)=>r.propagating?uAe(t)||GP(t):(r.propagating=!0,NW(r,e)===n?uAe(t):GP(t)),NW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",GP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",uAe=t=>t?.code==="EPIPE";var dAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>kW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),kW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=QT(t,e,l);if(NW(l,e)){await u;return}let[d]=await Promise.all([cAe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var fAe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?ep([t,e].filter(Boolean)):void 0,pAe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>kW({...OAt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:PAt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),OAt=({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}},PAt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as NAt}from"events";var hAe=t=>Og(t,"ipc"),mAe=(t,e)=>{let r=XO(t);ga({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var gAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=hAe(s),a=Lc(e,"ipc"),c=Lc(r,"ipc");for await(let l of gW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ewe(t,i,c),i.push(l)),o&&mAe(l,s);return i},_Ae=async(t,e)=>(await Promise.allSettled([t]),e);var yAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:S})=>{let E=wRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=dAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=pAe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],R=gAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=kAt(m,t,y),C=$At(h,y);try{return await Promise.race([Promise.all([{},ARe(E),Promise.all(_),T,R,Xbe(t,d),...b,...C]),g,DAt(t,S),...Wbe(t,s,f,S),...hbe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Hbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(x=>PW(x))),PW(T),_Ae(R,w),Promise.allSettled(b),Promise.allSettled(C)])}},kAt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:QT(n,i,r)),$At=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>yo(s,{checkOpen:!1})&&!mo(s)).map(({type:i,value:s,stream:o=s})=>QT(o,n,e,{isSameDirection:Ls.has(i),stopOnExit:i==="native"}))),DAt=async(t,{signal:e})=>{let[r]=await NAt(t,"error",{signal:e});throw r};var SAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=_a();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Bg=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 LAt}from"stream";import{callbackify as MAt}from"util";import{finished as EAe}from"stream/promises";var $W=async t=>{if(t!==void 0)try{await DW(t)}catch{}},vAe=async t=>{if(t!==void 0)try{await LW(t)}catch{}},DW=async t=>{await EAe(t,{cleanup:!0,readable:!1,writable:!0})},LW=async t=>{await EAe(t,{cleanup:!0,readable:!0,writable:!1})},WP=async(t,e)=>{if(await t,e)throw e},YP=(t,e,r)=>{r&&!GP(r)?t.destroy(r):e&&t.destroy()};var TAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Qi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=MW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=UW(a,o),{read:f,onStdoutDataDone:p}=FW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new LAt({read:f,destroy:MAt(zW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return jW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},MW=(t,e,r)=>{let n=Dg(t,e),i=eb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},UW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:OW},FW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=_a(),o=HP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){UAt(this,o,s)},onStdoutDataDone:s}},UAt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},jW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LW(t),await n,await $W(i),await e,r.readable&&r.push(null)}catch(s){await $W(i),bAe(r,s)}},zW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bg(r,e)&&(bAe(t,n),await WP(e,n))},bAe=(t,e)=>{YP(t,t.readable,e)};import{Writable as FAt}from"stream";import{callbackify as wAe}from"util";var RAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=qW(t,r,e),o=new FAt({...BW(n,t,i),destroy:wAe(HW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return VW(n,o),o},qW=(t,e,r)=>{let n=lP(t,e),i=eb(r,n,"writableFinal"),s=eb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},BW=(t,e,r)=>({write:jAt.bind(void 0,t),final:wAe(zAt.bind(void 0,t,e,r))}),jAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},zAt=async(t,e,r)=>{await Bg(r,e)&&(t.writable&&t.end(),await e)},VW=async(t,e,r)=>{try{await DW(t),e.writable&&e.end()}catch(n){await vAe(r),AAe(e,n)}},HW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bg(r,e),await Bg(n,e)&&(AAe(t,i),await WP(e,i))},AAe=(t,e)=>{YP(t,t.writable,e)};import{Duplex as qAt}from"stream";import{callbackify as BAt}from"util";var xAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Qi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=MW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=qW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=UW(c,a),{read:g,onStdoutDataDone:S}=FW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new qAt({read:g,...BW(u,t,d),destroy:BAt(VAt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return jW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),VW(u,E,c),E},VAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([zW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var GW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Qi.has(e),o=Dg(t,r),a=HP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return HAt(a,o,t)},HAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var CAe=(t,{encoding:e})=>{let r=SAe();t.readable=TAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=RAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=xAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=GW.bind(void 0,t,e),t[Symbol.asyncIterator]=GW.bind(void 0,t,e,{})};var IAe=(t,e)=>{for(let[r,n]of WAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},GAt=(async()=>{})().constructor.prototype,WAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(GAt,t)]);var OAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ZAt(t,e,r),{subprocess:f,promise:p}=XAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=VP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),IAe(f,p),ya.set(f,{options:u,fileDescriptors:d}),f},ZAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=eP(t,e,r),{file:a,commandArguments:c,options:l}=EP(t,e,r),u=JAt(l),d=zRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},JAt=({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}},XAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=KAt(...vP(t,e,r))}catch(h){return MRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;YAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ZRe(c,a,l),XRe(c,r,l);let d={},f=_a();c.kill=fbe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=fAe(c,r),CAe(c,r),$Re(c,r);let p=QAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},QAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await yAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((_,T)=>Uc(_,e,T)),E=Uc(m,e,"all"),y=e0t({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return jg(y,n,e)},e0t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?YT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Sa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):IP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var KP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,t0t(n,t[n],i)]));return{...t,...r}},t0t=(t,e,r)=>r0t.has(t)&&Nr(e)&&Nr(r)?{...e,...r}:r,r0t=new Set(["env",...T3]);var Du=(t,e,r,n)=>{let i=(o,a,c)=>Du(o,a,r,c),s=(...o)=>n0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},n0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Nr(s))return i(t,KP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=i0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?CRe(a,c,l):OAe(a,c,l,i)},i0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=zve(e)?qve(e,r):[e,...r],[o,a,c]=BO(...s),l=KP(KP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var PAe=({file:t,commandArguments:e})=>kAe(t,e),NAe=({file:t,commandArguments:e})=>({...kAe(t,e),isSync:!0}),kAe=(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]=s0t(t);return{file:r,commandArguments:n}},s0t=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(o0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},o0t=/ +/g;var $Ae=(t,e,r)=>{t.sync=e(a0t,r),t.s=t.sync},DAe=({options:t})=>LAe(t),a0t=({options:t})=>({...LAe(t),isSync:!0}),LAe=t=>({options:{...c0t(t),...t}}),c0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},MAe={preferLocal:!0};var UAe=Du(()=>({})),OSr=Du(()=>({isSync:!0})),FAe=Du(PAe),PSr=Du(NAe),NSr=Du(Kbe),kSr=Du(DAe,{},MAe,$Ae),{sendMessage:$Sr,getOneMessage:DSr,getEachMessage:LSr,getCancelSignal:MSr}=DRe();import{Transform as l0t}from"stream";var u0t=["NETLIFY_AI_GATEWAY_KEY"];function d0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...u0t])]}function f0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function p0t(){let e=d0t().map(r=>process.env[r]).filter(r=>!(!r||f0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Li(t){if(typeof t!="string")return t;let e=p0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(h0t(n),"g");r=r.replace(i,"******")}),r}function h0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tb=class extends l0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Li(i);n(null,s)}},ZP=Symbol("maskedWrite");function jAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[ZP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Li(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[ZP]=!0,process.stdout.write=r}if(!process.stderr.write[ZP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Li(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[ZP]=!0,process.stderr.write=r}}}var zAe=!1,qAe,WW=t=>{qAe??=t},BAe=t=>{zAe=!0,WW(t)},kn=()=>zAe,va=()=>qAe,VAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var rb=null,HAe=t=>(rb&&rb.destroy(),rb=new Ms({totalAllowedTime:t}),rb),GAe=()=>rb;var Ms=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&&kn())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((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await FO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{X.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 WAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.194.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.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.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var y0t=g0t(import.meta.url),S0t=Fc.dirname(y0t),E0t=_0t(import.meta.url),Vg=fe("shell"),YW=new Set,YAe={preferLocal:!0},ar=(t,e,r)=>{let[n,i]=v0t(e,r),s={...YAe,...i},o=UAe(t,n,s);ZAe(o,s),QAe(o);let a=r?.idleTimeout;return a&&a>0&&XAe(o,a),o},KAe=(t,e)=>{let r={...YAe,...e},n=FAe(t,r);return ZAe(n,r),QAe(n),e?.idleTimeout&&e.idleTimeout>0&&XAe(n,e.idleTimeout),n},v0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ZAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ta.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ta.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tb).pipe(Ta.stdout),t.stderr?.pipe(new tb).pipe(Ta.stderr);return}t.stdout?.pipe(Ta.stdout),t.stderr?.pipe(Ta.stderr)},KW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ta.kill(-t.pid,e),Vg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Vg.error("Error killing process:",r),!1}},JAe=t=>KW(t,"SIGKILL"),XAe=(t,e)=>{let r=null,n=()=>{Vg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing idle process ${t.pid}`),JAe(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)},QAe=t=>{YW.add(t);let e=GAe();if(e){let r=e.onTimesUp(()=>{Vg.log(`Global timer expired, killing process ${t.pid}`),KW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing process ${t.pid} after timeout`),JAe(t))},5e3)});t.on("exit",()=>{YW.delete(t),r()}),t.on("error",()=>{YW.delete(t),r()})}};function ba(t,e){if(!Ta.env.NETLIFY_LOCAL_MODE)try{let i=E0t.resolve(WAe.name),s=Fc.dirname(i);for(;s!==Fc.dirname(s);){let o=Fc.dirname(s);if(Fc.basename(o)==="node_modules"){let a=Fc.join(o,".bin",e);if(JP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ta.env.NODE_PATH){let i=Fc.join(Ta.env.NODE_PATH,".bin",e);if(JP.existsSync(i))return i}let r=Fc.join(t,"node_modules",".bin",e);if(JP.existsSync(r))return r;let n=Fc.join(S0t,"..","node_modules",".bin",e);if(JP.existsSync(n))return n}import EL from"process";import{fileURLToPath as ZFt}from"url";import{createRequire as JFt}from"module";import rR from"path";import{readFileSync as XFt}from"fs";var T0t="__netlify__getTracer",b0t="__netlify__shutdownTracers",Et=(t,e)=>globalThis[T0t]?.(t,e),e0e=async()=>globalThis[b0t]?.();function nb(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 BFt}from"timers/promises";Oe();import wCt from"process";Oe();var W0t=(t,e)=>{e.recordException(t),e.setStatus({code:Xn.ERROR})};var qc=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}=W0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Y0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=W0e(r,n,i),c=this._tracer.startSpan(e,s,o);return Y0e(c,s,a)}};function W0e(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??Kt.active(),{opts:n,ctx:i,fn:s}}function Y0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:W0t,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)}}Oe();var Jg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var IY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=ixe(e),n._asyncAttributesPending=e.filter(([i,s])=>Jg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Jg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=ixe(this._rawAttributes),this._schemaUrl=Y0t(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,Jg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ce.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Jg(n)){ce.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=K0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function OY(t,e){return IY.FromAttributeList(Object.entries(t),e)}function ixe(t){return t.map(([e,r])=>Jg(r)?[e,r.catch(n=>{ce.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Y0t(t){if(typeof t=="string"||t===void 0)return t;ce.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function K0t(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;ce.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Oe();var mb=class{emit(e){}enabled(){return!1}},sxe=new mb;var gb=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function oxe(t,e,r){return n=>n===t?e:r}var PY=1;var NY=class{getLogger(e,r,n){return new mb}},EN=new NY;var vN=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):sxe}};var _b=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new vN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:EN}_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 TN=class t{constructor(){this._proxyLoggerProvider=new _b}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[gb]?this.getLoggerProvider():(Xg[gb]=oxe(PY,e,EN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[gb])===null||e===void 0?void 0:e.call(Xg,PY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[gb],this._proxyLoggerProvider=new _b}};var axe=TN.getInstance();function cxe(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 lxe(t){t.forEach(e=>e.disable())}function kY(t){let e=t.tracerProvider||Pt.getTracerProvider(),r=t.meterProvider||hb.getMeterProvider(),n=t.loggerProvider||axe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return cxe(i,e,r,n),()=>{lxe(i)}}Oe();var Z0t=on("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function uxe(t){return t.getValue(Z0t)===!0}var Qg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Qg||(Qg={}));Oe();var $Y="[_0-9a-z-*/]",J0t=`[a-z]${$Y}{0,255}`,X0t=`[a-z0-9]${$Y}{0,240}@[a-z]${$Y}{0,13}`,Q0t=new RegExp(`^(?:${J0t}|${X0t})$`),ext=/^[ -~]{0,255}[!-~]$/,txt=/,|=/;function DY(t){return Q0t.test(t)}function LY(t){return ext.test(t)&&!txt.test(t)}var rxt=32,dxe=512,fxe=",",pxe="=",bN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!DY(e)||!LY(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>dxe)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=fxe+e),e=`${n[0]}${pxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(fxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(pxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!DY(a)||!LY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>dxe)&&(r.set(a,c),n=l,r.size>=rxt))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 wN="traceparent",RN="tracestate",nxt="00",ixt="(?!ff)[\\da-f]{2}",sxt="(?![0]{32})[\\da-f]{32}",oxt="(?![0]{16})[\\da-f]{16}",axt="[\\da-f]{2}",cxt=new RegExp(`^\\s?(${ixt})-(${sxt})-(${oxt})-(${axt})(-.*)?\\s?$`);function hxe(t){let e=cxt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Uu=class{inject(e,r,n){let i=Pt.getSpanContext(e);if(!i||uxe(e)||!Mi(i))return;let s=`${nxt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||wr.NONE).toString(16)}`;n.set(r,wN,s),i.traceState&&n.set(r,RN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,wN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=hxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,RN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new bN(typeof c=="string"?c:void 0)}return Pt.setSpanContext(e,o)}fields(){return[wN,RN]}};var AN=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 yb=class{_isCalled=!1;_deferred=new AN;_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 _k=en(vK(),1);Oe();var ZIe=t=>{throw TypeError(t)},RK=(t,e,r)=>e.has(t)||ZIe("Cannot "+r),gk=(t,e,r)=>(RK(t,e,"read from private field"),r?r.call(t):e.get(t)),TK=(t,e,r)=>e.has(t)?ZIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),WIe=(t,e,r,n)=>(RK(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),bCt=(t,e,r)=>(RK(t,e,"access private method"),r),YIe="__netlify__getTracer",RCt="__netlify__shutdownTracers",ACt="__nfOTLPTrace",kb,$b,wK,JIe,xCt=class{constructor(){TK(this,wK),TK(this,kb),TK(this,$b),WIe(this,kb,new yb(bCt(this,wK,JIe),this)),WIe(this,$b,ce.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(gk(this,$b).debug(`export ${t.length.toString()} spans`),gk(this,kb).isCalled){e({code:Qg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(ACt,JSON.stringify(CCt(t))),e({code:Qg.SUCCESS})}shutdown(){return gk(this,kb).call()}};kb=new WeakMap;$b=new WeakMap;wK=new WeakSet;JIe=function(){return gk(this,$b).debug("Shutting down"),Promise.resolve()};function CCt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:mk(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||So.SERVER,startTimeUnixNano:bK(e.startTime),endTimeUnixNano:bK(e.endTime),attributes:mk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:bK(n.time),attributes:mk(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:mk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function mk(t){return Object.keys(t).map(e=>XIe(e,t[e]))}function XIe(t,e){return{key:t,value:QIe(e)}}function QIe(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(QIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>XIe(r,n))}}:{}}function bK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var KIe={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"}},eOe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,YIe))return;let e=wCt.version.slice(1),r=OY({"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??[ICt()],i=new _k.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Uu});let s=t.instrumentations??[];kY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,YIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new qc(Pt.getTracer(a,c)):new qc(Pt.getTracer(KIe.name,KIe.version))}}),Object.defineProperty(globalThis,RCt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},ICt=()=>new _k.SimpleSpanProcessor(new xCt);Oe();var Db=en(vK(),1);Oe();import*as yk from"diagnostics_channel";var tOe=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?Xn.ERROR:Xn.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],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof qc?t:new qc(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){yk.subscribe(t,e);let r=()=>yk.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:So.CLIENT},Kt.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:Xn.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 R1e=en(b1e(),1);var yL=fe("tracing"),w1e=8e3,VFt=5e3,Qw=async(t=VFt)=>{try{await Promise.race([e0e(),BFt(t)])}catch(e){yL.warn("Failed to flush tracers on shutdown",e)}},A1e=async(t,e,r)=>{if(!Et()){let n=[new Db.SimpleSpanProcessor(new AJ),new Db.SimpleSpanProcessor(new R1e.OTLPTraceExporter({url:r.exporterUrl}))];await eOe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new tOe({skipHeaders:!0})]})}return r.traceparent?(mi.setGlobalPropagator(new Uu),mi.extract(Kt.active(),{traceparent:r.traceparent,isRemote:!0})):Kt.active()};function Xt(t,e,r){return yL.log(`\u23F3 TRACE: ${e} starting...`),nb(t,e,r)}var AJ=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(", ")}]`:"";yL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&yL.log(` \u274C Error: ${e.status.message}`)}};function xJ(){return Ze().captureLlmContentEnabled}function x1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function SL(t,e,r){let n={role:t,parts:[{type:"text",content:Li(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var HFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function C1e(t,e,r,n){if(!t.length)return;let i=Et();if(!i)return;let s=xJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&HFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?a.message.length>w1e?`${a.message.slice(0,w1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":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":Li(g)}:{"gen_ai.output.messages":SL("assistant",g)}:{}}}).end(u)})}import{readdir as GFt,rm as WFt}from"fs/promises";import{join as YFt}from"path";async function I1e(t,e=[]){let n=(await GFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>WFt(YFt(t,i),{recursive:!0,force:!0})))}var KFt=300,eR=t=>Ze().budgetCreditThresholds[t.mode]?.[t.runner]??KFt,tR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var CJ=t=>{let e=eR(t);if(!tR(t,e))return"default";let r=Ze();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},O1e=t=>{let e=CJ(t),r=eR(t);return{budget_eligible:tR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var QFt=rR.dirname(ZFt(import.meta.url)),P1e=JFt(import.meta.url),ejt=rR.resolve(QFt,"scripts/scaffold.js"),tjt="scripts/scaffold.js",rjt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,IJ=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},njt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),ijt=t=>{let e=IJ(t);return e==="node"||e.endsWith("/node")},fl=t=>{if(typeof t!="string")return!1;let e=t.match(rjt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&njt(IJ(e[r]));)r+=1;if(r>=e.length||!ijt(e[r]))return!1;let n=e[r+1];return n?IJ(n).includes(tjt):!1},zp=fe("create_stage"),OJ="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.",sjt=`${OJ}
|
|
598
598
|
|
|
599
599
|
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.`,ojt=`${OJ}
|
|
600
600
|
|
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
142
142
|
`,LF:`
|
|
143
143
|
`,concatBytes:$U},hVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},mVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:hVe};import{Buffer as gVe}from"buffer";var Mae=(t,e)=>t?void 0:_Ve.bind(void 0,e),_Ve=function*(t,e){if(typeof e!="string"&&!hr(e)&&!gVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Dae=(t,e)=>t?yVe.bind(void 0,e):SVe.bind(void 0,e),yVe=function*(t,e){$ae(t,e),yield e},SVe=function*(t,e){if($ae(t,e),typeof e!="string"&&!hr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},$ae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
144
144
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
145
|
-
if (condition) { yield value; }`)};import{Buffer as EVe}from"buffer";import{StringDecoder as vVe}from"string_decoder";var IR=(t,e,r)=>{if(r)return;if(t)return{transform:TVe.bind(void 0,new TextEncoder)};let n=new vVe(e);return{transform:bVe.bind(void 0,n),final:wVe.bind(void 0,n)}},TVe=function*(t,e){EVe.isBuffer(e)?yield ha(e):typeof e=="string"?yield t.encode(e):yield e},bVe=function*(t,e){yield hr(e)?t.write(e):e},wVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Lae}from"util";var UU=Lae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),PR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xVe}=e[r];for await(let i of n(t))yield*PR(i,e,r+1)},Uae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*AVe(r,Number(e),t)},AVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*PR(n,r,e+1)},Fae=Lae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),xVe=function*(t){yield t};var FU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},zae=(t,e)=>[...e.flatMap(r=>[...Bu(r,t,0)]),...Ky(t)],Bu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=CVe}=e[r];for(let i of n(t))yield*Bu(i,e,r+1)},Ky=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*RVe(r,Number(e),t)},RVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Bu(n,r,e+1)},CVe=function*(t){yield t};var zU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Bae(t,s,o),l=ju(e),u=ju(r),d=l?UU.bind(void 0,PR,a):FU.bind(void 0,Bu),f=l||u?UU.bind(void 0,Uae,a):FU.bind(void 0,Ky),p=l||u?Fae.bind(void 0,a):void 0;return{stream:new IVe({writableObjectMode:n,writableHighWaterMark:jae(n),readableObjectMode:i,readableHighWaterMark:jae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},OR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Bae(s,r,a);t=zae(c,t)}return t},Bae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Mae(n,a)},IR(r,s,n),CR(r,o,n,c),{transform:t,final:e},{transform:Dae(i,a)},kae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var qae=(t,e)=>{for(let r of PVe(t))OVe(t,r,e)},PVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),OVe=(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 ${$c[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>NVe(a,n));r.input=Fy(s)},NVe=(t,e)=>{let r=OR(t,e,"utf8",!0);return kVe(r),Fy(r)},kVe=t=>{let e=t.find(r=>typeof r!="string"&&!hr(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 LVe,appendFileSync as UVe}from"fs";var NR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&kp(r,n)&&!ii.has(e)&&MVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&DVe.has(o))||t.every(({type:i})=>$i.has(i))),MVe=t=>t===1||t===2,DVe=new Set(["pipe","overlapped"]),Gae=async(t,e,r,n)=>{for await(let i of t)$Ve(e)||Hae(i,r,n)},Vae=(t,e,r)=>{for(let n of t)Hae(n,e,r)},$Ve=t=>t._readableState.pipes.length>0,Hae=(t,e,r)=>{let n=Hx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Wae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>FVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},FVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Yse(t,o,d),p=ha(f),{stdioItems:h,objectMode:m}=e[r],g=zVe([p],h,c,n),{serializedResult:_,finalResult:y=_}=jVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});BVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?y:void 0;try{return n.error===void 0&&qVe(_,h,i),w}catch(b){return n.error=b,w}},zVe=(t,e,r,n)=>{try{return OR(t,e,r,!1)}catch(i){return n.error=i,t}},jVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Fy(t)};let s=cie(t,r);return n[o]?{serializedResult:s,finalResult:LU(s,!i[o],e)}:{serializedResult:s}},BVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!NR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=LU(t,!1,s);try{Vae(a,e,n)}catch(c){r.error??=c}},qVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>xR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?UVe(n,t):(r.add(o),LVe(n,t))}};var Yae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_a(e,r,"all")]:Array.isArray(e)?[_a(t,r,"all"),...e]:hr(t)&&hr(e)?H1([t,e]):`${t}${e}`};import{once as jU}from"events";var Kae=async(t,e)=>{let[r,n]=await GVe(t);return e.isForcefullyTerminated??=!1,[r,n]},GVe=async t=>{let[e,r]=await Promise.allSettled([jU(t,"spawn"),jU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Zae(t):r.value},Zae=async t=>{try{return await jU(t,"exit")}catch{return Zae(t)}},Jae=async t=>{let[e,r]=await t;if(!VVe(e,r)&&BU(e,r))throw new yo;return[e,r]},VVe=(t,e)=>t===void 0&&e===void 0,BU=(t,e)=>t!==0||e!==null;var Xae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=HVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Wse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},HVe=(t,e,r)=>t!==void 0?t:BU(e,r)?new yo:void 0;var Qae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=YVe(t,e,r),d=JVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return qp(d,c,l)},YVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Yx(t,e,r),a=KVe(r),{file:c,commandArguments:l,options:u}=hR(t,e,a);ZVe(u);let d=Iae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ZVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&kR("ipcInput"),t&&kR("ipc: true"),r&&kR("detached: true"),n&&kR("cancelSignal")},kR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},JVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=XVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Xae(c,r),{output:h,error:m=l}=Wae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((y,w)=>_a(y,r,w)),_=_a(Yae(h,r),r,"all");return e4e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},XVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{qae(o,r);let a=QVe(r);return WVe(...mR(t,e,a))}catch(a){return Bp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},QVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:TR(e)}),e4e=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?bR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Yy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as jHe}from"events";import{spawn as BHe}from"child_process";import ice from"process";import{once as qU,on as t4e}from"events";var ece=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>($p({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cR(t)}),r4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),r4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{iR(e,i);let o=Dc(t,e,r),s=new AbortController;try{return await Promise.race([n4e(o,n,s),i4e(o,r,s),o4e(o,r,s)])}catch(a){throw Lp(t),a}finally{s.abort(),oR(e,i)}},n4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await qU(t,"message",{signal:r});return n}for await(let[n]of t4e(t,"message",{signal:r}))if(e(n))return n},i4e=async(t,e,{signal:r})=>{await qU(t,"disconnect",{signal:r}),zoe(e)},o4e=async(t,e,{signal:r})=>{let[n]=await qU(t,"strict:error",{signal:r});throw tR(n,e)};import{once as rce,on as s4e}from"events";var nce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>GU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),GU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{$p({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cR(t)}),iR(e,o);let s=Dc(t,e,r),a=new AbortController,c={};return a4e(t,s,a),c4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),l4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},a4e=async(t,e,r)=>{try{await rce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},c4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rce(t,"strict:error",{signal:r.signal});n.error=tR(i,e),r.abort()}catch{}},l4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of s4e(r,"message",{signal:o.signal}))tce(s),yield c}catch{tce(s)}finally{o.abort(),oR(e,a),n||Lp(t),i&&await t}},tce=({error:t})=>{if(t)throw t};var oce=(t,{ipc:e})=>{Object.assign(t,ace(t,!1,e))},sce=()=>{let t=ice,e=!0,r=ice.channel!==void 0;return{...ace(t,e,r),getCancelSignal:pse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ace=(t,e,r)=>({sendMessage:fR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as u4e}from"child_process";import{PassThrough as d4e,Readable as f4e,Writable as p4e,Duplex as h4e}from"stream";var cce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{MU(n);let a=new u4e;m4e(a,n),Object.assign(a,{readable:g4e,writable:_4e,duplex:y4e});let c=Bp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=S4e(c,s,i);return{subprocess:a,promise:l}},m4e=(t,e)=>{let r=Zy(),n=Zy(),i=Zy(),o=Array.from({length:e.length-3},Zy),s=Zy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Zy=()=>{let t=new d4e;return t.end(),t},g4e=()=>new f4e({read(){}}),_4e=()=>new p4e({write(){}}),y4e=()=>new h4e({read(){},write(){}}),S4e=async(t,e,r)=>qp(t,e,r);import{createReadStream as lce,createWriteStream as uce}from"fs";import{Buffer as E4e}from"buffer";import{Readable as Jy,Writable as v4e,Duplex as T4e}from"stream";var fce=(t,e)=>RR(b4e,t,e,!1),Xy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$c[t]}.`)},dce={fileNumber:Xy,generator:zU,asyncGenerator:zU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:T4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},b4e={input:{...dce,fileUrl:({value:t})=>({stream:lce(t)}),filePath:({value:{file:t}})=>({stream:lce(t)}),webStream:({value:t})=>({stream:Jy.fromWeb(t)}),iterable:({value:t})=>({stream:Jy.from(t)}),asyncIterable:({value:t})=>({stream:Jy.from(t)}),string:({value:t})=>({stream:Jy.from(t)}),uint8Array:({value:t})=>({stream:Jy.from(E4e.from(t))})},output:{...dce,fileUrl:({value:t})=>({stream:uce(t)}),filePath:({value:{file:t,append:e}})=>({stream:uce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:v4e.fromWeb(t)}),iterable:Xy,asyncIterable:Xy,string:Xy,uint8Array:Xy}};import{on as w4e,once as pce}from"events";import{PassThrough as A4e,getDefaultHighWaterMark as x4e}from"stream";import{finished as gce}from"stream/promises";function qu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)HU(i);let e=t.some(({readableObjectMode:i})=>i),r=R4e(t,e),n=new VU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var R4e=(t,e)=>{if(t.length===0)return x4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},VU=class extends A4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(HU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=C4e(this,this.#e,this.#o);let r=O4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(HU(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)}},C4e=async(t,e,r)=>{MR(t,hce);let n=new AbortController;try{await Promise.race([I4e(t,n),P4e(t,e,r,n)])}finally{n.abort(),MR(t,-hce)}},I4e=async(t,{signal:e})=>{try{await gce(t,{signal:e,cleanup:!0})}catch(r){throw _ce(t,r),r}},P4e=async(t,e,r,{signal:n})=>{for await(let[i]of w4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},HU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},O4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{MR(t,mce);let a=new AbortController;try{await Promise.race([N4e(o,e,a),k4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),M4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),MR(t,-mce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?WU(t):D4e(t))},N4e=async(t,e,{signal:r})=>{try{await t,r.aborted||WU(e)}catch(n){r.aborted||_ce(e,n)}},k4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await gce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;yce(s)?i.add(e):Sce(t,s)}},M4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await pce(t,i,{signal:o}),!t.readable)return pce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},D4e=t=>{t.writable&&t.end()},_ce=(t,e)=>{yce(e)?WU(t):Sce(t,e)},yce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",WU=t=>{(t.readable||t.writable)&&t.destroy()},Sce=(t,e)=>{t.destroyed||(t.once("error",$4e),t.destroy(e))},$4e=()=>{},MR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hce=2,mce=1;import{finished as Ece}from"stream/promises";var Vp=(t,e)=>{t.pipe(e),L4e(t,e),U4e(t,e)},L4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ece(t,{cleanup:!0,readable:!0,writable:!1})}catch{}YU(e)}},YU=t=>{t.writable&&t.end()},U4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ece(e,{cleanup:!0,readable:!1,writable:!0})}catch{}KU(t)}},KU=t=>{t.readable&&t.destroy()};var vce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>$i.has(c)))F4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!$i.has(c)))j4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:qu(o);Vp(s,i)}},F4e=(t,e,r,n)=>{r==="output"?Vp(t.stdio[n],e):Vp(e,t.stdio[n]);let i=z4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},z4e=["stdin","stdout","stderr"],j4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;B4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},B4e=(t,{signal:e})=>{_o(t)&&Fu(t,q4e,e)},q4e=2;import{addAbortListener as H4e}from"events";var Gu=[];Gu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Gu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Gu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var DR=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",ZU=Symbol.for("signal-exit emitter"),JU=globalThis,G4e=Object.defineProperty.bind(Object),XU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(JU[ZU])return JU[ZU];G4e(JU,ZU,{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 o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},$R=class{},V4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),QU=class extends $R{onExit(){return()=>{}}load(){}unload(){}},eF=class extends $R{#e=tF.platform==="win32"?"SIGINT":"SIGHUP";#r=new XU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Gu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!DR(this.#t))return()=>{};this.#s===!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.#s){this.#s=!0,this.#r.count+=1;for(let e of Gu)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.#s&&(this.#s=!1,Gu.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.#o,this.#r.count-=1)}#a(e){return DR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&DR(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)}},tF=globalThis.process,{onExit:Tce,load:J1t,unload:X1t}=V4e(DR(tF)?new eF(tF):new QU);var bce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Tce(()=>{t.kill()});H4e(n,()=>{i()})};var Ace=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Wx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=W4e(r,n,i),{sourceStream:d,sourceError:f}=K4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},W4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Y4e(t,e,...r),a=nR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Y4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(wce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||G1(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,o,s]=Lx(r,...n);return{destination:e(wce)(i,o,s),pipeOptions:s}}if(fs.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}`)},wce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),K4e=(t,e)=>{try{return{sourceStream:Up(t,e)}}catch(r){return{sourceError:r}}};var Rce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Z4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw rF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Z4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return KU(t),n;if(e!==void 0)return YU(r),e},rF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Bp({error:t,command:xce,escapedCommand:xce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),xce="source.pipe(destination)";var Cce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as J4e}from"stream/promises";var Ice=(t,e,r)=>{let n=LR.has(e)?Q4e(t,e):X4e(t,e);return Fu(t,tHe,r.signal),Fu(e,rHe,r.signal),eHe(e),n},X4e=(t,e)=>{let r=qu([t]);return Vp(r,e),LR.set(e,r),r},Q4e=(t,e)=>{let r=LR.get(e);return r.add(t),r},eHe=async t=>{try{await J4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}LR.delete(t)},LR=new WeakMap,tHe=2,rHe=1;import{aborted as nHe}from"util";var Pce=(t,e)=>t===void 0?[]:[iHe(t,e)],iHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await nHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw rF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var UR=(t,...e)=>{if(Xt(e[0]))return UR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ace(t,...e),i=oHe({...n,destination:r});return i.pipe=UR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},oHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=sHe(t,i);Rce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Ice(e,o,d);return await Promise.race([Cce(u),...Pce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},sHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pHe}from"timers/promises";import{on as aHe}from"events";import{getDefaultHighWaterMark as cHe}from"stream";var FR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return lHe(e,s),Nce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},lHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},nF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;uHe(e,s,t);let a=t.readableObjectMode&&!o;return Nce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},uHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=aHe(t,"data",{signal:e.signal,highWaterMark:Oce,highWatermark:Oce});return dHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},iF=cHe(!0),Oce=iF,dHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=fHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Bu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ky(a)}},fHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[IR(t,r,!e),CR(t,i,!n,{})].filter(Boolean);var kce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=hHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([mHe(t),d]);return}let f=DU(c,r),p=nF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([gHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},hHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!NR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=nF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Gae(a,t,r,o)},mHe=async t=>{await pHe(),t.readableFlowing===null&&t.resume()},gHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await SR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await ER(r,{maxBuffer:o})):await jp(r,{maxBuffer:o})}catch(a){return Mce(Gse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},oF=async t=>{try{return await t}catch(e){return Mce(e)}},Mce=({bufferedData:t})=>sie(t)?new Uint8Array(t):t;import{finished as _He}from"stream/promises";var Qy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=yHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],_He(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||vHe(a,e,r,n)}finally{s.abort()}},yHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&SHe(t,r,n),n},SHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{EHe(e,r),n.call(t,...i)}},EHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},vHe=(t,e,r,n)=>{if(!THe(t,e,r,n))throw t},THe=(t,e,r,n=!0)=>r.propagating?Dce(t)||zR(t):(r.propagating=!0,sF(r,e)===n?Dce(t):zR(t)),sF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Dce=t=>t?.code==="EPIPE";var $ce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>aF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),aF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Qy(t,e,l);if(sF(l,e)){await u;return}let[d]=await Promise.all([kce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Lce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qu([t,e].filter(Boolean)):void 0,Uce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>aF({...bHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:wHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),bHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},wHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as AHe}from"events";var Fce=t=>kp(t,"ipc"),zce=(t,e)=>{let r=Hx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var jce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Fce(o),a=ma(e,"ipc"),c=ma(r,"ipc");for await(let l of GU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Vse(t,i,c),i.push(l)),s&&zce(l,o);return i},Bce=async(t,e)=>(await Promise.allSettled([t]),e);var qce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let y=Kae(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:y,propagating:!1},b=$ce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),T=Uce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),x=[],I=jce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),P=xHe(m,t,w),N=RHe(h,w);try{return await Promise.race([Promise.all([{},Jae(y),Promise.all(b),T,I,bse(t,d),...P,...N]),g,CHe(t,_),...yse(t,o,f,_),...Foe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...gse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},y,Promise.all(b.map(v=>oF(v))),oF(T),Bce(I,x),Promise.allSettled(P),Promise.allSettled(N)])}},xHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Qy(n,i,r)),RHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Eo(o,{checkOpen:!1})&&!_o(o)).map(({type:i,value:o,stream:s=o})=>Qy(s,n,e,{isSameDirection:$i.has(i),stopOnExit:i==="native"}))),CHe=async(t,{signal:e})=>{let[r]=await AHe(t,"error",{signal:e});throw r};var Gce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Hp=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 IHe}from"stream";import{callbackify as PHe}from"util";import{finished as Vce}from"stream/promises";var cF=async t=>{if(t!==void 0)try{await lF(t)}catch{}},Hce=async t=>{if(t!==void 0)try{await uF(t)}catch{}},lF=async t=>{await Vce(t,{cleanup:!0,readable:!1,writable:!0})},uF=async t=>{await Vce(t,{cleanup:!0,readable:!0,writable:!1})},jR=async(t,e)=>{if(await t,e)throw e},BR=(t,e,r)=>{r&&!zR(r)?t.destroy(r):e&&t.destroy()};var Wce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=dF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=fF(a,s),{read:f,onStdoutDataDone:p}=pF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new IHe({read:f,destroy:PHe(mF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return hF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},dF=(t,e,r)=>{let n=Up(t,e),i=eS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},fF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:iF},pF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=FR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){OHe(this,s,o)},onStdoutDataDone:o}},OHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},hF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await uF(t),await n,await cF(i),await e,r.readable&&r.push(null)}catch(o){await cF(i),Yce(r,o)}},mF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Hp(r,e)&&(Yce(t,n),await jR(e,n))},Yce=(t,e)=>{BR(t,t.readable,e)};import{Writable as NHe}from"stream";import{callbackify as Kce}from"util";var Zce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=gF(t,r,e),s=new NHe({..._F(n,t,i),destroy:Kce(SF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return yF(n,s),s},gF=(t,e,r)=>{let n=nR(t,e),i=eS(r,n,"writableFinal"),o=eS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},_F=(t,e,r)=>({write:kHe.bind(void 0,t),final:Kce(MHe.bind(void 0,t,e,r))}),kHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},MHe=async(t,e,r)=>{await Hp(r,e)&&(t.writable&&t.end(),await e)},yF=async(t,e,r)=>{try{await lF(t),e.writable&&e.end()}catch(n){await Hce(r),Jce(e,n)}},SF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Hp(r,e),await Hp(n,e)&&(Jce(t,i),await jR(e,i))},Jce=(t,e)=>{BR(t,t.writable,e)};import{Duplex as DHe}from"stream";import{callbackify as $He}from"util";var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=dF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=gF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=fF(c,a),{read:g,onStdoutDataDone:_}=pF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),y=new DHe({read:g,..._F(u,t,d),destroy:$He(LHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return hF({subprocessStdout:c,onStdoutDataDone:_,readable:y,subprocess:t,subprocessStdin:u}),yF(u,y,c),y},LHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([mF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),SF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var EF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=Up(t,r),a=FR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return UHe(a,s,t)},UHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qce=(t,{encoding:e})=>{let r=Gce();t.readable=Wce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Zce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=EF.bind(void 0,t,e),t[Symbol.asyncIterator]=EF.bind(void 0,t,e,{})};var ele=(t,e)=>{for(let[r,n]of zHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},FHe=(async()=>{})().constructor.prototype,zHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(FHe,t)]);var tle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=qHe(t,e,r),{subprocess:f,promise:p}=VHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=UR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ele(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},qHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Yx(t,e,r),{file:a,commandArguments:c,options:l}=hR(t,e,r),u=GHe(l),d=fce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},GHe=({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}},VHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=BHe(...mR(t,e,r))}catch(h){return cce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;jHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vce(c,a,l),bce(c,r,l);let d={},f=ds();c.kill=Loe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Lce(c,r),Qce(c,r),oce(c,r);let p=HHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},HHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await qce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((b,T)=>_a(b,e,T)),y=_a(m,e,"all"),w=WHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:y,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return qp(w,n,e)},WHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Yy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):bR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var qR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,YHe(n,t[n],i)]));return{...t,...r}},YHe=(t,e,r)=>KHe.has(t)&&Xt(e)&&Xt(r)?{...e,...r}:r,KHe=new Set(["env",...Z1]);var Lc=(t,e,r,n)=>{let i=(s,a,c)=>Lc(s,a,r,c),o=(...s)=>ZHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},ZHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Xt(o))return i(t,qR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=JHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Qae(a,c,l):tle(a,c,l,i)},JHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=fie(e)?pie(e,r):[e,...r],[s,a,c]=Lx(...o),l=qR(qR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var rle=({file:t,commandArguments:e})=>ile(t,e),nle=({file:t,commandArguments:e})=>({...ile(t,e),isSync:!0}),ile=(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]=XHe(t);return{file:r,commandArguments:n}},XHe=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(QHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},QHe=/ +/g;var ole=(t,e,r)=>{t.sync=e(e6e,r),t.s=t.sync},sle=({options:t})=>ale(t),e6e=({options:t})=>({...ale(t),isSync:!0}),ale=t=>({options:{...t6e(t),...t}}),t6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},cle={preferLocal:!0};var lle=Lc(()=>({})),jzt=Lc(()=>({isSync:!0})),ule=Lc(rle),Bzt=Lc(nle),qzt=Lc(Ese),Gzt=Lc(sle,{},cle,ole),{sendMessage:Vzt,getOneMessage:Hzt,getEachMessage:Wzt,getCancelSignal:Yzt}=sce();var dle=!1,fle,r6e=t=>{fle??=t},ple=t=>{dle=!0,r6e(t)},oi=()=>dle,Uc=()=>fle,hle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tS=null,mle=t=>(tS&&tS.destroy(),tS=new Li({totalAllowedTime:t}),tS),gle=()=>tS;var Li=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&&oi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Rx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{G.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};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 _le={name:"@netlify/agent-runner-cli",type:"module",version:"1.194.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"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.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.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var s6e=i6e(import.meta.url),a6e=ya.dirname(s6e),c6e=o6e(import.meta.url),Wp=ne("shell"),vF=new Set,yle={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=l6e(e,r),o={...yle,...i},s=lle(t,n,o);Ele(s,o),ble(s);let a=r?.idleTimeout;return a&&a>0&&Tle(s,a),s},Sle=(t,e)=>{let r={...yle,...e},n=ule(t,r);return Ele(n,r),ble(n),e?.idleTimeout&&e.idleTimeout>0&&Tle(n,e.idleTimeout),n},l6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ele=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Iy).pipe(ms.stdout),t.stderr?.pipe(new Iy).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},TF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Wp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Wp.error("Error killing process:",r),!1}},vle=t=>TF(t,"SIGKILL"),Tle=(t,e)=>{let r=null,n=()=>{Wp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),TF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wp.log(`Force killing idle process ${t.pid}`),vle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},ble=t=>{vF.add(t);let e=gle();if(e){let r=e.onTimesUp(()=>{Wp.log(`Global timer expired, killing process ${t.pid}`),TF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wp.log(`Force killing process ${t.pid} after timeout`),vle(t))},5e3)});t.on("exit",()=>{vF.delete(t),r()}),t.on("error",()=>{vF.delete(t),r()})}};function gs(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=c6e.resolve(_le.name),o=ya.dirname(i);for(;o!==ya.dirname(o);){let s=ya.dirname(o);if(ya.basename(s)==="node_modules"){let a=ya.join(s,".bin",e);if(GR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=ya.join(ms.env.NODE_PATH,".bin",e);if(GR.existsSync(i))return i}let r=ya.join(t,"node_modules",".bin",e);if(GR.existsSync(r))return r;let n=ya.join(a6e,"..","node_modules",".bin",e);if(GR.existsSync(n))return n}var wle=ne("repo"),Cle="runner-diffs-",WR=t=>`${Cle}${t}-`,Ile=async t=>{let e=Rle.tmpdir(),r;try{r=await VR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Cle)&&!n.startsWith(WR(t))).map(n=>VR.rm(HR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Qt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),YR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{wle.info("Getting runner diffs");let n=await xF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=CF(o);await _6e(l,r)}wle.info("Changes after processing"),await AF(r);let s=await rS(o,r);if(await wF(s,r),i=await h6e(r),!i)return{hasChanges:!1,ignored:s};await Qt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await VR.mkdtemp(HR.join(Rle.tmpdir(),WR(t.sessionId))),c=await bF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await f6e(r),c.hasChanges&&G.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},bF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=HR.join(e,h);await Qt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:y}=await VR.stat(g);return{path:g,size:y}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await xle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await xle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ale=async t=>{let e=u6e("sha256");for await(let r of d6e(t))e.update(r);return e.digest("hex")},xle=async(t,e)=>t.size===e.size&&await Ale(t.path)===await Ale(e.path),f6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qt(["reset","--soft","HEAD~1"],{cwd:t})},wF=async(t=[],e=process.cwd())=>{await Qt(["add",".",...t],{cwd:e})},AF=async(t=process.cwd())=>{let e=await Qt(["status","-s"],{cwd:t});return String(e.stdout??"")},Ple=/.. (.+)?\.log$/,p6e=[Ple],xF=async(t=process.cwd())=>{let e=await AF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
145
|
+
if (condition) { yield value; }`)};import{Buffer as EVe}from"buffer";import{StringDecoder as vVe}from"string_decoder";var IR=(t,e,r)=>{if(r)return;if(t)return{transform:TVe.bind(void 0,new TextEncoder)};let n=new vVe(e);return{transform:bVe.bind(void 0,n),final:wVe.bind(void 0,n)}},TVe=function*(t,e){EVe.isBuffer(e)?yield ha(e):typeof e=="string"?yield t.encode(e):yield e},bVe=function*(t,e){yield hr(e)?t.write(e):e},wVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Lae}from"util";var UU=Lae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),PR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xVe}=e[r];for await(let i of n(t))yield*PR(i,e,r+1)},Uae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*AVe(r,Number(e),t)},AVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*PR(n,r,e+1)},Fae=Lae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),xVe=function*(t){yield t};var FU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},zae=(t,e)=>[...e.flatMap(r=>[...Bu(r,t,0)]),...Ky(t)],Bu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=CVe}=e[r];for(let i of n(t))yield*Bu(i,e,r+1)},Ky=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*RVe(r,Number(e),t)},RVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Bu(n,r,e+1)},CVe=function*(t){yield t};var zU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Bae(t,s,o),l=ju(e),u=ju(r),d=l?UU.bind(void 0,PR,a):FU.bind(void 0,Bu),f=l||u?UU.bind(void 0,Uae,a):FU.bind(void 0,Ky),p=l||u?Fae.bind(void 0,a):void 0;return{stream:new IVe({writableObjectMode:n,writableHighWaterMark:jae(n),readableObjectMode:i,readableHighWaterMark:jae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},OR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Bae(s,r,a);t=zae(c,t)}return t},Bae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Mae(n,a)},IR(r,s,n),CR(r,o,n,c),{transform:t,final:e},{transform:Dae(i,a)},kae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var qae=(t,e)=>{for(let r of PVe(t))OVe(t,r,e)},PVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),OVe=(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 ${$c[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>NVe(a,n));r.input=Fy(s)},NVe=(t,e)=>{let r=OR(t,e,"utf8",!0);return kVe(r),Fy(r)},kVe=t=>{let e=t.find(r=>typeof r!="string"&&!hr(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 LVe,appendFileSync as UVe}from"fs";var NR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&kp(r,n)&&!ii.has(e)&&MVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&DVe.has(o))||t.every(({type:i})=>$i.has(i))),MVe=t=>t===1||t===2,DVe=new Set(["pipe","overlapped"]),Gae=async(t,e,r,n)=>{for await(let i of t)$Ve(e)||Hae(i,r,n)},Vae=(t,e,r)=>{for(let n of t)Hae(n,e,r)},$Ve=t=>t._readableState.pipes.length>0,Hae=(t,e,r)=>{let n=Hx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Wae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>FVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},FVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Yse(t,o,d),p=ha(f),{stdioItems:h,objectMode:m}=e[r],g=zVe([p],h,c,n),{serializedResult:_,finalResult:y=_}=jVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});BVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?y:void 0;try{return n.error===void 0&&qVe(_,h,i),w}catch(b){return n.error=b,w}},zVe=(t,e,r,n)=>{try{return OR(t,e,r,!1)}catch(i){return n.error=i,t}},jVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Fy(t)};let s=cie(t,r);return n[o]?{serializedResult:s,finalResult:LU(s,!i[o],e)}:{serializedResult:s}},BVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!NR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=LU(t,!1,s);try{Vae(a,e,n)}catch(c){r.error??=c}},qVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>xR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?UVe(n,t):(r.add(o),LVe(n,t))}};var Yae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_a(e,r,"all")]:Array.isArray(e)?[_a(t,r,"all"),...e]:hr(t)&&hr(e)?H1([t,e]):`${t}${e}`};import{once as jU}from"events";var Kae=async(t,e)=>{let[r,n]=await GVe(t);return e.isForcefullyTerminated??=!1,[r,n]},GVe=async t=>{let[e,r]=await Promise.allSettled([jU(t,"spawn"),jU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Zae(t):r.value},Zae=async t=>{try{return await jU(t,"exit")}catch{return Zae(t)}},Jae=async t=>{let[e,r]=await t;if(!VVe(e,r)&&BU(e,r))throw new yo;return[e,r]},VVe=(t,e)=>t===void 0&&e===void 0,BU=(t,e)=>t!==0||e!==null;var Xae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=HVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Wse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},HVe=(t,e,r)=>t!==void 0?t:BU(e,r)?new yo:void 0;var Qae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=YVe(t,e,r),d=JVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return qp(d,c,l)},YVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Yx(t,e,r),a=KVe(r),{file:c,commandArguments:l,options:u}=hR(t,e,a);ZVe(u);let d=Iae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ZVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&kR("ipcInput"),t&&kR("ipc: true"),r&&kR("detached: true"),n&&kR("cancelSignal")},kR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},JVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=XVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Xae(c,r),{output:h,error:m=l}=Wae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((y,w)=>_a(y,r,w)),_=_a(Yae(h,r),r,"all");return e4e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},XVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{qae(o,r);let a=QVe(r);return WVe(...mR(t,e,a))}catch(a){return Bp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},QVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:TR(e)}),e4e=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?bR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Yy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as jHe}from"events";import{spawn as BHe}from"child_process";import ice from"process";import{once as qU,on as t4e}from"events";var ece=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>($p({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cR(t)}),r4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),r4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{iR(e,i);let o=Dc(t,e,r),s=new AbortController;try{return await Promise.race([n4e(o,n,s),i4e(o,r,s),o4e(o,r,s)])}catch(a){throw Lp(t),a}finally{s.abort(),oR(e,i)}},n4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await qU(t,"message",{signal:r});return n}for await(let[n]of t4e(t,"message",{signal:r}))if(e(n))return n},i4e=async(t,e,{signal:r})=>{await qU(t,"disconnect",{signal:r}),zoe(e)},o4e=async(t,e,{signal:r})=>{let[n]=await qU(t,"strict:error",{signal:r});throw tR(n,e)};import{once as rce,on as s4e}from"events";var nce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>GU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),GU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{$p({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cR(t)}),iR(e,o);let s=Dc(t,e,r),a=new AbortController,c={};return a4e(t,s,a),c4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),l4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},a4e=async(t,e,r)=>{try{await rce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},c4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rce(t,"strict:error",{signal:r.signal});n.error=tR(i,e),r.abort()}catch{}},l4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of s4e(r,"message",{signal:o.signal}))tce(s),yield c}catch{tce(s)}finally{o.abort(),oR(e,a),n||Lp(t),i&&await t}},tce=({error:t})=>{if(t)throw t};var oce=(t,{ipc:e})=>{Object.assign(t,ace(t,!1,e))},sce=()=>{let t=ice,e=!0,r=ice.channel!==void 0;return{...ace(t,e,r),getCancelSignal:pse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ace=(t,e,r)=>({sendMessage:fR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as u4e}from"child_process";import{PassThrough as d4e,Readable as f4e,Writable as p4e,Duplex as h4e}from"stream";var cce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{MU(n);let a=new u4e;m4e(a,n),Object.assign(a,{readable:g4e,writable:_4e,duplex:y4e});let c=Bp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=S4e(c,s,i);return{subprocess:a,promise:l}},m4e=(t,e)=>{let r=Zy(),n=Zy(),i=Zy(),o=Array.from({length:e.length-3},Zy),s=Zy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Zy=()=>{let t=new d4e;return t.end(),t},g4e=()=>new f4e({read(){}}),_4e=()=>new p4e({write(){}}),y4e=()=>new h4e({read(){},write(){}}),S4e=async(t,e,r)=>qp(t,e,r);import{createReadStream as lce,createWriteStream as uce}from"fs";import{Buffer as E4e}from"buffer";import{Readable as Jy,Writable as v4e,Duplex as T4e}from"stream";var fce=(t,e)=>RR(b4e,t,e,!1),Xy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$c[t]}.`)},dce={fileNumber:Xy,generator:zU,asyncGenerator:zU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:T4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},b4e={input:{...dce,fileUrl:({value:t})=>({stream:lce(t)}),filePath:({value:{file:t}})=>({stream:lce(t)}),webStream:({value:t})=>({stream:Jy.fromWeb(t)}),iterable:({value:t})=>({stream:Jy.from(t)}),asyncIterable:({value:t})=>({stream:Jy.from(t)}),string:({value:t})=>({stream:Jy.from(t)}),uint8Array:({value:t})=>({stream:Jy.from(E4e.from(t))})},output:{...dce,fileUrl:({value:t})=>({stream:uce(t)}),filePath:({value:{file:t,append:e}})=>({stream:uce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:v4e.fromWeb(t)}),iterable:Xy,asyncIterable:Xy,string:Xy,uint8Array:Xy}};import{on as w4e,once as pce}from"events";import{PassThrough as A4e,getDefaultHighWaterMark as x4e}from"stream";import{finished as gce}from"stream/promises";function qu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)HU(i);let e=t.some(({readableObjectMode:i})=>i),r=R4e(t,e),n=new VU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var R4e=(t,e)=>{if(t.length===0)return x4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},VU=class extends A4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(HU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=C4e(this,this.#e,this.#o);let r=O4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(HU(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)}},C4e=async(t,e,r)=>{MR(t,hce);let n=new AbortController;try{await Promise.race([I4e(t,n),P4e(t,e,r,n)])}finally{n.abort(),MR(t,-hce)}},I4e=async(t,{signal:e})=>{try{await gce(t,{signal:e,cleanup:!0})}catch(r){throw _ce(t,r),r}},P4e=async(t,e,r,{signal:n})=>{for await(let[i]of w4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},HU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},O4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{MR(t,mce);let a=new AbortController;try{await Promise.race([N4e(o,e,a),k4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),M4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),MR(t,-mce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?WU(t):D4e(t))},N4e=async(t,e,{signal:r})=>{try{await t,r.aborted||WU(e)}catch(n){r.aborted||_ce(e,n)}},k4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await gce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;yce(s)?i.add(e):Sce(t,s)}},M4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await pce(t,i,{signal:o}),!t.readable)return pce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},D4e=t=>{t.writable&&t.end()},_ce=(t,e)=>{yce(e)?WU(t):Sce(t,e)},yce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",WU=t=>{(t.readable||t.writable)&&t.destroy()},Sce=(t,e)=>{t.destroyed||(t.once("error",$4e),t.destroy(e))},$4e=()=>{},MR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hce=2,mce=1;import{finished as Ece}from"stream/promises";var Vp=(t,e)=>{t.pipe(e),L4e(t,e),U4e(t,e)},L4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ece(t,{cleanup:!0,readable:!0,writable:!1})}catch{}YU(e)}},YU=t=>{t.writable&&t.end()},U4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ece(e,{cleanup:!0,readable:!1,writable:!0})}catch{}KU(t)}},KU=t=>{t.readable&&t.destroy()};var vce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>$i.has(c)))F4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!$i.has(c)))j4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:qu(o);Vp(s,i)}},F4e=(t,e,r,n)=>{r==="output"?Vp(t.stdio[n],e):Vp(e,t.stdio[n]);let i=z4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},z4e=["stdin","stdout","stderr"],j4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;B4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},B4e=(t,{signal:e})=>{_o(t)&&Fu(t,q4e,e)},q4e=2;import{addAbortListener as H4e}from"events";var Gu=[];Gu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Gu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Gu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var DR=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",ZU=Symbol.for("signal-exit emitter"),JU=globalThis,G4e=Object.defineProperty.bind(Object),XU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(JU[ZU])return JU[ZU];G4e(JU,ZU,{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 o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},$R=class{},V4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),QU=class extends $R{onExit(){return()=>{}}load(){}unload(){}},eF=class extends $R{#e=tF.platform==="win32"?"SIGINT":"SIGHUP";#r=new XU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Gu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!DR(this.#t))return()=>{};this.#s===!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.#s){this.#s=!0,this.#r.count+=1;for(let e of Gu)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.#s&&(this.#s=!1,Gu.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.#o,this.#r.count-=1)}#a(e){return DR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&DR(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)}},tF=globalThis.process,{onExit:Tce,load:J1t,unload:X1t}=V4e(DR(tF)?new eF(tF):new QU);var bce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Tce(()=>{t.kill()});H4e(n,()=>{i()})};var Ace=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Wx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=W4e(r,n,i),{sourceStream:d,sourceError:f}=K4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},W4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Y4e(t,e,...r),a=nR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Y4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(wce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||G1(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,o,s]=Lx(r,...n);return{destination:e(wce)(i,o,s),pipeOptions:s}}if(fs.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}`)},wce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),K4e=(t,e)=>{try{return{sourceStream:Up(t,e)}}catch(r){return{sourceError:r}}};var Rce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Z4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw rF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Z4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return KU(t),n;if(e!==void 0)return YU(r),e},rF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Bp({error:t,command:xce,escapedCommand:xce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),xce="source.pipe(destination)";var Cce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as J4e}from"stream/promises";var Ice=(t,e,r)=>{let n=LR.has(e)?Q4e(t,e):X4e(t,e);return Fu(t,tHe,r.signal),Fu(e,rHe,r.signal),eHe(e),n},X4e=(t,e)=>{let r=qu([t]);return Vp(r,e),LR.set(e,r),r},Q4e=(t,e)=>{let r=LR.get(e);return r.add(t),r},eHe=async t=>{try{await J4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}LR.delete(t)},LR=new WeakMap,tHe=2,rHe=1;import{aborted as nHe}from"util";var Pce=(t,e)=>t===void 0?[]:[iHe(t,e)],iHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await nHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw rF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var UR=(t,...e)=>{if(Xt(e[0]))return UR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ace(t,...e),i=oHe({...n,destination:r});return i.pipe=UR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},oHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=sHe(t,i);Rce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Ice(e,o,d);return await Promise.race([Cce(u),...Pce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},sHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pHe}from"timers/promises";import{on as aHe}from"events";import{getDefaultHighWaterMark as cHe}from"stream";var FR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return lHe(e,s),Nce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},lHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},nF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;uHe(e,s,t);let a=t.readableObjectMode&&!o;return Nce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},uHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=aHe(t,"data",{signal:e.signal,highWaterMark:Oce,highWatermark:Oce});return dHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},iF=cHe(!0),Oce=iF,dHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=fHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Bu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ky(a)}},fHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[IR(t,r,!e),CR(t,i,!n,{})].filter(Boolean);var kce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=hHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([mHe(t),d]);return}let f=DU(c,r),p=nF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([gHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},hHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!NR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=nF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Gae(a,t,r,o)},mHe=async t=>{await pHe(),t.readableFlowing===null&&t.resume()},gHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await SR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await ER(r,{maxBuffer:o})):await jp(r,{maxBuffer:o})}catch(a){return Mce(Gse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},oF=async t=>{try{return await t}catch(e){return Mce(e)}},Mce=({bufferedData:t})=>sie(t)?new Uint8Array(t):t;import{finished as _He}from"stream/promises";var Qy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=yHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],_He(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||vHe(a,e,r,n)}finally{s.abort()}},yHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&SHe(t,r,n),n},SHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{EHe(e,r),n.call(t,...i)}},EHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},vHe=(t,e,r,n)=>{if(!THe(t,e,r,n))throw t},THe=(t,e,r,n=!0)=>r.propagating?Dce(t)||zR(t):(r.propagating=!0,sF(r,e)===n?Dce(t):zR(t)),sF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Dce=t=>t?.code==="EPIPE";var $ce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>aF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),aF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Qy(t,e,l);if(sF(l,e)){await u;return}let[d]=await Promise.all([kce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Lce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qu([t,e].filter(Boolean)):void 0,Uce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>aF({...bHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:wHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),bHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},wHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as AHe}from"events";var Fce=t=>kp(t,"ipc"),zce=(t,e)=>{let r=Hx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var jce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Fce(o),a=ma(e,"ipc"),c=ma(r,"ipc");for await(let l of GU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Vse(t,i,c),i.push(l)),s&&zce(l,o);return i},Bce=async(t,e)=>(await Promise.allSettled([t]),e);var qce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let y=Kae(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:y,propagating:!1},b=$ce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),T=Uce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),x=[],I=jce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),P=xHe(m,t,w),N=RHe(h,w);try{return await Promise.race([Promise.all([{},Jae(y),Promise.all(b),T,I,bse(t,d),...P,...N]),g,CHe(t,_),...yse(t,o,f,_),...Foe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...gse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},y,Promise.all(b.map(v=>oF(v))),oF(T),Bce(I,x),Promise.allSettled(P),Promise.allSettled(N)])}},xHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Qy(n,i,r)),RHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Eo(o,{checkOpen:!1})&&!_o(o)).map(({type:i,value:o,stream:s=o})=>Qy(s,n,e,{isSameDirection:$i.has(i),stopOnExit:i==="native"}))),CHe=async(t,{signal:e})=>{let[r]=await AHe(t,"error",{signal:e});throw r};var Gce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Hp=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 IHe}from"stream";import{callbackify as PHe}from"util";import{finished as Vce}from"stream/promises";var cF=async t=>{if(t!==void 0)try{await lF(t)}catch{}},Hce=async t=>{if(t!==void 0)try{await uF(t)}catch{}},lF=async t=>{await Vce(t,{cleanup:!0,readable:!1,writable:!0})},uF=async t=>{await Vce(t,{cleanup:!0,readable:!0,writable:!1})},jR=async(t,e)=>{if(await t,e)throw e},BR=(t,e,r)=>{r&&!zR(r)?t.destroy(r):e&&t.destroy()};var Wce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=dF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=fF(a,s),{read:f,onStdoutDataDone:p}=pF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new IHe({read:f,destroy:PHe(mF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return hF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},dF=(t,e,r)=>{let n=Up(t,e),i=eS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},fF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:iF},pF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=FR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){OHe(this,s,o)},onStdoutDataDone:o}},OHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},hF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await uF(t),await n,await cF(i),await e,r.readable&&r.push(null)}catch(o){await cF(i),Yce(r,o)}},mF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Hp(r,e)&&(Yce(t,n),await jR(e,n))},Yce=(t,e)=>{BR(t,t.readable,e)};import{Writable as NHe}from"stream";import{callbackify as Kce}from"util";var Zce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=gF(t,r,e),s=new NHe({..._F(n,t,i),destroy:Kce(SF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return yF(n,s),s},gF=(t,e,r)=>{let n=nR(t,e),i=eS(r,n,"writableFinal"),o=eS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},_F=(t,e,r)=>({write:kHe.bind(void 0,t),final:Kce(MHe.bind(void 0,t,e,r))}),kHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},MHe=async(t,e,r)=>{await Hp(r,e)&&(t.writable&&t.end(),await e)},yF=async(t,e,r)=>{try{await lF(t),e.writable&&e.end()}catch(n){await Hce(r),Jce(e,n)}},SF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Hp(r,e),await Hp(n,e)&&(Jce(t,i),await jR(e,i))},Jce=(t,e)=>{BR(t,t.writable,e)};import{Duplex as DHe}from"stream";import{callbackify as $He}from"util";var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=dF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=gF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=fF(c,a),{read:g,onStdoutDataDone:_}=pF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),y=new DHe({read:g,..._F(u,t,d),destroy:$He(LHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return hF({subprocessStdout:c,onStdoutDataDone:_,readable:y,subprocess:t,subprocessStdin:u}),yF(u,y,c),y},LHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([mF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),SF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var EF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=Up(t,r),a=FR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return UHe(a,s,t)},UHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qce=(t,{encoding:e})=>{let r=Gce();t.readable=Wce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Zce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=EF.bind(void 0,t,e),t[Symbol.asyncIterator]=EF.bind(void 0,t,e,{})};var ele=(t,e)=>{for(let[r,n]of zHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},FHe=(async()=>{})().constructor.prototype,zHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(FHe,t)]);var tle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=qHe(t,e,r),{subprocess:f,promise:p}=VHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=UR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ele(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},qHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Yx(t,e,r),{file:a,commandArguments:c,options:l}=hR(t,e,r),u=GHe(l),d=fce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},GHe=({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}},VHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=BHe(...mR(t,e,r))}catch(h){return cce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;jHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vce(c,a,l),bce(c,r,l);let d={},f=ds();c.kill=Loe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Lce(c,r),Qce(c,r),oce(c,r);let p=HHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},HHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await qce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((b,T)=>_a(b,e,T)),y=_a(m,e,"all"),w=WHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:y,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return qp(w,n,e)},WHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Yy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):bR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var qR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,YHe(n,t[n],i)]));return{...t,...r}},YHe=(t,e,r)=>KHe.has(t)&&Xt(e)&&Xt(r)?{...e,...r}:r,KHe=new Set(["env",...Z1]);var Lc=(t,e,r,n)=>{let i=(s,a,c)=>Lc(s,a,r,c),o=(...s)=>ZHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},ZHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Xt(o))return i(t,qR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=JHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Qae(a,c,l):tle(a,c,l,i)},JHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=fie(e)?pie(e,r):[e,...r],[s,a,c]=Lx(...o),l=qR(qR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var rle=({file:t,commandArguments:e})=>ile(t,e),nle=({file:t,commandArguments:e})=>({...ile(t,e),isSync:!0}),ile=(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]=XHe(t);return{file:r,commandArguments:n}},XHe=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(QHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},QHe=/ +/g;var ole=(t,e,r)=>{t.sync=e(e6e,r),t.s=t.sync},sle=({options:t})=>ale(t),e6e=({options:t})=>({...ale(t),isSync:!0}),ale=t=>({options:{...t6e(t),...t}}),t6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},cle={preferLocal:!0};var lle=Lc(()=>({})),jzt=Lc(()=>({isSync:!0})),ule=Lc(rle),Bzt=Lc(nle),qzt=Lc(Ese),Gzt=Lc(sle,{},cle,ole),{sendMessage:Vzt,getOneMessage:Hzt,getEachMessage:Wzt,getCancelSignal:Yzt}=sce();var dle=!1,fle,r6e=t=>{fle??=t},ple=t=>{dle=!0,r6e(t)},oi=()=>dle,Uc=()=>fle,hle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tS=null,mle=t=>(tS&&tS.destroy(),tS=new Li({totalAllowedTime:t}),tS),gle=()=>tS;var Li=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&&oi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Rx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{G.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};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 _le={name:"@netlify/agent-runner-cli",type:"module",version:"1.194.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.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.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var s6e=i6e(import.meta.url),a6e=ya.dirname(s6e),c6e=o6e(import.meta.url),Wp=ne("shell"),vF=new Set,yle={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=l6e(e,r),o={...yle,...i},s=lle(t,n,o);Ele(s,o),ble(s);let a=r?.idleTimeout;return a&&a>0&&Tle(s,a),s},Sle=(t,e)=>{let r={...yle,...e},n=ule(t,r);return Ele(n,r),ble(n),e?.idleTimeout&&e.idleTimeout>0&&Tle(n,e.idleTimeout),n},l6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ele=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Iy).pipe(ms.stdout),t.stderr?.pipe(new Iy).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},TF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Wp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Wp.error("Error killing process:",r),!1}},vle=t=>TF(t,"SIGKILL"),Tle=(t,e)=>{let r=null,n=()=>{Wp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),TF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wp.log(`Force killing idle process ${t.pid}`),vle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},ble=t=>{vF.add(t);let e=gle();if(e){let r=e.onTimesUp(()=>{Wp.log(`Global timer expired, killing process ${t.pid}`),TF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wp.log(`Force killing process ${t.pid} after timeout`),vle(t))},5e3)});t.on("exit",()=>{vF.delete(t),r()}),t.on("error",()=>{vF.delete(t),r()})}};function gs(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=c6e.resolve(_le.name),o=ya.dirname(i);for(;o!==ya.dirname(o);){let s=ya.dirname(o);if(ya.basename(s)==="node_modules"){let a=ya.join(s,".bin",e);if(GR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=ya.join(ms.env.NODE_PATH,".bin",e);if(GR.existsSync(i))return i}let r=ya.join(t,"node_modules",".bin",e);if(GR.existsSync(r))return r;let n=ya.join(a6e,"..","node_modules",".bin",e);if(GR.existsSync(n))return n}var wle=ne("repo"),Cle="runner-diffs-",WR=t=>`${Cle}${t}-`,Ile=async t=>{let e=Rle.tmpdir(),r;try{r=await VR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Cle)&&!n.startsWith(WR(t))).map(n=>VR.rm(HR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Qt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),YR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{wle.info("Getting runner diffs");let n=await xF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=CF(o);await _6e(l,r)}wle.info("Changes after processing"),await AF(r);let s=await rS(o,r);if(await wF(s,r),i=await h6e(r),!i)return{hasChanges:!1,ignored:s};await Qt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await VR.mkdtemp(HR.join(Rle.tmpdir(),WR(t.sessionId))),c=await bF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await f6e(r),c.hasChanges&&G.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},bF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=HR.join(e,h);await Qt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:y}=await VR.stat(g);return{path:g,size:y}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await xle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await xle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ale=async t=>{let e=u6e("sha256");for await(let r of d6e(t))e.update(r);return e.digest("hex")},xle=async(t,e)=>t.size===e.size&&await Ale(t.path)===await Ale(e.path),f6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qt(["reset","--soft","HEAD~1"],{cwd:t})},wF=async(t=[],e=process.cwd())=>{await Qt(["add",".",...t],{cwd:e})},AF=async(t=process.cwd())=>{let e=await Qt(["status","-s"],{cwd:t});return String(e.stdout??"")},Ple=/.. (.+)?\.log$/,p6e=[Ple],xF=async(t=process.cwd())=>{let e=await AF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
146
|
`).filter(i=>p6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},h6e=async(t=process.cwd())=>{try{return await Qt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},RF=async(t=process.cwd())=>{let{stdout:e}=await Qt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},m6e=1,g6e=async t=>{try{return await Qt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===m6e)return!1;throw e}},Ole=async(t=process.cwd())=>{if(!await g6e(t))return!0;let{stdout:e}=await Qt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Nle=async(t=process.cwd())=>{let{stdout:e}=await Qt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},rS=async(t,e=process.cwd())=>{t||=await AF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
147
147
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${HR.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Ple)?.[1];o&&n.push(`:!${o}.log`)}),n},kle=async(t=process.cwd())=>{await Qt(["reset","--hard","HEAD"],{cwd:t})},Mle=async(t=process.cwd())=>{let e=await Qt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
148
148
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},CF=t=>{let e=t.split(`
|